1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (autoload 'gnus-cache-write-active "gnus-cache")
42 (defcustom gnus-kill-summary-on-exit t
43 "*If non-nil, kill the summary buffer when you exit from it.
44 If nil, the summary will become a \"*Dead Summary*\" buffer, and
45 it will be killed sometime later."
46 :group 'gnus-summary-exit
49 (defcustom gnus-fetch-old-headers nil
50 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
51 If an unread article in the group refers to an older, already read (or
52 just marked as read) article, the old article will not normally be
53 displayed in the Summary buffer. If this variable is non-nil, Gnus
54 will attempt to grab the headers to the old articles, and thereby
55 build complete threads. If it has the value `some', only enough
56 headers to connect otherwise loose threads will be displayed. This
57 variable can also be a number. In that case, no more than that number
58 of old headers will be fetched. If it has the value `invisible', all
59 old headers will be fetched, but none will be displayed.
61 The server has to support NOV for any of this to work."
63 :type '(choice (const :tag "off" nil)
66 (sexp :menu-tag "other" t)))
68 (defcustom gnus-refer-thread-limit 200
69 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
70 If t, fetch all the available old headers."
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-summary-make-false-root 'adopt
76 "*nil means that Gnus won't gather loose threads.
77 If the root of a thread has expired or been read in a previous
78 session, the information necessary to build a complete thread has been
79 lost. Instead of having many small sub-threads from this original thread
80 scattered all over the summary buffer, Gnus can gather them.
82 If non-nil, Gnus will try to gather all loose sub-threads from an
83 original thread into one large thread.
85 If this variable is non-nil, it should be one of `none', `adopt',
88 If this variable is `none', Gnus will not make a false root, but just
89 present the sub-threads after another.
90 If this variable is `dummy', Gnus will create a dummy root that will
91 have all the sub-threads as children.
92 If this variable is `adopt', Gnus will make one of the \"children\"
93 the parent and mark all the step-children as such.
94 If this variable is `empty', the \"children\" are printed with empty
95 subject fields. (Or rather, they will be printed with a string
96 given by the `gnus-summary-same-subject' variable.)"
98 :type '(choice (const :tag "off" nil)
104 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
105 "*A regexp to match subjects to be excluded from loose thread gathering.
106 As loose thread gathering is done on subjects only, that means that
107 there can be many false gatherings performed. By rooting out certain
108 common subjects, gathering might become saner."
112 (defcustom gnus-summary-gather-subject-limit nil
113 "*Maximum length of subject comparisons when gathering loose threads.
114 Use nil to compare full subjects. Setting this variable to a low
115 number will help gather threads that have been corrupted by
116 newsreaders chopping off subject lines, but it might also mean that
117 unrelated articles that have subject that happen to begin with the
118 same few characters will be incorrectly gathered.
120 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
123 :type '(choice (const :tag "off" nil)
125 (sexp :menu-tag "on" t)))
127 (defcustom gnus-simplify-subject-functions nil
128 "List of functions taking a string argument that simplify subjects.
129 The functions are applied recursively.
131 Useful functions to put in this list include: `gnus-simplify-subject-re',
132 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
134 :type '(repeat function))
136 (defcustom gnus-simplify-ignored-prefixes nil
137 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
139 :type '(choice (const :tag "off" nil)
142 (defcustom gnus-build-sparse-threads nil
143 "*If non-nil, fill in the gaps in threads.
144 If `some', only fill in the gaps that are needed to tie loose threads
145 together. If `more', fill in all leaf nodes that Gnus can find. If
146 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
148 :type '(choice (const :tag "off" nil)
151 (sexp :menu-tag "all" t)))
153 (defcustom gnus-summary-thread-gathering-function
154 'gnus-gather-threads-by-subject
155 "*Function used for gathering loose threads.
156 There are two pre-defined functions: `gnus-gather-threads-by-subject',
157 which only takes Subjects into consideration; and
158 `gnus-gather-threads-by-references', which compared the References
159 headers of the articles to find matches."
161 :type '(radio (function-item gnus-gather-threads-by-subject)
162 (function-item gnus-gather-threads-by-references)
163 (function :tag "other")))
165 (defcustom gnus-summary-same-subject ""
166 "*String indicating that the current article has the same subject as the previous.
167 This variable will only be used if the value of
168 `gnus-summary-make-false-root' is `empty'."
169 :group 'gnus-summary-format
172 (defcustom gnus-summary-goto-unread t
173 "*If t, many commands will go to the next unread article.
174 This applies to marking commands as well as other commands that
175 \"naturally\" select the next article, like, for instance, `SPC' at
176 the end of an article.
178 If nil, the marking commands do NOT go to the next unread article
179 (they go to the next article instead). If `never', commands that
180 usually go to the next unread article, will go to the next article,
181 whether it is read or not."
182 :group 'gnus-summary-marks
183 :link '(custom-manual "(gnus)Setting Marks")
184 :type '(choice (const :tag "off" nil)
186 (sexp :menu-tag "on" t)))
188 (defcustom gnus-summary-default-score 0
189 "*Default article score level.
190 All scores generated by the score files will be added to this score.
191 If this variable is nil, scoring will be disabled."
192 :group 'gnus-score-default
193 :type '(choice (const :tag "disable")
196 (defcustom gnus-summary-zcore-fuzz 0
197 "*Fuzziness factor for the zcore in the summary buffer.
198 Articles with scores closer than this to `gnus-summary-default-score'
200 :group 'gnus-summary-format
203 (defcustom gnus-simplify-subject-fuzzy-regexp nil
204 "*Strings to be removed when doing fuzzy matches.
205 This can either be a regular expression or list of regular expressions
206 that will be removed from subject strings if fuzzy subject
207 simplification is selected."
209 :type '(repeat regexp))
211 (defcustom gnus-show-threads t
212 "*If non-nil, display threads in summary mode."
216 (defcustom gnus-thread-hide-subtree nil
217 "*If non-nil, hide all threads initially.
218 If threads are hidden, you have to run the command
219 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
220 to expose hidden threads."
224 (defcustom gnus-thread-hide-killed t
225 "*If non-nil, hide killed threads automatically."
229 (defcustom gnus-thread-ignore-subject t
230 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
231 If nil, articles that have different subjects from their parents will
232 start separate threads."
236 (defcustom gnus-thread-operation-ignore-subject t
237 "*If non-nil, subjects will be ignored when doing thread commands.
238 This affects commands like `gnus-summary-kill-thread' and
239 `gnus-summary-lower-thread'.
241 If this variable is nil, articles in the same thread with different
242 subjects will not be included in the operation in question. If this
243 variable is `fuzzy', only articles that have subjects that are fuzzily
244 equal will be included."
246 :type '(choice (const :tag "off" nil)
250 (defcustom gnus-thread-indent-level 4
251 "*Number that says how much each sub-thread should be indented."
255 (defcustom gnus-auto-extend-newsgroup t
256 "*If non-nil, extend newsgroup forward and backward when requested."
257 :group 'gnus-summary-choose
260 (defcustom gnus-auto-select-first t
261 "*If nil, don't select the first unread article when entering a group.
262 If this variable is `best', select the highest-scored unread article
263 in the group. If t, select the first unread article.
265 This variable can also be a function to place point on a likely
266 subject line. Useful values include `gnus-summary-first-unread-subject',
267 `gnus-summary-first-unread-article' and
268 `gnus-summary-best-unread-article'.
270 If you want to prevent automatic selection of the first unread article
271 in some newsgroups, set the variable to nil in
272 `gnus-select-group-hook'."
273 :group 'gnus-group-select
274 :type '(choice (const :tag "none" nil)
276 (sexp :menu-tag "first" t)
277 (function-item gnus-summary-first-unread-subject)
278 (function-item gnus-summary-first-unread-article)
279 (function-item gnus-summary-best-unread-article)))
281 (defcustom gnus-auto-select-next t
282 "*If non-nil, offer to go to the next group from the end of the previous.
283 If the value is t and the next newsgroup is empty, Gnus will exit
284 summary mode and go back to group mode. If the value is neither nil
285 nor t, Gnus will select the following unread newsgroup. In
286 particular, if the value is the symbol `quietly', the next unread
287 newsgroup will be selected without any confirmation, and if it is
288 `almost-quietly', the next group will be selected without any
289 confirmation if you are located on the last article in the group.
290 Finally, if this variable is `slightly-quietly', the `Z n' command
291 will go to the next group without confirmation."
292 :group 'gnus-summary-maneuvering
293 :type '(choice (const :tag "off" nil)
295 (const almost-quietly)
296 (const slightly-quietly)
297 (sexp :menu-tag "on" t)))
299 (defcustom gnus-auto-select-same nil
300 "*If non-nil, select the next article with the same subject.
301 If there are no more articles with the same subject, go to
302 the first unread article."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-summary-check-current nil
307 "*If non-nil, consider the current article when moving.
308 The \"unread\" movement commands will stay on the same line if the
309 current article is unread."
310 :group 'gnus-summary-maneuvering
313 (defcustom gnus-auto-center-summary t
314 "*If non-nil, always center the current summary buffer.
315 In particular, if `vertical' do only vertical recentering. If non-nil
316 and non-`vertical', do both horizontal and vertical recentering."
317 :group 'gnus-summary-maneuvering
318 :type '(choice (const :tag "none" nil)
320 (integer :tag "height")
321 (sexp :menu-tag "both" t)))
323 (defcustom gnus-show-all-headers nil
324 "*If non-nil, don't hide any headers."
325 :group 'gnus-article-hiding
326 :group 'gnus-article-headers
329 (defcustom gnus-summary-ignore-duplicates nil
330 "*If non-nil, ignore articles with identical Message-ID headers."
334 (defcustom gnus-single-article-buffer t
335 "*If non-nil, display all articles in the same buffer.
336 If nil, each group will get its own article buffer."
337 :group 'gnus-article-various
340 (defcustom gnus-break-pages t
341 "*If non-nil, do page breaking on articles.
342 The page delimiter is specified by the `gnus-page-delimiter'
344 :group 'gnus-article-various
347 (defcustom gnus-move-split-methods nil
348 "*Variable used to suggest where articles are to be moved to.
349 It uses the same syntax as the `gnus-split-methods' variable.
350 However, whereas `gnus-split-methods' specifies file names as targets,
351 this variable specifies group names."
352 :group 'gnus-summary-mail
353 :type '(repeat (choice (list :value (fun) function)
354 (cons :value ("" "") regexp (repeat string))
357 (defcustom gnus-unread-mark ? ;Whitespace
358 "*Mark used for unread articles."
359 :group 'gnus-summary-marks
362 (defcustom gnus-ticked-mark ?!
363 "*Mark used for ticked articles."
364 :group 'gnus-summary-marks
367 (defcustom gnus-dormant-mark ??
368 "*Mark used for dormant articles."
369 :group 'gnus-summary-marks
372 (defcustom gnus-del-mark ?r
373 "*Mark used for del'd articles."
374 :group 'gnus-summary-marks
377 (defcustom gnus-read-mark ?R
378 "*Mark used for read articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-expirable-mark ?E
383 "*Mark used for expirable articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-killed-mark ?K
388 "*Mark used for killed articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-souped-mark ?F
393 "*Mark used for killed articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-kill-file-mark ?X
398 "*Mark used for articles killed by kill files."
399 :group 'gnus-summary-marks
402 (defcustom gnus-low-score-mark ?Y
403 "*Mark used for articles with a low score."
404 :group 'gnus-summary-marks
407 (defcustom gnus-catchup-mark ?C
408 "*Mark used for articles that are caught up."
409 :group 'gnus-summary-marks
412 (defcustom gnus-replied-mark ?A
413 "*Mark used for articles that have been replied to."
414 :group 'gnus-summary-marks
417 (defcustom gnus-cached-mark ?*
418 "*Mark used for articles that are in the cache."
419 :group 'gnus-summary-marks
422 (defcustom gnus-saved-mark ?S
423 "*Mark used for articles that have been saved to."
424 :group 'gnus-summary-marks
427 (defcustom gnus-ancient-mark ?O
428 "*Mark used for ancient articles."
429 :group 'gnus-summary-marks
432 (defcustom gnus-sparse-mark ?Q
433 "*Mark used for sparsely reffed articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-canceled-mark ?G
438 "*Mark used for canceled articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-duplicate-mark ?M
443 "*Mark used for duplicate articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-undownloaded-mark ?@
448 "*Mark used for articles that weren't downloaded."
449 :group 'gnus-summary-marks
452 (defcustom gnus-downloadable-mark ?%
453 "*Mark used for articles that are to be downloaded."
454 :group 'gnus-summary-marks
457 (defcustom gnus-unsendable-mark ?=
458 "*Mark used for articles that won't be sent."
459 :group 'gnus-summary-marks
462 (defcustom gnus-score-over-mark ?+
463 "*Score mark used for articles with high scores."
464 :group 'gnus-summary-marks
467 (defcustom gnus-score-below-mark ?-
468 "*Score mark used for articles with low scores."
469 :group 'gnus-summary-marks
472 (defcustom gnus-empty-thread-mark ? ;Whitespace
473 "*There is no thread under the article."
474 :group 'gnus-summary-marks
477 (defcustom gnus-not-empty-thread-mark ?=
478 "*There is a thread under the article."
479 :group 'gnus-summary-marks
482 (defcustom gnus-view-pseudo-asynchronously nil
483 "*If non-nil, Gnus will view pseudo-articles asynchronously."
484 :group 'gnus-extract-view
487 (defcustom gnus-auto-expirable-marks
488 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
489 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
490 gnus-souped-mark gnus-duplicate-mark)
491 "*The list of marks converted into expiration if a group is auto-expirable."
493 :type '(repeat character))
495 (defcustom gnus-inhibit-user-auto-expire t
496 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
500 (defcustom gnus-view-pseudos nil
501 "*If `automatic', pseudo-articles will be viewed automatically.
502 If `not-confirm', pseudos will be viewed automatically, and the user
503 will not be asked to confirm the command."
504 :group 'gnus-extract-view
505 :type '(choice (const :tag "off" nil)
507 (const not-confirm)))
509 (defcustom gnus-view-pseudos-separately t
510 "*If non-nil, one pseudo-article will be created for each file to be viewed.
511 If nil, all files that use the same viewing command will be given as a
512 list of parameters to that command."
513 :group 'gnus-extract-view
516 (defcustom gnus-insert-pseudo-articles t
517 "*If non-nil, insert pseudo-articles when decoding articles."
518 :group 'gnus-extract-view
521 (defcustom gnus-summary-dummy-line-format
523 "*The format specification for the dummy roots in the summary buffer.
524 It works along the same lines as a normal formatting string,
525 with some simple extensions.
528 :group 'gnus-threading
531 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
532 "*The format specification for the summary mode line.
533 It works along the same lines as a normal formatting string,
534 with some simple extensions:
537 %p Unprefixed group name
538 %A Current article number
539 %z Current article score
541 %U Number of unread articles in the group
542 %e Number of unselected articles in the group
543 %Z A string with unread/unselected article counts
544 %g Shortish group name
545 %S Subject of the current article
547 %s Current score file name
548 %d Number of dormant articles
549 %r Number of articles that have been marked as read in this session
550 %E Number of articles expunged by the score files"
551 :group 'gnus-summary-format
554 (defcustom gnus-list-identifiers nil
555 "Regexp that matches list identifiers to be removed from subject.
556 This can also be a list of regexps."
557 :group 'gnus-summary-format
558 :group 'gnus-article-hiding
559 :type '(choice (const :tag "none" nil)
561 (repeat :value (".*") regexp)))
563 (defcustom gnus-summary-mark-below 0
564 "*Mark all articles with a score below this variable as read.
565 This variable is local to each summary buffer and usually set by the
567 :group 'gnus-score-default
570 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
571 "*List of functions used for sorting articles in the summary buffer.
572 This variable is only used when not using a threaded display."
573 :group 'gnus-summary-sort
574 :type '(repeat (choice (function-item gnus-article-sort-by-number)
575 (function-item gnus-article-sort-by-author)
576 (function-item gnus-article-sort-by-subject)
577 (function-item gnus-article-sort-by-date)
578 (function-item gnus-article-sort-by-score)
579 (function :tag "other"))))
581 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
582 "*List of functions used for sorting threads in the summary buffer.
583 By default, threads are sorted by article number.
585 Each function takes two threads and return non-nil if the first thread
586 should be sorted before the other. If you use more than one function,
587 the primary sort function should be the last. You should probably
588 always include `gnus-thread-sort-by-number' in the list of sorting
589 functions -- preferably first.
591 Ready-made functions include `gnus-thread-sort-by-number',
592 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
593 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
594 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
595 :group 'gnus-summary-sort
596 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
597 (function-item gnus-thread-sort-by-author)
598 (function-item gnus-thread-sort-by-subject)
599 (function-item gnus-thread-sort-by-date)
600 (function-item gnus-thread-sort-by-score)
601 (function-item gnus-thread-sort-by-total-score)
602 (function :tag "other"))))
604 (defcustom gnus-thread-score-function '+
605 "*Function used for calculating the total score of a thread.
607 The function is called with the scores of the article and each
608 subthread and should then return the score of the thread.
610 Some functions you can use are `+', `max', or `min'."
611 :group 'gnus-summary-sort
614 (defcustom gnus-summary-expunge-below nil
615 "All articles that have a score less than this variable will be expunged.
616 This variable is local to the summary buffers."
617 :group 'gnus-score-default
618 :type '(choice (const :tag "off" nil)
621 (defcustom gnus-thread-expunge-below nil
622 "All threads that have a total score less than this variable will be expunged.
623 See `gnus-thread-score-function' for en explanation of what a
626 This variable is local to the summary buffers."
627 :group 'gnus-threading
628 :group 'gnus-score-default
629 :type '(choice (const :tag "off" nil)
632 (defcustom gnus-summary-mode-hook nil
633 "*A hook for Gnus summary mode.
634 This hook is run before any variables are set in the summary buffer."
635 :group 'gnus-summary-various
638 (defcustom gnus-summary-menu-hook nil
639 "*Hook run after the creation of the summary mode menu."
640 :group 'gnus-summary-visual
643 (defcustom gnus-summary-exit-hook nil
644 "*A hook called on exit from the summary buffer.
645 It will be called with point in the group buffer."
646 :group 'gnus-summary-exit
649 (defcustom gnus-summary-prepare-hook nil
650 "*A hook called after the summary buffer has been generated.
651 If you want to modify the summary buffer, you can use this hook."
652 :group 'gnus-summary-various
655 (defcustom gnus-summary-prepared-hook nil
656 "*A hook called as the last thing after the summary buffer has been generated."
657 :group 'gnus-summary-various
660 (defcustom gnus-summary-generate-hook nil
661 "*A hook run just before generating the summary buffer.
662 This hook is commonly used to customize threading variables and the
664 :group 'gnus-summary-various
667 (defcustom gnus-select-group-hook nil
668 "*A hook called when a newsgroup is selected.
670 If you'd like to simplify subjects like the
671 `gnus-summary-next-same-subject' command does, you can use the
674 (setq gnus-select-group-hook
677 (mapcar (lambda (header)
678 (mail-header-set-subject
680 (gnus-simplify-subject
681 (mail-header-subject header) 're-only)))
682 gnus-newsgroup-headers))))"
683 :group 'gnus-group-select
686 (defcustom gnus-select-article-hook nil
687 "*A hook called when an article is selected."
688 :group 'gnus-summary-choose
691 (defcustom gnus-visual-mark-article-hook
692 (list 'gnus-highlight-selected-summary)
693 "*Hook run after selecting an article in the summary buffer.
694 It is meant to be used for highlighting the article in some way. It
695 is not run if `gnus-visual' is nil."
696 :group 'gnus-summary-visual
699 (defcustom gnus-parse-headers-hook nil
700 "*A hook called before parsing the headers."
704 (defcustom gnus-exit-group-hook nil
705 "*A hook called when exiting summary mode.
706 This hook is not called from the non-updating exit commands like `Q'."
710 (defcustom gnus-summary-update-hook
711 (list 'gnus-summary-highlight-line)
712 "*A hook called when a summary line is changed.
713 The hook will not be called if `gnus-visual' is nil.
715 The default function `gnus-summary-highlight-line' will
716 highlight the line according to the `gnus-summary-highlight'
718 :group 'gnus-summary-visual
721 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
722 "*A hook called when an article is selected for the first time.
723 The hook is intended to mark an article as read (or unread)
724 automatically when it is selected."
725 :group 'gnus-summary-choose
728 (defcustom gnus-group-no-more-groups-hook nil
729 "*A hook run when returning to group mode having no more (unread) groups."
730 :group 'gnus-group-select
733 (defcustom gnus-ps-print-hook nil
734 "*A hook run before ps-printing something from Gnus."
738 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
739 "Face used for highlighting the current article in the summary buffer."
740 :group 'gnus-summary-visual
743 (defcustom gnus-summary-highlight
744 '(((= mark gnus-canceled-mark)
745 . gnus-summary-cancelled-face)
746 ((and (> score default)
747 (or (= mark gnus-dormant-mark)
748 (= mark gnus-ticked-mark)))
749 . gnus-summary-high-ticked-face)
750 ((and (< score default)
751 (or (= mark gnus-dormant-mark)
752 (= mark gnus-ticked-mark)))
753 . gnus-summary-low-ticked-face)
754 ((or (= mark gnus-dormant-mark)
755 (= mark gnus-ticked-mark))
756 . gnus-summary-normal-ticked-face)
757 ((and (> score default) (= mark gnus-ancient-mark))
758 . gnus-summary-high-ancient-face)
759 ((and (< score default) (= mark gnus-ancient-mark))
760 . gnus-summary-low-ancient-face)
761 ((= mark gnus-ancient-mark)
762 . gnus-summary-normal-ancient-face)
763 ((and (> score default) (= mark gnus-unread-mark))
764 . gnus-summary-high-unread-face)
765 ((and (< score default) (= mark gnus-unread-mark))
766 . gnus-summary-low-unread-face)
767 ((= mark gnus-unread-mark)
768 . gnus-summary-normal-unread-face)
769 ((and (> score default) (memq mark (list gnus-downloadable-mark
770 gnus-undownloaded-mark)))
771 . gnus-summary-high-unread-face)
772 ((and (< score default) (memq mark (list gnus-downloadable-mark
773 gnus-undownloaded-mark)))
774 . gnus-summary-low-unread-face)
775 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
776 . gnus-summary-normal-unread-face)
778 . gnus-summary-high-read-face)
780 . gnus-summary-low-read-face)
782 . gnus-summary-normal-read-face))
783 "*Controls the highlighting of summary buffer lines.
785 A list of (FORM . FACE) pairs. When deciding how a a particular
786 summary line should be displayed, each form is evaluated. The content
787 of the face field after the first true form is used. You can change
788 how those summary lines are displayed, by editing the face field.
790 You can use the following variables in the FORM field.
792 score: The articles score
793 default: The default article score.
794 below: The score below which articles are automatically marked as read.
795 mark: The articles mark."
796 :group 'gnus-summary-visual
797 :type '(repeat (cons (sexp :tag "Form" nil)
800 (defcustom gnus-alter-header-function nil
801 "Function called to allow alteration of article header structures.
802 The function is called with one parameter, the article header vector,
803 which it may alter in any way.")
805 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
806 "Variable that says which function should be used to decode a string with encoded words.")
808 (defcustom gnus-extra-headers nil
809 "*Extra headers to parse."
811 :type '(repeat symbol))
813 (defcustom gnus-ignored-from-addresses
814 (and user-mail-address (regexp-quote user-mail-address))
815 "*Regexp of From headers that may be suppressed in favor of To headers."
819 (defcustom gnus-group-charset-alist
820 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
821 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
822 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
823 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
824 ("^relcom\\>" koi8-r)
826 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
827 ("^israel\\>" iso-8859-1)
829 ("^alt.chinese.text.big5\\>" chinese-big5)
830 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
831 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
833 "Alist of regexps (to match group names) and default charsets to be used when reading."
834 :type '(repeat (list (regexp :tag "Group")
835 (symbol :tag "Charset")))
836 :group 'gnus-charset)
838 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
839 "List of charsets that should be ignored.
840 When these charsets are used in the \"charset\" parameter, the
841 default charset will be used instead."
842 :type '(repeat symbol)
843 :group 'gnus-charset)
845 (defcustom gnus-group-ignored-charsets-alist
846 '(("alt\\.chinese\\.text" iso-8859-1))
847 "Alist of regexps (to match group names) and charsets that should be ignored.
848 When these charsets are used in the \"charset\" parameter, the
849 default charset will be used instead."
850 :type '(repeat (cons (regexp :tag "Group")
852 :group 'gnus-charset)
854 (defcustom gnus-group-highlight-words-alist nil
855 "Alist of group regexps and highlight regexps.
856 This variable uses the same syntax as `gnus-emphasis-alist'."
857 :type '(repeat (cons (regexp :tag "Group")
858 (repeat (list (regexp :tag "Highlight regexp")
859 (number :tag "Group for entire word" 0)
860 (number :tag "Group for displayed part" 0)
862 gnus-emphasis-highlight-words)))))
863 :group 'gnus-summary-visual)
865 (defcustom gnus-summary-show-article-charset-alist
867 "Alist of number and charset.
868 The article will be shown with the charset corresponding to the
870 For example: ((1 . cn-gb-2312) (2 . big5))."
871 :type '(repeat (cons (number :tag "Argument" 1)
872 (symbol :tag "Charset")))
873 :group 'gnus-charset)
875 (defcustom gnus-preserve-marks t
876 "Whether marks are preserved when moving, copying and respooling messages."
878 :group 'gnus-summary-marks)
880 (defcustom gnus-alter-articles-to-read-function nil
881 "Function to be called to alter the list of articles to be selected."
883 :group 'gnus-summary)
885 (defcustom gnus-orphan-score nil
886 "*All orphans get this score added. Set in the score file."
887 :group 'gnus-score-default
888 :type '(choice (const nil)
891 (defcustom gnus-summary-save-parts-default-mime "image/.*"
892 "*A regexp to match MIME parts when saving multiple parts of a message
893 with gnus-summary-save-parts (X m). This regexp will be used by default
894 when prompting the user for which type of files to save."
899 ;;; Internal variables
901 (defvar gnus-article-mime-handles nil)
902 (defvar gnus-article-decoded-p nil)
903 (defvar gnus-article-charset nil)
904 (defvar gnus-article-ignored-charsets nil)
905 (defvar gnus-scores-exclude-files nil)
906 (defvar gnus-page-broken nil)
907 (defvar gnus-inhibit-mime-unbuttonizing nil)
909 (defvar gnus-original-article nil)
910 (defvar gnus-article-internal-prepare-hook nil)
911 (defvar gnus-newsgroup-process-stack nil)
913 (defvar gnus-thread-indent-array nil)
914 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
915 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
916 "Function called to sort the articles within a thread after it has been gathered together.")
918 (defvar gnus-summary-save-parts-type-history nil)
919 (defvar gnus-summary-save-parts-last-directory nil)
921 ;; Avoid highlighting in kill files.
922 (defvar gnus-summary-inhibit-highlight nil)
923 (defvar gnus-newsgroup-selected-overlay nil)
924 (defvar gnus-inhibit-limiting nil)
925 (defvar gnus-newsgroup-adaptive-score-file nil)
926 (defvar gnus-current-score-file nil)
927 (defvar gnus-current-move-group nil)
928 (defvar gnus-current-copy-group nil)
929 (defvar gnus-current-crosspost-group nil)
931 (defvar gnus-newsgroup-dependencies nil)
932 (defvar gnus-newsgroup-adaptive nil)
933 (defvar gnus-summary-display-article-function nil)
934 (defvar gnus-summary-highlight-line-function nil
935 "Function called after highlighting a summary line.")
937 (defvar gnus-summary-line-format-alist
938 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
939 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
940 (?s gnus-tmp-subject-or-nil ?s)
941 (?n gnus-tmp-name ?s)
942 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
944 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
946 (?F gnus-tmp-from ?s)
947 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
948 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
949 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
950 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
951 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
952 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
953 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
954 (?L gnus-tmp-lines ?d)
955 (?I gnus-tmp-indentation ?s)
956 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
957 (?R gnus-tmp-replied ?c)
958 (?\[ gnus-tmp-opening-bracket ?c)
959 (?\] gnus-tmp-closing-bracket ?c)
960 (?\> (make-string gnus-tmp-level ? ) ?s)
961 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
962 (?i gnus-tmp-score ?d)
963 (?z gnus-tmp-score-char ?c)
964 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
965 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
966 (?U gnus-tmp-unread ?c)
967 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
968 (?t (gnus-summary-number-of-articles-in-thread
969 (and (boundp 'thread) (car thread)) gnus-tmp-level)
971 (?e (gnus-summary-number-of-articles-in-thread
972 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
974 (?u gnus-tmp-user-defined ?s)
975 (?P (gnus-pick-line-number) ?d))
976 "An alist of format specifications that can appear in summary lines.
977 These are paired with what variables they correspond with, along with
978 the type of the variable (string, integer, character, etc).")
980 (defvar gnus-summary-dummy-line-format-alist
981 `((?S gnus-tmp-subject ?s)
982 (?N gnus-tmp-number ?d)
983 (?u gnus-tmp-user-defined ?s)))
985 (defvar gnus-summary-mode-line-format-alist
986 `((?G gnus-tmp-group-name ?s)
987 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
988 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
989 (?A gnus-tmp-article-number ?d)
990 (?Z gnus-tmp-unread-and-unselected ?s)
992 (?U gnus-tmp-unread-and-unticked ?d)
993 (?S gnus-tmp-subject ?s)
994 (?e gnus-tmp-unselected ?d)
995 (?u gnus-tmp-user-defined ?s)
996 (?d (length gnus-newsgroup-dormant) ?d)
997 (?t (length gnus-newsgroup-marked) ?d)
998 (?r (length gnus-newsgroup-reads) ?d)
999 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1000 (?E gnus-newsgroup-expunged-tally ?d)
1001 (?s (gnus-current-score-file-nondirectory) ?s)))
1003 (defvar gnus-last-search-regexp nil
1004 "Default regexp for article search command.")
1006 (defvar gnus-last-shell-command nil
1007 "Default shell command on article.")
1009 (defvar gnus-newsgroup-begin nil)
1010 (defvar gnus-newsgroup-end nil)
1011 (defvar gnus-newsgroup-last-rmail nil)
1012 (defvar gnus-newsgroup-last-mail nil)
1013 (defvar gnus-newsgroup-last-folder nil)
1014 (defvar gnus-newsgroup-last-file nil)
1015 (defvar gnus-newsgroup-auto-expire nil)
1016 (defvar gnus-newsgroup-active nil)
1018 (defvar gnus-newsgroup-data nil)
1019 (defvar gnus-newsgroup-data-reverse nil)
1020 (defvar gnus-newsgroup-limit nil)
1021 (defvar gnus-newsgroup-limits nil)
1023 (defvar gnus-newsgroup-unreads nil
1024 "List of unread articles in the current newsgroup.")
1026 (defvar gnus-newsgroup-unselected nil
1027 "List of unselected unread articles in the current newsgroup.")
1029 (defvar gnus-newsgroup-reads nil
1030 "Alist of read articles and article marks in the current newsgroup.")
1032 (defvar gnus-newsgroup-expunged-tally nil)
1034 (defvar gnus-newsgroup-marked nil
1035 "List of ticked articles in the current newsgroup (a subset of unread art).")
1037 (defvar gnus-newsgroup-killed nil
1038 "List of ranges of articles that have been through the scoring process.")
1040 (defvar gnus-newsgroup-cached nil
1041 "List of articles that come from the article cache.")
1043 (defvar gnus-newsgroup-saved nil
1044 "List of articles that have been saved.")
1046 (defvar gnus-newsgroup-kill-headers nil)
1048 (defvar gnus-newsgroup-replied nil
1049 "List of articles that have been replied to in the current newsgroup.")
1051 (defvar gnus-newsgroup-expirable nil
1052 "List of articles in the current newsgroup that can be expired.")
1054 (defvar gnus-newsgroup-processable nil
1055 "List of articles in the current newsgroup that can be processed.")
1057 (defvar gnus-newsgroup-downloadable nil
1058 "List of articles in the current newsgroup that can be processed.")
1060 (defvar gnus-newsgroup-undownloaded nil
1061 "List of articles in the current newsgroup that haven't been downloaded..")
1063 (defvar gnus-newsgroup-unsendable nil
1064 "List of articles in the current newsgroup that won't be sent.")
1066 (defvar gnus-newsgroup-bookmarks nil
1067 "List of articles in the current newsgroup that have bookmarks.")
1069 (defvar gnus-newsgroup-dormant nil
1070 "List of dormant articles in the current newsgroup.")
1072 (defvar gnus-newsgroup-scored nil
1073 "List of scored articles in the current newsgroup.")
1075 (defvar gnus-newsgroup-headers nil
1076 "List of article headers in the current newsgroup.")
1078 (defvar gnus-newsgroup-threads nil)
1080 (defvar gnus-newsgroup-prepared nil
1081 "Whether the current group has been prepared properly.")
1083 (defvar gnus-newsgroup-ancient nil
1084 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1086 (defvar gnus-newsgroup-sparse nil)
1088 (defvar gnus-current-article nil)
1089 (defvar gnus-article-current nil)
1090 (defvar gnus-current-headers nil)
1091 (defvar gnus-have-all-headers nil)
1092 (defvar gnus-last-article nil)
1093 (defvar gnus-newsgroup-history nil)
1094 (defvar gnus-newsgroup-charset nil)
1095 (defvar gnus-newsgroup-ephemeral-charset nil)
1096 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1098 (defvar gnus-article-before-search nil)
1100 (defconst gnus-summary-local-variables
1101 '(gnus-newsgroup-name
1102 gnus-newsgroup-begin gnus-newsgroup-end
1103 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1104 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1105 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1106 gnus-newsgroup-unselected gnus-newsgroup-marked
1107 gnus-newsgroup-reads gnus-newsgroup-saved
1108 gnus-newsgroup-replied gnus-newsgroup-expirable
1109 gnus-newsgroup-processable gnus-newsgroup-killed
1110 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1111 gnus-newsgroup-unsendable
1112 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1113 gnus-newsgroup-headers gnus-newsgroup-threads
1114 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1115 gnus-current-article gnus-current-headers gnus-have-all-headers
1116 gnus-last-article gnus-article-internal-prepare-hook
1117 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1118 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1119 gnus-thread-expunge-below
1120 gnus-score-alist gnus-current-score-file
1121 (gnus-summary-expunge-below . global)
1122 (gnus-summary-mark-below . global)
1123 (gnus-orphan-score . global)
1124 gnus-newsgroup-active gnus-scores-exclude-files
1125 gnus-newsgroup-history gnus-newsgroup-ancient
1126 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1127 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1128 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1129 (gnus-newsgroup-expunged-tally . 0)
1130 gnus-cache-removable-articles gnus-newsgroup-cached
1131 gnus-newsgroup-data gnus-newsgroup-data-reverse
1132 gnus-newsgroup-limit gnus-newsgroup-limits
1133 gnus-newsgroup-charset)
1134 "Variables that are buffer-local to the summary buffers.")
1136 (defvar gnus-newsgroup-variables nil
1137 "Variables that have separate values in the newsgroups.")
1139 ;; Byte-compiler warning.
1140 (defvar gnus-article-mode-map)
1144 (defvar gnus-decode-encoded-word-methods
1145 '(mail-decode-encoded-word-string)
1146 "List of methods used to decode encoded words.
1148 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1149 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1150 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1151 whose names match REGEXP.
1154 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1155 mail-decode-encoded-word-string
1156 (\"chinese\" . rfc1843-decode-string))")
1158 (defvar gnus-decode-encoded-word-methods-cache nil)
1160 (defun gnus-multi-decode-encoded-word-string (string)
1161 "Apply the functions from `gnus-encoded-word-methods' that match."
1162 (unless (and gnus-decode-encoded-word-methods-cache
1163 (eq gnus-newsgroup-name
1164 (car gnus-decode-encoded-word-methods-cache)))
1165 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1168 (nconc gnus-decode-encoded-word-methods-cache (list x))
1169 (if (and gnus-newsgroup-name
1170 (string-match (car x) gnus-newsgroup-name))
1171 (nconc gnus-decode-encoded-word-methods-cache
1173 gnus-decode-encoded-word-methods))
1174 (let ((xlist gnus-decode-encoded-word-methods-cache))
1177 (setq string (funcall (pop xlist) string))))
1180 ;; Subject simplification.
1182 (defun gnus-simplify-whitespace (str)
1183 "Remove excessive whitespace from STR."
1186 (while (string-match "[ \t][ \t]+" mystr)
1187 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1189 (substring mystr (match-end 0)))))
1191 (when (string-match "^[ \t]+" mystr)
1192 (setq mystr (substring mystr (match-end 0))))
1194 (when (string-match "[ \t]+$" mystr)
1195 (setq mystr (substring mystr 0 (match-beginning 0))))
1198 (defsubst gnus-simplify-subject-re (subject)
1199 "Remove \"Re:\" from subject lines."
1200 (if (string-match "^[Rr][Ee]: *" subject)
1201 (substring subject (match-end 0))
1204 (defun gnus-simplify-subject (subject &optional re-only)
1205 "Remove `Re:' and words in parentheses.
1206 If RE-ONLY is non-nil, strip leading `Re:'s only."
1207 (let ((case-fold-search t)) ;Ignore case.
1208 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1209 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1210 (setq subject (substring subject (match-end 0))))
1211 ;; Remove uninteresting prefixes.
1212 (when (and (not re-only)
1213 gnus-simplify-ignored-prefixes
1214 (string-match gnus-simplify-ignored-prefixes subject))
1215 (setq subject (substring subject (match-end 0))))
1216 ;; Remove words in parentheses from end.
1218 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1219 (setq subject (substring subject 0 (match-beginning 0)))))
1220 ;; Return subject string.
1223 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1225 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1226 (goto-char (point-min))
1227 (while (re-search-forward regexp nil t)
1228 (replace-match (or newtext ""))))
1230 (defun gnus-simplify-buffer-fuzzy ()
1231 "Simplify string in the buffer fuzzily.
1232 The string in the accessible portion of the current buffer is simplified.
1233 It is assumed to be a single-line subject.
1234 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1235 matter is removed. Additional things can be deleted by setting
1236 `gnus-simplify-subject-fuzzy-regexp'."
1237 (let ((case-fold-search t)
1239 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1241 (while (not (eq modified-tick (buffer-modified-tick)))
1242 (setq modified-tick (buffer-modified-tick))
1244 ((listp gnus-simplify-subject-fuzzy-regexp)
1245 (mapcar 'gnus-simplify-buffer-fuzzy-step
1246 gnus-simplify-subject-fuzzy-regexp))
1247 (gnus-simplify-subject-fuzzy-regexp
1248 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1249 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1250 (gnus-simplify-buffer-fuzzy-step
1251 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1252 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1254 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1255 (gnus-simplify-buffer-fuzzy-step " +" " ")
1256 (gnus-simplify-buffer-fuzzy-step " $")
1257 (gnus-simplify-buffer-fuzzy-step "^ +")))
1259 (defun gnus-simplify-subject-fuzzy (subject)
1260 "Simplify a subject string fuzzily.
1261 See `gnus-simplify-buffer-fuzzy' for details."
1263 (gnus-set-work-buffer)
1264 (let ((case-fold-search t))
1265 ;; Remove uninteresting prefixes.
1266 (when (and gnus-simplify-ignored-prefixes
1267 (string-match gnus-simplify-ignored-prefixes subject))
1268 (setq subject (substring subject (match-end 0))))
1270 (inline (gnus-simplify-buffer-fuzzy))
1273 (defsubst gnus-simplify-subject-fully (subject)
1274 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1276 (gnus-simplify-subject-functions
1277 (gnus-map-function gnus-simplify-subject-functions subject))
1278 ((null gnus-summary-gather-subject-limit)
1279 (gnus-simplify-subject-re subject))
1280 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1281 (gnus-simplify-subject-fuzzy subject))
1282 ((numberp gnus-summary-gather-subject-limit)
1283 (gnus-limit-string (gnus-simplify-subject-re subject)
1284 gnus-summary-gather-subject-limit))
1288 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1289 "Check whether two subjects are equal.
1290 If optional argument simple-first is t, first argument is already
1293 ((null simple-first)
1294 (equal (gnus-simplify-subject-fully s1)
1295 (gnus-simplify-subject-fully s2)))
1298 (gnus-simplify-subject-fully s2)))))
1300 (defun gnus-summary-bubble-group ()
1301 "Increase the score of the current group.
1302 This is a handy function to add to `gnus-summary-exit-hook' to
1303 increase the score of each group you read."
1304 (gnus-group-add-score gnus-newsgroup-name))
1308 ;;; Gnus summary mode
1311 (put 'gnus-summary-mode 'mode-class 'special)
1314 ;; Non-orthogonal keys
1316 (gnus-define-keys gnus-summary-mode-map
1317 " " gnus-summary-next-page
1318 "\177" gnus-summary-prev-page
1319 [delete] gnus-summary-prev-page
1320 [backspace] gnus-summary-prev-page
1321 "\r" gnus-summary-scroll-up
1322 "\M-\r" gnus-summary-scroll-down
1323 "n" gnus-summary-next-unread-article
1324 "p" gnus-summary-prev-unread-article
1325 "N" gnus-summary-next-article
1326 "P" gnus-summary-prev-article
1327 "\M-\C-n" gnus-summary-next-same-subject
1328 "\M-\C-p" gnus-summary-prev-same-subject
1329 "\M-n" gnus-summary-next-unread-subject
1330 "\M-p" gnus-summary-prev-unread-subject
1331 "." gnus-summary-first-unread-article
1332 "," gnus-summary-best-unread-article
1333 "\M-s" gnus-summary-search-article-forward
1334 "\M-r" gnus-summary-search-article-backward
1335 "<" gnus-summary-beginning-of-article
1336 ">" gnus-summary-end-of-article
1337 "j" gnus-summary-goto-article
1338 "^" gnus-summary-refer-parent-article
1339 "\M-^" gnus-summary-refer-article
1340 "u" gnus-summary-tick-article-forward
1341 "!" gnus-summary-tick-article-forward
1342 "U" gnus-summary-tick-article-backward
1343 "d" gnus-summary-mark-as-read-forward
1344 "D" gnus-summary-mark-as-read-backward
1345 "E" gnus-summary-mark-as-expirable
1346 "\M-u" gnus-summary-clear-mark-forward
1347 "\M-U" gnus-summary-clear-mark-backward
1348 "k" gnus-summary-kill-same-subject-and-select
1349 "\C-k" gnus-summary-kill-same-subject
1350 "\M-\C-k" gnus-summary-kill-thread
1351 "\M-\C-l" gnus-summary-lower-thread
1352 "e" gnus-summary-edit-article
1353 "#" gnus-summary-mark-as-processable
1354 "\M-#" gnus-summary-unmark-as-processable
1355 "\M-\C-t" gnus-summary-toggle-threads
1356 "\M-\C-s" gnus-summary-show-thread
1357 "\M-\C-h" gnus-summary-hide-thread
1358 "\M-\C-f" gnus-summary-next-thread
1359 "\M-\C-b" gnus-summary-prev-thread
1360 [(meta down)] gnus-summary-next-thread
1361 [(meta up)] gnus-summary-prev-thread
1362 "\M-\C-u" gnus-summary-up-thread
1363 "\M-\C-d" gnus-summary-down-thread
1364 "&" gnus-summary-execute-command
1365 "c" gnus-summary-catchup-and-exit
1366 "\C-w" gnus-summary-mark-region-as-read
1367 "\C-t" gnus-summary-toggle-truncation
1368 "?" gnus-summary-mark-as-dormant
1369 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1370 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1371 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1372 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1373 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1374 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1375 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1376 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1377 "=" gnus-summary-expand-window
1378 "\C-x\C-s" gnus-summary-reselect-current-group
1379 "\M-g" gnus-summary-rescan-group
1380 "w" gnus-summary-stop-page-breaking
1381 "\C-c\C-r" gnus-summary-caesar-message
1382 "f" gnus-summary-followup
1383 "F" gnus-summary-followup-with-original
1384 "C" gnus-summary-cancel-article
1385 "r" gnus-summary-reply
1386 "R" gnus-summary-reply-with-original
1387 "\C-c\C-f" gnus-summary-mail-forward
1388 "o" gnus-summary-save-article
1389 "\C-o" gnus-summary-save-article-mail
1390 "|" gnus-summary-pipe-output
1391 "\M-k" gnus-summary-edit-local-kill
1392 "\M-K" gnus-summary-edit-global-kill
1394 "\C-c\C-d" gnus-summary-describe-group
1395 "q" gnus-summary-exit
1396 "Q" gnus-summary-exit-no-update
1397 "\C-c\C-i" gnus-info-find-node
1398 gnus-mouse-2 gnus-mouse-pick-article
1399 "m" gnus-summary-mail-other-window
1400 "a" gnus-summary-post-news
1401 "x" gnus-summary-limit-to-unread
1402 "s" gnus-summary-isearch-article
1403 "t" gnus-summary-toggle-header
1404 "g" gnus-summary-show-article
1405 "l" gnus-summary-goto-last-article
1406 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1407 "\C-d" gnus-summary-enter-digest-group
1408 "\M-\C-d" gnus-summary-read-document
1409 "\M-\C-e" gnus-summary-edit-parameters
1410 "\M-\C-a" gnus-summary-customize-parameters
1412 "*" gnus-cache-enter-article
1413 "\M-*" gnus-cache-remove-article
1414 "\M-&" gnus-summary-universal-argument
1415 "\C-l" gnus-recenter
1416 "I" gnus-summary-increase-score
1417 "L" gnus-summary-lower-score
1418 "\M-i" gnus-symbolic-argument
1419 "h" gnus-summary-select-article-buffer
1421 "b" gnus-article-view-part
1422 "\M-t" gnus-summary-toggle-display-buttonized
1424 "V" gnus-summary-score-map
1425 "X" gnus-uu-extract-map
1426 "S" gnus-summary-send-map)
1428 ;; Sort of orthogonal keymap
1429 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1430 "t" gnus-summary-tick-article-forward
1431 "!" gnus-summary-tick-article-forward
1432 "d" gnus-summary-mark-as-read-forward
1433 "r" gnus-summary-mark-as-read-forward
1434 "c" gnus-summary-clear-mark-forward
1435 " " gnus-summary-clear-mark-forward
1436 "e" gnus-summary-mark-as-expirable
1437 "x" gnus-summary-mark-as-expirable
1438 "?" gnus-summary-mark-as-dormant
1439 "b" gnus-summary-set-bookmark
1440 "B" gnus-summary-remove-bookmark
1441 "#" gnus-summary-mark-as-processable
1442 "\M-#" gnus-summary-unmark-as-processable
1443 "S" gnus-summary-limit-include-expunged
1444 "C" gnus-summary-catchup
1445 "H" gnus-summary-catchup-to-here
1446 "\C-c" gnus-summary-catchup-all
1447 "k" gnus-summary-kill-same-subject-and-select
1448 "K" gnus-summary-kill-same-subject
1449 "P" gnus-uu-mark-map)
1451 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1452 "c" gnus-summary-clear-above
1453 "u" gnus-summary-tick-above
1454 "m" gnus-summary-mark-above
1455 "k" gnus-summary-kill-below)
1457 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1458 "/" gnus-summary-limit-to-subject
1459 "n" gnus-summary-limit-to-articles
1460 "w" gnus-summary-pop-limit
1461 "s" gnus-summary-limit-to-subject
1462 "a" gnus-summary-limit-to-author
1463 "u" gnus-summary-limit-to-unread
1464 "m" gnus-summary-limit-to-marks
1465 "M" gnus-summary-limit-exclude-marks
1466 "v" gnus-summary-limit-to-score
1467 "*" gnus-summary-limit-include-cached
1468 "D" gnus-summary-limit-include-dormant
1469 "T" gnus-summary-limit-include-thread
1470 "d" gnus-summary-limit-exclude-dormant
1471 "t" gnus-summary-limit-to-age
1472 "x" gnus-summary-limit-to-extra
1473 "E" gnus-summary-limit-include-expunged
1474 "c" gnus-summary-limit-exclude-childless-dormant
1475 "C" gnus-summary-limit-mark-excluded-as-read)
1477 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1478 "n" gnus-summary-next-unread-article
1479 "p" gnus-summary-prev-unread-article
1480 "N" gnus-summary-next-article
1481 "P" gnus-summary-prev-article
1482 "\C-n" gnus-summary-next-same-subject
1483 "\C-p" gnus-summary-prev-same-subject
1484 "\M-n" gnus-summary-next-unread-subject
1485 "\M-p" gnus-summary-prev-unread-subject
1486 "f" gnus-summary-first-unread-article
1487 "b" gnus-summary-best-unread-article
1488 "j" gnus-summary-goto-article
1489 "g" gnus-summary-goto-subject
1490 "l" gnus-summary-goto-last-article
1491 "o" gnus-summary-pop-article)
1493 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1494 "k" gnus-summary-kill-thread
1495 "l" gnus-summary-lower-thread
1496 "i" gnus-summary-raise-thread
1497 "T" gnus-summary-toggle-threads
1498 "t" gnus-summary-rethread-current
1499 "^" gnus-summary-reparent-thread
1500 "s" gnus-summary-show-thread
1501 "S" gnus-summary-show-all-threads
1502 "h" gnus-summary-hide-thread
1503 "H" gnus-summary-hide-all-threads
1504 "n" gnus-summary-next-thread
1505 "p" gnus-summary-prev-thread
1506 "u" gnus-summary-up-thread
1507 "o" gnus-summary-top-thread
1508 "d" gnus-summary-down-thread
1509 "#" gnus-uu-mark-thread
1510 "\M-#" gnus-uu-unmark-thread)
1512 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1513 "g" gnus-summary-prepare
1514 "c" gnus-summary-insert-cached-articles)
1516 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1517 "c" gnus-summary-catchup-and-exit
1518 "C" gnus-summary-catchup-all-and-exit
1519 "E" gnus-summary-exit-no-update
1520 "Q" gnus-summary-exit
1521 "Z" gnus-summary-exit
1522 "n" gnus-summary-catchup-and-goto-next-group
1523 "R" gnus-summary-reselect-current-group
1524 "G" gnus-summary-rescan-group
1525 "N" gnus-summary-next-group
1526 "s" gnus-summary-save-newsrc
1527 "P" gnus-summary-prev-group)
1529 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1530 " " gnus-summary-next-page
1531 "n" gnus-summary-next-page
1532 "\177" gnus-summary-prev-page
1533 [delete] gnus-summary-prev-page
1534 "p" gnus-summary-prev-page
1535 "\r" gnus-summary-scroll-up
1536 "\M-\r" gnus-summary-scroll-down
1537 "<" gnus-summary-beginning-of-article
1538 ">" gnus-summary-end-of-article
1539 "b" gnus-summary-beginning-of-article
1540 "e" gnus-summary-end-of-article
1541 "^" gnus-summary-refer-parent-article
1542 "r" gnus-summary-refer-parent-article
1543 "D" gnus-summary-enter-digest-group
1544 "R" gnus-summary-refer-references
1545 "T" gnus-summary-refer-thread
1546 "g" gnus-summary-show-article
1547 "s" gnus-summary-isearch-article
1548 "P" gnus-summary-print-article
1549 "t" gnus-article-babel)
1551 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1552 "b" gnus-article-add-buttons
1553 "B" gnus-article-add-buttons-to-head
1554 "o" gnus-article-treat-overstrike
1555 "e" gnus-article-emphasize
1556 "w" gnus-article-fill-cited-article
1557 "Q" gnus-article-fill-long-lines
1558 "C" gnus-article-capitalize-sentences
1559 "c" gnus-article-remove-cr
1560 "q" gnus-article-de-quoted-unreadable
1561 "6" gnus-article-de-base64-unreadable
1562 "Z" gnus-article-decode-HZ
1563 "h" gnus-article-wash-html
1564 "s" gnus-summary-force-verify-and-decrypt
1565 "f" gnus-article-display-x-face
1566 "l" gnus-summary-stop-page-breaking
1567 "r" gnus-summary-caesar-message
1568 "t" gnus-summary-toggle-header
1569 "v" gnus-summary-verbose-headers
1570 "H" gnus-article-strip-headers-in-body
1571 "p" gnus-article-verify-x-pgp-sig
1572 "d" gnus-article-treat-dumbquotes)
1574 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1575 "a" gnus-article-hide
1576 "h" gnus-article-hide-headers
1577 "b" gnus-article-hide-boring-headers
1578 "s" gnus-article-hide-signature
1579 "c" gnus-article-hide-citation
1580 "C" gnus-article-hide-citation-in-followups
1581 "l" gnus-article-hide-list-identifiers
1582 "p" gnus-article-hide-pgp
1583 "B" gnus-article-strip-banner
1584 "P" gnus-article-hide-pem
1585 "\C-c" gnus-article-hide-citation-maybe)
1587 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1588 "a" gnus-article-highlight
1589 "h" gnus-article-highlight-headers
1590 "c" gnus-article-highlight-citation
1591 "s" gnus-article-highlight-signature)
1593 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1594 "w" gnus-article-decode-mime-words
1595 "c" gnus-article-decode-charset
1596 "v" gnus-mime-view-all-parts
1597 "b" gnus-article-view-part)
1599 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1600 "z" gnus-article-date-ut
1601 "u" gnus-article-date-ut
1602 "l" gnus-article-date-local
1603 "e" gnus-article-date-lapsed
1604 "o" gnus-article-date-original
1605 "i" gnus-article-date-iso8601
1606 "s" gnus-article-date-user)
1608 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1609 "t" gnus-article-remove-trailing-blank-lines
1610 "l" gnus-article-strip-leading-blank-lines
1611 "m" gnus-article-strip-multiple-blank-lines
1612 "a" gnus-article-strip-blank-lines
1613 "A" gnus-article-strip-all-blank-lines
1614 "s" gnus-article-strip-leading-space
1615 "e" gnus-article-strip-trailing-space)
1617 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1619 "f" gnus-summary-fetch-faq
1620 "d" gnus-summary-describe-group
1621 "h" gnus-summary-describe-briefly
1622 "i" gnus-info-find-node)
1624 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1625 "e" gnus-summary-expire-articles
1626 "\M-\C-e" gnus-summary-expire-articles-now
1627 "\177" gnus-summary-delete-article
1628 [delete] gnus-summary-delete-article
1629 [backspace] gnus-summary-delete-article
1630 "m" gnus-summary-move-article
1631 "r" gnus-summary-respool-article
1632 "w" gnus-summary-edit-article
1633 "c" gnus-summary-copy-article
1634 "B" gnus-summary-crosspost-article
1635 "q" gnus-summary-respool-query
1636 "t" gnus-summary-respool-trace
1637 "i" gnus-summary-import-article
1638 "p" gnus-summary-article-posted-p)
1640 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1641 "o" gnus-summary-save-article
1642 "m" gnus-summary-save-article-mail
1643 "F" gnus-summary-write-article-file
1644 "r" gnus-summary-save-article-rmail
1645 "f" gnus-summary-save-article-file
1646 "b" gnus-summary-save-article-body-file
1647 "h" gnus-summary-save-article-folder
1648 "v" gnus-summary-save-article-vm
1649 "p" gnus-summary-pipe-output
1650 "s" gnus-soup-add-article)
1652 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1653 "b" gnus-summary-display-buttonized
1654 "m" gnus-summary-repair-multipart
1655 "v" gnus-article-view-part
1656 "o" gnus-article-save-part
1657 "c" gnus-article-copy-part
1658 "C" gnus-article-view-part-as-charset
1659 "e" gnus-article-externalize-part
1660 "E" gnus-article-encrypt-body
1661 "i" gnus-article-inline-part
1662 "|" gnus-article-pipe-part))
1664 (defun gnus-summary-make-menu-bar ()
1665 (gnus-turn-off-edit-menu 'summary)
1667 (unless (boundp 'gnus-summary-misc-menu)
1670 gnus-summary-kill-menu gnus-summary-mode-map ""
1675 ["Enter score..." gnus-summary-score-entry t]
1676 ["Customize" gnus-score-customize t])
1677 (gnus-make-score-map 'increase)
1678 (gnus-make-score-map 'lower)
1680 ["Kill below" gnus-summary-kill-below t]
1681 ["Mark above" gnus-summary-mark-above t]
1682 ["Tick above" gnus-summary-tick-above t]
1683 ["Clear above" gnus-summary-clear-above t])
1684 ["Current score" gnus-summary-current-score t]
1685 ["Set score" gnus-summary-set-score t]
1686 ["Switch current score file..." gnus-score-change-score-file t]
1687 ["Set mark below..." gnus-score-set-mark-below t]
1688 ["Set expunge below..." gnus-score-set-expunge-below t]
1689 ["Edit current score file" gnus-score-edit-current-scores t]
1690 ["Edit score file" gnus-score-edit-file t]
1691 ["Trace score" gnus-score-find-trace t]
1692 ["Find words" gnus-score-find-favourite-words t]
1693 ["Rescore buffer" gnus-summary-rescore t]
1694 ["Increase score..." gnus-summary-increase-score t]
1695 ["Lower score..." gnus-summary-lower-score t]))))
1697 ;; Define both the Article menu in the summary buffer and the equivalent
1698 ;; Commands menu in the article buffer here for consistency.
1701 ["All" gnus-article-hide t]
1702 ["Headers" gnus-article-hide-headers t]
1703 ["Signature" gnus-article-hide-signature t]
1704 ["Citation" gnus-article-hide-citation t]
1705 ["List identifiers" gnus-article-hide-list-identifiers t]
1706 ["PGP" gnus-article-hide-pgp t]
1707 ["Banner" gnus-article-strip-banner t]
1708 ["Boring headers" gnus-article-hide-boring-headers t])
1710 ["All" gnus-article-highlight t]
1711 ["Headers" gnus-article-highlight-headers t]
1712 ["Signature" gnus-article-highlight-signature t]
1713 ["Citation" gnus-article-highlight-citation t])
1715 ["Words" gnus-article-decode-mime-words t]
1716 ["Charset" gnus-article-decode-charset t]
1717 ["QP" gnus-article-de-quoted-unreadable t]
1718 ["Base64" gnus-article-de-base64-unreadable t]
1719 ["View all" gnus-mime-view-all-parts t]
1720 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1721 ["Encrypt body" gnus-article-encrypt-body t])
1723 ["Local" gnus-article-date-local t]
1724 ["ISO8601" gnus-article-date-iso8601 t]
1725 ["UT" gnus-article-date-ut t]
1726 ["Original" gnus-article-date-original t]
1727 ["Lapsed" gnus-article-date-lapsed t]
1728 ["User-defined" gnus-article-date-user t])
1731 ["Leading" gnus-article-strip-leading-blank-lines t]
1732 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1733 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1734 ["All of the above" gnus-article-strip-blank-lines t]
1735 ["All" gnus-article-strip-all-blank-lines t]
1736 ["Leading space" gnus-article-strip-leading-space t]
1737 ["Trailing space" gnus-article-strip-trailing-space t])
1738 ["Overstrike" gnus-article-treat-overstrike t]
1739 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1740 ["Emphasis" gnus-article-emphasize t]
1741 ["Word wrap" gnus-article-fill-cited-article t]
1742 ["Fill long lines" gnus-article-fill-long-lines t]
1743 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1744 ["CR" gnus-article-remove-cr t]
1745 ["Show X-Face" gnus-article-display-x-face t]
1746 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1747 ["Base64" gnus-article-de-base64-unreadable t]
1748 ["Rot 13" gnus-summary-caesar-message t]
1749 ["Unix pipe" gnus-summary-pipe-message t]
1750 ["Add buttons" gnus-article-add-buttons t]
1751 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1752 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1753 ["Verbose header" gnus-summary-verbose-headers t]
1754 ["Toggle header" gnus-summary-toggle-header t]
1755 ["Html" gnus-article-wash-html t]
1756 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1757 ["HZ" gnus-article-decode-HZ t])
1759 ["Save in default format" gnus-summary-save-article t]
1760 ["Save in file" gnus-summary-save-article-file t]
1761 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1762 ["Save in MH folder" gnus-summary-save-article-folder t]
1763 ["Save in VM folder" gnus-summary-save-article-vm t]
1764 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1765 ["Save body in file" gnus-summary-save-article-body-file t]
1766 ["Pipe through a filter" gnus-summary-pipe-output t]
1767 ["Add to SOUP packet" gnus-soup-add-article t]
1768 ["Print" gnus-summary-print-article t])
1770 ["Respool article..." gnus-summary-respool-article t]
1771 ["Move article..." gnus-summary-move-article
1772 (gnus-check-backend-function
1773 'request-move-article gnus-newsgroup-name)]
1774 ["Copy article..." gnus-summary-copy-article t]
1775 ["Crosspost article..." gnus-summary-crosspost-article
1776 (gnus-check-backend-function
1777 'request-replace-article gnus-newsgroup-name)]
1778 ["Import file..." gnus-summary-import-article t]
1779 ["Check if posted" gnus-summary-article-posted-p t]
1780 ["Edit article" gnus-summary-edit-article
1781 (not (gnus-group-read-only-p))]
1782 ["Delete article" gnus-summary-delete-article
1783 (gnus-check-backend-function
1784 'request-expire-articles gnus-newsgroup-name)]
1785 ["Query respool" gnus-summary-respool-query t]
1786 ["Trace respool" gnus-summary-respool-trace t]
1787 ["Delete expirable articles" gnus-summary-expire-articles-now
1788 (gnus-check-backend-function
1789 'request-expire-articles gnus-newsgroup-name)])
1791 ["Uudecode" gnus-uu-decode-uu t]
1792 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1793 ["Unshar" gnus-uu-decode-unshar t]
1794 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1795 ["Save" gnus-uu-decode-save t]
1796 ["Binhex" gnus-uu-decode-binhex t]
1797 ["Postscript" gnus-uu-decode-postscript t])
1799 ["Enter article" gnus-cache-enter-article t]
1800 ["Remove article" gnus-cache-remove-article t])
1801 ["Translate" gnus-article-babel t]
1802 ["Select article buffer" gnus-summary-select-article-buffer t]
1803 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1804 ["Isearch article..." gnus-summary-isearch-article t]
1805 ["Beginning of the article" gnus-summary-beginning-of-article t]
1806 ["End of the article" gnus-summary-end-of-article t]
1807 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1808 ["Fetch referenced articles" gnus-summary-refer-references t]
1809 ["Fetch current thread" gnus-summary-refer-thread t]
1810 ["Fetch article with id..." gnus-summary-refer-article t]
1811 ["Redisplay" gnus-summary-show-article t])))
1813 gnus-summary-article-menu gnus-summary-mode-map ""
1814 (cons "Article" innards))
1817 gnus-article-commands-menu gnus-article-mode-map ""
1818 (cons "Commands" innards)))
1821 gnus-summary-thread-menu gnus-summary-mode-map ""
1823 ["Toggle threading" gnus-summary-toggle-threads t]
1824 ["Hide threads" gnus-summary-hide-all-threads t]
1825 ["Show threads" gnus-summary-show-all-threads t]
1826 ["Hide thread" gnus-summary-hide-thread t]
1827 ["Show thread" gnus-summary-show-thread t]
1828 ["Go to next thread" gnus-summary-next-thread t]
1829 ["Go to previous thread" gnus-summary-prev-thread t]
1830 ["Go down thread" gnus-summary-down-thread t]
1831 ["Go up thread" gnus-summary-up-thread t]
1832 ["Top of thread" gnus-summary-top-thread t]
1833 ["Mark thread as read" gnus-summary-kill-thread t]
1834 ["Lower thread score" gnus-summary-lower-thread t]
1835 ["Raise thread score" gnus-summary-raise-thread t]
1836 ["Rethread current" gnus-summary-rethread-current t]))
1839 gnus-summary-post-menu gnus-summary-mode-map ""
1841 ["Post an article" gnus-summary-post-news t]
1842 ["Followup" gnus-summary-followup t]
1843 ["Followup and yank" gnus-summary-followup-with-original t]
1844 ["Supersede article" gnus-summary-supersede-article t]
1845 ["Cancel article" gnus-summary-cancel-article t]
1846 ["Reply" gnus-summary-reply t]
1847 ["Reply and yank" gnus-summary-reply-with-original t]
1848 ["Wide reply" gnus-summary-wide-reply t]
1849 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1850 ["Mail forward" gnus-summary-mail-forward t]
1851 ["Post forward" gnus-summary-post-forward t]
1852 ["Digest and mail" gnus-uu-digest-mail-forward t]
1853 ["Digest and post" gnus-uu-digest-post-forward t]
1854 ["Resend message" gnus-summary-resend-message t]
1855 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1856 ["Send a mail" gnus-summary-mail-other-window t]
1857 ["Uuencode and post" gnus-uu-post-news t]
1858 ["Followup via news" gnus-summary-followup-to-mail t]
1859 ["Followup via news and yank"
1860 gnus-summary-followup-to-mail-with-original t]
1862 ;;["Send" gnus-summary-send-draft t]
1863 ;;["Send bounced" gnus-resend-bounced-mail t])
1867 gnus-summary-misc-menu gnus-summary-mode-map ""
1870 ["Mark as read" gnus-summary-mark-as-read-forward t]
1871 ["Mark same subject and select"
1872 gnus-summary-kill-same-subject-and-select t]
1873 ["Mark same subject" gnus-summary-kill-same-subject t]
1874 ["Catchup" gnus-summary-catchup t]
1875 ["Catchup all" gnus-summary-catchup-all t]
1876 ["Catchup to here" gnus-summary-catchup-to-here t]
1877 ["Catchup region" gnus-summary-mark-region-as-read t]
1878 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1880 ["Tick" gnus-summary-tick-article-forward t]
1881 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1882 ["Remove marks" gnus-summary-clear-mark-forward t]
1883 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1884 ["Set bookmark" gnus-summary-set-bookmark t]
1885 ["Remove bookmark" gnus-summary-remove-bookmark t])
1887 ["Marks..." gnus-summary-limit-to-marks t]
1888 ["Subject..." gnus-summary-limit-to-subject t]
1889 ["Author..." gnus-summary-limit-to-author t]
1890 ["Age..." gnus-summary-limit-to-age t]
1891 ["Extra..." gnus-summary-limit-to-extra t]
1892 ["Score" gnus-summary-limit-to-score t]
1893 ["Unread" gnus-summary-limit-to-unread t]
1894 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1895 ["Articles" gnus-summary-limit-to-articles t]
1896 ["Pop limit" gnus-summary-pop-limit t]
1897 ["Show dormant" gnus-summary-limit-include-dormant t]
1898 ["Hide childless dormant"
1899 gnus-summary-limit-exclude-childless-dormant t]
1900 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1901 ["Hide marked" gnus-summary-limit-exclude-marks t]
1902 ["Show expunged" gnus-summary-show-all-expunged t])
1904 ["Set mark" gnus-summary-mark-as-processable t]
1905 ["Remove mark" gnus-summary-unmark-as-processable t]
1906 ["Remove all marks" gnus-summary-unmark-all-processable t]
1907 ["Mark above" gnus-uu-mark-over t]
1908 ["Mark series" gnus-uu-mark-series t]
1909 ["Mark region" gnus-uu-mark-region t]
1910 ["Unmark region" gnus-uu-unmark-region t]
1911 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1912 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1913 ["Mark all" gnus-uu-mark-all t]
1914 ["Mark buffer" gnus-uu-mark-buffer t]
1915 ["Mark sparse" gnus-uu-mark-sparse t]
1916 ["Mark thread" gnus-uu-mark-thread t]
1917 ["Unmark thread" gnus-uu-unmark-thread t]
1918 ("Process Mark Sets"
1919 ["Kill" gnus-summary-kill-process-mark t]
1920 ["Yank" gnus-summary-yank-process-mark
1921 gnus-newsgroup-process-stack]
1922 ["Save" gnus-summary-save-process-mark t]))
1924 ["Page forward" gnus-summary-next-page t]
1925 ["Page backward" gnus-summary-prev-page t]
1926 ["Line forward" gnus-summary-scroll-up t])
1928 ["Next unread article" gnus-summary-next-unread-article t]
1929 ["Previous unread article" gnus-summary-prev-unread-article t]
1930 ["Next article" gnus-summary-next-article t]
1931 ["Previous article" gnus-summary-prev-article t]
1932 ["Next unread subject" gnus-summary-next-unread-subject t]
1933 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1934 ["Next article same subject" gnus-summary-next-same-subject t]
1935 ["Previous article same subject" gnus-summary-prev-same-subject t]
1936 ["First unread article" gnus-summary-first-unread-article t]
1937 ["Best unread article" gnus-summary-best-unread-article t]
1938 ["Go to subject number..." gnus-summary-goto-subject t]
1939 ["Go to article number..." gnus-summary-goto-article t]
1940 ["Go to the last article" gnus-summary-goto-last-article t]
1941 ["Pop article off history" gnus-summary-pop-article t])
1943 ["Sort by number" gnus-summary-sort-by-number t]
1944 ["Sort by author" gnus-summary-sort-by-author t]
1945 ["Sort by subject" gnus-summary-sort-by-subject t]
1946 ["Sort by date" gnus-summary-sort-by-date t]
1947 ["Sort by score" gnus-summary-sort-by-score t]
1948 ["Sort by lines" gnus-summary-sort-by-lines t]
1949 ["Sort by characters" gnus-summary-sort-by-chars t])
1951 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1952 ["Describe group" gnus-summary-describe-group t]
1953 ["Read manual" gnus-info-find-node t])
1955 ["Pick and read" gnus-pick-mode t]
1956 ["Binary" gnus-binary-mode t])
1958 ["Regenerate" gnus-summary-prepare t]
1959 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1960 ["Toggle threading" gnus-summary-toggle-threads t])
1961 ["Filter articles..." gnus-summary-execute-command t]
1962 ["Run command on subjects..." gnus-summary-universal-argument t]
1963 ["Search articles forward..." gnus-summary-search-article-forward t]
1964 ["Search articles backward..." gnus-summary-search-article-backward t]
1965 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1966 ["Expand window" gnus-summary-expand-window t]
1967 ["Expire expirable articles" gnus-summary-expire-articles
1968 (gnus-check-backend-function
1969 'request-expire-articles gnus-newsgroup-name)]
1970 ["Edit local kill file" gnus-summary-edit-local-kill t]
1971 ["Edit main kill file" gnus-summary-edit-global-kill t]
1972 ["Edit group parameters" gnus-summary-edit-parameters t]
1973 ["Customize group parameters" gnus-summary-customize-parameters t]
1974 ["Send a bug report" gnus-bug t]
1976 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1977 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1978 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1979 ["Exit group" gnus-summary-exit t]
1980 ["Exit group without updating" gnus-summary-exit-no-update t]
1981 ["Exit and goto next group" gnus-summary-next-group t]
1982 ["Exit and goto prev group" gnus-summary-prev-group t]
1983 ["Reselect group" gnus-summary-reselect-current-group t]
1984 ["Rescan group" gnus-summary-rescan-group t]
1985 ["Update dribble" gnus-summary-save-newsrc t])))
1987 (gnus-run-hooks 'gnus-summary-menu-hook)))
1989 (defun gnus-score-set-default (var value)
1990 "A version of set that updates the GNU Emacs menu-bar."
1992 ;; It is the message that forces the active status to be updated.
1995 (defun gnus-make-score-map (type)
1996 "Make a summary score map of type TYPE."
1999 (let ((headers '(("author" "from" string)
2000 ("subject" "subject" string)
2001 ("article body" "body" string)
2002 ("article head" "head" string)
2003 ("xref" "xref" string)
2004 ("extra header" "extra" string)
2005 ("lines" "lines" number)
2006 ("followups to author" "followup" string)))
2007 (types '((number ("less than" <)
2010 (string ("substring" s)
2014 (perms '(("temporary" (current-time-string))
2022 (if (eq type 'lower)
2027 (setq header (car headers))
2033 (let ((ts (cdr (assoc (nth 2 header) types)))
2049 'gnus-summary-score-entry
2051 (if (or (string= (nth 1 header)
2053 (string= (nth 1 header)
2056 (list 'gnus-summary-header
2058 (list 'quote (nth 1 (car ts)))
2059 (list 'gnus-score-delta-default
2066 (list (nreverse outp))))
2069 (list (nreverse outt))))
2071 (setq headers (cdr headers)))
2072 (list (nreverse outh))))))))
2076 (defun gnus-summary-mode (&optional group)
2077 "Major mode for reading articles.
2079 All normal editing commands are switched off.
2080 \\<gnus-summary-mode-map>
2081 Each line in this buffer represents one article. To read an
2082 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2083 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2086 You can also post articles and send mail from this buffer. To
2087 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2088 of an article, type `\\[gnus-summary-reply]'.
2090 There are approx. one gazillion commands you can execute in this
2091 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2093 The following commands are available:
2095 \\{gnus-summary-mode-map}"
2097 (when (gnus-visual-p 'summary-menu 'menu)
2098 (gnus-summary-make-menu-bar))
2099 (kill-all-local-variables)
2100 (gnus-summary-make-local-variables)
2101 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2102 (gnus-summary-make-local-variables))
2103 (gnus-make-thread-indent-array)
2104 (gnus-simplify-mode-line)
2105 (setq major-mode 'gnus-summary-mode)
2106 (setq mode-name "Summary")
2107 (make-local-variable 'minor-mode-alist)
2108 (use-local-map gnus-summary-mode-map)
2109 (buffer-disable-undo)
2110 (setq buffer-read-only t) ;Disable modification
2111 (setq truncate-lines t)
2112 (setq selective-display t)
2113 (setq selective-display-ellipses t) ;Display `...'
2114 (gnus-summary-set-display-table)
2115 (gnus-set-default-directory)
2116 (setq gnus-newsgroup-name group)
2117 (make-local-variable 'gnus-summary-line-format)
2118 (make-local-variable 'gnus-summary-line-format-spec)
2119 (make-local-variable 'gnus-summary-dummy-line-format)
2120 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2121 (make-local-variable 'gnus-summary-mark-positions)
2122 (make-local-hook 'pre-command-hook)
2123 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2124 (gnus-run-hooks 'gnus-summary-mode-hook)
2125 (mm-enable-multibyte-mule4)
2126 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2127 (gnus-update-summary-mark-positions))
2129 (defun gnus-summary-make-local-variables ()
2130 "Make all the local summary buffer variables."
2132 (dolist (local gnus-summary-local-variables)
2135 (if (eq (cdr local) 'global)
2136 ;; Copy the global value of the variable.
2137 (setq global (symbol-value (car local)))
2138 ;; Use the value from the list.
2139 (setq global (eval (cdr local))))
2140 (set (make-local-variable (car local)) global))
2141 ;; Simple nil-valued local variable.
2142 (set (make-local-variable local) nil)))))
2144 (defun gnus-summary-clear-local-variables ()
2145 (let ((locals gnus-summary-local-variables))
2147 (if (consp (car locals))
2148 (and (vectorp (caar locals))
2149 (set (caar locals) nil))
2150 (and (vectorp (car locals))
2151 (set (car locals) nil)))
2152 (setq locals (cdr locals)))))
2154 ;; Summary data functions.
2156 (defmacro gnus-data-number (data)
2159 (defmacro gnus-data-set-number (data number)
2160 `(setcar ,data ,number))
2162 (defmacro gnus-data-mark (data)
2165 (defmacro gnus-data-set-mark (data mark)
2166 `(setcar (nthcdr 1 ,data) ,mark))
2168 (defmacro gnus-data-pos (data)
2171 (defmacro gnus-data-set-pos (data pos)
2172 `(setcar (nthcdr 2 ,data) ,pos))
2174 (defmacro gnus-data-header (data)
2177 (defmacro gnus-data-set-header (data header)
2178 `(setf (nth 3 ,data) ,header))
2180 (defmacro gnus-data-level (data)
2183 (defmacro gnus-data-unread-p (data)
2184 `(= (nth 1 ,data) gnus-unread-mark))
2186 (defmacro gnus-data-read-p (data)
2187 `(/= (nth 1 ,data) gnus-unread-mark))
2189 (defmacro gnus-data-pseudo-p (data)
2190 `(consp (nth 3 ,data)))
2192 (defmacro gnus-data-find (number)
2193 `(assq ,number gnus-newsgroup-data))
2195 (defmacro gnus-data-find-list (number &optional data)
2196 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2197 (memq (assq ,number bdata)
2200 (defmacro gnus-data-make (number mark pos header level)
2201 `(list ,number ,mark ,pos ,header ,level))
2203 (defun gnus-data-enter (after-article number mark pos header level offset)
2204 (let ((data (gnus-data-find-list after-article)))
2206 (error "No such article: %d" after-article))
2207 (setcdr data (cons (gnus-data-make number mark pos header level)
2209 (setq gnus-newsgroup-data-reverse nil)
2210 (gnus-data-update-list (cddr data) offset)))
2212 (defun gnus-data-enter-list (after-article list &optional offset)
2214 (let ((data (and after-article (gnus-data-find-list after-article)))
2218 (let ((odata gnus-newsgroup-data))
2219 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2221 (gnus-data-update-list odata offset)))
2222 ;; Find the last element in the list to be spliced into the main
2225 (setq list (cdr list)))
2228 (setcdr list gnus-newsgroup-data)
2229 (setq gnus-newsgroup-data ilist)
2231 (gnus-data-update-list (cdr list) offset)))
2232 (setcdr list (cdr data))
2235 (gnus-data-update-list (cdr list) offset))))
2236 (setq gnus-newsgroup-data-reverse nil))))
2238 (defun gnus-data-remove (article &optional offset)
2239 (let ((data gnus-newsgroup-data))
2240 (if (= (gnus-data-number (car data)) article)
2242 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2243 gnus-newsgroup-data-reverse nil)
2245 (gnus-data-update-list gnus-newsgroup-data offset)))
2247 (when (= (gnus-data-number (cadr data)) article)
2248 (setcdr data (cddr data))
2250 (gnus-data-update-list (cdr data) offset))
2252 gnus-newsgroup-data-reverse nil))
2253 (setq data (cdr data))))))
2255 (defmacro gnus-data-list (backward)
2257 (or gnus-newsgroup-data-reverse
2258 (setq gnus-newsgroup-data-reverse
2259 (reverse gnus-newsgroup-data)))
2260 gnus-newsgroup-data))
2262 (defun gnus-data-update-list (data offset)
2263 "Add OFFSET to the POS of all data entries in DATA."
2264 (setq gnus-newsgroup-data-reverse nil)
2266 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2267 (setq data (cdr data))))
2269 (defun gnus-summary-article-pseudo-p (article)
2270 "Say whether this article is a pseudo article or not."
2271 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2273 (defmacro gnus-summary-article-sparse-p (article)
2274 "Say whether this article is a sparse article or not."
2275 `(memq ,article gnus-newsgroup-sparse))
2277 (defmacro gnus-summary-article-ancient-p (article)
2278 "Say whether this article is a sparse article or not."
2279 `(memq ,article gnus-newsgroup-ancient))
2281 (defun gnus-article-parent-p (number)
2282 "Say whether this article is a parent or not."
2283 (let ((data (gnus-data-find-list number)))
2284 (and (cdr data) ; There has to be an article after...
2285 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2286 (gnus-data-level (nth 1 data))))))
2288 (defun gnus-article-children (number)
2289 "Return a list of all children to NUMBER."
2290 (let* ((data (gnus-data-find-list number))
2291 (level (gnus-data-level (car data)))
2293 (setq data (cdr data))
2295 (= (gnus-data-level (car data)) (1+ level)))
2296 (push (gnus-data-number (car data)) children)
2297 (setq data (cdr data)))
2300 (defmacro gnus-summary-skip-intangible ()
2301 "If the current article is intangible, then jump to a different article."
2302 '(let ((to (get-text-property (point) 'gnus-intangible)))
2303 (and to (gnus-summary-goto-subject to))))
2305 (defmacro gnus-summary-article-intangible-p ()
2306 "Say whether this article is intangible or not."
2307 '(get-text-property (point) 'gnus-intangible))
2309 (defun gnus-article-read-p (article)
2310 "Say whether ARTICLE is read or not."
2311 (not (or (memq article gnus-newsgroup-marked)
2312 (memq article gnus-newsgroup-unreads)
2313 (memq article gnus-newsgroup-unselected)
2314 (memq article gnus-newsgroup-dormant))))
2316 ;; Some summary mode macros.
2318 (defmacro gnus-summary-article-number ()
2319 "The article number of the article on the current line.
2320 If there isn's an article number here, then we return the current
2323 (gnus-summary-skip-intangible)
2324 (or (get-text-property (point) 'gnus-number)
2325 (gnus-summary-last-subject))))
2327 (defmacro gnus-summary-article-header (&optional number)
2328 "Return the header of article NUMBER."
2329 `(gnus-data-header (gnus-data-find
2330 ,(or number '(gnus-summary-article-number)))))
2332 (defmacro gnus-summary-thread-level (&optional number)
2333 "Return the level of thread that starts with article NUMBER."
2334 `(if (and (eq gnus-summary-make-false-root 'dummy)
2335 (get-text-property (point) 'gnus-intangible))
2337 (gnus-data-level (gnus-data-find
2338 ,(or number '(gnus-summary-article-number))))))
2340 (defmacro gnus-summary-article-mark (&optional number)
2341 "Return the mark of article NUMBER."
2342 `(gnus-data-mark (gnus-data-find
2343 ,(or number '(gnus-summary-article-number)))))
2345 (defmacro gnus-summary-article-pos (&optional number)
2346 "Return the position of the line of article NUMBER."
2347 `(gnus-data-pos (gnus-data-find
2348 ,(or number '(gnus-summary-article-number)))))
2350 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2351 (defmacro gnus-summary-article-subject (&optional number)
2352 "Return current subject string or nil if nothing."
2355 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2356 '(gnus-data-header (assq (gnus-summary-article-number)
2357 gnus-newsgroup-data)))))
2360 (mail-header-subject headers))))
2362 (defmacro gnus-summary-article-score (&optional number)
2363 "Return current article score."
2364 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2365 gnus-newsgroup-scored))
2366 gnus-summary-default-score 0))
2368 (defun gnus-summary-article-children (&optional number)
2369 "Return a list of article numbers that are children of article NUMBER."
2370 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2371 (level (gnus-data-level (car data)))
2373 (while (and (setq data (cdr data))
2374 (> (setq l (gnus-data-level (car data))) level))
2375 (and (= (1+ level) l)
2376 (push (gnus-data-number (car data))
2378 (nreverse children)))
2380 (defun gnus-summary-article-parent (&optional number)
2381 "Return the article number of the parent of article NUMBER."
2382 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2383 (gnus-data-list t)))
2384 (level (gnus-data-level (car data))))
2386 () ; This is a root.
2387 ;; We search until we find an article with a level less than
2388 ;; this one. That function has to be the parent.
2389 (while (and (setq data (cdr data))
2390 (not (< (gnus-data-level (car data)) level))))
2391 (and data (gnus-data-number (car data))))))
2393 (defun gnus-unread-mark-p (mark)
2394 "Say whether MARK is the unread mark."
2395 (= mark gnus-unread-mark))
2397 (defun gnus-read-mark-p (mark)
2398 "Say whether MARK is one of the marks that mark as read.
2399 This is all marks except unread, ticked, dormant, and expirable."
2400 (not (or (= mark gnus-unread-mark)
2401 (= mark gnus-ticked-mark)
2402 (= mark gnus-dormant-mark)
2403 (= mark gnus-expirable-mark))))
2405 (defmacro gnus-article-mark (number)
2406 "Return the MARK of article NUMBER.
2407 This macro should only be used when computing the mark the \"first\"
2408 time; i.e., when generating the summary lines. After that,
2409 `gnus-summary-article-mark' should be used to examine the
2412 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2413 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2414 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2415 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2416 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2417 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2418 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2419 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2420 gnus-ancient-mark))))
2422 ;; Saving hidden threads.
2424 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2425 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2427 (defmacro gnus-save-hidden-threads (&rest forms)
2428 "Save hidden threads, eval FORMS, and restore the hidden threads."
2429 (let ((config (make-symbol "config")))
2430 `(let ((,config (gnus-hidden-threads-configuration)))
2434 (gnus-restore-hidden-threads-configuration ,config)))))
2436 (defun gnus-data-compute-positions ()
2437 "Compute the positions of all articles."
2438 (setq gnus-newsgroup-data-reverse nil)
2439 (let ((data gnus-newsgroup-data))
2441 (gnus-save-hidden-threads
2442 (gnus-summary-show-all-threads)
2443 (goto-char (point-min))
2445 (while (get-text-property (point) 'gnus-intangible)
2447 (gnus-data-set-pos (car data) (+ (point) 3))
2448 (setq data (cdr data))
2449 (forward-line 1))))))
2451 (defun gnus-hidden-threads-configuration ()
2452 "Return the current hidden threads configuration."
2455 (goto-char (point-min))
2456 (while (search-forward "\r" nil t)
2457 (push (1- (point)) config))
2460 (defun gnus-restore-hidden-threads-configuration (config)
2461 "Restore hidden threads configuration from CONFIG."
2463 (let (point buffer-read-only)
2464 (while (setq point (pop config))
2465 (when (and (< point (point-max))
2467 (eq (char-after) ?\n))
2468 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2470 ;; Various summary mode internalish functions.
2472 (defun gnus-mouse-pick-article (e)
2475 (gnus-summary-next-page nil t))
2477 (defun gnus-summary-set-display-table ()
2478 "Change the display table.
2479 Odd characters have a tendency to mess
2480 up nicely formatted displays - we make all possible glyphs
2481 display only a single character."
2483 ;; We start from the standard display table, if any.
2484 (let ((table (or (copy-sequence standard-display-table)
2485 (make-display-table)))
2487 ;; Nix out all the control chars...
2488 (while (>= (setq i (1- i)) 0)
2489 (aset table i [??]))
2490 ;; ... but not newline and cr, of course. (cr is necessary for the
2491 ;; selective display).
2492 (aset table ?\n nil)
2493 (aset table ?\r nil)
2494 ;; We keep TAB as well.
2495 (aset table ?\t nil)
2496 ;; We nix out any glyphs over 126 that are not set already.
2498 (while (>= (setq i (1- i)) 127)
2499 ;; Only modify if the entry is nil.
2500 (unless (aref table i)
2501 (aset table i [??]))))
2502 (setq buffer-display-table table)))
2504 (defun gnus-summary-setup-buffer (group)
2505 "Initialize summary buffer."
2506 (let ((buffer (concat "*Summary " group "*")))
2507 (if (get-buffer buffer)
2510 (setq gnus-summary-buffer (current-buffer))
2511 (not gnus-newsgroup-prepared))
2512 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2513 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2514 (gnus-summary-mode group)
2516 (gnus-carpal-setup-buffer 'summary))
2517 (unless gnus-single-article-buffer
2518 (make-local-variable 'gnus-article-buffer)
2519 (make-local-variable 'gnus-article-current)
2520 (make-local-variable 'gnus-original-article-buffer))
2521 (setq gnus-newsgroup-name group)
2524 (defun gnus-set-global-variables ()
2525 "Set the global equivalents of the buffer-local variables.
2526 They are set to the latest values they had. These reflect the summary
2527 buffer that was in action when the last article was fetched."
2528 (when (eq major-mode 'gnus-summary-mode)
2529 (setq gnus-summary-buffer (current-buffer))
2530 (let ((name gnus-newsgroup-name)
2531 (marked gnus-newsgroup-marked)
2532 (unread gnus-newsgroup-unreads)
2533 (headers gnus-current-headers)
2534 (data gnus-newsgroup-data)
2535 (summary gnus-summary-buffer)
2536 (article-buffer gnus-article-buffer)
2537 (original gnus-original-article-buffer)
2538 (gac gnus-article-current)
2539 (reffed gnus-reffed-article-number)
2540 (score-file gnus-current-score-file)
2541 (default-charset gnus-newsgroup-charset)
2543 (let ((locals gnus-newsgroup-variables))
2545 (if (consp (car locals))
2546 (push (eval (caar locals)) vlist)
2547 (push (eval (car locals)) vlist))
2548 (setq locals (cdr locals)))
2549 (setq vlist (nreverse vlist)))
2551 (set-buffer gnus-group-buffer)
2552 (setq gnus-newsgroup-name name
2553 gnus-newsgroup-marked marked
2554 gnus-newsgroup-unreads unread
2555 gnus-current-headers headers
2556 gnus-newsgroup-data data
2557 gnus-article-current gac
2558 gnus-summary-buffer summary
2559 gnus-article-buffer article-buffer
2560 gnus-original-article-buffer original
2561 gnus-reffed-article-number reffed
2562 gnus-current-score-file score-file
2563 gnus-newsgroup-charset default-charset)
2564 (let ((locals gnus-newsgroup-variables))
2566 (if (consp (car locals))
2567 (set (caar locals) (pop vlist))
2568 (set (car locals) (pop vlist)))
2569 (setq locals (cdr locals))))
2570 ;; The article buffer also has local variables.
2571 (when (gnus-buffer-live-p gnus-article-buffer)
2572 (set-buffer gnus-article-buffer)
2573 (setq gnus-summary-buffer summary))))))
2575 (defun gnus-summary-article-unread-p (article)
2576 "Say whether ARTICLE is unread or not."
2577 (memq article gnus-newsgroup-unreads))
2579 (defun gnus-summary-first-article-p (&optional article)
2580 "Return whether ARTICLE is the first article in the buffer."
2581 (if (not (setq article (or article (gnus-summary-article-number))))
2583 (eq article (caar gnus-newsgroup-data))))
2585 (defun gnus-summary-last-article-p (&optional article)
2586 "Return whether ARTICLE is the last article in the buffer."
2587 (if (not (setq article (or article (gnus-summary-article-number))))
2588 ;; All non-existent numbers are the last article. :-)
2590 (not (cdr (gnus-data-find-list article)))))
2592 (defun gnus-make-thread-indent-array ()
2594 (unless (and gnus-thread-indent-array
2595 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2596 (setq gnus-thread-indent-array (make-vector 201 "")
2597 gnus-thread-indent-array-level gnus-thread-indent-level)
2599 (aset gnus-thread-indent-array n
2600 (make-string (* n gnus-thread-indent-level) ? ))
2603 (defun gnus-update-summary-mark-positions ()
2604 "Compute where the summary marks are to go."
2606 (when (gnus-buffer-exists-p gnus-summary-buffer)
2607 (set-buffer gnus-summary-buffer))
2608 (let ((gnus-replied-mark 129)
2609 (gnus-score-below-mark 130)
2610 (gnus-score-over-mark 130)
2611 (gnus-download-mark 131)
2612 (spec gnus-summary-line-format-spec)
2615 (gnus-set-work-buffer)
2616 (let ((gnus-summary-line-format-spec spec)
2617 (gnus-newsgroup-downloadable '((0 . t))))
2618 (gnus-summary-insert-line
2619 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2620 (goto-char (point-min))
2621 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2623 (goto-char (point-min))
2624 (push (cons 'replied (and (search-forward "\201" nil t)
2627 (goto-char (point-min))
2628 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2630 (goto-char (point-min))
2631 (push (cons 'download
2632 (and (search-forward "\203" nil t) (- (point) 2)))
2634 (setq gnus-summary-mark-positions pos))))
2636 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2637 "Insert a dummy root in the summary buffer."
2639 (gnus-add-text-properties
2640 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2641 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2643 (defun gnus-summary-from-or-to-or-newsgroups (header)
2644 (let ((to (cdr (assq 'To (mail-header-extra header))))
2645 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2646 (mail-parse-charset gnus-newsgroup-charset)
2647 (mail-parse-ignored-charsets
2648 (save-excursion (set-buffer gnus-summary-buffer)
2649 gnus-newsgroup-ignored-charsets)))
2652 gnus-ignored-from-addresses
2653 (string-match gnus-ignored-from-addresses
2654 (mail-header-from header)))
2656 (or (car (funcall gnus-extract-address-components
2658 gnus-decode-encoded-word-function to)))
2659 (funcall gnus-decode-encoded-word-function to))))
2661 gnus-ignored-from-addresses
2662 (string-match gnus-ignored-from-addresses
2663 (mail-header-from header)))
2664 (concat "=> " newsgroups))
2666 (or (car (funcall gnus-extract-address-components
2667 (mail-header-from header)))
2668 (mail-header-from header))))))
2670 (defun gnus-summary-insert-line (gnus-tmp-header
2671 gnus-tmp-level gnus-tmp-current
2672 gnus-tmp-unread gnus-tmp-replied
2673 gnus-tmp-expirable gnus-tmp-subject-or-nil
2674 &optional gnus-tmp-dummy gnus-tmp-score
2676 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2677 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2678 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2679 (gnus-tmp-score-char
2680 (if (or (null gnus-summary-default-score)
2681 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2682 gnus-summary-zcore-fuzz))
2684 (if (< gnus-tmp-score gnus-summary-default-score)
2685 gnus-score-below-mark gnus-score-over-mark)))
2687 (cond (gnus-tmp-process gnus-process-mark)
2688 ((memq gnus-tmp-current gnus-newsgroup-cached)
2690 (gnus-tmp-replied gnus-replied-mark)
2691 ((memq gnus-tmp-current gnus-newsgroup-saved)
2693 (t gnus-unread-mark)))
2694 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2697 ((string-match "<[^>]+> *$" gnus-tmp-from)
2698 (let ((beg (match-beginning 0)))
2699 (or (and (string-match "^\".+\"" gnus-tmp-from)
2700 (substring gnus-tmp-from 1 (1- (match-end 0))))
2701 (substring gnus-tmp-from 0 beg))))
2702 ((string-match "(.+)" gnus-tmp-from)
2703 (substring gnus-tmp-from
2704 (1+ (match-beginning 0)) (1- (match-end 0))))
2706 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2707 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2708 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2709 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2710 (buffer-read-only nil))
2711 (when (string= gnus-tmp-name "")
2712 (setq gnus-tmp-name gnus-tmp-from))
2713 (unless (numberp gnus-tmp-lines)
2714 (setq gnus-tmp-lines 0))
2715 (gnus-put-text-property
2717 (progn (eval gnus-summary-line-format-spec) (point))
2718 'gnus-number gnus-tmp-number)
2719 (when (gnus-visual-p 'summary-highlight 'highlight)
2721 (gnus-run-hooks 'gnus-summary-update-hook)
2724 (defun gnus-summary-update-line (&optional dont-update)
2725 "Update summary line after change."
2726 (when (and gnus-summary-default-score
2727 (not gnus-summary-inhibit-highlight))
2728 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2729 (article (gnus-summary-article-number))
2730 (score (gnus-summary-article-score article)))
2732 (if (and gnus-summary-mark-below
2733 (< (gnus-summary-article-score)
2734 gnus-summary-mark-below))
2735 ;; This article has a low score, so we mark it as read.
2736 (when (memq article gnus-newsgroup-unreads)
2737 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2738 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2739 ;; This article was previously marked as read on account
2740 ;; of a low score, but now it has risen, so we mark it as
2742 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2743 (gnus-summary-update-mark
2744 (if (or (null gnus-summary-default-score)
2745 (<= (abs (- score gnus-summary-default-score))
2746 gnus-summary-zcore-fuzz))
2748 (if (< score gnus-summary-default-score)
2749 gnus-score-below-mark gnus-score-over-mark))
2751 ;; Do visual highlighting.
2752 (when (gnus-visual-p 'summary-highlight 'highlight)
2753 (gnus-run-hooks 'gnus-summary-update-hook)))))
2755 (defvar gnus-tmp-new-adopts nil)
2757 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2758 "Return the number of articles in THREAD.
2759 This may be 0 in some cases -- if none of the articles in
2760 the thread are to be displayed."
2762 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2764 ((not (listp thread))
2766 ((and (consp thread) (cdr thread))
2769 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2772 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2775 (when (and level (zerop level) gnus-tmp-new-adopts)
2778 'gnus-summary-number-of-articles-in-thread
2779 gnus-tmp-new-adopts))))
2781 (if (> number 1) gnus-not-empty-thread-mark
2782 gnus-empty-thread-mark)
2785 (defun gnus-summary-set-local-parameters (group)
2786 "Go through the local params of GROUP and set all variable specs in that list."
2787 (let ((params (gnus-group-find-parameter group))
2790 (setq elem (car params)
2791 params (cdr params))
2792 (and (consp elem) ; Has to be a cons.
2793 (consp (cdr elem)) ; The cdr has to be a list.
2794 (symbolp (car elem)) ; Has to be a symbol in there.
2795 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2796 (ignore-errors ; So we set it.
2797 (make-local-variable (car elem))
2798 (set (car elem) (eval (nth 1 elem))))))))
2800 (defun gnus-summary-read-group (group &optional show-all no-article
2801 kill-buffer no-display backward
2803 "Start reading news in newsgroup GROUP.
2804 If SHOW-ALL is non-nil, already read articles are also listed.
2805 If NO-ARTICLE is non-nil, no article is selected initially.
2806 If NO-DISPLAY, don't generate a summary buffer."
2810 (let ((gnus-auto-select-next nil))
2811 (or (gnus-summary-read-group-1
2812 group show-all no-article
2813 kill-buffer no-display
2816 select-articles nil)))))
2817 (eq gnus-auto-select-next 'quietly))
2818 (set-buffer gnus-group-buffer)
2819 ;; The entry function called above goes to the next
2820 ;; group automatically, so we go two groups back
2821 ;; if we are searching for the previous group.
2823 (gnus-group-prev-unread-group 2))
2824 (if (not (equal group (gnus-group-group-name)))
2825 (setq group (gnus-group-group-name))
2829 (defun gnus-summary-read-group-1 (group show-all no-article
2830 kill-buffer no-display
2831 &optional select-articles)
2832 ;; Killed foreign groups can't be entered.
2833 (when (and (not (gnus-group-native-p group))
2834 (not (gnus-gethash group gnus-newsrc-hashtb)))
2835 (error "Dead non-native groups can't be entered"))
2836 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2837 (let* ((new-group (gnus-summary-setup-buffer group))
2838 (quit-config (gnus-group-quit-config group))
2839 (did-select (and new-group (gnus-select-newsgroup
2840 group show-all select-articles))))
2842 ;; This summary buffer exists already, so we just select it.
2844 (gnus-set-global-variables)
2846 (gnus-kill-or-deaden-summary kill-buffer))
2847 (gnus-configure-windows 'summary 'force)
2848 (gnus-set-mode-line 'summary)
2849 (gnus-summary-position-point)
2852 ;; We couldn't select this group.
2854 (when (and (eq major-mode 'gnus-summary-mode)
2855 (not (equal (current-buffer) kill-buffer)))
2856 (kill-buffer (current-buffer))
2857 (if (not quit-config)
2859 ;; Update the info -- marks might need to be removed,
2861 (gnus-summary-update-info)
2862 (set-buffer gnus-group-buffer)
2863 (gnus-group-jump-to-group group)
2864 (gnus-group-next-unread-group 1))
2865 (gnus-handle-ephemeral-exit quit-config)))
2866 (gnus-message 3 "Can't select group")
2868 ;; The user did a `C-g' while prompting for number of articles,
2869 ;; so we exit this group.
2870 ((eq did-select 'quit)
2871 (and (eq major-mode 'gnus-summary-mode)
2872 (not (equal (current-buffer) kill-buffer))
2873 (kill-buffer (current-buffer)))
2875 (gnus-kill-or-deaden-summary kill-buffer))
2876 (if (not quit-config)
2878 (set-buffer gnus-group-buffer)
2879 (gnus-group-jump-to-group group)
2880 (gnus-group-next-unread-group 1)
2881 (gnus-configure-windows 'group 'force))
2882 (gnus-handle-ephemeral-exit quit-config))
2883 ;; Finally signal the quit.
2885 ;; The group was successfully selected.
2887 (gnus-set-global-variables)
2888 ;; Save the active value in effect when the group was entered.
2889 (setq gnus-newsgroup-active
2891 (gnus-active gnus-newsgroup-name)))
2892 ;; You can change the summary buffer in some way with this hook.
2893 (gnus-run-hooks 'gnus-select-group-hook)
2894 ;; Set any local variables in the group parameters.
2895 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2896 (gnus-update-format-specifications
2897 nil 'summary 'summary-mode 'summary-dummy)
2898 (gnus-update-summary-mark-positions)
2899 ;; Do score processing.
2900 (when gnus-use-scoring
2901 (gnus-possibly-score-headers))
2902 ;; Check whether to fill in the gaps in the threads.
2903 (when gnus-build-sparse-threads
2904 (gnus-build-sparse-threads))
2905 ;; Find the initial limit.
2906 (if gnus-show-threads
2908 (let ((gnus-newsgroup-dormant nil))
2909 (gnus-summary-initial-limit show-all))
2910 (gnus-summary-initial-limit show-all))
2911 ;; When untreaded, all articles are always shown.
2912 (setq gnus-newsgroup-limit
2914 (lambda (header) (mail-header-number header))
2915 gnus-newsgroup-headers)))
2916 ;; Generate the summary buffer.
2918 (gnus-summary-prepare))
2919 (when gnus-use-trees
2920 (gnus-tree-open group)
2921 (setq gnus-summary-highlight-line-function
2922 'gnus-tree-highlight-article))
2923 ;; If the summary buffer is empty, but there are some low-scored
2924 ;; articles or some excluded dormants, we include these in the
2926 (when (and (zerop (buffer-size))
2928 (cond (gnus-newsgroup-dormant
2929 (gnus-summary-limit-include-dormant))
2930 ((and gnus-newsgroup-scored show-all)
2931 (gnus-summary-limit-include-expunged t))))
2932 ;; Function `gnus-apply-kill-file' must be called in this hook.
2933 (gnus-run-hooks 'gnus-apply-kill-hook)
2934 (if (and (zerop (buffer-size))
2937 ;; This newsgroup is empty.
2938 (gnus-summary-catchup-and-exit nil t)
2939 (gnus-message 6 "No unread news")
2941 (gnus-kill-or-deaden-summary kill-buffer))
2942 ;; Return nil from this function.
2944 ;; Hide conversation thread subtrees. We cannot do this in
2945 ;; gnus-summary-prepare-hook since kill processing may not
2946 ;; work with hidden articles.
2947 (and gnus-show-threads
2948 gnus-thread-hide-subtree
2949 (gnus-summary-hide-all-threads))
2951 (gnus-kill-or-deaden-summary kill-buffer))
2952 ;; Show first unread article if requested.
2953 (if (and (not no-article)
2955 gnus-newsgroup-unreads
2956 gnus-auto-select-first)
2958 (gnus-configure-windows 'summary)
2960 ((eq gnus-auto-select-first 'best)
2961 (gnus-summary-best-unread-article))
2962 ((eq gnus-auto-select-first t)
2963 (gnus-summary-first-unread-article))
2964 ((gnus-functionp gnus-auto-select-first)
2965 (funcall gnus-auto-select-first))))
2966 ;; Don't select any articles, just move point to the first
2967 ;; article in the group.
2968 (goto-char (point-min))
2969 (gnus-summary-position-point)
2970 (gnus-configure-windows 'summary 'force)
2971 (gnus-set-mode-line 'summary))
2972 (when (get-buffer-window gnus-group-buffer t)
2973 ;; Gotta use windows, because recenter does weird stuff if
2974 ;; the current buffer ain't the displayed window.
2975 (let ((owin (selected-window)))
2976 (select-window (get-buffer-window gnus-group-buffer t))
2977 (when (gnus-group-goto-group group)
2979 (select-window owin)))
2980 ;; Mark this buffer as "prepared".
2981 (setq gnus-newsgroup-prepared t)
2982 (gnus-run-hooks 'gnus-summary-prepared-hook)
2985 (defun gnus-summary-prepare ()
2986 "Generate the summary buffer."
2988 (let ((buffer-read-only nil))
2990 (setq gnus-newsgroup-data nil
2991 gnus-newsgroup-data-reverse nil)
2992 (gnus-run-hooks 'gnus-summary-generate-hook)
2993 ;; Generate the buffer, either with threads or without.
2994 (when gnus-newsgroup-headers
2995 (gnus-summary-prepare-threads
2996 (if gnus-show-threads
2997 (gnus-sort-gathered-threads
2998 (funcall gnus-summary-thread-gathering-function
3000 (gnus-cut-threads (gnus-make-threads)))))
3001 ;; Unthreaded display.
3002 (gnus-sort-articles gnus-newsgroup-headers))))
3003 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3004 ;; Call hooks for modifying summary buffer.
3005 (goto-char (point-min))
3006 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3008 (defsubst gnus-general-simplify-subject (subject)
3009 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3012 ;; Truncate the subject.
3013 (gnus-simplify-subject-functions
3014 (gnus-map-function gnus-simplify-subject-functions subject))
3015 ((numberp gnus-summary-gather-subject-limit)
3016 (setq subject (gnus-simplify-subject-re subject))
3017 (if (> (length subject) gnus-summary-gather-subject-limit)
3018 (substring subject 0 gnus-summary-gather-subject-limit)
3020 ;; Fuzzily simplify it.
3021 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3022 (gnus-simplify-subject-fuzzy subject))
3023 ;; Just remove the leading "Re:".
3025 (gnus-simplify-subject-re subject))))
3027 (if (and gnus-summary-gather-exclude-subject
3028 (string-match gnus-summary-gather-exclude-subject subject))
3029 nil ; This article shouldn't be gathered
3032 (defun gnus-summary-simplify-subject-query ()
3033 "Query where the respool algorithm would put this article."
3035 (gnus-summary-select-article)
3036 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3038 (defun gnus-gather-threads-by-subject (threads)
3039 "Gather threads by looking at Subject headers."
3040 (if (not gnus-summary-make-false-root)
3042 (let ((hashtb (gnus-make-hashtable 1024))
3045 subject hthread whole-subject)
3047 (setq subject (gnus-general-simplify-subject
3048 (setq whole-subject (mail-header-subject
3051 (if (setq hthread (gnus-gethash subject hashtb))
3053 ;; We enter a dummy root into the thread, if we
3054 ;; haven't done that already.
3055 (unless (stringp (caar hthread))
3056 (setcar hthread (list whole-subject (car hthread))))
3057 ;; We add this new gathered thread to this gathered
3059 (setcdr (car hthread)
3060 (nconc (cdar hthread) (list (car threads))))
3061 ;; Remove it from the list of threads.
3062 (setcdr prev (cdr threads))
3063 (setq threads prev))
3064 ;; Enter this thread into the hash table.
3065 (gnus-sethash subject threads hashtb)))
3067 (setq threads (cdr threads)))
3070 (defun gnus-gather-threads-by-references (threads)
3071 "Gather threads by looking at References headers."
3072 (let ((idhashtb (gnus-make-hashtable 1024))
3073 (thhashtb (gnus-make-hashtable 1024))
3076 ids references id gthread gid entered ref)
3078 (when (setq references (mail-header-references (caar threads)))
3079 (setq id (mail-header-id (caar threads))
3080 ids (gnus-split-references references)
3082 (while (setq ref (pop ids))
3083 (setq ids (delete ref ids))
3084 (if (not (setq gid (gnus-gethash ref idhashtb)))
3086 (gnus-sethash ref id idhashtb)
3087 (gnus-sethash id threads thhashtb))
3088 (setq gthread (gnus-gethash gid thhashtb))
3090 ;; We enter a dummy root into the thread, if we
3091 ;; haven't done that already.
3092 (unless (stringp (caar gthread))
3093 (setcar gthread (list (mail-header-subject (caar gthread))
3095 ;; We add this new gathered thread to this gathered
3097 (setcdr (car gthread)
3098 (nconc (cdar gthread) (list (car threads)))))
3099 ;; Add it into the thread hash table.
3100 (gnus-sethash id gthread thhashtb)
3102 ;; Remove it from the list of threads.
3103 (setcdr prev (cdr threads))
3104 (setq threads prev))))
3106 (setq threads (cdr threads)))
3109 (defun gnus-sort-gathered-threads (threads)
3110 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3111 (let ((result threads))
3113 (when (stringp (caar threads))
3114 (setcdr (car threads)
3115 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3116 (setq threads (cdr threads)))
3119 (defun gnus-thread-loop-p (root thread)
3120 "Say whether ROOT is in THREAD."
3121 (let ((stack (list thread))
3124 (while (setq thread (pop stack))
3125 (setq th (cdr thread))
3127 (not (eq (caar th) root)))
3130 ;; We have found a loop.
3132 (setcdr thread (delq (car th) (cdr thread)))
3133 (if (boundp (setq ref-dep (intern "none"
3134 gnus-newsgroup-dependencies)))
3135 (setcdr (symbol-value ref-dep)
3136 (nconc (cdr (symbol-value ref-dep))
3138 (set ref-dep (list nil (car th))))
3141 ;; Push all the subthreads onto the stack.
3142 (push (cdr thread) stack)))
3145 (defun gnus-make-threads ()
3146 "Go through the dependency hashtb and find the roots. Return all threads."
3148 (while (catch 'infloop
3151 ;; Deal with self-referencing References loops.
3152 (when (and (car (symbol-value refs))
3159 (car (symbol-value refs)) thread))
3160 (cdr (symbol-value refs)))))))
3163 (unless (car (symbol-value refs))
3164 ;; These threads do not refer back to any other articles,
3165 ;; so they're roots.
3166 (setq threads (append (cdr (symbol-value refs)) threads))))
3167 gnus-newsgroup-dependencies)))
3170 ;; Build the thread tree.
3171 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3172 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3174 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3175 if it was already present.
3177 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3178 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3179 Message-IDs will be renamed be renamed to a unique Message-ID before
3182 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3183 (let* ((id (mail-header-id header))
3184 (id-dep (and id (intern id dependencies)))
3185 ref ref-dep ref-header)
3186 ;; Enter this `header' in the `dependencies' table.
3190 ;; The first two cases do the normal part: enter a new `header'
3191 ;; in the `dependencies' table.
3192 ((not (boundp id-dep))
3193 (set id-dep (list header)))
3194 ((null (car (symbol-value id-dep)))
3195 (setcar (symbol-value id-dep) header))
3197 ;; From here the `header' was already present in the
3198 ;; `dependencies' table.
3200 ;; Overrides an existing entry;
3201 ;; just set the header part of the entry.
3202 (setcar (symbol-value id-dep) header))
3204 ;; Renames the existing `header' to a unique Message-ID.
3205 ((not gnus-summary-ignore-duplicates)
3206 ;; An article with this Message-ID has already been seen.
3207 ;; We rename the Message-ID.
3208 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3210 (mail-header-set-id header id))
3212 ;; The last case ignores an existing entry, except it adds any
3213 ;; additional Xrefs (in case the two articles came from different
3215 ;; Also sets `header' to `nil' meaning that the `dependencies'
3216 ;; table was *not* modified.
3218 (mail-header-set-xref
3219 (car (symbol-value id-dep))
3220 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3222 (or (mail-header-xref header) "")))
3226 ;; First check if that we are not creating a References loop.
3227 (setq ref (gnus-parent-id (mail-header-references header)))
3229 (setq ref-dep (intern-soft ref dependencies))
3231 (setq ref-header (car (symbol-value ref-dep))))
3232 (if (string= id ref)
3233 ;; Yuk! This is a reference loop. Make the article be a
3236 (mail-header-set-references (car (symbol-value id-dep)) "none")
3238 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3239 (setq ref (gnus-parent-id (mail-header-references header)))
3240 (setq ref-dep (intern (or ref "none") dependencies))
3241 (if (boundp ref-dep)
3242 (setcdr (symbol-value ref-dep)
3243 (nconc (cdr (symbol-value ref-dep))
3244 (list (symbol-value id-dep))))
3245 (set ref-dep (list nil (symbol-value id-dep)))))
3248 (defun gnus-build-sparse-threads ()
3249 (let ((headers gnus-newsgroup-headers)
3250 (mail-parse-charset gnus-newsgroup-charset)
3251 (gnus-summary-ignore-duplicates t)
3252 header references generation relations
3253 subject child end new-child date)
3254 ;; First we create an alist of generations/relations, where
3255 ;; generations is how much we trust the relation, and the relation
3257 (gnus-message 7 "Making sparse threads...")
3259 (nnheader-set-temp-buffer " *gnus sparse threads*")
3260 (while (setq header (pop headers))
3261 (when (and (setq references (mail-header-references header))
3262 (not (string= references "")))
3264 (setq child (mail-header-id header)
3265 subject (mail-header-subject header)
3266 date (mail-header-date header)
3268 (while (search-backward ">" nil t)
3269 (setq end (1+ (point)))
3270 (when (search-backward "<" nil t)
3271 (setq new-child (buffer-substring (point) end))
3272 (push (list (incf generation)
3273 child (setq child new-child)
3277 (push (list (1+ generation) child nil subject) relations))
3279 (kill-buffer (current-buffer)))
3280 ;; Sort over trustworthiness.
3283 (when (gnus-dependencies-add-header
3284 (make-full-mail-header
3285 gnus-reffed-article-number
3286 (nth 3 relation) "" (or (nth 4 relation) "")
3288 (or (nth 2 relation) "") 0 0 "")
3289 gnus-newsgroup-dependencies nil)
3290 (push gnus-reffed-article-number gnus-newsgroup-limit)
3291 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3292 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3293 gnus-newsgroup-reads)
3294 (decf gnus-reffed-article-number)))
3295 (sort relations 'car-less-than-car))
3296 (gnus-message 7 "Making sparse threads...done")))
3298 (defun gnus-build-old-threads ()
3299 ;; Look at all the articles that refer back to old articles, and
3300 ;; fetch the headers for the articles that aren't there. This will
3301 ;; build complete threads - if the roots haven't been expired by the
3303 (let ((mail-parse-charset gnus-newsgroup-charset)
3307 (when (not (car (symbol-value refs)))
3308 (setq heads (cdr (symbol-value refs)))
3310 (if (memq (mail-header-number (caar heads))
3311 gnus-newsgroup-dormant)
3312 (setq heads (cdr heads))
3313 (setq id (symbol-name refs))
3314 (while (and (setq id (gnus-build-get-header id))
3315 (not (car (gnus-id-to-thread id)))))
3316 (setq heads nil)))))
3317 gnus-newsgroup-dependencies)))
3319 ;; This function has to be called with point after the article number
3320 ;; on the beginning of the line.
3321 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3322 (let ((eol (gnus-point-at-eol))
3323 (buffer (current-buffer))
3326 ;; overview: [num subject from date id refs chars lines misc]
3329 (narrow-to-region (point) eol)
3334 (make-full-mail-header
3336 (funcall gnus-decode-encoded-word-function
3337 (nnheader-nov-field)) ; subject
3338 (funcall gnus-decode-encoded-word-function
3339 (nnheader-nov-field)) ; from
3340 (nnheader-nov-field) ; date
3341 (nnheader-nov-read-message-id) ; id
3342 (nnheader-nov-field) ; refs
3343 (nnheader-nov-read-integer) ; chars
3344 (nnheader-nov-read-integer) ; lines
3346 (if (looking-at "Xref: ")
3347 (goto-char (match-end 0)))
3348 (nnheader-nov-field)) ; Xref
3349 (nnheader-nov-parse-extra)))) ; extra
3353 (when gnus-alter-header-function
3354 (funcall gnus-alter-header-function header))
3355 (gnus-dependencies-add-header header dependencies force-new)))
3357 (defun gnus-build-get-header (id)
3358 "Look through the buffer of NOV lines and find the header to ID.
3359 Enter this line into the dependencies hash table, and return
3360 the id of the parent article (if any)."
3361 (let ((deps gnus-newsgroup-dependencies)
3365 (set-buffer nntp-server-buffer)
3366 (let ((case-fold-search nil))
3367 (goto-char (point-min))
3368 (while (and (not found)
3369 (search-forward id nil t))
3371 (setq found (looking-at
3372 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3373 (regexp-quote id))))
3374 (or found (beginning-of-line 2)))
3378 (setq header (gnus-nov-parse-line
3379 (read (current-buffer)) deps))
3380 (gnus-parent-id (mail-header-references header))))))
3382 (let ((number (mail-header-number header)))
3383 (push number gnus-newsgroup-limit)
3384 (push header gnus-newsgroup-headers)
3385 (if (memq number gnus-newsgroup-unselected)
3387 (push number gnus-newsgroup-unreads)
3388 (setq gnus-newsgroup-unselected
3389 (delq number gnus-newsgroup-unselected)))
3390 (push number gnus-newsgroup-ancient)))))))
3392 (defun gnus-build-all-threads ()
3393 "Read all the headers."
3394 (let ((gnus-summary-ignore-duplicates t)
3395 (mail-parse-charset gnus-newsgroup-charset)
3396 (dependencies gnus-newsgroup-dependencies)
3399 (set-buffer nntp-server-buffer)
3400 (let ((case-fold-search nil))
3401 (goto-char (point-min))
3404 (setq article (read (current-buffer))
3405 header (gnus-nov-parse-line article dependencies)))
3408 (set-buffer gnus-summary-buffer)
3409 (push header gnus-newsgroup-headers)
3410 (if (memq (setq article (mail-header-number header))
3411 gnus-newsgroup-unselected)
3413 (push article gnus-newsgroup-unreads)
3414 (setq gnus-newsgroup-unselected
3415 (delq article gnus-newsgroup-unselected)))
3416 (push article gnus-newsgroup-ancient)))
3417 (forward-line 1)))))))
3419 (defun gnus-summary-update-article-line (article header)
3420 "Update the line for ARTICLE using HEADERS."
3421 (let* ((id (mail-header-id header))
3422 (thread (gnus-id-to-thread id)))
3424 (error "Article in no thread"))
3425 ;; Update the thread.
3426 (setcar thread header)
3427 (gnus-summary-goto-subject article)
3428 (let* ((datal (gnus-data-find-list article))
3430 (length (when (cdr datal)
3431 (- (gnus-data-pos data)
3432 (gnus-data-pos (cadr datal)))))
3433 (buffer-read-only nil)
3434 (level (gnus-summary-thread-level)))
3436 (gnus-summary-insert-line
3437 header level nil (gnus-article-mark article)
3438 (memq article gnus-newsgroup-replied)
3439 (memq article gnus-newsgroup-expirable)
3440 ;; Only insert the Subject string when it's different
3441 ;; from the previous Subject string.
3446 (mail-header-subject
3449 (gnus-data-find-list
3451 (gnus-data-list t)))))
3452 ;; Error on the side of excessive subjects.
3454 (mail-header-subject header)))
3456 (mail-header-subject header))
3457 nil (cdr (assq article gnus-newsgroup-scored))
3458 (memq article gnus-newsgroup-processable))
3460 (gnus-data-update-list
3461 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3463 (defun gnus-summary-update-article (article &optional iheader)
3464 "Update ARTICLE in the summary buffer."
3465 (set-buffer gnus-summary-buffer)
3466 (let* ((header (gnus-summary-article-header article))
3467 (id (mail-header-id header))
3468 (data (gnus-data-find article))
3469 (thread (gnus-id-to-thread id))
3470 (references (mail-header-references header))
3474 (when (and references
3475 (not (equal "" references)))
3478 (buffer-read-only nil)
3484 (delq thread parent)))
3485 (if (gnus-summary-insert-subject id header)
3486 ;; Set the (possibly) new article number in the data structure.
3487 (gnus-data-set-number data (gnus-id-to-article id))
3491 (defun gnus-rebuild-thread (id &optional line)
3492 "Rebuild the thread containing ID.
3493 If LINE, insert the rebuilt thread starting on line LINE."
3494 (let ((buffer-read-only nil)
3495 old-pos current thread data)
3496 (if (not gnus-show-threads)
3497 (setq thread (list (car (gnus-id-to-thread id))))
3498 ;; Get the thread this article is part of.
3499 (setq thread (gnus-remove-thread id)))
3500 (setq old-pos (gnus-point-at-bol))
3501 (setq current (save-excursion
3502 (and (zerop (forward-line -1))
3503 (gnus-summary-article-number))))
3504 ;; If this is a gathered thread, we have to go some re-gathering.
3505 (when (stringp (car thread))
3506 (let ((subject (car thread))
3508 (setq thread (cdr thread))
3510 (unless (memq (setq thr (gnus-id-to-thread
3512 (mail-header-id (caar thread)))))
3515 (setq thread (cdr thread)))
3516 ;; We now have all (unique) roots.
3517 (if (= (length roots) 1)
3518 ;; All the loose roots are now one solid root.
3519 (setq thread (car roots))
3520 (setq thread (cons subject (gnus-sort-threads roots))))))
3522 ;; We then insert this thread into the summary buffer.
3524 (goto-char (point-min))
3525 (forward-line (1- line)))
3526 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3527 (if gnus-show-threads
3528 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3529 (gnus-summary-prepare-unthreaded thread))
3530 (setq data (nreverse gnus-newsgroup-data))
3531 (setq threads gnus-newsgroup-threads))
3532 ;; We splice the new data into the data structure.
3533 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3534 ;;!!! then we want to insert at the beginning of the buffer.
3535 ;;!!! That happens to be true with Gnus now, but that may
3536 ;;!!! change in the future. Perhaps.
3537 (gnus-data-enter-list
3538 (if line nil current) data (- (point) old-pos))
3539 (setq gnus-newsgroup-threads
3540 (nconc threads gnus-newsgroup-threads))
3541 (gnus-data-compute-positions))))
3543 (defun gnus-number-to-header (number)
3544 "Return the header for article NUMBER."
3545 (let ((headers gnus-newsgroup-headers))
3547 (not (= number (mail-header-number (car headers)))))
3552 (defun gnus-parent-headers (in-headers &optional generation)
3553 "Return the headers of the GENERATIONeth parent of HEADERS."
3555 (setq generation 1))
3557 (headers in-headers)
3560 (not (zerop generation))
3561 (setq references (mail-header-references headers)))
3562 (setq headers (if (and references
3563 (setq parent (gnus-parent-id references)))
3564 (car (gnus-id-to-thread parent))
3567 (and (not (eq headers in-headers))
3570 (defun gnus-id-to-thread (id)
3571 "Return the (sub-)thread where ID appears."
3572 (gnus-gethash id gnus-newsgroup-dependencies))
3574 (defun gnus-id-to-article (id)
3575 "Return the article number of ID."
3576 (let ((thread (gnus-id-to-thread id)))
3579 (mail-header-number (car thread)))))
3581 (defun gnus-id-to-header (id)
3582 "Return the article headers of ID."
3583 (car (gnus-id-to-thread id)))
3585 (defun gnus-article-displayed-root-p (article)
3586 "Say whether ARTICLE is a root(ish) article."
3587 (let ((level (gnus-summary-thread-level article))
3588 (refs (mail-header-references (gnus-summary-article-header article)))
3594 ((null (gnus-parent-id refs)) t)
3596 (null (setq particle (gnus-id-to-article
3597 (gnus-parent-id refs))))
3598 (null (gnus-summary-thread-level particle)))))))
3600 (defun gnus-root-id (id)
3601 "Return the id of the root of the thread where ID appears."
3603 (while (and id (setq prev (car (gnus-id-to-thread id))))
3605 id (gnus-parent-id (mail-header-references prev))))
3608 (defun gnus-articles-in-thread (thread)
3609 "Return the list of articles in THREAD."
3610 (cons (mail-header-number (car thread))
3611 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3613 (defun gnus-remove-thread (id &optional dont-remove)
3614 "Remove the thread that has ID in it."
3615 (let (headers thread last-id)
3616 ;; First go up in this thread until we find the root.
3617 (setq last-id (gnus-root-id id)
3618 headers (message-flatten-list (gnus-id-to-thread last-id)))
3619 ;; We have now found the real root of this thread. It might have
3620 ;; been gathered into some loose thread, so we have to search
3621 ;; through the threads to find the thread we wanted.
3622 (let ((threads gnus-newsgroup-threads)
3625 (setq sub (car threads))
3626 (if (stringp (car sub))
3627 ;; This is a gathered thread, so we look at the roots
3628 ;; below it to find whether this article is in this
3631 (setq sub (cdr sub))
3633 (when (member (caar sub) headers)
3634 (setq thread (car threads)
3637 (setq sub (cdr sub))))
3638 ;; It's an ordinary thread, so we check it.
3639 (when (eq (car sub) (car headers))
3642 (setq threads (cdr threads)))
3643 ;; If this article is in no thread, then it's a root.
3646 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3647 (setq thread (gnus-id-to-thread last-id)))
3650 thread ; We return this thread.
3652 (if (stringp (car thread))
3654 ;; If we use dummy roots, then we have to remove the
3655 ;; dummy root as well.
3656 (when (eq gnus-summary-make-false-root 'dummy)
3657 ;; We go to the dummy root by going to
3658 ;; the first sub-"thread", and then one line up.
3659 (gnus-summary-goto-article
3660 (mail-header-number (caadr thread)))
3663 (gnus-data-compute-positions))
3664 (setq thread (cdr thread))
3666 (gnus-remove-thread-1 (car thread))
3667 (setq thread (cdr thread))))
3668 (gnus-remove-thread-1 thread))))))))
3670 (defun gnus-remove-thread-1 (thread)
3671 "Remove the thread THREAD recursively."
3672 (let ((number (mail-header-number (pop thread)))
3674 (setq thread (reverse thread))
3676 (gnus-remove-thread-1 (pop thread)))
3677 (when (setq d (gnus-data-find number))
3678 (goto-char (gnus-data-pos d))
3679 (gnus-summary-show-thread)
3682 (- (gnus-point-at-bol)
3684 (1+ (gnus-point-at-eol))
3685 (gnus-delete-line)))))))
3687 (defun gnus-sort-threads-1 (threads func)
3688 (sort (mapcar (lambda (thread)
3691 (gnus-sort-threads-1 (cdr thread) func))))
3694 (defun gnus-sort-threads (threads)
3696 (if (not gnus-thread-sort-functions)
3698 (gnus-message 8 "Sorting threads...")
3700 (gnus-sort-threads-1
3702 (gnus-make-sort-function gnus-thread-sort-functions))
3703 (gnus-message 8 "Sorting threads...done"))))
3705 (defun gnus-sort-articles (articles)
3707 (when gnus-article-sort-functions
3708 (gnus-message 7 "Sorting articles...")
3710 (setq gnus-newsgroup-headers
3711 (sort articles (gnus-make-sort-function
3712 gnus-article-sort-functions)))
3713 (gnus-message 7 "Sorting articles...done"))))
3715 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3716 (defmacro gnus-thread-header (thread)
3717 "Return header of first article in THREAD.
3718 Note that THREAD must never, ever be anything else than a variable -
3719 using some other form will lead to serious barfage."
3720 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3721 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3722 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3725 (defsubst gnus-article-sort-by-number (h1 h2)
3726 "Sort articles by article number."
3727 (< (mail-header-number h1)
3728 (mail-header-number h2)))
3730 (defun gnus-thread-sort-by-number (h1 h2)
3731 "Sort threads by root article number."
3732 (gnus-article-sort-by-number
3733 (gnus-thread-header h1) (gnus-thread-header h2)))
3735 (defsubst gnus-article-sort-by-lines (h1 h2)
3736 "Sort articles by article Lines header."
3737 (< (mail-header-lines h1)
3738 (mail-header-lines h2)))
3740 (defun gnus-thread-sort-by-lines (h1 h2)
3741 "Sort threads by root article Lines header."
3742 (gnus-article-sort-by-lines
3743 (gnus-thread-header h1) (gnus-thread-header h2)))
3745 (defsubst gnus-article-sort-by-chars (h1 h2)
3746 "Sort articles by octet length."
3747 (< (mail-header-chars h1)
3748 (mail-header-chars h2)))
3750 (defun gnus-thread-sort-by-chars (h1 h2)
3751 "Sort threads by root article octet length."
3752 (gnus-article-sort-by-chars
3753 (gnus-thread-header h1) (gnus-thread-header h2)))
3755 (defsubst gnus-article-sort-by-author (h1 h2)
3756 "Sort articles by root author."
3758 (let ((extract (funcall
3759 gnus-extract-address-components
3760 (mail-header-from h1))))
3761 (or (car extract) (cadr extract) ""))
3762 (let ((extract (funcall
3763 gnus-extract-address-components
3764 (mail-header-from h2))))
3765 (or (car extract) (cadr extract) ""))))
3767 (defun gnus-thread-sort-by-author (h1 h2)
3768 "Sort threads by root author."
3769 (gnus-article-sort-by-author
3770 (gnus-thread-header h1) (gnus-thread-header h2)))
3772 (defsubst gnus-article-sort-by-subject (h1 h2)
3773 "Sort articles by root subject."
3775 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3776 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3778 (defun gnus-thread-sort-by-subject (h1 h2)
3779 "Sort threads by root subject."
3780 (gnus-article-sort-by-subject
3781 (gnus-thread-header h1) (gnus-thread-header h2)))
3783 (defsubst gnus-article-sort-by-date (h1 h2)
3784 "Sort articles by root article date."
3786 (gnus-date-get-time (mail-header-date h1))
3787 (gnus-date-get-time (mail-header-date h2))))
3789 (defun gnus-thread-sort-by-date (h1 h2)
3790 "Sort threads by root article date."
3791 (gnus-article-sort-by-date
3792 (gnus-thread-header h1) (gnus-thread-header h2)))
3794 (defsubst gnus-article-sort-by-score (h1 h2)
3795 "Sort articles by root article score.
3796 Unscored articles will be counted as having a score of zero."
3797 (> (or (cdr (assq (mail-header-number h1)
3798 gnus-newsgroup-scored))
3799 gnus-summary-default-score 0)
3800 (or (cdr (assq (mail-header-number h2)
3801 gnus-newsgroup-scored))
3802 gnus-summary-default-score 0)))
3804 (defun gnus-thread-sort-by-score (h1 h2)
3805 "Sort threads by root article score."
3806 (gnus-article-sort-by-score
3807 (gnus-thread-header h1) (gnus-thread-header h2)))
3809 (defun gnus-thread-sort-by-total-score (h1 h2)
3810 "Sort threads by the sum of all scores in the thread.
3811 Unscored articles will be counted as having a score of zero."
3812 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3814 (defun gnus-thread-total-score (thread)
3815 ;; This function find the total score of THREAD.
3816 (cond ((null thread)
3819 (if (stringp (car thread))
3820 (apply gnus-thread-score-function 0
3821 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3822 (gnus-thread-total-score-1 thread)))
3824 (gnus-thread-total-score-1 (list thread)))))
3826 (defun gnus-thread-total-score-1 (root)
3827 ;; This function find the total score of the thread below ROOT.
3828 (setq root (car root))
3829 (apply gnus-thread-score-function
3831 (mapcar 'gnus-thread-total-score
3832 (cdr (gnus-id-to-thread (mail-header-id root))))
3833 (when (> (mail-header-number root) 0)
3834 (list (or (cdr (assq (mail-header-number root)
3835 gnus-newsgroup-scored))
3836 gnus-summary-default-score 0))))
3837 (list gnus-summary-default-score)
3840 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3841 (defvar gnus-tmp-prev-subject nil)
3842 (defvar gnus-tmp-false-parent nil)
3843 (defvar gnus-tmp-root-expunged nil)
3844 (defvar gnus-tmp-dummy-line nil)
3846 (defvar gnus-tmp-header)
3847 (defun gnus-extra-header (type &optional header)
3848 "Return the extra header of TYPE."
3849 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3852 (defun gnus-summary-prepare-threads (threads)
3853 "Prepare summary buffer from THREADS and indentation LEVEL.
3854 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3855 or a straight list of headers."
3856 (gnus-message 7 "Generating summary...")
3858 (setq gnus-newsgroup-threads threads)
3861 (let ((gnus-tmp-level 0)
3862 (default-score (or gnus-summary-default-score 0))
3863 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3864 thread number subject stack state gnus-tmp-gathered beg-match
3865 new-roots gnus-tmp-new-adopts thread-end
3866 gnus-tmp-header gnus-tmp-unread
3867 gnus-tmp-replied gnus-tmp-subject-or-nil
3868 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3869 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3870 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3872 (setq gnus-tmp-prev-subject nil)
3874 (if (vectorp (car threads))
3875 ;; If this is a straight (sic) list of headers, then a
3876 ;; threaded summary display isn't required, so we just create
3877 ;; an unthreaded one.
3878 (gnus-summary-prepare-unthreaded threads)
3880 ;; Do the threaded display.
3882 (while (or threads stack gnus-tmp-new-adopts new-roots)
3884 (if (and (= gnus-tmp-level 0)
3887 (not gnus-tmp-false-parent)
3888 (or gnus-tmp-new-adopts new-roots))
3889 (if gnus-tmp-new-adopts
3890 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3891 thread (list (car gnus-tmp-new-adopts))
3892 gnus-tmp-header (caar thread)
3893 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3895 (setq thread (list (car new-roots))
3896 gnus-tmp-header (caar thread)
3897 new-roots (cdr new-roots))))
3900 ;; If there are some threads, we do them before the
3901 ;; threads on the stack.
3902 (setq thread threads
3903 gnus-tmp-header (caar thread))
3904 ;; There were no current threads, so we pop something off
3906 (setq state (car stack)
3907 gnus-tmp-level (car state)
3910 gnus-tmp-header (caar thread))))
3912 (setq gnus-tmp-false-parent nil)
3913 (setq gnus-tmp-root-expunged nil)
3914 (setq thread-end nil)
3916 (if (stringp gnus-tmp-header)
3917 ;; The header is a dummy root.
3919 ((eq gnus-summary-make-false-root 'adopt)
3920 ;; We let the first article adopt the rest.
3921 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3923 (setq gnus-tmp-gathered
3925 (lambda (h) (mail-header-number (car h)))
3928 (setq thread (cons (list (caar thread)
3931 (setq gnus-tmp-level -1
3932 gnus-tmp-false-parent t))
3933 ((eq gnus-summary-make-false-root 'empty)
3934 ;; We print adopted articles with empty subject fields.
3935 (setq gnus-tmp-gathered
3937 (lambda (h) (mail-header-number (car h)))
3940 (setq gnus-tmp-level -1))
3941 ((eq gnus-summary-make-false-root 'dummy)
3942 ;; We remember that we probably want to output a dummy
3944 (setq gnus-tmp-dummy-line gnus-tmp-header)
3945 (setq gnus-tmp-prev-subject gnus-tmp-header))
3947 ;; We do not make a root for the gathered
3948 ;; sub-threads at all.
3949 (setq gnus-tmp-level -1)))
3951 (setq number (mail-header-number gnus-tmp-header)
3952 subject (mail-header-subject gnus-tmp-header))
3955 ;; If the thread has changed subject, we might want to make
3956 ;; this subthread into a root.
3957 ((and (null gnus-thread-ignore-subject)
3958 (not (zerop gnus-tmp-level))
3959 gnus-tmp-prev-subject
3961 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3962 (setq new-roots (nconc new-roots (list (car thread)))
3964 gnus-tmp-header nil))
3965 ;; If the article lies outside the current limit,
3966 ;; then we do not display it.
3967 ((not (memq number gnus-newsgroup-limit))
3968 (setq gnus-tmp-gathered
3970 (lambda (h) (mail-header-number (car h)))
3973 (setq gnus-tmp-new-adopts (if (cdar thread)
3974 (append gnus-tmp-new-adopts
3976 gnus-tmp-new-adopts)
3978 gnus-tmp-header nil)
3979 (when (zerop gnus-tmp-level)
3980 (setq gnus-tmp-root-expunged t)))
3981 ;; Perhaps this article is to be marked as read?
3982 ((and gnus-summary-mark-below
3983 (< (or (cdr (assq number gnus-newsgroup-scored))
3985 gnus-summary-mark-below)
3986 ;; Don't touch sparse articles.
3987 (not (gnus-summary-article-sparse-p number))
3988 (not (gnus-summary-article-ancient-p number)))
3989 (setq gnus-newsgroup-unreads
3990 (delq number gnus-newsgroup-unreads))
3991 (if gnus-newsgroup-auto-expire
3992 (push number gnus-newsgroup-expirable)
3993 (push (cons number gnus-low-score-mark)
3994 gnus-newsgroup-reads))))
3996 (when gnus-tmp-header
3997 ;; We may have an old dummy line to output before this
3999 (when (and gnus-tmp-dummy-line
4002 (mail-header-subject gnus-tmp-header)))
4003 (gnus-summary-insert-dummy-line
4004 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4005 (setq gnus-tmp-dummy-line nil))
4007 ;; Compute the mark.
4008 (setq gnus-tmp-unread (gnus-article-mark number))
4010 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4011 gnus-tmp-header gnus-tmp-level)
4012 gnus-newsgroup-data)
4014 ;; Actually insert the line.
4016 gnus-tmp-subject-or-nil
4018 ((and gnus-thread-ignore-subject
4019 gnus-tmp-prev-subject
4020 (not (inline (gnus-subject-equal
4021 gnus-tmp-prev-subject subject))))
4023 ((zerop gnus-tmp-level)
4024 (if (and (eq gnus-summary-make-false-root 'empty)
4025 (memq number gnus-tmp-gathered)
4026 gnus-tmp-prev-subject
4027 (inline (gnus-subject-equal
4028 gnus-tmp-prev-subject subject)))
4029 gnus-summary-same-subject
4031 (t gnus-summary-same-subject)))
4032 (if (and (eq gnus-summary-make-false-root 'adopt)
4033 (= gnus-tmp-level 1)
4034 (memq number gnus-tmp-gathered))
4035 (setq gnus-tmp-opening-bracket ?\<
4036 gnus-tmp-closing-bracket ?\>)
4037 (setq gnus-tmp-opening-bracket ?\[
4038 gnus-tmp-closing-bracket ?\]))
4040 gnus-tmp-indentation
4041 (aref gnus-thread-indent-array gnus-tmp-level)
4042 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4043 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4044 gnus-summary-default-score 0)
4046 (if (or (null gnus-summary-default-score)
4047 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4048 gnus-summary-zcore-fuzz))
4050 (if (< gnus-tmp-score gnus-summary-default-score)
4051 gnus-score-below-mark gnus-score-over-mark))
4053 (cond ((memq number gnus-newsgroup-processable)
4055 ((memq number gnus-newsgroup-cached)
4057 ((memq number gnus-newsgroup-replied)
4059 ((memq number gnus-newsgroup-saved)
4061 (t gnus-unread-mark))
4062 gnus-tmp-from (mail-header-from gnus-tmp-header)
4065 ((string-match "<[^>]+> *$" gnus-tmp-from)
4066 (setq beg-match (match-beginning 0))
4067 (or (and (string-match "^\".+\"" gnus-tmp-from)
4068 (substring gnus-tmp-from 1 (1- (match-end 0))))
4069 (substring gnus-tmp-from 0 beg-match)))
4070 ((string-match "(.+)" gnus-tmp-from)
4071 (substring gnus-tmp-from
4072 (1+ (match-beginning 0)) (1- (match-end 0))))
4074 (when (string= gnus-tmp-name "")
4075 (setq gnus-tmp-name gnus-tmp-from))
4076 (unless (numberp gnus-tmp-lines)
4077 (setq gnus-tmp-lines 0))
4078 (gnus-put-text-property
4080 (progn (eval gnus-summary-line-format-spec) (point))
4081 'gnus-number number)
4084 (gnus-run-hooks 'gnus-summary-update-hook)
4087 (setq gnus-tmp-prev-subject subject)))
4089 (when (nth 1 thread)
4090 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4091 (incf gnus-tmp-level)
4092 (setq threads (if thread-end nil (cdar thread)))
4094 (setq gnus-tmp-level 0)))))
4095 (gnus-message 7 "Generating summary...done"))
4097 (defun gnus-summary-prepare-unthreaded (headers)
4098 "Generate an unthreaded summary buffer based on HEADERS."
4099 (let (header number mark)
4104 ;; We may have to root out some bad articles...
4105 (when (memq (setq number (mail-header-number
4106 (setq header (pop headers))))
4107 gnus-newsgroup-limit)
4108 ;; Mark article as read when it has a low score.
4109 (when (and gnus-summary-mark-below
4110 (< (or (cdr (assq number gnus-newsgroup-scored))
4111 gnus-summary-default-score 0)
4112 gnus-summary-mark-below)
4113 (not (gnus-summary-article-ancient-p number)))
4114 (setq gnus-newsgroup-unreads
4115 (delq number gnus-newsgroup-unreads))
4116 (if gnus-newsgroup-auto-expire
4117 (push number gnus-newsgroup-expirable)
4118 (push (cons number gnus-low-score-mark)
4119 gnus-newsgroup-reads)))
4121 (setq mark (gnus-article-mark number))
4122 (push (gnus-data-make number mark (1+ (point)) header 0)
4123 gnus-newsgroup-data)
4124 (gnus-summary-insert-line
4126 mark (memq number gnus-newsgroup-replied)
4127 (memq number gnus-newsgroup-expirable)
4128 (mail-header-subject header) nil
4129 (cdr (assq number gnus-newsgroup-scored))
4130 (memq number gnus-newsgroup-processable))))))
4132 (defun gnus-summary-remove-list-identifiers ()
4133 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4134 (let ((regexp (if (stringp gnus-list-identifiers)
4135 gnus-list-identifiers
4136 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4137 (dolist (header gnus-newsgroup-headers)
4138 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4139 " *\\)\\)+\\(Re: +\\)?\\)")
4140 (mail-header-subject header))
4141 (mail-header-set-subject
4142 header (concat (substring (mail-header-subject header)
4143 0 (match-beginning 1))
4145 (match-string 3 (mail-header-subject header))
4146 (match-string 5 (mail-header-subject header)))
4147 (substring (mail-header-subject header)
4148 (match-end 1))))))))
4150 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4151 "Select newsgroup GROUP.
4152 If READ-ALL is non-nil, all articles in the group are selected.
4153 If SELECT-ARTICLES, only select those articles from GROUP."
4154 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4155 ;;!!! Dirty hack; should be removed.
4156 (gnus-summary-ignore-duplicates
4157 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4159 gnus-summary-ignore-duplicates))
4160 (info (nth 2 entry))
4161 articles fetched-articles cached)
4163 (unless (gnus-check-server
4164 (setq gnus-current-select-method
4165 (gnus-find-method-for-group group)))
4166 (error "Couldn't open server"))
4168 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4169 (gnus-activate-group group) ; Or we can activate it...
4170 (progn ; Or we bug out.
4171 (when (equal major-mode 'gnus-summary-mode)
4172 (kill-buffer (current-buffer)))
4173 (error "Couldn't activate group %s: %s"
4174 group (gnus-status-message group))))
4176 (unless (gnus-request-group group t)
4177 (when (equal major-mode 'gnus-summary-mode)
4178 (kill-buffer (current-buffer)))
4179 (error "Couldn't request group %s: %s"
4180 group (gnus-status-message group)))
4182 (setq gnus-newsgroup-name group)
4183 (setq gnus-newsgroup-unselected nil)
4184 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4185 (gnus-summary-setup-default-charset)
4187 ;; Adjust and set lists of article marks.
4189 (gnus-adjust-marked-articles info))
4191 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4192 (when (gnus-virtual-group-p group)
4193 (setq cached gnus-newsgroup-cached))
4195 (setq gnus-newsgroup-unreads
4196 (gnus-set-difference
4197 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4198 gnus-newsgroup-dormant))
4200 (setq gnus-newsgroup-processable nil)
4202 (gnus-update-read-articles group gnus-newsgroup-unreads)
4204 (if (setq articles select-articles)
4205 (setq gnus-newsgroup-unselected
4206 (gnus-sorted-intersection
4207 gnus-newsgroup-unreads
4208 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4209 (setq articles (gnus-articles-to-read group read-all)))
4213 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4215 ((eq articles 0) nil)
4217 ;; Init the dependencies hash table.
4218 (setq gnus-newsgroup-dependencies
4219 (gnus-make-hashtable (length articles)))
4220 (gnus-set-global-variables)
4221 ;; Retrieve the headers and read them in.
4222 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4223 (setq gnus-newsgroup-headers
4225 (setq gnus-headers-retrieved-by
4226 (gnus-retrieve-headers
4227 articles gnus-newsgroup-name
4228 ;; We might want to fetch old headers, but
4229 ;; not if there is only 1 article.
4231 (not (eq gnus-fetch-old-headers 'some))
4232 (not (numberp gnus-fetch-old-headers)))
4233 (> (length articles) 1))
4234 gnus-fetch-old-headers))))
4235 (gnus-get-newsgroup-headers-xover
4236 articles nil nil gnus-newsgroup-name t)
4237 (gnus-get-newsgroup-headers)))
4238 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4240 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4242 (setq gnus-newsgroup-cached cached))
4244 ;; Suppress duplicates?
4245 (when gnus-suppress-duplicates
4246 (gnus-dup-suppress-articles))
4248 ;; Set the initial limit.
4249 (setq gnus-newsgroup-limit (copy-sequence articles))
4250 ;; Remove canceled articles from the list of unread articles.
4251 (setq gnus-newsgroup-unreads
4252 (gnus-set-sorted-intersection
4253 gnus-newsgroup-unreads
4254 (setq fetched-articles
4255 (mapcar (lambda (headers) (mail-header-number headers))
4256 gnus-newsgroup-headers))))
4257 ;; Removed marked articles that do not exist.
4258 (gnus-update-missing-marks
4259 (gnus-sorted-complement fetched-articles articles))
4260 ;; We might want to build some more threads first.
4261 (when (and gnus-fetch-old-headers
4262 (eq gnus-headers-retrieved-by 'nov))
4263 (if (eq gnus-fetch-old-headers 'invisible)
4264 (gnus-build-all-threads)
4265 (gnus-build-old-threads)))
4266 ;; Let the Gnus agent mark articles as read.
4268 (gnus-agent-get-undownloaded-list))
4269 ;; Remove list identifiers from subject
4270 (when gnus-list-identifiers
4271 (gnus-summary-remove-list-identifiers))
4272 ;; Check whether auto-expire is to be done in this group.
4273 (setq gnus-newsgroup-auto-expire
4274 (gnus-group-auto-expirable-p group))
4275 ;; Set up the article buffer now, if necessary.
4276 (unless gnus-single-article-buffer
4277 (gnus-article-setup-buffer))
4278 ;; First and last article in this newsgroup.
4279 (when gnus-newsgroup-headers
4280 (setq gnus-newsgroup-begin
4281 (mail-header-number (car gnus-newsgroup-headers))
4284 (gnus-last-element gnus-newsgroup-headers))))
4285 ;; GROUP is successfully selected.
4286 (or gnus-newsgroup-headers t)))))
4288 (defun gnus-articles-to-read (group &optional read-all)
4289 "Find out what articles the user wants to read."
4291 ;; Select all articles if `read-all' is non-nil, or if there
4292 ;; are no unread articles.
4294 (and (zerop (length gnus-newsgroup-marked))
4295 (zerop (length gnus-newsgroup-unreads)))
4296 (eq (gnus-group-find-parameter group 'display)
4299 (gnus-uncompress-range (gnus-active group))
4300 (gnus-cache-articles-in-group group))
4301 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4302 (copy-sequence gnus-newsgroup-unreads))
4304 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4305 (scored (length scored-list))
4306 (number (length articles))
4307 (marked (+ (length gnus-newsgroup-marked)
4308 (length gnus-newsgroup-dormant)))
4316 ((and (or (<= scored marked) (= scored number))
4317 (numberp gnus-large-newsgroup)
4318 (> number gnus-large-newsgroup))
4322 "How many articles from %s (default %d): "
4323 (gnus-limit-string gnus-newsgroup-name 35)
4325 (if (string-match "^[ \t]*$" input) number input)))
4326 ((and (> scored marked) (< scored number)
4327 (> (- scored number) 20))
4330 (format "%s %s (%d scored, %d total): "
4331 "How many articles from"
4332 group scored number))))
4333 (if (string-match "^[ \t]*$" input)
4337 (message "Quit getting the articles to read")
4339 (setq select (if (stringp select) (string-to-number select) select))
4340 (if (or (null select) (zerop select))
4342 (if (and (not (zerop scored)) (<= (abs select) scored))
4344 (setq articles (sort scored-list '<))
4345 (setq number (length articles)))
4346 (setq articles (copy-sequence articles)))
4348 (when (< (abs select) number)
4350 ;; Select the N oldest articles.
4351 (setcdr (nthcdr (1- (abs select)) articles) nil)
4352 ;; Select the N most recent articles.
4353 (setq articles (nthcdr (- number select) articles))))
4354 (setq gnus-newsgroup-unselected
4355 (gnus-sorted-intersection
4356 gnus-newsgroup-unreads
4357 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4358 (when gnus-alter-articles-to-read-function
4359 (setq gnus-newsgroup-unreads
4361 (funcall gnus-alter-articles-to-read-function
4362 gnus-newsgroup-name gnus-newsgroup-unreads)
4366 (defun gnus-killed-articles (killed articles)
4369 (when (inline (gnus-member-of-range (car articles) killed))
4370 (push (car articles) out))
4371 (setq articles (cdr articles)))
4374 (defun gnus-uncompress-marks (marks)
4375 "Uncompress the mark ranges in MARKS."
4376 (let ((uncompressed '(score bookmark))
4379 (if (memq (caar marks) uncompressed)
4380 (push (car marks) out)
4381 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4382 (setq marks (cdr marks)))
4385 (defun gnus-adjust-marked-articles (info)
4386 "Set all article lists and remove all marks that are no longer valid."
4387 (let* ((marked-lists (gnus-info-marks info))
4388 (active (gnus-active (gnus-info-group info)))
4391 (types gnus-article-mark-lists)
4392 (uncompressed '(score bookmark killed))
4393 marks var articles article mark)
4396 (setq marks (pop marked-lists))
4397 (set (setq var (intern (format "gnus-newsgroup-%s"
4398 (car (rassq (setq mark (car marks))
4400 (if (memq (car marks) uncompressed) (cdr marks)
4401 (gnus-uncompress-range (cdr marks))))
4403 (setq articles (symbol-value var))
4405 ;; All articles have to be subsets of the active articles.
4407 ;; Adjust "simple" lists.
4408 ((memq mark '(tick dormant expire reply save))
4410 (when (or (< (setq article (pop articles)) min) (> article max))
4411 (set var (delq article (symbol-value var))))))
4413 ((memq mark uncompressed)
4414 (when (not (listp (cdr (symbol-value var))))
4415 (set var (list (symbol-value var))))
4416 (when (not (listp (cdr articles)))
4417 (setq articles (list articles)))
4419 (when (or (not (consp (setq article (pop articles))))
4420 (< (car article) min)
4421 (> (car article) max))
4422 (set var (delq article (symbol-value var))))))))))
4424 (defun gnus-update-missing-marks (missing)
4425 "Go through the list of MISSING articles and remove them from the mark lists."
4427 (let ((types gnus-article-mark-lists)
4429 ;; Go through all types.
4431 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4432 (when (symbol-value var)
4433 ;; This list has articles. So we delete all missing articles
4437 (set var (delq (pop m) (symbol-value var)))))))))
4439 (defun gnus-update-marks ()
4440 "Enter the various lists of marked articles into the newsgroup info list."
4441 (let ((types gnus-article-mark-lists)
4442 (info (gnus-get-info gnus-newsgroup-name))
4443 (uncompressed '(score bookmark killed))
4444 type list newmarked symbol delta-marks)
4446 ;; Add all marks lists to the list of marks lists.
4447 (while (setq type (pop types))
4448 (setq list (symbol-value
4450 (intern (format "gnus-newsgroup-%s"
4454 ;; Get rid of the entries of the articles that have the
4456 (when (and (eq (cdr type) 'score)
4460 (prev (cons nil list))
4463 (if (or (not (consp (car arts)))
4464 (= (cdar arts) gnus-summary-default-score))
4465 (setcdr prev (cdr arts))
4467 (setq arts (cdr arts)))
4468 (setq list (cdr all)))))
4470 (unless (memq (cdr type) uncompressed)
4471 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4473 (when (gnus-check-backend-function
4474 'request-set-mark gnus-newsgroup-name)
4475 ;; propagate flags to server, with the following exceptions:
4476 ;; uncompressed:s are not proper flags (they are cons cells)
4477 ;; cache is a internal gnus flag
4478 ;; download are local to one gnus installation (well)
4479 ;; unsend are for nndraft groups only
4480 ;; xxx: generality of this? this suits nnimap anyway
4481 (unless (memq (cdr type) (append '(cache download unsend)
4483 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4484 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4485 (add (gnus-remove-from-range
4486 (gnus-copy-sequence list) old)))
4488 (push (list add 'add (list (cdr type))) delta-marks))
4490 (push (list del 'del (list (cdr type))) delta-marks)))))
4493 (push (cons (cdr type) list) newmarked)))
4496 (unless (gnus-check-group gnus-newsgroup-name)
4497 (error "Can't open server for %s" gnus-newsgroup-name))
4498 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4500 ;; Enter these new marks into the info of the group.
4502 (setcar (nthcdr 3 info) newmarked)
4503 ;; Add the marks lists to the end of the info.
4505 (setcdr (nthcdr 2 info) (list newmarked))))
4507 ;; Cut off the end of the info if there's nothing else there.
4511 (when (nthcdr (decf i) info)
4512 (setcdr (nthcdr i info) nil)))))))
4514 (defun gnus-set-mode-line (where)
4515 "Set the mode line of the article or summary buffers.
4516 If WHERE is `summary', the summary mode line format will be used."
4517 ;; Is this mode line one we keep updated?
4518 (when (and (memq where gnus-updated-mode-lines)
4520 (intern (format "gnus-%s-mode-line-format-spec" where))))
4523 ;; We evaluate this in the summary buffer since these
4524 ;; variables are buffer-local to that buffer.
4525 (set-buffer gnus-summary-buffer)
4526 ;; We bind all these variables that are used in the `eval' form
4528 (let* ((mformat (symbol-value
4530 (format "gnus-%s-mode-line-format-spec" where))))
4531 (gnus-tmp-group-name (gnus-group-name-decode
4533 (gnus-group-name-charset
4535 gnus-newsgroup-name)))
4536 (gnus-tmp-article-number (or gnus-current-article 0))
4537 (gnus-tmp-unread gnus-newsgroup-unreads)
4538 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4539 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4540 (gnus-tmp-unread-and-unselected
4541 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4542 (zerop gnus-tmp-unselected))
4544 ((zerop gnus-tmp-unselected)
4545 (format "{%d more}" gnus-tmp-unread-and-unticked))
4546 (t (format "{%d(+%d) more}"
4547 gnus-tmp-unread-and-unticked
4548 gnus-tmp-unselected))))
4550 (if (and gnus-current-headers
4551 (vectorp gnus-current-headers))
4552 (gnus-mode-string-quote
4553 (mail-header-subject gnus-current-headers))
4555 bufname-length max-len
4556 gnus-tmp-header);; passed as argument to any user-format-funcs
4557 (setq mode-string (eval mformat))
4558 (setq bufname-length (if (string-match "%b" mode-string)
4561 (if (eq where 'summary)
4563 (get-buffer gnus-article-buffer))))
4566 (setq max-len (max 4 (if gnus-mode-non-string-length
4568 gnus-mode-non-string-length
4570 (length mode-string))))
4571 ;; We might have to chop a bit of the string off...
4572 (when (> (length mode-string) max-len)
4574 (concat (truncate-string-to-width mode-string (- max-len 3))
4576 ;; Pad the mode string a bit.
4577 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4578 ;; Update the mode line.
4579 (setq mode-line-buffer-identification
4580 (gnus-mode-line-buffer-identification (list mode-string)))
4581 (set-buffer-modified-p t))))
4583 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4584 "Go through the HEADERS list and add all Xrefs to a hash table.
4585 The resulting hash table is returned, or nil if no Xrefs were found."
4586 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4587 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4588 (xref-hashtb (gnus-make-hashtable))
4589 start group entry number xrefs header)
4591 (setq header (pop headers))
4592 (when (and (setq xrefs (mail-header-xref header))
4593 (not (memq (setq number (mail-header-number header))
4596 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4597 (setq start (match-end 0))
4598 (setq group (if prefix
4599 (concat prefix (substring xrefs (match-beginning 1)
4601 (substring xrefs (match-beginning 1) (match-end 1))))
4603 (string-to-int (substring xrefs (match-beginning 2)
4605 (if (setq entry (gnus-gethash group xref-hashtb))
4606 (setcdr entry (cons number (cdr entry)))
4607 (gnus-sethash group (cons number nil) xref-hashtb)))))
4608 (and start xref-hashtb)))
4610 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4611 "Look through all the headers and mark the Xrefs as read."
4612 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4613 name entry info xref-hashtb idlist method nth4)
4615 (set-buffer gnus-group-buffer)
4616 (when (setq xref-hashtb
4617 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4620 (unless (string= from-newsgroup (setq name (symbol-name group)))
4621 (setq idlist (symbol-value group))
4622 ;; Dead groups are not updated.
4624 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4626 (when (stringp (setq nth4 (gnus-info-method info)))
4627 (setq nth4 (gnus-server-to-method nth4))))
4628 ;; Only do the xrefs if the group has the same
4629 ;; select method as the group we have just read.
4630 (or (gnus-methods-equal-p
4631 nth4 (gnus-find-method-for-group from-newsgroup))
4633 (equal nth4 (setq method (gnus-find-method-for-group
4635 (and (equal (car nth4) (car method))
4636 (equal (nth 1 nth4) (nth 1 method))))
4637 gnus-use-cross-reference
4638 (or (not (eq gnus-use-cross-reference t))
4640 ;; Only do cross-references on subscribed
4641 ;; groups, if that is what is wanted.
4642 (<= (gnus-info-level info) gnus-level-subscribed))
4643 (gnus-group-make-articles-read name idlist))))
4646 (defun gnus-compute-read-articles (group articles)
4647 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4648 (info (nth 2 entry))
4649 (active (gnus-active group))
4652 ;; First peel off all invalid article numbers.
4654 (let ((ids articles)
4656 (while (setq id (pop ids))
4657 (when (and first (> id (cdr active)))
4658 ;; We'll end up in this situation in one particular
4659 ;; obscure situation. If you re-scan a group and get
4660 ;; a new article that is cross-posted to a different
4661 ;; group that has not been re-scanned, you might get
4662 ;; crossposted article that has a higher number than
4663 ;; Gnus believes possible. So we re-activate this
4664 ;; group as well. This might mean doing the
4665 ;; crossposting thingy will *increase* the number
4666 ;; of articles in some groups. Tsk, tsk.
4667 (setq active (or (gnus-activate-group group) active)))
4668 (when (or (> id (cdr active))
4669 (< id (car active)))
4670 (setq articles (delq id articles))))))
4671 ;; If the read list is nil, we init it.
4673 (null (gnus-info-read info))
4675 (setq ninfo (cons 1 (1- (car active))))
4676 (setq ninfo (gnus-info-read info)))
4677 ;; Then we add the read articles to the range.
4679 ninfo (setq articles (sort articles '<))))))
4681 (defun gnus-group-make-articles-read (group articles)
4682 "Update the info of GROUP to say that ARTICLES are read."
4684 (entry (gnus-gethash group gnus-newsrc-hashtb))
4685 (info (nth 2 entry))
4686 (active (gnus-active group))
4689 (setq range (gnus-compute-read-articles group articles))
4691 (set-buffer gnus-group-buffer)
4694 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4695 (gnus-info-set-read ',info ',(gnus-info-read info))
4696 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4697 (gnus-group-update-group ,group t))))
4698 ;; Add the read articles to the range.
4699 (gnus-info-set-read info range)
4700 ;; Then we have to re-compute how many unread
4701 ;; articles there are in this group.
4705 (setq num (- (1+ (cdr active)) (car active))))
4706 ((not (listp (cdr range)))
4707 (setq num (- (cdr active) (- (1+ (cdr range))
4711 (if (numberp (car range))
4713 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4714 (setq range (cdr range)))
4715 (setq num (- (cdr active) num))))
4716 ;; Update the number of unread articles.
4718 ;; Update the group buffer.
4719 (gnus-group-update-group group t)))))
4721 (defvar gnus-newsgroup-none-id 0)
4723 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4724 (let ((cur nntp-server-buffer)
4727 (save-excursion (set-buffer gnus-summary-buffer)
4728 gnus-newsgroup-dependencies)))
4730 (mail-parse-charset gnus-newsgroup-charset)
4731 (mail-parse-ignored-charsets
4732 (save-excursion (condition-case nil
4733 (set-buffer gnus-summary-buffer)
4735 gnus-newsgroup-ignored-charsets)))
4737 (set-buffer nntp-server-buffer)
4738 ;; Translate all TAB characters into SPACE characters.
4739 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4740 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4741 (gnus-run-hooks 'gnus-parse-headers-hook)
4742 (let ((case-fold-search t)
4743 in-reply-to header p lines chars)
4744 (goto-char (point-min))
4745 ;; Search to the beginning of the next header. Error messages
4746 ;; do not begin with 2 or 3.
4747 (while (re-search-forward "^[23][0-9]+ " nil t)
4750 ;; This implementation of this function, with nine
4751 ;; search-forwards instead of the one re-search-forward and
4752 ;; a case (which basically was the old function) is actually
4753 ;; about twice as fast, even though it looks messier. You
4754 ;; can't have everything, I guess. Speed and elegance
4755 ;; doesn't always go hand in hand.
4764 (narrow-to-region (point)
4765 (or (and (search-forward "\n.\n" nil t)
4771 (if (search-forward "\nsubject: " nil t)
4772 (funcall gnus-decode-encoded-word-function
4773 (nnheader-header-value))
4778 (if (or (search-forward "\nfrom: " nil t)
4779 (search-forward "\nfrom:" nil t))
4780 (funcall gnus-decode-encoded-word-function
4781 (nnheader-header-value))
4786 (if (search-forward "\ndate: " nil t)
4787 (nnheader-header-value) ""))
4791 (setq id (if (re-search-forward
4792 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4793 ;; We do it this way to make sure the Message-ID
4794 ;; is (somewhat) syntactically valid.
4795 (buffer-substring (match-beginning 1)
4797 ;; If there was no message-id, we just fake one
4798 ;; to make subsequent routines simpler.
4799 (nnheader-generate-fake-message-id))))
4803 (if (search-forward "\nreferences: " nil t)
4807 (nnheader-header-value)
4812 (search-backward ">" end t)
4815 (search-backward "<" end t)
4817 ;; Get the references from the in-reply-to header if there
4818 ;; were no references and the in-reply-to header looks
4820 (if (and (search-forward "\nin-reply-to: " nil t)
4821 (setq in-reply-to (nnheader-header-value))
4822 (string-match "<[^>]+>" in-reply-to))
4824 (setq ref (substring in-reply-to (match-beginning 0)
4826 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4827 (setq ref2 (substring in-reply-to (match-beginning 0)
4829 (when (> (length ref2) (length ref))
4836 (if (search-forward "\nchars: " nil t)
4837 (if (numberp (setq chars (ignore-errors (read cur))))
4843 (if (search-forward "\nlines: " nil t)
4844 (if (numberp (setq lines (ignore-errors (read cur))))
4850 (and (search-forward "\nxref: " nil t)
4851 (nnheader-header-value)))
4853 (when gnus-extra-headers
4854 (let ((extra gnus-extra-headers)
4858 (when (search-forward
4859 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4860 (push (cons (car extra) (nnheader-header-value))
4864 (when (equal id ref)
4867 (when gnus-alter-header-function
4868 (funcall gnus-alter-header-function header)
4869 (setq id (mail-header-id header)
4870 ref (gnus-parent-id (mail-header-references header))))
4873 (gnus-dependencies-add-header
4874 header dependencies force-new))
4875 (push header headers))
4876 (goto-char (point-max))
4878 (nreverse headers)))))
4880 ;; Goes through the xover lines and returns a list of vectors
4881 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4882 force-new dependencies
4883 group also-fetch-heads)
4884 "Parse the news overview data in the server buffer.
4885 Return a list of headers that match SEQUENCE (see
4886 `nntp-retrieve-headers')."
4887 ;; Get the Xref when the users reads the articles since most/some
4888 ;; NNTP servers do not include Xrefs when using XOVER.
4889 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4890 (let ((mail-parse-charset gnus-newsgroup-charset)
4891 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4892 (cur nntp-server-buffer)
4893 (dependencies (or dependencies gnus-newsgroup-dependencies))
4894 number headers header)
4896 (set-buffer nntp-server-buffer)
4897 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4898 ;; Allow the user to mangle the headers before parsing them.
4899 (gnus-run-hooks 'gnus-parse-headers-hook)
4900 (goto-char (point-min))
4903 (while (and sequence (not (eobp)))
4904 (setq number (read cur))
4905 (while (and sequence
4906 (< (car sequence) number))
4907 (setq sequence (cdr sequence)))
4909 (eq number (car sequence))
4911 (setq sequence (cdr sequence))
4912 (setq header (inline
4913 (gnus-nov-parse-line
4914 number dependencies force-new))))
4915 (push header headers))
4918 (gnus-error 4 "Strange nov line (%d)"
4919 (count-lines (point-min) (point)))))
4921 ;; A common bug in inn is that if you have posted an article and
4922 ;; then retrieves the active file, it will answer correctly --
4923 ;; the new article is included. However, a NOV entry for the
4924 ;; article may not have been generated yet, so this may fail.
4925 ;; We work around this problem by retrieving the last few
4926 ;; headers using HEAD.
4927 (if (or (not also-fetch-heads)
4929 ;; We (probably) got all the headers.
4931 (let ((gnus-nov-is-evil t))
4934 (when (gnus-retrieve-headers sequence group)
4935 (gnus-get-newsgroup-headers))))))))
4937 (defun gnus-article-get-xrefs ()
4938 "Fill in the Xref value in `gnus-current-headers', if necessary.
4939 This is meant to be called in `gnus-article-internal-prepare-hook'."
4940 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4941 gnus-current-headers)))
4942 (or (not gnus-use-cross-reference)
4944 (and (mail-header-xref headers)
4945 (not (string= (mail-header-xref headers) "")))
4946 (let ((case-fold-search t)
4949 (nnheader-narrow-to-headers)
4950 (goto-char (point-min))
4951 (when (or (and (not (eobp))
4952 (eq (downcase (char-after)) ?x)
4953 (looking-at "Xref:"))
4954 (search-forward "\nXref:" nil t))
4955 (goto-char (1+ (match-end 0)))
4956 (setq xref (buffer-substring (point)
4957 (progn (end-of-line) (point))))
4958 (mail-header-set-xref headers xref)))))))
4960 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4961 "Find article ID and insert the summary line for that article.
4962 OLD-HEADER can either be a header or a line number to insert
4963 the subject line on."
4964 (let* ((line (and (numberp old-header) old-header))
4965 (old-header (and (vectorp old-header) old-header))
4966 (header (cond ((and old-header use-old-header)
4969 (gnus-number-to-header id))
4970 (gnus-number-to-header id))
4972 (gnus-read-header id))))
4973 (number (and (numberp id) id))
4976 ;; Rebuild the thread that this article is part of and go to the
4977 ;; article we have fetched.
4978 (when (and (not gnus-show-threads)
4981 (setq d (gnus-data-find (mail-header-number old-header))))
4982 (goto-char (gnus-data-pos d))
4985 (- (gnus-point-at-bol)
4987 (1+ (gnus-point-at-eol))
4988 (gnus-delete-line))))))
4990 (mail-header-set-number header (mail-header-number old-header)))
4991 (setq gnus-newsgroup-sparse
4992 (delq (setq number (mail-header-number header))
4993 gnus-newsgroup-sparse))
4994 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4995 (push number gnus-newsgroup-limit)
4996 (gnus-rebuild-thread (mail-header-id header) line)
4997 (gnus-summary-goto-subject number nil t))
4998 (when (and (numberp number)
5000 ;; We have to update the boundaries even if we can't fetch the
5001 ;; article if ID is a number -- so that the next `P' or `N'
5002 ;; command will fetch the previous (or next) article even
5003 ;; if the one we tried to fetch this time has been canceled.
5004 (when (> number gnus-newsgroup-end)
5005 (setq gnus-newsgroup-end number))
5006 (when (< number gnus-newsgroup-begin)
5007 (setq gnus-newsgroup-begin number))
5008 (setq gnus-newsgroup-unselected
5009 (delq number gnus-newsgroup-unselected)))
5010 ;; Report back a success?
5011 (and header (mail-header-number header))))
5013 ;;; Process/prefix in the summary buffer
5015 (defun gnus-summary-work-articles (n)
5016 "Return a list of articles to be worked upon.
5017 The prefix argument, the list of process marked articles, and the
5018 current article will be taken into consideration."
5020 (set-buffer gnus-summary-buffer)
5023 ;; A numerical prefix has been given.
5024 (setq n (prefix-numeric-value n))
5025 (let ((backward (< n 0))
5026 (n (abs (prefix-numeric-value n)))
5031 (push (setq article (gnus-summary-article-number))
5034 (gnus-summary-find-prev nil article)
5035 (gnus-summary-find-next nil article)))
5037 (nreverse articles)))
5038 ((and (gnus-region-active-p) (mark))
5039 (message "region active")
5040 ;; Work on the region between point and mark.
5041 (let ((max (max (point) (mark)))
5044 (goto-char (min (min (point) (mark))))
5047 (push (setq article (gnus-summary-article-number)) articles)
5048 (gnus-summary-find-next nil article)
5050 (nreverse articles))))
5051 (gnus-newsgroup-processable
5052 ;; There are process-marked articles present.
5053 ;; Save current state.
5054 (gnus-summary-save-process-mark)
5056 (reverse gnus-newsgroup-processable))
5058 ;; Just return the current article.
5059 (list (gnus-summary-article-number))))))
5061 (defmacro gnus-summary-iterate (arg &rest forms)
5062 "Iterate over the process/prefixed articles and do FORMS.
5063 ARG is the interactive prefix given to the command. FORMS will be
5064 executed with point over the summary line of the articles."
5065 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5066 `(let ((,articles (gnus-summary-work-articles ,arg)))
5068 (gnus-summary-goto-subject (car ,articles))
5072 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5073 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5075 (defun gnus-summary-save-process-mark ()
5076 "Push the current set of process marked articles on the stack."
5078 (push (copy-sequence gnus-newsgroup-processable)
5079 gnus-newsgroup-process-stack))
5081 (defun gnus-summary-kill-process-mark ()
5082 "Push the current set of process marked articles on the stack and unmark."
5084 (gnus-summary-save-process-mark)
5085 (gnus-summary-unmark-all-processable))
5087 (defun gnus-summary-yank-process-mark ()
5088 "Pop the last process mark state off the stack and restore it."
5090 (unless gnus-newsgroup-process-stack
5091 (error "Empty mark stack"))
5092 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5094 (defun gnus-summary-process-mark-set (set)
5095 "Make SET into the current process marked articles."
5096 (gnus-summary-unmark-all-processable)
5098 (gnus-summary-set-process-mark (pop set))))
5100 ;;; Searching and stuff
5102 (defun gnus-summary-search-group (&optional backward use-level)
5103 "Search for next unread newsgroup.
5104 If optional argument BACKWARD is non-nil, search backward instead."
5106 (set-buffer gnus-group-buffer)
5107 (when (gnus-group-search-forward
5108 backward nil (if use-level (gnus-group-group-level) nil))
5109 (gnus-group-group-name))))
5111 (defun gnus-summary-best-group (&optional exclude-group)
5112 "Find the name of the best unread group.
5113 If EXCLUDE-GROUP, do not go to this group."
5115 (set-buffer gnus-group-buffer)
5117 (gnus-group-best-unread-group exclude-group))))
5119 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5120 (if backward (gnus-summary-find-prev)
5121 (let* ((dummy (gnus-summary-article-intangible-p))
5122 (article (or article (gnus-summary-article-number)))
5123 (arts (gnus-data-find-list article))
5125 (when (and (not dummy)
5126 (or (not gnus-summary-check-current)
5128 (not (gnus-data-unread-p (car arts)))))
5129 (setq arts (cdr arts)))
5134 (when (or (and undownloaded
5135 (eq gnus-undownloaded-mark
5136 (gnus-data-mark (car arts))))
5137 (gnus-data-unread-p (car arts)))
5138 (setq result (car arts)
5140 (setq arts (cdr arts)))
5143 (goto-char (gnus-data-pos result))
5144 (gnus-data-number result)))))
5146 (defun gnus-summary-find-prev (&optional unread article)
5147 (let* ((eobp (eobp))
5148 (article (or article (gnus-summary-article-number)))
5149 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5151 (when (and (not eobp)
5152 (or (not gnus-summary-check-current)
5154 (not (gnus-data-unread-p (car arts)))))
5155 (setq arts (cdr arts)))
5160 (when (gnus-data-unread-p (car arts))
5161 (setq result (car arts)
5163 (setq arts (cdr arts)))
5166 (goto-char (gnus-data-pos result))
5167 (gnus-data-number result))))
5169 (defun gnus-summary-find-subject (subject &optional unread backward article)
5170 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5171 (article (or article (gnus-summary-article-number)))
5172 (articles (gnus-data-list backward))
5173 (arts (gnus-data-find-list article articles))
5175 (when (or (not gnus-summary-check-current)
5177 (not (gnus-data-unread-p (car arts))))
5178 (setq arts (cdr arts)))
5180 (and (or (not unread)
5181 (gnus-data-unread-p (car arts)))
5182 (vectorp (gnus-data-header (car arts)))
5184 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5185 (setq result (car arts)
5187 (setq arts (cdr arts)))
5189 (goto-char (gnus-data-pos result))
5190 (gnus-data-number result))))
5192 (defun gnus-summary-search-forward (&optional unread subject backward)
5193 "Search forward for an article.
5194 If UNREAD, look for unread articles. If SUBJECT, look for
5195 articles with that subject. If BACKWARD, search backward instead."
5196 (cond (subject (gnus-summary-find-subject subject unread backward))
5197 (backward (gnus-summary-find-prev unread))
5198 (t (gnus-summary-find-next unread))))
5200 (defun gnus-recenter (&optional n)
5201 "Center point in window and redisplay frame.
5202 Also do horizontal recentering."
5204 (when (and gnus-auto-center-summary
5205 (not (eq gnus-auto-center-summary 'vertical)))
5206 (gnus-horizontal-recenter))
5209 (defun gnus-summary-recenter ()
5210 "Center point in the summary window.
5211 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5212 displayed, no centering will be performed."
5213 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5214 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5216 (let* ((top (cond ((< (window-height) 4) 0)
5217 ((< (window-height) 7) 1)
5218 (t (if (numberp gnus-auto-center-summary)
5219 gnus-auto-center-summary
5221 (height (1- (window-height)))
5222 (bottom (save-excursion (goto-char (point-max))
5223 (forward-line (- height))
5225 (window (get-buffer-window (current-buffer))))
5226 ;; The user has to want it.
5227 (when gnus-auto-center-summary
5228 (when (get-buffer-window gnus-article-buffer)
5229 ;; Only do recentering when the article buffer is displayed,
5230 ;; Set the window start to either `bottom', which is the biggest
5231 ;; possible valid number, or the second line from the top,
5232 ;; whichever is the least.
5234 window (min bottom (save-excursion
5235 (forward-line (- top)) (point)))
5237 ;; Do horizontal recentering while we're at it.
5238 (when (and (get-buffer-window (current-buffer) t)
5239 (not (eq gnus-auto-center-summary 'vertical)))
5240 (let ((selected (selected-window)))
5241 (select-window (get-buffer-window (current-buffer) t))
5242 (gnus-summary-position-point)
5243 (gnus-horizontal-recenter)
5244 (select-window selected))))))
5246 (defun gnus-summary-jump-to-group (newsgroup)
5247 "Move point to NEWSGROUP in group mode buffer."
5248 ;; Keep update point of group mode buffer if visible.
5249 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5250 (save-window-excursion
5251 ;; Take care of tree window mode.
5252 (when (get-buffer-window gnus-group-buffer)
5253 (pop-to-buffer gnus-group-buffer))
5254 (gnus-group-jump-to-group newsgroup))
5256 ;; Take care of tree window mode.
5257 (if (get-buffer-window gnus-group-buffer)
5258 (pop-to-buffer gnus-group-buffer)
5259 (set-buffer gnus-group-buffer))
5260 (gnus-group-jump-to-group newsgroup))))
5262 ;; This function returns a list of article numbers based on the
5263 ;; difference between the ranges of read articles in this group and
5264 ;; the range of active articles.
5265 (defun gnus-list-of-unread-articles (group)
5266 (let* ((read (gnus-info-read (gnus-get-info group)))
5267 (active (or (gnus-active group) (gnus-activate-group group)))
5270 ;; If none are read, then all are unread.
5272 (setq first (car active))
5273 ;; If the range of read articles is a single range, then the
5274 ;; first unread article is the article after the last read
5275 ;; article. Sounds logical, doesn't it?
5276 (if (and (not (listp (cdr read)))
5277 (or (< (car read) (car active))
5278 (progn (setq read (list read))
5280 (setq first (max (car active) (1+ (cdr read))))
5281 ;; `read' is a list of ranges.
5282 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5285 (setq first (car active)))
5288 (while (< first nlast)
5290 (setq first (1+ first))))
5291 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5292 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5293 (setq read (cdr read)))))
5294 ;; And add the last unread articles.
5295 (while (<= first last)
5297 (setq first (1+ first)))
5298 ;; Return the list of unread articles.
5299 (delq 0 (nreverse unread))))
5301 (defun gnus-list-of-read-articles (group)
5302 "Return a list of unread, unticked and non-dormant articles."
5303 (let* ((info (gnus-get-info group))
5304 (marked (gnus-info-marks info))
5305 (active (gnus-active group)))
5307 (gnus-set-difference
5308 (gnus-sorted-complement
5309 (gnus-uncompress-range active)
5310 (gnus-list-of-unread-articles group))
5312 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5313 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5315 ;; Various summary commands
5317 (defun gnus-summary-select-article-buffer ()
5318 "Reconfigure windows to show article buffer."
5320 (if (not (gnus-buffer-live-p gnus-article-buffer))
5321 (error "There is no article buffer for this summary buffer")
5322 (gnus-configure-windows 'article)
5323 (select-window (get-buffer-window gnus-article-buffer))))
5325 (defun gnus-summary-universal-argument (arg)
5326 "Perform any operation on all articles that are process/prefixed."
5328 (let ((articles (gnus-summary-work-articles arg))
5335 (substitute-command-keys
5336 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5338 (gnus-error 1 "Undefined key")
5341 (gnus-summary-goto-subject (setq article (pop articles)))
5342 (let (gnus-newsgroup-processable)
5343 (command-execute func))
5344 (gnus-summary-remove-process-mark article)))))
5345 (gnus-summary-position-point))
5347 (defun gnus-summary-toggle-truncation (&optional arg)
5348 "Toggle truncation of summary lines.
5349 With arg, turn line truncation on iff arg is positive."
5351 (setq truncate-lines
5352 (if (null arg) (not truncate-lines)
5353 (> (prefix-numeric-value arg) 0)))
5356 (defun gnus-summary-reselect-current-group (&optional all rescan)
5357 "Exit and then reselect the current newsgroup.
5358 The prefix argument ALL means to select all articles."
5360 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5361 (error "Ephemeral groups can't be reselected"))
5362 (let ((current-subject (gnus-summary-article-number))
5363 (group gnus-newsgroup-name))
5364 (setq gnus-newsgroup-begin nil)
5366 ;; We have to adjust the point of group mode buffer because
5367 ;; point was moved to the next unread newsgroup by exiting.
5368 (gnus-summary-jump-to-group group)
5371 (gnus-group-get-new-news-this-group 1)))
5372 (gnus-group-read-group all t)
5373 (gnus-summary-goto-subject current-subject nil t)))
5375 (defun gnus-summary-rescan-group (&optional all)
5376 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5378 (gnus-summary-reselect-current-group all t))
5380 (defun gnus-summary-update-info (&optional non-destructive)
5382 (let ((group gnus-newsgroup-name))
5384 (when gnus-newsgroup-kill-headers
5385 (setq gnus-newsgroup-killed
5386 (gnus-compress-sequence
5388 (gnus-set-sorted-intersection
5389 (gnus-uncompress-range gnus-newsgroup-killed)
5390 (setq gnus-newsgroup-unselected
5391 (sort gnus-newsgroup-unselected '<)))
5392 (setq gnus-newsgroup-unreads
5393 (sort gnus-newsgroup-unreads '<)))
5395 (unless (listp (cdr gnus-newsgroup-killed))
5396 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5397 (let ((headers gnus-newsgroup-headers))
5398 ;; Set the new ranges of read articles.
5400 (set-buffer gnus-group-buffer)
5401 (gnus-undo-force-boundary))
5402 (gnus-update-read-articles
5403 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5404 ;; Set the current article marks.
5405 (let ((gnus-newsgroup-scored
5406 (if (and (not gnus-save-score)
5407 (not non-destructive))
5409 gnus-newsgroup-scored)))
5411 (gnus-update-marks)))
5412 ;; Do the cross-ref thing.
5413 (when gnus-use-cross-reference
5414 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5415 ;; Do not switch windows but change the buffer to work.
5416 (set-buffer gnus-group-buffer)
5417 (unless (gnus-ephemeral-group-p group)
5418 (gnus-group-update-group group)))))))
5420 (defun gnus-summary-save-newsrc (&optional force)
5421 "Save the current number of read/marked articles in the dribble buffer.
5422 The dribble buffer will then be saved.
5423 If FORCE (the prefix), also save the .newsrc file(s)."
5425 (gnus-summary-update-info t)
5427 (gnus-save-newsrc-file)
5428 (gnus-dribble-save)))
5430 (defun gnus-summary-exit (&optional temporary)
5431 "Exit reading current newsgroup, and then return to group selection mode.
5432 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5434 (gnus-set-global-variables)
5435 (when (gnus-buffer-live-p gnus-article-buffer)
5437 (set-buffer gnus-article-buffer)
5438 (mm-destroy-parts gnus-article-mime-handles)
5439 ;; Set it to nil for safety reason.
5440 (setq gnus-article-mime-handle-alist nil)
5441 (setq gnus-article-mime-handles nil)))
5442 (gnus-kill-save-kill-buffer)
5443 (gnus-async-halt-prefetch)
5444 (let* ((group gnus-newsgroup-name)
5445 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5448 (buf (current-buffer)))
5450 ;; Do adaptive scoring, and possibly save score files.
5451 (when gnus-newsgroup-adaptive
5452 (gnus-score-adaptive))
5453 (when gnus-use-scoring
5455 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5456 ;; If we have several article buffers, we kill them at exit.
5457 (unless gnus-single-article-buffer
5458 (gnus-kill-buffer gnus-original-article-buffer)
5459 (setq gnus-article-current nil))
5460 (when gnus-use-cache
5461 (gnus-cache-possibly-remove-articles)
5462 (gnus-cache-save-buffers))
5463 (gnus-async-prefetch-remove-group group)
5464 (when gnus-suppress-duplicates
5465 (gnus-dup-enter-articles))
5466 (when gnus-use-trees
5467 (gnus-tree-close group))
5468 (when gnus-use-cache
5469 (gnus-cache-write-active))
5470 ;; Remove entries for this group.
5471 (nnmail-purge-split-history (gnus-group-real-name group))
5472 ;; Make all changes in this group permanent.
5474 (gnus-run-hooks 'gnus-exit-group-hook)
5475 (gnus-summary-update-info))
5476 (gnus-close-group group)
5477 ;; Make sure where we were, and go to next newsgroup.
5478 (set-buffer gnus-group-buffer)
5480 (gnus-group-jump-to-group group))
5481 (gnus-run-hooks 'gnus-summary-exit-hook)
5482 (unless (or quit-config
5483 ;; If this group has disappeared from the summary
5484 ;; buffer, don't skip forwards.
5485 (not (string= group (gnus-group-group-name))))
5486 (gnus-group-next-unread-group 1))
5487 (setq group-point (point))
5490 ;; If we have several article buffers, we kill them at exit.
5491 (unless gnus-single-article-buffer
5492 (gnus-kill-buffer gnus-article-buffer)
5493 (gnus-kill-buffer gnus-original-article-buffer)
5494 (setq gnus-article-current nil))
5496 (if (not gnus-kill-summary-on-exit)
5497 (gnus-deaden-summary)
5498 ;; We set all buffer-local variables to nil. It is unclear why
5499 ;; this is needed, but if we don't, buffer-local variables are
5500 ;; not garbage-collected, it seems. This would the lead to en
5501 ;; ever-growing Emacs.
5502 (gnus-summary-clear-local-variables)
5503 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5504 (gnus-summary-clear-local-variables))
5505 (when (get-buffer gnus-article-buffer)
5506 (bury-buffer gnus-article-buffer))
5507 ;; We clear the global counterparts of the buffer-local
5508 ;; variables as well, just to be on the safe side.
5509 (set-buffer gnus-group-buffer)
5510 (gnus-summary-clear-local-variables)
5511 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5512 (gnus-summary-clear-local-variables))
5513 ;; Return to group mode buffer.
5514 (when (eq mode 'gnus-summary-mode)
5515 (gnus-kill-buffer buf)))
5516 (setq gnus-current-select-method gnus-select-method)
5517 (pop-to-buffer gnus-group-buffer)
5518 (if (not quit-config)
5520 (goto-char group-point)
5521 (gnus-configure-windows 'group 'force))
5522 (gnus-handle-ephemeral-exit quit-config))
5523 ;; Clear the current group name.
5525 (setq gnus-newsgroup-name nil)))))
5527 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5528 (defun gnus-summary-exit-no-update (&optional no-questions)
5529 "Quit reading current newsgroup without updating read article info."
5531 (let* ((group gnus-newsgroup-name)
5532 (quit-config (gnus-group-quit-config group)))
5533 (when (or no-questions
5535 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5536 (gnus-async-halt-prefetch)
5538 (delq 'gnus-summary-expire-articles
5539 (copy-sequence gnus-summary-prepare-exit-hook)))
5540 (when (gnus-buffer-live-p gnus-article-buffer)
5542 (set-buffer gnus-article-buffer)
5543 (mm-destroy-parts gnus-article-mime-handles)
5544 ;; Set it to nil for safety reason.
5545 (setq gnus-article-mime-handle-alist nil)
5546 (setq gnus-article-mime-handles nil)))
5547 ;; If we have several article buffers, we kill them at exit.
5548 (unless gnus-single-article-buffer
5549 (gnus-kill-buffer gnus-article-buffer)
5550 (gnus-kill-buffer gnus-original-article-buffer)
5551 (setq gnus-article-current nil))
5552 (if (not gnus-kill-summary-on-exit)
5553 (gnus-deaden-summary)
5554 (gnus-close-group group)
5555 (gnus-summary-clear-local-variables)
5556 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5557 (gnus-summary-clear-local-variables))
5558 (set-buffer gnus-group-buffer)
5559 (gnus-summary-clear-local-variables)
5560 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5561 (gnus-summary-clear-local-variables))
5562 (when (get-buffer gnus-summary-buffer)
5563 (kill-buffer gnus-summary-buffer)))
5564 (unless gnus-single-article-buffer
5565 (setq gnus-article-current nil))
5566 (when gnus-use-trees
5567 (gnus-tree-close group))
5568 (gnus-async-prefetch-remove-group group)
5569 (when (get-buffer gnus-article-buffer)
5570 (bury-buffer gnus-article-buffer))
5571 ;; Return to the group buffer.
5572 (gnus-configure-windows 'group 'force)
5573 ;; Clear the current group name.
5574 (setq gnus-newsgroup-name nil)
5575 (when (equal (gnus-group-group-name) group)
5576 (gnus-group-next-unread-group 1))
5578 (gnus-handle-ephemeral-exit quit-config)))))
5580 (defun gnus-handle-ephemeral-exit (quit-config)
5581 "Handle movement when leaving an ephemeral group.
5582 The state which existed when entering the ephemeral is reset."
5583 (if (not (buffer-name (car quit-config)))
5584 (gnus-configure-windows 'group 'force)
5585 (set-buffer (car quit-config))
5586 (cond ((eq major-mode 'gnus-summary-mode)
5587 (gnus-set-global-variables))
5588 ((eq major-mode 'gnus-article-mode)
5590 ;; The `gnus-summary-buffer' variable may point
5591 ;; to the old summary buffer when using a single
5593 (unless (gnus-buffer-live-p gnus-summary-buffer)
5594 (set-buffer gnus-group-buffer))
5595 (set-buffer gnus-summary-buffer)
5596 (gnus-set-global-variables))))
5597 (if (or (eq (cdr quit-config) 'article)
5598 (eq (cdr quit-config) 'pick))
5600 ;; The current article may be from the ephemeral group
5601 ;; thus it is best that we reload this article
5602 (gnus-summary-show-article)
5603 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5604 (gnus-configure-windows 'pick 'force)
5605 (gnus-configure-windows (cdr quit-config) 'force)))
5606 (gnus-configure-windows (cdr quit-config) 'force))
5607 (when (eq major-mode 'gnus-summary-mode)
5608 (gnus-summary-next-subject 1 nil t)
5609 (gnus-summary-recenter)
5610 (gnus-summary-position-point))))
5614 (defvar gnus-dead-summary-mode-map nil)
5616 (unless gnus-dead-summary-mode-map
5617 (setq gnus-dead-summary-mode-map (make-keymap))
5618 (suppress-keymap gnus-dead-summary-mode-map)
5619 (substitute-key-definition
5620 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5621 (let ((keys '("\C-d" "\r" "\177" [delete])))
5623 (define-key gnus-dead-summary-mode-map
5624 (pop keys) 'gnus-summary-wake-up-the-dead))))
5626 (defvar gnus-dead-summary-mode nil
5627 "Minor mode for Gnus summary buffers.")
5629 (defun gnus-dead-summary-mode (&optional arg)
5630 "Minor mode for Gnus summary buffers."
5632 (when (eq major-mode 'gnus-summary-mode)
5633 (make-local-variable 'gnus-dead-summary-mode)
5634 (setq gnus-dead-summary-mode
5635 (if (null arg) (not gnus-dead-summary-mode)
5636 (> (prefix-numeric-value arg) 0)))
5637 (when gnus-dead-summary-mode
5638 (gnus-add-minor-mode
5639 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5641 (defun gnus-deaden-summary ()
5642 "Make the current summary buffer into a dead summary buffer."
5643 ;; Kill any previous dead summary buffer.
5644 (when (and gnus-dead-summary
5645 (buffer-name gnus-dead-summary))
5647 (set-buffer gnus-dead-summary)
5648 (when gnus-dead-summary-mode
5649 (kill-buffer (current-buffer)))))
5650 ;; Make this the current dead summary.
5651 (setq gnus-dead-summary (current-buffer))
5652 (gnus-dead-summary-mode 1)
5653 (let ((name (buffer-name)))
5654 (when (string-match "Summary" name)
5656 (concat (substring name 0 (match-beginning 0)) "Dead "
5657 (substring name (match-beginning 0)))
5661 (defun gnus-kill-or-deaden-summary (buffer)
5662 "Kill or deaden the summary BUFFER."
5664 (when (and (buffer-name buffer)
5665 (not gnus-single-article-buffer))
5668 (gnus-kill-buffer gnus-article-buffer)
5669 (gnus-kill-buffer gnus-original-article-buffer)))
5670 (cond (gnus-kill-summary-on-exit
5671 (when (and gnus-use-trees
5672 (gnus-buffer-exists-p buffer))
5675 (gnus-tree-close gnus-newsgroup-name)))
5676 (gnus-kill-buffer buffer))
5677 ((gnus-buffer-exists-p buffer)
5680 (gnus-deaden-summary))))))
5682 (defun gnus-summary-wake-up-the-dead (&rest args)
5683 "Wake up the dead summary buffer."
5685 (gnus-dead-summary-mode -1)
5686 (let ((name (buffer-name)))
5687 (when (string-match "Dead " name)
5689 (concat (substring name 0 (match-beginning 0))
5690 (substring name (match-end 0)))
5692 (gnus-message 3 "This dead summary is now alive again"))
5694 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5695 (defun gnus-summary-fetch-faq (&optional faq-dir)
5696 "Fetch the FAQ for the current group.
5697 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5701 (when current-prefix-arg
5703 "Faq dir: " (and (listp gnus-group-faq-directory)
5704 (mapcar (lambda (file) (list file))
5705 gnus-group-faq-directory))))))
5706 (let (gnus-faq-buffer)
5707 (when (setq gnus-faq-buffer
5708 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5709 (gnus-configure-windows 'summary-faq))))
5711 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5712 (defun gnus-summary-describe-group (&optional force)
5713 "Describe the current newsgroup."
5715 (gnus-group-describe-group force gnus-newsgroup-name))
5717 (defun gnus-summary-describe-briefly ()
5718 "Describe summary mode commands briefly."
5720 (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")))
5722 ;; Walking around group mode buffer from summary mode.
5724 (defun gnus-summary-next-group (&optional no-article target-group backward)
5725 "Exit current newsgroup and then select next unread newsgroup.
5726 If prefix argument NO-ARTICLE is non-nil, no article is selected
5727 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5728 previous group instead."
5730 ;; Stop pre-fetching.
5731 (gnus-async-halt-prefetch)
5732 (let ((current-group gnus-newsgroup-name)
5733 (current-buffer (current-buffer))
5735 ;; First we semi-exit this group to update Xrefs and all variables.
5736 ;; We can't do a real exit, because the window conf must remain
5737 ;; the same in case the user is prompted for info, and we don't
5738 ;; want the window conf to change before that...
5739 (gnus-summary-exit t)
5740 (while (not entered)
5741 ;; Then we find what group we are supposed to enter.
5742 (set-buffer gnus-group-buffer)
5743 (gnus-group-jump-to-group current-group)
5746 (if (eq gnus-keep-same-level 'best)
5747 (gnus-summary-best-group gnus-newsgroup-name)
5748 (gnus-summary-search-group backward gnus-keep-same-level))))
5749 (if (not target-group)
5750 ;; There are no further groups, so we return to the group
5753 (gnus-message 5 "Returning to the group buffer")
5755 (when (gnus-buffer-live-p current-buffer)
5756 (set-buffer current-buffer)
5757 (gnus-summary-exit))
5758 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5759 ;; We try to enter the target group.
5760 (gnus-group-jump-to-group target-group)
5761 (let ((unreads (gnus-group-group-unread)))
5762 (if (and (or (eq t unreads)
5763 (and unreads (not (zerop unreads))))
5764 (gnus-summary-read-group
5765 target-group nil no-article
5766 (and (buffer-name current-buffer) current-buffer)
5769 (setq current-group target-group
5770 target-group nil)))))))
5772 (defun gnus-summary-prev-group (&optional no-article)
5773 "Exit current newsgroup and then select previous unread newsgroup.
5774 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5776 (gnus-summary-next-group no-article nil t))
5778 ;; Walking around summary lines.
5780 (defun gnus-summary-first-subject (&optional unread undownloaded)
5781 "Go to the first unread subject.
5782 If UNREAD is non-nil, go to the first unread article.
5783 Returns the article selected or nil if there are no unread articles."
5788 ((null gnus-newsgroup-data)
5789 (gnus-message 3 "No articles in the group")
5791 ;; Pick the first article.
5793 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5794 (gnus-data-number (car gnus-newsgroup-data)))
5795 ;; No unread articles.
5796 ((null gnus-newsgroup-unreads)
5797 (gnus-message 3 "No more unread articles")
5799 ;; Find the first unread article.
5801 (let ((data gnus-newsgroup-data))
5803 (and (not (and undownloaded
5804 (eq gnus-undownloaded-mark
5805 (gnus-data-mark (car data)))))
5806 (not (gnus-data-unread-p (car data)))))
5807 (setq data (cdr data)))
5809 (goto-char (gnus-data-pos (car data)))
5810 (gnus-data-number (car data))))))
5811 (gnus-summary-position-point)))
5813 (defun gnus-summary-next-subject (n &optional unread dont-display)
5814 "Go to next N'th summary line.
5815 If N is negative, go to the previous N'th subject line.
5816 If UNREAD is non-nil, only unread articles are selected.
5817 The difference between N and the actual number of steps taken is
5820 (let ((backward (< n 0))
5824 (gnus-summary-find-prev unread)
5825 (gnus-summary-find-next unread)))
5826 (unless (zerop (setq n (1- n)))
5827 (gnus-summary-show-thread)))
5829 (gnus-message 7 "No more%s articles"
5830 (if unread " unread" "")))
5831 (unless dont-display
5832 (gnus-summary-recenter)
5833 (gnus-summary-position-point))
5836 (defun gnus-summary-next-unread-subject (n)
5837 "Go to next N'th unread summary line."
5839 (gnus-summary-next-subject n t))
5841 (defun gnus-summary-prev-subject (n &optional unread)
5842 "Go to previous N'th summary line.
5843 If optional argument UNREAD is non-nil, only unread article is selected."
5845 (gnus-summary-next-subject (- n) unread))
5847 (defun gnus-summary-prev-unread-subject (n)
5848 "Go to previous N'th unread summary line."
5850 (gnus-summary-next-subject (- n) t))
5852 (defun gnus-summary-goto-subject (article &optional force silent)
5853 "Go the subject line of ARTICLE.
5854 If FORCE, also allow jumping to articles not currently shown."
5855 (interactive "nArticle number: ")
5857 (data (gnus-data-find article)))
5858 ;; We read in the article if we have to.
5861 (gnus-summary-insert-subject
5863 (if (or (numberp force) (vectorp force)) force)
5865 (setq data (gnus-data-find article)))
5870 (gnus-message 3 "Can't find article %d" article))
5872 (goto-char (gnus-data-pos data))
5873 (gnus-summary-position-point)
5876 ;; Walking around summary lines with displaying articles.
5878 (defun gnus-summary-expand-window (&optional arg)
5879 "Make the summary buffer take up the entire Emacs frame.
5880 Given a prefix, will force an `article' buffer configuration."
5883 (gnus-configure-windows 'article 'force)
5884 (gnus-configure-windows 'summary 'force)))
5886 (defun gnus-summary-display-article (article &optional all-header)
5887 "Display ARTICLE in article buffer."
5888 (gnus-set-global-variables)
5889 (when (gnus-buffer-live-p gnus-article-buffer)
5890 (with-current-buffer gnus-article-buffer
5891 (setq gnus-article-charset gnus-newsgroup-charset)
5892 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
5893 (mm-enable-multibyte-mule4)))
5897 (if gnus-summary-display-article-function
5898 (funcall gnus-summary-display-article-function article all-header)
5899 (gnus-article-prepare article all-header))
5900 (gnus-run-hooks 'gnus-select-article-hook)
5901 (when (and gnus-current-article
5902 (not (zerop gnus-current-article)))
5903 (gnus-summary-goto-subject gnus-current-article))
5904 (gnus-summary-recenter)
5905 (when (and gnus-use-trees gnus-show-threads)
5906 (gnus-possibly-generate-tree article)
5907 (gnus-highlight-selected-tree article))
5908 ;; Successfully display article.
5909 (gnus-article-set-window-start
5910 (cdr (assq article gnus-newsgroup-bookmarks))))))
5912 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5913 "Select the current article.
5914 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5915 non-nil, the article will be re-fetched even if it already present in
5916 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5918 ;; Make sure we are in the summary buffer to work around bbdb bug.
5919 (unless (eq major-mode 'gnus-summary-mode)
5920 (set-buffer gnus-summary-buffer))
5921 (let ((article (or article (gnus-summary-article-number)))
5922 (all-headers (not (not all-headers))) ;Must be T or NIL.
5923 gnus-summary-display-article-function)
5925 (gnus-summary-article-pseudo-p article)
5926 (error "This is a pseudo-article"))
5928 (set-buffer gnus-summary-buffer)
5929 (if (or (and gnus-single-article-buffer
5930 (or (null gnus-current-article)
5931 (null gnus-article-current)
5932 (null (get-buffer gnus-article-buffer))
5933 (not (eq article (cdr gnus-article-current)))
5934 (not (equal (car gnus-article-current)
5935 gnus-newsgroup-name))))
5936 (and (not gnus-single-article-buffer)
5937 (or (null gnus-current-article)
5938 (not (eq gnus-current-article article))))
5940 ;; The requested article is different from the current article.
5942 (gnus-summary-display-article article all-headers)
5943 (when (gnus-buffer-live-p gnus-article-buffer)
5944 (with-current-buffer gnus-article-buffer
5945 (if (not gnus-article-decoded-p) ;; a local variable
5946 (mm-disable-multibyte-mule4))))
5947 (when (or all-headers gnus-show-all-headers)
5948 (gnus-article-show-all-headers))
5949 (gnus-article-set-window-start
5950 (cdr (assq article gnus-newsgroup-bookmarks)))
5952 (when (or all-headers gnus-show-all-headers)
5953 (gnus-article-show-all-headers))
5956 (defun gnus-summary-force-verify-and-decrypt ()
5958 (let ((mm-verify-option 'known)
5959 (mm-decrypt-option 'known))
5960 (gnus-summary-select-article nil 'force)))
5962 (defun gnus-summary-set-current-mark (&optional current-mark)
5963 "Obsolete function."
5966 (defun gnus-summary-next-article (&optional unread subject backward push)
5967 "Select the next article.
5968 If UNREAD, only unread articles are selected.
5969 If SUBJECT, only articles with SUBJECT are selected.
5970 If BACKWARD, the previous article is selected instead of the next."
5973 ;; Is there such an article?
5974 ((and (gnus-summary-search-forward unread subject backward)
5975 (or (gnus-summary-display-article (gnus-summary-article-number))
5976 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5977 (gnus-summary-position-point))
5978 ;; If not, we try the first unread, if that is wanted.
5980 gnus-auto-select-same
5981 (gnus-summary-first-unread-article))
5982 (gnus-summary-position-point)
5983 (gnus-message 6 "Wrapped"))
5984 ;; Try to get next/previous article not displayed in this group.
5985 ((and gnus-auto-extend-newsgroup
5986 (not unread) (not subject))
5987 (gnus-summary-goto-article
5988 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5989 nil (count-lines (point-min) (point))))
5990 ;; Go to next/previous group.
5992 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5993 (gnus-summary-jump-to-group gnus-newsgroup-name))
5994 (let ((cmd last-command-char)
5997 (set-buffer gnus-group-buffer)
6000 (if (eq gnus-keep-same-level 'best)
6001 (gnus-summary-best-group gnus-newsgroup-name)
6002 (gnus-summary-search-group backward gnus-keep-same-level))))
6003 ;; For some reason, the group window gets selected. We change
6005 (select-window (get-buffer-window (current-buffer)))
6006 ;; Select next unread newsgroup automagically.
6008 ((or (not gnus-auto-select-next)
6010 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6011 ((or (eq gnus-auto-select-next 'quietly)
6012 (and (eq gnus-auto-select-next 'slightly-quietly)
6014 (and (eq gnus-auto-select-next 'almost-quietly)
6015 (gnus-summary-last-article-p)))
6017 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6019 (gnus-message 7 "No more%s articles (%s)..."
6020 (if unread " unread" "")
6021 (if group (concat "selecting " group)
6023 (gnus-summary-next-group nil group backward)))
6025 (when (gnus-key-press-event-p last-input-event)
6026 (gnus-summary-walk-group-buffer
6027 gnus-newsgroup-name cmd unread backward point))))))))
6029 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6030 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6031 (?\C-p (gnus-group-prev-unread-group 1))))
6032 (cursor-in-echo-area t)
6033 keve key group ended)
6035 (set-buffer gnus-group-buffer)
6038 (if (eq gnus-keep-same-level 'best)
6039 (gnus-summary-best-group gnus-newsgroup-name)
6040 (gnus-summary-search-group backward gnus-keep-same-level))))
6043 5 "No more%s articles%s" (if unread " unread" "")
6045 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6046 (format " (Type %s for %s [%s])"
6047 (single-key-description cmd) group
6048 (car (gnus-gethash group gnus-newsrc-hashtb)))
6049 (format " (Type %s to exit %s)"
6050 (single-key-description cmd)
6051 gnus-newsgroup-name)))
6052 ;; Confirm auto selection.
6053 (setq key (car (setq keve (gnus-read-event-char))))
6056 ((assq key keystrokes)
6057 (let ((obuf (current-buffer)))
6058 (switch-to-buffer gnus-group-buffer)
6060 (gnus-group-jump-to-group group))
6061 (eval (cadr (assq key keystrokes)))
6062 (setq group (gnus-group-group-name))
6063 (switch-to-buffer obuf))
6067 (gnus-ephemeral-group-p gnus-newsgroup-name))
6069 (gnus-summary-next-group nil group backward)))
6071 (push (cdr keve) unread-command-events))))))
6073 (defun gnus-summary-next-unread-article ()
6074 "Select unread article after current one."
6076 (gnus-summary-next-article
6077 (or (not (eq gnus-summary-goto-unread 'never))
6078 (gnus-summary-last-article-p (gnus-summary-article-number)))
6079 (and gnus-auto-select-same
6080 (gnus-summary-article-subject))))
6082 (defun gnus-summary-prev-article (&optional unread subject)
6083 "Select the article after the current one.
6084 If UNREAD is non-nil, only unread articles are selected."
6086 (gnus-summary-next-article unread subject t))
6088 (defun gnus-summary-prev-unread-article ()
6089 "Select unread article before current one."
6091 (gnus-summary-prev-article
6092 (or (not (eq gnus-summary-goto-unread 'never))
6093 (gnus-summary-first-article-p (gnus-summary-article-number)))
6094 (and gnus-auto-select-same
6095 (gnus-summary-article-subject))))
6097 (defun gnus-summary-next-page (&optional lines circular)
6098 "Show next page of the selected article.
6099 If at the end of the current article, select the next article.
6100 LINES says how many lines should be scrolled up.
6102 If CIRCULAR is non-nil, go to the start of the article instead of
6103 selecting the next article when reaching the end of the current
6106 (setq gnus-summary-buffer (current-buffer))
6107 (gnus-set-global-variables)
6108 (let ((article (gnus-summary-article-number))
6109 (article-window (get-buffer-window gnus-article-buffer t))
6111 ;; If the buffer is empty, we have no article.
6113 (error "No article to select"))
6114 (gnus-configure-windows 'article)
6115 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6116 (if (and (eq gnus-summary-goto-unread 'never)
6117 (not (gnus-summary-last-article-p article)))
6118 (gnus-summary-next-article)
6119 (gnus-summary-next-unread-article))
6120 (if (or (null gnus-current-article)
6121 (null gnus-article-current)
6122 (/= article (cdr gnus-article-current))
6123 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6124 ;; Selected subject is different from current article's.
6125 (gnus-summary-display-article article)
6126 (when article-window
6127 (gnus-eval-in-buffer-window gnus-article-buffer
6128 (setq endp (gnus-article-next-page lines)))
6131 (gnus-summary-beginning-of-article))
6133 (gnus-message 3 "End of message"))
6135 (if (and (eq gnus-summary-goto-unread 'never)
6136 (not (gnus-summary-last-article-p article)))
6137 (gnus-summary-next-article)
6138 (gnus-summary-next-unread-article))))))))
6139 (gnus-summary-recenter)
6140 (gnus-summary-position-point)))
6142 (defun gnus-summary-prev-page (&optional lines move)
6143 "Show previous page of selected article.
6144 Argument LINES specifies lines to be scrolled down.
6145 If MOVE, move to the previous unread article if point is at
6146 the beginning of the buffer."
6148 (let ((article (gnus-summary-article-number))
6149 (article-window (get-buffer-window gnus-article-buffer t))
6151 (gnus-configure-windows 'article)
6152 (if (or (null gnus-current-article)
6153 (null gnus-article-current)
6154 (/= article (cdr gnus-article-current))
6155 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6156 ;; Selected subject is different from current article's.
6157 (gnus-summary-display-article article)
6158 (gnus-summary-recenter)
6159 (when article-window
6160 (gnus-eval-in-buffer-window gnus-article-buffer
6161 (setq endp (gnus-article-prev-page lines)))
6162 (when (and move endp)
6164 (gnus-message 3 "Beginning of message"))
6166 (if (and (eq gnus-summary-goto-unread 'never)
6167 (not (gnus-summary-first-article-p article)))
6168 (gnus-summary-prev-article)
6169 (gnus-summary-prev-unread-article))))))))
6170 (gnus-summary-position-point))
6172 (defun gnus-summary-prev-page-or-article (&optional lines)
6173 "Show previous page of selected article.
6174 Argument LINES specifies lines to be scrolled down.
6175 If at the beginning of the article, go to the next article."
6177 (gnus-summary-prev-page lines t))
6179 (defun gnus-summary-scroll-up (lines)
6180 "Scroll up (or down) one line current article.
6181 Argument LINES specifies lines to be scrolled up (or down if negative)."
6183 (gnus-configure-windows 'article)
6184 (gnus-summary-show-thread)
6185 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6186 (gnus-eval-in-buffer-window gnus-article-buffer
6188 (when (gnus-article-next-page lines)
6189 (gnus-message 3 "End of message")))
6191 (gnus-article-prev-page (- lines))))))
6192 (gnus-summary-recenter)
6193 (gnus-summary-position-point))
6195 (defun gnus-summary-scroll-down (lines)
6196 "Scroll down (or up) one line current article.
6197 Argument LINES specifies lines to be scrolled down (or up if negative)."
6199 (gnus-summary-scroll-up (- lines)))
6201 (defun gnus-summary-next-same-subject ()
6202 "Select next article which has the same subject as current one."
6204 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6206 (defun gnus-summary-prev-same-subject ()
6207 "Select previous article which has the same subject as current one."
6209 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6211 (defun gnus-summary-next-unread-same-subject ()
6212 "Select next unread article which has the same subject as current one."
6214 (gnus-summary-next-article t (gnus-summary-article-subject)))
6216 (defun gnus-summary-prev-unread-same-subject ()
6217 "Select previous unread article which has the same subject as current one."
6219 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6221 (defun gnus-summary-first-unread-article ()
6222 "Select the first unread article.
6223 Return nil if there are no unread articles."
6226 (when (gnus-summary-first-subject t)
6227 (gnus-summary-show-thread)
6228 (gnus-summary-first-subject t)
6229 (gnus-summary-display-article (gnus-summary-article-number)))
6230 (gnus-summary-position-point)))
6232 (defun gnus-summary-first-unread-subject ()
6233 "Place the point on the subject line of the first unread article.
6234 Return nil if there are no unread articles."
6237 (when (gnus-summary-first-subject t)
6238 (gnus-summary-show-thread)
6239 (gnus-summary-first-subject t))
6240 (gnus-summary-position-point)))
6242 (defun gnus-summary-first-article ()
6243 "Select the first article.
6244 Return nil if there are no articles."
6247 (when (gnus-summary-first-subject)
6248 (gnus-summary-show-thread)
6249 (gnus-summary-first-subject)
6250 (gnus-summary-display-article (gnus-summary-article-number)))
6251 (gnus-summary-position-point)))
6253 (defun gnus-summary-best-unread-article ()
6254 "Select the unread article with the highest score."
6256 (let ((best -1000000)
6257 (data gnus-newsgroup-data)
6260 (and (gnus-data-unread-p (car data))
6262 (gnus-summary-article-score (gnus-data-number (car data))))
6265 article (gnus-data-number (car data))))
6266 (setq data (cdr data)))
6269 (gnus-summary-goto-article article)
6270 (error "No unread articles"))
6271 (gnus-summary-position-point))))
6273 (defun gnus-summary-last-subject ()
6274 "Go to the last displayed subject line in the group."
6275 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6277 (gnus-summary-goto-subject article))))
6279 (defun gnus-summary-goto-article (article &optional all-headers force)
6280 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6281 If ALL-HEADERS is non-nil, no header lines are hidden.
6282 If FORCE, go to the article even if it isn't displayed. If FORCE
6283 is a number, it is the line the article is to be displayed on."
6287 "Article number or Message-ID: "
6288 (mapcar (lambda (number) (list (int-to-string number)))
6289 gnus-newsgroup-limit))
6293 (if (and (stringp article)
6294 (string-match "@" article))
6295 (gnus-summary-refer-article article)
6296 (when (stringp article)
6297 (setq article (string-to-number article)))
6298 (if (gnus-summary-goto-subject article force)
6299 (gnus-summary-display-article article all-headers)
6300 (gnus-message 4 "Couldn't go to article %s" article) nil))
6301 (gnus-summary-position-point)))
6303 (defun gnus-summary-goto-last-article ()
6304 "Go to the previously read article."
6307 (when gnus-last-article
6308 (gnus-summary-goto-article gnus-last-article nil t))
6309 (gnus-summary-position-point)))
6311 (defun gnus-summary-pop-article (number)
6312 "Pop one article off the history and go to the previous.
6313 NUMBER articles will be popped off."
6316 (setq gnus-newsgroup-history
6317 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6319 (gnus-summary-goto-article (car to) nil t)
6320 (error "Article history empty")))
6321 (gnus-summary-position-point))
6323 ;; Summary commands and functions for limiting the summary buffer.
6325 (defun gnus-summary-limit-to-articles (n)
6326 "Limit the summary buffer to the next N articles.
6327 If not given a prefix, use the process marked articles instead."
6330 (let ((articles (gnus-summary-work-articles n)))
6331 (setq gnus-newsgroup-processable nil)
6332 (gnus-summary-limit articles))
6333 (gnus-summary-position-point)))
6335 (defun gnus-summary-pop-limit (&optional total)
6336 "Restore the previous limit.
6337 If given a prefix, remove all limits."
6340 (setq gnus-newsgroup-limits
6341 (list (mapcar (lambda (h) (mail-header-number h))
6342 gnus-newsgroup-headers))))
6343 (unless gnus-newsgroup-limits
6344 (error "No limit to pop"))
6346 (gnus-summary-limit nil 'pop)
6347 (gnus-summary-position-point)))
6349 (defun gnus-summary-limit-to-subject (subject &optional header)
6350 "Limit the summary buffer to articles that have subjects that match a regexp."
6351 (interactive "sLimit to subject (regexp): ")
6353 (setq header "subject"))
6354 (when (not (equal "" subject))
6356 (let ((articles (gnus-summary-find-matching
6357 (or header "subject") subject 'all)))
6359 (error "Found no matches for \"%s\"" subject))
6360 (gnus-summary-limit articles))
6361 (gnus-summary-position-point))))
6363 (defun gnus-summary-limit-to-author (from)
6364 "Limit the summary buffer to articles that have authors that match a regexp."
6365 (interactive "sLimit to author (regexp): ")
6366 (gnus-summary-limit-to-subject from "from"))
6368 (defun gnus-summary-limit-to-age (age &optional younger-p)
6369 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6370 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6371 articles that are younger than AGE days."
6373 (let ((younger current-prefix-arg)
6376 (while (not days-got)
6377 (setq days (if younger
6378 (read-string "Limit to articles within (in days): ")
6379 (read-string "Limit to articles old than (in days): ")))
6380 (when (> (length days) 0)
6381 (setq days (read days)))
6384 (message "Please enter a number.")
6386 (list days younger)))
6388 (let ((data gnus-newsgroup-data)
6389 (cutoff (days-to-time age))
6390 articles d date is-younger)
6391 (while (setq d (pop data))
6392 (when (and (vectorp (gnus-data-header d))
6393 (setq date (mail-header-date (gnus-data-header d))))
6394 (setq is-younger (time-less-p
6395 (time-since (condition-case ()
6402 (push (gnus-data-number d) articles))))
6403 (gnus-summary-limit (nreverse articles)))
6404 (gnus-summary-position-point)))
6406 (defun gnus-summary-limit-to-extra (header regexp)
6407 "Limit the summary buffer to articles that match an 'extra' header."
6411 (gnus-completing-read
6412 (symbol-name (car gnus-extra-headers))
6413 "Limit extra header:"
6415 (cons (symbol-name x) x))
6420 (read-string (format "Limit to header %s (regexp): " header)))))
6421 (when (not (equal "" regexp))
6423 (let ((articles (gnus-summary-find-matching
6424 (cons 'extra header) regexp 'all)))
6426 (error "Found no matches for \"%s\"" regexp))
6427 (gnus-summary-limit articles))
6428 (gnus-summary-position-point))))
6430 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6432 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6434 (defun gnus-summary-limit-to-unread (&optional all)
6435 "Limit the summary buffer to articles that are not marked as read.
6436 If ALL is non-nil, limit strictly to unread articles."
6439 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6440 (gnus-summary-limit-to-marks
6441 ;; Concat all the marks that say that an article is read and have
6443 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6444 gnus-killed-mark gnus-kill-file-mark
6445 gnus-low-score-mark gnus-expirable-mark
6446 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6447 gnus-duplicate-mark gnus-souped-mark)
6450 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6451 (make-obsolete 'gnus-summary-delete-marked-with
6452 'gnus-summary-limit-exlude-marks)
6454 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6455 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6456 If REVERSE, limit the summary buffer to articles that are marked
6457 with MARKS. MARKS can either be a string of marks or a list of marks.
6458 Returns how many articles were removed."
6459 (interactive "sMarks: ")
6460 (gnus-summary-limit-to-marks marks t))
6462 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6463 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6464 If REVERSE (the prefix), limit the summary buffer to articles that are
6465 not marked with MARKS. MARKS can either be a string of marks or a
6467 Returns how many articles were removed."
6468 (interactive "sMarks: \nP")
6470 (let ((data gnus-newsgroup-data)
6471 (marks (if (listp marks) marks
6472 (append marks nil))) ; Transform to list.
6475 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6476 (memq (gnus-data-mark (car data)) marks))
6477 (push (gnus-data-number (car data)) articles))
6478 (setq data (cdr data)))
6479 (gnus-summary-limit articles))
6480 (gnus-summary-position-point)))
6482 (defun gnus-summary-limit-to-score (&optional score)
6483 "Limit to articles with score at or above SCORE."
6485 (setq score (if score
6486 (prefix-numeric-value score)
6487 (or gnus-summary-default-score 0)))
6488 (let ((data gnus-newsgroup-data)
6491 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6493 (push (gnus-data-number (car data)) articles))
6494 (setq data (cdr data)))
6496 (gnus-summary-limit articles)
6497 (gnus-summary-position-point))))
6499 (defun gnus-summary-limit-include-thread (id)
6500 "Display all the hidden articles that in the current thread."
6501 (interactive (list (mail-header-id (gnus-summary-article-header))))
6502 (let ((articles (gnus-articles-in-thread
6503 (gnus-id-to-thread (gnus-root-id id)))))
6505 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6506 (gnus-summary-position-point))))
6508 (defun gnus-summary-limit-include-dormant ()
6509 "Display all the hidden articles that are marked as dormant.
6510 Note that this command only works on a subset of the articles currently
6511 fetched for this group."
6513 (unless gnus-newsgroup-dormant
6514 (error "There are no dormant articles in this group"))
6516 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6517 (gnus-summary-position-point)))
6519 (defun gnus-summary-limit-exclude-dormant ()
6520 "Hide all dormant articles."
6523 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6524 (gnus-summary-position-point)))
6526 (defun gnus-summary-limit-exclude-childless-dormant ()
6527 "Hide all dormant articles that have no children."
6529 (let ((data (gnus-data-list t))
6530 articles d children)
6531 ;; Find all articles that are either not dormant or have
6533 (while (setq d (pop data))
6534 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6536 (gnus-article-children (gnus-data-number d)))
6539 (when (memq (car children) articles)
6544 (push (gnus-data-number d) articles)))
6547 (gnus-summary-limit articles)
6548 (gnus-summary-position-point))))
6550 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6551 "Mark all unread excluded articles as read.
6552 If ALL, mark even excluded ticked and dormants as read."
6554 (let ((articles (gnus-sorted-complement
6556 (mapcar (lambda (h) (mail-header-number h))
6557 gnus-newsgroup-headers)
6559 (sort gnus-newsgroup-limit '<)))
6561 (setq gnus-newsgroup-unreads
6562 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6564 (setq gnus-newsgroup-dormant nil
6565 gnus-newsgroup-marked nil
6566 gnus-newsgroup-reads
6568 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6569 gnus-newsgroup-reads))
6570 (while (setq article (pop articles))
6571 (unless (or (memq article gnus-newsgroup-dormant)
6572 (memq article gnus-newsgroup-marked))
6573 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6575 (defun gnus-summary-limit (articles &optional pop)
6577 ;; We pop the previous limit off the stack and use that.
6578 (setq articles (car gnus-newsgroup-limits)
6579 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6580 ;; We use the new limit, so we push the old limit on the stack.
6581 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6583 (setq gnus-newsgroup-limit articles)
6584 (let ((total (length gnus-newsgroup-data))
6585 (data (gnus-data-find-list (gnus-summary-article-number)))
6586 (gnus-summary-mark-below nil) ; Inhibit this.
6588 ;; This will do all the work of generating the new summary buffer
6589 ;; according to the new limit.
6590 (gnus-summary-prepare)
6591 ;; Hide any threads, possibly.
6592 (and gnus-show-threads
6593 gnus-thread-hide-subtree
6594 (gnus-summary-hide-all-threads))
6595 ;; Try to return to the article you were at, or one in the
6598 ;; We try to find some article after the current one.
6600 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6603 (setq data (cdr data))))
6605 ;; If there is no data, that means that we were after the last
6606 ;; article. The same goes when we can't find any articles
6607 ;; after the current one.
6608 (goto-char (point-max))
6609 (gnus-summary-find-prev))
6610 (gnus-set-mode-line 'summary)
6611 ;; We return how many articles were removed from the summary
6612 ;; buffer as a result of the new limit.
6613 (- total (length gnus-newsgroup-data))))
6615 (defsubst gnus-invisible-cut-children (threads)
6618 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6623 (defsubst gnus-cut-thread (thread)
6624 "Go forwards in the thread until we find an article that we want to display."
6625 (when (or (eq gnus-fetch-old-headers 'some)
6626 (eq gnus-fetch-old-headers 'invisible)
6627 (numberp gnus-fetch-old-headers)
6628 (eq gnus-build-sparse-threads 'some)
6629 (eq gnus-build-sparse-threads 'more))
6630 ;; Deal with old-fetched headers and sparse threads.
6634 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6635 (gnus-summary-article-ancient-p
6636 (mail-header-number (car thread))))
6637 (if (or (<= (length (cdr thread)) 1)
6638 (eq gnus-fetch-old-headers 'invisible))
6639 (setq gnus-newsgroup-limit
6640 (delq (mail-header-number (car thread))
6641 gnus-newsgroup-limit)
6642 thread (cadr thread))
6643 (when (gnus-invisible-cut-children (cdr thread))
6644 (let ((th (cdr thread)))
6646 (if (memq (mail-header-number (caar th))
6647 gnus-newsgroup-limit)
6648 (setq thread (car th)
6650 (setq th (cdr th))))))))))
6653 (defun gnus-cut-threads (threads)
6654 "Cut off all uninteresting articles from the beginning of threads."
6655 (when (or (eq gnus-fetch-old-headers 'some)
6656 (eq gnus-fetch-old-headers 'invisible)
6657 (numberp gnus-fetch-old-headers)
6658 (eq gnus-build-sparse-threads 'some)
6659 (eq gnus-build-sparse-threads 'more))
6662 (setcar th (gnus-cut-thread (car th)))
6663 (setq th (cdr th)))))
6664 ;; Remove nixed out threads.
6667 (defun gnus-summary-initial-limit (&optional show-if-empty)
6668 "Figure out what the initial limit is supposed to be on group entry.
6669 This entails weeding out unwanted dormants, low-scored articles,
6670 fetch-old-headers verbiage, and so on."
6671 ;; Most groups have nothing to remove.
6672 (if (or gnus-inhibit-limiting
6673 (and (null gnus-newsgroup-dormant)
6674 (not (eq gnus-fetch-old-headers 'some))
6675 (not (numberp gnus-fetch-old-headers))
6676 (not (eq gnus-fetch-old-headers 'invisible))
6677 (null gnus-summary-expunge-below)
6678 (not (eq gnus-build-sparse-threads 'some))
6679 (not (eq gnus-build-sparse-threads 'more))
6680 (null gnus-thread-expunge-below)
6681 (not gnus-use-nocem)))
6683 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6684 (setq gnus-newsgroup-limit nil)
6687 (unless (car (symbol-value node))
6688 ;; These threads have no parents -- they are roots.
6689 (let ((nodes (cdr (symbol-value node)))
6692 (if (and gnus-thread-expunge-below
6693 (< (gnus-thread-total-score (car nodes))
6694 gnus-thread-expunge-below))
6695 (gnus-expunge-thread (pop nodes))
6696 (setq thread (pop nodes))
6697 (gnus-summary-limit-children thread))))))
6698 gnus-newsgroup-dependencies)
6699 ;; If this limitation resulted in an empty group, we might
6700 ;; pop the previous limit and use it instead.
6701 (when (and (not gnus-newsgroup-limit)
6703 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6704 gnus-newsgroup-limit))
6706 (defun gnus-summary-limit-children (thread)
6707 "Return 1 if this subthread is visible and 0 if it is not."
6708 ;; First we get the number of visible children to this thread. This
6709 ;; is done by recursing down the thread using this function, so this
6710 ;; will really go down to a leaf article first, before slowly
6711 ;; working its way up towards the root.
6715 (apply '+ (mapcar 'gnus-summary-limit-children
6718 (number (mail-header-number (car thread)))
6721 (not (memq number gnus-newsgroup-marked))
6723 ;; If this article is dormant and has absolutely no visible
6724 ;; children, then this article isn't visible.
6725 (and (memq number gnus-newsgroup-dormant)
6727 ;; If this is "fetch-old-headered" and there is no
6728 ;; visible children, then we don't want this article.
6729 (and (or (eq gnus-fetch-old-headers 'some)
6730 (numberp gnus-fetch-old-headers))
6731 (gnus-summary-article-ancient-p number)
6733 ;; If this is "fetch-old-headered" and `invisible', then
6734 ;; we don't want this article.
6735 (and (eq gnus-fetch-old-headers 'invisible)
6736 (gnus-summary-article-ancient-p number))
6737 ;; If this is a sparsely inserted article with no children,
6738 ;; we don't want it.
6739 (and (eq gnus-build-sparse-threads 'some)
6740 (gnus-summary-article-sparse-p number)
6742 ;; If we use expunging, and this article is really
6743 ;; low-scored, then we don't want this article.
6744 (when (and gnus-summary-expunge-below
6746 (or (cdr (assq number gnus-newsgroup-scored))
6747 gnus-summary-default-score))
6748 gnus-summary-expunge-below))
6749 ;; We increase the expunge-tally here, but that has
6750 ;; nothing to do with the limits, really.
6751 (incf gnus-newsgroup-expunged-tally)
6752 ;; We also mark as read here, if that's wanted.
6753 (when (and gnus-summary-mark-below
6754 (< score gnus-summary-mark-below))
6755 (setq gnus-newsgroup-unreads
6756 (delq number gnus-newsgroup-unreads))
6757 (if gnus-newsgroup-auto-expire
6758 (push number gnus-newsgroup-expirable)
6759 (push (cons number gnus-low-score-mark)
6760 gnus-newsgroup-reads)))
6762 ;; Check NoCeM things.
6763 (if (and gnus-use-nocem
6764 (gnus-nocem-unwanted-article-p
6765 (mail-header-id (car thread))))
6767 (setq gnus-newsgroup-unreads
6768 (delq number gnus-newsgroup-unreads))
6770 ;; Nope, invisible article.
6772 ;; Ok, this article is to be visible, so we add it to the limit
6774 (push number gnus-newsgroup-limit)
6777 (defun gnus-expunge-thread (thread)
6778 "Mark all articles in THREAD as read."
6779 (let* ((number (mail-header-number (car thread))))
6780 (incf gnus-newsgroup-expunged-tally)
6781 ;; We also mark as read here, if that's wanted.
6782 (setq gnus-newsgroup-unreads
6783 (delq number gnus-newsgroup-unreads))
6784 (if gnus-newsgroup-auto-expire
6785 (push number gnus-newsgroup-expirable)
6786 (push (cons number gnus-low-score-mark)
6787 gnus-newsgroup-reads)))
6788 ;; Go recursively through all subthreads.
6789 (mapcar 'gnus-expunge-thread (cdr thread)))
6791 ;; Summary article oriented commands
6793 (defun gnus-summary-refer-parent-article (n)
6794 "Refer parent article N times.
6795 If N is negative, go to ancestor -N instead.
6796 The difference between N and the number of articles fetched is returned."
6800 (when (not (natnump n))
6805 (setq header (gnus-summary-article-header))
6806 (if (and (eq (mail-header-number header)
6807 (cdr gnus-article-current))
6808 (equal gnus-newsgroup-name
6809 (car gnus-article-current)))
6810 ;; If we try to find the parent of the currently
6811 ;; displayed article, then we take a look at the actual
6812 ;; References header, since this is slightly more
6813 ;; reliable than the References field we got from the
6816 (set-buffer gnus-original-article-buffer)
6817 (nnheader-narrow-to-headers)
6818 (unless (setq ref (message-fetch-field "references"))
6819 (setq ref (message-fetch-field "in-reply-to")))
6822 ;; It's not the current article, so we take a bet on
6823 ;; the value we got from the server.
6824 (mail-header-references header)))
6826 (not (equal ref "")))
6827 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6828 (gnus-message 1 "Couldn't find parent"))
6829 (gnus-message 1 "No references in article %d"
6830 (gnus-summary-article-number))
6833 (gnus-summary-position-point)
6836 (defun gnus-summary-refer-references ()
6837 "Fetch all articles mentioned in the References header.
6838 Return the number of articles fetched."
6840 (let ((ref (mail-header-references (gnus-summary-article-header)))
6841 (current (gnus-summary-article-number))
6845 (error "No References in the current article")
6846 ;; For each Message-ID in the References header...
6847 (while (string-match "<[^>]*>" ref)
6849 ;; ... fetch that article.
6850 (gnus-summary-refer-article
6851 (prog1 (match-string 0 ref)
6852 (setq ref (substring ref (match-end 0))))))
6853 (gnus-summary-goto-subject current)
6854 (gnus-summary-position-point)
6857 (defun gnus-summary-refer-thread (&optional limit)
6858 "Fetch all articles in the current thread.
6859 If LIMIT (the numerical prefix), fetch that many old headers instead
6860 of what's specified by the `gnus-refer-thread-limit' variable."
6862 (let ((id (mail-header-id (gnus-summary-article-header)))
6863 (limit (if limit (prefix-numeric-value limit)
6864 gnus-refer-thread-limit)))
6865 ;; We want to fetch LIMIT *old* headers, but we also have to
6866 ;; re-fetch all the headers in the current buffer, because many of
6867 ;; them may be undisplayed. So we adjust LIMIT.
6868 (when (numberp limit)
6869 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6870 (unless (eq gnus-fetch-old-headers 'invisible)
6871 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6872 ;; Retrieve the headers and read them in.
6873 (if (eq (gnus-retrieve-headers
6874 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6876 (gnus-build-all-threads)
6877 (error "Can't fetch thread from backends that don't support NOV"))
6878 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6879 (gnus-summary-limit-include-thread id)))
6881 (defun gnus-summary-refer-article (message-id)
6882 "Fetch an article specified by MESSAGE-ID."
6883 (interactive "sMessage-ID: ")
6884 (when (and (stringp message-id)
6885 (not (zerop (length message-id))))
6886 ;; Construct the correct Message-ID if necessary.
6887 ;; Suggested by tale@pawl.rpi.edu.
6888 (unless (string-match "^<" message-id)
6889 (setq message-id (concat "<" message-id)))
6890 (unless (string-match ">$" message-id)
6891 (setq message-id (concat message-id ">")))
6892 (let* ((header (gnus-id-to-header message-id))
6894 (gnus-summary-article-sparse-p
6895 (mail-header-number header))
6896 (memq (mail-header-number header)
6897 gnus-newsgroup-limit)))
6900 ;; If the article is present in the buffer we just go to it.
6902 (or (not (gnus-summary-article-sparse-p
6903 (mail-header-number header)))
6906 (gnus-summary-goto-article
6907 (mail-header-number header) nil t)
6909 (gnus-summary-update-article (mail-header-number header)))))
6911 ;; We fetch the article.
6913 (dolist (gnus-override-method (gnus-refer-article-methods))
6914 (gnus-check-server gnus-override-method)
6915 ;; Fetch the header, and display the article.
6916 (when (setq number (gnus-summary-insert-subject message-id))
6917 (gnus-summary-select-article nil nil nil number)
6919 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6921 (defun gnus-refer-article-methods ()
6922 "Return a list of referrable methods."
6924 ;; No method, so we default to current and native.
6925 ((null gnus-refer-article-method)
6926 (list gnus-current-select-method gnus-select-method))
6928 ((eq 'current gnus-refer-article-method)
6929 (list gnus-current-select-method))
6930 ;; List of select methods.
6931 ((not (and (symbolp (car gnus-refer-article-method))
6932 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6934 (dolist (method gnus-refer-article-method)
6935 (push (if (eq 'current method)
6936 gnus-current-select-method
6940 ;; One single select method.
6942 (list gnus-refer-article-method))))
6944 (defun gnus-summary-edit-parameters ()
6945 "Edit the group parameters of the current group."
6947 (gnus-group-edit-group gnus-newsgroup-name 'params))
6949 (defun gnus-summary-customize-parameters ()
6950 "Customize the group parameters of the current group."
6952 (gnus-group-customize gnus-newsgroup-name))
6954 (defun gnus-summary-enter-digest-group (&optional force)
6955 "Enter an nndoc group based on the current article.
6956 If FORCE, force a digest interpretation. If not, try
6957 to guess what the document format is."
6959 (let ((conf gnus-current-window-configuration))
6961 (gnus-summary-select-article))
6962 (setq gnus-current-window-configuration conf)
6963 (let* ((name (format "%s-%d"
6964 (gnus-group-prefixed-name
6965 gnus-newsgroup-name (list 'nndoc ""))
6967 (set-buffer gnus-summary-buffer)
6968 gnus-current-article)))
6969 (ogroup gnus-newsgroup-name)
6970 (params (append (gnus-info-params (gnus-get-info ogroup))
6971 (list (cons 'to-group ogroup))
6972 (list (cons 'save-article-group ogroup))))
6973 (case-fold-search t)
6974 (buf (current-buffer))
6977 (set-buffer gnus-original-article-buffer)
6978 ;; Have the digest group inherit the main mail address of
6979 ;; the parent article.
6980 (when (setq to-address (or (message-fetch-field "reply-to")
6981 (message-fetch-field "from")))
6982 (setq params (append
6983 (list (cons 'to-address
6984 (funcall gnus-decode-encoded-word-function
6986 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6987 (insert-buffer-substring gnus-original-article-buffer)
6988 ;; Remove lines that may lead nndoc to misinterpret the
6991 (goto-char (point-min))
6992 (or (search-forward "\n\n" nil t) (point)))
6993 (goto-char (point-min))
6994 (delete-matching-lines "^Path:\\|^From ")
6997 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6998 (gnus-newsgroup-ephemeral-ignored-charsets
6999 gnus-newsgroup-ignored-charsets))
7000 (gnus-group-read-ephemeral-group
7001 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7003 ,(if force 'mbox 'guess))) t))
7004 ;; Make all postings to this group go to the parent group.
7005 (nconc (gnus-info-params (gnus-get-info name))
7007 ;; Couldn't select this doc group.
7008 (switch-to-buffer buf)
7009 (gnus-set-global-variables)
7010 (gnus-configure-windows 'summary)
7011 (gnus-message 3 "Article couldn't be entered?"))
7012 (kill-buffer dig)))))
7014 (defun gnus-summary-read-document (n)
7015 "Open a new group based on the current article(s).
7016 This will allow you to read digests and other similar
7017 documents as newsgroups.
7018 Obeys the standard process/prefix convention."
7020 (let* ((articles (gnus-summary-work-articles n))
7021 (ogroup gnus-newsgroup-name)
7022 (params (append (gnus-info-params (gnus-get-info ogroup))
7023 (list (cons 'to-group ogroup))))
7024 article group egroup groups vgroup)
7025 (while (setq article (pop articles))
7026 (setq group (format "%s-%d" gnus-newsgroup-name article))
7027 (gnus-summary-remove-process-mark article)
7028 (when (gnus-summary-display-article article)
7031 (insert-buffer-substring gnus-original-article-buffer)
7032 ;; Remove some headers that may lead nndoc to make
7034 (message-narrow-to-head)
7035 (goto-char (point-min))
7036 (delete-matching-lines "^\\(Path\\):\\|^From ")
7039 (gnus-group-read-ephemeral-group
7040 group `(nndoc ,group (nndoc-address ,(current-buffer))
7041 (nndoc-article-type guess))
7044 ;; Make all postings to this group go to the parent group.
7045 (nconc (gnus-info-params (gnus-get-info egroup))
7047 (push egroup groups))
7048 ;; Couldn't select this doc group.
7049 (gnus-error 3 "Article couldn't be entered"))))))
7050 ;; Now we have selected all the documents.
7053 (error "None of the articles could be interpreted as documents"))
7054 ((gnus-group-read-ephemeral-group
7055 (setq vgroup (format
7056 "nnvirtual:%s-%s" gnus-newsgroup-name
7057 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7058 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7060 (cons (current-buffer) 'summary)))
7062 (error "Couldn't select virtual nndoc group")))))
7064 (defun gnus-summary-isearch-article (&optional regexp-p)
7065 "Do incremental search forward on the current article.
7066 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7068 (gnus-summary-select-article)
7069 (gnus-configure-windows 'article)
7070 (gnus-eval-in-buffer-window gnus-article-buffer
7073 (isearch-forward regexp-p))))
7075 (defun gnus-summary-search-article-forward (regexp &optional backward)
7076 "Search for an article containing REGEXP forward.
7077 If BACKWARD, search backward instead."
7080 (format "Search article %s (regexp%s): "
7081 (if current-prefix-arg "backward" "forward")
7082 (if gnus-last-search-regexp
7083 (concat ", default " gnus-last-search-regexp)
7085 current-prefix-arg))
7086 (if (string-equal regexp "")
7087 (setq regexp (or gnus-last-search-regexp ""))
7088 (setq gnus-last-search-regexp regexp)
7089 (setq gnus-article-before-search gnus-current-article))
7090 ;; Intentionally set gnus-last-article.
7091 (setq gnus-last-article gnus-article-before-search)
7092 (let ((gnus-last-article gnus-last-article))
7093 (if (gnus-summary-search-article regexp backward)
7094 (gnus-summary-show-thread)
7095 (error "Search failed: \"%s\"" regexp))))
7097 (defun gnus-summary-search-article-backward (regexp)
7098 "Search for an article containing REGEXP backward."
7101 (format "Search article backward (regexp%s): "
7102 (if gnus-last-search-regexp
7103 (concat ", default " gnus-last-search-regexp)
7105 (gnus-summary-search-article-forward regexp 'backward))
7107 (defun gnus-summary-search-article (regexp &optional backward)
7108 "Search for an article containing REGEXP.
7109 Optional argument BACKWARD means do search for backward.
7110 `gnus-select-article-hook' is not called during the search."
7111 ;; We have to require this here to make sure that the following
7112 ;; dynamic binding isn't shadowed by autoloading.
7113 (require 'gnus-async)
7115 (let ((gnus-select-article-hook nil) ;Disable hook.
7116 (gnus-article-prepare-hook nil)
7117 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7118 (gnus-use-article-prefetch nil)
7119 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7120 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7121 (sum (current-buffer))
7122 (gnus-display-mime-function nil)
7125 (gnus-save-hidden-threads
7126 (gnus-summary-select-article)
7127 (set-buffer gnus-article-buffer)
7128 (goto-char (window-point (get-buffer-window (current-buffer))))
7132 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7134 (re-search-backward regexp nil t)
7135 (re-search-forward regexp nil t))
7136 ;; We found the regexp.
7141 (get-buffer-window (current-buffer))
7145 (get-buffer-window (current-buffer))
7148 (setq point (point)))
7149 ;; We didn't find it, so we go to the next article.
7152 (while (eq found 'not)
7153 (if (not (if backward (gnus-summary-find-prev)
7154 (gnus-summary-find-next)))
7155 ;; No more articles.
7157 ;; Select the next article and adjust point.
7158 (unless (gnus-summary-article-sparse-p
7159 (gnus-summary-article-number))
7161 (gnus-summary-select-article)
7162 (set-buffer gnus-article-buffer)
7164 (goto-char (if backward (point-max) (point-min))))))))
7165 (gnus-message 7 ""))
7166 ;; Return whether we found the regexp.
7167 (when (eq found 'found)
7169 (gnus-summary-show-thread)
7170 (gnus-summary-goto-subject gnus-current-article)
7171 (gnus-summary-position-point)
7174 (defun gnus-summary-find-matching (header regexp &optional backward unread
7176 "Return a list of all articles that match REGEXP on HEADER.
7177 The search stars on the current article and goes forwards unless
7178 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7179 If UNREAD is non-nil, only unread articles will
7180 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7181 in the comparisons."
7182 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7183 (gnus-data-find-list
7184 (gnus-summary-article-number) (gnus-data-list backward))))
7185 (case-fold-search (not not-case-fold))
7188 (if (eq (car header) 'extra)
7191 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7193 (error "%s is an invalid header" header))
7194 (unless (fboundp (intern (concat "mail-header-" header)))
7195 (error "%s is not a valid header" header))
7196 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7199 (and (or (not unread) ; We want all articles...
7200 (gnus-data-unread-p d)) ; Or just unreads.
7201 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7202 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7203 (push (gnus-data-number d) articles)) ; Success!
7204 (setq data (cdr data)))
7205 (nreverse articles)))
7207 (defun gnus-summary-execute-command (header regexp command &optional backward)
7208 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7209 If HEADER is an empty string (or nil), the match is done on the entire
7210 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7212 (list (let ((completion-ignore-case t))
7215 (mapcar (lambda (string) (list string))
7216 '("Number" "Subject" "From" "Lines" "Date"
7217 "Message-ID" "Xref" "References" "Body"))
7218 nil 'require-match))
7219 (read-string "Regexp: ")
7220 (read-key-sequence "Command: ")
7221 current-prefix-arg))
7222 (when (equal header "Body")
7224 ;; Hidden thread subtrees must be searched as well.
7225 (gnus-summary-show-all-threads)
7226 ;; We don't want to change current point nor window configuration.
7228 (save-window-excursion
7229 (gnus-message 6 "Executing %s..." (key-description command))
7230 ;; We'd like to execute COMMAND interactively so as to give arguments.
7231 (gnus-execute header regexp
7232 `(call-interactively ',(key-binding command))
7234 (gnus-message 6 "Executing %s...done" (key-description command)))))
7236 (defun gnus-summary-beginning-of-article ()
7237 "Scroll the article back to the beginning."
7239 (gnus-summary-select-article)
7240 (gnus-configure-windows 'article)
7241 (gnus-eval-in-buffer-window gnus-article-buffer
7243 (goto-char (point-min))
7244 (when gnus-page-broken
7245 (gnus-narrow-to-page))))
7247 (defun gnus-summary-end-of-article ()
7248 "Scroll to the end of the article."
7250 (gnus-summary-select-article)
7251 (gnus-configure-windows 'article)
7252 (gnus-eval-in-buffer-window gnus-article-buffer
7254 (goto-char (point-max))
7256 (when gnus-page-broken
7257 (gnus-narrow-to-page))))
7259 (defun gnus-summary-print-article (&optional filename n)
7260 "Generate and print a PostScript image of the N next (mail) articles.
7262 If N is negative, print the N previous articles. If N is nil and articles
7263 have been marked with the process mark, print these instead.
7265 If the optional first argument FILENAME is nil, send the image to the
7266 printer. If FILENAME is a string, save the PostScript image in a file with
7267 that name. If FILENAME is a number, prompt the user for the name of the file
7269 (interactive (list (ps-print-preprint current-prefix-arg)
7270 current-prefix-arg))
7271 (dolist (article (gnus-summary-work-articles n))
7272 (gnus-summary-select-article nil nil 'pseudo article)
7273 (gnus-eval-in-buffer-window gnus-article-buffer
7274 (let ((buffer (generate-new-buffer " *print*")))
7277 (copy-to-buffer buffer (point-min) (point-max))
7279 (gnus-article-delete-invisible-text)
7280 (let ((ps-left-header
7283 (mail-header-subject gnus-current-headers) ")")
7285 (mail-header-from gnus-current-headers) ")")))
7288 "/pagenumberstring load"
7290 (mail-header-date gnus-current-headers) ")"))))
7291 (gnus-run-hooks 'gnus-ps-print-hook)
7293 (ps-print-buffer-with-faces filename))))
7294 (kill-buffer buffer))))))
7296 (defun gnus-summary-show-article (&optional arg)
7297 "Force re-fetching of the current article.
7298 If ARG (the prefix) is a number, show the article with the charset
7299 defined in `gnus-summary-show-article-charset-alist', or the charset
7301 If ARG (the prefix) is non-nil and not a number, show the raw article
7302 without any article massaging functions being run."
7306 (let ((gnus-newsgroup-charset
7307 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7308 (read-coding-system "Charset: ")))
7309 (gnus-newsgroup-ignored-charsets 'gnus-all))
7310 (gnus-summary-select-article nil 'force)
7311 (let ((deps gnus-newsgroup-dependencies)
7314 (set-buffer gnus-original-article-buffer)
7316 (message-narrow-to-head)
7317 (setq head (buffer-string)))
7319 (insert (format "211 %d Article retrieved.\n"
7320 (cdr gnus-article-current)))
7323 (let ((nntp-server-buffer (current-buffer)))
7324 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7325 (gnus-data-set-header
7326 (gnus-data-find (cdr gnus-article-current))
7328 (gnus-summary-update-article-line
7329 (cdr gnus-article-current) header))))
7331 ;; Select the article the normal way.
7332 (gnus-summary-select-article nil 'force))
7334 ;; We have to require this here to make sure that the following
7335 ;; dynamic binding isn't shadowed by autoloading.
7336 (require 'gnus-async)
7338 ;; Bind the article treatment functions to nil.
7339 (let ((gnus-have-all-headers t)
7340 gnus-article-prepare-hook
7341 gnus-article-decode-hook
7342 gnus-display-mime-function
7344 ;; Destroy any MIME parts.
7345 (when (gnus-buffer-live-p gnus-article-buffer)
7347 (set-buffer gnus-article-buffer)
7348 (mm-destroy-parts gnus-article-mime-handles)
7349 ;; Set it to nil for safety reason.
7350 (setq gnus-article-mime-handle-alist nil)
7351 (setq gnus-article-mime-handles nil)))
7352 (gnus-summary-select-article nil 'force))))
7353 (gnus-summary-goto-subject gnus-current-article)
7354 (gnus-summary-position-point))
7356 (defun gnus-summary-verbose-headers (&optional arg)
7357 "Toggle permanent full header display.
7358 If ARG is a positive number, turn header display on.
7359 If ARG is a negative number, turn header display off."
7361 (setq gnus-show-all-headers
7362 (cond ((or (not (numberp arg))
7364 (not gnus-show-all-headers))
7367 (gnus-summary-show-article))
7369 (defun gnus-summary-toggle-header (&optional arg)
7370 "Show the headers if they are hidden, or hide them if they are shown.
7371 If ARG is a positive number, show the entire header.
7372 If ARG is a negative number, hide the unwanted header lines."
7375 (set-buffer gnus-article-buffer)
7377 (let* ((buffer-read-only nil)
7378 (inhibit-point-motion-hooks t)
7384 (article-narrow-to-head)
7385 (gnus-article-hidden-text-p 'headers))))
7386 (goto-char (point-min))
7387 (when (search-forward "\n\n" nil t)
7388 (delete-region (point-min) (1- (point))))
7389 (goto-char (point-min))
7391 (set-buffer gnus-original-article-buffer)
7392 (goto-char (point-min))
7393 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7394 (insert-buffer-substring gnus-original-article-buffer 1 e)
7396 (narrow-to-region (point-min) (point))
7397 (article-decode-encoded-words)
7399 (let ((gnus-treat-hide-headers nil)
7400 (gnus-treat-hide-boring-headers nil))
7401 (setq gnus-article-wash-types
7402 (delq 'headers gnus-article-wash-types))
7403 (gnus-treat-article 'head))
7404 (gnus-treat-article 'head)))
7405 (gnus-set-mode-line 'article)))))
7407 (defun gnus-summary-show-all-headers ()
7408 "Make all header lines visible."
7410 (gnus-article-show-all-headers))
7412 (defun gnus-summary-caesar-message (&optional arg)
7413 "Caesar rotate the current article by 13.
7414 The numerical prefix specifies how many places to rotate each letter
7417 (gnus-summary-select-article)
7418 (let ((mail-header-separator ""))
7419 (gnus-eval-in-buffer-window gnus-article-buffer
7422 (let ((start (window-start))
7424 (message-caesar-buffer-body arg)
7425 (set-window-start (get-buffer-window (current-buffer)) start))))))
7427 (defun gnus-summary-stop-page-breaking ()
7428 "Stop page breaking in the current article."
7430 (gnus-summary-select-article)
7431 (gnus-eval-in-buffer-window gnus-article-buffer
7433 (when (gnus-visual-p 'page-marker)
7434 (let ((buffer-read-only nil))
7435 (gnus-remove-text-with-property 'gnus-prev)
7436 (gnus-remove-text-with-property 'gnus-next))
7437 (setq gnus-page-broken nil))))
7439 (defun gnus-summary-move-article (&optional n to-newsgroup
7440 select-method action)
7441 "Move the current article to a different newsgroup.
7442 If N is a positive number, move the N next articles.
7443 If N is a negative number, move the N previous articles.
7444 If N is nil and any articles have been marked with the process mark,
7445 move those articles instead.
7446 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7447 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7448 re-spool using this method.
7450 For this function to work, both the current newsgroup and the
7451 newsgroup that you want to move to have to support the `request-move'
7452 and `request-accept' functions.
7454 ACTION can be either `move' (the default), `crosspost' or `copy'."
7457 (setq action 'move))
7458 ;; Disable marking as read.
7459 (let (gnus-mark-article-hook)
7460 (save-window-excursion
7461 (gnus-summary-select-article)))
7462 ;; Check whether the source group supports the required functions.
7463 (cond ((and (eq action 'move)
7464 (not (gnus-check-backend-function
7465 'request-move-article gnus-newsgroup-name)))
7466 (error "The current group does not support article moving"))
7467 ((and (eq action 'crosspost)
7468 (not (gnus-check-backend-function
7469 'request-replace-article gnus-newsgroup-name)))
7470 (error "The current group does not support article editing")))
7471 (let ((articles (gnus-summary-work-articles n))
7472 (prefix (if (gnus-check-backend-function
7473 'request-move-article gnus-newsgroup-name)
7474 (gnus-group-real-prefix gnus-newsgroup-name)
7476 (names '((move "Move" "Moving")
7477 (copy "Copy" "Copying")
7478 (crosspost "Crosspost" "Crossposting")))
7479 (copy-buf (save-excursion
7480 (nnheader-set-temp-buffer " *copy article*")))
7481 art-group to-method new-xref article to-groups)
7482 (unless (assq action names)
7483 (error "Unknown action %s" action))
7484 ;; Read the newsgroup name.
7485 (when (and (not to-newsgroup)
7486 (not select-method))
7488 (gnus-read-move-group-name
7489 (cadr (assq action names))
7490 (symbol-value (intern (format "gnus-current-%s-group" action)))
7492 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7493 (setq to-method (or select-method
7494 (gnus-server-to-method
7495 (gnus-group-method to-newsgroup))))
7496 ;; Check the method we are to move this article to...
7497 (unless (gnus-check-backend-function
7498 'request-accept-article (car to-method))
7499 (error "%s does not support article copying" (car to-method)))
7500 (unless (gnus-check-server to-method)
7501 (error "Can't open server %s" (car to-method)))
7502 (gnus-message 6 "%s to %s: %s..."
7503 (caddr (assq action names))
7504 (or (car select-method) to-newsgroup) articles)
7506 (setq article (pop articles))
7510 ;; Move the article.
7512 ;; Remove this article from future suppression.
7513 (gnus-dup-unsuppress-article article)
7514 (gnus-request-move-article
7515 article ; Article to move
7516 gnus-newsgroup-name ; From newsgroup
7517 (nth 1 (gnus-find-method-for-group
7518 gnus-newsgroup-name)) ; Server
7519 (list 'gnus-request-accept-article
7520 to-newsgroup (list 'quote select-method)
7521 (not articles) t) ; Accept form
7522 (not articles))) ; Only save nov last time
7523 ;; Copy the article.
7526 (set-buffer copy-buf)
7527 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7528 (gnus-request-accept-article
7529 to-newsgroup select-method (not articles) t))))
7530 ;; Crosspost the article.
7531 ((eq action 'crosspost)
7532 (let ((xref (message-tokenize-header
7533 (mail-header-xref (gnus-summary-article-header article))
7535 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7538 (setq xref (list (system-name))))
7541 (mapconcat 'identity
7542 (delete "Xref:" (delete new-xref xref))
7546 (set-buffer copy-buf)
7547 ;; First put the article in the destination group.
7548 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7549 (when (consp (setq art-group
7550 (gnus-request-accept-article
7551 to-newsgroup select-method (not articles))))
7552 (setq new-xref (concat new-xref " " (car art-group)
7553 ":" (cdr art-group)))
7554 ;; Now we have the new Xrefs header, so we insert
7555 ;; it and replace the new article.
7556 (nnheader-replace-header "Xref" new-xref)
7557 (gnus-request-replace-article
7558 (cdr art-group) to-newsgroup (current-buffer))
7562 (gnus-message 1 "Couldn't %s article %s: %s"
7563 (cadr (assq action names)) article
7564 (nnheader-get-report (car to-method))))
7565 ((eq art-group 'junk)
7566 (when (eq action 'move)
7567 (gnus-summary-mark-article article gnus-canceled-mark)
7568 (gnus-message 4 "Deleted article %s" article)))
7570 (let* ((pto-group (gnus-group-prefixed-name
7571 (car art-group) to-method))
7573 (gnus-gethash pto-group gnus-newsrc-hashtb))
7574 (info (nth 2 entry))
7575 (to-group (gnus-info-group info))
7577 ;; Update the group that has been moved to.
7579 (memq action '(move copy)))
7580 (unless (member to-group to-groups)
7581 (push to-group to-groups))
7583 (unless (memq article gnus-newsgroup-unreads)
7584 (push 'read to-marks)
7586 info (gnus-add-to-range (gnus-info-read info)
7587 (list (cdr art-group)))))
7589 ;; See whether the article is to be put in the cache.
7590 (let ((marks gnus-article-mark-lists)
7591 (to-article (cdr art-group)))
7593 ;; Enter the article into the cache in the new group,
7594 ;; if that is required.
7595 (when gnus-use-cache
7596 (gnus-cache-possibly-enter-article
7598 (memq article gnus-newsgroup-marked)
7599 (memq article gnus-newsgroup-dormant)
7600 (memq article gnus-newsgroup-unreads)))
7602 (when gnus-preserve-marks
7603 ;; Copy any marks over to the new group.
7604 (when (and (equal to-group gnus-newsgroup-name)
7605 (not (memq article gnus-newsgroup-unreads)))
7606 ;; Mark this article as read in this group.
7607 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7608 (setcdr (gnus-active to-group) to-article)
7609 (setcdr gnus-newsgroup-active to-article))
7612 (when (memq article (symbol-value
7613 (intern (format "gnus-newsgroup-%s"
7615 (push (cdar marks) to-marks)
7616 ;; If the other group is the same as this group,
7617 ;; then we have to add the mark to the list.
7618 (when (equal to-group gnus-newsgroup-name)
7619 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7622 (intern (format "gnus-newsgroup-%s"
7624 ;; Copy the marks to other group.
7625 (gnus-add-marked-articles
7626 to-group (cdar marks) (list to-article) info))
7627 (setq marks (cdr marks)))
7629 (gnus-request-set-mark to-group (list (list (list to-article)
7634 (concat "(gnus-group-set-info '"
7635 (gnus-prin1-to-string (gnus-get-info to-group))
7638 ;; Update the Xref header in this article to point to
7639 ;; the new crossposted article we have just created.
7640 (when (eq action 'crosspost)
7642 (set-buffer copy-buf)
7643 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7644 (nnheader-replace-header "Xref" new-xref)
7645 (gnus-request-replace-article
7646 article gnus-newsgroup-name (current-buffer)))))
7648 ;;;!!!Why is this necessary?
7649 (set-buffer gnus-summary-buffer)
7651 (gnus-summary-goto-subject article)
7652 (when (eq action 'move)
7653 (gnus-summary-mark-article article gnus-canceled-mark))))
7654 (gnus-summary-remove-process-mark article))
7655 ;; Re-activate all groups that have been moved to.
7658 (set-buffer gnus-group-buffer)
7659 (when (gnus-group-goto-group (car to-groups) t)
7660 (gnus-group-get-new-news-this-group 1 t))
7663 (gnus-kill-buffer copy-buf)
7664 (gnus-summary-position-point)
7665 (gnus-set-mode-line 'summary)))
7667 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7668 "Move the current article to a different newsgroup.
7669 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7670 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7671 re-spool using this method."
7673 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7675 (defun gnus-summary-crosspost-article (&optional n)
7676 "Crosspost the current article to some other group."
7678 (gnus-summary-move-article n nil nil 'crosspost))
7680 (defcustom gnus-summary-respool-default-method nil
7681 "Default method for respooling an article.
7682 If nil, use to the current newsgroup method."
7683 :type '(choice (gnus-select-method :value (nnml ""))
7685 :group 'gnus-summary-mail)
7687 (defun gnus-summary-respool-article (&optional n method)
7688 "Respool the current article.
7689 The article will be squeezed through the mail spooling process again,
7690 which means that it will be put in some mail newsgroup or other
7691 depending on `nnmail-split-methods'.
7692 If N is a positive number, respool the N next articles.
7693 If N is a negative number, respool the N previous articles.
7694 If N is nil and any articles have been marked with the process mark,
7695 respool those articles instead.
7697 Respooling can be done both from mail groups and \"real\" newsgroups.
7698 In the former case, the articles in question will be moved from the
7699 current group into whatever groups they are destined to. In the
7700 latter case, they will be copied into the relevant groups."
7702 (list current-prefix-arg
7703 (let* ((methods (gnus-methods-using 'respool))
7705 (symbol-name (or gnus-summary-respool-default-method
7706 (car (gnus-find-method-for-group
7707 gnus-newsgroup-name)))))
7709 (gnus-completing-read
7710 methname "What backend do you want to use when respooling?"
7711 methods nil t nil 'gnus-mail-method-history))
7714 ((zerop (length (setq ms (gnus-servers-using-backend
7716 (list (intern method) ""))
7720 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7721 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7724 (error "No method given for respooling"))
7725 (if (assoc (symbol-name
7726 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7727 (gnus-methods-using 'respool))
7728 (gnus-summary-move-article n nil method)
7729 (gnus-summary-copy-article n nil method)))
7731 (defun gnus-summary-import-article (file)
7732 "Import an arbitrary file into a mail newsgroup."
7733 (interactive "fImport file: ")
7734 (let ((group gnus-newsgroup-name)
7735 (now (current-time))
7737 (unless (gnus-check-backend-function 'request-accept-article group)
7738 (error "%s does not support article importing" group))
7739 (or (file-readable-p file)
7740 (not (file-regular-p file))
7741 (error "Can't read %s" file))
7743 (set-buffer (gnus-get-buffer-create " *import file*"))
7745 (nnheader-insert-file-contents file)
7746 (goto-char (point-min))
7747 (unless (nnheader-article-p)
7748 ;; This doesn't look like an article, so we fudge some headers.
7749 (setq atts (file-attributes file)
7750 lines (count-lines (point-min) (point-max)))
7751 (insert "From: " (read-string "From: ") "\n"
7752 "Subject: " (read-string "Subject: ") "\n"
7753 "Date: " (message-make-date (nth 5 atts))
7755 "Message-ID: " (message-make-message-id) "\n"
7756 "Lines: " (int-to-string lines) "\n"
7757 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7758 (gnus-request-accept-article group nil t)
7759 (kill-buffer (current-buffer)))))
7761 (defun gnus-summary-article-posted-p ()
7762 "Say whether the current (mail) article is available from news as well.
7763 This will be the case if the article has both been mailed and posted."
7765 (let ((id (mail-header-references (gnus-summary-article-header)))
7766 (gnus-override-method (car (gnus-refer-article-methods))))
7767 (if (gnus-request-head id "")
7768 (gnus-message 2 "The current message was found on %s"
7769 gnus-override-method)
7770 (gnus-message 2 "The current message couldn't be found on %s"
7771 gnus-override-method)
7774 (defun gnus-summary-expire-articles (&optional now)
7775 "Expire all articles that are marked as expirable in the current group."
7777 (when (gnus-check-backend-function
7778 'request-expire-articles gnus-newsgroup-name)
7779 ;; This backend supports expiry.
7780 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7781 (expirable (if total
7783 ;; We need to update the info for
7784 ;; this group for `gnus-list-of-read-articles'
7785 ;; to give us the right answer.
7786 (gnus-run-hooks 'gnus-exit-group-hook)
7787 (gnus-summary-update-info)
7788 (gnus-list-of-read-articles gnus-newsgroup-name))
7789 (setq gnus-newsgroup-expirable
7790 (sort gnus-newsgroup-expirable '<))))
7791 (expiry-wait (if now 'immediate
7792 (gnus-group-find-parameter
7793 gnus-newsgroup-name 'expiry-wait)))
7794 (nnmail-expiry-target
7795 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7796 nnmail-expiry-target))
7799 ;; There are expirable articles in this group, so we run them
7800 ;; through the expiry process.
7801 (gnus-message 6 "Expiring articles...")
7802 (unless (gnus-check-group gnus-newsgroup-name)
7803 (error "Can't open server for %s" gnus-newsgroup-name))
7804 ;; The list of articles that weren't expired is returned.
7807 (let ((nnmail-expiry-wait-function nil)
7808 (nnmail-expiry-wait expiry-wait))
7809 (setq es (gnus-request-expire-articles
7810 expirable gnus-newsgroup-name)))
7811 (setq es (gnus-request-expire-articles
7812 expirable gnus-newsgroup-name)))
7814 (setq gnus-newsgroup-expirable es))
7815 ;; We go through the old list of expirable, and mark all
7816 ;; really expired articles as nonexistent.
7817 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7818 (let ((gnus-use-cache nil))
7820 (unless (memq (car expirable) es)
7821 (when (gnus-data-find (car expirable))
7822 (gnus-summary-mark-article
7823 (car expirable) gnus-canceled-mark)))
7824 (setq expirable (cdr expirable))))))
7825 (gnus-message 6 "Expiring articles...done")))))
7827 (defun gnus-summary-expire-articles-now ()
7828 "Expunge all expirable articles in the current group.
7829 This means that *all* articles that are marked as expirable will be
7830 deleted forever, right now."
7832 (or gnus-expert-user
7834 "Are you really, really, really sure you want to delete all these messages? ")
7836 (gnus-summary-expire-articles t))
7838 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7839 (defun gnus-summary-delete-article (&optional n)
7840 "Delete the N next (mail) articles.
7841 This command actually deletes articles. This is not a marking
7842 command. The article will disappear forever from your life, never to
7844 If N is negative, delete backwards.
7845 If N is nil and articles have been marked with the process mark,
7846 delete these instead."
7848 (unless (gnus-check-backend-function 'request-expire-articles
7849 gnus-newsgroup-name)
7850 (error "The current newsgroup does not support article deletion"))
7851 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7852 (error "Couldn't open server"))
7853 ;; Compute the list of articles to delete.
7854 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7856 (if (and gnus-novice-user
7857 (not (gnus-yes-or-no-p
7858 (format "Do you really want to delete %s forever? "
7859 (if (> (length articles) 1)
7860 (format "these %s articles" (length articles))
7863 ;; Delete the articles.
7864 (setq not-deleted (gnus-request-expire-articles
7865 articles gnus-newsgroup-name 'force))
7867 (gnus-summary-remove-process-mark (car articles))
7868 ;; The backend might not have been able to delete the article
7870 (unless (memq (car articles) not-deleted)
7871 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7872 (setq articles (cdr articles)))
7874 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7875 (gnus-summary-position-point)
7876 (gnus-set-mode-line 'summary)
7879 (defun gnus-summary-edit-article (&optional arg)
7880 "Edit the current article.
7881 This will have permanent effect only in mail groups.
7882 If ARG is nil, edit the decoded articles.
7883 If ARG is 1, edit the raw articles.
7884 If ARG is 2, edit the raw articles even in read-only groups.
7885 If ARG is 3, edit the articles with the current handles.
7886 Otherwise, allow editing of articles even in read-only
7889 (let (force raw current-handles)
7892 ((eq arg 1) (setq raw t))
7893 ((eq arg 2) (setq raw t
7895 ((eq arg 3) (setq current-handles
7896 (and (gnus-buffer-live-p gnus-article-buffer)
7897 (with-current-buffer gnus-article-buffer
7899 gnus-article-mime-handles
7900 (setq gnus-article-mime-handles nil))))))
7902 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7903 (error "Can't edit the raw article in group nndraft:drafts."))
7905 (set-buffer gnus-summary-buffer)
7906 (let ((mail-parse-charset gnus-newsgroup-charset)
7907 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7908 (gnus-set-global-variables)
7909 (when (and (not force)
7910 (gnus-group-read-only-p))
7911 (error "The current newsgroup does not support article editing"))
7912 (gnus-summary-show-article t)
7913 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7914 (with-current-buffer gnus-article-buffer
7915 (mm-enable-multibyte-mule4)))
7916 (if (equal gnus-newsgroup-name "nndraft:drafts")
7918 (gnus-article-edit-article
7921 (let ((mbl mml-buffer-list))
7922 (setq mml-buffer-list nil)
7923 (mime-to-mml ,'current-handles)
7924 (make-local-hook 'kill-buffer-hook)
7925 (let ((mbl1 mml-buffer-list))
7926 (setq mml-buffer-list mbl)
7927 (set (make-local-variable 'mml-buffer-list) mbl1))
7928 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7929 `(lambda (no-highlight)
7930 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7931 (message-options message-options)
7932 (message-options-set-recipient)
7933 (mail-parse-ignored-charsets
7934 ',gnus-newsgroup-ignored-charsets))
7935 ,(if (not raw) '(progn
7937 (mml-destroy-buffers)
7938 (remove-hook 'kill-buffer-hook
7939 'mml-destroy-buffers t)
7940 (kill-local-variable 'mml-buffer-list)))
7941 (gnus-summary-edit-article-done
7942 ,(or (mail-header-references gnus-current-headers) "")
7943 ,(gnus-group-read-only-p)
7944 ,gnus-summary-buffer no-highlight))))))))
7946 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7948 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7950 "Make edits to the current article permanent."
7953 ;; The buffer restriction contains the entire article if it exists.
7954 (when (article-goto-body)
7955 (let ((lines (count-lines (point) (point-max)))
7956 (length (- (point-max) (point)))
7957 (case-fold-search t)
7958 (body (copy-marker (point))))
7959 (goto-char (point-min))
7960 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
7961 (delete-region (match-beginning 1) (match-end 1))
7962 (insert (number-to-string length)))
7963 (goto-char (point-min))
7964 (when (re-search-forward
7965 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
7966 (delete-region (match-beginning 1) (match-end 1))
7967 (insert (number-to-string length)))
7968 (goto-char (point-min))
7969 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
7970 (delete-region (match-beginning 1) (match-end 1))
7971 (insert (number-to-string lines))))))
7972 ;; Replace the article.
7973 (let ((buf (current-buffer)))
7975 (insert-buffer-substring buf)
7977 (if (and (not read-only)
7978 (not (gnus-request-replace-article
7979 (cdr gnus-article-current) (car gnus-article-current)
7980 (current-buffer) t)))
7981 (error "Couldn't replace article")
7982 ;; Update the summary buffer.
7984 (equal (message-tokenize-header references " ")
7985 (message-tokenize-header
7986 (or (message-fetch-field "references") "") " ")))
7987 ;; We only have to update this line.
7990 (message-narrow-to-head)
7991 (let ((head (buffer-string))
7994 (insert (format "211 %d Article retrieved.\n"
7995 (cdr gnus-article-current)))
7998 (let ((nntp-server-buffer (current-buffer)))
7999 (setq header (car (gnus-get-newsgroup-headers
8001 (set-buffer gnus-summary-buffer)
8002 gnus-newsgroup-dependencies)
8005 (set-buffer gnus-summary-buffer)
8006 (gnus-data-set-header
8007 (gnus-data-find (cdr gnus-article-current))
8009 (gnus-summary-update-article-line
8010 (cdr gnus-article-current) header))))))
8012 (set-buffer (or buffer gnus-summary-buffer))
8013 (gnus-summary-update-article (cdr gnus-article-current)))
8014 ;; Prettify the article buffer again.
8015 (unless no-highlight
8017 (set-buffer gnus-article-buffer)
8018 ;;;!!! Fix this -- article should be rehighlighted.
8019 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8020 (set-buffer gnus-original-article-buffer)
8021 (gnus-request-article
8022 (cdr gnus-article-current)
8023 (car gnus-article-current) (current-buffer))))
8024 ;; Prettify the summary buffer line.
8025 (when (gnus-visual-p 'summary-highlight 'highlight)
8026 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8028 (defun gnus-summary-edit-wash (key)
8029 "Perform editing command KEY in the article buffer."
8033 (message "%s" (concat (this-command-keys) "- "))
8036 (gnus-summary-edit-article)
8037 (execute-kbd-macro (concat (this-command-keys) key))
8038 (gnus-article-edit-done))
8042 (defun gnus-summary-respool-query (&optional silent trace)
8043 "Query where the respool algorithm would put this article."
8045 (let (gnus-mark-article-hook)
8046 (gnus-summary-select-article)
8048 (set-buffer gnus-original-article-buffer)
8050 (message-narrow-to-head)
8051 (let ((groups (nnmail-article-group 'identity trace)))
8054 (message "This message would go to %s"
8055 (mapconcat 'car groups ", "))
8056 (message "This message would go to no groups"))
8059 (defun gnus-summary-respool-trace ()
8060 "Trace where the respool algorithm would put this article.
8061 Display a buffer showing all fancy splitting patterns which matched."
8063 (gnus-summary-respool-query nil t))
8065 ;; Summary marking commands.
8067 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8068 "Mark articles which has the same subject as read, and then select the next.
8069 If UNMARK is positive, remove any kind of mark.
8070 If UNMARK is negative, tick articles."
8073 (setq unmark (prefix-numeric-value unmark)))
8075 (gnus-summary-mark-same-subject
8076 (gnus-summary-article-subject) unmark)))
8077 ;; Select next unread article. If auto-select-same mode, should
8078 ;; select the first unread article.
8079 (gnus-summary-next-article t (and gnus-auto-select-same
8080 (gnus-summary-article-subject)))
8081 (gnus-message 7 "%d article%s marked as %s"
8082 count (if (= count 1) " is" "s are")
8083 (if unmark "unread" "read"))))
8085 (defun gnus-summary-kill-same-subject (&optional unmark)
8086 "Mark articles which has the same subject as read.
8087 If UNMARK is positive, remove any kind of mark.
8088 If UNMARK is negative, tick articles."
8091 (setq unmark (prefix-numeric-value unmark)))
8093 (gnus-summary-mark-same-subject
8094 (gnus-summary-article-subject) unmark)))
8095 ;; If marked as read, go to next unread subject.
8097 ;; Go to next unread subject.
8098 (gnus-summary-next-subject 1 t))
8099 (gnus-message 7 "%d articles are marked as %s"
8100 count (if unmark "unread" "read"))))
8102 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8103 "Mark articles with same SUBJECT as read, and return marked number.
8104 If optional argument UNMARK is positive, remove any kinds of marks.
8105 If optional argument UNMARK is negative, mark articles as unread instead."
8109 ((null unmark) ; Mark as read.
8112 (gnus-summary-mark-article-as-read gnus-killed-mark)
8113 (gnus-summary-show-thread) t)
8114 (gnus-summary-find-subject subject))
8115 (setq count (1+ count))))
8116 ((> unmark 0) ; Tick.
8119 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8120 (gnus-summary-show-thread) t)
8121 (gnus-summary-find-subject subject))
8122 (setq count (1+ count))))
8123 (t ; Mark as unread.
8126 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8127 (gnus-summary-show-thread) t)
8128 (gnus-summary-find-subject subject))
8129 (setq count (1+ count)))))
8130 (gnus-set-mode-line 'summary)
8131 ;; Return the number of marked articles.
8134 (defun gnus-summary-mark-as-processable (n &optional unmark)
8135 "Set the process mark on the next N articles.
8136 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8137 the process mark instead. The difference between N and the actual
8138 number of articles marked is returned."
8140 (let ((backward (< n 0))
8145 (gnus-summary-remove-process-mark
8146 (gnus-summary-article-number))
8147 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8148 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8151 (gnus-message 7 "No more articles"))
8152 (gnus-summary-recenter)
8153 (gnus-summary-position-point)
8156 (defun gnus-summary-unmark-as-processable (n)
8157 "Remove the process mark from the next N articles.
8158 If N is negative, unmark backward instead. The difference between N and
8159 the actual number of articles unmarked is returned."
8161 (gnus-summary-mark-as-processable n t))
8163 (defun gnus-summary-unmark-all-processable ()
8164 "Remove the process mark from all articles."
8167 (while gnus-newsgroup-processable
8168 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8169 (gnus-summary-position-point))
8171 (defun gnus-summary-mark-as-expirable (n)
8172 "Mark N articles forward as expirable.
8173 If N is negative, mark backward instead. The difference between N and
8174 the actual number of articles marked is returned."
8176 (gnus-summary-mark-forward n gnus-expirable-mark))
8178 (defun gnus-summary-mark-article-as-replied (article)
8179 "Mark ARTICLE replied and update the summary line."
8180 (push article gnus-newsgroup-replied)
8181 (let ((buffer-read-only nil))
8182 (when (gnus-summary-goto-subject article nil t)
8183 (gnus-summary-update-secondary-mark article))))
8185 (defun gnus-summary-set-bookmark (article)
8186 "Set a bookmark in current article."
8187 (interactive (list (gnus-summary-article-number)))
8188 (when (or (not (get-buffer gnus-article-buffer))
8189 (not gnus-current-article)
8190 (not gnus-article-current)
8191 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8192 (error "No current article selected"))
8193 ;; Remove old bookmark, if one exists.
8194 (let ((old (assq article gnus-newsgroup-bookmarks)))
8196 (setq gnus-newsgroup-bookmarks
8197 (delq old gnus-newsgroup-bookmarks))))
8198 ;; Set the new bookmark, which is on the form
8199 ;; (article-number . line-number-in-body).
8203 (set-buffer gnus-article-buffer)
8207 (goto-char (point-min))
8208 (search-forward "\n\n" nil t)
8211 gnus-newsgroup-bookmarks)
8212 (gnus-message 6 "A bookmark has been added to the current article."))
8214 (defun gnus-summary-remove-bookmark (article)
8215 "Remove the bookmark from the current article."
8216 (interactive (list (gnus-summary-article-number)))
8217 ;; Remove old bookmark, if one exists.
8218 (let ((old (assq article gnus-newsgroup-bookmarks)))
8221 (setq gnus-newsgroup-bookmarks
8222 (delq old gnus-newsgroup-bookmarks))
8223 (gnus-message 6 "Removed bookmark."))
8224 (gnus-message 6 "No bookmark in current article."))))
8226 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8227 (defun gnus-summary-mark-as-dormant (n)
8228 "Mark N articles forward as dormant.
8229 If N is negative, mark backward instead. The difference between N and
8230 the actual number of articles marked is returned."
8232 (gnus-summary-mark-forward n gnus-dormant-mark))
8234 (defun gnus-summary-set-process-mark (article)
8235 "Set the process mark on ARTICLE and update the summary line."
8236 (setq gnus-newsgroup-processable
8238 (delq article gnus-newsgroup-processable)))
8239 (when (gnus-summary-goto-subject article)
8240 (gnus-summary-show-thread)
8241 (gnus-summary-goto-subject article)
8242 (gnus-summary-update-secondary-mark article)))
8244 (defun gnus-summary-remove-process-mark (article)
8245 "Remove the process mark from ARTICLE and update the summary line."
8246 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8247 (when (gnus-summary-goto-subject article)
8248 (gnus-summary-show-thread)
8249 (gnus-summary-goto-subject article)
8250 (gnus-summary-update-secondary-mark article)))
8252 (defun gnus-summary-set-saved-mark (article)
8253 "Set the process mark on ARTICLE and update the summary line."
8254 (push article gnus-newsgroup-saved)
8255 (when (gnus-summary-goto-subject article)
8256 (gnus-summary-update-secondary-mark article)))
8258 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8259 "Mark N articles as read forwards.
8260 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8261 The difference between N and the actual number of articles marked is
8263 Iff NO-EXPIRE, auto-expiry will be inhibited."
8265 (gnus-summary-show-thread)
8266 (let ((backward (< n 0))
8267 (gnus-summary-goto-unread
8268 (and gnus-summary-goto-unread
8269 (not (eq gnus-summary-goto-unread 'never))
8270 (not (memq mark (list gnus-unread-mark
8271 gnus-ticked-mark gnus-dormant-mark)))))
8273 (mark (or mark gnus-del-mark)))
8275 (gnus-summary-mark-article nil mark no-expire)
8276 (zerop (gnus-summary-next-subject
8278 (and gnus-summary-goto-unread
8279 (not (eq gnus-summary-goto-unread 'never)))
8283 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8284 (gnus-summary-recenter)
8285 (gnus-summary-position-point)
8286 (gnus-set-mode-line 'summary)
8289 (defun gnus-summary-mark-article-as-read (mark)
8290 "Mark the current article quickly as read with MARK."
8291 (let ((article (gnus-summary-article-number)))
8292 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8293 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8294 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8295 (push (cons article mark) gnus-newsgroup-reads)
8296 ;; Possibly remove from cache, if that is used.
8297 (when gnus-use-cache
8298 (gnus-cache-enter-remove-article article))
8299 ;; Allow the backend to change the mark.
8300 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8301 ;; Check for auto-expiry.
8302 (when (and gnus-newsgroup-auto-expire
8303 (memq mark gnus-auto-expirable-marks))
8304 (setq mark gnus-expirable-mark)
8305 ;; Let the backend know about the mark change.
8306 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8307 (push article gnus-newsgroup-expirable))
8308 ;; Set the mark in the buffer.
8309 (gnus-summary-update-mark mark 'unread)
8312 (defun gnus-summary-mark-article-as-unread (mark)
8313 "Mark the current article quickly as unread with MARK."
8314 (let* ((article (gnus-summary-article-number))
8315 (old-mark (gnus-summary-article-mark article)))
8316 ;; Allow the backend to change the mark.
8317 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8318 (if (eq mark old-mark)
8322 (gnus-error 1 "Can't mark negative article numbers")
8324 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8325 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8326 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8327 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8328 (cond ((= mark gnus-ticked-mark)
8329 (push article gnus-newsgroup-marked))
8330 ((= mark gnus-dormant-mark)
8331 (push article gnus-newsgroup-dormant))
8333 (push article gnus-newsgroup-unreads)))
8334 (gnus-pull article gnus-newsgroup-reads)
8336 ;; See whether the article is to be put in the cache.
8338 (vectorp (gnus-summary-article-header article))
8340 (gnus-cache-possibly-enter-article
8341 gnus-newsgroup-name article
8342 (= mark gnus-ticked-mark)
8343 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8346 (gnus-summary-update-mark mark 'unread)
8349 (defun gnus-summary-mark-article (&optional article mark no-expire)
8350 "Mark ARTICLE with MARK. MARK can be any character.
8351 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8352 `??' (dormant) and `?E' (expirable).
8353 If MARK is nil, then the default character `?r' is used.
8354 If ARTICLE is nil, then the article on the current line will be
8356 Iff NO-EXPIRE, auto-expiry will be inhibited."
8357 ;; The mark might be a string.
8358 (when (stringp mark)
8359 (setq mark (aref mark 0)))
8360 ;; If no mark is given, then we check auto-expiring.
8362 (setq mark gnus-del-mark))
8363 (when (and (not no-expire)
8364 gnus-newsgroup-auto-expire
8365 (memq mark gnus-auto-expirable-marks))
8366 (setq mark gnus-expirable-mark))
8367 (let ((article (or article (gnus-summary-article-number)))
8368 (old-mark (gnus-summary-article-mark article)))
8369 ;; Allow the backend to change the mark.
8370 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8371 (if (eq mark old-mark)
8374 (error "No article on current line"))
8375 (if (not (if (or (= mark gnus-unread-mark)
8376 (= mark gnus-ticked-mark)
8377 (= mark gnus-dormant-mark))
8378 (gnus-mark-article-as-unread article mark)
8379 (gnus-mark-article-as-read article mark)))
8381 ;; See whether the article is to be put in the cache.
8383 (not (= mark gnus-canceled-mark))
8384 (vectorp (gnus-summary-article-header article))
8386 (gnus-cache-possibly-enter-article
8387 gnus-newsgroup-name article
8388 (= mark gnus-ticked-mark)
8389 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8391 (when (gnus-summary-goto-subject article nil t)
8392 (let ((buffer-read-only nil))
8393 (gnus-summary-show-thread)
8395 (gnus-summary-update-mark mark 'unread)
8398 (defun gnus-summary-update-secondary-mark (article)
8399 "Update the secondary (read, process, cache) mark."
8400 (gnus-summary-update-mark
8401 (cond ((memq article gnus-newsgroup-processable)
8403 ((memq article gnus-newsgroup-cached)
8405 ((memq article gnus-newsgroup-replied)
8407 ((memq article gnus-newsgroup-saved)
8409 (t gnus-unread-mark))
8411 (when (gnus-visual-p 'summary-highlight 'highlight)
8412 (gnus-run-hooks 'gnus-summary-update-hook))
8415 (defun gnus-summary-update-mark (mark type)
8416 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8417 (buffer-read-only nil))
8418 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8420 (when (looking-at "\r")
8422 (when (<= (+ forward (point)) (point-max))
8423 ;; Go to the right position on the line.
8424 (goto-char (+ forward (point)))
8425 ;; Replace the old mark with the new mark.
8426 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8427 ;; Optionally update the marks by some user rule.
8428 (when (eq type 'unread)
8430 (gnus-data-find (gnus-summary-article-number)) mark)
8431 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8433 (defun gnus-mark-article-as-read (article &optional mark)
8434 "Enter ARTICLE in the pertinent lists and remove it from others."
8435 ;; Make the article expirable.
8436 (let ((mark (or mark gnus-del-mark)))
8437 (if (= mark gnus-expirable-mark)
8438 (push article gnus-newsgroup-expirable)
8439 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8440 ;; Remove from unread and marked lists.
8441 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8442 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8443 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8444 (push (cons article mark) gnus-newsgroup-reads)
8445 ;; Possibly remove from cache, if that is used.
8446 (when gnus-use-cache
8447 (gnus-cache-enter-remove-article article))
8450 (defun gnus-mark-article-as-unread (article &optional mark)
8451 "Enter ARTICLE in the pertinent lists and remove it from others."
8452 (let ((mark (or mark gnus-ticked-mark)))
8455 (gnus-error 1 "Can't mark negative article numbers")
8457 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8458 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8459 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8460 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8462 ;; Unsuppress duplicates?
8463 (when gnus-suppress-duplicates
8464 (gnus-dup-unsuppress-article article))
8466 (cond ((= mark gnus-ticked-mark)
8467 (push article gnus-newsgroup-marked))
8468 ((= mark gnus-dormant-mark)
8469 (push article gnus-newsgroup-dormant))
8471 (push article gnus-newsgroup-unreads)))
8472 (gnus-pull article gnus-newsgroup-reads)
8475 (defalias 'gnus-summary-mark-as-unread-forward
8476 'gnus-summary-tick-article-forward)
8477 (make-obsolete 'gnus-summary-mark-as-unread-forward
8478 'gnus-summary-tick-article-forward)
8479 (defun gnus-summary-tick-article-forward (n)
8480 "Tick N articles forwards.
8481 If N is negative, tick backwards instead.
8482 The difference between N and the number of articles ticked is returned."
8484 (gnus-summary-mark-forward n gnus-ticked-mark))
8486 (defalias 'gnus-summary-mark-as-unread-backward
8487 'gnus-summary-tick-article-backward)
8488 (make-obsolete 'gnus-summary-mark-as-unread-backward
8489 'gnus-summary-tick-article-backward)
8490 (defun gnus-summary-tick-article-backward (n)
8491 "Tick N articles backwards.
8492 The difference between N and the number of articles ticked is returned."
8494 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8496 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8497 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8498 (defun gnus-summary-tick-article (&optional article clear-mark)
8499 "Mark current article as unread.
8500 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8501 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8503 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8506 (defun gnus-summary-mark-as-read-forward (n)
8507 "Mark N articles as read forwards.
8508 If N is negative, mark backwards instead.
8509 The difference between N and the actual number of articles marked is
8512 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8514 (defun gnus-summary-mark-as-read-backward (n)
8515 "Mark the N articles as read backwards.
8516 The difference between N and the actual number of articles marked is
8519 (gnus-summary-mark-forward
8520 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8522 (defun gnus-summary-mark-as-read (&optional article mark)
8523 "Mark current article as read.
8524 ARTICLE specifies the article to be marked as read.
8525 MARK specifies a string to be inserted at the beginning of the line."
8526 (gnus-summary-mark-article article mark))
8528 (defun gnus-summary-clear-mark-forward (n)
8529 "Clear marks from N articles forward.
8530 If N is negative, clear backward instead.
8531 The difference between N and the number of marks cleared is returned."
8533 (gnus-summary-mark-forward n gnus-unread-mark))
8535 (defun gnus-summary-clear-mark-backward (n)
8536 "Clear marks from N articles backward.
8537 The difference between N and the number of marks cleared is returned."
8539 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8541 (defun gnus-summary-mark-unread-as-read ()
8542 "Intended to be used by `gnus-summary-mark-article-hook'."
8543 (when (memq gnus-current-article gnus-newsgroup-unreads)
8544 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8546 (defun gnus-summary-mark-read-and-unread-as-read ()
8547 "Intended to be used by `gnus-summary-mark-article-hook'."
8548 (let ((mark (gnus-summary-article-mark)))
8549 (when (or (gnus-unread-mark-p mark)
8550 (gnus-read-mark-p mark))
8551 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8553 (defun gnus-summary-mark-region-as-read (point mark all)
8554 "Mark all unread articles between point and mark as read.
8555 If given a prefix, mark all articles between point and mark as read,
8556 even ticked and dormant ones."
8557 (interactive "r\nP")
8566 (memq (setq article (gnus-summary-article-number))
8567 gnus-newsgroup-unreads))
8568 (gnus-summary-mark-article article gnus-del-mark))
8570 (gnus-summary-find-next))))))
8572 (defun gnus-summary-mark-below (score mark)
8573 "Mark articles with score less than SCORE with MARK."
8574 (interactive "P\ncMark: ")
8575 (setq score (if score
8576 (prefix-numeric-value score)
8577 (or gnus-summary-default-score 0)))
8579 (set-buffer gnus-summary-buffer)
8580 (goto-char (point-min))
8583 (and (< (gnus-summary-article-score) score)
8584 (gnus-summary-mark-article nil mark))
8585 (gnus-summary-find-next)))))
8587 (defun gnus-summary-kill-below (&optional score)
8588 "Mark articles with score below SCORE as read."
8590 (gnus-summary-mark-below score gnus-killed-mark))
8592 (defun gnus-summary-clear-above (&optional score)
8593 "Clear all marks from articles with score above SCORE."
8595 (gnus-summary-mark-above score gnus-unread-mark))
8597 (defun gnus-summary-tick-above (&optional score)
8598 "Tick all articles with score above SCORE."
8600 (gnus-summary-mark-above score gnus-ticked-mark))
8602 (defun gnus-summary-mark-above (score mark)
8603 "Mark articles with score over SCORE with MARK."
8604 (interactive "P\ncMark: ")
8605 (setq score (if score
8606 (prefix-numeric-value score)
8607 (or gnus-summary-default-score 0)))
8609 (set-buffer gnus-summary-buffer)
8610 (goto-char (point-min))
8612 (when (> (gnus-summary-article-score) score)
8613 (gnus-summary-mark-article nil mark))
8615 (gnus-summary-find-next)))))
8617 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8618 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8619 (defun gnus-summary-limit-include-expunged (&optional no-error)
8620 "Display all the hidden articles that were expunged for low scores."
8622 (let ((buffer-read-only nil))
8623 (let ((scored gnus-newsgroup-scored)
8626 (unless (gnus-summary-goto-subject (caar scored))
8627 (and (setq h (gnus-summary-article-header (caar scored)))
8628 (< (cdar scored) gnus-summary-expunge-below)
8630 (setq scored (cdr scored)))
8632 (when (not no-error)
8633 (error "No expunged articles hidden"))
8634 (goto-char (point-min))
8635 (gnus-summary-prepare-unthreaded (nreverse headers))
8636 (goto-char (point-min))
8637 (gnus-summary-position-point)
8640 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8641 "Mark all unread articles in this newsgroup as read.
8642 If prefix argument ALL is non-nil, ticked and dormant articles will
8643 also be marked as read.
8644 If QUIETLY is non-nil, no questions will be asked.
8645 If TO-HERE is non-nil, it should be a point in the buffer. All
8646 articles before this point will be marked as read.
8647 Note that this function will only catch up the unread article
8648 in the current summary buffer limitation.
8649 The number of articles marked as read is returned."
8654 (not gnus-interactive-catchup) ;Without confirmation?
8658 "Mark absolutely all articles as read? "
8659 "Mark all unread articles as read? ")))
8661 (not gnus-newsgroup-adaptive)
8662 (not gnus-newsgroup-auto-expire)
8663 (not gnus-suppress-duplicates)
8664 (or (not gnus-use-cache)
8665 (eq gnus-use-cache 'passive)))
8668 (setq gnus-newsgroup-marked nil
8669 gnus-newsgroup-dormant nil))
8670 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8671 ;; We actually mark all articles as canceled, which we
8672 ;; have to do when using auto-expiry or adaptive scoring.
8673 (gnus-summary-show-all-threads)
8674 (when (gnus-summary-first-subject (not all) t)
8676 (if to-here (< (point) to-here) t)
8677 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8678 (gnus-summary-find-next (not all) nil nil t))))
8679 (gnus-set-mode-line 'summary))
8681 (gnus-summary-position-point)))
8683 (defun gnus-summary-catchup-to-here (&optional all)
8684 "Mark all unticked articles before the current one as read.
8685 If ALL is non-nil, also mark ticked and dormant articles as read."
8688 (gnus-save-hidden-threads
8689 (let ((beg (point)))
8690 ;; We check that there are unread articles.
8691 (when (or all (gnus-summary-find-prev))
8692 (gnus-summary-catchup all t beg)))))
8693 (gnus-summary-position-point))
8695 (defun gnus-summary-catchup-all (&optional quietly)
8696 "Mark all articles in this newsgroup as read."
8698 (gnus-summary-catchup t quietly))
8700 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8701 "Mark all unread articles in this group as read, then exit.
8702 If prefix argument ALL is non-nil, all articles are marked as read."
8704 (when (gnus-summary-catchup all quietly nil 'fast)
8705 ;; Select next newsgroup or exit.
8706 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8707 (eq gnus-auto-select-next 'quietly))
8708 (gnus-summary-next-group nil)
8709 (gnus-summary-exit))))
8711 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8712 "Mark all articles in this newsgroup as read, and then exit."
8714 (gnus-summary-catchup-and-exit t quietly))
8716 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8717 "Mark all articles in this group as read and select the next group.
8718 If given a prefix, mark all articles, unread as well as ticked, as
8722 (gnus-summary-catchup all))
8723 (gnus-summary-next-group))
8729 (defmacro gnus-with-article (article &rest forms)
8730 "Select ARTICLE and perform FORMS in the original article buffer.
8731 Then replace the article with the result."
8733 ;; We don't want the article to be marked as read.
8734 (let (gnus-mark-article-hook)
8735 (gnus-summary-select-article t t nil ,article))
8736 (set-buffer gnus-original-article-buffer)
8738 (if (not (gnus-check-backend-function
8739 'request-replace-article (car gnus-article-current)))
8740 (gnus-message 5 "Read-only group; not replacing")
8741 (unless (gnus-request-replace-article
8742 ,article (car gnus-article-current)
8744 (error "Couldn't replace article")))
8745 ;; The cache and backlog have to be flushed somewhat.
8746 (when gnus-keep-backlog
8747 (gnus-backlog-remove-article
8748 (car gnus-article-current) (cdr gnus-article-current)))
8749 (when gnus-use-cache
8750 (gnus-cache-update-article
8751 (car gnus-article-current) (cdr gnus-article-current)))))
8753 (put 'gnus-with-article 'lisp-indent-function 1)
8754 (put 'gnus-with-article 'edebug-form-spec '(form body))
8756 ;; Thread-based commands.
8758 (defun gnus-summary-articles-in-thread (&optional article)
8759 "Return a list of all articles in the current thread.
8760 If ARTICLE is non-nil, return all articles in the thread that starts
8762 (let* ((article (or article (gnus-summary-article-number)))
8763 (data (gnus-data-find-list article))
8764 (top-level (gnus-data-level (car data)))
8766 (cond ((null gnus-thread-operation-ignore-subject)
8767 (gnus-simplify-subject-re
8768 (mail-header-subject (gnus-data-header (car data)))))
8769 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8770 (gnus-simplify-subject-fuzzy
8771 (mail-header-subject (gnus-data-header (car data)))))
8773 (end-point (save-excursion
8774 (if (gnus-summary-go-to-next-thread)
8775 (point) (point-max))))
8778 (< (gnus-data-pos (car data)) end-point))
8779 (when (or (not top-subject)
8780 (string= top-subject
8781 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8782 (gnus-simplify-subject-fuzzy
8783 (mail-header-subject
8784 (gnus-data-header (car data))))
8785 (gnus-simplify-subject-re
8786 (mail-header-subject
8787 (gnus-data-header (car data)))))))
8788 (push (gnus-data-number (car data)) articles))
8789 (unless (and (setq data (cdr data))
8790 (> (gnus-data-level (car data)) top-level))
8792 ;; Return the list of articles.
8793 (nreverse articles)))
8795 (defun gnus-summary-rethread-current ()
8796 "Rethread the thread the current article is part of."
8798 (let* ((gnus-show-threads t)
8799 (article (gnus-summary-article-number))
8800 (id (mail-header-id (gnus-summary-article-header)))
8801 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8803 (error "No article on the current line"))
8804 (gnus-rebuild-thread id)
8805 (gnus-summary-goto-subject article)))
8807 (defun gnus-summary-reparent-thread ()
8808 "Make the current article child of the marked (or previous) article.
8810 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8811 is non-nil or the Subject: of both articles are the same."
8813 (unless (not (gnus-group-read-only-p))
8814 (error "The current newsgroup does not support article editing"))
8815 (unless (<= (length gnus-newsgroup-processable) 1)
8816 (error "No more than one article may be marked"))
8817 (save-window-excursion
8818 (let ((gnus-article-buffer " *reparent*")
8819 (current-article (gnus-summary-article-number))
8820 ;; First grab the marked article, otherwise one line up.
8821 (parent-article (if (not (null gnus-newsgroup-processable))
8822 (car gnus-newsgroup-processable)
8824 (if (eq (forward-line -1) 0)
8825 (gnus-summary-article-number)
8826 (error "Beginning of summary buffer"))))))
8827 (unless (not (eq current-article parent-article))
8828 (error "An article may not be self-referential"))
8829 (let ((message-id (mail-header-id
8830 (gnus-summary-article-header parent-article))))
8831 (unless (and message-id (not (equal message-id "")))
8832 (error "No message-id in desired parent"))
8833 (gnus-with-article current-article
8835 (goto-char (point-min))
8836 (message-narrow-to-head)
8837 (if (re-search-forward "^References: " nil t)
8839 (re-search-forward "^[^ \t]" nil t)
8842 (insert " " message-id))
8843 (insert "References: " message-id "\n"))))
8844 (set-buffer gnus-summary-buffer)
8845 (gnus-summary-unmark-all-processable)
8846 (gnus-summary-update-article current-article)
8847 (gnus-summary-rethread-current)
8848 (gnus-message 3 "Article %d is now the child of article %d"
8849 current-article parent-article)))))
8851 (defun gnus-summary-toggle-threads (&optional arg)
8852 "Toggle showing conversation threads.
8853 If ARG is positive number, turn showing conversation threads on."
8855 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8856 (setq gnus-show-threads
8857 (if (null arg) (not gnus-show-threads)
8858 (> (prefix-numeric-value arg) 0)))
8859 (gnus-summary-prepare)
8860 (gnus-summary-goto-subject current)
8861 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8862 (gnus-summary-position-point)))
8864 (defun gnus-summary-show-all-threads ()
8868 (let ((buffer-read-only nil))
8869 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8870 (gnus-summary-position-point))
8872 (defun gnus-summary-show-thread ()
8873 "Show thread subtrees.
8874 Returns nil if no thread was there to be shown."
8876 (let ((buffer-read-only nil)
8878 ;; first goto end then to beg, to have point at beg after let
8879 (end (progn (end-of-line) (point)))
8880 (beg (progn (beginning-of-line) (point))))
8882 ;; Any hidden lines here?
8883 (search-forward "\r" end t)
8884 (subst-char-in-region beg end ?\^M ?\n t)
8886 (gnus-summary-position-point))))
8888 (defun gnus-summary-hide-all-threads ()
8889 "Hide all thread subtrees."
8892 (goto-char (point-min))
8893 (gnus-summary-hide-thread)
8894 (while (zerop (gnus-summary-next-thread 1 t))
8895 (gnus-summary-hide-thread)))
8896 (gnus-summary-position-point))
8898 (defun gnus-summary-hide-thread ()
8899 "Hide thread subtrees.
8900 Returns nil if no threads were there to be hidden."
8902 (let ((buffer-read-only nil)
8904 (article (gnus-summary-article-number)))
8906 ;; Go forward until either the buffer ends or the subthread
8908 (when (and (not (eobp))
8909 (or (zerop (gnus-summary-next-thread 1 t))
8910 (goto-char (point-max))))
8912 (if (and (> (point) start)
8913 (search-backward "\n" start t))
8915 (subst-char-in-region start (point) ?\n ?\^M)
8916 (gnus-summary-goto-subject article))
8920 (defun gnus-summary-go-to-next-thread (&optional previous)
8921 "Go to the same level (or less) next thread.
8922 If PREVIOUS is non-nil, go to previous thread instead.
8923 Return the article number moved to, or nil if moving was impossible."
8924 (let ((level (gnus-summary-thread-level))
8925 (way (if previous -1 1))
8928 (while (and (not (eobp))
8929 (< level (gnus-summary-thread-level)))
8937 (gnus-summary-article-number)
8940 (defun gnus-summary-next-thread (n &optional silent)
8941 "Go to the same level next N'th thread.
8942 If N is negative, search backward instead.
8943 Returns the difference between N and the number of skips actually
8946 If SILENT, don't output messages."
8948 (let ((backward (< n 0))
8951 (gnus-summary-go-to-next-thread backward))
8954 (gnus-summary-position-point))
8955 (when (and (not silent) (/= 0 n))
8956 (gnus-message 7 "No more threads"))
8959 (defun gnus-summary-prev-thread (n)
8960 "Go to the same level previous N'th thread.
8961 Returns the difference between N and the number of skips actually
8964 (gnus-summary-next-thread (- n)))
8966 (defun gnus-summary-go-down-thread ()
8967 "Go down one level in the current thread."
8968 (let ((children (gnus-summary-article-children)))
8970 (gnus-summary-goto-subject (car children)))))
8972 (defun gnus-summary-go-up-thread ()
8973 "Go up one level in the current thread."
8974 (let ((parent (gnus-summary-article-parent)))
8976 (gnus-summary-goto-subject parent))))
8978 (defun gnus-summary-down-thread (n)
8979 "Go down thread N steps.
8980 If N is negative, go up instead.
8981 Returns the difference between N and how many steps down that were
8987 (if up (gnus-summary-go-up-thread)
8988 (gnus-summary-go-down-thread)))
8990 (gnus-summary-position-point)
8992 (gnus-message 7 "Can't go further"))
8995 (defun gnus-summary-up-thread (n)
8996 "Go up thread N steps.
8997 If N is negative, go up instead.
8998 Returns the difference between N and how many steps down that were
9001 (gnus-summary-down-thread (- n)))
9003 (defun gnus-summary-top-thread ()
9004 "Go to the top of the thread."
9006 (while (gnus-summary-go-up-thread))
9007 (gnus-summary-article-number))
9009 (defun gnus-summary-kill-thread (&optional unmark)
9010 "Mark articles under current thread as read.
9011 If the prefix argument is positive, remove any kinds of marks.
9012 If the prefix argument is negative, tick articles instead."
9015 (setq unmark (prefix-numeric-value unmark)))
9016 (let ((articles (gnus-summary-articles-in-thread)))
9018 ;; Expand the thread.
9019 (gnus-summary-show-thread)
9020 ;; Mark all the articles.
9022 (gnus-summary-goto-subject (car articles))
9023 (cond ((null unmark)
9024 (gnus-summary-mark-article-as-read gnus-killed-mark))
9026 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9028 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9029 (setq articles (cdr articles))))
9030 ;; Hide killed subtrees.
9032 gnus-thread-hide-killed
9033 (gnus-summary-hide-thread))
9034 ;; If marked as read, go to next unread subject.
9036 ;; Go to next unread subject.
9037 (gnus-summary-next-subject 1 t)))
9038 (gnus-set-mode-line 'summary))
9040 ;; Summary sorting commands
9042 (defun gnus-summary-sort-by-number (&optional reverse)
9043 "Sort the summary buffer by article number.
9044 Argument REVERSE means reverse order."
9046 (gnus-summary-sort 'number reverse))
9048 (defun gnus-summary-sort-by-author (&optional reverse)
9049 "Sort the summary buffer by author name alphabetically.
9050 If `case-fold-search' is non-nil, case of letters is ignored.
9051 Argument REVERSE means reverse order."
9053 (gnus-summary-sort 'author reverse))
9055 (defun gnus-summary-sort-by-subject (&optional reverse)
9056 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9057 If `case-fold-search' is non-nil, case of letters is ignored.
9058 Argument REVERSE means reverse order."
9060 (gnus-summary-sort 'subject reverse))
9062 (defun gnus-summary-sort-by-date (&optional reverse)
9063 "Sort the summary buffer by date.
9064 Argument REVERSE means reverse order."
9066 (gnus-summary-sort 'date reverse))
9068 (defun gnus-summary-sort-by-score (&optional reverse)
9069 "Sort the summary buffer by score.
9070 Argument REVERSE means reverse order."
9072 (gnus-summary-sort 'score reverse))
9074 (defun gnus-summary-sort-by-lines (&optional reverse)
9075 "Sort the summary buffer by the number of lines.
9076 Argument REVERSE means reverse order."
9078 (gnus-summary-sort 'lines reverse))
9080 (defun gnus-summary-sort-by-chars (&optional reverse)
9081 "Sort the summary buffer by article length.
9082 Argument REVERSE means reverse order."
9084 (gnus-summary-sort 'chars reverse))
9086 (defun gnus-summary-sort (predicate reverse)
9087 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9088 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9089 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9090 (gnus-thread-sort-functions
9095 (gnus-sort-gathered-threads-function
9096 gnus-thread-sort-functions)
9097 (gnus-article-sort-functions
9103 (gnus-summary-prepare-hook nil))
9104 ;; We do the sorting by regenerating the threads.
9105 (gnus-summary-prepare)
9106 ;; Hide subthreads if needed.
9107 (when (and gnus-show-threads gnus-thread-hide-subtree)
9108 (gnus-summary-hide-all-threads))))
9110 ;; Summary saving commands.
9112 (defun gnus-summary-save-article (&optional n not-saved)
9113 "Save the current article using the default saver function.
9114 If N is a positive number, save the N next articles.
9115 If N is a negative number, save the N previous articles.
9116 If N is nil and any articles have been marked with the process mark,
9117 save those articles instead.
9118 The variable `gnus-default-article-saver' specifies the saver function."
9120 (let* ((articles (gnus-summary-work-articles n))
9121 (save-buffer (save-excursion
9122 (nnheader-set-temp-buffer " *Gnus Save*")))
9123 (num (length articles))
9125 (dolist (article articles)
9126 (setq header (gnus-summary-article-header article))
9127 (if (not (vectorp header))
9128 ;; This is a pseudo-article.
9129 (if (assq 'name header)
9130 (gnus-copy-file (cdr (assq 'name header)))
9131 (gnus-message 1 "Article %d is unsaveable" article))
9132 ;; This is a real article.
9133 (save-window-excursion
9134 (gnus-summary-select-article t nil nil article))
9136 (set-buffer save-buffer)
9138 (insert-buffer-substring gnus-original-article-buffer))
9139 (setq file (gnus-article-save save-buffer file num))
9140 (gnus-summary-remove-process-mark article)
9142 (gnus-summary-set-saved-mark article))))
9143 (gnus-kill-buffer save-buffer)
9144 (gnus-summary-position-point)
9145 (gnus-set-mode-line 'summary)
9148 (defun gnus-summary-pipe-output (&optional arg)
9149 "Pipe the current article to a subprocess.
9150 If N is a positive number, pipe the N next articles.
9151 If N is a negative number, pipe the N previous articles.
9152 If N is nil and any articles have been marked with the process mark,
9153 pipe those articles instead."
9155 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9156 (gnus-summary-save-article arg t))
9157 (gnus-configure-windows 'pipe))
9159 (defun gnus-summary-save-article-mail (&optional arg)
9160 "Append the current article to an mail file.
9161 If N is a positive number, save the N next articles.
9162 If N is a negative number, save the N previous articles.
9163 If N is nil and any articles have been marked with the process mark,
9164 save those articles instead."
9166 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9167 (gnus-summary-save-article arg)))
9169 (defun gnus-summary-save-article-rmail (&optional arg)
9170 "Append the current article to an rmail file.
9171 If N is a positive number, save the N next articles.
9172 If N is a negative number, save the N previous articles.
9173 If N is nil and any articles have been marked with the process mark,
9174 save those articles instead."
9176 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9177 (gnus-summary-save-article arg)))
9179 (defun gnus-summary-save-article-file (&optional arg)
9180 "Append the current article to a file.
9181 If N is a positive number, save the N next articles.
9182 If N is a negative number, save the N previous articles.
9183 If N is nil and any articles have been marked with the process mark,
9184 save those articles instead."
9186 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9187 (gnus-summary-save-article arg)))
9189 (defun gnus-summary-write-article-file (&optional arg)
9190 "Write the current article to a file, deleting the previous file.
9191 If N is a positive number, save the N next articles.
9192 If N is a negative number, save the N previous articles.
9193 If N is nil and any articles have been marked with the process mark,
9194 save those articles instead."
9196 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9197 (gnus-summary-save-article arg)))
9199 (defun gnus-summary-save-article-body-file (&optional arg)
9200 "Append the current article body to a file.
9201 If N is a positive number, save the N next articles.
9202 If N is a negative number, save the N previous articles.
9203 If N is nil and any articles have been marked with the process mark,
9204 save those articles instead."
9206 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9207 (gnus-summary-save-article arg)))
9209 (defun gnus-summary-pipe-message (program)
9210 "Pipe the current article through PROGRAM."
9211 (interactive "sProgram: ")
9212 (gnus-summary-select-article)
9213 (let ((mail-header-separator ""))
9214 (gnus-eval-in-buffer-window gnus-article-buffer
9217 (let ((start (window-start))
9219 (message-pipe-buffer-body program)
9220 (set-window-start (get-buffer-window (current-buffer)) start))))))
9222 (defun gnus-get-split-value (methods)
9223 "Return a value based on the split METHODS."
9224 (let (split-name method result match)
9227 (set-buffer gnus-original-article-buffer)
9229 (nnheader-narrow-to-headers)
9230 (while (and methods (not split-name))
9231 (goto-char (point-min))
9232 (setq method (pop methods))
9233 (setq match (car method))
9236 ;; Regular expression.
9238 (re-search-forward match nil t)))
9239 ((gnus-functionp match)
9243 (setq result (funcall match gnus-newsgroup-name))))
9248 (setq result (eval match)))))
9249 (setq split-name (cdr method))
9250 (cond ((stringp result)
9251 (push (expand-file-name
9252 result gnus-article-save-directory)
9255 (setq split-name (append result split-name)))))))))
9256 (nreverse split-name)))
9258 (defun gnus-valid-move-group-p (group)
9261 (symbol-value group)
9262 (gnus-get-function (gnus-find-method-for-group
9263 (symbol-name group)) 'request-accept-article t)))
9265 (defun gnus-read-move-group-name (prompt default articles prefix)
9266 "Read a group name."
9267 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9268 (minibuffer-confirm-incomplete nil) ; XEmacs
9272 (if (> (length articles) 1)
9273 (format "these %d articles" (length articles))
9278 (gnus-completing-read default prom
9280 'gnus-valid-move-group-p
9282 'gnus-group-history))
9283 ((= 1 (length split-name))
9284 (gnus-completing-read (car split-name) prom
9286 'gnus-valid-move-group-p
9288 'gnus-group-history))
9290 (gnus-completing-read nil prom
9291 (mapcar (lambda (el) (list el))
9292 (nreverse split-name))
9294 'gnus-group-history))))
9295 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9297 (if (or (string= to-newsgroup "")
9298 (string= to-newsgroup prefix))
9299 (setq to-newsgroup default))
9300 (unless to-newsgroup
9301 (error "No group name entered"))
9302 (or (gnus-active to-newsgroup)
9303 (gnus-activate-group to-newsgroup nil nil to-method)
9304 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9306 (or (and (gnus-request-create-group to-newsgroup to-method)
9307 (gnus-activate-group
9308 to-newsgroup nil nil to-method)
9309 (gnus-subscribe-group to-newsgroup))
9310 (error "Couldn't create group %s" to-newsgroup)))
9311 (error "No such group: %s" to-newsgroup)))
9314 (defun gnus-summary-save-parts (type dir n &optional reverse)
9315 "Save parts matching TYPE to DIR.
9316 If REVERSE, save parts that do not match TYPE."
9318 (list (read-string "Save parts of type: "
9319 (or (car gnus-summary-save-parts-type-history)
9320 gnus-summary-save-parts-default-mime)
9321 'gnus-summary-save-parts-type-history)
9322 (setq gnus-summary-save-parts-last-directory
9323 (read-file-name "Save to directory: "
9324 gnus-summary-save-parts-last-directory
9326 current-prefix-arg))
9327 (gnus-summary-iterate n
9328 (let ((gnus-display-mime-function nil)
9329 (gnus-inhibit-treatment t))
9330 (gnus-summary-select-article))
9332 (set-buffer gnus-article-buffer)
9333 (let ((handles (or gnus-article-mime-handles
9334 (mm-dissect-buffer) (mm-uu-dissect))))
9336 (gnus-summary-save-parts-1 type dir handles reverse)
9337 (unless gnus-article-mime-handles ;; Don't destroy this case.
9338 (mm-destroy-parts handles)))))))
9340 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9341 (if (stringp (car handle))
9342 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9345 (not (string-match type (mm-handle-media-type handle)))
9346 (string-match type (mm-handle-media-type handle)))
9347 (let ((file (expand-file-name
9348 (file-name-nondirectory
9350 (mail-content-type-get
9351 (mm-handle-disposition handle) 'filename)
9352 (concat gnus-newsgroup-name
9353 "." (number-to-string
9354 (cdr gnus-article-current)))))
9356 (unless (file-exists-p file)
9357 (mm-save-part-to-file handle file))))))
9359 ;; Summary extract commands
9361 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9362 (let ((buffer-read-only nil)
9363 (article (gnus-summary-article-number))
9365 (unless (gnus-summary-goto-subject article)
9366 (error "No such article: %d" article))
9367 (gnus-summary-position-point)
9368 ;; If all commands are to be bunched up on one line, we collect
9370 (unless gnus-view-pseudos-separately
9371 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9374 (setq action (cdr (assq 'action (car ps))))
9375 (setq files (list (cdr (assq 'name (car ps)))))
9376 (while (and ps (cdr ps)
9377 (string= (or action "1")
9378 (or (cdr (assq 'action (cadr ps))) "2")))
9379 (push (cdr (assq 'name (cadr ps))) files)
9380 (setcdr ps (cddr ps)))
9382 (when (not (string-match "%s" action))
9385 (when (assq 'execute (car ps))
9386 (setcdr (assq 'execute (car ps))
9387 (funcall (if (string-match "%s" action)
9396 (setq ps (cdr ps)))))
9397 (if (and gnus-view-pseudos (not not-view))
9399 (when (assq 'execute (car pslist))
9400 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9401 (eq gnus-view-pseudos 'not-confirm)))
9402 (setq pslist (cdr pslist)))
9405 (setq after-article (or (cdr (assq 'article (car pslist)))
9406 (gnus-summary-article-number)))
9407 (gnus-summary-goto-subject after-article)
9410 (insert " " (file-name-nondirectory
9411 (cdr (assq 'name (car pslist))))
9412 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9414 (forward-line -1) ; back to `b'
9415 (gnus-add-text-properties
9416 b (1- e) (list 'gnus-number gnus-reffed-article-number
9417 gnus-mouse-face-prop gnus-mouse-face))
9419 after-article gnus-reffed-article-number
9420 gnus-unread-mark b (car pslist) 0 (- e b))
9421 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9422 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9423 (setq pslist (cdr pslist)))))))
9425 (defun gnus-pseudos< (p1 p2)
9426 (let ((c1 (cdr (assq 'action p1)))
9427 (c2 (cdr (assq 'action p2))))
9428 (and c1 c2 (string< c1 c2))))
9430 (defun gnus-request-pseudo-article (props)
9431 (cond ((assq 'execute props)
9432 (gnus-execute-command (cdr (assq 'execute props)))))
9433 (let ((gnus-current-article (gnus-summary-article-number)))
9434 (gnus-run-hooks 'gnus-mark-article-hook)))
9436 (defun gnus-execute-command (command &optional automatic)
9438 (gnus-article-setup-buffer)
9439 (set-buffer gnus-article-buffer)
9440 (setq buffer-read-only nil)
9441 (let ((command (if automatic command
9442 (read-string "Command: " (cons command 0)))))
9444 (insert "$ " command "\n\n")
9445 (if gnus-view-pseudo-asynchronously
9446 (start-process "gnus-execute" (current-buffer) shell-file-name
9447 shell-command-switch command)
9448 (call-process shell-file-name nil t nil
9449 shell-command-switch command)))))
9451 ;; Summary kill commands.
9453 (defun gnus-summary-edit-global-kill (article)
9454 "Edit the \"global\" kill file."
9455 (interactive (list (gnus-summary-article-number)))
9456 (gnus-group-edit-global-kill article))
9458 (defun gnus-summary-edit-local-kill ()
9459 "Edit a local kill file applied to the current newsgroup."
9461 (setq gnus-current-headers (gnus-summary-article-header))
9462 (gnus-group-edit-local-kill
9463 (gnus-summary-article-number) gnus-newsgroup-name))
9467 (defun gnus-read-header (id &optional header)
9468 "Read the headers of article ID and enter them into the Gnus system."
9469 (let ((group gnus-newsgroup-name)
9470 (gnus-override-method
9472 gnus-override-method
9473 (and (gnus-news-group-p gnus-newsgroup-name)
9474 (car (gnus-refer-article-methods)))))
9476 ;; First we check to see whether the header in question is already
9479 ;; This is a Message-ID.
9480 (setq header (or header (gnus-id-to-header id)))
9481 ;; This is an article number.
9482 (setq header (or header (gnus-summary-article-header id))))
9484 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9485 ;; We have found the header.
9487 ;; If this is a sparse article, we have to nix out its
9488 ;; previous entry in the thread hashtb.
9490 (gnus-summary-article-sparse-p (mail-header-number header)))
9491 (let* ((parent (gnus-parent-id (mail-header-references header)))
9492 (thread (and parent (gnus-id-to-thread parent))))
9494 (delq (assq header thread) thread))))
9495 ;; We have to really fetch the header to this article.
9497 (set-buffer nntp-server-buffer)
9498 (when (setq where (gnus-request-head id group))
9499 (nnheader-fold-continuation-lines)
9500 (goto-char (point-max))
9502 (goto-char (point-min))
9506 ((cdr where) (cdr where))
9507 (header (mail-header-number header))
9508 (t gnus-reffed-article-number))
9510 (insert " Article retrieved.\n"))
9512 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9513 () ; Malformed head.
9514 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9515 (when (and (stringp id)
9516 (not (string= (gnus-group-real-name group)
9518 ;; If we fetched by Message-ID and the article came
9519 ;; from a different group, we fudge some bogus article
9520 ;; numbers for this article.
9521 (mail-header-set-number header gnus-reffed-article-number))
9523 (set-buffer gnus-summary-buffer)
9524 (decf gnus-reffed-article-number)
9525 (gnus-remove-header (mail-header-number header))
9526 (push header gnus-newsgroup-headers)
9527 (setq gnus-current-headers header)
9528 (push (mail-header-number header) gnus-newsgroup-limit)))
9531 (defun gnus-remove-header (number)
9532 "Remove header NUMBER from `gnus-newsgroup-headers'."
9533 (if (and gnus-newsgroup-headers
9534 (= number (mail-header-number (car gnus-newsgroup-headers))))
9535 (pop gnus-newsgroup-headers)
9536 (let ((headers gnus-newsgroup-headers))
9537 (while (and (cdr headers)
9538 (not (= number (mail-header-number (cadr headers)))))
9541 (setcdr headers (cddr headers))))))
9544 ;;; summary highlights
9547 (defun gnus-highlight-selected-summary ()
9548 "Highlight selected article in summary buffer."
9549 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9550 (when gnus-summary-selected-face
9552 (let* ((beg (progn (beginning-of-line) (point)))
9553 (end (progn (end-of-line) (point)))
9554 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9555 (from (if (get-text-property beg gnus-mouse-face-prop)
9557 (or (next-single-property-change
9558 beg gnus-mouse-face-prop nil end)
9563 (or (next-single-property-change
9564 from gnus-mouse-face-prop nil end)
9566 ;; If no mouse-face prop on line we will have to = from = end,
9567 ;; so we highlight the entire line instead.
9568 (when (= (+ to 2) from)
9571 (if gnus-newsgroup-selected-overlay
9572 ;; Move old overlay.
9574 gnus-newsgroup-selected-overlay from to (current-buffer))
9575 ;; Create new overlay.
9577 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9578 'face gnus-summary-selected-face))))))
9580 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9581 (defun gnus-summary-highlight-line ()
9582 "Highlight current line according to `gnus-summary-highlight'."
9583 (let* ((list gnus-summary-highlight)
9585 (end (progn (end-of-line) (point)))
9586 ;; now find out where the line starts and leave point there.
9587 (beg (progn (beginning-of-line) (point)))
9588 (article (gnus-summary-article-number))
9589 (score (or (cdr (assq (or article gnus-current-article)
9590 gnus-newsgroup-scored))
9591 gnus-summary-default-score 0))
9592 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9593 (inhibit-read-only t))
9594 ;; Eval the cars of the lists until we find a match.
9595 (let ((default gnus-summary-default-score))
9597 (not (eval (caar list))))
9598 (setq list (cdr list))))
9599 (let ((face (cdar list)))
9600 (unless (eq face (get-text-property beg 'face))
9601 (gnus-put-text-property-excluding-characters-with-faces
9603 (setq face (if (boundp face) (symbol-value face) face)))
9604 (when gnus-summary-highlight-line-function
9605 (funcall gnus-summary-highlight-line-function article face))))
9608 (defun gnus-update-read-articles (group unread &optional compute)
9609 "Update the list of read articles in GROUP."
9610 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9611 (entry (gnus-gethash group gnus-newsrc-hashtb))
9612 (info (nth 2 entry))
9614 (unread (sort (copy-sequence unread) '<))
9616 (if (or (not info) (not active))
9617 ;; There is no info on this group if it was, in fact,
9618 ;; killed. Gnus stores no information on killed groups, so
9619 ;; there's nothing to be done.
9620 ;; One could store the information somewhere temporarily,
9621 ;; perhaps... Hmmm...
9623 ;; Remove any negative articles numbers.
9624 (while (and unread (< (car unread) 0))
9625 (setq unread (cdr unread)))
9626 ;; Remove any expired article numbers
9627 (while (and unread (< (car unread) (car active)))
9628 (setq unread (cdr unread)))
9629 ;; Compute the ranges of read articles by looking at the list of
9632 (when (/= (car unread) prev)
9633 (push (if (= prev (1- (car unread))) prev
9634 (cons prev (1- (car unread))))
9636 (setq prev (1+ (car unread)))
9637 (setq unread (cdr unread)))
9638 (when (<= prev (cdr active))
9639 (push (cons prev (cdr active)) read))
9640 (setq read (if (> (length read) 1) (nreverse read) read))
9645 ;; Propagate the read marks to the backend.
9646 (when (gnus-check-backend-function 'request-set-mark group)
9647 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9648 (add (gnus-remove-from-range read (gnus-info-read info))))
9650 (unless (gnus-check-group group)
9651 (error "Can't open server for %s" group))
9652 (gnus-request-set-mark
9653 group (delq nil (list (if add (list add 'add '(read)))
9654 (if del (list del 'del '(read))))))
9656 `(gnus-request-set-mark
9659 (if del (list del 'add '(read)))
9660 (if add (list add 'del '(read))))))))))
9661 (set-buffer gnus-group-buffer)
9664 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9665 (gnus-info-set-read ',info ',(gnus-info-read info))
9666 (gnus-get-unread-articles-in-group ',info
9667 (gnus-active ,group))
9668 (gnus-group-update-group ,group t)
9670 ;; Enter this list into the group info.
9671 (gnus-info-set-read info read)
9672 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9673 (gnus-get-unread-articles-in-group info (gnus-active group))
9676 (defun gnus-offer-save-summaries ()
9677 "Offer to save all active summary buffers."
9679 (let ((buflist (buffer-list))
9681 ;; Go through all buffers and find all summaries.
9683 (and (setq bufname (buffer-name (car buflist)))
9684 (string-match "Summary" bufname)
9686 (set-buffer bufname)
9687 ;; We check that this is, indeed, a summary buffer.
9688 (and (eq major-mode 'gnus-summary-mode)
9689 ;; Also make sure this isn't bogus.
9690 gnus-newsgroup-prepared
9691 ;; Also make sure that this isn't a dead summary buffer.
9692 (not gnus-dead-summary-mode)))
9693 (push bufname buffers))
9694 (setq buflist (cdr buflist)))
9695 ;; Go through all these summary buffers and offer to save them.
9698 "Update summary buffer %s? "
9700 (switch-to-buffer buf)
9701 (gnus-summary-exit))
9704 (defun gnus-summary-setup-default-charset ()
9705 "Setup newsgroup default charset."
9706 (if (equal gnus-newsgroup-name "nndraft:drafts")
9707 (setq gnus-newsgroup-charset nil)
9708 (let* ((name (and gnus-newsgroup-name
9709 (gnus-group-real-name gnus-newsgroup-name)))
9711 (or gnus-newsgroup-ephemeral-ignored-charsets
9713 (and gnus-newsgroup-name
9714 (or (gnus-group-find-parameter gnus-newsgroup-name
9715 'ignored-charsets t)
9716 (let ((alist gnus-group-ignored-charsets-alist)
9717 elem (charsets nil))
9718 (while (setq elem (pop alist))
9720 (string-match (car elem) name))
9722 charsets (cdr elem))))
9724 gnus-newsgroup-ignored-charsets))))
9725 (setq gnus-newsgroup-charset
9726 (or gnus-newsgroup-ephemeral-charset
9727 (and gnus-newsgroup-name
9728 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9729 (let ((alist gnus-group-charset-alist)
9731 (while (setq elem (pop alist))
9733 (string-match (car elem) name))
9735 charset (cadr elem))))
9737 gnus-default-charset))
9738 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9739 ignored-charsets))))
9745 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9746 "Display the current article buffer fully MIME-buttonized.
9747 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9748 treated as multipart/mixed."
9751 (let ((gnus-unbuttonized-mime-types nil)
9752 (gnus-mime-display-multipart-as-mixed show-all-parts))
9753 (gnus-summary-show-article)))
9755 (defun gnus-summary-repair-multipart (article)
9756 "Add a Content-Type header to a multipart article without one."
9757 (interactive (list (gnus-summary-article-number)))
9758 (gnus-with-article article
9759 (message-narrow-to-head)
9760 (message-remove-header "Mime-Version")
9761 (goto-char (point-max))
9762 (insert "Mime-Version: 1.0\n")
9764 (when (search-forward "\n--" nil t)
9765 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9766 (message-narrow-to-head)
9767 (message-remove-header "Content-Type")
9768 (goto-char (point-max))
9769 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9772 (let (gnus-mark-article-hook)
9773 (gnus-summary-select-article t t nil article)))
9775 (defun gnus-summary-toggle-display-buttonized ()
9776 "Toggle the buttonizing of the article buffer."
9779 (if (setq gnus-inhibit-mime-unbuttonizing
9780 (not gnus-inhibit-mime-unbuttonizing))
9781 (let ((gnus-unbuttonized-mime-types nil))
9782 (gnus-summary-show-article))
9783 (gnus-summary-show-article)))
9786 ;;; Generic summary marking commands
9789 (defvar gnus-summary-marking-alist
9790 '((read gnus-del-mark "d")
9791 (unread gnus-unread-mark "u")
9792 (ticked gnus-ticked-mark "!")
9793 (dormant gnus-dormant-mark "?")
9794 (expirable gnus-expirable-mark "e"))
9795 "An alist of names/marks/keystrokes.")
9797 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9798 (defvar gnus-summary-mark-map)
9800 (defun gnus-summary-make-all-marking-commands ()
9801 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9802 (dolist (elem gnus-summary-marking-alist)
9803 (apply 'gnus-summary-make-marking-command elem)))
9805 (defun gnus-summary-make-marking-command (name mark keystroke)
9806 (let ((map (make-sparse-keymap)))
9807 (define-key gnus-summary-generic-mark-map keystroke map)
9808 (dolist (lway `((next "next" next nil "n")
9809 (next-unread "next unread" next t "N")
9810 (prev "previous" prev nil "p")
9811 (prev-unread "previous unread" prev t "P")
9812 (nomove "" nil nil ,keystroke)))
9813 (let ((func (gnus-summary-make-marking-command-1
9814 mark (car lway) lway name)))
9815 (setq func (eval func))
9816 (define-key map (nth 4 lway) func)))))
9818 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9820 (format "gnus-summary-put-mark-as-%s%s"
9821 name (if (eq way 'nomove)
9823 (concat "-" (symbol-name way)))))
9826 "Mark the current article as %s%s.
9827 If N, the prefix, then repeat N times.
9828 If N is negative, move in reverse order.
9829 The difference between N and the actual number of articles marked is
9833 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9835 (defun gnus-summary-generic-mark (n mark move unread)
9836 "Mark N articles with MARK."
9837 (unless (eq major-mode 'gnus-summary-mode)
9838 (error "This command can only be used in the summary buffer"))
9839 (gnus-summary-show-thread)
9843 ((eq move 'prev) -1)
9849 nummove (* -1 nummove))))
9851 (gnus-summary-mark-article nil mark)
9852 (zerop (gnus-summary-next-subject nummove unread t)))
9855 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9856 (gnus-summary-recenter)
9857 (gnus-summary-position-point)
9858 (gnus-set-mode-line 'summary)
9861 (gnus-summary-make-all-marking-commands)
9867 (run-hooks 'gnus-sum-load-hook)
9869 ;;; gnus-sum.el ends here