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))
43 ;; Avoid byte-compile warnings.
44 (defvar gnus-article-decoded-p)
45 (defvar gnus-decode-encoded-word-function)
49 (autoload 'gnus-cache-articles-in-group "gnus-cache"))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
54 (defcustom gnus-kill-summary-on-exit t
55 "*If non-nil, kill the summary buffer when you exit from it.
56 If nil, the summary will become a \"*Dead Summary*\" buffer, and
57 it will be killed sometime later."
58 :group 'gnus-summary-exit
61 (defcustom gnus-fetch-old-headers nil
62 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
63 If an unread article in the group refers to an older, already read (or
64 just marked as read) article, the old article will not normally be
65 displayed in the Summary buffer. If this variable is non-nil, Gnus
66 will attempt to grab the headers to the old articles, and thereby
67 build complete threads. If it has the value `some', only enough
68 headers to connect otherwise loose threads will be displayed. This
69 variable can also be a number. In that case, no more than that number
70 of old headers will be fetched. If it has the value `invisible', all
71 old headers will be fetched, but none will be displayed.
73 The server has to support NOV for any of this to work."
75 :type '(choice (const :tag "off" nil)
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-refer-thread-limit 200
81 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
82 If t, fetch all the available old headers."
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-summary-make-false-root 'adopt
88 "*nil means that Gnus won't gather loose threads.
89 If the root of a thread has expired or been read in a previous
90 session, the information necessary to build a complete thread has been
91 lost. Instead of having many small sub-threads from this original thread
92 scattered all over the summary buffer, Gnus can gather them.
94 If non-nil, Gnus will try to gather all loose sub-threads from an
95 original thread into one large thread.
97 If this variable is non-nil, it should be one of `none', `adopt',
100 If this variable is `none', Gnus will not make a false root, but just
101 present the sub-threads after another.
102 If this variable is `dummy', Gnus will create a dummy root that will
103 have all the sub-threads as children.
104 If this variable is `adopt', Gnus will make one of the \"children\"
105 the parent and mark all the step-children as such.
106 If this variable is `empty', the \"children\" are printed with empty
107 subject fields. (Or rather, they will be printed with a string
108 given by the `gnus-summary-same-subject' variable.)"
110 :type '(choice (const :tag "off" nil)
116 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
117 "*A regexp to match subjects to be excluded from loose thread gathering.
118 As loose thread gathering is done on subjects only, that means that
119 there can be many false gatherings performed. By rooting out certain
120 common subjects, gathering might become saner."
124 (defcustom gnus-summary-gather-subject-limit nil
125 "*Maximum length of subject comparisons when gathering loose threads.
126 Use nil to compare full subjects. Setting this variable to a low
127 number will help gather threads that have been corrupted by
128 newsreaders chopping off subject lines, but it might also mean that
129 unrelated articles that have subject that happen to begin with the
130 same few characters will be incorrectly gathered.
132 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
135 :type '(choice (const :tag "off" nil)
137 (sexp :menu-tag "on" t)))
139 (defcustom gnus-simplify-subject-functions nil
140 "List of functions taking a string argument that simplify subjects.
141 The functions are applied recursively.
143 Useful functions to put in this list include: `gnus-simplify-subject-re',
144 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
146 :type '(repeat function))
148 (defcustom gnus-simplify-ignored-prefixes nil
149 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
151 :type '(choice (const :tag "off" nil)
154 (defcustom gnus-build-sparse-threads nil
155 "*If non-nil, fill in the gaps in threads.
156 If `some', only fill in the gaps that are needed to tie loose threads
157 together. If `more', fill in all leaf nodes that Gnus can find. If
158 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
160 :type '(choice (const :tag "off" nil)
163 (sexp :menu-tag "all" t)))
165 (defcustom gnus-summary-thread-gathering-function
166 'gnus-gather-threads-by-subject
167 "*Function used for gathering loose threads.
168 There are two pre-defined functions: `gnus-gather-threads-by-subject',
169 which only takes Subjects into consideration; and
170 `gnus-gather-threads-by-references', which compared the References
171 headers of the articles to find matches."
173 :type '(radio (function-item gnus-gather-threads-by-subject)
174 (function-item gnus-gather-threads-by-references)
175 (function :tag "other")))
177 (defcustom gnus-summary-same-subject ""
178 "*String indicating that the current article has the same subject as the previous.
179 This variable will only be used if the value of
180 `gnus-summary-make-false-root' is `empty'."
181 :group 'gnus-summary-format
184 (defcustom gnus-summary-goto-unread t
185 "*If t, marking commands will go to the next unread article.
186 If `never', commands that usually go to the next unread article, will
187 go to the next article, whether it is read or not.
188 If nil, only the marking commands will go to the next (un)read article."
189 :group 'gnus-summary-marks
190 :link '(custom-manual "(gnus)Setting Marks")
191 :type '(choice (const :tag "off" nil)
193 (sexp :menu-tag "on" t)))
195 (defcustom gnus-summary-default-score 0
196 "*Default article score level.
197 All scores generated by the score files will be added to this score.
198 If this variable is nil, scoring will be disabled."
199 :group 'gnus-score-default
200 :type '(choice (const :tag "disable")
203 (defcustom gnus-summary-zcore-fuzz 0
204 "*Fuzziness factor for the zcore in the summary buffer.
205 Articles with scores closer than this to `gnus-summary-default-score'
207 :group 'gnus-summary-format
210 (defcustom gnus-simplify-subject-fuzzy-regexp nil
211 "*Strings to be removed when doing fuzzy matches.
212 This can either be a regular expression or list of regular expressions
213 that will be removed from subject strings if fuzzy subject
214 simplification is selected."
216 :type '(repeat regexp))
218 (defcustom gnus-show-threads t
219 "*If non-nil, display threads in summary mode."
223 (defcustom gnus-thread-hide-subtree nil
224 "*If non-nil, hide all threads initially.
225 If threads are hidden, you have to run the command
226 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
227 to expose hidden threads."
231 (defcustom gnus-thread-hide-killed t
232 "*If non-nil, hide killed threads automatically."
236 (defcustom gnus-thread-ignore-subject t
237 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
238 If nil, articles that have different subjects from their parents will
239 start separate threads."
243 (defcustom gnus-thread-operation-ignore-subject t
244 "*If non-nil, subjects will be ignored when doing thread commands.
245 This affects commands like `gnus-summary-kill-thread' and
246 `gnus-summary-lower-thread'.
248 If this variable is nil, articles in the same thread with different
249 subjects will not be included in the operation in question. If this
250 variable is `fuzzy', only articles that have subjects that are fuzzily
251 equal will be included."
253 :type '(choice (const :tag "off" nil)
257 (defcustom gnus-thread-indent-level 4
258 "*Number that says how much each sub-thread should be indented."
262 (defcustom gnus-auto-extend-newsgroup t
263 "*If non-nil, extend newsgroup forward and backward when requested."
264 :group 'gnus-summary-choose
267 (defcustom gnus-auto-select-first t
268 "*If nil, don't select the first unread article when entering a group.
269 If this variable is `best', select the highest-scored unread article
270 in the group. If t, select the first unread article.
272 This variable can also be a function to place point on a likely
273 subject line. Useful values include `gnus-summary-first-unread-subject',
274 `gnus-summary-first-unread-article' and
275 `gnus-summary-best-unread-article'.
277 If you want to prevent automatic selection of the first unread article
278 in some newsgroups, set the variable to nil in
279 `gnus-select-group-hook'."
280 :group 'gnus-group-select
281 :type '(choice (const :tag "none" nil)
283 (sexp :menu-tag "first" t)
284 (function-item gnus-summary-first-unread-subject)
285 (function-item gnus-summary-first-unread-article)
286 (function-item gnus-summary-best-unread-article)))
288 (defcustom gnus-auto-select-next t
289 "*If non-nil, offer to go to the next group from the end of the previous.
290 If the value is t and the next newsgroup is empty, Gnus will exit
291 summary mode and go back to group mode. If the value is neither nil
292 nor t, Gnus will select the following unread newsgroup. In
293 particular, if the value is the symbol `quietly', the next unread
294 newsgroup will be selected without any confirmation, and if it is
295 `almost-quietly', the next group will be selected without any
296 confirmation if you are located on the last article in the group.
297 Finally, if this variable is `slightly-quietly', the `Z n' command
298 will go to the next group without confirmation."
299 :group 'gnus-summary-maneuvering
300 :type '(choice (const :tag "off" nil)
302 (const almost-quietly)
303 (const slightly-quietly)
304 (sexp :menu-tag "on" t)))
306 (defcustom gnus-auto-select-same nil
307 "*If non-nil, select the next article with the same subject.
308 If there are no more articles with the same subject, go to
309 the first unread article."
310 :group 'gnus-summary-maneuvering
313 (defcustom gnus-summary-check-current nil
314 "*If non-nil, consider the current article when moving.
315 The \"unread\" movement commands will stay on the same line if the
316 current article is unread."
317 :group 'gnus-summary-maneuvering
320 (defcustom gnus-auto-center-summary t
321 "*If non-nil, always center the current summary buffer.
322 In particular, if `vertical' do only vertical recentering. If non-nil
323 and non-`vertical', do both horizontal and vertical recentering."
324 :group 'gnus-summary-maneuvering
325 :type '(choice (const :tag "none" nil)
327 (integer :tag "height")
328 (sexp :menu-tag "both" t)))
330 (defcustom gnus-show-all-headers nil
331 "*If non-nil, don't hide any headers."
332 :group 'gnus-article-hiding
333 :group 'gnus-article-headers
336 (defcustom gnus-summary-ignore-duplicates nil
337 "*If non-nil, ignore articles with identical Message-ID headers."
341 (defcustom gnus-single-article-buffer t
342 "*If non-nil, display all articles in the same buffer.
343 If nil, each group will get its own article buffer."
344 :group 'gnus-article-various
347 (defcustom gnus-break-pages t
348 "*If non-nil, do page breaking on articles.
349 The page delimiter is specified by the `gnus-page-delimiter'
351 :group 'gnus-article-various
354 (defcustom gnus-show-mime t
355 "*If non-nil, do mime processing of articles.
356 The articles will simply be fed to the function given by
357 `gnus-article-display-method-for-mime'."
358 :group 'gnus-article-mime
361 (defcustom gnus-move-split-methods nil
362 "*Variable used to suggest where articles are to be moved to.
363 It uses the same syntax as the `gnus-split-methods' variable."
364 :group 'gnus-summary-mail
365 :type '(repeat (choice (list :value (fun) function)
366 (cons :value ("" "") regexp (repeat string))
369 (defcustom gnus-unread-mark ? ;Whitespace
370 "*Mark used for unread articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-ticked-mark ?!
375 "*Mark used for ticked articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-dormant-mark ??
380 "*Mark used for dormant articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-del-mark ?r
385 "*Mark used for del'd articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-read-mark ?R
390 "*Mark used for read articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-expirable-mark ?E
395 "*Mark used for expirable articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-killed-mark ?K
400 "*Mark used for killed articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-souped-mark ?F
405 "*Mark used for killed articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-kill-file-mark ?X
410 "*Mark used for articles killed by kill files."
411 :group 'gnus-summary-marks
414 (defcustom gnus-low-score-mark ?Y
415 "*Mark used for articles with a low score."
416 :group 'gnus-summary-marks
419 (defcustom gnus-catchup-mark ?C
420 "*Mark used for articles that are caught up."
421 :group 'gnus-summary-marks
424 (defcustom gnus-replied-mark ?A
425 "*Mark used for articles that have been replied to."
426 :group 'gnus-summary-marks
429 (defcustom gnus-cached-mark ?*
430 "*Mark used for articles that are in the cache."
431 :group 'gnus-summary-marks
434 (defcustom gnus-saved-mark ?S
435 "*Mark used for articles that have been saved to."
436 :group 'gnus-summary-marks
439 (defcustom gnus-ancient-mark ?O
440 "*Mark used for ancient articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-sparse-mark ?Q
445 "*Mark used for sparsely reffed articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-canceled-mark ?G
450 "*Mark used for canceled articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-duplicate-mark ?M
455 "*Mark used for duplicate articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-undownloaded-mark ?@
460 "*Mark used for articles that weren't downloaded."
461 :group 'gnus-summary-marks
464 (defcustom gnus-downloadable-mark ?%
465 "*Mark used for articles that are to be downloaded."
466 :group 'gnus-summary-marks
469 (defcustom gnus-unsendable-mark ?=
470 "*Mark used for articles that won't be sent."
471 :group 'gnus-summary-marks
474 (defcustom gnus-score-over-mark ?+
475 "*Score mark used for articles with high scores."
476 :group 'gnus-summary-marks
479 (defcustom gnus-score-below-mark ?-
480 "*Score mark used for articles with low scores."
481 :group 'gnus-summary-marks
484 (defcustom gnus-empty-thread-mark ? ;Whitespace
485 "*There is no thread under the article."
486 :group 'gnus-summary-marks
489 (defcustom gnus-not-empty-thread-mark ?=
490 "*There is a thread under the article."
491 :group 'gnus-summary-marks
494 (defcustom gnus-view-pseudo-asynchronously nil
495 "*If non-nil, Gnus will view pseudo-articles asynchronously."
496 :group 'gnus-extract-view
499 (defcustom gnus-auto-expirable-marks
500 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
501 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
502 gnus-souped-mark gnus-duplicate-mark)
503 "*The list of marks converted into expiration if a group is auto-expirable."
505 :type '(repeat character))
507 (defcustom gnus-inhibit-user-auto-expire t
508 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
512 (defcustom gnus-view-pseudos nil
513 "*If `automatic', pseudo-articles will be viewed automatically.
514 If `not-confirm', pseudos will be viewed automatically, and the user
515 will not be asked to confirm the command."
516 :group 'gnus-extract-view
517 :type '(choice (const :tag "off" nil)
519 (const not-confirm)))
521 (defcustom gnus-view-pseudos-separately t
522 "*If non-nil, one pseudo-article will be created for each file to be viewed.
523 If nil, all files that use the same viewing command will be given as a
524 list of parameters to that command."
525 :group 'gnus-extract-view
528 (defcustom gnus-insert-pseudo-articles t
529 "*If non-nil, insert pseudo-articles when decoding articles."
530 :group 'gnus-extract-view
533 (defcustom gnus-summary-dummy-line-format
535 "*The format specification for the dummy roots in the summary buffer.
536 It works along the same lines as a normal formatting string,
537 with some simple extensions.
540 :group 'gnus-threading
543 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
544 "*The format specification for the summary mode line.
545 It works along the same lines as a normal formatting string,
546 with some simple extensions:
549 %p Unprefixed group name
550 %A Current article number
551 %z Current article score
553 %U Number of unread articles in the group
554 %e Number of unselected articles in the group
555 %Z A string with unread/unselected article counts
556 %g Shortish group name
557 %S Subject of the current article
559 %s Current score file name
560 %d Number of dormant articles
561 %r Number of articles that have been marked as read in this session
562 %E Number of articles expunged by the score files"
563 :group 'gnus-summary-format
566 (defcustom gnus-summary-mark-below 0
567 "*Mark all articles with a score below this variable as read.
568 This variable is local to each summary buffer and usually set by the
570 :group 'gnus-score-default
573 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
574 "*List of functions used for sorting articles in the summary buffer.
575 This variable is only used when not using a threaded display."
576 :group 'gnus-summary-sort
577 :type '(repeat (choice (function-item gnus-article-sort-by-number)
578 (function-item gnus-article-sort-by-author)
579 (function-item gnus-article-sort-by-subject)
580 (function-item gnus-article-sort-by-date)
581 (function-item gnus-article-sort-by-score)
582 (function :tag "other"))))
584 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
585 "*List of functions used for sorting threads in the summary buffer.
586 By default, threads are sorted by article number.
588 Each function takes two threads and return non-nil if the first thread
589 should be sorted before the other. If you use more than one function,
590 the primary sort function should be the last. You should probably
591 always include `gnus-thread-sort-by-number' in the list of sorting
592 functions -- preferably first.
594 Ready-made functions include `gnus-thread-sort-by-number',
595 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
596 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
597 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
598 :group 'gnus-summary-sort
599 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
600 (function-item gnus-thread-sort-by-author)
601 (function-item gnus-thread-sort-by-subject)
602 (function-item gnus-thread-sort-by-date)
603 (function-item gnus-thread-sort-by-score)
604 (function-item gnus-thread-sort-by-total-score)
605 (function :tag "other"))))
607 (defcustom gnus-thread-score-function '+
608 "*Function used for calculating the total score of a thread.
610 The function is called with the scores of the article and each
611 subthread and should then return the score of the thread.
613 Some functions you can use are `+', `max', or `min'."
614 :group 'gnus-summary-sort
617 (defcustom gnus-summary-expunge-below nil
618 "All articles that have a score less than this variable will be expunged.
619 This variable is local to the summary buffers."
620 :group 'gnus-score-default
621 :type '(choice (const :tag "off" nil)
624 (defcustom gnus-thread-expunge-below nil
625 "All threads that have a total score less than this variable will be expunged.
626 See `gnus-thread-score-function' for en explanation of what a
629 This variable is local to the summary buffers."
630 :group 'gnus-threading
631 :group 'gnus-score-default
632 :type '(choice (const :tag "off" nil)
635 (defcustom gnus-summary-mode-hook nil
636 "*A hook for Gnus summary mode.
637 This hook is run before any variables are set in the summary buffer."
638 :group 'gnus-summary-various
641 (defcustom gnus-summary-menu-hook nil
642 "*Hook run after the creation of the summary mode menu."
643 :group 'gnus-summary-visual
646 (defcustom gnus-summary-exit-hook nil
647 "*A hook called on exit from the summary buffer.
648 It will be called with point in the group buffer."
649 :group 'gnus-summary-exit
652 (defcustom gnus-summary-prepare-hook nil
653 "*A hook called after the summary buffer has been generated.
654 If you want to modify the summary buffer, you can use this hook."
655 :group 'gnus-summary-various
658 (defcustom gnus-summary-prepared-hook nil
659 "*A hook called as the last thing after the summary buffer has been generated."
660 :group 'gnus-summary-various
663 (defcustom gnus-summary-generate-hook nil
664 "*A hook run just before generating the summary buffer.
665 This hook is commonly used to customize threading variables and the
667 :group 'gnus-summary-various
670 (defcustom gnus-select-group-hook nil
671 "*A hook called when a newsgroup is selected.
673 If you'd like to simplify subjects like the
674 `gnus-summary-next-same-subject' command does, you can use the
677 (setq gnus-select-group-hook
680 (mapcar (lambda (header)
681 (mail-header-set-subject
683 (gnus-simplify-subject
684 (mail-header-subject header) 're-only)))
685 gnus-newsgroup-headers))))"
686 :group 'gnus-group-select
689 (defcustom gnus-select-article-hook nil
690 "*A hook called when an article is selected."
691 :group 'gnus-summary-choose
694 (defcustom gnus-visual-mark-article-hook
695 (list 'gnus-highlight-selected-summary)
696 "*Hook run after selecting an article in the summary buffer.
697 It is meant to be used for highlighting the article in some way. It
698 is not run if `gnus-visual' is nil."
699 :group 'gnus-summary-visual
702 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
703 "*A hook called before parsing the headers."
707 (defcustom gnus-exit-group-hook nil
708 "*A hook called when exiting (not quitting) summary mode."
712 (defcustom gnus-summary-update-hook
713 (list 'gnus-summary-highlight-line)
714 "*A hook called when a summary line is changed.
715 The hook will not be called if `gnus-visual' is nil.
717 The default function `gnus-summary-highlight-line' will
718 highlight the line according to the `gnus-summary-highlight'
720 :group 'gnus-summary-visual
723 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
724 "*A hook called when an article is selected for the first time.
725 The hook is intended to mark an article as read (or unread)
726 automatically when it is selected."
727 :group 'gnus-summary-choose
730 (defcustom gnus-group-no-more-groups-hook nil
731 "*A hook run when returning to group mode having no more (unread) groups."
732 :group 'gnus-group-select
735 (defcustom gnus-ps-print-hook nil
736 "*A hook run before ps-printing something from Gnus."
740 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
741 "Face used for highlighting the current article in the summary buffer."
742 :group 'gnus-summary-visual
745 (defcustom gnus-summary-highlight
746 '(((= mark gnus-canceled-mark)
747 . gnus-summary-cancelled-face)
748 ((and (> score default)
749 (or (= mark gnus-dormant-mark)
750 (= mark gnus-ticked-mark)))
751 . gnus-summary-high-ticked-face)
752 ((and (< score default)
753 (or (= mark gnus-dormant-mark)
754 (= mark gnus-ticked-mark)))
755 . gnus-summary-low-ticked-face)
756 ((or (= mark gnus-dormant-mark)
757 (= mark gnus-ticked-mark))
758 . gnus-summary-normal-ticked-face)
759 ((and (> score default) (= mark gnus-ancient-mark))
760 . gnus-summary-high-ancient-face)
761 ((and (< score default) (= mark gnus-ancient-mark))
762 . gnus-summary-low-ancient-face)
763 ((= mark gnus-ancient-mark)
764 . gnus-summary-normal-ancient-face)
765 ((and (> score default) (= mark gnus-unread-mark))
766 . gnus-summary-high-unread-face)
767 ((and (< score default) (= mark gnus-unread-mark))
768 . gnus-summary-low-unread-face)
769 ((= mark gnus-unread-mark)
770 . gnus-summary-normal-unread-face)
771 ((and (> score default) (memq mark (list gnus-downloadable-mark
772 gnus-undownloaded-mark)))
773 . gnus-summary-high-unread-face)
774 ((and (< score default) (memq mark (list gnus-downloadable-mark
775 gnus-undownloaded-mark)))
776 . gnus-summary-low-unread-face)
777 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
778 . gnus-summary-normal-unread-face)
780 . gnus-summary-high-read-face)
782 . gnus-summary-low-read-face)
784 . gnus-summary-normal-read-face))
785 "*Controls the highlighting of summary buffer lines.
787 A list of (FORM . FACE) pairs. When deciding how a a particular
788 summary line should be displayed, each form is evaluated. The content
789 of the face field after the first true form is used. You can change
790 how those summary lines are displayed, by editing the face field.
792 You can use the following variables in the FORM field.
794 score: The articles score
795 default: The default article score.
796 below: The score below which articles are automatically marked as read.
797 mark: The articles mark."
798 :group 'gnus-summary-visual
799 :type '(repeat (cons (sexp :tag "Form" nil)
802 (defcustom gnus-alter-header-function nil
803 "Function called to allow alteration of article header structures.
804 The function is called with one parameter, the article header vector,
805 which it may alter in any way.")
807 (defcustom gnus-extra-headers nil
808 "*Extra headers to parse."
810 :type '(repeat symbol))
812 (defcustom gnus-ignored-from-addresses
813 (and user-mail-address (regexp-quote user-mail-address))
814 "*Regexp of From headers that may be suppressed in favor of To headers."
818 (defcustom gnus-group-charset-alist
819 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
820 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
821 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
822 ("^relcom\\>" koi8-r)
823 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
824 ("^israel\\>" iso-8859-1)
826 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
828 "Alist of regexps (to match group names) and default charsets to be used when reading."
829 :type '(repeat (list (regexp :tag "Group")
830 (symbol :tag "Charset")))
831 :group 'gnus-charset)
833 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
834 "List of charsets that should be ignored.
835 When these charsets are used in the \"charset\" parameter, the
836 default charset will be used instead."
837 :type '(repeat symbol)
838 :group 'gnus-charset)
840 (defcustom gnus-group-ignored-charsets-alist
841 '(("alt\\.chinese\\.text" iso-8859-1))
842 "Alist of regexps (to match group names) and charsets that should be ignored.
843 When these charsets are used in the \"charset\" parameter, the
844 default charset will be used instead."
845 :type '(repeat (cons (regexp :tag "Group")
847 :group 'gnus-charset)
849 (defcustom gnus-group-highlight-words-alist nil
850 "Alist of group regexps and highlight regexps.
851 This variable uses the same syntax as `gnus-emphasis-alist'."
852 :type '(repeat (cons (regexp :tag "Group")
853 (repeat (list (regexp :tag "Highlight regexp")
854 (number :tag "Group for entire word" 0)
855 (number :tag "Group for displayed part" 0)
857 gnus-emphasis-highlight-words)))))
858 :group 'gnus-summary-visual)
860 ;;; Internal variables
862 (defvar gnus-scores-exclude-files nil)
863 (defvar gnus-page-broken nil)
864 (defvar gnus-inhibit-mime-unbuttonizing nil)
866 (defvar gnus-original-article nil)
867 (defvar gnus-article-internal-prepare-hook nil)
868 (defvar gnus-newsgroup-process-stack nil)
870 (defvar gnus-thread-indent-array nil)
871 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
873 ;; Avoid highlighting in kill files.
874 (defvar gnus-summary-inhibit-highlight nil)
875 (defvar gnus-newsgroup-selected-overlay nil)
876 (defvar gnus-inhibit-limiting nil)
877 (defvar gnus-newsgroup-adaptive-score-file nil)
878 (defvar gnus-current-score-file nil)
879 (defvar gnus-current-move-group nil)
880 (defvar gnus-current-copy-group nil)
881 (defvar gnus-current-crosspost-group nil)
883 (defvar gnus-newsgroup-dependencies nil)
884 (defvar gnus-newsgroup-adaptive nil)
885 (defvar gnus-summary-display-article-function nil)
886 (defvar gnus-summary-highlight-line-function nil
887 "Function called after highlighting a summary line.")
889 (defvar gnus-summary-line-format-alist
890 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
891 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
892 (?s gnus-tmp-subject-or-nil ?s)
893 (?n gnus-tmp-name ?s)
894 (?A (std11-address-string
895 (car (mime-read-field 'From gnus-tmp-header))) ?s)
896 (?a (or (std11-full-name-string
897 (car (mime-read-field 'From gnus-tmp-header)))
899 (?F gnus-tmp-from ?s)
900 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
901 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
902 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
903 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
904 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
905 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
906 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
907 (?L gnus-tmp-lines ?d)
908 (?I gnus-tmp-indentation ?s)
909 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
910 (?R gnus-tmp-replied ?c)
911 (?\[ gnus-tmp-opening-bracket ?c)
912 (?\] gnus-tmp-closing-bracket ?c)
913 (?\> (make-string gnus-tmp-level ? ) ?s)
914 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
915 (?i gnus-tmp-score ?d)
916 (?z gnus-tmp-score-char ?c)
917 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
918 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
919 (?U gnus-tmp-unread ?c)
920 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
921 (?t (gnus-summary-number-of-articles-in-thread
922 (and (boundp 'thread) (car thread)) gnus-tmp-level)
924 (?e (gnus-summary-number-of-articles-in-thread
925 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
927 (?u gnus-tmp-user-defined ?s)
928 (?P (gnus-pick-line-number) ?d))
929 "An alist of format specifications that can appear in summary lines,
930 and what variables they correspond with, along with the type of the
931 variable (string, integer, character, etc).")
933 (defvar gnus-summary-dummy-line-format-alist
934 `((?S gnus-tmp-subject ?s)
935 (?N gnus-tmp-number ?d)
936 (?u gnus-tmp-user-defined ?s)))
938 (defvar gnus-summary-mode-line-format-alist
939 `((?G gnus-tmp-group-name ?s)
940 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
941 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
942 (?A gnus-tmp-article-number ?d)
943 (?Z gnus-tmp-unread-and-unselected ?s)
945 (?U gnus-tmp-unread-and-unticked ?d)
946 (?S gnus-tmp-subject ?s)
947 (?e gnus-tmp-unselected ?d)
948 (?u gnus-tmp-user-defined ?s)
949 (?d (length gnus-newsgroup-dormant) ?d)
950 (?t (length gnus-newsgroup-marked) ?d)
951 (?r (length gnus-newsgroup-reads) ?d)
952 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
953 (?E gnus-newsgroup-expunged-tally ?d)
954 (?s (gnus-current-score-file-nondirectory) ?s)))
956 (defvar gnus-last-search-regexp nil
957 "Default regexp for article search command.")
959 (defvar gnus-last-shell-command nil
960 "Default shell command on article.")
962 (defvar gnus-newsgroup-begin nil)
963 (defvar gnus-newsgroup-end nil)
964 (defvar gnus-newsgroup-last-rmail nil)
965 (defvar gnus-newsgroup-last-mail nil)
966 (defvar gnus-newsgroup-last-folder nil)
967 (defvar gnus-newsgroup-last-file nil)
968 (defvar gnus-newsgroup-auto-expire nil)
969 (defvar gnus-newsgroup-active nil)
971 (defvar gnus-newsgroup-data nil)
972 (defvar gnus-newsgroup-data-reverse nil)
973 (defvar gnus-newsgroup-limit nil)
974 (defvar gnus-newsgroup-limits nil)
976 (defvar gnus-newsgroup-unreads nil
977 "List of unread articles in the current newsgroup.")
979 (defvar gnus-newsgroup-unselected nil
980 "List of unselected unread articles in the current newsgroup.")
982 (defvar gnus-newsgroup-reads nil
983 "Alist of read articles and article marks in the current newsgroup.")
985 (defvar gnus-newsgroup-expunged-tally nil)
987 (defvar gnus-newsgroup-marked nil
988 "List of ticked articles in the current newsgroup (a subset of unread art).")
990 (defvar gnus-newsgroup-killed nil
991 "List of ranges of articles that have been through the scoring process.")
993 (defvar gnus-newsgroup-cached nil
994 "List of articles that come from the article cache.")
996 (defvar gnus-newsgroup-saved nil
997 "List of articles that have been saved.")
999 (defvar gnus-newsgroup-kill-headers nil)
1001 (defvar gnus-newsgroup-replied nil
1002 "List of articles that have been replied to in the current newsgroup.")
1004 (defvar gnus-newsgroup-expirable nil
1005 "List of articles in the current newsgroup that can be expired.")
1007 (defvar gnus-newsgroup-processable nil
1008 "List of articles in the current newsgroup that can be processed.")
1010 (defvar gnus-newsgroup-downloadable nil
1011 "List of articles in the current newsgroup that can be processed.")
1013 (defvar gnus-newsgroup-undownloaded nil
1014 "List of articles in the current newsgroup that haven't been downloaded..")
1016 (defvar gnus-newsgroup-unsendable nil
1017 "List of articles in the current newsgroup that won't be sent.")
1019 (defvar gnus-newsgroup-bookmarks nil
1020 "List of articles in the current newsgroup that have bookmarks.")
1022 (defvar gnus-newsgroup-dormant nil
1023 "List of dormant articles in the current newsgroup.")
1025 (defvar gnus-newsgroup-scored nil
1026 "List of scored articles in the current newsgroup.")
1028 (defvar gnus-newsgroup-headers nil
1029 "List of article headers in the current newsgroup.")
1031 (defvar gnus-newsgroup-threads nil)
1033 (defvar gnus-newsgroup-prepared nil
1034 "Whether the current group has been prepared properly.")
1036 (defvar gnus-newsgroup-ancient nil
1037 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1039 (defvar gnus-newsgroup-sparse nil)
1041 (defvar gnus-current-article nil)
1042 (defvar gnus-article-current nil)
1043 (defvar gnus-current-headers nil)
1044 (defvar gnus-have-all-headers nil)
1045 (defvar gnus-last-article nil)
1046 (defvar gnus-newsgroup-history nil)
1047 (defvar gnus-newsgroup-charset nil)
1048 (defvar gnus-newsgroup-ephemeral-charset nil)
1049 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1051 (defconst gnus-summary-local-variables
1052 '(gnus-newsgroup-name
1053 gnus-newsgroup-begin gnus-newsgroup-end
1054 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1055 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1056 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1057 gnus-newsgroup-unselected gnus-newsgroup-marked
1058 gnus-newsgroup-reads gnus-newsgroup-saved
1059 gnus-newsgroup-replied gnus-newsgroup-expirable
1060 gnus-newsgroup-processable gnus-newsgroup-killed
1061 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1062 gnus-newsgroup-unsendable
1063 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1064 gnus-newsgroup-headers gnus-newsgroup-threads
1065 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1066 gnus-current-article gnus-current-headers gnus-have-all-headers
1067 gnus-last-article gnus-article-internal-prepare-hook
1068 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1069 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1070 gnus-thread-expunge-below
1071 gnus-score-alist gnus-current-score-file
1072 (gnus-summary-expunge-below . global)
1073 (gnus-summary-mark-below . global)
1074 gnus-newsgroup-active gnus-scores-exclude-files
1075 gnus-newsgroup-history gnus-newsgroup-ancient
1076 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1077 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1078 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1079 (gnus-newsgroup-expunged-tally . 0)
1080 gnus-cache-removable-articles gnus-newsgroup-cached
1081 gnus-newsgroup-data gnus-newsgroup-data-reverse
1082 gnus-newsgroup-limit gnus-newsgroup-limits
1083 gnus-newsgroup-charset)
1084 "Variables that are buffer-local to the summary buffers.")
1086 ;; Byte-compiler warning.
1087 (defvar gnus-article-mode-map)
1089 ;; Subject simplification.
1091 (defun gnus-simplify-whitespace (str)
1092 "Remove excessive whitespace."
1095 (while (string-match "[ \t][ \t]+" mystr)
1096 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1098 (substring mystr (match-end 0)))))
1100 (when (string-match "^[ \t]+" mystr)
1101 (setq mystr (substring mystr (match-end 0))))
1103 (when (string-match "[ \t]+$" mystr)
1104 (setq mystr (substring mystr 0 (match-beginning 0))))
1107 (defsubst gnus-simplify-subject-re (subject)
1108 "Remove \"Re:\" from subject lines."
1109 (if (string-match "^[Rr][Ee]: *" subject)
1110 (substring subject (match-end 0))
1113 (defun gnus-simplify-subject (subject &optional re-only)
1114 "Remove `Re:' and words in parentheses.
1115 If RE-ONLY is non-nil, strip leading `Re:'s only."
1116 (let ((case-fold-search t)) ;Ignore case.
1117 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1118 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1119 (setq subject (substring subject (match-end 0))))
1120 ;; Remove uninteresting prefixes.
1121 (when (and (not re-only)
1122 gnus-simplify-ignored-prefixes
1123 (string-match gnus-simplify-ignored-prefixes subject))
1124 (setq subject (substring subject (match-end 0))))
1125 ;; Remove words in parentheses from end.
1127 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1128 (setq subject (substring subject 0 (match-beginning 0)))))
1129 ;; Return subject string.
1132 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1134 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1135 (goto-char (point-min))
1136 (while (re-search-forward regexp nil t)
1137 (replace-match (or newtext ""))))
1139 (defun gnus-simplify-buffer-fuzzy ()
1140 "Simplify string in the buffer fuzzily.
1141 The string in the accessible portion of the current buffer is simplified.
1142 It is assumed to be a single-line subject.
1143 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1144 matter is removed. Additional things can be deleted by setting
1145 gnus-simplify-subject-fuzzy-regexp."
1146 (let ((case-fold-search t)
1148 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1150 (while (not (eq modified-tick (buffer-modified-tick)))
1151 (setq modified-tick (buffer-modified-tick))
1153 ((listp gnus-simplify-subject-fuzzy-regexp)
1154 (mapcar 'gnus-simplify-buffer-fuzzy-step
1155 gnus-simplify-subject-fuzzy-regexp))
1156 (gnus-simplify-subject-fuzzy-regexp
1157 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1158 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1159 (gnus-simplify-buffer-fuzzy-step
1160 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1161 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1163 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1164 (gnus-simplify-buffer-fuzzy-step " +" " ")
1165 (gnus-simplify-buffer-fuzzy-step " $")
1166 (gnus-simplify-buffer-fuzzy-step "^ +")))
1168 (defun gnus-simplify-subject-fuzzy (subject)
1169 "Simplify a subject string fuzzily.
1170 See `gnus-simplify-buffer-fuzzy' for details."
1172 (gnus-set-work-buffer)
1173 (let ((case-fold-search t))
1174 ;; Remove uninteresting prefixes.
1175 (when (and gnus-simplify-ignored-prefixes
1176 (string-match gnus-simplify-ignored-prefixes subject))
1177 (setq subject (substring subject (match-end 0))))
1179 (inline (gnus-simplify-buffer-fuzzy))
1182 (defsubst gnus-simplify-subject-fully (subject)
1183 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1185 (gnus-simplify-subject-functions
1186 (gnus-map-function gnus-simplify-subject-functions subject))
1187 ((null gnus-summary-gather-subject-limit)
1188 (gnus-simplify-subject-re subject))
1189 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1190 (gnus-simplify-subject-fuzzy subject))
1191 ((numberp gnus-summary-gather-subject-limit)
1192 (gnus-limit-string (gnus-simplify-subject-re subject)
1193 gnus-summary-gather-subject-limit))
1197 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1198 "Check whether two subjects are equal.
1199 If optional argument simple-first is t, first argument is already
1202 ((null simple-first)
1203 (equal (gnus-simplify-subject-fully s1)
1204 (gnus-simplify-subject-fully s2)))
1207 (gnus-simplify-subject-fully s2)))))
1209 (defun gnus-summary-bubble-group ()
1210 "Increase the score of the current group.
1211 This is a handy function to add to `gnus-summary-exit-hook' to
1212 increase the score of each group you read."
1213 (gnus-group-add-score gnus-newsgroup-name))
1217 ;;; Gnus summary mode
1220 (put 'gnus-summary-mode 'mode-class 'special)
1223 ;; Non-orthogonal keys
1225 (gnus-define-keys gnus-summary-mode-map
1226 " " gnus-summary-next-page
1227 "\177" gnus-summary-prev-page
1228 [delete] gnus-summary-prev-page
1229 [backspace] gnus-summary-prev-page
1230 "\r" gnus-summary-scroll-up
1231 "\M-\r" gnus-summary-scroll-down
1232 "n" gnus-summary-next-unread-article
1233 "p" gnus-summary-prev-unread-article
1234 "N" gnus-summary-next-article
1235 "P" gnus-summary-prev-article
1236 "\M-\C-n" gnus-summary-next-same-subject
1237 "\M-\C-p" gnus-summary-prev-same-subject
1238 "\M-n" gnus-summary-next-unread-subject
1239 "\M-p" gnus-summary-prev-unread-subject
1240 "." gnus-summary-first-unread-article
1241 "," gnus-summary-best-unread-article
1242 "\M-s" gnus-summary-search-article-forward
1243 "\M-r" gnus-summary-search-article-backward
1244 "<" gnus-summary-beginning-of-article
1245 ">" gnus-summary-end-of-article
1246 "j" gnus-summary-goto-article
1247 "^" gnus-summary-refer-parent-article
1248 "\M-^" gnus-summary-refer-article
1249 "u" gnus-summary-tick-article-forward
1250 "!" gnus-summary-tick-article-forward
1251 "U" gnus-summary-tick-article-backward
1252 "d" gnus-summary-mark-as-read-forward
1253 "D" gnus-summary-mark-as-read-backward
1254 "E" gnus-summary-mark-as-expirable
1255 "\M-u" gnus-summary-clear-mark-forward
1256 "\M-U" gnus-summary-clear-mark-backward
1257 "k" gnus-summary-kill-same-subject-and-select
1258 "\C-k" gnus-summary-kill-same-subject
1259 "\M-\C-k" gnus-summary-kill-thread
1260 "\M-\C-l" gnus-summary-lower-thread
1261 "e" gnus-summary-edit-article
1262 "#" gnus-summary-mark-as-processable
1263 "\M-#" gnus-summary-unmark-as-processable
1264 "\M-\C-t" gnus-summary-toggle-threads
1265 "\M-\C-s" gnus-summary-show-thread
1266 "\M-\C-h" gnus-summary-hide-thread
1267 "\M-\C-f" gnus-summary-next-thread
1268 "\M-\C-b" gnus-summary-prev-thread
1269 "\M-\C-u" gnus-summary-up-thread
1270 "\M-\C-d" gnus-summary-down-thread
1271 "&" gnus-summary-execute-command
1272 "c" gnus-summary-catchup-and-exit
1273 "\C-w" gnus-summary-mark-region-as-read
1274 "\C-t" gnus-summary-toggle-truncation
1275 "?" gnus-summary-mark-as-dormant
1276 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1277 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1278 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1279 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1280 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1281 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1282 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1283 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1284 "=" gnus-summary-expand-window
1285 "\C-x\C-s" gnus-summary-reselect-current-group
1286 "\M-g" gnus-summary-rescan-group
1287 "w" gnus-summary-stop-page-breaking
1288 "\C-c\C-r" gnus-summary-caesar-message
1289 "\M-t" gnus-summary-toggle-mime
1290 "f" gnus-summary-followup
1291 "F" gnus-summary-followup-with-original
1292 "C" gnus-summary-cancel-article
1293 "r" gnus-summary-reply
1294 "R" gnus-summary-reply-with-original
1295 "\C-c\C-f" gnus-summary-mail-forward
1296 "o" gnus-summary-save-article
1297 "\C-o" gnus-summary-save-article-mail
1298 "|" gnus-summary-pipe-output
1299 "\M-k" gnus-summary-edit-local-kill
1300 "\M-K" gnus-summary-edit-global-kill
1302 "\C-c\C-d" gnus-summary-describe-group
1303 "q" gnus-summary-exit
1304 "Q" gnus-summary-exit-no-update
1305 "\C-c\C-i" gnus-info-find-node
1306 gnus-mouse-2 gnus-mouse-pick-article
1307 "m" gnus-summary-mail-other-window
1308 "a" gnus-summary-post-news
1309 "x" gnus-summary-limit-to-unread
1310 "s" gnus-summary-isearch-article
1311 "t" gnus-article-toggle-headers
1312 "g" gnus-summary-show-article
1313 "l" gnus-summary-goto-last-article
1314 "v" gnus-summary-preview-mime-message
1315 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1316 "\C-d" gnus-summary-enter-digest-group
1317 "\M-\C-d" gnus-summary-read-document
1318 "\M-\C-e" gnus-summary-edit-parameters
1319 "\M-\C-g" gnus-summary-customize-parameters
1321 "*" gnus-cache-enter-article
1322 "\M-*" gnus-cache-remove-article
1323 "\M-&" gnus-summary-universal-argument
1324 "\C-l" gnus-recenter
1325 "I" gnus-summary-increase-score
1326 "L" gnus-summary-lower-score
1327 "\M-i" gnus-symbolic-argument
1328 "h" gnus-summary-select-article-buffer
1330 "V" gnus-summary-score-map
1331 "X" gnus-uu-extract-map
1332 "S" gnus-summary-send-map)
1334 ;; Sort of orthogonal keymap
1335 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1336 "t" gnus-summary-tick-article-forward
1337 "!" gnus-summary-tick-article-forward
1338 "d" gnus-summary-mark-as-read-forward
1339 "r" gnus-summary-mark-as-read-forward
1340 "c" gnus-summary-clear-mark-forward
1341 " " gnus-summary-clear-mark-forward
1342 "e" gnus-summary-mark-as-expirable
1343 "x" gnus-summary-mark-as-expirable
1344 "?" gnus-summary-mark-as-dormant
1345 "b" gnus-summary-set-bookmark
1346 "B" gnus-summary-remove-bookmark
1347 "#" gnus-summary-mark-as-processable
1348 "\M-#" gnus-summary-unmark-as-processable
1349 "S" gnus-summary-limit-include-expunged
1350 "C" gnus-summary-catchup
1351 "H" gnus-summary-catchup-to-here
1352 "\C-c" gnus-summary-catchup-all
1353 "k" gnus-summary-kill-same-subject-and-select
1354 "K" gnus-summary-kill-same-subject
1355 "P" gnus-uu-mark-map)
1357 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1358 "c" gnus-summary-clear-above
1359 "u" gnus-summary-tick-above
1360 "m" gnus-summary-mark-above
1361 "k" gnus-summary-kill-below)
1363 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1364 "/" gnus-summary-limit-to-subject
1365 "n" gnus-summary-limit-to-articles
1366 "w" gnus-summary-pop-limit
1367 "s" gnus-summary-limit-to-subject
1368 "a" gnus-summary-limit-to-author
1369 "u" gnus-summary-limit-to-unread
1370 "m" gnus-summary-limit-to-marks
1371 "M" gnus-summary-limit-exclude-marks
1372 "v" gnus-summary-limit-to-score
1373 "*" gnus-summary-limit-include-cached
1374 "D" gnus-summary-limit-include-dormant
1375 "T" gnus-summary-limit-include-thread
1376 "d" gnus-summary-limit-exclude-dormant
1377 "t" gnus-summary-limit-to-age
1378 "x" gnus-summary-limit-to-extra
1379 "E" gnus-summary-limit-include-expunged
1380 "c" gnus-summary-limit-exclude-childless-dormant
1381 "C" gnus-summary-limit-mark-excluded-as-read)
1383 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1384 "n" gnus-summary-next-unread-article
1385 "p" gnus-summary-prev-unread-article
1386 "N" gnus-summary-next-article
1387 "P" gnus-summary-prev-article
1388 "\C-n" gnus-summary-next-same-subject
1389 "\C-p" gnus-summary-prev-same-subject
1390 "\M-n" gnus-summary-next-unread-subject
1391 "\M-p" gnus-summary-prev-unread-subject
1392 "f" gnus-summary-first-unread-article
1393 "b" gnus-summary-best-unread-article
1394 "j" gnus-summary-goto-article
1395 "g" gnus-summary-goto-subject
1396 "l" gnus-summary-goto-last-article
1397 "o" gnus-summary-pop-article)
1399 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1400 "k" gnus-summary-kill-thread
1401 "l" gnus-summary-lower-thread
1402 "i" gnus-summary-raise-thread
1403 "T" gnus-summary-toggle-threads
1404 "t" gnus-summary-rethread-current
1405 "^" gnus-summary-reparent-thread
1406 "s" gnus-summary-show-thread
1407 "S" gnus-summary-show-all-threads
1408 "h" gnus-summary-hide-thread
1409 "H" gnus-summary-hide-all-threads
1410 "n" gnus-summary-next-thread
1411 "p" gnus-summary-prev-thread
1412 "u" gnus-summary-up-thread
1413 "o" gnus-summary-top-thread
1414 "d" gnus-summary-down-thread
1415 "#" gnus-uu-mark-thread
1416 "\M-#" gnus-uu-unmark-thread)
1418 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1419 "g" gnus-summary-prepare
1420 "c" gnus-summary-insert-cached-articles)
1422 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1423 "c" gnus-summary-catchup-and-exit
1424 "C" gnus-summary-catchup-all-and-exit
1425 "E" gnus-summary-exit-no-update
1426 "Q" gnus-summary-exit
1427 "Z" gnus-summary-exit
1428 "n" gnus-summary-catchup-and-goto-next-group
1429 "R" gnus-summary-reselect-current-group
1430 "G" gnus-summary-rescan-group
1431 "N" gnus-summary-next-group
1432 "s" gnus-summary-save-newsrc
1433 "P" gnus-summary-prev-group)
1435 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1436 " " gnus-summary-next-page
1437 "n" gnus-summary-next-page
1438 "\177" gnus-summary-prev-page
1439 [delete] gnus-summary-prev-page
1440 "p" gnus-summary-prev-page
1441 "\r" gnus-summary-scroll-up
1442 "\M-\r" gnus-summary-scroll-down
1443 "<" gnus-summary-beginning-of-article
1444 ">" gnus-summary-end-of-article
1445 "b" gnus-summary-beginning-of-article
1446 "e" gnus-summary-end-of-article
1447 "^" gnus-summary-refer-parent-article
1448 "r" gnus-summary-refer-parent-article
1449 "D" gnus-summary-enter-digest-group
1450 "R" gnus-summary-refer-references
1451 "T" gnus-summary-refer-thread
1452 "g" gnus-summary-show-article
1453 "s" gnus-summary-isearch-article
1454 "P" gnus-summary-print-article
1455 "t" gnus-article-babel)
1457 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1458 "b" gnus-article-add-buttons
1459 "B" gnus-article-add-buttons-to-head
1460 "o" gnus-article-treat-overstrike
1461 "e" gnus-article-emphasize
1462 "w" gnus-article-fill-cited-article
1463 "Q" gnus-article-fill-long-lines
1464 "C" gnus-article-capitalize-sentences
1465 "c" gnus-article-remove-cr
1466 "f" gnus-article-display-x-face
1467 "l" gnus-summary-stop-page-breaking
1468 "r" gnus-summary-caesar-message
1469 "t" gnus-article-toggle-headers
1470 "v" gnus-summary-verbose-headers
1471 "m" gnus-summary-toggle-mime
1472 "H" gnus-article-strip-headers-in-body
1473 "d" gnus-article-treat-dumbquotes)
1475 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1476 "a" gnus-article-hide
1477 "h" gnus-article-toggle-headers
1478 "b" gnus-article-hide-boring-headers
1479 "s" gnus-article-hide-signature
1480 "c" gnus-article-hide-citation
1481 "C" gnus-article-hide-citation-in-followups
1482 "p" gnus-article-hide-pgp
1483 "B" gnus-article-strip-banner
1484 "P" gnus-article-hide-pem
1485 "\C-c" gnus-article-hide-citation-maybe)
1487 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1488 "a" gnus-article-highlight
1489 "h" gnus-article-highlight-headers
1490 "c" gnus-article-highlight-citation
1491 "s" gnus-article-highlight-signature)
1493 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1494 "z" gnus-article-date-ut
1495 "u" gnus-article-date-ut
1496 "l" gnus-article-date-local
1497 "e" gnus-article-date-lapsed
1498 "o" gnus-article-date-original
1499 "i" gnus-article-date-iso8601
1500 "s" gnus-article-date-user)
1502 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1503 "t" gnus-article-remove-trailing-blank-lines
1504 "l" gnus-article-strip-leading-blank-lines
1505 "m" gnus-article-strip-multiple-blank-lines
1506 "a" gnus-article-strip-blank-lines
1507 "A" gnus-article-strip-all-blank-lines
1508 "s" gnus-article-strip-leading-space
1509 "e" gnus-article-strip-trailing-space)
1511 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1513 "f" gnus-summary-fetch-faq
1514 "d" gnus-summary-describe-group
1515 "h" gnus-summary-describe-briefly
1516 "i" gnus-info-find-node)
1518 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1519 "e" gnus-summary-expire-articles
1520 "\M-\C-e" gnus-summary-expire-articles-now
1521 "\177" gnus-summary-delete-article
1522 [delete] gnus-summary-delete-article
1523 [backspace] gnus-summary-delete-article
1524 "m" gnus-summary-move-article
1525 "r" gnus-summary-respool-article
1526 "w" gnus-summary-edit-article
1527 "c" gnus-summary-copy-article
1528 "B" gnus-summary-crosspost-article
1529 "q" gnus-summary-respool-query
1530 "t" gnus-summary-respool-trace
1531 "i" gnus-summary-import-article
1532 "p" gnus-summary-article-posted-p)
1534 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1535 "o" gnus-summary-save-article
1536 "m" gnus-summary-save-article-mail
1537 "F" gnus-summary-write-article-file
1538 "r" gnus-summary-save-article-rmail
1539 "f" gnus-summary-save-article-file
1540 "b" gnus-summary-save-article-body-file
1541 "h" gnus-summary-save-article-folder
1542 "v" gnus-summary-save-article-vm
1543 "p" gnus-summary-pipe-output
1544 "s" gnus-soup-add-article)
1546 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1547 "b" gnus-summary-display-buttonized
1548 "m" gnus-summary-repair-multipart
1549 "v" gnus-article-view-part
1550 "o" gnus-article-save-part
1551 "c" gnus-article-copy-part
1552 "e" gnus-article-externalize-part
1553 "i" gnus-article-inline-part
1554 "|" gnus-article-pipe-part)
1557 (defun gnus-summary-make-menu-bar ()
1558 (gnus-turn-off-edit-menu 'summary)
1560 (unless (boundp 'gnus-summary-misc-menu)
1563 gnus-summary-kill-menu gnus-summary-mode-map ""
1568 ["Enter score..." gnus-summary-score-entry t]
1569 ["Customize" gnus-score-customize t])
1570 (gnus-make-score-map 'increase)
1571 (gnus-make-score-map 'lower)
1573 ["Kill below" gnus-summary-kill-below t]
1574 ["Mark above" gnus-summary-mark-above t]
1575 ["Tick above" gnus-summary-tick-above t]
1576 ["Clear above" gnus-summary-clear-above t])
1577 ["Current score" gnus-summary-current-score t]
1578 ["Set score" gnus-summary-set-score t]
1579 ["Switch current score file..." gnus-score-change-score-file t]
1580 ["Set mark below..." gnus-score-set-mark-below t]
1581 ["Set expunge below..." gnus-score-set-expunge-below t]
1582 ["Edit current score file" gnus-score-edit-current-scores t]
1583 ["Edit score file" gnus-score-edit-file t]
1584 ["Trace score" gnus-score-find-trace t]
1585 ["Find words" gnus-score-find-favourite-words t]
1586 ["Rescore buffer" gnus-summary-rescore t]
1587 ["Increase score..." gnus-summary-increase-score t]
1588 ["Lower score..." gnus-summary-lower-score t]))))
1590 ;; Define both the Article menu in the summary buffer and the equivalent
1591 ;; Commands menu in the article buffer here for consistency.
1594 ["All" gnus-article-hide t]
1595 ["Headers" gnus-article-toggle-headers t]
1596 ["Signature" gnus-article-hide-signature t]
1597 ["Citation" gnus-article-hide-citation t]
1598 ["PGP" gnus-article-hide-pgp t]
1599 ["Banner" gnus-article-strip-banner t]
1600 ["Boring headers" gnus-article-hide-boring-headers t])
1602 ["All" gnus-article-highlight t]
1603 ["Headers" gnus-article-highlight-headers t]
1604 ["Signature" gnus-article-highlight-signature t]
1605 ["Citation" gnus-article-highlight-citation t])
1607 ["Local" gnus-article-date-local t]
1608 ["ISO8601" gnus-article-date-iso8601 t]
1609 ["UT" gnus-article-date-ut t]
1610 ["Original" gnus-article-date-original t]
1611 ["Lapsed" gnus-article-date-lapsed t]
1612 ["User-defined" gnus-article-date-user t])
1615 ["Leading" gnus-article-strip-leading-blank-lines t]
1616 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1617 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1618 ["All of the above" gnus-article-strip-blank-lines t]
1619 ["All" gnus-article-strip-all-blank-lines t]
1620 ["Leading space" gnus-article-strip-leading-space t]
1621 ["Trailing space" gnus-article-strip-trailing-space t])
1622 ["Overstrike" gnus-article-treat-overstrike t]
1623 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1624 ["Emphasis" gnus-article-emphasize t]
1625 ["Word wrap" gnus-article-fill-cited-article t]
1626 ["Fill long lines" gnus-article-fill-long-lines t]
1627 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1628 ["CR" gnus-article-remove-cr t]
1629 ["Show X-Face" gnus-article-display-x-face t]
1630 ["Rot 13" gnus-summary-caesar-message t]
1631 ["Unix pipe" gnus-summary-pipe-message t]
1632 ["Add buttons" gnus-article-add-buttons t]
1633 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1634 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1635 ["Toggle MIME" gnus-summary-toggle-mime t]
1636 ["Verbose header" gnus-summary-verbose-headers t]
1637 ["Toggle header" gnus-summary-toggle-header t])
1639 ["Save in default format" gnus-summary-save-article t]
1640 ["Save in file" gnus-summary-save-article-file t]
1641 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1642 ["Save in MH folder" gnus-summary-save-article-folder t]
1643 ["Save in VM folder" gnus-summary-save-article-vm t]
1644 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1645 ["Save body in file" gnus-summary-save-article-body-file t]
1646 ["Pipe through a filter" gnus-summary-pipe-output t]
1647 ["Add to SOUP packet" gnus-soup-add-article t]
1648 ["Print" gnus-summary-print-article t])
1650 ["Respool article..." gnus-summary-respool-article t]
1651 ["Move article..." gnus-summary-move-article
1652 (gnus-check-backend-function
1653 'request-move-article gnus-newsgroup-name)]
1654 ["Copy article..." gnus-summary-copy-article t]
1655 ["Crosspost article..." gnus-summary-crosspost-article
1656 (gnus-check-backend-function
1657 'request-replace-article gnus-newsgroup-name)]
1658 ["Import file..." gnus-summary-import-article t]
1659 ["Check if posted" gnus-summary-article-posted-p t]
1660 ["Edit article" gnus-summary-edit-article
1661 (not (gnus-group-read-only-p))]
1662 ["Delete article" gnus-summary-delete-article
1663 (gnus-check-backend-function
1664 'request-expire-articles gnus-newsgroup-name)]
1665 ["Query respool" gnus-summary-respool-query t]
1666 ["Trace respool" gnus-summary-respool-trace t]
1667 ["Delete expirable articles" gnus-summary-expire-articles-now
1668 (gnus-check-backend-function
1669 'request-expire-articles gnus-newsgroup-name)])
1671 ["Uudecode" gnus-uu-decode-uu t]
1672 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1673 ["Unshar" gnus-uu-decode-unshar t]
1674 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1675 ["Save" gnus-uu-decode-save t]
1676 ["Binhex" gnus-uu-decode-binhex t]
1677 ["Postscript" gnus-uu-decode-postscript t])
1679 ["Enter article" gnus-cache-enter-article t]
1680 ["Remove article" gnus-cache-remove-article t])
1681 ["Translate" gnus-article-babel t]
1682 ["Select article buffer" gnus-summary-select-article-buffer t]
1683 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1684 ["Isearch article..." gnus-summary-isearch-article t]
1685 ["Beginning of the article" gnus-summary-beginning-of-article t]
1686 ["End of the article" gnus-summary-end-of-article t]
1687 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1688 ["Fetch referenced articles" gnus-summary-refer-references t]
1689 ["Fetch current thread" gnus-summary-refer-thread t]
1690 ["Fetch article with id..." gnus-summary-refer-article t]
1691 ["Redisplay" gnus-summary-show-article t])))
1693 gnus-summary-article-menu gnus-summary-mode-map ""
1694 (cons "Article" innards))
1697 gnus-article-commands-menu gnus-article-mode-map ""
1698 (cons "Commands" innards)))
1701 gnus-summary-thread-menu gnus-summary-mode-map ""
1703 ["Toggle threading" gnus-summary-toggle-threads t]
1704 ["Hide threads" gnus-summary-hide-all-threads t]
1705 ["Show threads" gnus-summary-show-all-threads t]
1706 ["Hide thread" gnus-summary-hide-thread t]
1707 ["Show thread" gnus-summary-show-thread t]
1708 ["Go to next thread" gnus-summary-next-thread t]
1709 ["Go to previous thread" gnus-summary-prev-thread t]
1710 ["Go down thread" gnus-summary-down-thread t]
1711 ["Go up thread" gnus-summary-up-thread t]
1712 ["Top of thread" gnus-summary-top-thread t]
1713 ["Mark thread as read" gnus-summary-kill-thread t]
1714 ["Lower thread score" gnus-summary-lower-thread t]
1715 ["Raise thread score" gnus-summary-raise-thread t]
1716 ["Rethread current" gnus-summary-rethread-current t]
1720 gnus-summary-post-menu gnus-summary-mode-map ""
1722 ["Post an article" gnus-summary-post-news t]
1723 ["Followup" gnus-summary-followup t]
1724 ["Followup and yank" gnus-summary-followup-with-original t]
1725 ["Supersede article" gnus-summary-supersede-article t]
1726 ["Cancel article" gnus-summary-cancel-article t]
1727 ["Reply" gnus-summary-reply t]
1728 ["Reply and yank" gnus-summary-reply-with-original t]
1729 ["Wide reply" gnus-summary-wide-reply t]
1730 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1731 ["Mail forward" gnus-summary-mail-forward t]
1732 ["Post forward" gnus-summary-post-forward t]
1733 ["Digest and mail" gnus-summary-mail-digest t]
1734 ["Digest and post" gnus-summary-post-digest t]
1735 ["Resend message" gnus-summary-resend-message t]
1736 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1737 ["Send a mail" gnus-summary-mail-other-window t]
1738 ["Uuencode and post" gnus-uu-post-news t]
1739 ["Followup via news" gnus-summary-followup-to-mail t]
1740 ["Followup via news and yank"
1741 gnus-summary-followup-to-mail-with-original t]
1743 ;;["Send" gnus-summary-send-draft t]
1744 ;;["Send bounced" gnus-resend-bounced-mail t])
1748 gnus-summary-misc-menu gnus-summary-mode-map ""
1751 ["Mark as read" gnus-summary-mark-as-read-forward t]
1752 ["Mark same subject and select"
1753 gnus-summary-kill-same-subject-and-select t]
1754 ["Mark same subject" gnus-summary-kill-same-subject t]
1755 ["Catchup" gnus-summary-catchup t]
1756 ["Catchup all" gnus-summary-catchup-all t]
1757 ["Catchup to here" gnus-summary-catchup-to-here t]
1758 ["Catchup region" gnus-summary-mark-region-as-read t]
1759 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1761 ["Tick" gnus-summary-tick-article-forward t]
1762 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1763 ["Remove marks" gnus-summary-clear-mark-forward t]
1764 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1765 ["Set bookmark" gnus-summary-set-bookmark t]
1766 ["Remove bookmark" gnus-summary-remove-bookmark t])
1768 ["Marks..." gnus-summary-limit-to-marks t]
1769 ["Subject..." gnus-summary-limit-to-subject t]
1770 ["Author..." gnus-summary-limit-to-author t]
1771 ["Age..." gnus-summary-limit-to-age t]
1772 ["Extra..." gnus-summary-limit-to-extra t]
1773 ["Score" gnus-summary-limit-to-score t]
1774 ["Unread" gnus-summary-limit-to-unread t]
1775 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1776 ["Articles" gnus-summary-limit-to-articles t]
1777 ["Pop limit" gnus-summary-pop-limit t]
1778 ["Show dormant" gnus-summary-limit-include-dormant t]
1779 ["Hide childless dormant"
1780 gnus-summary-limit-exclude-childless-dormant t]
1781 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1782 ["Hide marked" gnus-summary-limit-exclude-marks t]
1783 ["Show expunged" gnus-summary-show-all-expunged t])
1785 ["Set mark" gnus-summary-mark-as-processable t]
1786 ["Remove mark" gnus-summary-unmark-as-processable t]
1787 ["Remove all marks" gnus-summary-unmark-all-processable t]
1788 ["Mark above" gnus-uu-mark-over t]
1789 ["Mark series" gnus-uu-mark-series t]
1790 ["Mark region" gnus-uu-mark-region t]
1791 ["Unmark region" gnus-uu-unmark-region t]
1792 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1793 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1794 ["Mark all" gnus-uu-mark-all t]
1795 ["Mark buffer" gnus-uu-mark-buffer t]
1796 ["Mark sparse" gnus-uu-mark-sparse t]
1797 ["Mark thread" gnus-uu-mark-thread t]
1798 ["Unmark thread" gnus-uu-unmark-thread t]
1799 ("Process Mark Sets"
1800 ["Kill" gnus-summary-kill-process-mark t]
1801 ["Yank" gnus-summary-yank-process-mark
1802 gnus-newsgroup-process-stack]
1803 ["Save" gnus-summary-save-process-mark t]))
1805 ["Page forward" gnus-summary-next-page t]
1806 ["Page backward" gnus-summary-prev-page t]
1807 ["Line forward" gnus-summary-scroll-up t])
1809 ["Next unread article" gnus-summary-next-unread-article t]
1810 ["Previous unread article" gnus-summary-prev-unread-article t]
1811 ["Next article" gnus-summary-next-article t]
1812 ["Previous article" gnus-summary-prev-article t]
1813 ["Next unread subject" gnus-summary-next-unread-subject t]
1814 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1815 ["Next article same subject" gnus-summary-next-same-subject t]
1816 ["Previous article same subject" gnus-summary-prev-same-subject t]
1817 ["First unread article" gnus-summary-first-unread-article t]
1818 ["Best unread article" gnus-summary-best-unread-article t]
1819 ["Go to subject number..." gnus-summary-goto-subject t]
1820 ["Go to article number..." gnus-summary-goto-article t]
1821 ["Go to the last article" gnus-summary-goto-last-article t]
1822 ["Pop article off history" gnus-summary-pop-article t])
1824 ["Sort by number" gnus-summary-sort-by-number t]
1825 ["Sort by author" gnus-summary-sort-by-author t]
1826 ["Sort by subject" gnus-summary-sort-by-subject t]
1827 ["Sort by date" gnus-summary-sort-by-date t]
1828 ["Sort by score" gnus-summary-sort-by-score t]
1829 ["Sort by lines" gnus-summary-sort-by-lines t]
1830 ["Sort by characters" gnus-summary-sort-by-chars t])
1832 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1833 ["Describe group" gnus-summary-describe-group t]
1834 ["Read manual" gnus-info-find-node t])
1836 ["Pick and read" gnus-pick-mode t]
1837 ["Binary" gnus-binary-mode t])
1839 ["Regenerate" gnus-summary-prepare t]
1840 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1841 ["Toggle threading" gnus-summary-toggle-threads t])
1842 ["Filter articles..." gnus-summary-execute-command t]
1843 ["Run command on subjects..." gnus-summary-universal-argument t]
1844 ["Search articles forward..." gnus-summary-search-article-forward t]
1845 ["Search articles backward..." gnus-summary-search-article-backward t]
1846 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1847 ["Expand window" gnus-summary-expand-window t]
1848 ["Expire expirable articles" gnus-summary-expire-articles
1849 (gnus-check-backend-function
1850 'request-expire-articles gnus-newsgroup-name)]
1851 ["Edit local kill file" gnus-summary-edit-local-kill t]
1852 ["Edit main kill file" gnus-summary-edit-global-kill t]
1853 ["Edit group parameters" gnus-summary-edit-parameters t]
1854 ["Customize group parameters" gnus-summary-customize-parameters t]
1855 ["Send a bug report" gnus-bug t]
1857 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1858 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1859 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1860 ["Exit group" gnus-summary-exit t]
1861 ["Exit group without updating" gnus-summary-exit-no-update t]
1862 ["Exit and goto next group" gnus-summary-next-group t]
1863 ["Exit and goto prev group" gnus-summary-prev-group t]
1864 ["Reselect group" gnus-summary-reselect-current-group t]
1865 ["Rescan group" gnus-summary-rescan-group t]
1866 ["Update dribble" gnus-summary-save-newsrc t])))
1868 (gnus-run-hooks 'gnus-summary-menu-hook)))
1870 (defun gnus-score-set-default (var value)
1871 "A version of set that updates the GNU Emacs menu-bar."
1873 ;; It is the message that forces the active status to be updated.
1876 (defun gnus-make-score-map (type)
1877 "Make a summary score map of type TYPE."
1880 (let ((headers '(("author" "from" string)
1881 ("subject" "subject" string)
1882 ("article body" "body" string)
1883 ("article head" "head" string)
1884 ("xref" "xref" string)
1885 ("extra header" "extra" string)
1886 ("lines" "lines" number)
1887 ("followups to author" "followup" string)))
1888 (types '((number ("less than" <)
1891 (string ("substring" s)
1895 (perms '(("temporary" (current-time-string))
1903 (if (eq type 'lower)
1908 (setq header (car headers))
1914 (let ((ts (cdr (assoc (nth 2 header) types)))
1930 'gnus-summary-score-entry
1932 (if (or (string= (nth 1 header)
1934 (string= (nth 1 header)
1937 (list 'gnus-summary-header
1939 (list 'quote (nth 1 (car ts)))
1940 (list 'gnus-score-default nil)
1946 (list (nreverse outp))))
1949 (list (nreverse outt))))
1951 (setq headers (cdr headers)))
1952 (list (nreverse outh))))))))
1956 (defun gnus-summary-mode (&optional group)
1957 "Major mode for reading articles.
1959 All normal editing commands are switched off.
1960 \\<gnus-summary-mode-map>
1961 Each line in this buffer represents one article. To read an
1962 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1963 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1966 You can also post articles and send mail from this buffer. To
1967 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1968 of an article, type `\\[gnus-summary-reply]'.
1970 There are approx. one gazillion commands you can execute in this
1971 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1973 The following commands are available:
1975 \\{gnus-summary-mode-map}"
1977 (when (gnus-visual-p 'summary-menu 'menu)
1978 (gnus-summary-make-menu-bar))
1979 (kill-all-local-variables)
1980 (gnus-summary-make-local-variables)
1981 (gnus-make-thread-indent-array)
1982 (gnus-simplify-mode-line)
1983 (setq major-mode 'gnus-summary-mode)
1984 (setq mode-name "Summary")
1985 (make-local-variable 'minor-mode-alist)
1986 (use-local-map gnus-summary-mode-map)
1987 (buffer-disable-undo)
1988 (setq buffer-read-only t) ;Disable modification
1989 (setq truncate-lines t)
1990 (setq selective-display t)
1991 (setq selective-display-ellipses t) ;Display `...'
1992 (gnus-summary-set-display-table)
1993 (gnus-set-default-directory)
1994 (setq gnus-newsgroup-name group)
1995 (make-local-variable 'gnus-summary-line-format)
1996 (make-local-variable 'gnus-summary-line-format-spec)
1997 (make-local-variable 'gnus-summary-dummy-line-format)
1998 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1999 (make-local-variable 'gnus-summary-mark-positions)
2000 (make-local-hook 'pre-command-hook)
2001 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2002 (gnus-run-hooks 'gnus-summary-mode-hook)
2003 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2004 (gnus-update-summary-mark-positions))
2006 (defun gnus-summary-make-local-variables ()
2007 "Make all the local summary buffer variables."
2009 (dolist (local gnus-summary-local-variables)
2012 (if (eq (cdr local) 'global)
2013 ;; Copy the global value of the variable.
2014 (setq global (symbol-value (car local)))
2015 ;; Use the value from the list.
2016 (setq global (eval (cdr local))))
2017 (set (make-local-variable (car local)) global))
2018 ;; Simple nil-valued local variable.
2019 (set (make-local-variable local) nil)))))
2021 (defun gnus-summary-clear-local-variables ()
2022 (let ((locals gnus-summary-local-variables))
2024 (if (consp (car locals))
2025 (and (vectorp (caar locals))
2026 (set (caar locals) nil))
2027 (and (vectorp (car locals))
2028 (set (car locals) nil)))
2029 (setq locals (cdr locals)))))
2031 ;; Summary data functions.
2033 (defmacro gnus-data-number (data)
2036 (defmacro gnus-data-set-number (data number)
2037 `(setcar ,data ,number))
2039 (defmacro gnus-data-mark (data)
2042 (defmacro gnus-data-set-mark (data mark)
2043 `(setcar (nthcdr 1 ,data) ,mark))
2045 (defmacro gnus-data-pos (data)
2048 (defmacro gnus-data-set-pos (data pos)
2049 `(setcar (nthcdr 2 ,data) ,pos))
2051 (defmacro gnus-data-header (data)
2054 (defmacro gnus-data-set-header (data header)
2055 `(setf (nth 3 ,data) ,header))
2057 (defmacro gnus-data-level (data)
2060 (defmacro gnus-data-unread-p (data)
2061 `(= (nth 1 ,data) gnus-unread-mark))
2063 (defmacro gnus-data-read-p (data)
2064 `(/= (nth 1 ,data) gnus-unread-mark))
2066 (defmacro gnus-data-pseudo-p (data)
2067 `(consp (nth 3 ,data)))
2069 (defmacro gnus-data-find (number)
2070 `(assq ,number gnus-newsgroup-data))
2072 (defmacro gnus-data-find-list (number &optional data)
2073 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2074 (memq (assq ,number bdata)
2077 (defmacro gnus-data-make (number mark pos header level)
2078 `(list ,number ,mark ,pos ,header ,level))
2080 (defun gnus-data-enter (after-article number mark pos header level offset)
2081 (let ((data (gnus-data-find-list after-article)))
2083 (error "No such article: %d" after-article))
2084 (setcdr data (cons (gnus-data-make number mark pos header level)
2086 (setq gnus-newsgroup-data-reverse nil)
2087 (gnus-data-update-list (cddr data) offset)))
2089 (defun gnus-data-enter-list (after-article list &optional offset)
2091 (let ((data (and after-article (gnus-data-find-list after-article)))
2095 (let ((odata gnus-newsgroup-data))
2096 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2098 (gnus-data-update-list odata offset)))
2099 ;; Find the last element in the list to be spliced into the main
2102 (setq list (cdr list)))
2105 (setcdr list gnus-newsgroup-data)
2106 (setq gnus-newsgroup-data ilist)
2108 (gnus-data-update-list (cdr list) offset)))
2109 (setcdr list (cdr data))
2112 (gnus-data-update-list (cdr list) offset))))
2113 (setq gnus-newsgroup-data-reverse nil))))
2115 (defun gnus-data-remove (article &optional offset)
2116 (let ((data gnus-newsgroup-data))
2117 (if (= (gnus-data-number (car data)) article)
2119 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2120 gnus-newsgroup-data-reverse nil)
2122 (gnus-data-update-list gnus-newsgroup-data offset)))
2124 (when (= (gnus-data-number (cadr data)) article)
2125 (setcdr data (cddr data))
2127 (gnus-data-update-list (cdr data) offset))
2129 gnus-newsgroup-data-reverse nil))
2130 (setq data (cdr data))))))
2132 (defmacro gnus-data-list (backward)
2134 (or gnus-newsgroup-data-reverse
2135 (setq gnus-newsgroup-data-reverse
2136 (reverse gnus-newsgroup-data)))
2137 gnus-newsgroup-data))
2139 (defun gnus-data-update-list (data offset)
2140 "Add OFFSET to the POS of all data entries in DATA."
2141 (setq gnus-newsgroup-data-reverse nil)
2143 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2144 (setq data (cdr data))))
2146 (defun gnus-summary-article-pseudo-p (article)
2147 "Say whether this article is a pseudo article or not."
2148 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2150 (defmacro gnus-summary-article-sparse-p (article)
2151 "Say whether this article is a sparse article or not."
2152 `(memq ,article gnus-newsgroup-sparse))
2154 (defmacro gnus-summary-article-ancient-p (article)
2155 "Say whether this article is a sparse article or not."
2156 `(memq ,article gnus-newsgroup-ancient))
2158 (defun gnus-article-parent-p (number)
2159 "Say whether this article is a parent or not."
2160 (let ((data (gnus-data-find-list number)))
2161 (and (cdr data) ; There has to be an article after...
2162 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2163 (gnus-data-level (nth 1 data))))))
2165 (defun gnus-article-children (number)
2166 "Return a list of all children to NUMBER."
2167 (let* ((data (gnus-data-find-list number))
2168 (level (gnus-data-level (car data)))
2170 (setq data (cdr data))
2172 (= (gnus-data-level (car data)) (1+ level)))
2173 (push (gnus-data-number (car data)) children)
2174 (setq data (cdr data)))
2177 (defmacro gnus-summary-skip-intangible ()
2178 "If the current article is intangible, then jump to a different article."
2179 '(let ((to (get-text-property (point) 'gnus-intangible)))
2180 (and to (gnus-summary-goto-subject to))))
2182 (defmacro gnus-summary-article-intangible-p ()
2183 "Say whether this article is intangible or not."
2184 '(get-text-property (point) 'gnus-intangible))
2186 (defun gnus-article-read-p (article)
2187 "Say whether ARTICLE is read or not."
2188 (not (or (memq article gnus-newsgroup-marked)
2189 (memq article gnus-newsgroup-unreads)
2190 (memq article gnus-newsgroup-unselected)
2191 (memq article gnus-newsgroup-dormant))))
2193 ;; Some summary mode macros.
2195 (defmacro gnus-summary-article-number ()
2196 "The article number of the article on the current line.
2197 If there isn's an article number here, then we return the current
2200 (gnus-summary-skip-intangible)
2201 (or (get-text-property (point) 'gnus-number)
2202 (gnus-summary-last-subject))))
2204 (defmacro gnus-summary-article-header (&optional number)
2205 "Return the header of article NUMBER."
2206 `(gnus-data-header (gnus-data-find
2207 ,(or number '(gnus-summary-article-number)))))
2209 (defmacro gnus-summary-thread-level (&optional number)
2210 "Return the level of thread that starts with article NUMBER."
2211 `(if (and (eq gnus-summary-make-false-root 'dummy)
2212 (get-text-property (point) 'gnus-intangible))
2214 (gnus-data-level (gnus-data-find
2215 ,(or number '(gnus-summary-article-number))))))
2217 (defmacro gnus-summary-article-mark (&optional number)
2218 "Return the mark of article NUMBER."
2219 `(gnus-data-mark (gnus-data-find
2220 ,(or number '(gnus-summary-article-number)))))
2222 (defmacro gnus-summary-article-pos (&optional number)
2223 "Return the position of the line of article NUMBER."
2224 `(gnus-data-pos (gnus-data-find
2225 ,(or number '(gnus-summary-article-number)))))
2227 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2228 (defmacro gnus-summary-article-subject (&optional number)
2229 "Return current subject string or nil if nothing."
2232 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2233 '(gnus-data-header (assq (gnus-summary-article-number)
2234 gnus-newsgroup-data)))))
2237 (mail-header-subject headers))))
2239 (defmacro gnus-summary-article-score (&optional number)
2240 "Return current article score."
2241 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2242 gnus-newsgroup-scored))
2243 gnus-summary-default-score 0))
2245 (defun gnus-summary-article-children (&optional number)
2246 "Return a list of article numbers that are children of article NUMBER."
2247 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2248 (level (gnus-data-level (car data)))
2250 (while (and (setq data (cdr data))
2251 (> (setq l (gnus-data-level (car data))) level))
2252 (and (= (1+ level) l)
2253 (push (gnus-data-number (car data))
2255 (nreverse children)))
2257 (defun gnus-summary-article-parent (&optional number)
2258 "Return the article number of the parent of article NUMBER."
2259 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2260 (gnus-data-list t)))
2261 (level (gnus-data-level (car data))))
2263 () ; This is a root.
2264 ;; We search until we find an article with a level less than
2265 ;; this one. That function has to be the parent.
2266 (while (and (setq data (cdr data))
2267 (not (< (gnus-data-level (car data)) level))))
2268 (and data (gnus-data-number (car data))))))
2270 (defun gnus-unread-mark-p (mark)
2271 "Say whether MARK is the unread mark."
2272 (= mark gnus-unread-mark))
2274 (defun gnus-read-mark-p (mark)
2275 "Say whether MARK is one of the marks that mark as read.
2276 This is all marks except unread, ticked, dormant, and expirable."
2277 (not (or (= mark gnus-unread-mark)
2278 (= mark gnus-ticked-mark)
2279 (= mark gnus-dormant-mark)
2280 (= mark gnus-expirable-mark))))
2282 (defmacro gnus-article-mark (number)
2283 "Return the MARK of article NUMBER.
2284 This macro should only be used when computing the mark the \"first\"
2285 time; i.e., when generating the summary lines. After that,
2286 `gnus-summary-article-mark' should be used to examine the
2289 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2290 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2291 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2292 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2293 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2294 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2295 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2296 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2297 gnus-ancient-mark))))
2299 ;; Saving hidden threads.
2301 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2302 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2304 (defmacro gnus-save-hidden-threads (&rest forms)
2305 "Save hidden threads, eval FORMS, and restore the hidden threads."
2306 (let ((config (make-symbol "config")))
2307 `(let ((,config (gnus-hidden-threads-configuration)))
2311 (gnus-restore-hidden-threads-configuration ,config)))))
2313 (defun gnus-data-compute-positions ()
2314 "Compute the positions of all articles."
2315 (setq gnus-newsgroup-data-reverse nil)
2316 (let ((data gnus-newsgroup-data))
2318 (gnus-save-hidden-threads
2319 (gnus-summary-show-all-threads)
2320 (goto-char (point-min))
2322 (while (get-text-property (point) 'gnus-intangible)
2324 (gnus-data-set-pos (car data) (+ (point) 3))
2325 (setq data (cdr data))
2326 (forward-line 1))))))
2328 (defun gnus-hidden-threads-configuration ()
2329 "Return the current hidden threads configuration."
2332 (goto-char (point-min))
2333 (while (search-forward "\r" nil t)
2334 (push (1- (point)) config))
2337 (defun gnus-restore-hidden-threads-configuration (config)
2338 "Restore hidden threads configuration from CONFIG."
2339 (let (point buffer-read-only)
2340 (while (setq point (pop config))
2341 (when (and (< point (point-max))
2343 (eq (char-after) ?\n))
2344 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2346 ;; Various summary mode internalish functions.
2348 (defun gnus-mouse-pick-article (e)
2351 (gnus-summary-next-page nil t))
2353 (defun gnus-summary-set-display-table ()
2354 ;; Change the display table. Odd characters have a tendency to mess
2355 ;; up nicely formatted displays - we make all possible glyphs
2356 ;; display only a single character.
2358 ;; We start from the standard display table, if any.
2359 (let ((table (or (copy-sequence standard-display-table)
2360 (make-display-table)))
2362 ;; Nix out all the control chars...
2363 (while (>= (setq i (1- i)) 0)
2364 (aset table i [??]))
2365 ;; ... but not newline and cr, of course. (cr is necessary for the
2366 ;; selective display).
2367 (aset table ?\n nil)
2368 (aset table ?\r nil)
2369 ;; We keep TAB as well.
2370 (aset table ?\t nil)
2371 ;; We nix out any glyphs over 126 that are not set already.
2373 (while (>= (setq i (1- i)) 127)
2374 ;; Only modify if the entry is nil.
2375 (unless (aref table i)
2376 (aset table i [??]))))
2377 (setq buffer-display-table table)))
2379 (defun gnus-summary-setup-buffer (group)
2380 "Initialize summary buffer."
2381 (let ((buffer (concat "*Summary " group "*")))
2382 (if (get-buffer buffer)
2385 (setq gnus-summary-buffer (current-buffer))
2386 (not gnus-newsgroup-prepared))
2387 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2388 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2389 (gnus-summary-mode group)
2391 (gnus-carpal-setup-buffer 'summary))
2392 (unless gnus-single-article-buffer
2393 (make-local-variable 'gnus-article-buffer)
2394 (make-local-variable 'gnus-article-current)
2395 (make-local-variable 'gnus-original-article-buffer))
2396 (setq gnus-newsgroup-name group)
2399 (defun gnus-set-global-variables ()
2400 ;; Set the global equivalents of the summary buffer-local variables
2401 ;; to the latest values they had. These reflect the summary buffer
2402 ;; that was in action when the last article was fetched.
2403 (when (eq major-mode 'gnus-summary-mode)
2404 (setq gnus-summary-buffer (current-buffer))
2405 (let ((name gnus-newsgroup-name)
2406 (marked gnus-newsgroup-marked)
2407 (unread gnus-newsgroup-unreads)
2408 (headers gnus-current-headers)
2409 (data gnus-newsgroup-data)
2410 (summary gnus-summary-buffer)
2411 (article-buffer gnus-article-buffer)
2412 (original gnus-original-article-buffer)
2413 (gac gnus-article-current)
2414 (reffed gnus-reffed-article-number)
2415 (score-file gnus-current-score-file)
2416 (default-charset gnus-newsgroup-charset))
2418 (set-buffer gnus-group-buffer)
2419 (setq gnus-newsgroup-name name
2420 gnus-newsgroup-marked marked
2421 gnus-newsgroup-unreads unread
2422 gnus-current-headers headers
2423 gnus-newsgroup-data data
2424 gnus-article-current gac
2425 gnus-summary-buffer summary
2426 gnus-article-buffer article-buffer
2427 gnus-original-article-buffer original
2428 gnus-reffed-article-number reffed
2429 gnus-current-score-file score-file
2430 gnus-newsgroup-charset default-charset)
2431 ;; The article buffer also has local variables.
2432 (when (gnus-buffer-live-p gnus-article-buffer)
2433 (set-buffer gnus-article-buffer)
2434 (setq gnus-summary-buffer summary))))))
2436 (defun gnus-summary-article-unread-p (article)
2437 "Say whether ARTICLE is unread or not."
2438 (memq article gnus-newsgroup-unreads))
2440 (defun gnus-summary-first-article-p (&optional article)
2441 "Return whether ARTICLE is the first article in the buffer."
2442 (if (not (setq article (or article (gnus-summary-article-number))))
2444 (eq article (caar gnus-newsgroup-data))))
2446 (defun gnus-summary-last-article-p (&optional article)
2447 "Return whether ARTICLE is the last article in the buffer."
2448 (if (not (setq article (or article (gnus-summary-article-number))))
2449 ;; All non-existent numbers are the last article. :-)
2451 (not (cdr (gnus-data-find-list article)))))
2453 (defun gnus-make-thread-indent-array ()
2455 (unless (and gnus-thread-indent-array
2456 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2457 (setq gnus-thread-indent-array (make-vector 201 "")
2458 gnus-thread-indent-array-level gnus-thread-indent-level)
2460 (aset gnus-thread-indent-array n
2461 (make-string (* n gnus-thread-indent-level) ? ))
2464 (defun gnus-update-summary-mark-positions ()
2465 "Compute where the summary marks are to go."
2467 (when (gnus-buffer-exists-p gnus-summary-buffer)
2468 (set-buffer gnus-summary-buffer))
2469 (let ((gnus-replied-mark 129)
2470 (gnus-score-below-mark 130)
2471 (gnus-score-over-mark 130)
2472 (gnus-download-mark 131)
2473 (spec gnus-summary-line-format-spec)
2476 (gnus-set-work-buffer)
2477 (let ((gnus-summary-line-format-spec spec)
2478 (gnus-newsgroup-downloadable '((0 . t))))
2479 (gnus-summary-insert-line
2480 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2481 0 nil 128 t nil "" nil 1)
2482 (goto-char (point-min))
2483 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2485 (goto-char (point-min))
2486 (push (cons 'replied (and (search-forward "\201" nil t)
2489 (goto-char (point-min))
2490 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2492 (goto-char (point-min))
2493 (push (cons 'download
2494 (and (search-forward "\203" nil t) (- (point) 2)))
2496 (setq gnus-summary-mark-positions pos))))
2498 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2499 "Insert a dummy root in the summary buffer."
2501 (gnus-add-text-properties
2502 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2503 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2505 (defun gnus-summary-from-or-to-or-newsgroups (header)
2506 (let ((to (cdr (assq 'To (mail-header-extra header))))
2507 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2508 (mail-parse-charset gnus-newsgroup-charset)
2509 (mail-parse-ignored-charsets
2510 (save-excursion (set-buffer gnus-summary-buffer)
2511 gnus-newsgroup-ignored-charsets)))
2514 gnus-ignored-from-addresses
2515 (string-match gnus-ignored-from-addresses
2516 (mail-header-from header)))
2518 (or (car (funcall gnus-extract-address-components
2520 gnus-decode-encoded-word-function to)))
2521 (funcall gnus-decode-encoded-word-function to))))
2523 gnus-ignored-from-addresses
2524 (string-match gnus-ignored-from-addresses
2525 (mail-header-from header)))
2526 (concat "=> " newsgroups))
2528 (or (car (funcall gnus-extract-address-components
2529 (mail-header-from header)))
2530 (mail-header-from header))))))
2532 (defun gnus-summary-insert-line (gnus-tmp-header
2533 gnus-tmp-level gnus-tmp-current
2534 gnus-tmp-unread gnus-tmp-replied
2535 gnus-tmp-expirable gnus-tmp-subject-or-nil
2536 &optional gnus-tmp-dummy gnus-tmp-score
2538 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2539 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2540 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2541 (gnus-tmp-score-char
2542 (if (or (null gnus-summary-default-score)
2543 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2544 gnus-summary-zcore-fuzz))
2546 (if (< gnus-tmp-score gnus-summary-default-score)
2547 gnus-score-below-mark gnus-score-over-mark)))
2549 (cond (gnus-tmp-process gnus-process-mark)
2550 ((memq gnus-tmp-current gnus-newsgroup-cached)
2552 (gnus-tmp-replied gnus-replied-mark)
2553 ((memq gnus-tmp-current gnus-newsgroup-saved)
2555 (t gnus-unread-mark)))
2556 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2559 ((string-match "<[^>]+> *$" gnus-tmp-from)
2560 (let ((beg (match-beginning 0)))
2561 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2562 (substring gnus-tmp-from (1+ (match-beginning 0))
2563 (1- (match-end 0))))
2564 (substring gnus-tmp-from 0 beg))))
2565 ((string-match "(.+)" gnus-tmp-from)
2566 (substring gnus-tmp-from
2567 (1+ (match-beginning 0)) (1- (match-end 0))))
2569 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2570 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2571 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2572 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2573 (buffer-read-only nil))
2574 (when (string= gnus-tmp-name "")
2575 (setq gnus-tmp-name gnus-tmp-from))
2576 (unless (numberp gnus-tmp-lines)
2577 (setq gnus-tmp-lines 0))
2578 (gnus-put-text-property-excluding-characters-with-faces
2580 (progn (eval gnus-summary-line-format-spec) (point))
2581 'gnus-number gnus-tmp-number)
2582 (when (gnus-visual-p 'summary-highlight 'highlight)
2584 (gnus-run-hooks 'gnus-summary-update-hook)
2587 (defun gnus-summary-update-line (&optional dont-update)
2588 ;; Update summary line after change.
2589 (when (and gnus-summary-default-score
2590 (not gnus-summary-inhibit-highlight))
2591 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2592 (article (gnus-summary-article-number))
2593 (score (gnus-summary-article-score article)))
2595 (if (and gnus-summary-mark-below
2596 (< (gnus-summary-article-score)
2597 gnus-summary-mark-below))
2598 ;; This article has a low score, so we mark it as read.
2599 (when (memq article gnus-newsgroup-unreads)
2600 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2601 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2602 ;; This article was previously marked as read on account
2603 ;; of a low score, but now it has risen, so we mark it as
2605 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2606 (gnus-summary-update-mark
2607 (if (or (null gnus-summary-default-score)
2608 (<= (abs (- score gnus-summary-default-score))
2609 gnus-summary-zcore-fuzz))
2611 (if (< score gnus-summary-default-score)
2612 gnus-score-below-mark gnus-score-over-mark))
2614 ;; Do visual highlighting.
2615 (when (gnus-visual-p 'summary-highlight 'highlight)
2616 (gnus-run-hooks 'gnus-summary-update-hook)))))
2618 (defvar gnus-tmp-new-adopts nil)
2620 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2621 "Return the number of articles in THREAD.
2622 This may be 0 in some cases -- if none of the articles in
2623 the thread are to be displayed."
2625 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2627 ((not (listp thread))
2629 ((and (consp thread) (cdr thread))
2632 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2635 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2638 (when (and level (zerop level) gnus-tmp-new-adopts)
2641 'gnus-summary-number-of-articles-in-thread
2642 gnus-tmp-new-adopts))))
2644 (if (> number 1) gnus-not-empty-thread-mark
2645 gnus-empty-thread-mark)
2648 (defun gnus-summary-set-local-parameters (group)
2649 "Go through the local params of GROUP and set all variable specs in that list."
2650 (let ((params (gnus-group-find-parameter group))
2653 (setq elem (car params)
2654 params (cdr params))
2655 (and (consp elem) ; Has to be a cons.
2656 (consp (cdr elem)) ; The cdr has to be a list.
2657 (symbolp (car elem)) ; Has to be a symbol in there.
2658 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2659 (ignore-errors ; So we set it.
2660 (make-local-variable (car elem))
2661 (set (car elem) (eval (nth 1 elem))))))))
2663 (defun gnus-summary-read-group (group &optional show-all no-article
2664 kill-buffer no-display backward
2666 "Start reading news in newsgroup GROUP.
2667 If SHOW-ALL is non-nil, already read articles are also listed.
2668 If NO-ARTICLE is non-nil, no article is selected initially.
2669 If NO-DISPLAY, don't generate a summary buffer."
2673 (let ((gnus-auto-select-next nil))
2674 (or (gnus-summary-read-group-1
2675 group show-all no-article
2676 kill-buffer no-display
2679 select-articles nil)))))
2680 (eq gnus-auto-select-next 'quietly))
2681 (set-buffer gnus-group-buffer)
2682 ;; The entry function called above goes to the next
2683 ;; group automatically, so we go two groups back
2684 ;; if we are searching for the previous group.
2686 (gnus-group-prev-unread-group 2))
2687 (if (not (equal group (gnus-group-group-name)))
2688 (setq group (gnus-group-group-name))
2692 (defun gnus-summary-read-group-1 (group show-all no-article
2693 kill-buffer no-display
2694 &optional select-articles)
2695 ;; Killed foreign groups can't be entered.
2696 (when (and (not (gnus-group-native-p group))
2697 (not (gnus-gethash group gnus-newsrc-hashtb)))
2698 (error "Dead non-native groups can't be entered"))
2699 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2700 (let* ((new-group (gnus-summary-setup-buffer group))
2701 (quit-config (gnus-group-quit-config group))
2702 (did-select (and new-group (gnus-select-newsgroup
2703 group show-all select-articles))))
2705 ;; This summary buffer exists already, so we just select it.
2707 (gnus-set-global-variables)
2709 (gnus-kill-or-deaden-summary kill-buffer))
2710 (gnus-configure-windows 'summary 'force)
2711 (gnus-set-mode-line 'summary)
2712 (gnus-summary-position-point)
2715 ;; We couldn't select this group.
2717 (when (and (eq major-mode 'gnus-summary-mode)
2718 (not (equal (current-buffer) kill-buffer)))
2719 (kill-buffer (current-buffer))
2720 (if (not quit-config)
2722 ;; Update the info -- marks might need to be removed,
2724 (gnus-summary-update-info)
2725 (set-buffer gnus-group-buffer)
2726 (gnus-group-jump-to-group group)
2727 (gnus-group-next-unread-group 1))
2728 (gnus-handle-ephemeral-exit quit-config)))
2729 (gnus-message 3 "Can't select group")
2731 ;; The user did a `C-g' while prompting for number of articles,
2732 ;; so we exit this group.
2733 ((eq did-select 'quit)
2734 (and (eq major-mode 'gnus-summary-mode)
2735 (not (equal (current-buffer) kill-buffer))
2736 (kill-buffer (current-buffer)))
2738 (gnus-kill-or-deaden-summary kill-buffer))
2739 (if (not quit-config)
2741 (set-buffer gnus-group-buffer)
2742 (gnus-group-jump-to-group group)
2743 (gnus-group-next-unread-group 1)
2744 (gnus-configure-windows 'group 'force))
2745 (gnus-handle-ephemeral-exit quit-config))
2746 ;; Finally signal the quit.
2748 ;; The group was successfully selected.
2750 (gnus-set-global-variables)
2751 ;; Save the active value in effect when the group was entered.
2752 (setq gnus-newsgroup-active
2754 (gnus-active gnus-newsgroup-name)))
2755 ;; You can change the summary buffer in some way with this hook.
2756 (gnus-run-hooks 'gnus-select-group-hook)
2757 ;; Set any local variables in the group parameters.
2758 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2759 (gnus-update-format-specifications
2760 nil 'summary 'summary-mode 'summary-dummy)
2761 (gnus-update-summary-mark-positions)
2762 ;; Do score processing.
2763 (when gnus-use-scoring
2764 (gnus-possibly-score-headers))
2765 ;; Check whether to fill in the gaps in the threads.
2766 (when gnus-build-sparse-threads
2767 (gnus-build-sparse-threads))
2768 ;; Find the initial limit.
2769 (if gnus-show-threads
2771 (let ((gnus-newsgroup-dormant nil))
2772 (gnus-summary-initial-limit show-all))
2773 (gnus-summary-initial-limit show-all))
2774 (setq gnus-newsgroup-limit
2776 (lambda (header) (mail-header-number header))
2777 gnus-newsgroup-headers)))
2778 ;; Generate the summary buffer.
2780 (gnus-summary-prepare))
2781 (when gnus-use-trees
2782 (gnus-tree-open group)
2783 (setq gnus-summary-highlight-line-function
2784 'gnus-tree-highlight-article))
2785 ;; If the summary buffer is empty, but there are some low-scored
2786 ;; articles or some excluded dormants, we include these in the
2788 (when (and (zerop (buffer-size))
2790 (cond (gnus-newsgroup-dormant
2791 (gnus-summary-limit-include-dormant))
2792 ((and gnus-newsgroup-scored show-all)
2793 (gnus-summary-limit-include-expunged t))))
2794 ;; Function `gnus-apply-kill-file' must be called in this hook.
2795 (gnus-run-hooks 'gnus-apply-kill-hook)
2796 (if (and (zerop (buffer-size))
2799 ;; This newsgroup is empty.
2800 (gnus-summary-catchup-and-exit nil t)
2801 (gnus-message 6 "No unread news")
2803 (gnus-kill-or-deaden-summary kill-buffer))
2804 ;; Return nil from this function.
2806 ;; Hide conversation thread subtrees. We cannot do this in
2807 ;; gnus-summary-prepare-hook since kill processing may not
2808 ;; work with hidden articles.
2809 (and gnus-show-threads
2810 gnus-thread-hide-subtree
2811 (gnus-summary-hide-all-threads))
2813 (gnus-kill-or-deaden-summary kill-buffer))
2814 ;; Show first unread article if requested.
2815 (if (and (not no-article)
2817 gnus-newsgroup-unreads
2818 gnus-auto-select-first)
2820 (gnus-configure-windows 'summary)
2822 ((eq gnus-auto-select-first 'best)
2823 (gnus-summary-best-unread-article))
2824 ((eq gnus-auto-select-first t)
2825 (gnus-summary-first-unread-article))
2826 ((gnus-functionp gnus-auto-select-first)
2827 (funcall gnus-auto-select-first))))
2828 ;; Don't select any articles, just move point to the first
2829 ;; article in the group.
2830 (goto-char (point-min))
2831 (gnus-summary-position-point)
2832 (gnus-configure-windows 'summary 'force)
2833 (gnus-set-mode-line 'summary))
2834 (when (get-buffer-window gnus-group-buffer t)
2835 ;; Gotta use windows, because recenter does weird stuff if
2836 ;; the current buffer ain't the displayed window.
2837 (let ((owin (selected-window)))
2838 (select-window (get-buffer-window gnus-group-buffer t))
2839 (when (gnus-group-goto-group group)
2841 (select-window owin)))
2842 ;; Mark this buffer as "prepared".
2843 (setq gnus-newsgroup-prepared t)
2844 (gnus-run-hooks 'gnus-summary-prepared-hook)
2847 (defun gnus-summary-prepare ()
2848 "Generate the summary buffer."
2850 (let ((buffer-read-only nil))
2852 (setq gnus-newsgroup-data nil
2853 gnus-newsgroup-data-reverse nil)
2854 (gnus-run-hooks 'gnus-summary-generate-hook)
2855 ;; Generate the buffer, either with threads or without.
2856 (when gnus-newsgroup-headers
2857 (gnus-summary-prepare-threads
2858 (if gnus-show-threads
2859 (gnus-sort-gathered-threads
2860 (funcall gnus-summary-thread-gathering-function
2862 (gnus-cut-threads (gnus-make-threads)))))
2863 ;; Unthreaded display.
2864 (gnus-sort-articles gnus-newsgroup-headers))))
2865 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2866 ;; Call hooks for modifying summary buffer.
2867 (goto-char (point-min))
2868 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2870 (defsubst gnus-general-simplify-subject (subject)
2871 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2874 ;; Truncate the subject.
2875 (gnus-simplify-subject-functions
2876 (gnus-map-function gnus-simplify-subject-functions subject))
2877 ((numberp gnus-summary-gather-subject-limit)
2878 (setq subject (gnus-simplify-subject-re subject))
2879 (if (> (length subject) gnus-summary-gather-subject-limit)
2880 (substring subject 0 gnus-summary-gather-subject-limit)
2882 ;; Fuzzily simplify it.
2883 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2884 (gnus-simplify-subject-fuzzy subject))
2885 ;; Just remove the leading "Re:".
2887 (gnus-simplify-subject-re subject))))
2889 (if (and gnus-summary-gather-exclude-subject
2890 (string-match gnus-summary-gather-exclude-subject subject))
2891 nil ; This article shouldn't be gathered
2894 (defun gnus-summary-simplify-subject-query ()
2895 "Query where the respool algorithm would put this article."
2897 (gnus-summary-select-article)
2898 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2900 (defun gnus-gather-threads-by-subject (threads)
2901 "Gather threads by looking at Subject headers."
2902 (if (not gnus-summary-make-false-root)
2904 (let ((hashtb (gnus-make-hashtable 1024))
2907 subject hthread whole-subject)
2909 (setq subject (gnus-general-simplify-subject
2910 (setq whole-subject (mail-header-subject
2913 (if (setq hthread (gnus-gethash subject hashtb))
2915 ;; We enter a dummy root into the thread, if we
2916 ;; haven't done that already.
2917 (unless (stringp (caar hthread))
2918 (setcar hthread (list whole-subject (car hthread))))
2919 ;; We add this new gathered thread to this gathered
2921 (setcdr (car hthread)
2922 (nconc (cdar hthread) (list (car threads))))
2923 ;; Remove it from the list of threads.
2924 (setcdr prev (cdr threads))
2925 (setq threads prev))
2926 ;; Enter this thread into the hash table.
2927 (gnus-sethash subject threads hashtb)))
2929 (setq threads (cdr threads)))
2932 (defun gnus-gather-threads-by-references (threads)
2933 "Gather threads by looking at References headers."
2934 (let ((idhashtb (gnus-make-hashtable 1024))
2935 (thhashtb (gnus-make-hashtable 1024))
2938 ids references id gthread gid entered ref)
2940 (when (setq references (mail-header-references (caar threads)))
2941 (setq id (mail-header-id (caar threads))
2942 ids (gnus-split-references references)
2944 (while (setq ref (pop ids))
2945 (setq ids (delete ref ids))
2946 (if (not (setq gid (gnus-gethash ref idhashtb)))
2948 (gnus-sethash ref id idhashtb)
2949 (gnus-sethash id threads thhashtb))
2950 (setq gthread (gnus-gethash gid thhashtb))
2952 ;; We enter a dummy root into the thread, if we
2953 ;; haven't done that already.
2954 (unless (stringp (caar gthread))
2955 (setcar gthread (list (mail-header-subject (caar gthread))
2957 ;; We add this new gathered thread to this gathered
2959 (setcdr (car gthread)
2960 (nconc (cdar gthread) (list (car threads)))))
2961 ;; Add it into the thread hash table.
2962 (gnus-sethash id gthread thhashtb)
2964 ;; Remove it from the list of threads.
2965 (setcdr prev (cdr threads))
2966 (setq threads prev))))
2968 (setq threads (cdr threads)))
2971 (defun gnus-sort-gathered-threads (threads)
2972 "Sort subtreads inside each gathered thread by article number."
2973 (let ((result threads))
2975 (when (stringp (caar threads))
2976 (setcdr (car threads)
2977 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2978 (setq threads (cdr threads)))
2981 (defun gnus-thread-loop-p (root thread)
2982 "Say whether ROOT is in THREAD."
2983 (let ((stack (list thread))
2986 (while (setq thread (pop stack))
2987 (setq th (cdr thread))
2989 (not (eq (caar th) root)))
2992 ;; We have found a loop.
2994 (setcdr thread (delq (car th) (cdr thread)))
2995 (if (boundp (setq ref-dep (intern "none"
2996 gnus-newsgroup-dependencies)))
2997 (setcdr (symbol-value ref-dep)
2998 (nconc (cdr (symbol-value ref-dep))
3000 (set ref-dep (list nil (car th))))
3003 ;; Push all the subthreads onto the stack.
3004 (push (cdr thread) stack)))
3007 (defun gnus-make-threads ()
3008 "Go through the dependency hashtb and find the roots. Return all threads."
3010 (while (catch 'infloop
3013 ;; Deal with self-referencing References loops.
3014 (when (and (car (symbol-value refs))
3021 (car (symbol-value refs)) thread))
3022 (cdr (symbol-value refs)))))))
3025 (unless (car (symbol-value refs))
3026 ;; These threads do not refer back to any other articles,
3027 ;; so they're roots.
3028 (setq threads (append (cdr (symbol-value refs)) threads))))
3029 gnus-newsgroup-dependencies)))
3032 ;; Build the thread tree.
3033 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3034 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3036 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3037 if it was already present.
3039 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3040 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3041 Message-IDs will be renamed be renamed to a unique Message-ID before
3044 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3045 (let* ((id (mail-header-id header))
3046 (id-dep (and id (intern id dependencies)))
3047 ref ref-dep ref-header)
3048 ;; Enter this `header' in the `dependencies' table.
3052 ;; The first two cases do the normal part: enter a new `header'
3053 ;; in the `dependencies' table.
3054 ((not (boundp id-dep))
3055 (set id-dep (list header)))
3056 ((null (car (symbol-value id-dep)))
3057 (setcar (symbol-value id-dep) header))
3059 ;; From here the `header' was already present in the
3060 ;; `dependencies' table.
3062 ;; Overrides an existing entry;
3063 ;; just set the header part of the entry.
3064 (setcar (symbol-value id-dep) header))
3066 ;; Renames the existing `header' to a unique Message-ID.
3067 ((not gnus-summary-ignore-duplicates)
3068 ;; An article with this Message-ID has already been seen.
3069 ;; We rename the Message-ID.
3070 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3072 (mail-header-set-id header id))
3074 ;; The last case ignores an existing entry, except it adds any
3075 ;; additional Xrefs (in case the two articles came from different
3077 ;; Also sets `header' to `nil' meaning that the `dependencies'
3078 ;; table was *not* modified.
3080 (mail-header-set-xref
3081 (car (symbol-value id-dep))
3082 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3084 (or (mail-header-xref header) "")))
3088 ;; First check if that we are not creating a References loop.
3089 (setq ref (gnus-parent-id (mail-header-references header)))
3091 (setq ref-dep (intern-soft ref dependencies))
3093 (setq ref-header (car (symbol-value ref-dep))))
3094 (if (string= id ref)
3095 ;; Yuk! This is a reference loop. Make the article be a
3098 (mail-header-set-references (car (symbol-value id-dep)) "none")
3100 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3101 (setq ref (gnus-parent-id (mail-header-references header)))
3102 (setq ref-dep (intern (or ref "none") dependencies))
3103 (if (boundp ref-dep)
3104 (setcdr (symbol-value ref-dep)
3105 (nconc (cdr (symbol-value ref-dep))
3106 (list (symbol-value id-dep))))
3107 (set ref-dep (list nil (symbol-value id-dep)))))
3110 (defun gnus-build-sparse-threads ()
3111 (let ((headers gnus-newsgroup-headers)
3112 (gnus-summary-ignore-duplicates t)
3113 header references generation relations
3114 subject child end new-child date)
3115 ;; First we create an alist of generations/relations, where
3116 ;; generations is how much we trust the relation, and the relation
3118 (gnus-message 7 "Making sparse threads...")
3120 (nnheader-set-temp-buffer " *gnus sparse threads*")
3121 (while (setq header (pop headers))
3122 (when (and (setq references (mail-header-references header))
3123 (not (string= references "")))
3125 (setq child (mail-header-id header)
3126 subject (mail-header-subject header)
3127 date (mail-header-date header)
3129 (while (search-backward ">" nil t)
3130 (setq end (1+ (point)))
3131 (when (search-backward "<" nil t)
3132 (setq new-child (buffer-substring (point) end))
3133 (push (list (incf generation)
3134 child (setq child new-child)
3138 (push (list (1+ generation) child nil subject) relations))
3140 (kill-buffer (current-buffer)))
3141 ;; Sort over trustworthiness.
3144 (when (gnus-dependencies-add-header
3145 (make-full-mail-header
3146 gnus-reffed-article-number
3147 (nth 3 relation) "" (or (nth 4 relation) "")
3149 (or (nth 2 relation) "") 0 0 "")
3150 gnus-newsgroup-dependencies nil)
3151 (push gnus-reffed-article-number gnus-newsgroup-limit)
3152 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3153 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3154 gnus-newsgroup-reads)
3155 (decf gnus-reffed-article-number)))
3156 (sort relations 'car-less-than-car))
3157 (gnus-message 7 "Making sparse threads...done")))
3159 (defun gnus-build-old-threads ()
3160 ;; Look at all the articles that refer back to old articles, and
3161 ;; fetch the headers for the articles that aren't there. This will
3162 ;; build complete threads - if the roots haven't been expired by the
3167 (when (not (car (symbol-value refs)))
3168 (setq heads (cdr (symbol-value refs)))
3170 (if (memq (mail-header-number (caar heads))
3171 gnus-newsgroup-dormant)
3172 (setq heads (cdr heads))
3173 (setq id (symbol-name refs))
3174 (while (and (setq id (gnus-build-get-header id))
3175 (not (car (gnus-id-to-thread id)))))
3176 (setq heads nil)))))
3177 gnus-newsgroup-dependencies)))
3179 ;; This function has to be called with point after the article number
3180 ;; on the beginning of the line.
3181 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3182 (let ((eol (gnus-point-at-eol))
3183 (buffer (current-buffer))
3186 ;; overview: [num subject from date id refs chars lines misc]
3191 (make-full-mail-header
3193 (nnheader-nov-field) ; subject
3194 (nnheader-nov-field) ; from
3195 (nnheader-nov-field) ; date
3196 (nnheader-nov-read-message-id) ; id
3197 (nnheader-nov-field) ; refs
3198 (nnheader-nov-read-integer) ; chars
3199 (nnheader-nov-read-integer) ; lines
3201 (nnheader-nov-field)) ; misc
3202 (nnheader-nov-parse-extra))) ; extra
3204 (when gnus-alter-header-function
3205 (funcall gnus-alter-header-function header))
3206 (gnus-dependencies-add-header header dependencies force-new)))
3208 (defun gnus-build-get-header (id)
3209 ;; Look through the buffer of NOV lines and find the header to
3210 ;; ID. Enter this line into the dependencies hash table, and return
3211 ;; the id of the parent article (if any).
3212 (let ((deps gnus-newsgroup-dependencies)
3216 (set-buffer nntp-server-buffer)
3217 (let ((case-fold-search nil))
3218 (goto-char (point-min))
3219 (while (and (not found)
3220 (search-forward id nil t))
3222 (setq found (looking-at
3223 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3224 (regexp-quote id))))
3225 (or found (beginning-of-line 2)))
3229 (setq header (gnus-nov-parse-line
3230 (read (current-buffer)) deps))
3231 (gnus-parent-id (mail-header-references header))))))
3233 (let ((number (mail-header-number header)))
3234 (push number gnus-newsgroup-limit)
3235 (push header gnus-newsgroup-headers)
3236 (if (memq number gnus-newsgroup-unselected)
3238 (push number gnus-newsgroup-unreads)
3239 (setq gnus-newsgroup-unselected
3240 (delq number gnus-newsgroup-unselected)))
3241 (push number gnus-newsgroup-ancient)))))))
3243 (defun gnus-build-all-threads ()
3244 "Read all the headers."
3245 (let ((gnus-summary-ignore-duplicates t)
3246 (dependencies gnus-newsgroup-dependencies)
3249 (set-buffer nntp-server-buffer)
3250 (let ((case-fold-search nil))
3251 (goto-char (point-min))
3254 (setq article (read (current-buffer))
3255 header (gnus-nov-parse-line
3256 article dependencies)))
3259 (set-buffer gnus-summary-buffer)
3260 (push header gnus-newsgroup-headers)
3261 (if (memq (setq article (mail-header-number header))
3262 gnus-newsgroup-unselected)
3264 (push article gnus-newsgroup-unreads)
3265 (setq gnus-newsgroup-unselected
3266 (delq article gnus-newsgroup-unselected)))
3267 (push article gnus-newsgroup-ancient)))
3268 (forward-line 1)))))))
3270 (defun gnus-summary-update-article-line (article header)
3271 "Update the line for ARTICLE using HEADERS."
3272 (let* ((id (mail-header-id header))
3273 (thread (gnus-id-to-thread id)))
3275 (error "Article in no thread"))
3276 ;; Update the thread.
3277 (setcar thread header)
3278 (gnus-summary-goto-subject article)
3279 (let* ((datal (gnus-data-find-list article))
3281 (length (when (cdr datal)
3282 (- (gnus-data-pos data)
3283 (gnus-data-pos (cadr datal)))))
3284 (buffer-read-only nil)
3285 (level (gnus-summary-thread-level)))
3287 (gnus-summary-insert-line
3288 header level nil (gnus-article-mark article)
3289 (memq article gnus-newsgroup-replied)
3290 (memq article gnus-newsgroup-expirable)
3291 ;; Only insert the Subject string when it's different
3292 ;; from the previous Subject string.
3293 (if (gnus-subject-equal
3295 (mail-header-subject
3298 (gnus-data-find-list
3300 (gnus-data-list t)))))
3301 ;; Error on the side of excessive subjects.
3303 (mail-header-subject header))
3305 (mail-header-subject header))
3306 nil (cdr (assq article gnus-newsgroup-scored))
3307 (memq article gnus-newsgroup-processable))
3309 (gnus-data-update-list
3310 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3312 (defun gnus-summary-update-article (article &optional iheader)
3313 "Update ARTICLE in the summary buffer."
3314 (set-buffer gnus-summary-buffer)
3315 (let* ((header (gnus-summary-article-header article))
3316 (id (mail-header-id header))
3317 (data (gnus-data-find article))
3318 (thread (gnus-id-to-thread id))
3319 (references (mail-header-references header))
3323 (when (and references
3324 (not (equal "" references)))
3327 (buffer-read-only nil)
3333 (delq thread parent)))
3334 (if (gnus-summary-insert-subject id header)
3335 ;; Set the (possibly) new article number in the data structure.
3336 (gnus-data-set-number data (gnus-id-to-article id))
3340 (defun gnus-rebuild-thread (id &optional line)
3341 "Rebuild the thread containing ID.
3342 If LINE, insert the rebuilt thread starting on line LINE."
3343 (let ((buffer-read-only nil)
3344 old-pos current thread data)
3345 (if (not gnus-show-threads)
3346 (setq thread (list (car (gnus-id-to-thread id))))
3347 ;; Get the thread this article is part of.
3348 (setq thread (gnus-remove-thread id)))
3349 (setq old-pos (gnus-point-at-bol))
3350 (setq current (save-excursion
3351 (and (zerop (forward-line -1))
3352 (gnus-summary-article-number))))
3353 ;; If this is a gathered thread, we have to go some re-gathering.
3354 (when (stringp (car thread))
3355 (let ((subject (car thread))
3357 (setq thread (cdr thread))
3359 (unless (memq (setq thr (gnus-id-to-thread
3361 (mail-header-id (caar thread)))))
3364 (setq thread (cdr thread)))
3365 ;; We now have all (unique) roots.
3366 (if (= (length roots) 1)
3367 ;; All the loose roots are now one solid root.
3368 (setq thread (car roots))
3369 (setq thread (cons subject (gnus-sort-threads roots))))))
3371 ;; We then insert this thread into the summary buffer.
3373 (goto-char (point-min))
3374 (forward-line (1- line)))
3375 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3376 (if gnus-show-threads
3377 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3378 (gnus-summary-prepare-unthreaded thread))
3379 (setq data (nreverse gnus-newsgroup-data))
3380 (setq threads gnus-newsgroup-threads))
3381 ;; We splice the new data into the data structure.
3382 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3383 ;;!!! then we want to insert at the beginning of the buffer.
3384 ;;!!! That happens to be true with Gnus now, but that may
3385 ;;!!! change in the future. Perhaps.
3386 (gnus-data-enter-list
3387 (if line nil current) data (- (point) old-pos))
3388 (setq gnus-newsgroup-threads
3389 (nconc threads gnus-newsgroup-threads))
3390 (gnus-data-compute-positions))))
3392 (defun gnus-number-to-header (number)
3393 "Return the header for article NUMBER."
3394 (let ((headers gnus-newsgroup-headers))
3396 (not (= number (mail-header-number (car headers)))))
3401 (defun gnus-parent-headers (in-headers &optional generation)
3402 "Return the headers of the GENERATIONeth parent of HEADERS."
3404 (setq generation 1))
3406 (headers in-headers)
3409 (not (zerop generation))
3410 (setq references (mail-header-references headers)))
3411 (setq headers (if (and references
3412 (setq parent (gnus-parent-id references)))
3413 (car (gnus-id-to-thread parent))
3416 (and (not (eq headers in-headers))
3419 (defun gnus-id-to-thread (id)
3420 "Return the (sub-)thread where ID appears."
3421 (gnus-gethash id gnus-newsgroup-dependencies))
3423 (defun gnus-id-to-article (id)
3424 "Return the article number of ID."
3425 (let ((thread (gnus-id-to-thread id)))
3428 (mail-header-number (car thread)))))
3430 (defun gnus-id-to-header (id)
3431 "Return the article headers of ID."
3432 (car (gnus-id-to-thread id)))
3434 (defun gnus-article-displayed-root-p (article)
3435 "Say whether ARTICLE is a root(ish) article."
3436 (let ((level (gnus-summary-thread-level article))
3437 (refs (mail-header-references (gnus-summary-article-header article)))
3443 ((null (gnus-parent-id refs)) t)
3445 (null (setq particle (gnus-id-to-article
3446 (gnus-parent-id refs))))
3447 (null (gnus-summary-thread-level particle)))))))
3449 (defun gnus-root-id (id)
3450 "Return the id of the root of the thread where ID appears."
3452 (while (and id (setq prev (car (gnus-id-to-thread id))))
3454 id (gnus-parent-id (mail-header-references prev))))
3457 (defun gnus-articles-in-thread (thread)
3458 "Return the list of articles in THREAD."
3459 (cons (mail-header-number (car thread))
3460 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3462 (defun gnus-remove-thread (id &optional dont-remove)
3463 "Remove the thread that has ID in it."
3464 (let (headers thread last-id)
3465 ;; First go up in this thread until we find the root.
3466 (setq last-id (gnus-root-id id)
3467 headers (message-flatten-list (gnus-id-to-thread last-id)))
3468 ;; We have now found the real root of this thread. It might have
3469 ;; been gathered into some loose thread, so we have to search
3470 ;; through the threads to find the thread we wanted.
3471 (let ((threads gnus-newsgroup-threads)
3474 (setq sub (car threads))
3475 (if (stringp (car sub))
3476 ;; This is a gathered thread, so we look at the roots
3477 ;; below it to find whether this article is in this
3480 (setq sub (cdr sub))
3482 (when (member (caar sub) headers)
3483 (setq thread (car threads)
3486 (setq sub (cdr sub))))
3487 ;; It's an ordinary thread, so we check it.
3488 (when (eq (car sub) (car headers))
3491 (setq threads (cdr threads)))
3492 ;; If this article is in no thread, then it's a root.
3495 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3496 (setq thread (gnus-id-to-thread last-id)))
3499 thread ; We return this thread.
3501 (if (stringp (car thread))
3503 ;; If we use dummy roots, then we have to remove the
3504 ;; dummy root as well.
3505 (when (eq gnus-summary-make-false-root 'dummy)
3506 ;; We go to the dummy root by going to
3507 ;; the first sub-"thread", and then one line up.
3508 (gnus-summary-goto-article
3509 (mail-header-number (caadr thread)))
3512 (gnus-data-compute-positions))
3513 (setq thread (cdr thread))
3515 (gnus-remove-thread-1 (car thread))
3516 (setq thread (cdr thread))))
3517 (gnus-summary-show-all-threads)
3518 (gnus-remove-thread-1 thread))))))))
3520 (defun gnus-remove-thread-1 (thread)
3521 "Remove the thread THREAD recursively."
3522 (let ((number (mail-header-number (pop thread)))
3524 (setq thread (reverse thread))
3526 (gnus-remove-thread-1 (pop thread)))
3527 (when (setq d (gnus-data-find number))
3528 (goto-char (gnus-data-pos d))
3531 (- (gnus-point-at-bol)
3533 (1+ (gnus-point-at-eol))
3534 (gnus-delete-line)))))))
3536 (defun gnus-sort-threads (threads)
3538 (if (not gnus-thread-sort-functions)
3540 (gnus-message 8 "Sorting threads...")
3542 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3543 (gnus-message 8 "Sorting threads...done"))))
3545 (defun gnus-sort-articles (articles)
3547 (when gnus-article-sort-functions
3548 (gnus-message 7 "Sorting articles...")
3550 (setq gnus-newsgroup-headers
3551 (sort articles (gnus-make-sort-function
3552 gnus-article-sort-functions)))
3553 (gnus-message 7 "Sorting articles...done"))))
3555 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3556 (defmacro gnus-thread-header (thread)
3557 ;; Return header of first article in THREAD.
3558 ;; Note that THREAD must never, ever be anything else than a variable -
3559 ;; using some other form will lead to serious barfage.
3560 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3561 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3562 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3565 (defsubst gnus-article-sort-by-number (h1 h2)
3566 "Sort articles by article number."
3567 (< (mail-header-number h1)
3568 (mail-header-number h2)))
3570 (defun gnus-thread-sort-by-number (h1 h2)
3571 "Sort threads by root article number."
3572 (gnus-article-sort-by-number
3573 (gnus-thread-header h1) (gnus-thread-header h2)))
3575 (defsubst gnus-article-sort-by-lines (h1 h2)
3576 "Sort articles by article Lines header."
3577 (< (mail-header-lines h1)
3578 (mail-header-lines h2)))
3580 (defun gnus-thread-sort-by-lines (h1 h2)
3581 "Sort threads by root article Lines header."
3582 (gnus-article-sort-by-lines
3583 (gnus-thread-header h1) (gnus-thread-header h2)))
3585 (defsubst gnus-article-sort-by-chars (h1 h2)
3586 "Sort articles by octet length."
3587 (< (mail-header-chars h1)
3588 (mail-header-chars h2)))
3590 (defun gnus-thread-sort-by-chars (h1 h2)
3591 "Sort threads by root article octet length."
3592 (gnus-article-sort-by-chars
3593 (gnus-thread-header h1) (gnus-thread-header h2)))
3595 (defsubst gnus-article-sort-by-author (h1 h2)
3596 "Sort articles by root author."
3598 (let ((addr (car (mime-read-field 'From h1))))
3599 (or (std11-full-name-string addr)
3600 (std11-address-string addr)
3602 (let ((addr (car (mime-read-field 'From h2))))
3603 (or (std11-full-name-string addr)
3604 (std11-address-string addr)
3608 (defun gnus-thread-sort-by-author (h1 h2)
3609 "Sort threads by root author."
3610 (gnus-article-sort-by-author
3611 (gnus-thread-header h1) (gnus-thread-header h2)))
3613 (defsubst gnus-article-sort-by-subject (h1 h2)
3614 "Sort articles by root subject."
3616 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3617 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3619 (defun gnus-thread-sort-by-subject (h1 h2)
3620 "Sort threads by root subject."
3621 (gnus-article-sort-by-subject
3622 (gnus-thread-header h1) (gnus-thread-header h2)))
3624 (defsubst gnus-article-sort-by-date (h1 h2)
3625 "Sort articles by root article date."
3627 (gnus-date-get-time (mail-header-date h1))
3628 (gnus-date-get-time (mail-header-date h2))))
3630 (defun gnus-thread-sort-by-date (h1 h2)
3631 "Sort threads by root article date."
3632 (gnus-article-sort-by-date
3633 (gnus-thread-header h1) (gnus-thread-header h2)))
3635 (defsubst gnus-article-sort-by-score (h1 h2)
3636 "Sort articles by root article score.
3637 Unscored articles will be counted as having a score of zero."
3638 (> (or (cdr (assq (mail-header-number h1)
3639 gnus-newsgroup-scored))
3640 gnus-summary-default-score 0)
3641 (or (cdr (assq (mail-header-number h2)
3642 gnus-newsgroup-scored))
3643 gnus-summary-default-score 0)))
3645 (defun gnus-thread-sort-by-score (h1 h2)
3646 "Sort threads by root article score."
3647 (gnus-article-sort-by-score
3648 (gnus-thread-header h1) (gnus-thread-header h2)))
3650 (defun gnus-thread-sort-by-total-score (h1 h2)
3651 "Sort threads by the sum of all scores in the thread.
3652 Unscored articles will be counted as having a score of zero."
3653 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3655 (defun gnus-thread-total-score (thread)
3656 ;; This function find the total score of THREAD.
3657 (cond ((null thread)
3660 (if (stringp (car thread))
3661 (apply gnus-thread-score-function 0
3662 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3663 (gnus-thread-total-score-1 thread)))
3665 (gnus-thread-total-score-1 (list thread)))))
3667 (defun gnus-thread-total-score-1 (root)
3668 ;; This function find the total score of the thread below ROOT.
3669 (setq root (car root))
3670 (apply gnus-thread-score-function
3672 (mapcar 'gnus-thread-total-score
3673 (cdr (gnus-id-to-thread (mail-header-id root))))
3674 (when (> (mail-header-number root) 0)
3675 (list (or (cdr (assq (mail-header-number root)
3676 gnus-newsgroup-scored))
3677 gnus-summary-default-score 0))))
3678 (list gnus-summary-default-score)
3681 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3682 (defvar gnus-tmp-prev-subject nil)
3683 (defvar gnus-tmp-false-parent nil)
3684 (defvar gnus-tmp-root-expunged nil)
3685 (defvar gnus-tmp-dummy-line nil)
3687 (defvar gnus-tmp-header)
3688 (defun gnus-extra-header (type &optional header)
3689 "Return the extra header of TYPE."
3690 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3693 (defun gnus-summary-prepare-threads (threads)
3694 "Prepare summary buffer from THREADS and indentation LEVEL.
3695 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3696 or a straight list of headers."
3697 (gnus-message 7 "Generating summary...")
3699 (setq gnus-newsgroup-threads threads)
3702 (let ((gnus-tmp-level 0)
3703 (default-score (or gnus-summary-default-score 0))
3704 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3705 thread number subject stack state gnus-tmp-gathered beg-match
3706 new-roots gnus-tmp-new-adopts thread-end
3707 gnus-tmp-header gnus-tmp-unread
3708 gnus-tmp-replied gnus-tmp-subject-or-nil
3709 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3710 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3711 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3713 (setq gnus-tmp-prev-subject nil)
3715 (if (vectorp (car threads))
3716 ;; If this is a straight (sic) list of headers, then a
3717 ;; threaded summary display isn't required, so we just create
3718 ;; an unthreaded one.
3719 (gnus-summary-prepare-unthreaded threads)
3721 ;; Do the threaded display.
3723 (while (or threads stack gnus-tmp-new-adopts new-roots)
3725 (if (and (= gnus-tmp-level 0)
3728 (not gnus-tmp-false-parent)
3729 (or gnus-tmp-new-adopts new-roots))
3730 (if gnus-tmp-new-adopts
3731 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3732 thread (list (car gnus-tmp-new-adopts))
3733 gnus-tmp-header (caar thread)
3734 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3736 (setq thread (list (car new-roots))
3737 gnus-tmp-header (caar thread)
3738 new-roots (cdr new-roots))))
3741 ;; If there are some threads, we do them before the
3742 ;; threads on the stack.
3743 (setq thread threads
3744 gnus-tmp-header (caar thread))
3745 ;; There were no current threads, so we pop something off
3747 (setq state (car stack)
3748 gnus-tmp-level (car state)
3751 gnus-tmp-header (caar thread))))
3753 (setq gnus-tmp-false-parent nil)
3754 (setq gnus-tmp-root-expunged nil)
3755 (setq thread-end nil)
3757 (if (stringp gnus-tmp-header)
3758 ;; The header is a dummy root.
3760 ((eq gnus-summary-make-false-root 'adopt)
3761 ;; We let the first article adopt the rest.
3762 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3764 (setq gnus-tmp-gathered
3766 (lambda (h) (mail-header-number (car h)))
3769 (setq thread (cons (list (caar thread)
3772 (setq gnus-tmp-level -1
3773 gnus-tmp-false-parent t))
3774 ((eq gnus-summary-make-false-root 'empty)
3775 ;; We print adopted articles with empty subject fields.
3776 (setq gnus-tmp-gathered
3778 (lambda (h) (mail-header-number (car h)))
3781 (setq gnus-tmp-level -1))
3782 ((eq gnus-summary-make-false-root 'dummy)
3783 ;; We remember that we probably want to output a dummy
3785 (setq gnus-tmp-dummy-line gnus-tmp-header)
3786 (setq gnus-tmp-prev-subject gnus-tmp-header))
3788 ;; We do not make a root for the gathered
3789 ;; sub-threads at all.
3790 (setq gnus-tmp-level -1)))
3792 (setq number (mail-header-number gnus-tmp-header)
3793 subject (mail-header-subject gnus-tmp-header))
3796 ;; If the thread has changed subject, we might want to make
3797 ;; this subthread into a root.
3798 ((and (null gnus-thread-ignore-subject)
3799 (not (zerop gnus-tmp-level))
3800 gnus-tmp-prev-subject
3802 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3803 (setq new-roots (nconc new-roots (list (car thread)))
3805 gnus-tmp-header nil))
3806 ;; If the article lies outside the current limit,
3807 ;; then we do not display it.
3808 ((not (memq number gnus-newsgroup-limit))
3809 (setq gnus-tmp-gathered
3811 (lambda (h) (mail-header-number (car h)))
3814 (setq gnus-tmp-new-adopts (if (cdar thread)
3815 (append gnus-tmp-new-adopts
3817 gnus-tmp-new-adopts)
3819 gnus-tmp-header nil)
3820 (when (zerop gnus-tmp-level)
3821 (setq gnus-tmp-root-expunged t)))
3822 ;; Perhaps this article is to be marked as read?
3823 ((and gnus-summary-mark-below
3824 (< (or (cdr (assq number gnus-newsgroup-scored))
3826 gnus-summary-mark-below)
3827 ;; Don't touch sparse articles.
3828 (not (gnus-summary-article-sparse-p number))
3829 (not (gnus-summary-article-ancient-p number)))
3830 (setq gnus-newsgroup-unreads
3831 (delq number gnus-newsgroup-unreads))
3832 (if gnus-newsgroup-auto-expire
3833 (push number gnus-newsgroup-expirable)
3834 (push (cons number gnus-low-score-mark)
3835 gnus-newsgroup-reads))))
3837 (when gnus-tmp-header
3838 ;; We may have an old dummy line to output before this
3840 (when (and gnus-tmp-dummy-line
3843 (mail-header-subject gnus-tmp-header)))
3844 (gnus-summary-insert-dummy-line
3845 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3846 (setq gnus-tmp-dummy-line nil))
3848 ;; Compute the mark.
3849 (setq gnus-tmp-unread (gnus-article-mark number))
3851 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3852 gnus-tmp-header gnus-tmp-level)
3853 gnus-newsgroup-data)
3855 ;; Actually insert the line.
3857 gnus-tmp-subject-or-nil
3859 ((and gnus-thread-ignore-subject
3860 gnus-tmp-prev-subject
3861 (not (inline (gnus-subject-equal
3862 gnus-tmp-prev-subject subject))))
3864 ((zerop gnus-tmp-level)
3865 (if (and (eq gnus-summary-make-false-root 'empty)
3866 (memq number gnus-tmp-gathered)
3867 gnus-tmp-prev-subject
3868 (inline (gnus-subject-equal
3869 gnus-tmp-prev-subject subject)))
3870 gnus-summary-same-subject
3872 (t gnus-summary-same-subject)))
3873 (if (and (eq gnus-summary-make-false-root 'adopt)
3874 (= gnus-tmp-level 1)
3875 (memq number gnus-tmp-gathered))
3876 (setq gnus-tmp-opening-bracket ?\<
3877 gnus-tmp-closing-bracket ?\>)
3878 (setq gnus-tmp-opening-bracket ?\[
3879 gnus-tmp-closing-bracket ?\]))
3881 gnus-tmp-indentation
3882 (aref gnus-thread-indent-array gnus-tmp-level)
3883 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3884 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3885 gnus-summary-default-score 0)
3887 (if (or (null gnus-summary-default-score)
3888 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3889 gnus-summary-zcore-fuzz))
3891 (if (< gnus-tmp-score gnus-summary-default-score)
3892 gnus-score-below-mark gnus-score-over-mark))
3894 (cond ((memq number gnus-newsgroup-processable)
3896 ((memq number gnus-newsgroup-cached)
3898 ((memq number gnus-newsgroup-replied)
3900 ((memq number gnus-newsgroup-saved)
3902 (t gnus-unread-mark))
3903 gnus-tmp-from (mail-header-from gnus-tmp-header)
3906 ((string-match "<[^>]+> *$" gnus-tmp-from)
3907 (setq beg-match (match-beginning 0))
3908 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3909 (substring gnus-tmp-from (1+ (match-beginning 0))
3910 (1- (match-end 0))))
3911 (substring gnus-tmp-from 0 beg-match)))
3912 ((string-match "(.+)" gnus-tmp-from)
3913 (substring gnus-tmp-from
3914 (1+ (match-beginning 0)) (1- (match-end 0))))
3916 (when (string= gnus-tmp-name "")
3917 (setq gnus-tmp-name gnus-tmp-from))
3918 (unless (numberp gnus-tmp-lines)
3919 (setq gnus-tmp-lines 0))
3920 (gnus-put-text-property
3922 (progn (eval gnus-summary-line-format-spec) (point))
3923 'gnus-number number)
3926 (gnus-run-hooks 'gnus-summary-update-hook)
3929 (setq gnus-tmp-prev-subject subject)))
3931 (when (nth 1 thread)
3932 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3933 (incf gnus-tmp-level)
3934 (setq threads (if thread-end nil (cdar thread)))
3936 (setq gnus-tmp-level 0)))))
3937 (gnus-message 7 "Generating summary...done"))
3939 (defun gnus-summary-prepare-unthreaded (headers)
3940 "Generate an unthreaded summary buffer based on HEADERS."
3941 (let (header number mark)
3946 ;; We may have to root out some bad articles...
3947 (when (memq (setq number (mail-header-number
3948 (setq header (pop headers))))
3949 gnus-newsgroup-limit)
3950 ;; Mark article as read when it has a low score.
3951 (when (and gnus-summary-mark-below
3952 (< (or (cdr (assq number gnus-newsgroup-scored))
3953 gnus-summary-default-score 0)
3954 gnus-summary-mark-below)
3955 (not (gnus-summary-article-ancient-p number)))
3956 (setq gnus-newsgroup-unreads
3957 (delq number gnus-newsgroup-unreads))
3958 (if gnus-newsgroup-auto-expire
3959 (push number gnus-newsgroup-expirable)
3960 (push (cons number gnus-low-score-mark)
3961 gnus-newsgroup-reads)))
3963 (setq mark (gnus-article-mark number))
3964 (push (gnus-data-make number mark (1+ (point)) header 0)
3965 gnus-newsgroup-data)
3966 (gnus-summary-insert-line
3968 mark (memq number gnus-newsgroup-replied)
3969 (memq number gnus-newsgroup-expirable)
3970 (mail-header-subject header) nil
3971 (cdr (assq number gnus-newsgroup-scored))
3972 (memq number gnus-newsgroup-processable))))))
3974 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3975 "Select newsgroup GROUP.
3976 If READ-ALL is non-nil, all articles in the group are selected.
3977 If SELECT-ARTICLES, only select those articles from GROUP."
3978 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3979 ;;!!! Dirty hack; should be removed.
3980 (gnus-summary-ignore-duplicates
3981 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3983 gnus-summary-ignore-duplicates))
3984 (info (nth 2 entry))
3985 articles fetched-articles cached)
3987 (unless (gnus-check-server
3988 (setq gnus-current-select-method
3989 (gnus-find-method-for-group group)))
3990 (error "Couldn't open server"))
3992 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3993 (gnus-activate-group group) ; Or we can activate it...
3994 (progn ; Or we bug out.
3995 (when (equal major-mode 'gnus-summary-mode)
3996 (kill-buffer (current-buffer)))
3997 (error "Couldn't request group %s: %s"
3998 group (gnus-status-message group))))
4000 (unless (gnus-request-group group t)
4001 (when (equal major-mode 'gnus-summary-mode)
4002 (kill-buffer (current-buffer)))
4003 (error "Couldn't request group %s: %s"
4004 group (gnus-status-message group)))
4006 (setq gnus-newsgroup-name group)
4007 (setq gnus-newsgroup-unselected nil)
4008 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4009 (gnus-summary-setup-default-charset)
4011 ;; Adjust and set lists of article marks.
4013 (gnus-adjust-marked-articles info))
4015 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4017 (if (gnus-virtual-group-p group)
4018 gnus-newsgroup-cached
4019 (gnus-cache-articles-in-group group)))
4021 (setq gnus-newsgroup-unreads
4022 (gnus-set-difference
4023 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4024 gnus-newsgroup-dormant))
4026 (setq gnus-newsgroup-processable nil)
4028 (gnus-update-read-articles group gnus-newsgroup-unreads)
4030 (if (setq articles select-articles)
4031 (setq gnus-newsgroup-unselected
4032 (gnus-sorted-intersection
4033 gnus-newsgroup-unreads
4034 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4035 (setq articles (gnus-articles-to-read group read-all)))
4039 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4041 ((eq articles 0) nil)
4043 ;; Init the dependencies hash table.
4044 (setq gnus-newsgroup-dependencies
4045 (gnus-make-hashtable (length articles)))
4046 (gnus-set-global-variables)
4047 ;; Retrieve the headers and read them in.
4048 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4049 (setq gnus-newsgroup-headers
4050 (gnus-retrieve-parsed-headers
4051 articles gnus-newsgroup-name
4052 ;; We might want to fetch old headers, but
4053 ;; not if there is only 1 article.
4054 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4055 (not (numberp gnus-fetch-old-headers)))
4056 (> (length articles) 1))
4057 gnus-fetch-old-headers)))
4058 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4060 ;; Suppress duplicates?
4061 (when gnus-suppress-duplicates
4062 (gnus-dup-suppress-articles))
4064 ;; Set the initial limit.
4065 (setq gnus-newsgroup-limit (copy-sequence articles))
4066 ;; Remove canceled articles from the list of unread articles.
4067 (setq gnus-newsgroup-unreads
4068 (gnus-set-sorted-intersection
4069 gnus-newsgroup-unreads
4070 (setq fetched-articles
4071 (mapcar (lambda (headers) (mail-header-number headers))
4072 gnus-newsgroup-headers))))
4073 ;; Removed marked articles that do not exist.
4074 (gnus-update-missing-marks
4075 (gnus-sorted-complement fetched-articles articles))
4077 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4079 (setq gnus-newsgroup-cached cached))
4081 ;; We might want to build some more threads first.
4082 (when (and gnus-fetch-old-headers
4083 (eq gnus-headers-retrieved-by 'nov))
4084 (if (eq gnus-fetch-old-headers 'invisible)
4085 (gnus-build-all-threads)
4086 (gnus-build-old-threads)))
4087 ;; Let the Gnus agent mark articles as read.
4089 (gnus-agent-get-undownloaded-list))
4090 ;; Check whether auto-expire is to be done in this group.
4091 (setq gnus-newsgroup-auto-expire
4092 (gnus-group-auto-expirable-p group))
4093 ;; Set up the article buffer now, if necessary.
4094 (unless gnus-single-article-buffer
4095 (gnus-article-setup-buffer))
4096 ;; First and last article in this newsgroup.
4097 (when gnus-newsgroup-headers
4098 (setq gnus-newsgroup-begin
4099 (mail-header-number (car gnus-newsgroup-headers))
4102 (gnus-last-element gnus-newsgroup-headers))))
4103 ;; GROUP is successfully selected.
4104 (or gnus-newsgroup-headers t)))))
4106 (defun gnus-articles-to-read (group &optional read-all)
4107 ;; Find out what articles the user wants to read.
4109 ;; Select all articles if `read-all' is non-nil, or if there
4110 ;; are no unread articles.
4112 (and (zerop (length gnus-newsgroup-marked))
4113 (zerop (length gnus-newsgroup-unreads)))
4114 (eq (gnus-group-find-parameter group 'display)
4116 (gnus-uncompress-range (gnus-active group))
4117 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4118 (copy-sequence gnus-newsgroup-unreads))
4120 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4121 (scored (length scored-list))
4122 (number (length articles))
4123 (marked (+ (length gnus-newsgroup-marked)
4124 (length gnus-newsgroup-dormant)))
4132 ((and (or (<= scored marked) (= scored number))
4133 (natnump gnus-large-newsgroup)
4134 (> number gnus-large-newsgroup))
4135 (let* ((minibuffer-setup-hook (append
4136 minibuffer-setup-hook
4137 '(beginning-of-line)))
4140 "How many articles from %s (max %d): "
4141 (gnus-limit-string gnus-newsgroup-name 35)
4143 (number-to-string gnus-large-newsgroup))))
4144 (if (string-match "^[ \t]*$" input)
4147 ((and (> scored marked) (< scored number)
4148 (> (- scored number) 20))
4151 (format "%s %s (%d scored, %d total): "
4152 "How many articles from"
4153 group scored number))))
4154 (if (string-match "^[ \t]*$" input)
4158 (setq select (if (stringp select) (string-to-number select) select))
4159 (if (or (null select) (zerop select))
4161 (if (and (not (zerop scored)) (<= (abs select) scored))
4163 (setq articles (sort scored-list '<))
4164 (setq number (length articles)))
4165 (setq articles (copy-sequence articles)))
4167 (when (< (abs select) number)
4169 ;; Select the N oldest articles.
4170 (setcdr (nthcdr (1- (abs select)) articles) nil)
4171 ;; Select the N most recent articles.
4172 (setq articles (nthcdr (- number select) articles))))
4173 (setq gnus-newsgroup-unselected
4174 (gnus-sorted-intersection
4175 gnus-newsgroup-unreads
4176 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4179 (defun gnus-killed-articles (killed articles)
4182 (when (inline (gnus-member-of-range (car articles) killed))
4183 (push (car articles) out))
4184 (setq articles (cdr articles)))
4187 (defun gnus-uncompress-marks (marks)
4188 "Uncompress the mark ranges in MARKS."
4189 (let ((uncompressed '(score bookmark))
4192 (if (memq (caar marks) uncompressed)
4193 (push (car marks) out)
4194 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4195 (setq marks (cdr marks)))
4198 (defun gnus-adjust-marked-articles (info)
4199 "Set all article lists and remove all marks that are no longer valid."
4200 (let* ((marked-lists (gnus-info-marks info))
4201 (active (gnus-active (gnus-info-group info)))
4204 (types gnus-article-mark-lists)
4205 (uncompressed '(score bookmark killed))
4206 marks var articles article mark)
4209 (setq marks (pop marked-lists))
4210 (set (setq var (intern (format "gnus-newsgroup-%s"
4211 (car (rassq (setq mark (car marks))
4213 (if (memq (car marks) uncompressed) (cdr marks)
4214 (gnus-uncompress-range (cdr marks))))
4216 (setq articles (symbol-value var))
4218 ;; All articles have to be subsets of the active articles.
4220 ;; Adjust "simple" lists.
4221 ((memq mark '(tick dormant expire reply save))
4223 (when (or (< (setq article (pop articles)) min) (> article max))
4224 (set var (delq article (symbol-value var))))))
4226 ((memq mark uncompressed)
4227 (when (not (listp (cdr (symbol-value var))))
4228 (set var (list (symbol-value var))))
4229 (when (not (listp (cdr articles)))
4230 (setq articles (list articles)))
4232 (when (or (not (consp (setq article (pop articles))))
4233 (< (car article) min)
4234 (> (car article) max))
4235 (set var (delq article (symbol-value var))))))))))
4237 (defun gnus-update-missing-marks (missing)
4238 "Go through the list of MISSING articles and remove them from the mark lists."
4240 (let ((types gnus-article-mark-lists)
4242 ;; Go through all types.
4244 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4245 (when (symbol-value var)
4246 ;; This list has articles. So we delete all missing articles
4250 (set var (delq (pop m) (symbol-value var)))))))))
4252 (defun gnus-update-marks ()
4253 "Enter the various lists of marked articles into the newsgroup info list."
4254 (let ((types gnus-article-mark-lists)
4255 (info (gnus-get-info gnus-newsgroup-name))
4256 (uncompressed '(score bookmark killed))
4257 type list newmarked symbol delta-marks)
4259 ;; Add all marks lists to the list of marks lists.
4260 (while (setq type (pop types))
4261 (setq list (symbol-value
4263 (intern (format "gnus-newsgroup-%s"
4267 ;; Get rid of the entries of the articles that have the
4269 (when (and (eq (cdr type) 'score)
4273 (prev (cons nil list))
4276 (if (or (not (consp (car arts)))
4277 (= (cdar arts) gnus-summary-default-score))
4278 (setcdr prev (cdr arts))
4280 (setq arts (cdr arts)))
4281 (setq list (cdr all)))))
4283 (or (memq (cdr type) uncompressed)
4284 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4286 (when (gnus-check-backend-function 'request-set-mark
4287 gnus-newsgroup-name)
4288 ;; uncompressed:s are not proper flags (they are cons cells)
4289 ;; cache is a internal gnus flag
4290 (unless (memq (cdr type) (cons 'cache uncompressed))
4291 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4292 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4293 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4295 (push (list add 'add (list (cdr type))) delta-marks))
4297 (push (list del 'del (list (cdr type))) delta-marks)))))
4300 (push (cons (cdr type) list) newmarked)))
4303 (unless (gnus-check-group gnus-newsgroup-name)
4304 (error "Can't open server for %s" gnus-newsgroup-name))
4305 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4307 ;; Enter these new marks into the info of the group.
4309 (setcar (nthcdr 3 info) newmarked)
4310 ;; Add the marks lists to the end of the info.
4312 (setcdr (nthcdr 2 info) (list newmarked))))
4314 ;; Cut off the end of the info if there's nothing else there.
4318 (when (nthcdr (decf i) info)
4319 (setcdr (nthcdr i info) nil)))))))
4321 (defun gnus-set-mode-line (where)
4322 "This function sets the mode line of the article or summary buffers.
4323 If WHERE is `summary', the summary mode line format will be used."
4324 ;; Is this mode line one we keep updated?
4325 (when (and (memq where gnus-updated-mode-lines)
4327 (intern (format "gnus-%s-mode-line-format-spec" where))))
4330 ;; We evaluate this in the summary buffer since these
4331 ;; variables are buffer-local to that buffer.
4332 (set-buffer gnus-summary-buffer)
4333 ;; We bind all these variables that are used in the `eval' form
4335 (let* ((mformat (symbol-value
4337 (format "gnus-%s-mode-line-format-spec" where))))
4338 (gnus-tmp-group-name gnus-newsgroup-name)
4339 (gnus-tmp-article-number (or gnus-current-article 0))
4340 (gnus-tmp-unread gnus-newsgroup-unreads)
4341 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4342 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4343 (gnus-tmp-unread-and-unselected
4344 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4345 (zerop gnus-tmp-unselected))
4347 ((zerop gnus-tmp-unselected)
4348 (format "{%d more}" gnus-tmp-unread-and-unticked))
4349 (t (format "{%d(+%d) more}"
4350 gnus-tmp-unread-and-unticked
4351 gnus-tmp-unselected))))
4353 (if (and gnus-current-headers
4354 (vectorp gnus-current-headers))
4355 (gnus-mode-string-quote
4356 (mail-header-subject gnus-current-headers))
4358 bufname-length max-len
4359 gnus-tmp-header);; passed as argument to any user-format-funcs
4360 (setq mode-string (eval mformat))
4361 (setq bufname-length (if (string-match "%b" mode-string)
4364 (if (eq where 'summary)
4366 (get-buffer gnus-article-buffer))))
4369 (setq max-len (max 4 (if gnus-mode-non-string-length
4371 gnus-mode-non-string-length
4373 (length mode-string))))
4374 ;; We might have to chop a bit of the string off...
4375 (when (> (length mode-string) max-len)
4377 (concat (gnus-truncate-string mode-string (- max-len 3))
4379 ;; Pad the mode string a bit.
4380 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4381 ;; Update the mode line.
4382 (setq mode-line-buffer-identification
4383 (gnus-mode-line-buffer-identification (list mode-string)))
4384 (set-buffer-modified-p t))))
4386 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4387 "Go through the HEADERS list and add all Xrefs to a hash table.
4388 The resulting hash table is returned, or nil if no Xrefs were found."
4389 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4390 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4391 (xref-hashtb (gnus-make-hashtable))
4392 start group entry number xrefs header)
4394 (setq header (pop headers))
4395 (when (and (setq xrefs (mail-header-xref header))
4396 (not (memq (setq number (mail-header-number header))
4399 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4400 (setq start (match-end 0))
4401 (setq group (if prefix
4402 (concat prefix (substring xrefs (match-beginning 1)
4404 (substring xrefs (match-beginning 1) (match-end 1))))
4406 (string-to-int (substring xrefs (match-beginning 2)
4408 (if (setq entry (gnus-gethash group xref-hashtb))
4409 (setcdr entry (cons number (cdr entry)))
4410 (gnus-sethash group (cons number nil) xref-hashtb)))))
4411 (and start xref-hashtb)))
4413 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4414 "Look through all the headers and mark the Xrefs as read."
4415 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4416 name entry info xref-hashtb idlist method nth4)
4418 (set-buffer gnus-group-buffer)
4419 (when (setq xref-hashtb
4420 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4423 (unless (string= from-newsgroup (setq name (symbol-name group)))
4424 (setq idlist (symbol-value group))
4425 ;; Dead groups are not updated.
4427 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4429 (when (stringp (setq nth4 (gnus-info-method info)))
4430 (setq nth4 (gnus-server-to-method nth4))))
4431 ;; Only do the xrefs if the group has the same
4432 ;; select method as the group we have just read.
4433 (or (gnus-methods-equal-p
4434 nth4 (gnus-find-method-for-group from-newsgroup))
4436 (equal nth4 (setq method (gnus-find-method-for-group
4438 (and (equal (car nth4) (car method))
4439 (equal (nth 1 nth4) (nth 1 method))))
4440 gnus-use-cross-reference
4441 (or (not (eq gnus-use-cross-reference t))
4443 ;; Only do cross-references on subscribed
4444 ;; groups, if that is what is wanted.
4445 (<= (gnus-info-level info) gnus-level-subscribed))
4446 (gnus-group-make-articles-read name idlist))))
4449 (defun gnus-compute-read-articles (group articles)
4450 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4451 (info (nth 2 entry))
4452 (active (gnus-active group))
4455 ;; First peel off all invalid article numbers.
4457 (let ((ids articles)
4459 (while (setq id (pop ids))
4460 (when (and first (> id (cdr active)))
4461 ;; We'll end up in this situation in one particular
4462 ;; obscure situation. If you re-scan a group and get
4463 ;; a new article that is cross-posted to a different
4464 ;; group that has not been re-scanned, you might get
4465 ;; crossposted article that has a higher number than
4466 ;; Gnus believes possible. So we re-activate this
4467 ;; group as well. This might mean doing the
4468 ;; crossposting thingy will *increase* the number
4469 ;; of articles in some groups. Tsk, tsk.
4470 (setq active (or (gnus-activate-group group) active)))
4471 (when (or (> id (cdr active))
4472 (< id (car active)))
4473 (setq articles (delq id articles))))))
4474 ;; If the read list is nil, we init it.
4476 (null (gnus-info-read info))
4478 (setq ninfo (cons 1 (1- (car active))))
4479 (setq ninfo (gnus-info-read info)))
4480 ;; Then we add the read articles to the range.
4482 ninfo (setq articles (sort articles '<))))))
4484 (defun gnus-group-make-articles-read (group articles)
4485 "Update the info of GROUP to say that ARTICLES are read."
4487 (entry (gnus-gethash group gnus-newsrc-hashtb))
4488 (info (nth 2 entry))
4489 (active (gnus-active group))
4492 (setq range (gnus-compute-read-articles group articles))
4494 (set-buffer gnus-group-buffer)
4497 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4498 (gnus-info-set-read ',info ',(gnus-info-read info))
4499 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4500 (gnus-group-update-group ,group t))))
4501 ;; Add the read articles to the range.
4502 (gnus-info-set-read info range)
4503 ;; Then we have to re-compute how many unread
4504 ;; articles there are in this group.
4508 (setq num (- (1+ (cdr active)) (car active))))
4509 ((not (listp (cdr range)))
4510 (setq num (- (cdr active) (- (1+ (cdr range))
4514 (if (numberp (car range))
4516 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4517 (setq range (cdr range)))
4518 (setq num (- (cdr active) num))))
4519 ;; Update the number of unread articles.
4521 ;; Update the group buffer.
4522 (gnus-group-update-group group t)))))
4524 (defvar gnus-newsgroup-none-id 0)
4526 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4527 (let ((cur nntp-server-buffer)
4530 (save-excursion (set-buffer gnus-summary-buffer)
4531 gnus-newsgroup-dependencies)))
4533 (mail-parse-charset gnus-newsgroup-charset)
4534 (mail-parse-ignored-charsets
4535 (save-excursion (condition-case nil
4536 (set-buffer gnus-summary-buffer)
4538 gnus-newsgroup-ignored-charsets)))
4540 (set-buffer nntp-server-buffer)
4541 ;; Translate all TAB characters into SPACE characters.
4542 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4543 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4544 (gnus-run-hooks 'gnus-parse-headers-hook)
4545 (let ((case-fold-search t)
4546 in-reply-to header p lines chars ctype)
4547 (goto-char (point-min))
4548 ;; Search to the beginning of the next header. Error messages
4549 ;; do not begin with 2 or 3.
4550 (while (re-search-forward "^[23][0-9]+ " nil t)
4553 ;; This implementation of this function, with nine
4554 ;; search-forwards instead of the one re-search-forward and
4555 ;; a case (which basically was the old function) is actually
4556 ;; about twice as fast, even though it looks messier. You
4557 ;; can't have everything, I guess. Speed and elegance
4558 ;; doesn't always go hand in hand.
4561 (make-full-mail-header
4567 (narrow-to-region (point)
4568 (or (and (search-forward "\n.\n" nil t)
4574 (if (search-forward "\nsubject: " nil t)
4575 (buffer-substring (match-end 0) (std11-field-end))
4580 (if (search-forward "\nfrom: " nil t)
4581 (buffer-substring (match-end 0) (std11-field-end))
4586 (if (search-forward "\ndate: " nil t)
4587 (buffer-substring (match-end 0) (std11-field-end))
4592 (setq id (if (re-search-forward
4593 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4594 ;; We do it this way to make sure the Message-ID
4595 ;; is (somewhat) syntactically valid.
4596 (buffer-substring (match-beginning 1)
4598 ;; If there was no message-id, we just fake one
4599 ;; to make subsequent routines simpler.
4600 (nnheader-generate-fake-message-id))))
4604 (if (search-forward "\nreferences: " nil t)
4608 (buffer-substring (match-end 0) (std11-field-end))
4613 (search-backward ">" end t)
4616 (search-backward "<" end t)
4618 ;; Get the references from the in-reply-to header if there
4619 ;; were no references and the in-reply-to header looks
4621 (if (and (search-forward "\nin-reply-to: " nil t)
4623 (buffer-substring (match-end 0)
4625 (string-match "<[^>]+>" in-reply-to))
4627 (setq ref (substring in-reply-to (match-beginning 0)
4629 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4630 (setq ref2 (substring in-reply-to (match-beginning 0)
4632 (when (> (length ref2) (length ref))
4639 (if (search-forward "\nchars: " nil t)
4640 (if (numberp (setq chars (ignore-errors (read cur))))
4646 (if (search-forward "\nlines: " nil t)
4647 (if (numberp (setq lines (ignore-errors (read cur))))
4653 (and (search-forward "\nxref: " nil t)
4654 (buffer-substring (match-end 0) (std11-field-end))))
4656 (when gnus-extra-headers
4657 (let ((extra gnus-extra-headers)
4661 (when (search-forward
4662 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4663 (push (cons (car extra)
4664 (buffer-substring (match-end 0)
4670 (if (and (search-forward "\ncontent-type: " nil t)
4672 (buffer-substring (match-end 0) (std11-field-end))))
4673 (mime-entity-set-content-type-internal
4674 header (mime-parse-Content-Type ctype)))
4675 (when (equal id ref)
4678 (when gnus-alter-header-function
4679 (funcall gnus-alter-header-function header)
4680 (setq id (mail-header-id header)
4681 ref (gnus-parent-id (mail-header-references header))))
4684 (gnus-dependencies-add-header
4685 header dependencies force-new))
4686 (push header headers))
4687 (goto-char (point-max))
4689 (nreverse headers)))))
4691 ;; Goes through the xover lines and returns a list of vectors
4692 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4693 force-new dependencies
4694 group also-fetch-heads)
4695 "Parse the news overview data in the server buffer, and return a
4696 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4697 ;; Get the Xref when the users reads the articles since most/some
4698 ;; NNTP servers do not include Xrefs when using XOVER.
4699 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4700 (let ((mail-parse-charset gnus-newsgroup-charset)
4701 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4702 (cur nntp-server-buffer)
4703 (dependencies (or dependencies gnus-newsgroup-dependencies))
4704 number headers header)
4706 (set-buffer nntp-server-buffer)
4707 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4708 ;; Allow the user to mangle the headers before parsing them.
4709 (gnus-run-hooks 'gnus-parse-headers-hook)
4710 (goto-char (point-min))
4713 (while (and sequence (not (eobp)))
4714 (setq number (read cur))
4715 (while (and sequence
4716 (< (car sequence) number))
4717 (setq sequence (cdr sequence)))
4719 (eq number (car sequence))
4721 (setq sequence (cdr sequence))
4722 (setq header (inline
4723 (gnus-nov-parse-line
4724 number dependencies force-new))))
4725 (push header headers))
4728 (gnus-error 4 "Strange nov line (%d)"
4729 (count-lines (point-min) (point)))))
4731 ;; A common bug in inn is that if you have posted an article and
4732 ;; then retrieves the active file, it will answer correctly --
4733 ;; the new article is included. However, a NOV entry for the
4734 ;; article may not have been generated yet, so this may fail.
4735 ;; We work around this problem by retrieving the last few
4736 ;; headers using HEAD.
4737 (if (or (not also-fetch-heads)
4739 ;; We (probably) got all the headers.
4741 (let ((gnus-nov-is-evil t))
4744 (gnus-retrieve-parsed-headers sequence group)
4747 (defun gnus-article-get-xrefs ()
4748 "Fill in the Xref value in `gnus-current-headers', if necessary.
4749 This is meant to be called in `gnus-article-internal-prepare-hook'."
4750 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4751 gnus-current-headers)))
4752 (or (not gnus-use-cross-reference)
4754 (and (mail-header-xref headers)
4755 (not (string= (mail-header-xref headers) "")))
4756 (let ((case-fold-search t)
4759 (nnheader-narrow-to-headers)
4760 (goto-char (point-min))
4761 (when (or (and (eq (downcase (char-after)) ?x)
4762 (looking-at "Xref:"))
4763 (search-forward "\nXref:" nil t))
4764 (goto-char (1+ (match-end 0)))
4765 (setq xref (buffer-substring (point)
4766 (progn (end-of-line) (point))))
4767 (mail-header-set-xref headers xref)))))))
4769 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4770 "Find article ID and insert the summary line for that article.
4771 OLD-HEADER can either be a header or a line number to insert
4772 the subject line on."
4773 (let* ((line (and (numberp old-header) old-header))
4774 (old-header (and (vectorp old-header) old-header))
4775 (header (cond ((and old-header use-old-header)
4778 (gnus-number-to-header id))
4779 (gnus-number-to-header id))
4781 (gnus-read-header id))))
4782 (number (and (numberp id) id))
4785 ;; Rebuild the thread that this article is part of and go to the
4786 ;; article we have fetched.
4787 (when (and (not gnus-show-threads)
4790 (setq d (gnus-data-find (mail-header-number old-header))))
4791 (goto-char (gnus-data-pos d))
4794 (- (gnus-point-at-bol)
4796 (1+ (gnus-point-at-eol))
4797 (gnus-delete-line))))))
4799 (mail-header-set-number header (mail-header-number old-header)))
4800 (setq gnus-newsgroup-sparse
4801 (delq (setq number (mail-header-number header))
4802 gnus-newsgroup-sparse))
4803 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4804 (push number gnus-newsgroup-limit)
4805 (gnus-rebuild-thread (mail-header-id header) line)
4806 (gnus-summary-goto-subject number nil t))
4807 (when (and (numberp number)
4809 ;; We have to update the boundaries even if we can't fetch the
4810 ;; article if ID is a number -- so that the next `P' or `N'
4811 ;; command will fetch the previous (or next) article even
4812 ;; if the one we tried to fetch this time has been canceled.
4813 (when (> number gnus-newsgroup-end)
4814 (setq gnus-newsgroup-end number))
4815 (when (< number gnus-newsgroup-begin)
4816 (setq gnus-newsgroup-begin number))
4817 (setq gnus-newsgroup-unselected
4818 (delq number gnus-newsgroup-unselected)))
4819 ;; Report back a success?
4820 (and header (mail-header-number header))))
4822 ;;; Process/prefix in the summary buffer
4824 (defun gnus-summary-work-articles (n)
4825 "Return a list of articles to be worked upon.
4826 The prefix argument, the list of process marked articles, and the
4827 current article will be taken into consideration."
4829 (set-buffer gnus-summary-buffer)
4832 ;; A numerical prefix has been given.
4833 (setq n (prefix-numeric-value n))
4834 (let ((backward (< n 0))
4835 (n (abs (prefix-numeric-value n)))
4840 (push (setq article (gnus-summary-article-number))
4843 (gnus-summary-find-prev nil article)
4844 (gnus-summary-find-next nil article)))
4846 (nreverse articles)))
4847 ((and (gnus-region-active-p) (mark))
4848 (message "region active")
4849 ;; Work on the region between point and mark.
4850 (let ((max (max (point) (mark)))
4853 (goto-char (min (point) (mark)))
4856 (push (setq article (gnus-summary-article-number)) articles)
4857 (gnus-summary-find-next nil article)
4859 (nreverse articles))))
4860 (gnus-newsgroup-processable
4861 ;; There are process-marked articles present.
4862 ;; Save current state.
4863 (gnus-summary-save-process-mark)
4865 (reverse gnus-newsgroup-processable))
4867 ;; Just return the current article.
4868 (list (gnus-summary-article-number))))))
4870 (defmacro gnus-summary-iterate (arg &rest forms)
4871 "Iterate over the process/prefixed articles and do FORMS.
4872 ARG is the interactive prefix given to the command. FORMS will be
4873 executed with point over the summary line of the articles."
4874 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4875 `(let ((,articles (gnus-summary-work-articles ,arg)))
4877 (gnus-summary-goto-subject (car ,articles))
4881 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4882 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4884 (defun gnus-summary-save-process-mark ()
4885 "Push the current set of process marked articles on the stack."
4887 (push (copy-sequence gnus-newsgroup-processable)
4888 gnus-newsgroup-process-stack))
4890 (defun gnus-summary-kill-process-mark ()
4891 "Push the current set of process marked articles on the stack and unmark."
4893 (gnus-summary-save-process-mark)
4894 (gnus-summary-unmark-all-processable))
4896 (defun gnus-summary-yank-process-mark ()
4897 "Pop the last process mark state off the stack and restore it."
4899 (unless gnus-newsgroup-process-stack
4900 (error "Empty mark stack"))
4901 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4903 (defun gnus-summary-process-mark-set (set)
4904 "Make SET into the current process marked articles."
4905 (gnus-summary-unmark-all-processable)
4907 (gnus-summary-set-process-mark (pop set))))
4909 ;;; Searching and stuff
4911 (defun gnus-summary-search-group (&optional backward use-level)
4912 "Search for next unread newsgroup.
4913 If optional argument BACKWARD is non-nil, search backward instead."
4915 (set-buffer gnus-group-buffer)
4916 (when (gnus-group-search-forward
4917 backward nil (if use-level (gnus-group-group-level) nil))
4918 (gnus-group-group-name))))
4920 (defun gnus-summary-best-group (&optional exclude-group)
4921 "Find the name of the best unread group.
4922 If EXCLUDE-GROUP, do not go to this group."
4924 (set-buffer gnus-group-buffer)
4926 (gnus-group-best-unread-group exclude-group))))
4928 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4929 (if backward (gnus-summary-find-prev)
4930 (let* ((dummy (gnus-summary-article-intangible-p))
4931 (article (or article (gnus-summary-article-number)))
4932 (arts (gnus-data-find-list article))
4934 (when (and (not dummy)
4935 (or (not gnus-summary-check-current)
4937 (not (gnus-data-unread-p (car arts)))))
4938 (setq arts (cdr arts)))
4943 (when (or (and undownloaded
4944 (eq gnus-undownloaded-mark
4945 (gnus-data-mark (car arts))))
4946 (gnus-data-unread-p (car arts)))
4947 (setq result (car arts)
4949 (setq arts (cdr arts)))
4952 (goto-char (gnus-data-pos result))
4953 (gnus-data-number result)))))
4955 (defun gnus-summary-find-prev (&optional unread article)
4956 (let* ((eobp (eobp))
4957 (article (or article (gnus-summary-article-number)))
4958 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4960 (when (and (not eobp)
4961 (or (not gnus-summary-check-current)
4963 (not (gnus-data-unread-p (car arts)))))
4964 (setq arts (cdr arts)))
4969 (when (gnus-data-unread-p (car arts))
4970 (setq result (car arts)
4972 (setq arts (cdr arts)))
4975 (goto-char (gnus-data-pos result))
4976 (gnus-data-number result))))
4978 (defun gnus-summary-find-subject (subject &optional unread backward article)
4979 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4980 (article (or article (gnus-summary-article-number)))
4981 (articles (gnus-data-list backward))
4982 (arts (gnus-data-find-list article articles))
4984 (when (or (not gnus-summary-check-current)
4986 (not (gnus-data-unread-p (car arts))))
4987 (setq arts (cdr arts)))
4989 (and (or (not unread)
4990 (gnus-data-unread-p (car arts)))
4991 (vectorp (gnus-data-header (car arts)))
4993 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4994 (setq result (car arts)
4996 (setq arts (cdr arts)))
4998 (goto-char (gnus-data-pos result))
4999 (gnus-data-number result))))
5001 (defun gnus-summary-search-forward (&optional unread subject backward)
5002 "Search forward for an article.
5003 If UNREAD, look for unread articles. If SUBJECT, look for
5004 articles with that subject. If BACKWARD, search backward instead."
5005 (cond (subject (gnus-summary-find-subject subject unread backward))
5006 (backward (gnus-summary-find-prev unread))
5007 (t (gnus-summary-find-next unread))))
5009 (defun gnus-recenter (&optional n)
5010 "Center point in window and redisplay frame.
5011 Also do horizontal recentering."
5013 (when (and gnus-auto-center-summary
5014 (not (eq gnus-auto-center-summary 'vertical)))
5015 (gnus-horizontal-recenter))
5018 (defun gnus-summary-recenter ()
5019 "Center point in the summary window.
5020 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5021 displayed, no centering will be performed."
5022 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5023 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5024 (let* ((top (cond ((< (window-height) 4) 0)
5025 ((< (window-height) 7) 1)
5026 (t (if (numberp gnus-auto-center-summary)
5027 gnus-auto-center-summary
5029 (height (1- (window-height)))
5030 (bottom (save-excursion (goto-char (point-max))
5031 (forward-line (- height))
5033 (window (get-buffer-window (current-buffer))))
5034 ;; The user has to want it.
5035 (when gnus-auto-center-summary
5036 (when (get-buffer-window gnus-article-buffer)
5037 ;; Only do recentering when the article buffer is displayed,
5038 ;; Set the window start to either `bottom', which is the biggest
5039 ;; possible valid number, or the second line from the top,
5040 ;; whichever is the least.
5042 window (min bottom (save-excursion
5043 (forward-line (- top)) (point)))))
5044 ;; Do horizontal recentering while we're at it.
5045 (when (and (get-buffer-window (current-buffer) t)
5046 (not (eq gnus-auto-center-summary 'vertical)))
5047 (let ((selected (selected-window)))
5048 (select-window (get-buffer-window (current-buffer) t))
5049 (gnus-summary-position-point)
5050 (gnus-horizontal-recenter)
5051 (select-window selected))))))
5053 (defun gnus-summary-jump-to-group (newsgroup)
5054 "Move point to NEWSGROUP in group mode buffer."
5055 ;; Keep update point of group mode buffer if visible.
5056 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5057 (save-window-excursion
5058 ;; Take care of tree window mode.
5059 (when (get-buffer-window gnus-group-buffer)
5060 (pop-to-buffer gnus-group-buffer))
5061 (gnus-group-jump-to-group newsgroup))
5063 ;; Take care of tree window mode.
5064 (if (get-buffer-window gnus-group-buffer)
5065 (pop-to-buffer gnus-group-buffer)
5066 (set-buffer gnus-group-buffer))
5067 (gnus-group-jump-to-group newsgroup))))
5069 ;; This function returns a list of article numbers based on the
5070 ;; difference between the ranges of read articles in this group and
5071 ;; the range of active articles.
5072 (defun gnus-list-of-unread-articles (group)
5073 (let* ((read (gnus-info-read (gnus-get-info group)))
5074 (active (or (gnus-active group) (gnus-activate-group group)))
5077 ;; If none are read, then all are unread.
5079 (setq first (car active))
5080 ;; If the range of read articles is a single range, then the
5081 ;; first unread article is the article after the last read
5082 ;; article. Sounds logical, doesn't it?
5083 (if (not (listp (cdr read)))
5084 (setq first (max (car active) (1+ (cdr read))))
5085 ;; `read' is a list of ranges.
5086 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5089 (setq first (car active)))
5092 (while (< first nlast)
5094 (setq first (1+ first))))
5095 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5096 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5097 (setq read (cdr read)))))
5098 ;; And add the last unread articles.
5099 (while (<= first last)
5101 (setq first (1+ first)))
5102 ;; Return the list of unread articles.
5103 (delq 0 (nreverse unread))))
5105 (defun gnus-list-of-read-articles (group)
5106 "Return a list of unread, unticked and non-dormant articles."
5107 (let* ((info (gnus-get-info group))
5108 (marked (gnus-info-marks info))
5109 (active (gnus-active group)))
5111 (gnus-set-difference
5112 (gnus-sorted-complement
5113 (gnus-uncompress-range active)
5114 (gnus-list-of-unread-articles group))
5116 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5117 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5119 ;; Various summary commands
5121 (defun gnus-summary-select-article-buffer ()
5122 "Reconfigure windows to show article buffer."
5124 (if (not (gnus-buffer-live-p gnus-article-buffer))
5125 (error "There is no article buffer for this summary buffer")
5126 (gnus-configure-windows 'article)
5127 (select-window (get-buffer-window gnus-article-buffer))))
5129 (defun gnus-summary-universal-argument (arg)
5130 "Perform any operation on all articles that are process/prefixed."
5132 (let ((articles (gnus-summary-work-articles arg))
5139 (substitute-command-keys
5140 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5143 (gnus-error 1 "Undefined key")
5146 (gnus-summary-goto-subject (setq article (pop articles)))
5147 (let (gnus-newsgroup-processable)
5148 (command-execute func))
5149 (gnus-summary-remove-process-mark article)))))
5150 (gnus-summary-position-point))
5152 (defun gnus-summary-toggle-truncation (&optional arg)
5153 "Toggle truncation of summary lines.
5154 With arg, turn line truncation on iff arg is positive."
5156 (setq truncate-lines
5157 (if (null arg) (not truncate-lines)
5158 (> (prefix-numeric-value arg) 0)))
5161 (defun gnus-summary-reselect-current-group (&optional all rescan)
5162 "Exit and then reselect the current newsgroup.
5163 The prefix argument ALL means to select all articles."
5165 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5166 (error "Ephemeral groups can't be reselected"))
5167 (let ((current-subject (gnus-summary-article-number))
5168 (group gnus-newsgroup-name))
5169 (setq gnus-newsgroup-begin nil)
5171 ;; We have to adjust the point of group mode buffer because
5172 ;; point was moved to the next unread newsgroup by exiting.
5173 (gnus-summary-jump-to-group group)
5176 (gnus-group-get-new-news-this-group 1)))
5177 (gnus-group-read-group all t)
5178 (gnus-summary-goto-subject current-subject nil t)))
5180 (defun gnus-summary-rescan-group (&optional all)
5181 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5183 (gnus-summary-reselect-current-group all t))
5185 (defun gnus-summary-update-info (&optional non-destructive)
5187 (let ((group gnus-newsgroup-name))
5189 (when gnus-newsgroup-kill-headers
5190 (setq gnus-newsgroup-killed
5191 (gnus-compress-sequence
5193 (gnus-set-sorted-intersection
5194 (gnus-uncompress-range gnus-newsgroup-killed)
5195 (setq gnus-newsgroup-unselected
5196 (sort gnus-newsgroup-unselected '<)))
5197 (setq gnus-newsgroup-unreads
5198 (sort gnus-newsgroup-unreads '<)))
5200 (unless (listp (cdr gnus-newsgroup-killed))
5201 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5202 (let ((headers gnus-newsgroup-headers))
5203 ;; Set the new ranges of read articles.
5205 (set-buffer gnus-group-buffer)
5206 (gnus-undo-force-boundary))
5207 (gnus-update-read-articles
5208 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5209 ;; Set the current article marks.
5210 (let ((gnus-newsgroup-scored
5211 (if (and (not gnus-save-score)
5212 (not non-destructive))
5214 gnus-newsgroup-scored)))
5216 (gnus-update-marks)))
5217 ;; Do the cross-ref thing.
5218 (when gnus-use-cross-reference
5219 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5220 ;; Do not switch windows but change the buffer to work.
5221 (set-buffer gnus-group-buffer)
5222 (unless (gnus-ephemeral-group-p group)
5223 (gnus-group-update-group group)))))))
5225 (defun gnus-summary-save-newsrc (&optional force)
5226 "Save the current number of read/marked articles in the dribble buffer.
5227 The dribble buffer will then be saved.
5228 If FORCE (the prefix), also save the .newsrc file(s)."
5230 (gnus-summary-update-info t)
5232 (gnus-save-newsrc-file)
5233 (gnus-dribble-save)))
5235 (defun gnus-summary-exit (&optional temporary)
5236 "Exit reading current newsgroup, and then return to group selection mode.
5237 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5239 (gnus-set-global-variables)
5240 (gnus-kill-save-kill-buffer)
5241 (gnus-async-halt-prefetch)
5242 (let* ((group gnus-newsgroup-name)
5243 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5246 (buf (current-buffer)))
5248 ;; Do adaptive scoring, and possibly save score files.
5249 (when gnus-newsgroup-adaptive
5250 (gnus-score-adaptive))
5251 (when gnus-use-scoring
5253 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5254 ;; If we have several article buffers, we kill them at exit.
5255 (unless gnus-single-article-buffer
5256 (gnus-kill-buffer gnus-original-article-buffer)
5257 (setq gnus-article-current nil))
5258 (when gnus-use-cache
5259 (gnus-cache-possibly-remove-articles)
5260 (gnus-cache-save-buffers))
5261 (gnus-async-prefetch-remove-group group)
5262 (when gnus-suppress-duplicates
5263 (gnus-dup-enter-articles))
5264 (when gnus-use-trees
5265 (gnus-tree-close group))
5266 ;; Remove entries for this group.
5267 (nnmail-purge-split-history (gnus-group-real-name group))
5268 ;; Make all changes in this group permanent.
5270 (gnus-run-hooks 'gnus-exit-group-hook)
5271 (gnus-summary-update-info))
5272 (gnus-close-group group)
5273 ;; Make sure where we were, and go to next newsgroup.
5274 (set-buffer gnus-group-buffer)
5276 (gnus-group-jump-to-group group))
5277 (gnus-run-hooks 'gnus-summary-exit-hook)
5278 (unless (or quit-config
5279 ;; If this group has disappeared from the summary
5280 ;; buffer, don't skip forwards.
5281 (not (string= group (gnus-group-group-name))))
5282 (gnus-group-next-unread-group 1))
5283 (setq group-point (point))
5286 ;; If we have several article buffers, we kill them at exit.
5287 (unless gnus-single-article-buffer
5288 (gnus-kill-buffer gnus-article-buffer)
5289 (gnus-kill-buffer gnus-original-article-buffer)
5290 (setq gnus-article-current nil))
5292 (if (not gnus-kill-summary-on-exit)
5293 (gnus-deaden-summary)
5294 ;; We set all buffer-local variables to nil. It is unclear why
5295 ;; this is needed, but if we don't, buffer-local variables are
5296 ;; not garbage-collected, it seems. This would the lead to en
5297 ;; ever-growing Emacs.
5298 (gnus-summary-clear-local-variables)
5299 (when (get-buffer gnus-article-buffer)
5300 (bury-buffer gnus-article-buffer))
5301 ;; We clear the global counterparts of the buffer-local
5302 ;; variables as well, just to be on the safe side.
5303 (set-buffer gnus-group-buffer)
5304 (gnus-summary-clear-local-variables)
5305 ;; Return to group mode buffer.
5306 (when (eq mode 'gnus-summary-mode)
5307 (gnus-kill-buffer buf)))
5308 (setq gnus-current-select-method gnus-select-method)
5309 (pop-to-buffer gnus-group-buffer)
5310 (if (not quit-config)
5312 (goto-char group-point)
5313 (gnus-configure-windows 'group 'force))
5314 (gnus-handle-ephemeral-exit quit-config))
5315 ;; Clear the current group name.
5317 (setq gnus-newsgroup-name nil)))))
5319 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5320 (defun gnus-summary-exit-no-update (&optional no-questions)
5321 "Quit reading current newsgroup without updating read article info."
5323 (let* ((group gnus-newsgroup-name)
5324 (quit-config (gnus-group-quit-config group)))
5325 (when (or no-questions
5327 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5328 (gnus-async-halt-prefetch)
5330 (delq 'gnus-summary-expire-articles
5331 (copy-list gnus-summary-prepare-exit-hook)))
5332 ;; If we have several article buffers, we kill them at exit.
5333 (unless gnus-single-article-buffer
5334 (gnus-kill-buffer gnus-article-buffer)
5335 (gnus-kill-buffer gnus-original-article-buffer)
5336 (setq gnus-article-current nil))
5337 (if (not gnus-kill-summary-on-exit)
5338 (gnus-deaden-summary)
5339 (gnus-close-group group)
5340 (gnus-summary-clear-local-variables)
5341 (set-buffer gnus-group-buffer)
5342 (gnus-summary-clear-local-variables)
5343 (when (get-buffer gnus-summary-buffer)
5344 (kill-buffer gnus-summary-buffer)))
5345 (unless gnus-single-article-buffer
5346 (setq gnus-article-current nil))
5347 (when gnus-use-trees
5348 (gnus-tree-close group))
5349 (gnus-async-prefetch-remove-group group)
5350 (when (get-buffer gnus-article-buffer)
5351 (bury-buffer gnus-article-buffer))
5352 ;; Return to the group buffer.
5353 (gnus-configure-windows 'group 'force)
5354 ;; Clear the current group name.
5355 (setq gnus-newsgroup-name nil)
5356 (when (equal (gnus-group-group-name) group)
5357 (gnus-group-next-unread-group 1))
5359 (gnus-handle-ephemeral-exit quit-config)))))
5361 (defun gnus-handle-ephemeral-exit (quit-config)
5362 "Handle movement when leaving an ephemeral group.
5363 The state which existed when entering the ephemeral is reset."
5364 (if (not (buffer-name (car quit-config)))
5365 (gnus-configure-windows 'group 'force)
5366 (set-buffer (car quit-config))
5367 (cond ((eq major-mode 'gnus-summary-mode)
5368 (gnus-set-global-variables))
5369 ((eq major-mode 'gnus-article-mode)
5371 ;; The `gnus-summary-buffer' variable may point
5372 ;; to the old summary buffer when using a single
5374 (unless (gnus-buffer-live-p gnus-summary-buffer)
5375 (set-buffer gnus-group-buffer))
5376 (set-buffer gnus-summary-buffer)
5377 (gnus-set-global-variables))))
5378 (if (or (eq (cdr quit-config) 'article)
5379 (eq (cdr quit-config) 'pick))
5381 ;; The current article may be from the ephemeral group
5382 ;; thus it is best that we reload this article
5383 (gnus-summary-show-article)
5384 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5385 (gnus-configure-windows 'pick 'force)
5386 (gnus-configure-windows (cdr quit-config) 'force)))
5387 (gnus-configure-windows (cdr quit-config) 'force))
5388 (when (eq major-mode 'gnus-summary-mode)
5389 (gnus-summary-next-subject 1 nil t)
5390 (gnus-summary-recenter)
5391 (gnus-summary-position-point))))
5393 (defun gnus-summary-preview-mime-message ()
5394 "MIME decode and play this message."
5396 (let ((gnus-break-pages nil)
5398 (gnus-summary-select-article gnus-show-all-headers t))
5399 (select-window (get-buffer-window gnus-article-buffer)))
5403 (defvar gnus-dead-summary-mode-map nil)
5405 (unless gnus-dead-summary-mode-map
5406 (setq gnus-dead-summary-mode-map (make-keymap))
5407 (suppress-keymap gnus-dead-summary-mode-map)
5408 (substitute-key-definition
5409 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5410 (let ((keys '("\C-d" "\r" "\177" [delete])))
5412 (define-key gnus-dead-summary-mode-map
5413 (pop keys) 'gnus-summary-wake-up-the-dead))))
5415 (defvar gnus-dead-summary-mode nil
5416 "Minor mode for Gnus summary buffers.")
5418 (defun gnus-dead-summary-mode (&optional arg)
5419 "Minor mode for Gnus summary buffers."
5421 (when (eq major-mode 'gnus-summary-mode)
5422 (make-local-variable 'gnus-dead-summary-mode)
5423 (setq gnus-dead-summary-mode
5424 (if (null arg) (not gnus-dead-summary-mode)
5425 (> (prefix-numeric-value arg) 0)))
5426 (when gnus-dead-summary-mode
5427 (gnus-add-minor-mode
5428 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5430 (defun gnus-deaden-summary ()
5431 "Make the current summary buffer into a dead summary buffer."
5432 ;; Kill any previous dead summary buffer.
5433 (when (and gnus-dead-summary
5434 (buffer-name gnus-dead-summary))
5436 (set-buffer gnus-dead-summary)
5437 (when gnus-dead-summary-mode
5438 (kill-buffer (current-buffer)))))
5439 ;; Make this the current dead summary.
5440 (setq gnus-dead-summary (current-buffer))
5441 (gnus-dead-summary-mode 1)
5442 (let ((name (buffer-name)))
5443 (when (string-match "Summary" name)
5445 (concat (substring name 0 (match-beginning 0)) "Dead "
5446 (substring name (match-beginning 0)))
5449 (defun gnus-kill-or-deaden-summary (buffer)
5450 "Kill or deaden the summary BUFFER."
5452 (when (and (buffer-name buffer)
5453 (not gnus-single-article-buffer))
5456 (gnus-kill-buffer gnus-article-buffer)
5457 (gnus-kill-buffer gnus-original-article-buffer)))
5458 (cond (gnus-kill-summary-on-exit
5459 (when (and gnus-use-trees
5460 (gnus-buffer-exists-p buffer))
5463 (gnus-tree-close gnus-newsgroup-name)))
5464 (gnus-kill-buffer buffer))
5465 ((gnus-buffer-exists-p buffer)
5468 (gnus-deaden-summary))))))
5470 (defun gnus-summary-wake-up-the-dead (&rest args)
5471 "Wake up the dead summary buffer."
5473 (gnus-dead-summary-mode -1)
5474 (let ((name (buffer-name)))
5475 (when (string-match "Dead " name)
5477 (concat (substring name 0 (match-beginning 0))
5478 (substring name (match-end 0)))
5480 (gnus-message 3 "This dead summary is now alive again"))
5482 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5483 (defun gnus-summary-fetch-faq (&optional faq-dir)
5484 "Fetch the FAQ for the current group.
5485 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5489 (when current-prefix-arg
5491 "Faq dir: " (and (listp gnus-group-faq-directory)
5492 (mapcar (lambda (file) (list file))
5493 gnus-group-faq-directory))))))
5494 (let (gnus-faq-buffer)
5495 (when (setq gnus-faq-buffer
5496 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5497 (gnus-configure-windows 'summary-faq))))
5499 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5500 (defun gnus-summary-describe-group (&optional force)
5501 "Describe the current newsgroup."
5503 (gnus-group-describe-group force gnus-newsgroup-name))
5505 (defun gnus-summary-describe-briefly ()
5506 "Describe summary mode commands briefly."
5508 (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")))
5510 ;; Walking around group mode buffer from summary mode.
5512 (defun gnus-summary-next-group (&optional no-article target-group backward)
5513 "Exit current newsgroup and then select next unread newsgroup.
5514 If prefix argument NO-ARTICLE is non-nil, no article is selected
5515 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5516 previous group instead."
5518 ;; Stop pre-fetching.
5519 (gnus-async-halt-prefetch)
5520 (let ((current-group gnus-newsgroup-name)
5521 (current-buffer (current-buffer))
5523 ;; First we semi-exit this group to update Xrefs and all variables.
5524 ;; We can't do a real exit, because the window conf must remain
5525 ;; the same in case the user is prompted for info, and we don't
5526 ;; want the window conf to change before that...
5527 (gnus-summary-exit t)
5528 (while (not entered)
5529 ;; Then we find what group we are supposed to enter.
5530 (set-buffer gnus-group-buffer)
5531 (gnus-group-jump-to-group current-group)
5534 (if (eq gnus-keep-same-level 'best)
5535 (gnus-summary-best-group gnus-newsgroup-name)
5536 (gnus-summary-search-group backward gnus-keep-same-level))))
5537 (if (not target-group)
5538 ;; There are no further groups, so we return to the group
5541 (gnus-message 5 "Returning to the group buffer")
5543 (when (gnus-buffer-live-p current-buffer)
5544 (set-buffer current-buffer)
5545 (gnus-summary-exit))
5546 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5547 ;; We try to enter the target group.
5548 (gnus-group-jump-to-group target-group)
5549 (let ((unreads (gnus-group-group-unread)))
5550 (if (and (or (eq t unreads)
5551 (and unreads (not (zerop unreads))))
5552 (gnus-summary-read-group
5553 target-group nil no-article
5554 (and (buffer-name current-buffer) current-buffer)
5557 (setq current-group target-group
5558 target-group nil)))))))
5560 (defun gnus-summary-prev-group (&optional no-article)
5561 "Exit current newsgroup and then select previous unread newsgroup.
5562 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5564 (gnus-summary-next-group no-article nil t))
5566 ;; Walking around summary lines.
5568 (defun gnus-summary-first-subject (&optional unread undownloaded)
5569 "Go to the first unread subject.
5570 If UNREAD is non-nil, go to the first unread article.
5571 Returns the article selected or nil if there are no unread articles."
5576 ((null gnus-newsgroup-data)
5577 (gnus-message 3 "No articles in the group")
5579 ;; Pick the first article.
5581 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5582 (gnus-data-number (car gnus-newsgroup-data)))
5583 ;; No unread articles.
5584 ((null gnus-newsgroup-unreads)
5585 (gnus-message 3 "No more unread articles")
5587 ;; Find the first unread article.
5589 (let ((data gnus-newsgroup-data))
5591 (and (not (and undownloaded
5592 (eq gnus-undownloaded-mark
5593 (gnus-data-mark (car data)))))
5594 (not (gnus-data-unread-p (car data)))))
5595 (setq data (cdr data)))
5597 (goto-char (gnus-data-pos (car data)))
5598 (gnus-data-number (car data))))))
5599 (gnus-summary-position-point)))
5601 (defun gnus-summary-next-subject (n &optional unread dont-display)
5602 "Go to next N'th summary line.
5603 If N is negative, go to the previous N'th subject line.
5604 If UNREAD is non-nil, only unread articles are selected.
5605 The difference between N and the actual number of steps taken is
5608 (let ((backward (< n 0))
5612 (gnus-summary-find-prev unread)
5613 (gnus-summary-find-next unread)))
5614 (gnus-summary-show-thread)
5617 (gnus-message 7 "No more%s articles"
5618 (if unread " unread" "")))
5619 (unless dont-display
5620 (gnus-summary-recenter)
5621 (gnus-summary-position-point))
5624 (defun gnus-summary-next-unread-subject (n)
5625 "Go to next N'th unread summary line."
5627 (gnus-summary-next-subject n t))
5629 (defun gnus-summary-prev-subject (n &optional unread)
5630 "Go to previous N'th summary line.
5631 If optional argument UNREAD is non-nil, only unread article is selected."
5633 (gnus-summary-next-subject (- n) unread))
5635 (defun gnus-summary-prev-unread-subject (n)
5636 "Go to previous N'th unread summary line."
5638 (gnus-summary-next-subject (- n) t))
5640 (defun gnus-summary-goto-subject (article &optional force silent)
5641 "Go the subject line of ARTICLE.
5642 If FORCE, also allow jumping to articles not currently shown."
5643 (interactive "nArticle number: ")
5645 (data (gnus-data-find article)))
5646 ;; We read in the article if we have to.
5649 (gnus-summary-insert-subject
5651 (if (or (numberp force) (vectorp force)) force)
5653 (setq data (gnus-data-find article)))
5658 (gnus-message 3 "Can't find article %d" article))
5660 (goto-char (gnus-data-pos data))
5661 (gnus-summary-position-point)
5664 ;; Walking around summary lines with displaying articles.
5666 (defun gnus-summary-expand-window (&optional arg)
5667 "Make the summary buffer take up the entire Emacs frame.
5668 Given a prefix, will force an `article' buffer configuration."
5671 (gnus-configure-windows 'article 'force)
5672 (gnus-configure-windows 'summary 'force)))
5674 (defun gnus-summary-display-article (article &optional all-header)
5675 "Display ARTICLE in article buffer."
5676 (gnus-set-global-variables)
5680 (if gnus-summary-display-article-function
5681 (funcall gnus-summary-display-article-function article all-header)
5682 (gnus-article-prepare article all-header))
5683 (gnus-run-hooks 'gnus-select-article-hook)
5684 (when (and gnus-current-article
5685 (not (zerop gnus-current-article)))
5686 (gnus-summary-goto-subject gnus-current-article))
5687 (gnus-summary-recenter)
5688 (when (and gnus-use-trees gnus-show-threads)
5689 (gnus-possibly-generate-tree article)
5690 (gnus-highlight-selected-tree article))
5691 ;; Successfully display article.
5692 (gnus-article-set-window-start
5693 (cdr (assq article gnus-newsgroup-bookmarks))))))
5695 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5696 "Select the current article.
5697 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5698 non-nil, the article will be re-fetched even if it already present in
5699 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5701 ;; Make sure we are in the summary buffer to work around bbdb bug.
5702 (unless (eq major-mode 'gnus-summary-mode)
5703 (set-buffer gnus-summary-buffer))
5704 (let ((article (or article (gnus-summary-article-number)))
5705 (all-headers (not (not all-headers))) ;Must be T or NIL.
5706 gnus-summary-display-article-function
5709 (gnus-summary-article-pseudo-p article)
5710 (error "This is a pseudo-article"))
5713 (set-buffer gnus-summary-buffer)
5714 (if (or (and gnus-single-article-buffer
5715 (or (null gnus-current-article)
5716 (null gnus-article-current)
5717 (null (get-buffer gnus-article-buffer))
5718 (not (eq article (cdr gnus-article-current)))
5719 (not (equal (car gnus-article-current)
5720 gnus-newsgroup-name))))
5721 (and (not gnus-single-article-buffer)
5722 (or (null gnus-current-article)
5723 (not (eq gnus-current-article article))))
5725 ;; The requested article is different from the current article.
5727 (gnus-summary-display-article article all-headers)
5729 (when (or all-headers gnus-show-all-headers)
5730 (gnus-article-show-all-headers)))
5731 (when (or all-headers gnus-show-all-headers)
5732 (gnus-article-show-all-headers))
5735 (gnus-article-set-window-start
5736 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5738 (defun gnus-summary-set-current-mark (&optional current-mark)
5739 "Obsolete function."
5742 (defun gnus-summary-next-article (&optional unread subject backward push)
5743 "Select the next article.
5744 If UNREAD, only unread articles are selected.
5745 If SUBJECT, only articles with SUBJECT are selected.
5746 If BACKWARD, the previous article is selected instead of the next."
5749 ;; Is there such an article?
5750 ((and (gnus-summary-search-forward unread subject backward)
5751 (or (gnus-summary-display-article (gnus-summary-article-number))
5752 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5753 (gnus-summary-position-point))
5754 ;; If not, we try the first unread, if that is wanted.
5756 gnus-auto-select-same
5757 (gnus-summary-first-unread-article))
5758 (gnus-summary-position-point)
5759 (gnus-message 6 "Wrapped"))
5760 ;; Try to get next/previous article not displayed in this group.
5761 ((and gnus-auto-extend-newsgroup
5762 (not unread) (not subject))
5763 (gnus-summary-goto-article
5764 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5765 nil (count-lines (point-min) (point))))
5766 ;; Go to next/previous group.
5768 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5769 (gnus-summary-jump-to-group gnus-newsgroup-name))
5770 (let ((cmd last-command-char)
5773 (set-buffer gnus-group-buffer)
5776 (if (eq gnus-keep-same-level 'best)
5777 (gnus-summary-best-group gnus-newsgroup-name)
5778 (gnus-summary-search-group backward gnus-keep-same-level))))
5779 ;; For some reason, the group window gets selected. We change
5781 (select-window (get-buffer-window (current-buffer)))
5782 ;; Select next unread newsgroup automagically.
5784 ((or (not gnus-auto-select-next)
5786 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5787 ((or (eq gnus-auto-select-next 'quietly)
5788 (and (eq gnus-auto-select-next 'slightly-quietly)
5790 (and (eq gnus-auto-select-next 'almost-quietly)
5791 (gnus-summary-last-article-p)))
5793 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5795 (gnus-message 7 "No more%s articles (%s)..."
5796 (if unread " unread" "")
5797 (if group (concat "selecting " group)
5799 (gnus-summary-next-group nil group backward)))
5801 (when (gnus-key-press-event-p last-input-event)
5802 (gnus-summary-walk-group-buffer
5803 gnus-newsgroup-name cmd unread backward point))))))))
5805 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5806 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5807 (?\C-p (gnus-group-prev-unread-group 1))))
5808 (cursor-in-echo-area t)
5809 keve key group ended)
5811 (set-buffer gnus-group-buffer)
5814 (if (eq gnus-keep-same-level 'best)
5815 (gnus-summary-best-group gnus-newsgroup-name)
5816 (gnus-summary-search-group backward gnus-keep-same-level))))
5819 5 "No more%s articles%s" (if unread " unread" "")
5821 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5822 (format " (Type %s for %s [%s])"
5823 (single-key-description cmd) group
5824 (car (gnus-gethash group gnus-newsrc-hashtb)))
5825 (format " (Type %s to exit %s)"
5826 (single-key-description cmd)
5827 gnus-newsgroup-name)))
5828 ;; Confirm auto selection.
5829 (setq key (car (setq keve (gnus-read-event-char))))
5832 ((assq key keystrokes)
5833 (let ((obuf (current-buffer)))
5834 (switch-to-buffer gnus-group-buffer)
5836 (gnus-group-jump-to-group group))
5837 (eval (cadr (assq key keystrokes)))
5838 (setq group (gnus-group-group-name))
5839 (switch-to-buffer obuf))
5843 (gnus-ephemeral-group-p gnus-newsgroup-name))
5845 (gnus-summary-next-group nil group backward)))
5847 (push (cdr keve) unread-command-events))))))
5849 (defun gnus-summary-next-unread-article ()
5850 "Select unread article after current one."
5852 (gnus-summary-next-article
5853 (or (not (eq gnus-summary-goto-unread 'never))
5854 (gnus-summary-last-article-p (gnus-summary-article-number)))
5855 (and gnus-auto-select-same
5856 (gnus-summary-article-subject))))
5858 (defun gnus-summary-prev-article (&optional unread subject)
5859 "Select the article after the current one.
5860 If UNREAD is non-nil, only unread articles are selected."
5862 (gnus-summary-next-article unread subject t))
5864 (defun gnus-summary-prev-unread-article ()
5865 "Select unread article before current one."
5867 (gnus-summary-prev-article
5868 (or (not (eq gnus-summary-goto-unread 'never))
5869 (gnus-summary-first-article-p (gnus-summary-article-number)))
5870 (and gnus-auto-select-same
5871 (gnus-summary-article-subject))))
5873 (defun gnus-summary-next-page (&optional lines circular)
5874 "Show next page of the selected article.
5875 If at the end of the current article, select the next article.
5876 LINES says how many lines should be scrolled up.
5878 If CIRCULAR is non-nil, go to the start of the article instead of
5879 selecting the next article when reaching the end of the current
5882 (setq gnus-summary-buffer (current-buffer))
5883 (gnus-set-global-variables)
5884 (let ((article (gnus-summary-article-number))
5885 (article-window (get-buffer-window gnus-article-buffer t))
5887 ;; If the buffer is empty, we have no article.
5889 (error "No article to select"))
5890 (gnus-configure-windows 'article)
5891 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5892 (if (and (eq gnus-summary-goto-unread 'never)
5893 (not (gnus-summary-last-article-p article)))
5894 (gnus-summary-next-article)
5895 (gnus-summary-next-unread-article))
5896 (if (or (null gnus-current-article)
5897 (null gnus-article-current)
5898 (/= article (cdr gnus-article-current))
5899 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5900 ;; Selected subject is different from current article's.
5901 (gnus-summary-display-article article)
5902 (when article-window
5903 (gnus-eval-in-buffer-window gnus-article-buffer
5904 (setq endp (gnus-article-next-page lines)))
5907 (gnus-summary-beginning-of-article))
5909 (gnus-message 3 "End of message"))
5911 (if (and (eq gnus-summary-goto-unread 'never)
5912 (not (gnus-summary-last-article-p article)))
5913 (gnus-summary-next-article)
5914 (gnus-summary-next-unread-article))))))))
5915 (gnus-summary-recenter)
5916 (gnus-summary-position-point)))
5918 (defun gnus-summary-prev-page (&optional lines move)
5919 "Show previous page of selected article.
5920 Argument LINES specifies lines to be scrolled down.
5921 If MOVE, move to the previous unread article if point is at
5922 the beginning of the buffer."
5924 (let ((article (gnus-summary-article-number))
5925 (article-window (get-buffer-window gnus-article-buffer t))
5927 (gnus-configure-windows 'article)
5928 (if (or (null gnus-current-article)
5929 (null gnus-article-current)
5930 (/= article (cdr gnus-article-current))
5931 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5932 ;; Selected subject is different from current article's.
5933 (gnus-summary-display-article article)
5934 (gnus-summary-recenter)
5935 (when article-window
5936 (gnus-eval-in-buffer-window gnus-article-buffer
5937 (setq endp (gnus-article-prev-page lines)))
5938 (when (and move endp)
5940 (gnus-message 3 "Beginning of message"))
5942 (if (and (eq gnus-summary-goto-unread 'never)
5943 (not (gnus-summary-first-article-p article)))
5944 (gnus-summary-prev-article)
5945 (gnus-summary-prev-unread-article))))))))
5946 (gnus-summary-position-point))
5948 (defun gnus-summary-prev-page-or-article (&optional lines)
5949 "Show previous page of selected article.
5950 Argument LINES specifies lines to be scrolled down.
5951 If at the beginning of the article, go to the next article."
5953 (gnus-summary-prev-page lines t))
5955 (defun gnus-summary-scroll-up (lines)
5956 "Scroll up (or down) one line current article.
5957 Argument LINES specifies lines to be scrolled up (or down if negative)."
5959 (gnus-configure-windows 'article)
5960 (gnus-summary-show-thread)
5961 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5962 (gnus-eval-in-buffer-window gnus-article-buffer
5964 (when (gnus-article-next-page lines)
5965 (gnus-message 3 "End of message")))
5967 (gnus-article-prev-page (- lines))))))
5968 (gnus-summary-recenter)
5969 (gnus-summary-position-point))
5971 (defun gnus-summary-scroll-down (lines)
5972 "Scroll down (or up) one line current article.
5973 Argument LINES specifies lines to be scrolled down (or up if negative)."
5975 (gnus-summary-scroll-up (- lines)))
5977 (defun gnus-summary-next-same-subject ()
5978 "Select next article which has the same subject as current one."
5980 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5982 (defun gnus-summary-prev-same-subject ()
5983 "Select previous article which has the same subject as current one."
5985 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5987 (defun gnus-summary-next-unread-same-subject ()
5988 "Select next unread article which has the same subject as current one."
5990 (gnus-summary-next-article t (gnus-summary-article-subject)))
5992 (defun gnus-summary-prev-unread-same-subject ()
5993 "Select previous unread article which has the same subject as current one."
5995 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5997 (defun gnus-summary-first-unread-article ()
5998 "Select the first unread article.
5999 Return nil if there are no unread articles."
6002 (when (gnus-summary-first-subject t)
6003 (gnus-summary-show-thread)
6004 (gnus-summary-first-subject t)
6005 (gnus-summary-display-article (gnus-summary-article-number)))
6006 (gnus-summary-position-point)))
6008 (defun gnus-summary-first-unread-subject ()
6009 "Place the point on the subject line of the first unread article.
6010 Return nil if there are no unread articles."
6013 (when (gnus-summary-first-subject t)
6014 (gnus-summary-show-thread)
6015 (gnus-summary-first-subject t))
6016 (gnus-summary-position-point)))
6018 (defun gnus-summary-first-article ()
6019 "Select the first article.
6020 Return nil if there are no articles."
6023 (when (gnus-summary-first-subject)
6024 (gnus-summary-show-thread)
6025 (gnus-summary-first-subject)
6026 (gnus-summary-display-article (gnus-summary-article-number)))
6027 (gnus-summary-position-point)))
6029 (defun gnus-summary-best-unread-article ()
6030 "Select the unread article with the highest score."
6032 (let ((best -1000000)
6033 (data gnus-newsgroup-data)
6036 (and (gnus-data-unread-p (car data))
6038 (gnus-summary-article-score (gnus-data-number (car data))))
6041 article (gnus-data-number (car data))))
6042 (setq data (cdr data)))
6045 (gnus-summary-goto-article article)
6046 (error "No unread articles"))
6047 (gnus-summary-position-point))))
6049 (defun gnus-summary-last-subject ()
6050 "Go to the last displayed subject line in the group."
6051 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6053 (gnus-summary-goto-subject article))))
6055 (defun gnus-summary-goto-article (article &optional all-headers force)
6056 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6057 If ALL-HEADERS is non-nil, no header lines are hidden.
6058 If FORCE, go to the article even if it isn't displayed. If FORCE
6059 is a number, it is the line the article is to be displayed on."
6063 "Article number or Message-ID: "
6064 (mapcar (lambda (number) (list (int-to-string number)))
6065 gnus-newsgroup-limit))
6069 (if (and (stringp article)
6070 (string-match "@" article))
6071 (gnus-summary-refer-article article)
6072 (when (stringp article)
6073 (setq article (string-to-number article)))
6074 (if (gnus-summary-goto-subject article force)
6075 (gnus-summary-display-article article all-headers)
6076 (gnus-message 4 "Couldn't go to article %s" article) nil))
6077 (gnus-summary-position-point)))
6079 (defun gnus-summary-goto-last-article ()
6080 "Go to the previously read article."
6083 (when gnus-last-article
6084 (gnus-summary-goto-article gnus-last-article nil t))
6085 (gnus-summary-position-point)))
6087 (defun gnus-summary-pop-article (number)
6088 "Pop one article off the history and go to the previous.
6089 NUMBER articles will be popped off."
6092 (setq gnus-newsgroup-history
6093 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6095 (gnus-summary-goto-article (car to) nil t)
6096 (error "Article history empty")))
6097 (gnus-summary-position-point))
6099 ;; Summary commands and functions for limiting the summary buffer.
6101 (defun gnus-summary-limit-to-articles (n)
6102 "Limit the summary buffer to the next N articles.
6103 If not given a prefix, use the process marked articles instead."
6106 (let ((articles (gnus-summary-work-articles n)))
6107 (setq gnus-newsgroup-processable nil)
6108 (gnus-summary-limit articles))
6109 (gnus-summary-position-point)))
6111 (defun gnus-summary-pop-limit (&optional total)
6112 "Restore the previous limit.
6113 If given a prefix, remove all limits."
6116 (setq gnus-newsgroup-limits
6117 (list (mapcar (lambda (h) (mail-header-number h))
6118 gnus-newsgroup-headers))))
6119 (unless gnus-newsgroup-limits
6120 (error "No limit to pop"))
6122 (gnus-summary-limit nil 'pop)
6123 (gnus-summary-position-point)))
6125 (defun gnus-summary-limit-to-subject (subject &optional header)
6126 "Limit the summary buffer to articles that have subjects that match a regexp."
6127 (interactive "sLimit to subject (regexp): ")
6129 (setq header "subject"))
6130 (when (not (equal "" subject))
6132 (let ((articles (gnus-summary-find-matching
6133 (or header "subject") subject 'all)))
6135 (error "Found no matches for \"%s\"" subject))
6136 (gnus-summary-limit articles))
6137 (gnus-summary-position-point))))
6139 (defun gnus-summary-limit-to-author (from)
6140 "Limit the summary buffer to articles that have authors that match a regexp."
6141 (interactive "sLimit to author (regexp): ")
6142 (gnus-summary-limit-to-subject from "from"))
6144 (defun gnus-summary-limit-to-age (age &optional younger-p)
6145 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6146 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6147 articles that are younger than AGE days."
6148 (interactive "nLimit to articles older than (in days): \nP")
6150 (let ((data gnus-newsgroup-data)
6151 (cutoff (days-to-time age))
6152 articles d date is-younger)
6153 (while (setq d (pop data))
6154 (when (and (vectorp (gnus-data-header d))
6155 (setq date (mail-header-date (gnus-data-header d))))
6156 (setq is-younger (time-less-p
6157 (time-since (date-to-time date))
6162 (push (gnus-data-number d) articles))))
6163 (gnus-summary-limit (nreverse articles)))
6164 (gnus-summary-position-point)))
6166 (defun gnus-summary-limit-to-extra (header regexp)
6167 "Limit the summary buffer to articles that match an 'extra' header."
6171 (gnus-completing-read
6172 (symbol-name (car gnus-extra-headers))
6173 "Limit extra header:"
6175 (cons (symbol-name x) x))
6180 (read-string (format "Limit to header %s (regexp): " header)))))
6181 (when (not (equal "" regexp))
6183 (let ((articles (gnus-summary-find-matching
6184 (cons 'extra header) regexp 'all)))
6186 (error "Found no matches for \"%s\"" regexp))
6187 (gnus-summary-limit articles))
6188 (gnus-summary-position-point))))
6190 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6192 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6194 (defun gnus-summary-limit-to-unread (&optional all)
6195 "Limit the summary buffer to articles that are not marked as read.
6196 If ALL is non-nil, limit strictly to unread articles."
6199 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6200 (gnus-summary-limit-to-marks
6201 ;; Concat all the marks that say that an article is read and have
6203 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6204 gnus-killed-mark gnus-kill-file-mark
6205 gnus-low-score-mark gnus-expirable-mark
6206 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6207 gnus-duplicate-mark gnus-souped-mark)
6210 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6211 (make-obsolete 'gnus-summary-delete-marked-with
6212 'gnus-summary-limit-exlude-marks)
6214 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6215 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6216 If REVERSE, limit the summary buffer to articles that are marked
6217 with MARKS. MARKS can either be a string of marks or a list of marks.
6218 Returns how many articles were removed."
6219 (interactive "sMarks: ")
6220 (gnus-summary-limit-to-marks marks t))
6222 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6223 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6224 If REVERSE (the prefix), limit the summary buffer to articles that are
6225 not marked with MARKS. MARKS can either be a string of marks or a
6227 Returns how many articles were removed."
6228 (interactive "sMarks: \nP")
6230 (let ((data gnus-newsgroup-data)
6231 (marks (if (listp marks) marks
6232 (append marks nil))) ; Transform to list.
6235 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6236 (memq (gnus-data-mark (car data)) marks))
6237 (push (gnus-data-number (car data)) articles))
6238 (setq data (cdr data)))
6239 (gnus-summary-limit articles))
6240 (gnus-summary-position-point)))
6242 (defun gnus-summary-limit-to-score (&optional score)
6243 "Limit to articles with score at or above SCORE."
6245 (setq score (if score
6246 (prefix-numeric-value score)
6247 (or gnus-summary-default-score 0)))
6248 (let ((data gnus-newsgroup-data)
6251 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6253 (push (gnus-data-number (car data)) articles))
6254 (setq data (cdr data)))
6256 (gnus-summary-limit articles)
6257 (gnus-summary-position-point))))
6259 (defun gnus-summary-limit-include-thread (id)
6260 "Display all the hidden articles that in the current thread."
6261 (interactive (list (mail-header-id (gnus-summary-article-header))))
6262 (let ((articles (gnus-articles-in-thread
6263 (gnus-id-to-thread (gnus-root-id id)))))
6265 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6266 (gnus-summary-position-point))))
6268 (defun gnus-summary-limit-include-dormant ()
6269 "Display all the hidden articles that are marked as dormant.
6270 Note that this command only works on a subset of the articles currently
6271 fetched for this group."
6273 (unless gnus-newsgroup-dormant
6274 (error "There are no dormant articles in this group"))
6276 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6277 (gnus-summary-position-point)))
6279 (defun gnus-summary-limit-exclude-dormant ()
6280 "Hide all dormant articles."
6283 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6284 (gnus-summary-position-point)))
6286 (defun gnus-summary-limit-exclude-childless-dormant ()
6287 "Hide all dormant articles that have no children."
6289 (let ((data (gnus-data-list t))
6290 articles d children)
6291 ;; Find all articles that are either not dormant or have
6293 (while (setq d (pop data))
6294 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6296 (gnus-article-children (gnus-data-number d)))
6299 (when (memq (car children) articles)
6304 (push (gnus-data-number d) articles)))
6307 (gnus-summary-limit articles)
6308 (gnus-summary-position-point))))
6310 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6311 "Mark all unread excluded articles as read.
6312 If ALL, mark even excluded ticked and dormants as read."
6314 (let ((articles (gnus-sorted-complement
6316 (mapcar (lambda (h) (mail-header-number h))
6317 gnus-newsgroup-headers)
6319 (sort gnus-newsgroup-limit '<)))
6321 (setq gnus-newsgroup-unreads
6322 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6324 (setq gnus-newsgroup-dormant nil
6325 gnus-newsgroup-marked nil
6326 gnus-newsgroup-reads
6328 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6329 gnus-newsgroup-reads))
6330 (while (setq article (pop articles))
6331 (unless (or (memq article gnus-newsgroup-dormant)
6332 (memq article gnus-newsgroup-marked))
6333 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6335 (defun gnus-summary-limit (articles &optional pop)
6337 ;; We pop the previous limit off the stack and use that.
6338 (setq articles (car gnus-newsgroup-limits)
6339 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6340 ;; We use the new limit, so we push the old limit on the stack.
6341 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6343 (setq gnus-newsgroup-limit articles)
6344 (let ((total (length gnus-newsgroup-data))
6345 (data (gnus-data-find-list (gnus-summary-article-number)))
6346 (gnus-summary-mark-below nil) ; Inhibit this.
6348 ;; This will do all the work of generating the new summary buffer
6349 ;; according to the new limit.
6350 (gnus-summary-prepare)
6351 ;; Hide any threads, possibly.
6352 (and gnus-show-threads
6353 gnus-thread-hide-subtree
6354 (gnus-summary-hide-all-threads))
6355 ;; Try to return to the article you were at, or one in the
6358 ;; We try to find some article after the current one.
6360 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6363 (setq data (cdr data))))
6365 ;; If there is no data, that means that we were after the last
6366 ;; article. The same goes when we can't find any articles
6367 ;; after the current one.
6368 (goto-char (point-max))
6369 (gnus-summary-find-prev))
6370 (gnus-set-mode-line 'summary)
6371 ;; We return how many articles were removed from the summary
6372 ;; buffer as a result of the new limit.
6373 (- total (length gnus-newsgroup-data))))
6375 (defsubst gnus-invisible-cut-children (threads)
6378 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6383 (defsubst gnus-cut-thread (thread)
6384 "Go forwards in the thread until we find an article that we want to display."
6385 (when (or (eq gnus-fetch-old-headers 'some)
6386 (eq gnus-fetch-old-headers 'invisible)
6387 (eq gnus-build-sparse-threads 'some)
6388 (eq gnus-build-sparse-threads 'more))
6389 ;; Deal with old-fetched headers and sparse threads.
6393 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6394 (gnus-summary-article-ancient-p
6395 (mail-header-number (car thread))))
6396 (if (or (<= (length (cdr thread)) 1)
6397 (eq gnus-fetch-old-headers 'invisible))
6398 (setq gnus-newsgroup-limit
6399 (delq (mail-header-number (car thread))
6400 gnus-newsgroup-limit)
6401 thread (cadr thread))
6402 (when (gnus-invisible-cut-children (cdr thread))
6403 (let ((th (cdr thread)))
6405 (if (memq (mail-header-number (caar th))
6406 gnus-newsgroup-limit)
6407 (setq thread (car th)
6409 (setq th (cdr th))))))))))
6412 (defun gnus-cut-threads (threads)
6413 "Cut off all uninteresting articles from the beginning of threads."
6414 (when (or (eq gnus-fetch-old-headers 'some)
6415 (eq gnus-fetch-old-headers 'invisible)
6416 (eq gnus-build-sparse-threads 'some)
6417 (eq gnus-build-sparse-threads 'more))
6420 (setcar th (gnus-cut-thread (car th)))
6421 (setq th (cdr th)))))
6422 ;; Remove nixed out threads.
6425 (defun gnus-summary-initial-limit (&optional show-if-empty)
6426 "Figure out what the initial limit is supposed to be on group entry.
6427 This entails weeding out unwanted dormants, low-scored articles,
6428 fetch-old-headers verbiage, and so on."
6429 ;; Most groups have nothing to remove.
6430 (if (or gnus-inhibit-limiting
6431 (and (null gnus-newsgroup-dormant)
6432 (not (eq gnus-fetch-old-headers 'some))
6433 (not (eq gnus-fetch-old-headers 'invisible))
6434 (null gnus-summary-expunge-below)
6435 (not (eq gnus-build-sparse-threads 'some))
6436 (not (eq gnus-build-sparse-threads 'more))
6437 (null gnus-thread-expunge-below)
6438 (not gnus-use-nocem)))
6440 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6441 (setq gnus-newsgroup-limit nil)
6444 (unless (car (symbol-value node))
6445 ;; These threads have no parents -- they are roots.
6446 (let ((nodes (cdr (symbol-value node)))
6449 (if (and gnus-thread-expunge-below
6450 (< (gnus-thread-total-score (car nodes))
6451 gnus-thread-expunge-below))
6452 (gnus-expunge-thread (pop nodes))
6453 (setq thread (pop nodes))
6454 (gnus-summary-limit-children thread))))))
6455 gnus-newsgroup-dependencies)
6456 ;; If this limitation resulted in an empty group, we might
6457 ;; pop the previous limit and use it instead.
6458 (when (and (not gnus-newsgroup-limit)
6460 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6461 gnus-newsgroup-limit))
6463 (defun gnus-summary-limit-children (thread)
6464 "Return 1 if this subthread is visible and 0 if it is not."
6465 ;; First we get the number of visible children to this thread. This
6466 ;; is done by recursing down the thread using this function, so this
6467 ;; will really go down to a leaf article first, before slowly
6468 ;; working its way up towards the root.
6472 (apply '+ (mapcar 'gnus-summary-limit-children
6475 (number (mail-header-number (car thread)))
6478 (not (memq number gnus-newsgroup-marked))
6480 ;; If this article is dormant and has absolutely no visible
6481 ;; children, then this article isn't visible.
6482 (and (memq number gnus-newsgroup-dormant)
6484 ;; If this is "fetch-old-headered" and there is no
6485 ;; visible children, then we don't want this article.
6486 (and (eq gnus-fetch-old-headers 'some)
6487 (gnus-summary-article-ancient-p number)
6489 ;; If this is "fetch-old-headered" and `invisible', then
6490 ;; we don't want this article.
6491 (and (eq gnus-fetch-old-headers 'invisible)
6492 (gnus-summary-article-ancient-p number))
6493 ;; If this is a sparsely inserted article with no children,
6494 ;; we don't want it.
6495 (and (eq gnus-build-sparse-threads 'some)
6496 (gnus-summary-article-sparse-p number)
6498 ;; If we use expunging, and this article is really
6499 ;; low-scored, then we don't want this article.
6500 (when (and gnus-summary-expunge-below
6502 (or (cdr (assq number gnus-newsgroup-scored))
6503 gnus-summary-default-score))
6504 gnus-summary-expunge-below))
6505 ;; We increase the expunge-tally here, but that has
6506 ;; nothing to do with the limits, really.
6507 (incf gnus-newsgroup-expunged-tally)
6508 ;; We also mark as read here, if that's wanted.
6509 (when (and gnus-summary-mark-below
6510 (< score gnus-summary-mark-below))
6511 (setq gnus-newsgroup-unreads
6512 (delq number gnus-newsgroup-unreads))
6513 (if gnus-newsgroup-auto-expire
6514 (push number gnus-newsgroup-expirable)
6515 (push (cons number gnus-low-score-mark)
6516 gnus-newsgroup-reads)))
6518 ;; Check NoCeM things.
6519 (if (and gnus-use-nocem
6520 (gnus-nocem-unwanted-article-p
6521 (mail-header-id (car thread))))
6523 (setq gnus-newsgroup-unreads
6524 (delq number gnus-newsgroup-unreads))
6526 ;; Nope, invisible article.
6528 ;; Ok, this article is to be visible, so we add it to the limit
6530 (push number gnus-newsgroup-limit)
6533 (defun gnus-expunge-thread (thread)
6534 "Mark all articles in THREAD as read."
6535 (let* ((number (mail-header-number (car thread))))
6536 (incf gnus-newsgroup-expunged-tally)
6537 ;; We also mark as read here, if that's wanted.
6538 (setq gnus-newsgroup-unreads
6539 (delq number gnus-newsgroup-unreads))
6540 (if gnus-newsgroup-auto-expire
6541 (push number gnus-newsgroup-expirable)
6542 (push (cons number gnus-low-score-mark)
6543 gnus-newsgroup-reads)))
6544 ;; Go recursively through all subthreads.
6545 (mapcar 'gnus-expunge-thread (cdr thread)))
6547 ;; Summary article oriented commands
6549 (defun gnus-summary-refer-parent-article (n)
6550 "Refer parent article N times.
6551 If N is negative, go to ancestor -N instead.
6552 The difference between N and the number of articles fetched is returned."
6556 (when (not (natnump n))
6561 (setq header (gnus-summary-article-header))
6562 (if (and (eq (mail-header-number header)
6563 (cdr gnus-article-current))
6564 (equal gnus-newsgroup-name
6565 (car gnus-article-current)))
6566 ;; If we try to find the parent of the currently
6567 ;; displayed article, then we take a look at the actual
6568 ;; References header, since this is slightly more
6569 ;; reliable than the References field we got from the
6572 (set-buffer gnus-original-article-buffer)
6573 (nnheader-narrow-to-headers)
6574 (unless (setq ref (message-fetch-field "references"))
6575 (setq ref (message-fetch-field "in-reply-to")))
6578 ;; It's not the current article, so we take a bet on
6579 ;; the value we got from the server.
6580 (mail-header-references header)))
6582 (not (equal ref "")))
6583 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6584 (gnus-message 1 "Couldn't find parent"))
6585 (gnus-message 1 "No references in article %d"
6586 (gnus-summary-article-number))
6589 (gnus-summary-position-point)
6592 (defun gnus-summary-refer-references ()
6593 "Fetch all articles mentioned in the References header.
6594 Return the number of articles fetched."
6596 (let ((ref (mail-header-references (gnus-summary-article-header)))
6597 (current (gnus-summary-article-number))
6601 (error "No References in the current article")
6602 ;; For each Message-ID in the References header...
6603 (while (string-match "<[^>]*>" ref)
6605 ;; ... fetch that article.
6606 (gnus-summary-refer-article
6607 (prog1 (match-string 0 ref)
6608 (setq ref (substring ref (match-end 0))))))
6609 (gnus-summary-goto-subject current)
6610 (gnus-summary-position-point)
6613 (defun gnus-summary-refer-thread (&optional limit)
6614 "Fetch all articles in the current thread.
6615 If LIMIT (the numerical prefix), fetch that many old headers instead
6616 of what's specified by the `gnus-refer-thread-limit' variable."
6618 (let ((id (mail-header-id (gnus-summary-article-header)))
6619 (limit (if limit (prefix-numeric-value limit)
6620 gnus-refer-thread-limit)))
6621 ;; We want to fetch LIMIT *old* headers, but we also have to
6622 ;; re-fetch all the headers in the current buffer, because many of
6623 ;; them may be undisplayed. So we adjust LIMIT.
6624 (when (numberp limit)
6625 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6626 (unless (eq gnus-fetch-old-headers 'invisible)
6627 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6628 ;; Retrieve the headers and read them in.
6629 (if (eq (gnus-retrieve-headers
6630 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6632 (gnus-build-all-threads)
6633 (error "Can't fetch thread from backends that don't support NOV"))
6634 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6635 (gnus-summary-limit-include-thread id)))
6637 (defun gnus-summary-refer-article (message-id &optional arg)
6638 "Fetch an article specified by MESSAGE-ID.
6639 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6640 or `gnus-select-method', no matter what backend the article comes from."
6641 (interactive "sMessage-ID: \nP")
6642 (when (and (stringp message-id)
6643 (not (zerop (length message-id))))
6644 ;; Construct the correct Message-ID if necessary.
6645 ;; Suggested by tale@pawl.rpi.edu.
6646 (unless (string-match "^<" message-id)
6647 (setq message-id (concat "<" message-id)))
6648 (unless (string-match ">$" message-id)
6649 (setq message-id (concat message-id ">")))
6650 (let* ((header (gnus-id-to-header message-id))
6652 (gnus-summary-article-sparse-p
6653 (mail-header-number header))
6654 (memq (mail-header-number header)
6655 gnus-newsgroup-limit))))
6657 ;; If the article is present in the buffer we just go to it.
6659 (or (not (gnus-summary-article-sparse-p
6660 (mail-header-number header)))
6663 (gnus-summary-goto-article
6664 (mail-header-number header) nil t)
6666 (gnus-summary-update-article (mail-header-number header)))))
6668 ;; We fetch the article
6669 (let ((gnus-override-method
6670 (cond ((gnus-news-group-p gnus-newsgroup-name)
6671 gnus-refer-article-method)
6673 (or gnus-refer-article-method gnus-select-method))
6676 ;; Start the special refer-article method, if necessary.
6677 (when (and gnus-refer-article-method
6678 (gnus-news-group-p gnus-newsgroup-name))
6679 (gnus-check-server gnus-refer-article-method))
6680 ;; Fetch the header, and display the article.
6681 (if (setq number (gnus-summary-insert-subject message-id))
6682 (gnus-summary-select-article nil nil nil number)
6683 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6685 (defun gnus-summary-edit-parameters ()
6686 "Edit the group parameters of the current group."
6688 (gnus-group-edit-group gnus-newsgroup-name 'params))
6690 (defun gnus-summary-customize-parameters ()
6691 "Customize the group parameters of the current group."
6693 (gnus-group-customize gnus-newsgroup-name))
6695 (defun gnus-summary-enter-digest-group (&optional force)
6696 "Enter an nndoc group based on the current article.
6697 If FORCE, force a digest interpretation. If not, try
6698 to guess what the document format is."
6700 (let ((conf gnus-current-window-configuration))
6702 (gnus-summary-select-article))
6703 (setq gnus-current-window-configuration conf)
6704 (let* ((name (format "%s-%d"
6705 (gnus-group-prefixed-name
6706 gnus-newsgroup-name (list 'nndoc ""))
6708 (set-buffer gnus-summary-buffer)
6709 gnus-current-article)))
6710 (ogroup gnus-newsgroup-name)
6711 (params (append (gnus-info-params (gnus-get-info ogroup))
6712 (list (cons 'to-group ogroup))
6713 (list (cons 'save-article-group ogroup))))
6714 (case-fold-search t)
6715 (buf (current-buffer))
6718 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6719 (insert-buffer-substring gnus-original-article-buffer)
6720 ;; Remove lines that may lead nndoc to misinterpret the
6723 (goto-char (point-min))
6724 (or (search-forward "\n\n" nil t) (point)))
6725 (goto-char (point-min))
6726 (delete-matching-lines "^Path:\\|^From ")
6729 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6730 (gnus-newsgroup-ephemeral-ignored-charsets
6731 gnus-newsgroup-ignored-charsets))
6732 (gnus-group-read-ephemeral-group
6733 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6735 ,(if force 'digest 'guess))) t))
6736 ;; Make all postings to this group go to the parent group.
6737 (nconc (gnus-info-params (gnus-get-info name))
6739 ;; Couldn't select this doc group.
6740 (switch-to-buffer buf)
6741 (gnus-set-global-variables)
6742 (gnus-configure-windows 'summary)
6743 (gnus-message 3 "Article couldn't be entered?"))
6744 (kill-buffer dig)))))
6746 (defun gnus-summary-read-document (n)
6747 "Open a new group based on the current article(s).
6748 This will allow you to read digests and other similar
6749 documents as newsgroups.
6750 Obeys the standard process/prefix convention."
6752 (let* ((articles (gnus-summary-work-articles n))
6753 (ogroup gnus-newsgroup-name)
6754 (params (append (gnus-info-params (gnus-get-info ogroup))
6755 (list (cons 'to-group ogroup))))
6756 article group egroup groups vgroup)
6757 (while (setq article (pop articles))
6758 (setq group (format "%s-%d" gnus-newsgroup-name article))
6759 (gnus-summary-remove-process-mark article)
6760 (when (gnus-summary-display-article article)
6763 (insert-buffer-substring gnus-original-article-buffer)
6764 ;; Remove some headers that may lead nndoc to make
6766 (message-narrow-to-head)
6767 (goto-char (point-min))
6768 (delete-matching-lines "^\\(Path\\):\\|^From ")
6771 (gnus-group-read-ephemeral-group
6772 group `(nndoc ,group (nndoc-address ,(current-buffer))
6773 (nndoc-article-type guess))
6776 ;; Make all postings to this group go to the parent group.
6777 (nconc (gnus-info-params (gnus-get-info egroup))
6779 (push egroup groups))
6780 ;; Couldn't select this doc group.
6781 (gnus-error 3 "Article couldn't be entered"))))))
6782 ;; Now we have selected all the documents.
6785 (error "None of the articles could be interpreted as documents"))
6786 ((gnus-group-read-ephemeral-group
6787 (setq vgroup (format
6788 "nnvirtual:%s-%s" gnus-newsgroup-name
6789 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6790 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6792 (cons (current-buffer) 'summary)))
6794 (error "Couldn't select virtual nndoc group")))))
6796 (defun gnus-summary-isearch-article (&optional regexp-p)
6797 "Do incremental search forward on the current article.
6798 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6800 (gnus-summary-select-article)
6801 (gnus-configure-windows 'article)
6802 (gnus-eval-in-buffer-window gnus-article-buffer
6805 (isearch-forward regexp-p))))
6807 (defun gnus-summary-search-article-forward (regexp &optional backward)
6808 "Search for an article containing REGEXP forward.
6809 If BACKWARD, search backward instead."
6812 (format "Search article %s (regexp%s): "
6813 (if current-prefix-arg "backward" "forward")
6814 (if gnus-last-search-regexp
6815 (concat ", default " gnus-last-search-regexp)
6817 current-prefix-arg))
6818 (if (string-equal regexp "")
6819 (setq regexp (or gnus-last-search-regexp ""))
6820 (setq gnus-last-search-regexp regexp))
6821 (if (gnus-summary-search-article regexp backward)
6822 (gnus-summary-show-thread)
6823 (error "Search failed: \"%s\"" regexp)))
6825 (defun gnus-summary-search-article-backward (regexp)
6826 "Search for an article containing REGEXP backward."
6829 (format "Search article backward (regexp%s): "
6830 (if gnus-last-search-regexp
6831 (concat ", default " gnus-last-search-regexp)
6833 (gnus-summary-search-article-forward regexp 'backward))
6835 (defun gnus-summary-search-article (regexp &optional backward)
6836 "Search for an article containing REGEXP.
6837 Optional argument BACKWARD means do search for backward.
6838 `gnus-select-article-hook' is not called during the search."
6839 ;; We have to require this here to make sure that the following
6840 ;; dynamic binding isn't shadowed by autoloading.
6841 (require 'gnus-async)
6843 (let ((gnus-select-article-hook nil) ;Disable hook.
6844 (gnus-article-display-hook nil)
6845 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6846 (gnus-use-article-prefetch nil)
6847 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6848 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6849 (sum (current-buffer))
6852 (gnus-save-hidden-threads
6853 (gnus-summary-select-article)
6854 (set-buffer gnus-article-buffer)
6858 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6860 (re-search-backward regexp nil t)
6861 (re-search-forward regexp nil t))
6862 ;; We found the regexp.
6867 (get-buffer-window (current-buffer))
6871 (setq point (point)))
6872 ;; We didn't find it, so we go to the next article.
6875 (while (eq found 'not)
6876 (if (not (if backward (gnus-summary-find-prev)
6877 (gnus-summary-find-next)))
6878 ;; No more articles.
6880 ;; Select the next article and adjust point.
6881 (unless (gnus-summary-article-sparse-p
6882 (gnus-summary-article-number))
6884 (gnus-summary-select-article)
6885 (set-buffer gnus-article-buffer)
6887 (goto-char (if backward (point-max) (point-min))))))))
6888 (gnus-message 7 ""))
6889 ;; Return whether we found the regexp.
6890 (when (eq found 'found)
6892 (gnus-summary-show-thread)
6893 (gnus-summary-goto-subject gnus-current-article)
6894 (gnus-summary-position-point)
6897 (defun gnus-summary-find-matching (header regexp &optional backward unread
6899 "Return a list of all articles that match REGEXP on HEADER.
6900 The search stars on the current article and goes forwards unless
6901 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6902 If UNREAD is non-nil, only unread articles will
6903 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6904 in the comparisons."
6905 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6906 (gnus-data-find-list
6907 (gnus-summary-article-number) (gnus-data-list backward))))
6908 (case-fold-search (not not-case-fold))
6911 (if (eq (car header) 'extra)
6914 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
6916 (error "%s is an invalid header" header))
6917 (unless (fboundp (intern (concat "mail-header-" header)))
6918 (error "%s is not a valid header" header))
6919 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
6922 (and (or (not unread) ; We want all articles...
6923 (gnus-data-unread-p d)) ; Or just unreads.
6924 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6925 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6926 (push (gnus-data-number d) articles)) ; Success!
6927 (setq data (cdr data)))
6928 (nreverse articles)))
6930 (defun gnus-summary-execute-command (header regexp command &optional backward)
6931 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6932 If HEADER is an empty string (or nil), the match is done on the entire
6933 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6935 (list (let ((completion-ignore-case t))
6938 (mapcar (lambda (string) (list string))
6939 '("Number" "Subject" "From" "Lines" "Date"
6940 "Message-ID" "Xref" "References" "Body"))
6941 nil 'require-match))
6942 (read-string "Regexp: ")
6943 (read-key-sequence "Command: ")
6944 current-prefix-arg))
6945 (when (equal header "Body")
6947 ;; Hidden thread subtrees must be searched as well.
6948 (gnus-summary-show-all-threads)
6949 ;; We don't want to change current point nor window configuration.
6951 (save-window-excursion
6952 (gnus-message 6 "Executing %s..." (key-description command))
6953 ;; We'd like to execute COMMAND interactively so as to give arguments.
6954 (gnus-execute header regexp
6955 `(call-interactively ',(key-binding command))
6957 (gnus-message 6 "Executing %s...done" (key-description command)))))
6959 (defun gnus-summary-beginning-of-article ()
6960 "Scroll the article back to the beginning."
6962 (gnus-summary-select-article)
6963 (gnus-configure-windows 'article)
6964 (gnus-eval-in-buffer-window gnus-article-buffer
6966 (goto-char (point-min))
6967 (when gnus-page-broken
6968 (gnus-narrow-to-page))))
6970 (defun gnus-summary-end-of-article ()
6971 "Scroll to the end of the article."
6973 (gnus-summary-select-article)
6974 (gnus-configure-windows 'article)
6975 (gnus-eval-in-buffer-window gnus-article-buffer
6977 (goto-char (point-max))
6979 (when gnus-page-broken
6980 (gnus-narrow-to-page))))
6982 (defun gnus-summary-print-article (&optional filename n)
6983 "Generate and print a PostScript image of the N next (mail) articles.
6985 If N is negative, print the N previous articles. If N is nil and articles
6986 have been marked with the process mark, print these instead.
6988 If the optional first argument FILENAME is nil, send the image to the
6989 printer. If FILENAME is a string, save the PostScript image in a file with
6990 that name. If FILENAME is a number, prompt the user for the name of the file
6992 (interactive (list (ps-print-preprint current-prefix-arg)
6993 current-prefix-arg))
6994 (dolist (article (gnus-summary-work-articles n))
6995 (gnus-summary-select-article nil nil 'pseudo article)
6996 (gnus-eval-in-buffer-window gnus-article-buffer
6997 (let ((buffer (generate-new-buffer " *print*")))
7000 (copy-to-buffer buffer (point-min) (point-max))
7002 (gnus-article-delete-invisible-text)
7003 (let ((ps-left-header
7006 (mail-header-subject gnus-current-headers) ")")
7008 (mail-header-from gnus-current-headers) ")")))
7011 "/pagenumberstring load"
7013 (mail-header-date gnus-current-headers) ")"))))
7014 (gnus-run-hooks 'gnus-ps-print-hook)
7016 (ps-print-buffer-with-faces filename))))
7017 (kill-buffer buffer))))))
7019 (defun gnus-summary-show-article (&optional arg)
7020 "Force re-fetching of the current article.
7021 If ARG (the prefix) is non-nil, show the raw article without any
7022 article massaging functions being run."
7025 ;; Select the article the normal way.
7026 (gnus-summary-select-article nil 'force)
7027 ;; We have to require this here to make sure that the following
7028 ;; dynamic binding isn't shadowed by autoloading.
7029 (require 'gnus-async)
7031 ;; Bind the article treatment functions to nil.
7032 (let ((gnus-have-all-headers t)
7033 gnus-article-display-hook
7034 gnus-article-prepare-hook
7035 gnus-article-decode-hook
7039 (gnus-summary-select-article nil 'force)))
7040 (gnus-summary-goto-subject gnus-current-article)
7041 (gnus-summary-position-point))
7043 (defun gnus-summary-verbose-headers (&optional arg)
7044 "Toggle permanent full header display.
7045 If ARG is a positive number, turn header display on.
7046 If ARG is a negative number, turn header display off."
7048 (setq gnus-show-all-headers
7049 (cond ((or (not (numberp arg))
7051 (not gnus-show-all-headers))
7054 (gnus-summary-show-article))
7056 (defun gnus-summary-toggle-header (&optional arg)
7057 "Show the headers if they are hidden, or hide them if they are shown.
7058 If ARG is a positive number, show the entire header.
7059 If ARG is a negative number, hide the unwanted header lines."
7062 (set-buffer gnus-article-buffer)
7064 (let* ((buffer-read-only nil)
7065 (inhibit-point-motion-hooks t)
7068 (article-narrow-to-head)
7069 (setq hidden (gnus-article-hidden-text-p 'headers)))
7070 (goto-char (point-min))
7071 (when (search-forward "\n\n" nil t)
7072 (delete-region (point-min) (1- (point))))
7073 (goto-char (point-min))
7075 (set-buffer gnus-original-article-buffer)
7076 (goto-char (point-min))
7077 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7078 (insert-buffer-substring gnus-original-article-buffer 1 e)
7080 (narrow-to-region (point-min) (point))
7081 (article-decode-encoded-words)
7083 (and (numberp arg) (< arg 0)))
7084 (let ((gnus-treat-hide-headers nil)
7085 (gnus-treat-hide-boring-headers nil))
7086 (gnus-treat-article 'head))
7087 (gnus-treat-article 'head)))))))
7089 (defun gnus-summary-show-all-headers ()
7090 "Make all header lines visible."
7092 (gnus-article-show-all-headers))
7094 (defun gnus-summary-toggle-mime (&optional arg)
7095 "Toggle MIME processing.
7096 If ARG is a positive number, turn MIME processing on."
7098 (setq gnus-show-mime
7100 (not gnus-show-mime)
7101 (> (prefix-numeric-value arg) 0)))
7102 (gnus-summary-select-article t 'force))
7104 (defun gnus-summary-caesar-message (&optional arg)
7105 "Caesar rotate the current article by 13.
7106 The numerical prefix specifies how many places to rotate each letter
7109 (gnus-summary-select-article)
7110 (let ((mail-header-separator ""))
7111 (gnus-eval-in-buffer-window gnus-article-buffer
7114 (let ((start (window-start))
7116 (message-caesar-buffer-body arg)
7117 (set-window-start (get-buffer-window (current-buffer)) start))))))
7119 (defun gnus-summary-stop-page-breaking ()
7120 "Stop page breaking in the current article."
7122 (gnus-summary-select-article)
7123 (gnus-eval-in-buffer-window gnus-article-buffer
7125 (when (gnus-visual-p 'page-marker)
7126 (let ((buffer-read-only nil))
7127 (gnus-remove-text-with-property 'gnus-prev)
7128 (gnus-remove-text-with-property 'gnus-next))
7129 (setq gnus-page-broken nil))))
7131 (defun gnus-summary-move-article (&optional n to-newsgroup
7132 select-method action)
7133 "Move the current article to a different newsgroup.
7134 If N is a positive number, move the N next articles.
7135 If N is a negative number, move the N previous articles.
7136 If N is nil and any articles have been marked with the process mark,
7137 move those articles instead.
7138 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7139 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7140 re-spool using this method.
7142 For this function to work, both the current newsgroup and the
7143 newsgroup that you want to move to have to support the `request-move'
7144 and `request-accept' functions."
7147 (setq action 'move))
7148 ;; Disable marking as read.
7149 (let (gnus-mark-article-hook)
7150 (save-window-excursion
7151 (gnus-summary-select-article)))
7152 ;; Check whether the source group supports the required functions.
7153 (cond ((and (eq action 'move)
7154 (not (gnus-check-backend-function
7155 'request-move-article gnus-newsgroup-name)))
7156 (error "The current group does not support article moving"))
7157 ((and (eq action 'crosspost)
7158 (not (gnus-check-backend-function
7159 'request-replace-article gnus-newsgroup-name)))
7160 (error "The current group does not support article editing")))
7161 (let ((articles (gnus-summary-work-articles n))
7162 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7163 (names '((move "Move" "Moving")
7164 (copy "Copy" "Copying")
7165 (crosspost "Crosspost" "Crossposting")))
7166 (copy-buf (save-excursion
7167 (nnheader-set-temp-buffer " *copy article*")))
7168 (default-marks gnus-article-mark-lists)
7169 (no-expire-marks (delete '(expirable . expire)
7170 (copy-sequence gnus-article-mark-lists)))
7171 art-group to-method new-xref article to-groups)
7172 (unless (assq action names)
7173 (error "Unknown action %s" action))
7174 ;; Read the newsgroup name.
7175 (when (and (not to-newsgroup)
7176 (not select-method))
7178 (gnus-read-move-group-name
7179 (cadr (assq action names))
7180 (symbol-value (intern (format "gnus-current-%s-group" action)))
7182 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7183 (setq to-method (or select-method
7184 (gnus-group-name-to-method to-newsgroup)))
7185 ;; Check the method we are to move this article to...
7186 (unless (gnus-check-backend-function
7187 'request-accept-article (car to-method))
7188 (error "%s does not support article copying" (car to-method)))
7189 (unless (gnus-check-server to-method)
7190 (error "Can't open server %s" (car to-method)))
7191 (gnus-message 6 "%s to %s: %s..."
7192 (caddr (assq action names))
7193 (or (car select-method) to-newsgroup) articles)
7195 (setq article (pop articles))
7199 ;; Move the article.
7201 ;; Remove this article from future suppression.
7202 (gnus-dup-unsuppress-article article)
7203 (gnus-request-move-article
7204 article ; Article to move
7205 gnus-newsgroup-name ; From newsgroup
7206 (nth 1 (gnus-find-method-for-group
7207 gnus-newsgroup-name)) ; Server
7208 (list 'gnus-request-accept-article
7209 to-newsgroup (list 'quote select-method)
7210 (not articles) t) ; Accept form
7211 (not articles))) ; Only save nov last time
7212 ;; Copy the article.
7215 (set-buffer copy-buf)
7216 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7217 (gnus-request-accept-article
7218 to-newsgroup select-method (not articles) t))))
7219 ;; Crosspost the article.
7220 ((eq action 'crosspost)
7221 (let ((xref (message-tokenize-header
7222 (mail-header-xref (gnus-summary-article-header article))
7224 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7227 (setq xref (list (system-name))))
7230 (mapconcat 'identity
7231 (delete "Xref:" (delete new-xref xref))
7235 (set-buffer copy-buf)
7236 ;; First put the article in the destination group.
7237 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7238 (when (consp (setq art-group
7239 (gnus-request-accept-article
7240 to-newsgroup select-method (not articles))))
7241 (setq new-xref (concat new-xref " " (car art-group)
7242 ":" (cdr art-group)))
7243 ;; Now we have the new Xrefs header, so we insert
7244 ;; it and replace the new article.
7245 (nnheader-replace-header "Xref" new-xref)
7246 (gnus-request-replace-article
7247 (cdr art-group) to-newsgroup (current-buffer))
7251 (gnus-message 1 "Couldn't %s article %s"
7252 (cadr (assq action names)) article))
7253 ((and (eq art-group 'junk)
7255 (gnus-summary-mark-article article gnus-canceled-mark)
7256 (gnus-message 4 "Deleted article %s" article))
7258 (let* ((pto-group (gnus-group-prefixed-name
7259 (car art-group) to-method))
7261 (gnus-gethash pto-group gnus-newsrc-hashtb))
7262 (info (nth 2 entry))
7263 (to-group (gnus-info-group info))
7265 ;; Update the group that has been moved to.
7267 (memq action '(move copy)))
7268 (unless (member to-group to-groups)
7269 (push to-group to-groups))
7271 (unless (memq article gnus-newsgroup-unreads)
7272 (push 'read to-marks)
7274 info (gnus-add-to-range (gnus-info-read info)
7275 (list (cdr art-group)))))
7277 ;; Copy any marks over to the new group.
7278 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7281 (to-article (cdr art-group)))
7283 ;; See whether the article is to be put in the cache.
7284 (when gnus-use-cache
7285 (gnus-cache-possibly-enter-article
7287 (let ((header (copy-sequence
7288 (gnus-summary-article-header article))))
7289 (mail-header-set-number header to-article)
7291 (memq article gnus-newsgroup-marked)
7292 (memq article gnus-newsgroup-dormant)
7293 (memq article gnus-newsgroup-unreads)))
7295 (when (and (equal to-group gnus-newsgroup-name)
7296 (not (memq article gnus-newsgroup-unreads)))
7297 ;; Mark this article as read in this group.
7298 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7299 (setcdr (gnus-active to-group) to-article)
7300 (setcdr gnus-newsgroup-active to-article))
7303 (when (memq article (symbol-value
7304 (intern (format "gnus-newsgroup-%s"
7306 (push (cdar marks) to-marks)
7307 ;; If the other group is the same as this group,
7308 ;; then we have to add the mark to the list.
7309 (when (equal to-group gnus-newsgroup-name)
7310 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7313 (intern (format "gnus-newsgroup-%s"
7315 ;; Copy the marks to other group.
7316 (gnus-add-marked-articles
7317 to-group (cdar marks) (list to-article) info))
7318 (setq marks (cdr marks)))
7320 (gnus-request-set-mark to-group (list (list (list to-article)
7325 (concat "(gnus-group-set-info '"
7326 (gnus-prin1-to-string (gnus-get-info to-group))
7329 ;; Update the Xref header in this article to point to
7330 ;; the new crossposted article we have just created.
7331 (when (eq action 'crosspost)
7333 (set-buffer copy-buf)
7334 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7335 (nnheader-replace-header "Xref" new-xref)
7336 (gnus-request-replace-article
7337 article gnus-newsgroup-name (current-buffer)))))
7339 ;;;!!!Why is this necessary?
7340 (set-buffer gnus-summary-buffer)
7342 (gnus-summary-goto-subject article)
7343 (when (eq action 'move)
7344 (gnus-summary-mark-article article gnus-canceled-mark))))
7345 (gnus-summary-remove-process-mark article))
7346 ;; Re-activate all groups that have been moved to.
7349 (set-buffer gnus-group-buffer)
7350 (when (gnus-group-goto-group (car to-groups) t)
7351 (gnus-group-get-new-news-this-group 1 t))
7354 (gnus-kill-buffer copy-buf)
7355 (gnus-summary-position-point)
7356 (gnus-set-mode-line 'summary)))
7358 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7359 "Move the current article to a different newsgroup.
7360 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7361 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7362 re-spool using this method."
7364 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7366 (defun gnus-summary-crosspost-article (&optional n)
7367 "Crosspost the current article to some other group."
7369 (gnus-summary-move-article n nil nil 'crosspost))
7371 (defcustom gnus-summary-respool-default-method nil
7372 "Default method for respooling an article.
7373 If nil, use to the current newsgroup method."
7374 :type '(choice (gnus-select-method :value (nnml ""))
7376 :group 'gnus-summary-mail)
7378 (defun gnus-summary-respool-article (&optional n method)
7379 "Respool the current article.
7380 The article will be squeezed through the mail spooling process again,
7381 which means that it will be put in some mail newsgroup or other
7382 depending on `nnmail-split-methods'.
7383 If N is a positive number, respool the N next articles.
7384 If N is a negative number, respool the N previous articles.
7385 If N is nil and any articles have been marked with the process mark,
7386 respool those articles instead.
7388 Respooling can be done both from mail groups and \"real\" newsgroups.
7389 In the former case, the articles in question will be moved from the
7390 current group into whatever groups they are destined to. In the
7391 latter case, they will be copied into the relevant groups."
7393 (list current-prefix-arg
7394 (let* ((methods (gnus-methods-using 'respool))
7396 (symbol-name (or gnus-summary-respool-default-method
7397 (car (gnus-find-method-for-group
7398 gnus-newsgroup-name)))))
7400 (gnus-completing-read
7401 methname "What backend do you want to use when respooling?"
7402 methods nil t nil 'gnus-mail-method-history))
7405 ((zerop (length (setq ms (gnus-servers-using-backend
7407 (list (intern method) ""))
7411 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7412 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7415 (error "No method given for respooling"))
7416 (if (assoc (symbol-name
7417 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7418 (gnus-methods-using 'respool))
7419 (gnus-summary-move-article n nil method)
7420 (gnus-summary-copy-article n nil method)))
7422 (defun gnus-summary-import-article (file)
7423 "Import an arbitrary file into a mail newsgroup."
7424 (interactive "fImport file: ")
7425 (let ((group gnus-newsgroup-name)
7426 (now (current-time))
7428 (unless (gnus-check-backend-function 'request-accept-article group)
7429 (error "%s does not support article importing" group))
7430 (or (file-readable-p file)
7431 (not (file-regular-p file))
7432 (error "Can't read %s" file))
7434 (set-buffer (gnus-get-buffer-create " *import file*"))
7436 (nnheader-insert-file-contents file)
7437 (goto-char (point-min))
7438 (unless (nnheader-article-p)
7439 ;; This doesn't look like an article, so we fudge some headers.
7440 (setq atts (file-attributes file)
7441 lines (count-lines (point-min) (point-max)))
7442 (insert "From: " (read-string "From: ") "\n"
7443 "Subject: " (read-string "Subject: ") "\n"
7444 "Date: " (message-make-date (nth 5 atts))
7446 "Message-ID: " (message-make-message-id) "\n"
7447 "Lines: " (int-to-string lines) "\n"
7448 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7449 (gnus-request-accept-article group nil t)
7450 (kill-buffer (current-buffer)))))
7452 (defun gnus-summary-article-posted-p ()
7453 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7454 This will be the case if the article has both been mailed and posted."
7456 (let ((id (mail-header-references (gnus-summary-article-header)))
7457 (gnus-override-method
7458 (or gnus-refer-article-method gnus-select-method)))
7459 (if (gnus-request-head id "")
7460 (gnus-message 2 "The current message was found on %s"
7461 gnus-override-method)
7462 (gnus-message 2 "The current message couldn't be found on %s"
7463 gnus-override-method)
7466 (defun gnus-summary-expire-articles (&optional now)
7467 "Expire all articles that are marked as expirable in the current group."
7469 (when (gnus-check-backend-function
7470 'request-expire-articles gnus-newsgroup-name)
7471 ;; This backend supports expiry.
7472 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7473 (expirable (if total
7475 ;; We need to update the info for
7476 ;; this group for `gnus-list-of-read-articles'
7477 ;; to give us the right answer.
7478 (gnus-run-hooks 'gnus-exit-group-hook)
7479 (gnus-summary-update-info)
7480 (gnus-list-of-read-articles gnus-newsgroup-name))
7481 (setq gnus-newsgroup-expirable
7482 (sort gnus-newsgroup-expirable '<))))
7483 (expiry-wait (if now 'immediate
7484 (gnus-group-find-parameter
7485 gnus-newsgroup-name 'expiry-wait)))
7488 ;; There are expirable articles in this group, so we run them
7489 ;; through the expiry process.
7490 (gnus-message 6 "Expiring articles...")
7491 (unless (gnus-check-group gnus-newsgroup-name)
7492 (error "Can't open server for %s" gnus-newsgroup-name))
7493 ;; The list of articles that weren't expired is returned.
7496 (let ((nnmail-expiry-wait-function nil)
7497 (nnmail-expiry-wait expiry-wait))
7498 (setq es (gnus-request-expire-articles
7499 expirable gnus-newsgroup-name)))
7500 (setq es (gnus-request-expire-articles
7501 expirable gnus-newsgroup-name))))
7503 (setq gnus-newsgroup-expirable es))
7504 ;; We go through the old list of expirable, and mark all
7505 ;; really expired articles as nonexistent.
7506 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7507 (let ((gnus-use-cache nil))
7509 (unless (memq (car expirable) es)
7510 (when (gnus-data-find (car expirable))
7511 (gnus-summary-mark-article
7512 (car expirable) gnus-canceled-mark)))
7513 (setq expirable (cdr expirable)))))
7514 (gnus-message 6 "Expiring articles...done")))))
7516 (defun gnus-summary-expire-articles-now ()
7517 "Expunge all expirable articles in the current group.
7518 This means that *all* articles that are marked as expirable will be
7519 deleted forever, right now."
7521 (or gnus-expert-user
7523 "Are you really, really, really sure you want to delete all these messages? ")
7525 (gnus-summary-expire-articles t))
7527 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7528 (defun gnus-summary-delete-article (&optional n)
7529 "Delete the N next (mail) articles.
7530 This command actually deletes articles. This is not a marking
7531 command. The article will disappear forever from your life, never to
7533 If N is negative, delete backwards.
7534 If N is nil and articles have been marked with the process mark,
7535 delete these instead."
7537 (unless (gnus-check-backend-function 'request-expire-articles
7538 gnus-newsgroup-name)
7539 (error "The current newsgroup does not support article deletion"))
7540 ;; Compute the list of articles to delete.
7541 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7543 (if (and gnus-novice-user
7544 (not (gnus-yes-or-no-p
7545 (format "Do you really want to delete %s forever? "
7546 (if (> (length articles) 1)
7547 (format "these %s articles" (length articles))
7550 ;; Delete the articles.
7551 (setq not-deleted (gnus-request-expire-articles
7552 articles gnus-newsgroup-name 'force))
7554 (gnus-summary-remove-process-mark (car articles))
7555 ;; The backend might not have been able to delete the article
7557 (unless (memq (car articles) not-deleted)
7558 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7559 (setq articles (cdr articles)))
7561 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7562 (gnus-summary-position-point)
7563 (gnus-set-mode-line 'summary)
7566 (defun gnus-summary-edit-article (&optional force)
7567 "Edit the current article.
7568 This will have permanent effect only in mail groups.
7569 If FORCE is non-nil, allow editing of articles even in read-only
7573 (set-buffer gnus-summary-buffer)
7574 (let ((mail-parse-charset gnus-newsgroup-charset)
7575 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7576 (gnus-set-global-variables)
7577 (when (and (not force)
7578 (gnus-group-read-only-p))
7579 (error "The current newsgroup does not support article editing"))
7580 (gnus-summary-show-article t)
7581 (gnus-article-edit-article
7583 `(lambda (no-highlight)
7584 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7585 (mail-parse-ignored-charsets
7586 ',gnus-newsgroup-ignored-charsets))
7587 (gnus-summary-edit-article-done
7588 ,(or (mail-header-references gnus-current-headers) "")
7589 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7591 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7593 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7595 "Make edits to the current article permanent."
7597 ;; Replace the article.
7598 (let ((buf (current-buffer)))
7600 (insert-buffer-substring buf)
7601 (if (and (not read-only)
7602 (not (gnus-request-replace-article
7603 (cdr gnus-article-current) (car gnus-article-current)
7604 (current-buffer) t)))
7605 (error "Couldn't replace article")
7606 ;; Update the summary buffer.
7608 (equal (message-tokenize-header references " ")
7609 (message-tokenize-header
7610 (or (message-fetch-field "references") "") " ")))
7611 ;; We only have to update this line.
7614 (message-narrow-to-head)
7615 (let ((head (buffer-string))
7618 (insert (format "211 %d Article retrieved.\n"
7619 (cdr gnus-article-current)))
7622 (let ((nntp-server-buffer (current-buffer)))
7623 (setq header (car (gnus-get-newsgroup-headers
7625 (set-buffer gnus-summary-buffer)
7626 gnus-newsgroup-dependencies)
7629 (set-buffer gnus-summary-buffer)
7630 (gnus-data-set-header
7631 (gnus-data-find (cdr gnus-article-current))
7633 (gnus-summary-update-article-line
7634 (cdr gnus-article-current) header))))))
7636 (set-buffer (or buffer gnus-summary-buffer))
7637 (gnus-summary-update-article (cdr gnus-article-current)))
7638 ;; Prettify the article buffer again.
7639 (unless no-highlight
7641 (set-buffer gnus-article-buffer)
7642 ;;;!!! Fix this -- article should be rehighlighted.
7643 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7644 (set-buffer gnus-original-article-buffer)
7645 (gnus-request-article
7646 (cdr gnus-article-current)
7647 (car gnus-article-current) (current-buffer))))
7648 ;; Prettify the summary buffer line.
7649 (when (gnus-visual-p 'summary-highlight 'highlight)
7650 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7652 (defun gnus-summary-edit-wash (key)
7653 "Perform editing command KEY in the article buffer."
7657 (message "%s" (concat (this-command-keys) "- "))
7660 (gnus-summary-edit-article)
7661 (execute-kbd-macro (concat (this-command-keys) key))
7662 (gnus-article-edit-done))
7666 (defun gnus-summary-respool-query (&optional silent trace)
7667 "Query where the respool algorithm would put this article."
7669 (let (gnus-mark-article-hook)
7670 (gnus-summary-select-article)
7672 (set-buffer gnus-original-article-buffer)
7674 (message-narrow-to-head)
7675 (let ((groups (nnmail-article-group 'identity trace)))
7678 (message "This message would go to %s"
7679 (mapconcat 'car groups ", "))
7680 (message "This message would go to no groups"))
7683 (defun gnus-summary-respool-trace ()
7684 "Trace where the respool algorithm would put this article.
7685 Display a buffer showing all fancy splitting patterns which matched."
7687 (gnus-summary-respool-query nil t))
7689 ;; Summary marking commands.
7691 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7692 "Mark articles which has the same subject as read, and then select the next.
7693 If UNMARK is positive, remove any kind of mark.
7694 If UNMARK is negative, tick articles."
7697 (setq unmark (prefix-numeric-value unmark)))
7699 (gnus-summary-mark-same-subject
7700 (gnus-summary-article-subject) unmark)))
7701 ;; Select next unread article. If auto-select-same mode, should
7702 ;; select the first unread article.
7703 (gnus-summary-next-article t (and gnus-auto-select-same
7704 (gnus-summary-article-subject)))
7705 (gnus-message 7 "%d article%s marked as %s"
7706 count (if (= count 1) " is" "s are")
7707 (if unmark "unread" "read"))))
7709 (defun gnus-summary-kill-same-subject (&optional unmark)
7710 "Mark articles which has the same subject as read.
7711 If UNMARK is positive, remove any kind of mark.
7712 If UNMARK is negative, tick articles."
7715 (setq unmark (prefix-numeric-value unmark)))
7717 (gnus-summary-mark-same-subject
7718 (gnus-summary-article-subject) unmark)))
7719 ;; If marked as read, go to next unread subject.
7721 ;; Go to next unread subject.
7722 (gnus-summary-next-subject 1 t))
7723 (gnus-message 7 "%d articles are marked as %s"
7724 count (if unmark "unread" "read"))))
7726 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7727 "Mark articles with same SUBJECT as read, and return marked number.
7728 If optional argument UNMARK is positive, remove any kinds of marks.
7729 If optional argument UNMARK is negative, mark articles as unread instead."
7733 ((null unmark) ; Mark as read.
7736 (gnus-summary-mark-article-as-read gnus-killed-mark)
7737 (gnus-summary-show-thread) t)
7738 (gnus-summary-find-subject subject))
7739 (setq count (1+ count))))
7740 ((> unmark 0) ; Tick.
7743 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7744 (gnus-summary-show-thread) t)
7745 (gnus-summary-find-subject subject))
7746 (setq count (1+ count))))
7747 (t ; Mark as unread.
7750 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7751 (gnus-summary-show-thread) t)
7752 (gnus-summary-find-subject subject))
7753 (setq count (1+ count)))))
7754 (gnus-set-mode-line 'summary)
7755 ;; Return the number of marked articles.
7758 (defun gnus-summary-mark-as-processable (n &optional unmark)
7759 "Set the process mark on the next N articles.
7760 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7761 the process mark instead. The difference between N and the actual
7762 number of articles marked is returned."
7764 (let ((backward (< n 0))
7769 (gnus-summary-remove-process-mark
7770 (gnus-summary-article-number))
7771 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7772 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7775 (gnus-message 7 "No more articles"))
7776 (gnus-summary-recenter)
7777 (gnus-summary-position-point)
7780 (defun gnus-summary-unmark-as-processable (n)
7781 "Remove the process mark from the next N articles.
7782 If N is negative, unmark backward instead. The difference between N and
7783 the actual number of articles unmarked is returned."
7785 (gnus-summary-mark-as-processable n t))
7787 (defun gnus-summary-unmark-all-processable ()
7788 "Remove the process mark from all articles."
7791 (while gnus-newsgroup-processable
7792 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7793 (gnus-summary-position-point))
7795 (defun gnus-summary-mark-as-expirable (n)
7796 "Mark N articles forward as expirable.
7797 If N is negative, mark backward instead. The difference between N and
7798 the actual number of articles marked is returned."
7800 (gnus-summary-mark-forward n gnus-expirable-mark))
7802 (defun gnus-summary-mark-article-as-replied (article)
7803 "Mark ARTICLE replied and update the summary line."
7804 (push article gnus-newsgroup-replied)
7805 (let ((buffer-read-only nil))
7806 (when (gnus-summary-goto-subject article nil t)
7807 (gnus-summary-update-secondary-mark article))))
7809 (defun gnus-summary-set-bookmark (article)
7810 "Set a bookmark in current article."
7811 (interactive (list (gnus-summary-article-number)))
7812 (when (or (not (get-buffer gnus-article-buffer))
7813 (not gnus-current-article)
7814 (not gnus-article-current)
7815 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7816 (error "No current article selected"))
7817 ;; Remove old bookmark, if one exists.
7818 (let ((old (assq article gnus-newsgroup-bookmarks)))
7820 (setq gnus-newsgroup-bookmarks
7821 (delq old gnus-newsgroup-bookmarks))))
7822 ;; Set the new bookmark, which is on the form
7823 ;; (article-number . line-number-in-body).
7827 (set-buffer gnus-article-buffer)
7831 (goto-char (point-min))
7832 (search-forward "\n\n" nil t)
7835 gnus-newsgroup-bookmarks)
7836 (gnus-message 6 "A bookmark has been added to the current article."))
7838 (defun gnus-summary-remove-bookmark (article)
7839 "Remove the bookmark from the current article."
7840 (interactive (list (gnus-summary-article-number)))
7841 ;; Remove old bookmark, if one exists.
7842 (let ((old (assq article gnus-newsgroup-bookmarks)))
7845 (setq gnus-newsgroup-bookmarks
7846 (delq old gnus-newsgroup-bookmarks))
7847 (gnus-message 6 "Removed bookmark."))
7848 (gnus-message 6 "No bookmark in current article."))))
7850 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7851 (defun gnus-summary-mark-as-dormant (n)
7852 "Mark N articles forward as dormant.
7853 If N is negative, mark backward instead. The difference between N and
7854 the actual number of articles marked is returned."
7856 (gnus-summary-mark-forward n gnus-dormant-mark))
7858 (defun gnus-summary-set-process-mark (article)
7859 "Set the process mark on ARTICLE and update the summary line."
7860 (setq gnus-newsgroup-processable
7862 (delq article gnus-newsgroup-processable)))
7863 (when (gnus-summary-goto-subject article)
7864 (gnus-summary-show-thread)
7865 (gnus-summary-goto-subject article)
7866 (gnus-summary-update-secondary-mark article)))
7868 (defun gnus-summary-remove-process-mark (article)
7869 "Remove the process mark from ARTICLE and update the summary line."
7870 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7871 (when (gnus-summary-goto-subject article)
7872 (gnus-summary-show-thread)
7873 (gnus-summary-goto-subject article)
7874 (gnus-summary-update-secondary-mark article)))
7876 (defun gnus-summary-set-saved-mark (article)
7877 "Set the process mark on ARTICLE and update the summary line."
7878 (push article gnus-newsgroup-saved)
7879 (when (gnus-summary-goto-subject article)
7880 (gnus-summary-update-secondary-mark article)))
7882 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7883 "Mark N articles as read forwards.
7884 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7885 The difference between N and the actual number of articles marked is
7888 (gnus-summary-show-thread)
7889 (let ((backward (< n 0))
7890 (gnus-summary-goto-unread
7891 (and gnus-summary-goto-unread
7892 (not (eq gnus-summary-goto-unread 'never))
7893 (not (memq mark (list gnus-unread-mark
7894 gnus-ticked-mark gnus-dormant-mark)))))
7896 (mark (or mark gnus-del-mark)))
7898 (gnus-summary-mark-article nil mark no-expire)
7899 (zerop (gnus-summary-next-subject
7901 (and gnus-summary-goto-unread
7902 (not (eq gnus-summary-goto-unread 'never)))
7906 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7907 (gnus-summary-recenter)
7908 (gnus-summary-position-point)
7909 (gnus-set-mode-line 'summary)
7912 (defun gnus-summary-mark-article-as-read (mark)
7913 "Mark the current article quickly as read with MARK."
7914 (let ((article (gnus-summary-article-number)))
7915 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7916 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7917 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7918 (push (cons article mark) gnus-newsgroup-reads)
7919 ;; Possibly remove from cache, if that is used.
7920 (when gnus-use-cache
7921 (gnus-cache-enter-remove-article article))
7922 ;; Allow the backend to change the mark.
7923 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7924 ;; Check for auto-expiry.
7925 (when (and gnus-newsgroup-auto-expire
7926 (memq mark gnus-auto-expirable-marks))
7927 (setq mark gnus-expirable-mark)
7928 ;; Let the backend know about the mark change.
7929 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7930 (push article gnus-newsgroup-expirable))
7931 ;; Set the mark in the buffer.
7932 (gnus-summary-update-mark mark 'unread)
7935 (defun gnus-summary-mark-article-as-unread (mark)
7936 "Mark the current article quickly as unread with MARK."
7937 (let* ((article (gnus-summary-article-number))
7938 (old-mark (gnus-summary-article-mark article)))
7939 ;; Allow the backend to change the mark.
7940 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7941 (if (eq mark old-mark)
7945 (gnus-error 1 "Can't mark negative article numbers")
7947 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7948 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7949 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7950 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7951 (cond ((= mark gnus-ticked-mark)
7952 (push article gnus-newsgroup-marked))
7953 ((= mark gnus-dormant-mark)
7954 (push article gnus-newsgroup-dormant))
7956 (push article gnus-newsgroup-unreads)))
7957 (gnus-pull article gnus-newsgroup-reads)
7959 ;; See whether the article is to be put in the cache.
7961 (vectorp (gnus-summary-article-header article))
7963 (gnus-cache-possibly-enter-article
7964 gnus-newsgroup-name article
7965 (gnus-summary-article-header article)
7966 (= mark gnus-ticked-mark)
7967 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7970 (gnus-summary-update-mark mark 'unread)
7973 (defun gnus-summary-mark-article (&optional article mark no-expire)
7974 "Mark ARTICLE with MARK. MARK can be any character.
7975 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7976 `??' (dormant) and `?E' (expirable).
7977 If MARK is nil, then the default character `?r' is used.
7978 If ARTICLE is nil, then the article on the current line will be
7980 ;; The mark might be a string.
7981 (when (stringp mark)
7982 (setq mark (aref mark 0)))
7983 ;; If no mark is given, then we check auto-expiring.
7985 (setq mark gnus-del-mark))
7986 (when (and (not no-expire)
7987 gnus-newsgroup-auto-expire
7988 (memq mark gnus-auto-expirable-marks))
7989 (setq mark gnus-expirable-mark))
7990 (let ((article (or article (gnus-summary-article-number)))
7991 (old-mark (gnus-summary-article-mark article)))
7992 ;; Allow the backend to change the mark.
7993 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7994 (if (eq mark old-mark)
7997 (error "No article on current line"))
7998 (if (not (if (or (= mark gnus-unread-mark)
7999 (= mark gnus-ticked-mark)
8000 (= mark gnus-dormant-mark))
8001 (gnus-mark-article-as-unread article mark)
8002 (gnus-mark-article-as-read article mark)))
8004 ;; See whether the article is to be put in the cache.
8006 (not (= mark gnus-canceled-mark))
8007 (vectorp (gnus-summary-article-header article))
8009 (gnus-cache-possibly-enter-article
8010 gnus-newsgroup-name article
8011 (gnus-summary-article-header article)
8012 (= mark gnus-ticked-mark)
8013 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8015 (when (gnus-summary-goto-subject article nil t)
8016 (let ((buffer-read-only nil))
8017 (gnus-summary-show-thread)
8019 (gnus-summary-update-mark mark 'unread)
8022 (defun gnus-summary-update-secondary-mark (article)
8023 "Update the secondary (read, process, cache) mark."
8024 (gnus-summary-update-mark
8025 (cond ((memq article gnus-newsgroup-processable)
8027 ((memq article gnus-newsgroup-cached)
8029 ((memq article gnus-newsgroup-replied)
8031 ((memq article gnus-newsgroup-saved)
8033 (t gnus-unread-mark))
8035 (when (gnus-visual-p 'summary-highlight 'highlight)
8036 (gnus-run-hooks 'gnus-summary-update-hook))
8039 (defun gnus-summary-update-mark (mark type)
8040 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8041 (buffer-read-only nil))
8042 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8044 (when (looking-at "\r")
8046 (when (<= (+ forward (point)) (point-max))
8047 ;; Go to the right position on the line.
8048 (goto-char (+ forward (point)))
8049 ;; Replace the old mark with the new mark.
8050 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8051 ;; Optionally update the marks by some user rule.
8052 (when (eq type 'unread)
8054 (gnus-data-find (gnus-summary-article-number)) mark)
8055 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8057 (defun gnus-mark-article-as-read (article &optional mark)
8058 "Enter ARTICLE in the pertinent lists and remove it from others."
8059 ;; Make the article expirable.
8060 (let ((mark (or mark gnus-del-mark)))
8061 (if (= mark gnus-expirable-mark)
8062 (push article gnus-newsgroup-expirable)
8063 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8064 ;; Remove from unread and marked lists.
8065 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8066 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8067 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8068 (push (cons article mark) gnus-newsgroup-reads)
8069 ;; Possibly remove from cache, if that is used.
8070 (when gnus-use-cache
8071 (gnus-cache-enter-remove-article article))
8074 (defun gnus-mark-article-as-unread (article &optional mark)
8075 "Enter ARTICLE in the pertinent lists and remove it from others."
8076 (let ((mark (or mark gnus-ticked-mark)))
8079 (gnus-error 1 "Can't mark negative article numbers")
8081 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8082 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8083 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8084 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8086 ;; Unsuppress duplicates?
8087 (when gnus-suppress-duplicates
8088 (gnus-dup-unsuppress-article article))
8090 (cond ((= mark gnus-ticked-mark)
8091 (push article gnus-newsgroup-marked))
8092 ((= mark gnus-dormant-mark)
8093 (push article gnus-newsgroup-dormant))
8095 (push article gnus-newsgroup-unreads)))
8096 (gnus-pull article gnus-newsgroup-reads)
8099 (defalias 'gnus-summary-mark-as-unread-forward
8100 'gnus-summary-tick-article-forward)
8101 (make-obsolete 'gnus-summary-mark-as-unread-forward
8102 'gnus-summary-tick-article-forward)
8103 (defun gnus-summary-tick-article-forward (n)
8104 "Tick N articles forwards.
8105 If N is negative, tick backwards instead.
8106 The difference between N and the number of articles ticked is returned."
8108 (gnus-summary-mark-forward n gnus-ticked-mark))
8110 (defalias 'gnus-summary-mark-as-unread-backward
8111 'gnus-summary-tick-article-backward)
8112 (make-obsolete 'gnus-summary-mark-as-unread-backward
8113 'gnus-summary-tick-article-backward)
8114 (defun gnus-summary-tick-article-backward (n)
8115 "Tick N articles backwards.
8116 The difference between N and the number of articles ticked is returned."
8118 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8120 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8121 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8122 (defun gnus-summary-tick-article (&optional article clear-mark)
8123 "Mark current article as unread.
8124 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8125 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8127 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8130 (defun gnus-summary-mark-as-read-forward (n)
8131 "Mark N articles as read forwards.
8132 If N is negative, mark backwards instead.
8133 The difference between N and the actual number of articles marked is
8136 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8138 (defun gnus-summary-mark-as-read-backward (n)
8139 "Mark the N articles as read backwards.
8140 The difference between N and the actual number of articles marked is
8143 (gnus-summary-mark-forward
8144 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8146 (defun gnus-summary-mark-as-read (&optional article mark)
8147 "Mark current article as read.
8148 ARTICLE specifies the article to be marked as read.
8149 MARK specifies a string to be inserted at the beginning of the line."
8150 (gnus-summary-mark-article article mark))
8152 (defun gnus-summary-clear-mark-forward (n)
8153 "Clear marks from N articles forward.
8154 If N is negative, clear backward instead.
8155 The difference between N and the number of marks cleared is returned."
8157 (gnus-summary-mark-forward n gnus-unread-mark))
8159 (defun gnus-summary-clear-mark-backward (n)
8160 "Clear marks from N articles backward.
8161 The difference between N and the number of marks cleared is returned."
8163 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8165 (defun gnus-summary-mark-unread-as-read ()
8166 "Intended to be used by `gnus-summary-mark-article-hook'."
8167 (when (memq gnus-current-article gnus-newsgroup-unreads)
8168 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8170 (defun gnus-summary-mark-read-and-unread-as-read ()
8171 "Intended to be used by `gnus-summary-mark-article-hook'."
8172 (let ((mark (gnus-summary-article-mark)))
8173 (when (or (gnus-unread-mark-p mark)
8174 (gnus-read-mark-p mark))
8175 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8177 (defun gnus-summary-mark-region-as-read (point mark all)
8178 "Mark all unread articles between point and mark as read.
8179 If given a prefix, mark all articles between point and mark as read,
8180 even ticked and dormant ones."
8181 (interactive "r\nP")
8190 (memq (setq article (gnus-summary-article-number))
8191 gnus-newsgroup-unreads))
8192 (gnus-summary-mark-article article gnus-del-mark))
8194 (gnus-summary-find-next))))))
8196 (defun gnus-summary-mark-below (score mark)
8197 "Mark articles with score less than SCORE with MARK."
8198 (interactive "P\ncMark: ")
8199 (setq score (if score
8200 (prefix-numeric-value score)
8201 (or gnus-summary-default-score 0)))
8203 (set-buffer gnus-summary-buffer)
8204 (goto-char (point-min))
8207 (and (< (gnus-summary-article-score) score)
8208 (gnus-summary-mark-article nil mark))
8209 (gnus-summary-find-next)))))
8211 (defun gnus-summary-kill-below (&optional score)
8212 "Mark articles with score below SCORE as read."
8214 (gnus-summary-mark-below score gnus-killed-mark))
8216 (defun gnus-summary-clear-above (&optional score)
8217 "Clear all marks from articles with score above SCORE."
8219 (gnus-summary-mark-above score gnus-unread-mark))
8221 (defun gnus-summary-tick-above (&optional score)
8222 "Tick all articles with score above SCORE."
8224 (gnus-summary-mark-above score gnus-ticked-mark))
8226 (defun gnus-summary-mark-above (score mark)
8227 "Mark articles with score over SCORE with MARK."
8228 (interactive "P\ncMark: ")
8229 (setq score (if score
8230 (prefix-numeric-value score)
8231 (or gnus-summary-default-score 0)))
8233 (set-buffer gnus-summary-buffer)
8234 (goto-char (point-min))
8236 (when (> (gnus-summary-article-score) score)
8237 (gnus-summary-mark-article nil mark))
8239 (gnus-summary-find-next)))))
8241 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8242 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8243 (defun gnus-summary-limit-include-expunged (&optional no-error)
8244 "Display all the hidden articles that were expunged for low scores."
8246 (let ((buffer-read-only nil))
8247 (let ((scored gnus-newsgroup-scored)
8250 (unless (gnus-summary-goto-subject (caar scored))
8251 (and (setq h (gnus-summary-article-header (caar scored)))
8252 (< (cdar scored) gnus-summary-expunge-below)
8254 (setq scored (cdr scored)))
8256 (when (not no-error)
8257 (error "No expunged articles hidden"))
8258 (goto-char (point-min))
8259 (gnus-summary-prepare-unthreaded (nreverse headers))
8260 (goto-char (point-min))
8261 (gnus-summary-position-point)
8264 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8265 "Mark all unread articles in this newsgroup as read.
8266 If prefix argument ALL is non-nil, ticked and dormant articles will
8267 also be marked as read.
8268 If QUIETLY is non-nil, no questions will be asked.
8269 If TO-HERE is non-nil, it should be a point in the buffer. All
8270 articles before this point will be marked as read.
8271 Note that this function will only catch up the unread article
8272 in the current summary buffer limitation.
8273 The number of articles marked as read is returned."
8278 (not gnus-interactive-catchup) ;Without confirmation?
8282 "Mark absolutely all articles as read? "
8283 "Mark all unread articles as read? ")))
8285 (not gnus-newsgroup-adaptive)
8286 (not gnus-newsgroup-auto-expire)
8287 (not gnus-suppress-duplicates)
8288 (or (not gnus-use-cache)
8289 (eq gnus-use-cache 'passive)))
8292 (setq gnus-newsgroup-marked nil
8293 gnus-newsgroup-dormant nil))
8294 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8295 ;; We actually mark all articles as canceled, which we
8296 ;; have to do when using auto-expiry or adaptive scoring.
8297 (gnus-summary-show-all-threads)
8298 (when (gnus-summary-first-subject (not all) t)
8300 (if to-here (< (point) to-here) t)
8301 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8302 (gnus-summary-find-next (not all) nil nil t))))
8303 (gnus-set-mode-line 'summary))
8305 (gnus-summary-position-point)))
8307 (defun gnus-summary-catchup-to-here (&optional all)
8308 "Mark all unticked articles before the current one as read.
8309 If ALL is non-nil, also mark ticked and dormant articles as read."
8312 (gnus-save-hidden-threads
8313 (let ((beg (point)))
8314 ;; We check that there are unread articles.
8315 (when (or all (gnus-summary-find-prev))
8316 (gnus-summary-catchup all t beg)))))
8317 (gnus-summary-position-point))
8319 (defun gnus-summary-catchup-all (&optional quietly)
8320 "Mark all articles in this newsgroup as read."
8322 (gnus-summary-catchup t quietly))
8324 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8325 "Mark all unread articles in this group as read, then exit.
8326 If prefix argument ALL is non-nil, all articles are marked as read."
8328 (when (gnus-summary-catchup all quietly nil 'fast)
8329 ;; Select next newsgroup or exit.
8330 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8331 (eq gnus-auto-select-next 'quietly))
8332 (gnus-summary-next-group nil)
8333 (gnus-summary-exit))))
8335 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8336 "Mark all articles in this newsgroup as read, and then exit."
8338 (gnus-summary-catchup-and-exit t quietly))
8340 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8341 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8342 "Mark all articles in this group as read and select the next group.
8343 If given a prefix, mark all articles, unread as well as ticked, as
8347 (gnus-summary-catchup all))
8348 (gnus-summary-next-article t nil nil t))
8350 ;; Thread-based commands.
8352 (defun gnus-summary-articles-in-thread (&optional article)
8353 "Return a list of all articles in the current thread.
8354 If ARTICLE is non-nil, return all articles in the thread that starts
8356 (let* ((article (or article (gnus-summary-article-number)))
8357 (data (gnus-data-find-list article))
8358 (top-level (gnus-data-level (car data)))
8360 (cond ((null gnus-thread-operation-ignore-subject)
8361 (gnus-simplify-subject-re
8362 (mail-header-subject (gnus-data-header (car data)))))
8363 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8364 (gnus-simplify-subject-fuzzy
8365 (mail-header-subject (gnus-data-header (car data)))))
8367 (end-point (save-excursion
8368 (if (gnus-summary-go-to-next-thread)
8369 (point) (point-max))))
8372 (< (gnus-data-pos (car data)) end-point))
8373 (when (or (not top-subject)
8374 (string= top-subject
8375 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8376 (gnus-simplify-subject-fuzzy
8377 (mail-header-subject
8378 (gnus-data-header (car data))))
8379 (gnus-simplify-subject-re
8380 (mail-header-subject
8381 (gnus-data-header (car data)))))))
8382 (push (gnus-data-number (car data)) articles))
8383 (unless (and (setq data (cdr data))
8384 (> (gnus-data-level (car data)) top-level))
8386 ;; Return the list of articles.
8387 (nreverse articles)))
8389 (defun gnus-summary-rethread-current ()
8390 "Rethread the thread the current article is part of."
8392 (let* ((gnus-show-threads t)
8393 (article (gnus-summary-article-number))
8394 (id (mail-header-id (gnus-summary-article-header)))
8395 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8397 (error "No article on the current line"))
8398 (gnus-rebuild-thread id)
8399 (gnus-summary-goto-subject article)))
8401 (defun gnus-summary-reparent-thread ()
8402 "Make the current article child of the marked (or previous) article.
8404 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8405 is non-nil or the Subject: of both articles are the same."
8407 (unless (not (gnus-group-read-only-p))
8408 (error "The current newsgroup does not support article editing"))
8409 (unless (<= (length gnus-newsgroup-processable) 1)
8410 (error "No more than one article may be marked"))
8411 (save-window-excursion
8412 (let ((gnus-article-buffer " *reparent*")
8413 (current-article (gnus-summary-article-number))
8414 ;; First grab the marked article, otherwise one line up.
8415 (parent-article (if (not (null gnus-newsgroup-processable))
8416 (car gnus-newsgroup-processable)
8418 (if (eq (forward-line -1) 0)
8419 (gnus-summary-article-number)
8420 (error "Beginning of summary buffer"))))))
8421 (unless (not (eq current-article parent-article))
8422 (error "An article may not be self-referential"))
8423 (let ((message-id (mail-header-id
8424 (gnus-summary-article-header parent-article))))
8425 (unless (and message-id (not (equal message-id "")))
8426 (error "No message-id in desired parent"))
8427 (gnus-with-article current-article
8428 (goto-char (point-min))
8429 (if (re-search-forward "^References: " nil t)
8431 (re-search-forward "^[^ \t]" nil t)
8434 (insert " " message-id))
8435 (insert "References: " message-id "\n")))
8436 (set-buffer gnus-summary-buffer)
8437 (gnus-summary-unmark-all-processable)
8438 (gnus-summary-update-article current-article)
8439 (gnus-summary-rethread-current)
8440 (gnus-message 3 "Article %d is now the child of article %d"
8441 current-article parent-article)))))
8443 (defun gnus-summary-toggle-threads (&optional arg)
8444 "Toggle showing conversation threads.
8445 If ARG is positive number, turn showing conversation threads on."
8447 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8448 (setq gnus-show-threads
8449 (if (null arg) (not gnus-show-threads)
8450 (> (prefix-numeric-value arg) 0)))
8451 (gnus-summary-prepare)
8452 (gnus-summary-goto-subject current)
8453 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8454 (gnus-summary-position-point)))
8456 (defun gnus-summary-show-all-threads ()
8460 (let ((buffer-read-only nil))
8461 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8462 (gnus-summary-position-point))
8464 (defun gnus-summary-show-thread ()
8465 "Show thread subtrees.
8466 Returns nil if no thread was there to be shown."
8468 (let ((buffer-read-only nil)
8470 ;; first goto end then to beg, to have point at beg after let
8471 (end (progn (end-of-line) (point)))
8472 (beg (progn (beginning-of-line) (point))))
8474 ;; Any hidden lines here?
8475 (search-forward "\r" end t)
8476 (subst-char-in-region beg end ?\^M ?\n t)
8478 (gnus-summary-position-point))))
8480 (defun gnus-summary-hide-all-threads ()
8481 "Hide all thread subtrees."
8484 (goto-char (point-min))
8485 (gnus-summary-hide-thread)
8486 (while (zerop (gnus-summary-next-thread 1 t))
8487 (gnus-summary-hide-thread)))
8488 (gnus-summary-position-point))
8490 (defun gnus-summary-hide-thread ()
8491 "Hide thread subtrees.
8492 Returns nil if no threads were there to be hidden."
8494 (let ((buffer-read-only nil)
8496 (article (gnus-summary-article-number)))
8498 ;; Go forward until either the buffer ends or the subthread
8500 (when (and (not (eobp))
8501 (or (zerop (gnus-summary-next-thread 1 t))
8502 (goto-char (point-max))))
8504 (if (and (> (point) start)
8505 (search-backward "\n" start t))
8507 (subst-char-in-region start (point) ?\n ?\^M)
8508 (gnus-summary-goto-subject article))
8511 ;;(gnus-summary-position-point)
8514 (defun gnus-summary-go-to-next-thread (&optional previous)
8515 "Go to the same level (or less) next thread.
8516 If PREVIOUS is non-nil, go to previous thread instead.
8517 Return the article number moved to, or nil if moving was impossible."
8518 (let ((level (gnus-summary-thread-level))
8519 (way (if previous -1 1))
8522 (while (and (not (eobp))
8523 (< level (gnus-summary-thread-level)))
8531 (gnus-summary-article-number)
8534 (defun gnus-summary-next-thread (n &optional silent)
8535 "Go to the same level next N'th thread.
8536 If N is negative, search backward instead.
8537 Returns the difference between N and the number of skips actually
8540 If SILENT, don't output messages."
8542 (let ((backward (< n 0))
8545 (gnus-summary-go-to-next-thread backward))
8548 (gnus-summary-position-point))
8549 (when (and (not silent) (/= 0 n))
8550 (gnus-message 7 "No more threads"))
8553 (defun gnus-summary-prev-thread (n)
8554 "Go to the same level previous N'th thread.
8555 Returns the difference between N and the number of skips actually
8558 (gnus-summary-next-thread (- n)))
8560 (defun gnus-summary-go-down-thread ()
8561 "Go down one level in the current thread."
8562 (let ((children (gnus-summary-article-children)))
8564 (gnus-summary-goto-subject (car children)))))
8566 (defun gnus-summary-go-up-thread ()
8567 "Go up one level in the current thread."
8568 (let ((parent (gnus-summary-article-parent)))
8570 (gnus-summary-goto-subject parent))))
8572 (defun gnus-summary-down-thread (n)
8573 "Go down thread N steps.
8574 If N is negative, go up instead.
8575 Returns the difference between N and how many steps down that were
8581 (if up (gnus-summary-go-up-thread)
8582 (gnus-summary-go-down-thread)))
8584 (gnus-summary-position-point)
8586 (gnus-message 7 "Can't go further"))
8589 (defun gnus-summary-up-thread (n)
8590 "Go up thread N steps.
8591 If N is negative, go up instead.
8592 Returns the difference between N and how many steps down that were
8595 (gnus-summary-down-thread (- n)))
8597 (defun gnus-summary-top-thread ()
8598 "Go to the top of the thread."
8600 (while (gnus-summary-go-up-thread))
8601 (gnus-summary-article-number))
8603 (defun gnus-summary-kill-thread (&optional unmark)
8604 "Mark articles under current thread as read.
8605 If the prefix argument is positive, remove any kinds of marks.
8606 If the prefix argument is negative, tick articles instead."
8609 (setq unmark (prefix-numeric-value unmark)))
8610 (let ((articles (gnus-summary-articles-in-thread)))
8612 ;; Expand the thread.
8613 (gnus-summary-show-thread)
8614 ;; Mark all the articles.
8616 (gnus-summary-goto-subject (car articles))
8617 (cond ((null unmark)
8618 (gnus-summary-mark-article-as-read gnus-killed-mark))
8620 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8622 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8623 (setq articles (cdr articles))))
8624 ;; Hide killed subtrees.
8626 gnus-thread-hide-killed
8627 (gnus-summary-hide-thread))
8628 ;; If marked as read, go to next unread subject.
8630 ;; Go to next unread subject.
8631 (gnus-summary-next-subject 1 t)))
8632 (gnus-set-mode-line 'summary))
8634 ;; Summary sorting commands
8636 (defun gnus-summary-sort-by-number (&optional reverse)
8637 "Sort the summary buffer by article number.
8638 Argument REVERSE means reverse order."
8640 (gnus-summary-sort 'number reverse))
8642 (defun gnus-summary-sort-by-author (&optional reverse)
8643 "Sort the summary buffer by author name alphabetically.
8644 If case-fold-search is non-nil, case of letters is ignored.
8645 Argument REVERSE means reverse order."
8647 (gnus-summary-sort 'author reverse))
8649 (defun gnus-summary-sort-by-subject (&optional reverse)
8650 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8651 If case-fold-search is non-nil, case of letters is ignored.
8652 Argument REVERSE means reverse order."
8654 (gnus-summary-sort 'subject reverse))
8656 (defun gnus-summary-sort-by-date (&optional reverse)
8657 "Sort the summary buffer by date.
8658 Argument REVERSE means reverse order."
8660 (gnus-summary-sort 'date reverse))
8662 (defun gnus-summary-sort-by-score (&optional reverse)
8663 "Sort the summary buffer by score.
8664 Argument REVERSE means reverse order."
8666 (gnus-summary-sort 'score reverse))
8668 (defun gnus-summary-sort-by-lines (&optional reverse)
8669 "Sort the summary buffer by the number of lines.
8670 Argument REVERSE means reverse order."
8672 (gnus-summary-sort 'lines reverse))
8674 (defun gnus-summary-sort-by-chars (&optional reverse)
8675 "Sort the summary buffer by article length.
8676 Argument REVERSE means reverse order."
8678 (gnus-summary-sort 'chars reverse))
8680 (defun gnus-summary-sort (predicate reverse)
8681 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8682 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8683 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8684 (gnus-thread-sort-functions
8689 (gnus-article-sort-functions
8695 (gnus-summary-prepare-hook nil))
8696 ;; We do the sorting by regenerating the threads.
8697 (gnus-summary-prepare)
8698 ;; Hide subthreads if needed.
8699 (when (and gnus-show-threads gnus-thread-hide-subtree)
8700 (gnus-summary-hide-all-threads))))
8702 ;; Summary saving commands.
8704 (defun gnus-summary-save-article (&optional n not-saved)
8705 "Save the current article using the default saver function.
8706 If N is a positive number, save the N next articles.
8707 If N is a negative number, save the N previous articles.
8708 If N is nil and any articles have been marked with the process mark,
8709 save those articles instead.
8710 The variable `gnus-default-article-saver' specifies the saver function."
8712 (let* ((articles (gnus-summary-work-articles n))
8713 (save-buffer (save-excursion
8714 (nnheader-set-temp-buffer " *Gnus Save*")))
8715 (num (length articles))
8717 (dolist (article articles)
8718 (setq header (gnus-summary-article-header article))
8719 (if (not (vectorp header))
8720 ;; This is a pseudo-article.
8721 (if (assq 'name header)
8722 (gnus-copy-file (cdr (assq 'name header)))
8723 (gnus-message 1 "Article %d is unsaveable" article))
8724 ;; This is a real article.
8725 (save-window-excursion
8726 (gnus-summary-select-article t nil nil article))
8728 (set-buffer save-buffer)
8730 (insert-buffer-substring gnus-original-article-buffer))
8731 (setq file (gnus-article-save save-buffer file num))
8732 (gnus-summary-remove-process-mark article)
8734 (gnus-summary-set-saved-mark article))))
8735 (gnus-kill-buffer save-buffer)
8736 (gnus-summary-position-point)
8737 (gnus-set-mode-line 'summary)
8740 (defun gnus-summary-pipe-output (&optional arg)
8741 "Pipe the current article to a subprocess.
8742 If N is a positive number, pipe the N next articles.
8743 If N is a negative number, pipe the N previous articles.
8744 If N is nil and any articles have been marked with the process mark,
8745 pipe those articles instead."
8747 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8748 (gnus-summary-save-article arg t))
8749 (gnus-configure-windows 'pipe))
8751 (defun gnus-summary-save-article-mail (&optional arg)
8752 "Append the current article to an mail file.
8753 If N is a positive number, save the N next articles.
8754 If N is a negative number, save the N previous articles.
8755 If N is nil and any articles have been marked with the process mark,
8756 save those articles instead."
8758 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8759 (gnus-summary-save-article arg)))
8761 (defun gnus-summary-save-article-rmail (&optional arg)
8762 "Append the current article to an rmail file.
8763 If N is a positive number, save the N next articles.
8764 If N is a negative number, save the N previous articles.
8765 If N is nil and any articles have been marked with the process mark,
8766 save those articles instead."
8768 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8769 (gnus-summary-save-article arg)))
8771 (defun gnus-summary-save-article-file (&optional arg)
8772 "Append the current article to a file.
8773 If N is a positive number, save the N next articles.
8774 If N is a negative number, save the N previous articles.
8775 If N is nil and any articles have been marked with the process mark,
8776 save those articles instead."
8778 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8779 (gnus-summary-save-article arg)))
8781 (defun gnus-summary-write-article-file (&optional arg)
8782 "Write the current article to a file, deleting the previous file.
8783 If N is a positive number, save the N next articles.
8784 If N is a negative number, save the N previous articles.
8785 If N is nil and any articles have been marked with the process mark,
8786 save those articles instead."
8788 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8789 (gnus-summary-save-article arg)))
8791 (defun gnus-summary-save-article-body-file (&optional arg)
8792 "Append the current article body to a file.
8793 If N is a positive number, save the N next articles.
8794 If N is a negative number, save the N previous articles.
8795 If N is nil and any articles have been marked with the process mark,
8796 save those articles instead."
8798 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8799 (gnus-summary-save-article arg)))
8801 (defun gnus-summary-pipe-message (program)
8802 "Pipe the current article through PROGRAM."
8803 (interactive "sProgram: ")
8804 (gnus-summary-select-article)
8805 (let ((mail-header-separator ""))
8806 (gnus-eval-in-buffer-window gnus-article-buffer
8809 (let ((start (window-start))
8811 (message-pipe-buffer-body program)
8812 (set-window-start (get-buffer-window (current-buffer)) start))))))
8814 (defun gnus-get-split-value (methods)
8815 "Return a value based on the split METHODS."
8816 (let (split-name method result match)
8819 (set-buffer gnus-original-article-buffer)
8821 (nnheader-narrow-to-headers)
8823 (goto-char (point-min))
8824 (setq method (pop methods))
8825 (setq match (car method))
8828 ;; Regular expression.
8830 (re-search-forward match nil t)))
8831 ((gnus-functionp match)
8835 (setq result (funcall match gnus-newsgroup-name))))
8840 (setq result (eval match)))))
8841 (setq split-name (append (cdr method) split-name))
8842 (cond ((stringp result)
8843 (push (expand-file-name
8844 result gnus-article-save-directory)
8847 (setq split-name (append result split-name)))))))))
8848 (nreverse split-name)))
8850 (defun gnus-valid-move-group-p (group)
8853 (symbol-value group)
8854 (gnus-get-function (gnus-find-method-for-group
8855 (symbol-name group)) 'request-accept-article t)))
8857 (defun gnus-read-move-group-name (prompt default articles prefix)
8858 "Read a group name."
8859 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8860 (minibuffer-confirm-incomplete nil) ; XEmacs
8864 (if (> (length articles) 1)
8865 (format "these %d articles" (length articles))
8870 (gnus-completing-read default prom
8872 'gnus-valid-move-group-p
8874 'gnus-group-history))
8875 ((= 1 (length split-name))
8876 (gnus-completing-read (car split-name) prom
8878 'gnus-valid-move-group-p
8880 'gnus-group-history))
8882 (gnus-completing-read nil prom
8883 (mapcar (lambda (el) (list el))
8884 (nreverse split-name))
8886 'gnus-group-history)))))
8888 (if (or (string= to-newsgroup "")
8889 (string= to-newsgroup prefix))
8890 (setq to-newsgroup default))
8891 (unless to-newsgroup
8892 (error "No group name entered"))
8893 (or (gnus-active to-newsgroup)
8894 (gnus-activate-group to-newsgroup)
8895 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8897 (or (and (gnus-request-create-group
8898 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8899 (gnus-activate-group to-newsgroup nil nil
8900 (gnus-group-name-to-method
8902 (error "Couldn't create group %s" to-newsgroup)))
8903 (error "No such group: %s" to-newsgroup)))
8906 (defun gnus-summary-save-parts (type dir n reverse)
8907 "Save parts matching TYPE to DIR.
8908 If REVERSE, save parts that do not match TYPE."
8910 (list (read-string "Save parts of type: " "image/.*")
8911 (read-file-name "Save to directory: " t nil t)
8912 current-prefix-arg))
8913 (gnus-summary-iterate n
8914 (let ((gnus-display-mime-function nil)
8915 (gnus-inhibit-treatment t))
8916 (gnus-summary-select-article))
8918 (set-buffer gnus-article-buffer)
8919 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
8921 (gnus-summary-save-parts-1 type dir handles reverse)
8922 (mm-destroy-parts handles))))))
8924 (defun gnus-summary-save-parts-1 (type dir handle reverse)
8925 (if (stringp (car handle))
8926 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
8929 (not (string-match type (mm-handle-media-type handle)))
8930 (string-match type (mm-handle-media-type handle)))
8931 (let ((file (expand-file-name
8932 (file-name-nondirectory
8934 (mail-content-type-get
8935 (mm-handle-disposition handle) 'filename)
8936 (concat gnus-newsgroup-name "." gnus-current-article)))
8938 (unless (file-exists-p file)
8939 (mm-save-part-to-file handle file))))))
8941 ;; Summary extract commands
8943 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8944 (let ((buffer-read-only nil)
8945 (article (gnus-summary-article-number))
8947 (unless (gnus-summary-goto-subject article)
8948 (error "No such article: %d" article))
8949 (gnus-summary-position-point)
8950 ;; If all commands are to be bunched up on one line, we collect
8952 (unless gnus-view-pseudos-separately
8953 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8956 (setq action (cdr (assq 'action (car ps))))
8957 (setq files (list (cdr (assq 'name (car ps)))))
8958 (while (and ps (cdr ps)
8959 (string= (or action "1")
8960 (or (cdr (assq 'action (cadr ps))) "2")))
8961 (push (cdr (assq 'name (cadr ps))) files)
8962 (setcdr ps (cddr ps)))
8964 (when (not (string-match "%s" action))
8967 (when (assq 'execute (car ps))
8968 (setcdr (assq 'execute (car ps))
8969 (funcall (if (string-match "%s" action)
8976 (gnus-quote-arg-for-sh-or-csh f)))
8978 (setq ps (cdr ps)))))
8979 (if (and gnus-view-pseudos (not not-view))
8981 (when (assq 'execute (car pslist))
8982 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8983 (eq gnus-view-pseudos 'not-confirm)))
8984 (setq pslist (cdr pslist)))
8987 (setq after-article (or (cdr (assq 'article (car pslist)))
8988 (gnus-summary-article-number)))
8989 (gnus-summary-goto-subject after-article)
8992 (insert " " (file-name-nondirectory
8993 (cdr (assq 'name (car pslist))))
8994 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8996 (forward-line -1) ; back to `b'
8997 (gnus-add-text-properties
8998 b (1- e) (list 'gnus-number gnus-reffed-article-number
8999 gnus-mouse-face-prop gnus-mouse-face))
9001 after-article gnus-reffed-article-number
9002 gnus-unread-mark b (car pslist) 0 (- e b))
9003 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9004 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9005 (setq pslist (cdr pslist)))))))
9007 (defun gnus-pseudos< (p1 p2)
9008 (let ((c1 (cdr (assq 'action p1)))
9009 (c2 (cdr (assq 'action p2))))
9010 (and c1 c2 (string< c1 c2))))
9012 (defun gnus-request-pseudo-article (props)
9013 (cond ((assq 'execute props)
9014 (gnus-execute-command (cdr (assq 'execute props)))))
9015 (let ((gnus-current-article (gnus-summary-article-number)))
9016 (gnus-run-hooks 'gnus-mark-article-hook)))
9018 (defun gnus-execute-command (command &optional automatic)
9020 (gnus-article-setup-buffer)
9021 (set-buffer gnus-article-buffer)
9022 (setq buffer-read-only nil)
9023 (let ((command (if automatic command
9024 (read-string "Command: " (cons command 0)))))
9026 (insert "$ " command "\n\n")
9027 (if gnus-view-pseudo-asynchronously
9028 (start-process "gnus-execute" (current-buffer) shell-file-name
9029 shell-command-switch command)
9030 (call-process shell-file-name nil t nil
9031 shell-command-switch command)))))
9033 ;; Summary kill commands.
9035 (defun gnus-summary-edit-global-kill (article)
9036 "Edit the \"global\" kill file."
9037 (interactive (list (gnus-summary-article-number)))
9038 (gnus-group-edit-global-kill article))
9040 (defun gnus-summary-edit-local-kill ()
9041 "Edit a local kill file applied to the current newsgroup."
9043 (setq gnus-current-headers (gnus-summary-article-header))
9044 (gnus-group-edit-local-kill
9045 (gnus-summary-article-number) gnus-newsgroup-name))
9049 (defun gnus-read-header (id &optional header)
9050 "Read the headers of article ID and enter them into the Gnus system."
9051 (let ((group gnus-newsgroup-name)
9052 (gnus-override-method
9053 (and (gnus-news-group-p gnus-newsgroup-name)
9054 gnus-refer-article-method))
9056 ;; First we check to see whether the header in question is already
9059 ;; This is a Message-ID.
9060 (setq header (or header (gnus-id-to-header id)))
9061 ;; This is an article number.
9062 (setq header (or header (gnus-summary-article-header id))))
9064 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9065 ;; We have found the header.
9067 ;; If this is a sparse article, we have to nix out its
9068 ;; previous entry in the thread hashtb.
9070 (gnus-summary-article-sparse-p (mail-header-number header)))
9071 (let* ((parent (gnus-parent-id (mail-header-references header)))
9072 (thread (and parent (gnus-id-to-thread parent))))
9074 (delq (assq header thread) thread))))
9075 ;; We have to really fetch the header to this article.
9077 (set-buffer nntp-server-buffer)
9078 (when (setq where (gnus-request-head id group))
9079 (nnheader-fold-continuation-lines)
9080 (goto-char (point-max))
9082 (goto-char (point-min))
9086 ((cdr where) (cdr where))
9087 (header (mail-header-number header))
9088 (t gnus-reffed-article-number))
9090 (insert " Article retrieved.\n"))
9092 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9093 () ; Malformed head.
9094 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9095 (when (and (stringp id)
9096 (not (string= (gnus-group-real-name group)
9098 ;; If we fetched by Message-ID and the article came
9099 ;; from a different group, we fudge some bogus article
9100 ;; numbers for this article.
9101 (mail-header-set-number header gnus-reffed-article-number))
9103 (set-buffer gnus-summary-buffer)
9104 (decf gnus-reffed-article-number)
9105 (gnus-remove-header (mail-header-number header))
9106 (push header gnus-newsgroup-headers)
9107 (setq gnus-current-headers header)
9108 (push (mail-header-number header) gnus-newsgroup-limit)))
9111 (defun gnus-remove-header (number)
9112 "Remove header NUMBER from `gnus-newsgroup-headers'."
9113 (if (and gnus-newsgroup-headers
9114 (= number (mail-header-number (car gnus-newsgroup-headers))))
9115 (pop gnus-newsgroup-headers)
9116 (let ((headers gnus-newsgroup-headers))
9117 (while (and (cdr headers)
9118 (not (= number (mail-header-number (cadr headers)))))
9121 (setcdr headers (cddr headers))))))
9124 ;;; summary highlights
9127 (defun gnus-highlight-selected-summary ()
9128 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9129 ;; Highlight selected article in summary buffer
9130 (when gnus-summary-selected-face
9132 (let* ((beg (progn (beginning-of-line) (point)))
9133 (end (progn (end-of-line) (point)))
9134 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9135 (from (if (get-text-property beg gnus-mouse-face-prop)
9137 (or (next-single-property-change
9138 beg gnus-mouse-face-prop nil end)
9143 (or (next-single-property-change
9144 from gnus-mouse-face-prop nil end)
9146 ;; If no mouse-face prop on line we will have to = from = end,
9147 ;; so we highlight the entire line instead.
9148 (when (= (+ to 2) from)
9151 (if gnus-newsgroup-selected-overlay
9152 ;; Move old overlay.
9154 gnus-newsgroup-selected-overlay from to (current-buffer))
9155 ;; Create new overlay.
9157 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9158 'face gnus-summary-selected-face))))))
9160 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9161 (defun gnus-summary-highlight-line ()
9162 "Highlight current line according to `gnus-summary-highlight'."
9163 (let* ((list gnus-summary-highlight)
9165 (end (progn (end-of-line) (point)))
9166 ;; now find out where the line starts and leave point there.
9167 (beg (progn (beginning-of-line) (point)))
9168 (article (gnus-summary-article-number))
9169 (score (or (cdr (assq (or article gnus-current-article)
9170 gnus-newsgroup-scored))
9171 gnus-summary-default-score 0))
9172 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9173 (inhibit-read-only t))
9174 ;; Eval the cars of the lists until we find a match.
9175 (let ((default gnus-summary-default-score))
9177 (not (eval (caar list))))
9178 (setq list (cdr list))))
9179 (let ((face (cdar list)))
9180 (unless (eq face (get-text-property beg 'face))
9181 (gnus-put-text-property-excluding-characters-with-faces
9183 (setq face (if (boundp face) (symbol-value face) face)))
9184 (when gnus-summary-highlight-line-function
9185 (funcall gnus-summary-highlight-line-function article face))))
9188 (defun gnus-update-read-articles (group unread &optional compute)
9189 "Update the list of read articles in GROUP."
9190 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9191 (entry (gnus-gethash group gnus-newsrc-hashtb))
9192 (info (nth 2 entry))
9194 (unread (sort (copy-sequence unread) '<))
9196 (if (or (not info) (not active))
9197 ;; There is no info on this group if it was, in fact,
9198 ;; killed. Gnus stores no information on killed groups, so
9199 ;; there's nothing to be done.
9200 ;; One could store the information somewhere temporarily,
9201 ;; perhaps... Hmmm...
9203 ;; Remove any negative articles numbers.
9204 (while (and unread (< (car unread) 0))
9205 (setq unread (cdr unread)))
9206 ;; Remove any expired article numbers
9207 (while (and unread (< (car unread) (car active)))
9208 (setq unread (cdr unread)))
9209 ;; Compute the ranges of read articles by looking at the list of
9212 (when (/= (car unread) prev)
9213 (push (if (= prev (1- (car unread))) prev
9214 (cons prev (1- (car unread))))
9216 (setq prev (1+ (car unread)))
9217 (setq unread (cdr unread)))
9218 (when (<= prev (cdr active))
9219 (push (cons prev (cdr active)) read))
9220 (setq read (if (> (length read) 1) (nreverse read) read))
9224 (set-buffer gnus-group-buffer)
9227 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9228 (gnus-info-set-read ',info ',(gnus-info-read info))
9229 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9230 (gnus-group-update-group ,group t))))
9231 ;; Propagate the read marks to the backend.
9232 (if (gnus-check-backend-function 'request-set-mark group)
9233 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9234 (add (gnus-remove-from-range read (gnus-info-read info))))
9236 (unless (gnus-check-group group)
9237 (error "Can't open server for %s" group))
9238 (gnus-request-set-mark
9239 group (delq nil (list (if add (list add 'add '(read)))
9240 (if del (list del 'del '(read)))))))))
9241 ;; Enter this list into the group info.
9242 (gnus-info-set-read info read)
9243 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9244 (gnus-get-unread-articles-in-group info (gnus-active group))
9247 (defun gnus-offer-save-summaries ()
9248 "Offer to save all active summary buffers."
9250 (let ((buflist (buffer-list))
9252 ;; Go through all buffers and find all summaries.
9254 (and (setq bufname (buffer-name (car buflist)))
9255 (string-match "Summary" bufname)
9257 (set-buffer bufname)
9258 ;; We check that this is, indeed, a summary buffer.
9259 (and (eq major-mode 'gnus-summary-mode)
9260 ;; Also make sure this isn't bogus.
9261 gnus-newsgroup-prepared
9262 ;; Also make sure that this isn't a dead summary buffer.
9263 (not gnus-dead-summary-mode)))
9264 (push bufname buffers))
9265 (setq buflist (cdr buflist)))
9266 ;; Go through all these summary buffers and offer to save them.
9269 "Update summary buffer %s? "
9271 (switch-to-buffer buf)
9272 (gnus-summary-exit))
9276 ;;; @ for mime-partial
9279 (defun gnus-request-partial-message ()
9281 (let ((number (gnus-summary-article-number))
9282 (group gnus-newsgroup-name)
9283 (mother gnus-article-buffer))
9284 (set-buffer (get-buffer-create " *Partial Article*"))
9286 (setq mime-preview-buffer mother)
9287 (gnus-request-article-this-buffer number group)
9291 (autoload 'mime-combine-message/partial-pieces-automatically
9293 "Internal method to combine message/partial messages automatically.")
9296 'action '((type . message)(subtype . partial)
9297 (major-mode . gnus-original-article-mode)
9298 (method . mime-combine-message/partial-pieces-automatically)
9299 (summary-buffer-exp . gnus-summary-buffer)
9300 (request-partial-message-method . gnus-request-partial-message)
9304 ;;; @ for message/rfc822
9307 (defun gnus-mime-extract-message/rfc822 (entity situation)
9308 (let (group article num cwin swin cur)
9309 (with-current-buffer (mime-entity-buffer entity)
9311 (narrow-to-region (mime-entity-body-start entity)
9312 (mime-entity-body-end entity))
9313 (setq group (or (cdr (assq 'group situation))
9314 (completing-read "Group: "
9317 (gnus-read-active-file-p)
9318 gnus-newsgroup-name))
9319 article (gnus-request-accept-article group)
9322 (when (and (consp article)
9323 (numberp (setq article (cdr article))))
9324 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9325 cwin (get-buffer-window (current-buffer) t)
9327 (save-window-excursion
9328 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9329 (select-window swin)
9330 (set-buffer gnus-summary-buffer)
9332 (setq cur gnus-current-article)
9334 (let (gnus-show-threads)
9335 (gnus-summary-goto-subject article t)
9337 (gnus-summary-clear-mark-forward 1)
9338 (gnus-summary-goto-subject cur)
9340 (when (and cwin (window-frame cwin))
9341 (select-frame (window-frame cwin))
9343 (when (boundp 'mime-acting-situation-to-override)
9344 (set-alist 'mime-acting-situation-to-override
9347 (set-alist 'mime-acting-situation-to-override
9350 (save-current-buffer
9351 (set-buffer gnus-group-buffer)
9352 (gnus-activate-group ,group)
9354 (gnus-summary-goto-article ,cur
9355 gnus-show-all-headers)
9357 (set-alist 'mime-acting-situation-to-override
9363 'action '((type . message)(subtype . rfc822)
9364 (major-mode . gnus-original-article-mode)
9365 (method . gnus-mime-extract-message/rfc822)
9370 'action '((type . message)(subtype . news)
9371 (major-mode . gnus-original-article-mode)
9372 (method . gnus-mime-extract-message/rfc822)
9376 (defun gnus-mime-extract-multipart (entity situation)
9377 (let ((children (mime-entity-children entity))
9378 mime-acting-situation-to-override
9381 (mime-play-entity (car children)
9382 (cons (assq 'mode situation)
9383 mime-acting-situation-to-override))
9384 (setq children (cdr children)))
9385 (if (setq f (cdr (assq 'after-method
9386 mime-acting-situation-to-override)))
9391 'action '((type . multipart)
9392 (method . gnus-mime-extract-multipart)
9401 (defun gnus-summary-setup-default-charset ()
9402 "Setup newsgroup default charset."
9403 (if (equal gnus-newsgroup-name "nndraft:drafts")
9404 (setq gnus-newsgroup-charset nil)
9405 (let* ((name (and gnus-newsgroup-name
9406 (gnus-group-real-name gnus-newsgroup-name)))
9408 (or gnus-newsgroup-ephemeral-ignored-charsets
9410 (and gnus-newsgroup-name
9411 (or (gnus-group-find-parameter gnus-newsgroup-name
9412 'ignored-charsets t)
9413 (let ((alist gnus-group-ignored-charsets-alist)
9414 elem (charsets nil))
9415 (while (setq elem (pop alist))
9417 (string-match (car elem) name))
9419 charsets (cdr elem))))
9421 gnus-newsgroup-ignored-charsets)))
9422 (setq gnus-newsgroup-charset
9423 (or gnus-newsgroup-ephemeral-charset
9424 (and gnus-newsgroup-name
9425 (or (gnus-group-find-parameter gnus-newsgroup-name
9427 (let ((alist gnus-group-charset-alist)
9429 (while (setq elem (pop alist))
9431 (string-match (car elem) name))
9433 charset (cadr elem))))
9435 gnus-default-charset))
9436 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9437 ignored-charsets))))
9443 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9444 "Display the current article buffer fully MIME-buttonized.
9445 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9446 treated as multipart/mixed."
9449 (let ((gnus-unbuttonized-mime-types nil)
9450 (gnus-mime-display-multipart-as-mixed show-all-parts))
9451 (gnus-summary-show-article)))
9453 (defun gnus-summary-repair-multipart (article)
9454 "Add a Content-Type header to a multipart article without one."
9455 (interactive (list (gnus-summary-article-number)))
9456 (gnus-with-article article
9457 (message-narrow-to-head)
9458 (goto-char (point-max))
9460 (when (search-forward "\n--" nil t)
9461 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9462 (message-narrow-to-head)
9463 (message-remove-header "Mime-Version")
9464 (message-remove-header "Content-Type")
9465 (goto-char (point-max))
9466 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9468 (insert "Mime-Version: 1.0\n")
9470 (let (gnus-mark-article-hook)
9471 (gnus-summary-select-article t t nil article)))
9473 (defun gnus-summary-toggle-display-buttonized ()
9474 "Toggle the buttonizing of the article buffer."
9477 (if (setq gnus-inhibit-mime-unbuttonizing
9478 (not gnus-inhibit-mime-unbuttonizing))
9479 (let ((gnus-unbuttonized-mime-types nil))
9480 (gnus-summary-show-article))
9481 (gnus-summary-show-article)))
9487 (defmacro gnus-with-article (article &rest forms)
9488 "Select ARTICLE and perform FORMS in the original article buffer.
9489 Then replace the article with the result."
9491 ;; We don't want the article to be marked as read.
9492 (let (gnus-mark-article-hook)
9493 (gnus-summary-select-article t t nil ,article))
9494 (set-buffer gnus-original-article-buffer)
9496 (if (not (gnus-check-backend-function
9497 'request-replace-article (car gnus-article-current)))
9498 (gnus-message 5 "Read-only group; not replacing")
9499 (unless (gnus-request-replace-article
9500 ,article (car gnus-article-current)
9502 (error "Couldn't replace article")))
9503 ;; The cache and backlog have to be flushed somewhat.
9504 (when gnus-keep-backlog
9505 (gnus-backlog-remove-article
9506 (car gnus-article-current) (cdr gnus-article-current)))
9507 (when gnus-use-cache
9508 (gnus-cache-update-article
9509 (car gnus-article-current) (cdr gnus-article-current)))))
9511 (put 'gnus-with-article 'lisp-indent-function 1)
9512 (put 'gnus-with-article 'edebug-form-spec '(form body))
9515 ;;; Generic summary marking commands
9518 (defvar gnus-summary-marking-alist
9519 '((read gnus-del-mark "d")
9520 (unread gnus-unread-mark "u")
9521 (ticked gnus-ticked-mark "!")
9522 (dormant gnus-dormant-mark "?")
9523 (expirable gnus-expirable-mark "e"))
9524 "An alist of names/marks/keystrokes.")
9526 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9527 (defvar gnus-summary-mark-map)
9529 (defun gnus-summary-make-all-marking-commands ()
9530 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9531 (dolist (elem gnus-summary-marking-alist)
9532 (apply 'gnus-summary-make-marking-command elem)))
9534 (defun gnus-summary-make-marking-command (name mark keystroke)
9535 (let ((map (make-sparse-keymap)))
9536 (define-key gnus-summary-generic-mark-map keystroke map)
9537 (dolist (lway `((next "next" next nil "n")
9538 (next-unread "next unread" next t "N")
9539 (prev "previous" prev nil "p")
9540 (prev-unread "previous unread" prev t "P")
9541 (nomove "" nil nil ,keystroke)))
9542 (let ((func (gnus-summary-make-marking-command-1
9543 mark (car lway) lway name)))
9544 (setq func (eval func))
9545 (define-key map (nth 4 lway) func)))))
9547 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9549 (format "gnus-summary-put-mark-as-%s%s"
9550 name (if (eq way 'nomove)
9552 (concat "-" (symbol-name way)))))
9555 "Mark the current article as %s%s.
9556 If N, the prefix, then repeat N times.
9557 If N is negative, move in reverse order.
9558 The difference between N and the actual number of articles marked is
9562 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9564 (defun gnus-summary-generic-mark (n mark move unread)
9565 "Mark N articles with MARK."
9566 (unless (eq major-mode 'gnus-summary-mode)
9567 (error "This command can only be used in the summary buffer"))
9568 (gnus-summary-show-thread)
9572 ((eq move 'prev) -1)
9578 nummove (* -1 nummove))))
9580 (gnus-summary-mark-article nil mark)
9581 (zerop (gnus-summary-next-subject nummove unread t)))
9584 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9585 (gnus-summary-recenter)
9586 (gnus-summary-position-point)
9587 (gnus-set-mode-line 'summary)
9590 (gnus-summary-make-all-marking-commands)
9596 (run-hooks 'gnus-sum-load-hook)
9598 ;;; gnus-sum.el ends here