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 "d" gnus-article-treat-dumbquotes)
1573 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1574 "a" gnus-article-hide
1575 "h" gnus-article-hide-headers
1576 "b" gnus-article-hide-boring-headers
1577 "s" gnus-article-hide-signature
1578 "c" gnus-article-hide-citation
1579 "C" gnus-article-hide-citation-in-followups
1580 "l" gnus-article-hide-list-identifiers
1581 "p" gnus-article-hide-pgp
1582 "B" gnus-article-strip-banner
1583 "P" gnus-article-hide-pem
1584 "\C-c" gnus-article-hide-citation-maybe)
1586 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1587 "a" gnus-article-highlight
1588 "h" gnus-article-highlight-headers
1589 "c" gnus-article-highlight-citation
1590 "s" gnus-article-highlight-signature)
1592 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1593 "w" gnus-article-decode-mime-words
1594 "c" gnus-article-decode-charset
1595 "v" gnus-mime-view-all-parts
1596 "b" gnus-article-view-part)
1598 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1599 "z" gnus-article-date-ut
1600 "u" gnus-article-date-ut
1601 "l" gnus-article-date-local
1602 "e" gnus-article-date-lapsed
1603 "o" gnus-article-date-original
1604 "i" gnus-article-date-iso8601
1605 "s" gnus-article-date-user)
1607 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1608 "t" gnus-article-remove-trailing-blank-lines
1609 "l" gnus-article-strip-leading-blank-lines
1610 "m" gnus-article-strip-multiple-blank-lines
1611 "a" gnus-article-strip-blank-lines
1612 "A" gnus-article-strip-all-blank-lines
1613 "s" gnus-article-strip-leading-space
1614 "e" gnus-article-strip-trailing-space)
1616 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1618 "f" gnus-summary-fetch-faq
1619 "d" gnus-summary-describe-group
1620 "h" gnus-summary-describe-briefly
1621 "i" gnus-info-find-node)
1623 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1624 "e" gnus-summary-expire-articles
1625 "\M-\C-e" gnus-summary-expire-articles-now
1626 "\177" gnus-summary-delete-article
1627 [delete] gnus-summary-delete-article
1628 [backspace] gnus-summary-delete-article
1629 "m" gnus-summary-move-article
1630 "r" gnus-summary-respool-article
1631 "w" gnus-summary-edit-article
1632 "c" gnus-summary-copy-article
1633 "B" gnus-summary-crosspost-article
1634 "q" gnus-summary-respool-query
1635 "t" gnus-summary-respool-trace
1636 "i" gnus-summary-import-article
1637 "p" gnus-summary-article-posted-p)
1639 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1640 "o" gnus-summary-save-article
1641 "m" gnus-summary-save-article-mail
1642 "F" gnus-summary-write-article-file
1643 "r" gnus-summary-save-article-rmail
1644 "f" gnus-summary-save-article-file
1645 "b" gnus-summary-save-article-body-file
1646 "h" gnus-summary-save-article-folder
1647 "v" gnus-summary-save-article-vm
1648 "p" gnus-summary-pipe-output
1649 "s" gnus-soup-add-article)
1651 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1652 "b" gnus-summary-display-buttonized
1653 "m" gnus-summary-repair-multipart
1654 "v" gnus-article-view-part
1655 "o" gnus-article-save-part
1656 "c" gnus-article-copy-part
1657 "C" gnus-article-view-part-as-charset
1658 "e" gnus-article-externalize-part
1659 "E" gnus-article-encrypt-body
1660 "i" gnus-article-inline-part
1661 "|" gnus-article-pipe-part))
1663 (defun gnus-summary-make-menu-bar ()
1664 (gnus-turn-off-edit-menu 'summary)
1666 (unless (boundp 'gnus-summary-misc-menu)
1669 gnus-summary-kill-menu gnus-summary-mode-map ""
1674 ["Enter score..." gnus-summary-score-entry t]
1675 ["Customize" gnus-score-customize t])
1676 (gnus-make-score-map 'increase)
1677 (gnus-make-score-map 'lower)
1679 ["Kill below" gnus-summary-kill-below t]
1680 ["Mark above" gnus-summary-mark-above t]
1681 ["Tick above" gnus-summary-tick-above t]
1682 ["Clear above" gnus-summary-clear-above t])
1683 ["Current score" gnus-summary-current-score t]
1684 ["Set score" gnus-summary-set-score t]
1685 ["Switch current score file..." gnus-score-change-score-file t]
1686 ["Set mark below..." gnus-score-set-mark-below t]
1687 ["Set expunge below..." gnus-score-set-expunge-below t]
1688 ["Edit current score file" gnus-score-edit-current-scores t]
1689 ["Edit score file" gnus-score-edit-file t]
1690 ["Trace score" gnus-score-find-trace t]
1691 ["Find words" gnus-score-find-favourite-words t]
1692 ["Rescore buffer" gnus-summary-rescore t]
1693 ["Increase score..." gnus-summary-increase-score t]
1694 ["Lower score..." gnus-summary-lower-score t]))))
1696 ;; Define both the Article menu in the summary buffer and the equivalent
1697 ;; Commands menu in the article buffer here for consistency.
1700 ["All" gnus-article-hide t]
1701 ["Headers" gnus-article-hide-headers t]
1702 ["Signature" gnus-article-hide-signature t]
1703 ["Citation" gnus-article-hide-citation t]
1704 ["List identifiers" gnus-article-hide-list-identifiers t]
1705 ["PGP" gnus-article-hide-pgp t]
1706 ["Banner" gnus-article-strip-banner t]
1707 ["Boring headers" gnus-article-hide-boring-headers t])
1709 ["All" gnus-article-highlight t]
1710 ["Headers" gnus-article-highlight-headers t]
1711 ["Signature" gnus-article-highlight-signature t]
1712 ["Citation" gnus-article-highlight-citation t])
1714 ["Words" gnus-article-decode-mime-words t]
1715 ["Charset" gnus-article-decode-charset t]
1716 ["QP" gnus-article-de-quoted-unreadable t]
1717 ["Base64" gnus-article-de-base64-unreadable t]
1718 ["View all" gnus-mime-view-all-parts t]
1719 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt]
1720 ["Encrypt body" gnus-article-encrypt-body])
1722 ["Local" gnus-article-date-local t]
1723 ["ISO8601" gnus-article-date-iso8601 t]
1724 ["UT" gnus-article-date-ut t]
1725 ["Original" gnus-article-date-original t]
1726 ["Lapsed" gnus-article-date-lapsed t]
1727 ["User-defined" gnus-article-date-user t])
1730 ["Leading" gnus-article-strip-leading-blank-lines t]
1731 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1732 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1733 ["All of the above" gnus-article-strip-blank-lines t]
1734 ["All" gnus-article-strip-all-blank-lines t]
1735 ["Leading space" gnus-article-strip-leading-space t]
1736 ["Trailing space" gnus-article-strip-trailing-space t])
1737 ["Overstrike" gnus-article-treat-overstrike t]
1738 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1739 ["Emphasis" gnus-article-emphasize t]
1740 ["Word wrap" gnus-article-fill-cited-article t]
1741 ["Fill long lines" gnus-article-fill-long-lines t]
1742 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1743 ["CR" gnus-article-remove-cr t]
1744 ["Show X-Face" gnus-article-display-x-face t]
1745 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1746 ["Base64" gnus-article-de-base64-unreadable t]
1747 ["Rot 13" gnus-summary-caesar-message t]
1748 ["Unix pipe" gnus-summary-pipe-message t]
1749 ["Add buttons" gnus-article-add-buttons t]
1750 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1751 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1752 ["Verbose header" gnus-summary-verbose-headers t]
1753 ["Toggle header" gnus-summary-toggle-header t]
1754 ["Html" gnus-article-wash-html t]
1755 ["HZ" gnus-article-decode-HZ t])
1757 ["Save in default format" gnus-summary-save-article t]
1758 ["Save in file" gnus-summary-save-article-file t]
1759 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1760 ["Save in MH folder" gnus-summary-save-article-folder t]
1761 ["Save in VM folder" gnus-summary-save-article-vm t]
1762 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1763 ["Save body in file" gnus-summary-save-article-body-file t]
1764 ["Pipe through a filter" gnus-summary-pipe-output t]
1765 ["Add to SOUP packet" gnus-soup-add-article t]
1766 ["Print" gnus-summary-print-article t])
1768 ["Respool article..." gnus-summary-respool-article t]
1769 ["Move article..." gnus-summary-move-article
1770 (gnus-check-backend-function
1771 'request-move-article gnus-newsgroup-name)]
1772 ["Copy article..." gnus-summary-copy-article t]
1773 ["Crosspost article..." gnus-summary-crosspost-article
1774 (gnus-check-backend-function
1775 'request-replace-article gnus-newsgroup-name)]
1776 ["Import file..." gnus-summary-import-article t]
1777 ["Check if posted" gnus-summary-article-posted-p t]
1778 ["Edit article" gnus-summary-edit-article
1779 (not (gnus-group-read-only-p))]
1780 ["Delete article" gnus-summary-delete-article
1781 (gnus-check-backend-function
1782 'request-expire-articles gnus-newsgroup-name)]
1783 ["Query respool" gnus-summary-respool-query t]
1784 ["Trace respool" gnus-summary-respool-trace t]
1785 ["Delete expirable articles" gnus-summary-expire-articles-now
1786 (gnus-check-backend-function
1787 'request-expire-articles gnus-newsgroup-name)])
1789 ["Uudecode" gnus-uu-decode-uu t]
1790 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1791 ["Unshar" gnus-uu-decode-unshar t]
1792 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1793 ["Save" gnus-uu-decode-save t]
1794 ["Binhex" gnus-uu-decode-binhex t]
1795 ["Postscript" gnus-uu-decode-postscript t])
1797 ["Enter article" gnus-cache-enter-article t]
1798 ["Remove article" gnus-cache-remove-article t])
1799 ["Translate" gnus-article-babel t]
1800 ["Select article buffer" gnus-summary-select-article-buffer t]
1801 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1802 ["Isearch article..." gnus-summary-isearch-article t]
1803 ["Beginning of the article" gnus-summary-beginning-of-article t]
1804 ["End of the article" gnus-summary-end-of-article t]
1805 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1806 ["Fetch referenced articles" gnus-summary-refer-references t]
1807 ["Fetch current thread" gnus-summary-refer-thread t]
1808 ["Fetch article with id..." gnus-summary-refer-article t]
1809 ["Redisplay" gnus-summary-show-article t])))
1811 gnus-summary-article-menu gnus-summary-mode-map ""
1812 (cons "Article" innards))
1815 gnus-article-commands-menu gnus-article-mode-map ""
1816 (cons "Commands" innards)))
1819 gnus-summary-thread-menu gnus-summary-mode-map ""
1821 ["Toggle threading" gnus-summary-toggle-threads t]
1822 ["Hide threads" gnus-summary-hide-all-threads t]
1823 ["Show threads" gnus-summary-show-all-threads t]
1824 ["Hide thread" gnus-summary-hide-thread t]
1825 ["Show thread" gnus-summary-show-thread t]
1826 ["Go to next thread" gnus-summary-next-thread t]
1827 ["Go to previous thread" gnus-summary-prev-thread t]
1828 ["Go down thread" gnus-summary-down-thread t]
1829 ["Go up thread" gnus-summary-up-thread t]
1830 ["Top of thread" gnus-summary-top-thread t]
1831 ["Mark thread as read" gnus-summary-kill-thread t]
1832 ["Lower thread score" gnus-summary-lower-thread t]
1833 ["Raise thread score" gnus-summary-raise-thread t]
1834 ["Rethread current" gnus-summary-rethread-current t]))
1837 gnus-summary-post-menu gnus-summary-mode-map ""
1839 ["Post an article" gnus-summary-post-news t]
1840 ["Followup" gnus-summary-followup t]
1841 ["Followup and yank" gnus-summary-followup-with-original t]
1842 ["Supersede article" gnus-summary-supersede-article t]
1843 ["Cancel article" gnus-summary-cancel-article t]
1844 ["Reply" gnus-summary-reply t]
1845 ["Reply and yank" gnus-summary-reply-with-original t]
1846 ["Wide reply" gnus-summary-wide-reply t]
1847 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1848 ["Mail forward" gnus-summary-mail-forward t]
1849 ["Post forward" gnus-summary-post-forward t]
1850 ["Digest and mail" gnus-uu-digest-mail-forward t]
1851 ["Digest and post" gnus-uu-digest-post-forward t]
1852 ["Resend message" gnus-summary-resend-message t]
1853 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1854 ["Send a mail" gnus-summary-mail-other-window t]
1855 ["Uuencode and post" gnus-uu-post-news t]
1856 ["Followup via news" gnus-summary-followup-to-mail t]
1857 ["Followup via news and yank"
1858 gnus-summary-followup-to-mail-with-original t]
1860 ;;["Send" gnus-summary-send-draft t]
1861 ;;["Send bounced" gnus-resend-bounced-mail t])
1865 gnus-summary-misc-menu gnus-summary-mode-map ""
1868 ["Mark as read" gnus-summary-mark-as-read-forward t]
1869 ["Mark same subject and select"
1870 gnus-summary-kill-same-subject-and-select t]
1871 ["Mark same subject" gnus-summary-kill-same-subject t]
1872 ["Catchup" gnus-summary-catchup t]
1873 ["Catchup all" gnus-summary-catchup-all t]
1874 ["Catchup to here" gnus-summary-catchup-to-here t]
1875 ["Catchup region" gnus-summary-mark-region-as-read t]
1876 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1878 ["Tick" gnus-summary-tick-article-forward t]
1879 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1880 ["Remove marks" gnus-summary-clear-mark-forward t]
1881 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1882 ["Set bookmark" gnus-summary-set-bookmark t]
1883 ["Remove bookmark" gnus-summary-remove-bookmark t])
1885 ["Marks..." gnus-summary-limit-to-marks t]
1886 ["Subject..." gnus-summary-limit-to-subject t]
1887 ["Author..." gnus-summary-limit-to-author t]
1888 ["Age..." gnus-summary-limit-to-age t]
1889 ["Extra..." gnus-summary-limit-to-extra t]
1890 ["Score" gnus-summary-limit-to-score t]
1891 ["Unread" gnus-summary-limit-to-unread t]
1892 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1893 ["Articles" gnus-summary-limit-to-articles t]
1894 ["Pop limit" gnus-summary-pop-limit t]
1895 ["Show dormant" gnus-summary-limit-include-dormant t]
1896 ["Hide childless dormant"
1897 gnus-summary-limit-exclude-childless-dormant t]
1898 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1899 ["Hide marked" gnus-summary-limit-exclude-marks t]
1900 ["Show expunged" gnus-summary-show-all-expunged t])
1902 ["Set mark" gnus-summary-mark-as-processable t]
1903 ["Remove mark" gnus-summary-unmark-as-processable t]
1904 ["Remove all marks" gnus-summary-unmark-all-processable t]
1905 ["Mark above" gnus-uu-mark-over t]
1906 ["Mark series" gnus-uu-mark-series t]
1907 ["Mark region" gnus-uu-mark-region t]
1908 ["Unmark region" gnus-uu-unmark-region t]
1909 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1910 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1911 ["Mark all" gnus-uu-mark-all t]
1912 ["Mark buffer" gnus-uu-mark-buffer t]
1913 ["Mark sparse" gnus-uu-mark-sparse t]
1914 ["Mark thread" gnus-uu-mark-thread t]
1915 ["Unmark thread" gnus-uu-unmark-thread t]
1916 ("Process Mark Sets"
1917 ["Kill" gnus-summary-kill-process-mark t]
1918 ["Yank" gnus-summary-yank-process-mark
1919 gnus-newsgroup-process-stack]
1920 ["Save" gnus-summary-save-process-mark t]))
1922 ["Page forward" gnus-summary-next-page t]
1923 ["Page backward" gnus-summary-prev-page t]
1924 ["Line forward" gnus-summary-scroll-up t])
1926 ["Next unread article" gnus-summary-next-unread-article t]
1927 ["Previous unread article" gnus-summary-prev-unread-article t]
1928 ["Next article" gnus-summary-next-article t]
1929 ["Previous article" gnus-summary-prev-article t]
1930 ["Next unread subject" gnus-summary-next-unread-subject t]
1931 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1932 ["Next article same subject" gnus-summary-next-same-subject t]
1933 ["Previous article same subject" gnus-summary-prev-same-subject t]
1934 ["First unread article" gnus-summary-first-unread-article t]
1935 ["Best unread article" gnus-summary-best-unread-article t]
1936 ["Go to subject number..." gnus-summary-goto-subject t]
1937 ["Go to article number..." gnus-summary-goto-article t]
1938 ["Go to the last article" gnus-summary-goto-last-article t]
1939 ["Pop article off history" gnus-summary-pop-article t])
1941 ["Sort by number" gnus-summary-sort-by-number t]
1942 ["Sort by author" gnus-summary-sort-by-author t]
1943 ["Sort by subject" gnus-summary-sort-by-subject t]
1944 ["Sort by date" gnus-summary-sort-by-date t]
1945 ["Sort by score" gnus-summary-sort-by-score t]
1946 ["Sort by lines" gnus-summary-sort-by-lines t]
1947 ["Sort by characters" gnus-summary-sort-by-chars t])
1949 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1950 ["Describe group" gnus-summary-describe-group t]
1951 ["Read manual" gnus-info-find-node t])
1953 ["Pick and read" gnus-pick-mode t]
1954 ["Binary" gnus-binary-mode t])
1956 ["Regenerate" gnus-summary-prepare t]
1957 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1958 ["Toggle threading" gnus-summary-toggle-threads t])
1959 ["Filter articles..." gnus-summary-execute-command t]
1960 ["Run command on subjects..." gnus-summary-universal-argument t]
1961 ["Search articles forward..." gnus-summary-search-article-forward t]
1962 ["Search articles backward..." gnus-summary-search-article-backward t]
1963 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1964 ["Expand window" gnus-summary-expand-window t]
1965 ["Expire expirable articles" gnus-summary-expire-articles
1966 (gnus-check-backend-function
1967 'request-expire-articles gnus-newsgroup-name)]
1968 ["Edit local kill file" gnus-summary-edit-local-kill t]
1969 ["Edit main kill file" gnus-summary-edit-global-kill t]
1970 ["Edit group parameters" gnus-summary-edit-parameters t]
1971 ["Customize group parameters" gnus-summary-customize-parameters t]
1972 ["Send a bug report" gnus-bug t]
1974 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1975 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1976 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1977 ["Exit group" gnus-summary-exit t]
1978 ["Exit group without updating" gnus-summary-exit-no-update t]
1979 ["Exit and goto next group" gnus-summary-next-group t]
1980 ["Exit and goto prev group" gnus-summary-prev-group t]
1981 ["Reselect group" gnus-summary-reselect-current-group t]
1982 ["Rescan group" gnus-summary-rescan-group t]
1983 ["Update dribble" gnus-summary-save-newsrc t])))
1985 (gnus-run-hooks 'gnus-summary-menu-hook)))
1987 (defun gnus-score-set-default (var value)
1988 "A version of set that updates the GNU Emacs menu-bar."
1990 ;; It is the message that forces the active status to be updated.
1993 (defun gnus-make-score-map (type)
1994 "Make a summary score map of type TYPE."
1997 (let ((headers '(("author" "from" string)
1998 ("subject" "subject" string)
1999 ("article body" "body" string)
2000 ("article head" "head" string)
2001 ("xref" "xref" string)
2002 ("extra header" "extra" string)
2003 ("lines" "lines" number)
2004 ("followups to author" "followup" string)))
2005 (types '((number ("less than" <)
2008 (string ("substring" s)
2012 (perms '(("temporary" (current-time-string))
2020 (if (eq type 'lower)
2025 (setq header (car headers))
2031 (let ((ts (cdr (assoc (nth 2 header) types)))
2047 'gnus-summary-score-entry
2049 (if (or (string= (nth 1 header)
2051 (string= (nth 1 header)
2054 (list 'gnus-summary-header
2056 (list 'quote (nth 1 (car ts)))
2057 (list 'gnus-score-delta-default
2064 (list (nreverse outp))))
2067 (list (nreverse outt))))
2069 (setq headers (cdr headers)))
2070 (list (nreverse outh))))))))
2074 (defun gnus-summary-mode (&optional group)
2075 "Major mode for reading articles.
2077 All normal editing commands are switched off.
2078 \\<gnus-summary-mode-map>
2079 Each line in this buffer represents one article. To read an
2080 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2081 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2084 You can also post articles and send mail from this buffer. To
2085 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2086 of an article, type `\\[gnus-summary-reply]'.
2088 There are approx. one gazillion commands you can execute in this
2089 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2091 The following commands are available:
2093 \\{gnus-summary-mode-map}"
2095 (when (gnus-visual-p 'summary-menu 'menu)
2096 (gnus-summary-make-menu-bar))
2097 (kill-all-local-variables)
2098 (gnus-summary-make-local-variables)
2099 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2100 (gnus-summary-make-local-variables))
2101 (gnus-make-thread-indent-array)
2102 (gnus-simplify-mode-line)
2103 (setq major-mode 'gnus-summary-mode)
2104 (setq mode-name "Summary")
2105 (make-local-variable 'minor-mode-alist)
2106 (use-local-map gnus-summary-mode-map)
2107 (buffer-disable-undo)
2108 (setq buffer-read-only t) ;Disable modification
2109 (setq truncate-lines t)
2110 (setq selective-display t)
2111 (setq selective-display-ellipses t) ;Display `...'
2112 (gnus-summary-set-display-table)
2113 (gnus-set-default-directory)
2114 (setq gnus-newsgroup-name group)
2115 (make-local-variable 'gnus-summary-line-format)
2116 (make-local-variable 'gnus-summary-line-format-spec)
2117 (make-local-variable 'gnus-summary-dummy-line-format)
2118 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2119 (make-local-variable 'gnus-summary-mark-positions)
2120 (make-local-hook 'pre-command-hook)
2121 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2122 (gnus-run-hooks 'gnus-summary-mode-hook)
2123 (mm-enable-multibyte-mule4)
2124 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2125 (gnus-update-summary-mark-positions))
2127 (defun gnus-summary-make-local-variables ()
2128 "Make all the local summary buffer variables."
2130 (dolist (local gnus-summary-local-variables)
2133 (if (eq (cdr local) 'global)
2134 ;; Copy the global value of the variable.
2135 (setq global (symbol-value (car local)))
2136 ;; Use the value from the list.
2137 (setq global (eval (cdr local))))
2138 (set (make-local-variable (car local)) global))
2139 ;; Simple nil-valued local variable.
2140 (set (make-local-variable local) nil)))))
2142 (defun gnus-summary-clear-local-variables ()
2143 (let ((locals gnus-summary-local-variables))
2145 (if (consp (car locals))
2146 (and (vectorp (caar locals))
2147 (set (caar locals) nil))
2148 (and (vectorp (car locals))
2149 (set (car locals) nil)))
2150 (setq locals (cdr locals)))))
2152 ;; Summary data functions.
2154 (defmacro gnus-data-number (data)
2157 (defmacro gnus-data-set-number (data number)
2158 `(setcar ,data ,number))
2160 (defmacro gnus-data-mark (data)
2163 (defmacro gnus-data-set-mark (data mark)
2164 `(setcar (nthcdr 1 ,data) ,mark))
2166 (defmacro gnus-data-pos (data)
2169 (defmacro gnus-data-set-pos (data pos)
2170 `(setcar (nthcdr 2 ,data) ,pos))
2172 (defmacro gnus-data-header (data)
2175 (defmacro gnus-data-set-header (data header)
2176 `(setf (nth 3 ,data) ,header))
2178 (defmacro gnus-data-level (data)
2181 (defmacro gnus-data-unread-p (data)
2182 `(= (nth 1 ,data) gnus-unread-mark))
2184 (defmacro gnus-data-read-p (data)
2185 `(/= (nth 1 ,data) gnus-unread-mark))
2187 (defmacro gnus-data-pseudo-p (data)
2188 `(consp (nth 3 ,data)))
2190 (defmacro gnus-data-find (number)
2191 `(assq ,number gnus-newsgroup-data))
2193 (defmacro gnus-data-find-list (number &optional data)
2194 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2195 (memq (assq ,number bdata)
2198 (defmacro gnus-data-make (number mark pos header level)
2199 `(list ,number ,mark ,pos ,header ,level))
2201 (defun gnus-data-enter (after-article number mark pos header level offset)
2202 (let ((data (gnus-data-find-list after-article)))
2204 (error "No such article: %d" after-article))
2205 (setcdr data (cons (gnus-data-make number mark pos header level)
2207 (setq gnus-newsgroup-data-reverse nil)
2208 (gnus-data-update-list (cddr data) offset)))
2210 (defun gnus-data-enter-list (after-article list &optional offset)
2212 (let ((data (and after-article (gnus-data-find-list after-article)))
2216 (let ((odata gnus-newsgroup-data))
2217 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2219 (gnus-data-update-list odata offset)))
2220 ;; Find the last element in the list to be spliced into the main
2223 (setq list (cdr list)))
2226 (setcdr list gnus-newsgroup-data)
2227 (setq gnus-newsgroup-data ilist)
2229 (gnus-data-update-list (cdr list) offset)))
2230 (setcdr list (cdr data))
2233 (gnus-data-update-list (cdr list) offset))))
2234 (setq gnus-newsgroup-data-reverse nil))))
2236 (defun gnus-data-remove (article &optional offset)
2237 (let ((data gnus-newsgroup-data))
2238 (if (= (gnus-data-number (car data)) article)
2240 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2241 gnus-newsgroup-data-reverse nil)
2243 (gnus-data-update-list gnus-newsgroup-data offset)))
2245 (when (= (gnus-data-number (cadr data)) article)
2246 (setcdr data (cddr data))
2248 (gnus-data-update-list (cdr data) offset))
2250 gnus-newsgroup-data-reverse nil))
2251 (setq data (cdr data))))))
2253 (defmacro gnus-data-list (backward)
2255 (or gnus-newsgroup-data-reverse
2256 (setq gnus-newsgroup-data-reverse
2257 (reverse gnus-newsgroup-data)))
2258 gnus-newsgroup-data))
2260 (defun gnus-data-update-list (data offset)
2261 "Add OFFSET to the POS of all data entries in DATA."
2262 (setq gnus-newsgroup-data-reverse nil)
2264 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2265 (setq data (cdr data))))
2267 (defun gnus-summary-article-pseudo-p (article)
2268 "Say whether this article is a pseudo article or not."
2269 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2271 (defmacro gnus-summary-article-sparse-p (article)
2272 "Say whether this article is a sparse article or not."
2273 `(memq ,article gnus-newsgroup-sparse))
2275 (defmacro gnus-summary-article-ancient-p (article)
2276 "Say whether this article is a sparse article or not."
2277 `(memq ,article gnus-newsgroup-ancient))
2279 (defun gnus-article-parent-p (number)
2280 "Say whether this article is a parent or not."
2281 (let ((data (gnus-data-find-list number)))
2282 (and (cdr data) ; There has to be an article after...
2283 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2284 (gnus-data-level (nth 1 data))))))
2286 (defun gnus-article-children (number)
2287 "Return a list of all children to NUMBER."
2288 (let* ((data (gnus-data-find-list number))
2289 (level (gnus-data-level (car data)))
2291 (setq data (cdr data))
2293 (= (gnus-data-level (car data)) (1+ level)))
2294 (push (gnus-data-number (car data)) children)
2295 (setq data (cdr data)))
2298 (defmacro gnus-summary-skip-intangible ()
2299 "If the current article is intangible, then jump to a different article."
2300 '(let ((to (get-text-property (point) 'gnus-intangible)))
2301 (and to (gnus-summary-goto-subject to))))
2303 (defmacro gnus-summary-article-intangible-p ()
2304 "Say whether this article is intangible or not."
2305 '(get-text-property (point) 'gnus-intangible))
2307 (defun gnus-article-read-p (article)
2308 "Say whether ARTICLE is read or not."
2309 (not (or (memq article gnus-newsgroup-marked)
2310 (memq article gnus-newsgroup-unreads)
2311 (memq article gnus-newsgroup-unselected)
2312 (memq article gnus-newsgroup-dormant))))
2314 ;; Some summary mode macros.
2316 (defmacro gnus-summary-article-number ()
2317 "The article number of the article on the current line.
2318 If there isn's an article number here, then we return the current
2321 (gnus-summary-skip-intangible)
2322 (or (get-text-property (point) 'gnus-number)
2323 (gnus-summary-last-subject))))
2325 (defmacro gnus-summary-article-header (&optional number)
2326 "Return the header of article NUMBER."
2327 `(gnus-data-header (gnus-data-find
2328 ,(or number '(gnus-summary-article-number)))))
2330 (defmacro gnus-summary-thread-level (&optional number)
2331 "Return the level of thread that starts with article NUMBER."
2332 `(if (and (eq gnus-summary-make-false-root 'dummy)
2333 (get-text-property (point) 'gnus-intangible))
2335 (gnus-data-level (gnus-data-find
2336 ,(or number '(gnus-summary-article-number))))))
2338 (defmacro gnus-summary-article-mark (&optional number)
2339 "Return the mark of article NUMBER."
2340 `(gnus-data-mark (gnus-data-find
2341 ,(or number '(gnus-summary-article-number)))))
2343 (defmacro gnus-summary-article-pos (&optional number)
2344 "Return the position of the line of article NUMBER."
2345 `(gnus-data-pos (gnus-data-find
2346 ,(or number '(gnus-summary-article-number)))))
2348 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2349 (defmacro gnus-summary-article-subject (&optional number)
2350 "Return current subject string or nil if nothing."
2353 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2354 '(gnus-data-header (assq (gnus-summary-article-number)
2355 gnus-newsgroup-data)))))
2358 (mail-header-subject headers))))
2360 (defmacro gnus-summary-article-score (&optional number)
2361 "Return current article score."
2362 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2363 gnus-newsgroup-scored))
2364 gnus-summary-default-score 0))
2366 (defun gnus-summary-article-children (&optional number)
2367 "Return a list of article numbers that are children of article NUMBER."
2368 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2369 (level (gnus-data-level (car data)))
2371 (while (and (setq data (cdr data))
2372 (> (setq l (gnus-data-level (car data))) level))
2373 (and (= (1+ level) l)
2374 (push (gnus-data-number (car data))
2376 (nreverse children)))
2378 (defun gnus-summary-article-parent (&optional number)
2379 "Return the article number of the parent of article NUMBER."
2380 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2381 (gnus-data-list t)))
2382 (level (gnus-data-level (car data))))
2384 () ; This is a root.
2385 ;; We search until we find an article with a level less than
2386 ;; this one. That function has to be the parent.
2387 (while (and (setq data (cdr data))
2388 (not (< (gnus-data-level (car data)) level))))
2389 (and data (gnus-data-number (car data))))))
2391 (defun gnus-unread-mark-p (mark)
2392 "Say whether MARK is the unread mark."
2393 (= mark gnus-unread-mark))
2395 (defun gnus-read-mark-p (mark)
2396 "Say whether MARK is one of the marks that mark as read.
2397 This is all marks except unread, ticked, dormant, and expirable."
2398 (not (or (= mark gnus-unread-mark)
2399 (= mark gnus-ticked-mark)
2400 (= mark gnus-dormant-mark)
2401 (= mark gnus-expirable-mark))))
2403 (defmacro gnus-article-mark (number)
2404 "Return the MARK of article NUMBER.
2405 This macro should only be used when computing the mark the \"first\"
2406 time; i.e., when generating the summary lines. After that,
2407 `gnus-summary-article-mark' should be used to examine the
2410 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2411 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2412 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2413 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2414 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2415 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2416 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2417 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2418 gnus-ancient-mark))))
2420 ;; Saving hidden threads.
2422 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2423 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2425 (defmacro gnus-save-hidden-threads (&rest forms)
2426 "Save hidden threads, eval FORMS, and restore the hidden threads."
2427 (let ((config (make-symbol "config")))
2428 `(let ((,config (gnus-hidden-threads-configuration)))
2432 (gnus-restore-hidden-threads-configuration ,config)))))
2434 (defun gnus-data-compute-positions ()
2435 "Compute the positions of all articles."
2436 (setq gnus-newsgroup-data-reverse nil)
2437 (let ((data gnus-newsgroup-data))
2439 (gnus-save-hidden-threads
2440 (gnus-summary-show-all-threads)
2441 (goto-char (point-min))
2443 (while (get-text-property (point) 'gnus-intangible)
2445 (gnus-data-set-pos (car data) (+ (point) 3))
2446 (setq data (cdr data))
2447 (forward-line 1))))))
2449 (defun gnus-hidden-threads-configuration ()
2450 "Return the current hidden threads configuration."
2453 (goto-char (point-min))
2454 (while (search-forward "\r" nil t)
2455 (push (1- (point)) config))
2458 (defun gnus-restore-hidden-threads-configuration (config)
2459 "Restore hidden threads configuration from CONFIG."
2461 (let (point buffer-read-only)
2462 (while (setq point (pop config))
2463 (when (and (< point (point-max))
2465 (eq (char-after) ?\n))
2466 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2468 ;; Various summary mode internalish functions.
2470 (defun gnus-mouse-pick-article (e)
2473 (gnus-summary-next-page nil t))
2475 (defun gnus-summary-set-display-table ()
2476 "Change the display table.
2477 Odd characters have a tendency to mess
2478 up nicely formatted displays - we make all possible glyphs
2479 display only a single character."
2481 ;; We start from the standard display table, if any.
2482 (let ((table (or (copy-sequence standard-display-table)
2483 (make-display-table)))
2485 ;; Nix out all the control chars...
2486 (while (>= (setq i (1- i)) 0)
2487 (aset table i [??]))
2488 ;; ... but not newline and cr, of course. (cr is necessary for the
2489 ;; selective display).
2490 (aset table ?\n nil)
2491 (aset table ?\r nil)
2492 ;; We keep TAB as well.
2493 (aset table ?\t nil)
2494 ;; We nix out any glyphs over 126 that are not set already.
2496 (while (>= (setq i (1- i)) 127)
2497 ;; Only modify if the entry is nil.
2498 (unless (aref table i)
2499 (aset table i [??]))))
2500 (setq buffer-display-table table)))
2502 (defun gnus-summary-setup-buffer (group)
2503 "Initialize summary buffer."
2504 (let ((buffer (concat "*Summary " group "*")))
2505 (if (get-buffer buffer)
2508 (setq gnus-summary-buffer (current-buffer))
2509 (not gnus-newsgroup-prepared))
2510 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2511 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2512 (gnus-summary-mode group)
2514 (gnus-carpal-setup-buffer 'summary))
2515 (unless gnus-single-article-buffer
2516 (make-local-variable 'gnus-article-buffer)
2517 (make-local-variable 'gnus-article-current)
2518 (make-local-variable 'gnus-original-article-buffer))
2519 (setq gnus-newsgroup-name group)
2522 (defun gnus-set-global-variables ()
2523 "Set the global equivalents of the buffer-local variables.
2524 They are set to the latest values they had. These reflect the summary
2525 buffer that was in action when the last article was fetched."
2526 (when (eq major-mode 'gnus-summary-mode)
2527 (setq gnus-summary-buffer (current-buffer))
2528 (let ((name gnus-newsgroup-name)
2529 (marked gnus-newsgroup-marked)
2530 (unread gnus-newsgroup-unreads)
2531 (headers gnus-current-headers)
2532 (data gnus-newsgroup-data)
2533 (summary gnus-summary-buffer)
2534 (article-buffer gnus-article-buffer)
2535 (original gnus-original-article-buffer)
2536 (gac gnus-article-current)
2537 (reffed gnus-reffed-article-number)
2538 (score-file gnus-current-score-file)
2539 (default-charset gnus-newsgroup-charset)
2541 (let ((locals gnus-newsgroup-variables))
2543 (if (consp (car locals))
2544 (push (eval (caar locals)) vlist)
2545 (push (eval (car locals)) vlist))
2546 (setq locals (cdr locals)))
2547 (setq vlist (nreverse vlist)))
2549 (set-buffer gnus-group-buffer)
2550 (setq gnus-newsgroup-name name
2551 gnus-newsgroup-marked marked
2552 gnus-newsgroup-unreads unread
2553 gnus-current-headers headers
2554 gnus-newsgroup-data data
2555 gnus-article-current gac
2556 gnus-summary-buffer summary
2557 gnus-article-buffer article-buffer
2558 gnus-original-article-buffer original
2559 gnus-reffed-article-number reffed
2560 gnus-current-score-file score-file
2561 gnus-newsgroup-charset default-charset)
2562 (let ((locals gnus-newsgroup-variables))
2564 (if (consp (car locals))
2565 (set (caar locals) (pop vlist))
2566 (set (car locals) (pop vlist)))
2567 (setq locals (cdr locals))))
2568 ;; The article buffer also has local variables.
2569 (when (gnus-buffer-live-p gnus-article-buffer)
2570 (set-buffer gnus-article-buffer)
2571 (setq gnus-summary-buffer summary))))))
2573 (defun gnus-summary-article-unread-p (article)
2574 "Say whether ARTICLE is unread or not."
2575 (memq article gnus-newsgroup-unreads))
2577 (defun gnus-summary-first-article-p (&optional article)
2578 "Return whether ARTICLE is the first article in the buffer."
2579 (if (not (setq article (or article (gnus-summary-article-number))))
2581 (eq article (caar gnus-newsgroup-data))))
2583 (defun gnus-summary-last-article-p (&optional article)
2584 "Return whether ARTICLE is the last article in the buffer."
2585 (if (not (setq article (or article (gnus-summary-article-number))))
2586 ;; All non-existent numbers are the last article. :-)
2588 (not (cdr (gnus-data-find-list article)))))
2590 (defun gnus-make-thread-indent-array ()
2592 (unless (and gnus-thread-indent-array
2593 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2594 (setq gnus-thread-indent-array (make-vector 201 "")
2595 gnus-thread-indent-array-level gnus-thread-indent-level)
2597 (aset gnus-thread-indent-array n
2598 (make-string (* n gnus-thread-indent-level) ? ))
2601 (defun gnus-update-summary-mark-positions ()
2602 "Compute where the summary marks are to go."
2604 (when (gnus-buffer-exists-p gnus-summary-buffer)
2605 (set-buffer gnus-summary-buffer))
2606 (let ((gnus-replied-mark 129)
2607 (gnus-score-below-mark 130)
2608 (gnus-score-over-mark 130)
2609 (gnus-download-mark 131)
2610 (spec gnus-summary-line-format-spec)
2613 (gnus-set-work-buffer)
2614 (let ((gnus-summary-line-format-spec spec)
2615 (gnus-newsgroup-downloadable '((0 . t))))
2616 (gnus-summary-insert-line
2617 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2618 (goto-char (point-min))
2619 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2621 (goto-char (point-min))
2622 (push (cons 'replied (and (search-forward "\201" nil t)
2625 (goto-char (point-min))
2626 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2628 (goto-char (point-min))
2629 (push (cons 'download
2630 (and (search-forward "\203" nil t) (- (point) 2)))
2632 (setq gnus-summary-mark-positions pos))))
2634 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2635 "Insert a dummy root in the summary buffer."
2637 (gnus-add-text-properties
2638 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2639 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2641 (defun gnus-summary-from-or-to-or-newsgroups (header)
2642 (let ((to (cdr (assq 'To (mail-header-extra header))))
2643 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2644 (mail-parse-charset gnus-newsgroup-charset)
2645 (mail-parse-ignored-charsets
2646 (save-excursion (set-buffer gnus-summary-buffer)
2647 gnus-newsgroup-ignored-charsets)))
2650 gnus-ignored-from-addresses
2651 (string-match gnus-ignored-from-addresses
2652 (mail-header-from header)))
2654 (or (car (funcall gnus-extract-address-components
2656 gnus-decode-encoded-word-function to)))
2657 (funcall gnus-decode-encoded-word-function to))))
2659 gnus-ignored-from-addresses
2660 (string-match gnus-ignored-from-addresses
2661 (mail-header-from header)))
2662 (concat "=> " newsgroups))
2664 (or (car (funcall gnus-extract-address-components
2665 (mail-header-from header)))
2666 (mail-header-from header))))))
2668 (defun gnus-summary-insert-line (gnus-tmp-header
2669 gnus-tmp-level gnus-tmp-current
2670 gnus-tmp-unread gnus-tmp-replied
2671 gnus-tmp-expirable gnus-tmp-subject-or-nil
2672 &optional gnus-tmp-dummy gnus-tmp-score
2674 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2675 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2676 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2677 (gnus-tmp-score-char
2678 (if (or (null gnus-summary-default-score)
2679 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2680 gnus-summary-zcore-fuzz))
2682 (if (< gnus-tmp-score gnus-summary-default-score)
2683 gnus-score-below-mark gnus-score-over-mark)))
2685 (cond (gnus-tmp-process gnus-process-mark)
2686 ((memq gnus-tmp-current gnus-newsgroup-cached)
2688 (gnus-tmp-replied gnus-replied-mark)
2689 ((memq gnus-tmp-current gnus-newsgroup-saved)
2691 (t gnus-unread-mark)))
2692 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2695 ((string-match "<[^>]+> *$" gnus-tmp-from)
2696 (let ((beg (match-beginning 0)))
2697 (or (and (string-match "^\".+\"" gnus-tmp-from)
2698 (substring gnus-tmp-from 1 (1- (match-end 0))))
2699 (substring gnus-tmp-from 0 beg))))
2700 ((string-match "(.+)" gnus-tmp-from)
2701 (substring gnus-tmp-from
2702 (1+ (match-beginning 0)) (1- (match-end 0))))
2704 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2705 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2706 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2707 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2708 (buffer-read-only nil))
2709 (when (string= gnus-tmp-name "")
2710 (setq gnus-tmp-name gnus-tmp-from))
2711 (unless (numberp gnus-tmp-lines)
2712 (setq gnus-tmp-lines 0))
2713 (gnus-put-text-property
2715 (progn (eval gnus-summary-line-format-spec) (point))
2716 'gnus-number gnus-tmp-number)
2717 (when (gnus-visual-p 'summary-highlight 'highlight)
2719 (gnus-run-hooks 'gnus-summary-update-hook)
2722 (defun gnus-summary-update-line (&optional dont-update)
2723 "Update summary line after change."
2724 (when (and gnus-summary-default-score
2725 (not gnus-summary-inhibit-highlight))
2726 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2727 (article (gnus-summary-article-number))
2728 (score (gnus-summary-article-score article)))
2730 (if (and gnus-summary-mark-below
2731 (< (gnus-summary-article-score)
2732 gnus-summary-mark-below))
2733 ;; This article has a low score, so we mark it as read.
2734 (when (memq article gnus-newsgroup-unreads)
2735 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2736 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2737 ;; This article was previously marked as read on account
2738 ;; of a low score, but now it has risen, so we mark it as
2740 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2741 (gnus-summary-update-mark
2742 (if (or (null gnus-summary-default-score)
2743 (<= (abs (- score gnus-summary-default-score))
2744 gnus-summary-zcore-fuzz))
2746 (if (< score gnus-summary-default-score)
2747 gnus-score-below-mark gnus-score-over-mark))
2749 ;; Do visual highlighting.
2750 (when (gnus-visual-p 'summary-highlight 'highlight)
2751 (gnus-run-hooks 'gnus-summary-update-hook)))))
2753 (defvar gnus-tmp-new-adopts nil)
2755 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2756 "Return the number of articles in THREAD.
2757 This may be 0 in some cases -- if none of the articles in
2758 the thread are to be displayed."
2760 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2762 ((not (listp thread))
2764 ((and (consp thread) (cdr thread))
2767 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2770 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2773 (when (and level (zerop level) gnus-tmp-new-adopts)
2776 'gnus-summary-number-of-articles-in-thread
2777 gnus-tmp-new-adopts))))
2779 (if (> number 1) gnus-not-empty-thread-mark
2780 gnus-empty-thread-mark)
2783 (defun gnus-summary-set-local-parameters (group)
2784 "Go through the local params of GROUP and set all variable specs in that list."
2785 (let ((params (gnus-group-find-parameter group))
2788 (setq elem (car params)
2789 params (cdr params))
2790 (and (consp elem) ; Has to be a cons.
2791 (consp (cdr elem)) ; The cdr has to be a list.
2792 (symbolp (car elem)) ; Has to be a symbol in there.
2793 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2794 (ignore-errors ; So we set it.
2795 (make-local-variable (car elem))
2796 (set (car elem) (eval (nth 1 elem))))))))
2798 (defun gnus-summary-read-group (group &optional show-all no-article
2799 kill-buffer no-display backward
2801 "Start reading news in newsgroup GROUP.
2802 If SHOW-ALL is non-nil, already read articles are also listed.
2803 If NO-ARTICLE is non-nil, no article is selected initially.
2804 If NO-DISPLAY, don't generate a summary buffer."
2808 (let ((gnus-auto-select-next nil))
2809 (or (gnus-summary-read-group-1
2810 group show-all no-article
2811 kill-buffer no-display
2814 select-articles nil)))))
2815 (eq gnus-auto-select-next 'quietly))
2816 (set-buffer gnus-group-buffer)
2817 ;; The entry function called above goes to the next
2818 ;; group automatically, so we go two groups back
2819 ;; if we are searching for the previous group.
2821 (gnus-group-prev-unread-group 2))
2822 (if (not (equal group (gnus-group-group-name)))
2823 (setq group (gnus-group-group-name))
2827 (defun gnus-summary-read-group-1 (group show-all no-article
2828 kill-buffer no-display
2829 &optional select-articles)
2830 ;; Killed foreign groups can't be entered.
2831 (when (and (not (gnus-group-native-p group))
2832 (not (gnus-gethash group gnus-newsrc-hashtb)))
2833 (error "Dead non-native groups can't be entered"))
2834 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2835 (let* ((new-group (gnus-summary-setup-buffer group))
2836 (quit-config (gnus-group-quit-config group))
2837 (did-select (and new-group (gnus-select-newsgroup
2838 group show-all select-articles))))
2840 ;; This summary buffer exists already, so we just select it.
2842 (gnus-set-global-variables)
2844 (gnus-kill-or-deaden-summary kill-buffer))
2845 (gnus-configure-windows 'summary 'force)
2846 (gnus-set-mode-line 'summary)
2847 (gnus-summary-position-point)
2850 ;; We couldn't select this group.
2852 (when (and (eq major-mode 'gnus-summary-mode)
2853 (not (equal (current-buffer) kill-buffer)))
2854 (kill-buffer (current-buffer))
2855 (if (not quit-config)
2857 ;; Update the info -- marks might need to be removed,
2859 (gnus-summary-update-info)
2860 (set-buffer gnus-group-buffer)
2861 (gnus-group-jump-to-group group)
2862 (gnus-group-next-unread-group 1))
2863 (gnus-handle-ephemeral-exit quit-config)))
2864 (gnus-message 3 "Can't select group")
2866 ;; The user did a `C-g' while prompting for number of articles,
2867 ;; so we exit this group.
2868 ((eq did-select 'quit)
2869 (and (eq major-mode 'gnus-summary-mode)
2870 (not (equal (current-buffer) kill-buffer))
2871 (kill-buffer (current-buffer)))
2873 (gnus-kill-or-deaden-summary kill-buffer))
2874 (if (not quit-config)
2876 (set-buffer gnus-group-buffer)
2877 (gnus-group-jump-to-group group)
2878 (gnus-group-next-unread-group 1)
2879 (gnus-configure-windows 'group 'force))
2880 (gnus-handle-ephemeral-exit quit-config))
2881 ;; Finally signal the quit.
2883 ;; The group was successfully selected.
2885 (gnus-set-global-variables)
2886 ;; Save the active value in effect when the group was entered.
2887 (setq gnus-newsgroup-active
2889 (gnus-active gnus-newsgroup-name)))
2890 ;; You can change the summary buffer in some way with this hook.
2891 (gnus-run-hooks 'gnus-select-group-hook)
2892 ;; Set any local variables in the group parameters.
2893 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2894 (gnus-update-format-specifications
2895 nil 'summary 'summary-mode 'summary-dummy)
2896 (gnus-update-summary-mark-positions)
2897 ;; Do score processing.
2898 (when gnus-use-scoring
2899 (gnus-possibly-score-headers))
2900 ;; Check whether to fill in the gaps in the threads.
2901 (when gnus-build-sparse-threads
2902 (gnus-build-sparse-threads))
2903 ;; Find the initial limit.
2904 (if gnus-show-threads
2906 (let ((gnus-newsgroup-dormant nil))
2907 (gnus-summary-initial-limit show-all))
2908 (gnus-summary-initial-limit show-all))
2909 ;; When untreaded, all articles are always shown.
2910 (setq gnus-newsgroup-limit
2912 (lambda (header) (mail-header-number header))
2913 gnus-newsgroup-headers)))
2914 ;; Generate the summary buffer.
2916 (gnus-summary-prepare))
2917 (when gnus-use-trees
2918 (gnus-tree-open group)
2919 (setq gnus-summary-highlight-line-function
2920 'gnus-tree-highlight-article))
2921 ;; If the summary buffer is empty, but there are some low-scored
2922 ;; articles or some excluded dormants, we include these in the
2924 (when (and (zerop (buffer-size))
2926 (cond (gnus-newsgroup-dormant
2927 (gnus-summary-limit-include-dormant))
2928 ((and gnus-newsgroup-scored show-all)
2929 (gnus-summary-limit-include-expunged t))))
2930 ;; Function `gnus-apply-kill-file' must be called in this hook.
2931 (gnus-run-hooks 'gnus-apply-kill-hook)
2932 (if (and (zerop (buffer-size))
2935 ;; This newsgroup is empty.
2936 (gnus-summary-catchup-and-exit nil t)
2937 (gnus-message 6 "No unread news")
2939 (gnus-kill-or-deaden-summary kill-buffer))
2940 ;; Return nil from this function.
2942 ;; Hide conversation thread subtrees. We cannot do this in
2943 ;; gnus-summary-prepare-hook since kill processing may not
2944 ;; work with hidden articles.
2945 (and gnus-show-threads
2946 gnus-thread-hide-subtree
2947 (gnus-summary-hide-all-threads))
2949 (gnus-kill-or-deaden-summary kill-buffer))
2950 ;; Show first unread article if requested.
2951 (if (and (not no-article)
2953 gnus-newsgroup-unreads
2954 gnus-auto-select-first)
2956 (gnus-configure-windows 'summary)
2958 ((eq gnus-auto-select-first 'best)
2959 (gnus-summary-best-unread-article))
2960 ((eq gnus-auto-select-first t)
2961 (gnus-summary-first-unread-article))
2962 ((gnus-functionp gnus-auto-select-first)
2963 (funcall gnus-auto-select-first))))
2964 ;; Don't select any articles, just move point to the first
2965 ;; article in the group.
2966 (goto-char (point-min))
2967 (gnus-summary-position-point)
2968 (gnus-configure-windows 'summary 'force)
2969 (gnus-set-mode-line 'summary))
2970 (when (get-buffer-window gnus-group-buffer t)
2971 ;; Gotta use windows, because recenter does weird stuff if
2972 ;; the current buffer ain't the displayed window.
2973 (let ((owin (selected-window)))
2974 (select-window (get-buffer-window gnus-group-buffer t))
2975 (when (gnus-group-goto-group group)
2977 (select-window owin)))
2978 ;; Mark this buffer as "prepared".
2979 (setq gnus-newsgroup-prepared t)
2980 (gnus-run-hooks 'gnus-summary-prepared-hook)
2983 (defun gnus-summary-prepare ()
2984 "Generate the summary buffer."
2986 (let ((buffer-read-only nil))
2988 (setq gnus-newsgroup-data nil
2989 gnus-newsgroup-data-reverse nil)
2990 (gnus-run-hooks 'gnus-summary-generate-hook)
2991 ;; Generate the buffer, either with threads or without.
2992 (when gnus-newsgroup-headers
2993 (gnus-summary-prepare-threads
2994 (if gnus-show-threads
2995 (gnus-sort-gathered-threads
2996 (funcall gnus-summary-thread-gathering-function
2998 (gnus-cut-threads (gnus-make-threads)))))
2999 ;; Unthreaded display.
3000 (gnus-sort-articles gnus-newsgroup-headers))))
3001 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3002 ;; Call hooks for modifying summary buffer.
3003 (goto-char (point-min))
3004 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3006 (defsubst gnus-general-simplify-subject (subject)
3007 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3010 ;; Truncate the subject.
3011 (gnus-simplify-subject-functions
3012 (gnus-map-function gnus-simplify-subject-functions subject))
3013 ((numberp gnus-summary-gather-subject-limit)
3014 (setq subject (gnus-simplify-subject-re subject))
3015 (if (> (length subject) gnus-summary-gather-subject-limit)
3016 (substring subject 0 gnus-summary-gather-subject-limit)
3018 ;; Fuzzily simplify it.
3019 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3020 (gnus-simplify-subject-fuzzy subject))
3021 ;; Just remove the leading "Re:".
3023 (gnus-simplify-subject-re subject))))
3025 (if (and gnus-summary-gather-exclude-subject
3026 (string-match gnus-summary-gather-exclude-subject subject))
3027 nil ; This article shouldn't be gathered
3030 (defun gnus-summary-simplify-subject-query ()
3031 "Query where the respool algorithm would put this article."
3033 (gnus-summary-select-article)
3034 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3036 (defun gnus-gather-threads-by-subject (threads)
3037 "Gather threads by looking at Subject headers."
3038 (if (not gnus-summary-make-false-root)
3040 (let ((hashtb (gnus-make-hashtable 1024))
3043 subject hthread whole-subject)
3045 (setq subject (gnus-general-simplify-subject
3046 (setq whole-subject (mail-header-subject
3049 (if (setq hthread (gnus-gethash subject hashtb))
3051 ;; We enter a dummy root into the thread, if we
3052 ;; haven't done that already.
3053 (unless (stringp (caar hthread))
3054 (setcar hthread (list whole-subject (car hthread))))
3055 ;; We add this new gathered thread to this gathered
3057 (setcdr (car hthread)
3058 (nconc (cdar hthread) (list (car threads))))
3059 ;; Remove it from the list of threads.
3060 (setcdr prev (cdr threads))
3061 (setq threads prev))
3062 ;; Enter this thread into the hash table.
3063 (gnus-sethash subject threads hashtb)))
3065 (setq threads (cdr threads)))
3068 (defun gnus-gather-threads-by-references (threads)
3069 "Gather threads by looking at References headers."
3070 (let ((idhashtb (gnus-make-hashtable 1024))
3071 (thhashtb (gnus-make-hashtable 1024))
3074 ids references id gthread gid entered ref)
3076 (when (setq references (mail-header-references (caar threads)))
3077 (setq id (mail-header-id (caar threads))
3078 ids (gnus-split-references references)
3080 (while (setq ref (pop ids))
3081 (setq ids (delete ref ids))
3082 (if (not (setq gid (gnus-gethash ref idhashtb)))
3084 (gnus-sethash ref id idhashtb)
3085 (gnus-sethash id threads thhashtb))
3086 (setq gthread (gnus-gethash gid thhashtb))
3088 ;; We enter a dummy root into the thread, if we
3089 ;; haven't done that already.
3090 (unless (stringp (caar gthread))
3091 (setcar gthread (list (mail-header-subject (caar gthread))
3093 ;; We add this new gathered thread to this gathered
3095 (setcdr (car gthread)
3096 (nconc (cdar gthread) (list (car threads)))))
3097 ;; Add it into the thread hash table.
3098 (gnus-sethash id gthread thhashtb)
3100 ;; Remove it from the list of threads.
3101 (setcdr prev (cdr threads))
3102 (setq threads prev))))
3104 (setq threads (cdr threads)))
3107 (defun gnus-sort-gathered-threads (threads)
3108 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3109 (let ((result threads))
3111 (when (stringp (caar threads))
3112 (setcdr (car threads)
3113 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3114 (setq threads (cdr threads)))
3117 (defun gnus-thread-loop-p (root thread)
3118 "Say whether ROOT is in THREAD."
3119 (let ((stack (list thread))
3122 (while (setq thread (pop stack))
3123 (setq th (cdr thread))
3125 (not (eq (caar th) root)))
3128 ;; We have found a loop.
3130 (setcdr thread (delq (car th) (cdr thread)))
3131 (if (boundp (setq ref-dep (intern "none"
3132 gnus-newsgroup-dependencies)))
3133 (setcdr (symbol-value ref-dep)
3134 (nconc (cdr (symbol-value ref-dep))
3136 (set ref-dep (list nil (car th))))
3139 ;; Push all the subthreads onto the stack.
3140 (push (cdr thread) stack)))
3143 (defun gnus-make-threads ()
3144 "Go through the dependency hashtb and find the roots. Return all threads."
3146 (while (catch 'infloop
3149 ;; Deal with self-referencing References loops.
3150 (when (and (car (symbol-value refs))
3157 (car (symbol-value refs)) thread))
3158 (cdr (symbol-value refs)))))))
3161 (unless (car (symbol-value refs))
3162 ;; These threads do not refer back to any other articles,
3163 ;; so they're roots.
3164 (setq threads (append (cdr (symbol-value refs)) threads))))
3165 gnus-newsgroup-dependencies)))
3168 ;; Build the thread tree.
3169 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3170 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3172 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3173 if it was already present.
3175 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3176 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3177 Message-IDs will be renamed be renamed to a unique Message-ID before
3180 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3181 (let* ((id (mail-header-id header))
3182 (id-dep (and id (intern id dependencies)))
3183 ref ref-dep ref-header)
3184 ;; Enter this `header' in the `dependencies' table.
3188 ;; The first two cases do the normal part: enter a new `header'
3189 ;; in the `dependencies' table.
3190 ((not (boundp id-dep))
3191 (set id-dep (list header)))
3192 ((null (car (symbol-value id-dep)))
3193 (setcar (symbol-value id-dep) header))
3195 ;; From here the `header' was already present in the
3196 ;; `dependencies' table.
3198 ;; Overrides an existing entry;
3199 ;; just set the header part of the entry.
3200 (setcar (symbol-value id-dep) header))
3202 ;; Renames the existing `header' to a unique Message-ID.
3203 ((not gnus-summary-ignore-duplicates)
3204 ;; An article with this Message-ID has already been seen.
3205 ;; We rename the Message-ID.
3206 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3208 (mail-header-set-id header id))
3210 ;; The last case ignores an existing entry, except it adds any
3211 ;; additional Xrefs (in case the two articles came from different
3213 ;; Also sets `header' to `nil' meaning that the `dependencies'
3214 ;; table was *not* modified.
3216 (mail-header-set-xref
3217 (car (symbol-value id-dep))
3218 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3220 (or (mail-header-xref header) "")))
3224 ;; First check if that we are not creating a References loop.
3225 (setq ref (gnus-parent-id (mail-header-references header)))
3227 (setq ref-dep (intern-soft ref dependencies))
3229 (setq ref-header (car (symbol-value ref-dep))))
3230 (if (string= id ref)
3231 ;; Yuk! This is a reference loop. Make the article be a
3234 (mail-header-set-references (car (symbol-value id-dep)) "none")
3236 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3237 (setq ref (gnus-parent-id (mail-header-references header)))
3238 (setq ref-dep (intern (or ref "none") dependencies))
3239 (if (boundp ref-dep)
3240 (setcdr (symbol-value ref-dep)
3241 (nconc (cdr (symbol-value ref-dep))
3242 (list (symbol-value id-dep))))
3243 (set ref-dep (list nil (symbol-value id-dep)))))
3246 (defun gnus-build-sparse-threads ()
3247 (let ((headers gnus-newsgroup-headers)
3248 (mail-parse-charset gnus-newsgroup-charset)
3249 (gnus-summary-ignore-duplicates t)
3250 header references generation relations
3251 subject child end new-child date)
3252 ;; First we create an alist of generations/relations, where
3253 ;; generations is how much we trust the relation, and the relation
3255 (gnus-message 7 "Making sparse threads...")
3257 (nnheader-set-temp-buffer " *gnus sparse threads*")
3258 (while (setq header (pop headers))
3259 (when (and (setq references (mail-header-references header))
3260 (not (string= references "")))
3262 (setq child (mail-header-id header)
3263 subject (mail-header-subject header)
3264 date (mail-header-date header)
3266 (while (search-backward ">" nil t)
3267 (setq end (1+ (point)))
3268 (when (search-backward "<" nil t)
3269 (setq new-child (buffer-substring (point) end))
3270 (push (list (incf generation)
3271 child (setq child new-child)
3275 (push (list (1+ generation) child nil subject) relations))
3277 (kill-buffer (current-buffer)))
3278 ;; Sort over trustworthiness.
3281 (when (gnus-dependencies-add-header
3282 (make-full-mail-header
3283 gnus-reffed-article-number
3284 (nth 3 relation) "" (or (nth 4 relation) "")
3286 (or (nth 2 relation) "") 0 0 "")
3287 gnus-newsgroup-dependencies nil)
3288 (push gnus-reffed-article-number gnus-newsgroup-limit)
3289 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3290 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3291 gnus-newsgroup-reads)
3292 (decf gnus-reffed-article-number)))
3293 (sort relations 'car-less-than-car))
3294 (gnus-message 7 "Making sparse threads...done")))
3296 (defun gnus-build-old-threads ()
3297 ;; Look at all the articles that refer back to old articles, and
3298 ;; fetch the headers for the articles that aren't there. This will
3299 ;; build complete threads - if the roots haven't been expired by the
3301 (let ((mail-parse-charset gnus-newsgroup-charset)
3305 (when (not (car (symbol-value refs)))
3306 (setq heads (cdr (symbol-value refs)))
3308 (if (memq (mail-header-number (caar heads))
3309 gnus-newsgroup-dormant)
3310 (setq heads (cdr heads))
3311 (setq id (symbol-name refs))
3312 (while (and (setq id (gnus-build-get-header id))
3313 (not (car (gnus-id-to-thread id)))))
3314 (setq heads nil)))))
3315 gnus-newsgroup-dependencies)))
3317 ;; This function has to be called with point after the article number
3318 ;; on the beginning of the line.
3319 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3320 (let ((eol (gnus-point-at-eol))
3321 (buffer (current-buffer))
3324 ;; overview: [num subject from date id refs chars lines misc]
3327 (narrow-to-region (point) eol)
3332 (make-full-mail-header
3334 (funcall gnus-decode-encoded-word-function
3335 (nnheader-nov-field)) ; subject
3336 (funcall gnus-decode-encoded-word-function
3337 (nnheader-nov-field)) ; from
3338 (nnheader-nov-field) ; date
3339 (nnheader-nov-read-message-id) ; id
3340 (nnheader-nov-field) ; refs
3341 (nnheader-nov-read-integer) ; chars
3342 (nnheader-nov-read-integer) ; lines
3344 (if (looking-at "Xref: ")
3345 (goto-char (match-end 0)))
3346 (nnheader-nov-field)) ; Xref
3347 (nnheader-nov-parse-extra)))) ; extra
3351 (when gnus-alter-header-function
3352 (funcall gnus-alter-header-function header))
3353 (gnus-dependencies-add-header header dependencies force-new)))
3355 (defun gnus-build-get-header (id)
3356 "Look through the buffer of NOV lines and find the header to ID.
3357 Enter this line into the dependencies hash table, and return
3358 the id of the parent article (if any)."
3359 (let ((deps gnus-newsgroup-dependencies)
3363 (set-buffer nntp-server-buffer)
3364 (let ((case-fold-search nil))
3365 (goto-char (point-min))
3366 (while (and (not found)
3367 (search-forward id nil t))
3369 (setq found (looking-at
3370 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3371 (regexp-quote id))))
3372 (or found (beginning-of-line 2)))
3376 (setq header (gnus-nov-parse-line
3377 (read (current-buffer)) deps))
3378 (gnus-parent-id (mail-header-references header))))))
3380 (let ((number (mail-header-number header)))
3381 (push number gnus-newsgroup-limit)
3382 (push header gnus-newsgroup-headers)
3383 (if (memq number gnus-newsgroup-unselected)
3385 (push number gnus-newsgroup-unreads)
3386 (setq gnus-newsgroup-unselected
3387 (delq number gnus-newsgroup-unselected)))
3388 (push number gnus-newsgroup-ancient)))))))
3390 (defun gnus-build-all-threads ()
3391 "Read all the headers."
3392 (let ((gnus-summary-ignore-duplicates t)
3393 (mail-parse-charset gnus-newsgroup-charset)
3394 (dependencies gnus-newsgroup-dependencies)
3397 (set-buffer nntp-server-buffer)
3398 (let ((case-fold-search nil))
3399 (goto-char (point-min))
3402 (setq article (read (current-buffer))
3403 header (gnus-nov-parse-line article dependencies)))
3406 (set-buffer gnus-summary-buffer)
3407 (push header gnus-newsgroup-headers)
3408 (if (memq (setq article (mail-header-number header))
3409 gnus-newsgroup-unselected)
3411 (push article gnus-newsgroup-unreads)
3412 (setq gnus-newsgroup-unselected
3413 (delq article gnus-newsgroup-unselected)))
3414 (push article gnus-newsgroup-ancient)))
3415 (forward-line 1)))))))
3417 (defun gnus-summary-update-article-line (article header)
3418 "Update the line for ARTICLE using HEADERS."
3419 (let* ((id (mail-header-id header))
3420 (thread (gnus-id-to-thread id)))
3422 (error "Article in no thread"))
3423 ;; Update the thread.
3424 (setcar thread header)
3425 (gnus-summary-goto-subject article)
3426 (let* ((datal (gnus-data-find-list article))
3428 (length (when (cdr datal)
3429 (- (gnus-data-pos data)
3430 (gnus-data-pos (cadr datal)))))
3431 (buffer-read-only nil)
3432 (level (gnus-summary-thread-level)))
3434 (gnus-summary-insert-line
3435 header level nil (gnus-article-mark article)
3436 (memq article gnus-newsgroup-replied)
3437 (memq article gnus-newsgroup-expirable)
3438 ;; Only insert the Subject string when it's different
3439 ;; from the previous Subject string.
3444 (mail-header-subject
3447 (gnus-data-find-list
3449 (gnus-data-list t)))))
3450 ;; Error on the side of excessive subjects.
3452 (mail-header-subject header)))
3454 (mail-header-subject header))
3455 nil (cdr (assq article gnus-newsgroup-scored))
3456 (memq article gnus-newsgroup-processable))
3458 (gnus-data-update-list
3459 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3461 (defun gnus-summary-update-article (article &optional iheader)
3462 "Update ARTICLE in the summary buffer."
3463 (set-buffer gnus-summary-buffer)
3464 (let* ((header (gnus-summary-article-header article))
3465 (id (mail-header-id header))
3466 (data (gnus-data-find article))
3467 (thread (gnus-id-to-thread id))
3468 (references (mail-header-references header))
3472 (when (and references
3473 (not (equal "" references)))
3476 (buffer-read-only nil)
3482 (delq thread parent)))
3483 (if (gnus-summary-insert-subject id header)
3484 ;; Set the (possibly) new article number in the data structure.
3485 (gnus-data-set-number data (gnus-id-to-article id))
3489 (defun gnus-rebuild-thread (id &optional line)
3490 "Rebuild the thread containing ID.
3491 If LINE, insert the rebuilt thread starting on line LINE."
3492 (let ((buffer-read-only nil)
3493 old-pos current thread data)
3494 (if (not gnus-show-threads)
3495 (setq thread (list (car (gnus-id-to-thread id))))
3496 ;; Get the thread this article is part of.
3497 (setq thread (gnus-remove-thread id)))
3498 (setq old-pos (gnus-point-at-bol))
3499 (setq current (save-excursion
3500 (and (zerop (forward-line -1))
3501 (gnus-summary-article-number))))
3502 ;; If this is a gathered thread, we have to go some re-gathering.
3503 (when (stringp (car thread))
3504 (let ((subject (car thread))
3506 (setq thread (cdr thread))
3508 (unless (memq (setq thr (gnus-id-to-thread
3510 (mail-header-id (caar thread)))))
3513 (setq thread (cdr thread)))
3514 ;; We now have all (unique) roots.
3515 (if (= (length roots) 1)
3516 ;; All the loose roots are now one solid root.
3517 (setq thread (car roots))
3518 (setq thread (cons subject (gnus-sort-threads roots))))))
3520 ;; We then insert this thread into the summary buffer.
3522 (goto-char (point-min))
3523 (forward-line (1- line)))
3524 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3525 (if gnus-show-threads
3526 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3527 (gnus-summary-prepare-unthreaded thread))
3528 (setq data (nreverse gnus-newsgroup-data))
3529 (setq threads gnus-newsgroup-threads))
3530 ;; We splice the new data into the data structure.
3531 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3532 ;;!!! then we want to insert at the beginning of the buffer.
3533 ;;!!! That happens to be true with Gnus now, but that may
3534 ;;!!! change in the future. Perhaps.
3535 (gnus-data-enter-list
3536 (if line nil current) data (- (point) old-pos))
3537 (setq gnus-newsgroup-threads
3538 (nconc threads gnus-newsgroup-threads))
3539 (gnus-data-compute-positions))))
3541 (defun gnus-number-to-header (number)
3542 "Return the header for article NUMBER."
3543 (let ((headers gnus-newsgroup-headers))
3545 (not (= number (mail-header-number (car headers)))))
3550 (defun gnus-parent-headers (in-headers &optional generation)
3551 "Return the headers of the GENERATIONeth parent of HEADERS."
3553 (setq generation 1))
3555 (headers in-headers)
3558 (not (zerop generation))
3559 (setq references (mail-header-references headers)))
3560 (setq headers (if (and references
3561 (setq parent (gnus-parent-id references)))
3562 (car (gnus-id-to-thread parent))
3565 (and (not (eq headers in-headers))
3568 (defun gnus-id-to-thread (id)
3569 "Return the (sub-)thread where ID appears."
3570 (gnus-gethash id gnus-newsgroup-dependencies))
3572 (defun gnus-id-to-article (id)
3573 "Return the article number of ID."
3574 (let ((thread (gnus-id-to-thread id)))
3577 (mail-header-number (car thread)))))
3579 (defun gnus-id-to-header (id)
3580 "Return the article headers of ID."
3581 (car (gnus-id-to-thread id)))
3583 (defun gnus-article-displayed-root-p (article)
3584 "Say whether ARTICLE is a root(ish) article."
3585 (let ((level (gnus-summary-thread-level article))
3586 (refs (mail-header-references (gnus-summary-article-header article)))
3592 ((null (gnus-parent-id refs)) t)
3594 (null (setq particle (gnus-id-to-article
3595 (gnus-parent-id refs))))
3596 (null (gnus-summary-thread-level particle)))))))
3598 (defun gnus-root-id (id)
3599 "Return the id of the root of the thread where ID appears."
3601 (while (and id (setq prev (car (gnus-id-to-thread id))))
3603 id (gnus-parent-id (mail-header-references prev))))
3606 (defun gnus-articles-in-thread (thread)
3607 "Return the list of articles in THREAD."
3608 (cons (mail-header-number (car thread))
3609 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3611 (defun gnus-remove-thread (id &optional dont-remove)
3612 "Remove the thread that has ID in it."
3613 (let (headers thread last-id)
3614 ;; First go up in this thread until we find the root.
3615 (setq last-id (gnus-root-id id)
3616 headers (message-flatten-list (gnus-id-to-thread last-id)))
3617 ;; We have now found the real root of this thread. It might have
3618 ;; been gathered into some loose thread, so we have to search
3619 ;; through the threads to find the thread we wanted.
3620 (let ((threads gnus-newsgroup-threads)
3623 (setq sub (car threads))
3624 (if (stringp (car sub))
3625 ;; This is a gathered thread, so we look at the roots
3626 ;; below it to find whether this article is in this
3629 (setq sub (cdr sub))
3631 (when (member (caar sub) headers)
3632 (setq thread (car threads)
3635 (setq sub (cdr sub))))
3636 ;; It's an ordinary thread, so we check it.
3637 (when (eq (car sub) (car headers))
3640 (setq threads (cdr threads)))
3641 ;; If this article is in no thread, then it's a root.
3644 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3645 (setq thread (gnus-id-to-thread last-id)))
3648 thread ; We return this thread.
3650 (if (stringp (car thread))
3652 ;; If we use dummy roots, then we have to remove the
3653 ;; dummy root as well.
3654 (when (eq gnus-summary-make-false-root 'dummy)
3655 ;; We go to the dummy root by going to
3656 ;; the first sub-"thread", and then one line up.
3657 (gnus-summary-goto-article
3658 (mail-header-number (caadr thread)))
3661 (gnus-data-compute-positions))
3662 (setq thread (cdr thread))
3664 (gnus-remove-thread-1 (car thread))
3665 (setq thread (cdr thread))))
3666 (gnus-remove-thread-1 thread))))))))
3668 (defun gnus-remove-thread-1 (thread)
3669 "Remove the thread THREAD recursively."
3670 (let ((number (mail-header-number (pop thread)))
3672 (setq thread (reverse thread))
3674 (gnus-remove-thread-1 (pop thread)))
3675 (when (setq d (gnus-data-find number))
3676 (goto-char (gnus-data-pos d))
3677 (gnus-summary-show-thread)
3680 (- (gnus-point-at-bol)
3682 (1+ (gnus-point-at-eol))
3683 (gnus-delete-line)))))))
3685 (defun gnus-sort-threads-1 (threads func)
3686 (sort (mapcar (lambda (thread)
3689 (gnus-sort-threads-1 (cdr thread) func))))
3692 (defun gnus-sort-threads (threads)
3694 (if (not gnus-thread-sort-functions)
3696 (gnus-message 8 "Sorting threads...")
3698 (gnus-sort-threads-1
3700 (gnus-make-sort-function gnus-thread-sort-functions))
3701 (gnus-message 8 "Sorting threads...done"))))
3703 (defun gnus-sort-articles (articles)
3705 (when gnus-article-sort-functions
3706 (gnus-message 7 "Sorting articles...")
3708 (setq gnus-newsgroup-headers
3709 (sort articles (gnus-make-sort-function
3710 gnus-article-sort-functions)))
3711 (gnus-message 7 "Sorting articles...done"))))
3713 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3714 (defmacro gnus-thread-header (thread)
3715 "Return header of first article in THREAD.
3716 Note that THREAD must never, ever be anything else than a variable -
3717 using some other form will lead to serious barfage."
3718 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3719 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3720 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3723 (defsubst gnus-article-sort-by-number (h1 h2)
3724 "Sort articles by article number."
3725 (< (mail-header-number h1)
3726 (mail-header-number h2)))
3728 (defun gnus-thread-sort-by-number (h1 h2)
3729 "Sort threads by root article number."
3730 (gnus-article-sort-by-number
3731 (gnus-thread-header h1) (gnus-thread-header h2)))
3733 (defsubst gnus-article-sort-by-lines (h1 h2)
3734 "Sort articles by article Lines header."
3735 (< (mail-header-lines h1)
3736 (mail-header-lines h2)))
3738 (defun gnus-thread-sort-by-lines (h1 h2)
3739 "Sort threads by root article Lines header."
3740 (gnus-article-sort-by-lines
3741 (gnus-thread-header h1) (gnus-thread-header h2)))
3743 (defsubst gnus-article-sort-by-chars (h1 h2)
3744 "Sort articles by octet length."
3745 (< (mail-header-chars h1)
3746 (mail-header-chars h2)))
3748 (defun gnus-thread-sort-by-chars (h1 h2)
3749 "Sort threads by root article octet length."
3750 (gnus-article-sort-by-chars
3751 (gnus-thread-header h1) (gnus-thread-header h2)))
3753 (defsubst gnus-article-sort-by-author (h1 h2)
3754 "Sort articles by root author."
3756 (let ((extract (funcall
3757 gnus-extract-address-components
3758 (mail-header-from h1))))
3759 (or (car extract) (cadr extract) ""))
3760 (let ((extract (funcall
3761 gnus-extract-address-components
3762 (mail-header-from h2))))
3763 (or (car extract) (cadr extract) ""))))
3765 (defun gnus-thread-sort-by-author (h1 h2)
3766 "Sort threads by root author."
3767 (gnus-article-sort-by-author
3768 (gnus-thread-header h1) (gnus-thread-header h2)))
3770 (defsubst gnus-article-sort-by-subject (h1 h2)
3771 "Sort articles by root subject."
3773 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3774 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3776 (defun gnus-thread-sort-by-subject (h1 h2)
3777 "Sort threads by root subject."
3778 (gnus-article-sort-by-subject
3779 (gnus-thread-header h1) (gnus-thread-header h2)))
3781 (defsubst gnus-article-sort-by-date (h1 h2)
3782 "Sort articles by root article date."
3784 (gnus-date-get-time (mail-header-date h1))
3785 (gnus-date-get-time (mail-header-date h2))))
3787 (defun gnus-thread-sort-by-date (h1 h2)
3788 "Sort threads by root article date."
3789 (gnus-article-sort-by-date
3790 (gnus-thread-header h1) (gnus-thread-header h2)))
3792 (defsubst gnus-article-sort-by-score (h1 h2)
3793 "Sort articles by root article score.
3794 Unscored articles will be counted as having a score of zero."
3795 (> (or (cdr (assq (mail-header-number h1)
3796 gnus-newsgroup-scored))
3797 gnus-summary-default-score 0)
3798 (or (cdr (assq (mail-header-number h2)
3799 gnus-newsgroup-scored))
3800 gnus-summary-default-score 0)))
3802 (defun gnus-thread-sort-by-score (h1 h2)
3803 "Sort threads by root article score."
3804 (gnus-article-sort-by-score
3805 (gnus-thread-header h1) (gnus-thread-header h2)))
3807 (defun gnus-thread-sort-by-total-score (h1 h2)
3808 "Sort threads by the sum of all scores in the thread.
3809 Unscored articles will be counted as having a score of zero."
3810 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3812 (defun gnus-thread-total-score (thread)
3813 ;; This function find the total score of THREAD.
3814 (cond ((null thread)
3817 (if (stringp (car thread))
3818 (apply gnus-thread-score-function 0
3819 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3820 (gnus-thread-total-score-1 thread)))
3822 (gnus-thread-total-score-1 (list thread)))))
3824 (defun gnus-thread-total-score-1 (root)
3825 ;; This function find the total score of the thread below ROOT.
3826 (setq root (car root))
3827 (apply gnus-thread-score-function
3829 (mapcar 'gnus-thread-total-score
3830 (cdr (gnus-id-to-thread (mail-header-id root))))
3831 (when (> (mail-header-number root) 0)
3832 (list (or (cdr (assq (mail-header-number root)
3833 gnus-newsgroup-scored))
3834 gnus-summary-default-score 0))))
3835 (list gnus-summary-default-score)
3838 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3839 (defvar gnus-tmp-prev-subject nil)
3840 (defvar gnus-tmp-false-parent nil)
3841 (defvar gnus-tmp-root-expunged nil)
3842 (defvar gnus-tmp-dummy-line nil)
3844 (defvar gnus-tmp-header)
3845 (defun gnus-extra-header (type &optional header)
3846 "Return the extra header of TYPE."
3847 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3850 (defun gnus-summary-prepare-threads (threads)
3851 "Prepare summary buffer from THREADS and indentation LEVEL.
3852 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3853 or a straight list of headers."
3854 (gnus-message 7 "Generating summary...")
3856 (setq gnus-newsgroup-threads threads)
3859 (let ((gnus-tmp-level 0)
3860 (default-score (or gnus-summary-default-score 0))
3861 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3862 thread number subject stack state gnus-tmp-gathered beg-match
3863 new-roots gnus-tmp-new-adopts thread-end
3864 gnus-tmp-header gnus-tmp-unread
3865 gnus-tmp-replied gnus-tmp-subject-or-nil
3866 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3867 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3868 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3870 (setq gnus-tmp-prev-subject nil)
3872 (if (vectorp (car threads))
3873 ;; If this is a straight (sic) list of headers, then a
3874 ;; threaded summary display isn't required, so we just create
3875 ;; an unthreaded one.
3876 (gnus-summary-prepare-unthreaded threads)
3878 ;; Do the threaded display.
3880 (while (or threads stack gnus-tmp-new-adopts new-roots)
3882 (if (and (= gnus-tmp-level 0)
3885 (not gnus-tmp-false-parent)
3886 (or gnus-tmp-new-adopts new-roots))
3887 (if gnus-tmp-new-adopts
3888 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3889 thread (list (car gnus-tmp-new-adopts))
3890 gnus-tmp-header (caar thread)
3891 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3893 (setq thread (list (car new-roots))
3894 gnus-tmp-header (caar thread)
3895 new-roots (cdr new-roots))))
3898 ;; If there are some threads, we do them before the
3899 ;; threads on the stack.
3900 (setq thread threads
3901 gnus-tmp-header (caar thread))
3902 ;; There were no current threads, so we pop something off
3904 (setq state (car stack)
3905 gnus-tmp-level (car state)
3908 gnus-tmp-header (caar thread))))
3910 (setq gnus-tmp-false-parent nil)
3911 (setq gnus-tmp-root-expunged nil)
3912 (setq thread-end nil)
3914 (if (stringp gnus-tmp-header)
3915 ;; The header is a dummy root.
3917 ((eq gnus-summary-make-false-root 'adopt)
3918 ;; We let the first article adopt the rest.
3919 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3921 (setq gnus-tmp-gathered
3923 (lambda (h) (mail-header-number (car h)))
3926 (setq thread (cons (list (caar thread)
3929 (setq gnus-tmp-level -1
3930 gnus-tmp-false-parent t))
3931 ((eq gnus-summary-make-false-root 'empty)
3932 ;; We print adopted articles with empty subject fields.
3933 (setq gnus-tmp-gathered
3935 (lambda (h) (mail-header-number (car h)))
3938 (setq gnus-tmp-level -1))
3939 ((eq gnus-summary-make-false-root 'dummy)
3940 ;; We remember that we probably want to output a dummy
3942 (setq gnus-tmp-dummy-line gnus-tmp-header)
3943 (setq gnus-tmp-prev-subject gnus-tmp-header))
3945 ;; We do not make a root for the gathered
3946 ;; sub-threads at all.
3947 (setq gnus-tmp-level -1)))
3949 (setq number (mail-header-number gnus-tmp-header)
3950 subject (mail-header-subject gnus-tmp-header))
3953 ;; If the thread has changed subject, we might want to make
3954 ;; this subthread into a root.
3955 ((and (null gnus-thread-ignore-subject)
3956 (not (zerop gnus-tmp-level))
3957 gnus-tmp-prev-subject
3959 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3960 (setq new-roots (nconc new-roots (list (car thread)))
3962 gnus-tmp-header nil))
3963 ;; If the article lies outside the current limit,
3964 ;; then we do not display it.
3965 ((not (memq number gnus-newsgroup-limit))
3966 (setq gnus-tmp-gathered
3968 (lambda (h) (mail-header-number (car h)))
3971 (setq gnus-tmp-new-adopts (if (cdar thread)
3972 (append gnus-tmp-new-adopts
3974 gnus-tmp-new-adopts)
3976 gnus-tmp-header nil)
3977 (when (zerop gnus-tmp-level)
3978 (setq gnus-tmp-root-expunged t)))
3979 ;; Perhaps this article is to be marked as read?
3980 ((and gnus-summary-mark-below
3981 (< (or (cdr (assq number gnus-newsgroup-scored))
3983 gnus-summary-mark-below)
3984 ;; Don't touch sparse articles.
3985 (not (gnus-summary-article-sparse-p number))
3986 (not (gnus-summary-article-ancient-p number)))
3987 (setq gnus-newsgroup-unreads
3988 (delq number gnus-newsgroup-unreads))
3989 (if gnus-newsgroup-auto-expire
3990 (push number gnus-newsgroup-expirable)
3991 (push (cons number gnus-low-score-mark)
3992 gnus-newsgroup-reads))))
3994 (when gnus-tmp-header
3995 ;; We may have an old dummy line to output before this
3997 (when (and gnus-tmp-dummy-line
4000 (mail-header-subject gnus-tmp-header)))
4001 (gnus-summary-insert-dummy-line
4002 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4003 (setq gnus-tmp-dummy-line nil))
4005 ;; Compute the mark.
4006 (setq gnus-tmp-unread (gnus-article-mark number))
4008 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4009 gnus-tmp-header gnus-tmp-level)
4010 gnus-newsgroup-data)
4012 ;; Actually insert the line.
4014 gnus-tmp-subject-or-nil
4016 ((and gnus-thread-ignore-subject
4017 gnus-tmp-prev-subject
4018 (not (inline (gnus-subject-equal
4019 gnus-tmp-prev-subject subject))))
4021 ((zerop gnus-tmp-level)
4022 (if (and (eq gnus-summary-make-false-root 'empty)
4023 (memq number gnus-tmp-gathered)
4024 gnus-tmp-prev-subject
4025 (inline (gnus-subject-equal
4026 gnus-tmp-prev-subject subject)))
4027 gnus-summary-same-subject
4029 (t gnus-summary-same-subject)))
4030 (if (and (eq gnus-summary-make-false-root 'adopt)
4031 (= gnus-tmp-level 1)
4032 (memq number gnus-tmp-gathered))
4033 (setq gnus-tmp-opening-bracket ?\<
4034 gnus-tmp-closing-bracket ?\>)
4035 (setq gnus-tmp-opening-bracket ?\[
4036 gnus-tmp-closing-bracket ?\]))
4038 gnus-tmp-indentation
4039 (aref gnus-thread-indent-array gnus-tmp-level)
4040 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4041 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4042 gnus-summary-default-score 0)
4044 (if (or (null gnus-summary-default-score)
4045 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4046 gnus-summary-zcore-fuzz))
4048 (if (< gnus-tmp-score gnus-summary-default-score)
4049 gnus-score-below-mark gnus-score-over-mark))
4051 (cond ((memq number gnus-newsgroup-processable)
4053 ((memq number gnus-newsgroup-cached)
4055 ((memq number gnus-newsgroup-replied)
4057 ((memq number gnus-newsgroup-saved)
4059 (t gnus-unread-mark))
4060 gnus-tmp-from (mail-header-from gnus-tmp-header)
4063 ((string-match "<[^>]+> *$" gnus-tmp-from)
4064 (setq beg-match (match-beginning 0))
4065 (or (and (string-match "^\".+\"" gnus-tmp-from)
4066 (substring gnus-tmp-from 1 (1- (match-end 0))))
4067 (substring gnus-tmp-from 0 beg-match)))
4068 ((string-match "(.+)" gnus-tmp-from)
4069 (substring gnus-tmp-from
4070 (1+ (match-beginning 0)) (1- (match-end 0))))
4072 (when (string= gnus-tmp-name "")
4073 (setq gnus-tmp-name gnus-tmp-from))
4074 (unless (numberp gnus-tmp-lines)
4075 (setq gnus-tmp-lines 0))
4076 (gnus-put-text-property
4078 (progn (eval gnus-summary-line-format-spec) (point))
4079 'gnus-number number)
4082 (gnus-run-hooks 'gnus-summary-update-hook)
4085 (setq gnus-tmp-prev-subject subject)))
4087 (when (nth 1 thread)
4088 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4089 (incf gnus-tmp-level)
4090 (setq threads (if thread-end nil (cdar thread)))
4092 (setq gnus-tmp-level 0)))))
4093 (gnus-message 7 "Generating summary...done"))
4095 (defun gnus-summary-prepare-unthreaded (headers)
4096 "Generate an unthreaded summary buffer based on HEADERS."
4097 (let (header number mark)
4102 ;; We may have to root out some bad articles...
4103 (when (memq (setq number (mail-header-number
4104 (setq header (pop headers))))
4105 gnus-newsgroup-limit)
4106 ;; Mark article as read when it has a low score.
4107 (when (and gnus-summary-mark-below
4108 (< (or (cdr (assq number gnus-newsgroup-scored))
4109 gnus-summary-default-score 0)
4110 gnus-summary-mark-below)
4111 (not (gnus-summary-article-ancient-p number)))
4112 (setq gnus-newsgroup-unreads
4113 (delq number gnus-newsgroup-unreads))
4114 (if gnus-newsgroup-auto-expire
4115 (push number gnus-newsgroup-expirable)
4116 (push (cons number gnus-low-score-mark)
4117 gnus-newsgroup-reads)))
4119 (setq mark (gnus-article-mark number))
4120 (push (gnus-data-make number mark (1+ (point)) header 0)
4121 gnus-newsgroup-data)
4122 (gnus-summary-insert-line
4124 mark (memq number gnus-newsgroup-replied)
4125 (memq number gnus-newsgroup-expirable)
4126 (mail-header-subject header) nil
4127 (cdr (assq number gnus-newsgroup-scored))
4128 (memq number gnus-newsgroup-processable))))))
4130 (defun gnus-summary-remove-list-identifiers ()
4131 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4132 (let ((regexp (if (stringp gnus-list-identifiers)
4133 gnus-list-identifiers
4134 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4135 (dolist (header gnus-newsgroup-headers)
4136 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4137 " *\\)\\)+\\(Re: +\\)?\\)")
4138 (mail-header-subject header))
4139 (mail-header-set-subject
4140 header (concat (substring (mail-header-subject header)
4141 0 (match-beginning 1))
4143 (match-string 3 (mail-header-subject header))
4144 (match-string 5 (mail-header-subject header)))
4145 (substring (mail-header-subject header)
4146 (match-end 1))))))))
4148 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4149 "Select newsgroup GROUP.
4150 If READ-ALL is non-nil, all articles in the group are selected.
4151 If SELECT-ARTICLES, only select those articles from GROUP."
4152 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4153 ;;!!! Dirty hack; should be removed.
4154 (gnus-summary-ignore-duplicates
4155 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4157 gnus-summary-ignore-duplicates))
4158 (info (nth 2 entry))
4159 articles fetched-articles cached)
4161 (unless (gnus-check-server
4162 (setq gnus-current-select-method
4163 (gnus-find-method-for-group group)))
4164 (error "Couldn't open server"))
4166 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4167 (gnus-activate-group group) ; Or we can activate it...
4168 (progn ; Or we bug out.
4169 (when (equal major-mode 'gnus-summary-mode)
4170 (kill-buffer (current-buffer)))
4171 (error "Couldn't request group %s: %s"
4172 group (gnus-status-message group))))
4174 (unless (gnus-request-group group t)
4175 (when (equal major-mode 'gnus-summary-mode)
4176 (kill-buffer (current-buffer)))
4177 (error "Couldn't request group %s: %s"
4178 group (gnus-status-message group)))
4180 (setq gnus-newsgroup-name group)
4181 (setq gnus-newsgroup-unselected nil)
4182 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4183 (gnus-summary-setup-default-charset)
4185 ;; Adjust and set lists of article marks.
4187 (gnus-adjust-marked-articles info))
4189 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4190 (when (gnus-virtual-group-p group)
4191 (setq cached gnus-newsgroup-cached))
4193 (setq gnus-newsgroup-unreads
4194 (gnus-set-difference
4195 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4196 gnus-newsgroup-dormant))
4198 (setq gnus-newsgroup-processable nil)
4200 (gnus-update-read-articles group gnus-newsgroup-unreads)
4202 (if (setq articles select-articles)
4203 (setq gnus-newsgroup-unselected
4204 (gnus-sorted-intersection
4205 gnus-newsgroup-unreads
4206 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4207 (setq articles (gnus-articles-to-read group read-all)))
4211 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4213 ((eq articles 0) nil)
4215 ;; Init the dependencies hash table.
4216 (setq gnus-newsgroup-dependencies
4217 (gnus-make-hashtable (length articles)))
4218 (gnus-set-global-variables)
4219 ;; Retrieve the headers and read them in.
4220 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4221 (setq gnus-newsgroup-headers
4223 (setq gnus-headers-retrieved-by
4224 (gnus-retrieve-headers
4225 articles gnus-newsgroup-name
4226 ;; We might want to fetch old headers, but
4227 ;; not if there is only 1 article.
4229 (not (eq gnus-fetch-old-headers 'some))
4230 (not (numberp gnus-fetch-old-headers)))
4231 (> (length articles) 1))
4232 gnus-fetch-old-headers))))
4233 (gnus-get-newsgroup-headers-xover
4234 articles nil nil gnus-newsgroup-name t)
4235 (gnus-get-newsgroup-headers)))
4236 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4238 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4240 (setq gnus-newsgroup-cached cached))
4242 ;; Suppress duplicates?
4243 (when gnus-suppress-duplicates
4244 (gnus-dup-suppress-articles))
4246 ;; Set the initial limit.
4247 (setq gnus-newsgroup-limit (copy-sequence articles))
4248 ;; Remove canceled articles from the list of unread articles.
4249 (setq gnus-newsgroup-unreads
4250 (gnus-set-sorted-intersection
4251 gnus-newsgroup-unreads
4252 (setq fetched-articles
4253 (mapcar (lambda (headers) (mail-header-number headers))
4254 gnus-newsgroup-headers))))
4255 ;; Removed marked articles that do not exist.
4256 (gnus-update-missing-marks
4257 (gnus-sorted-complement fetched-articles articles))
4258 ;; We might want to build some more threads first.
4259 (when (and gnus-fetch-old-headers
4260 (eq gnus-headers-retrieved-by 'nov))
4261 (if (eq gnus-fetch-old-headers 'invisible)
4262 (gnus-build-all-threads)
4263 (gnus-build-old-threads)))
4264 ;; Let the Gnus agent mark articles as read.
4266 (gnus-agent-get-undownloaded-list))
4267 ;; Remove list identifiers from subject
4268 (when gnus-list-identifiers
4269 (gnus-summary-remove-list-identifiers))
4270 ;; Check whether auto-expire is to be done in this group.
4271 (setq gnus-newsgroup-auto-expire
4272 (gnus-group-auto-expirable-p group))
4273 ;; Set up the article buffer now, if necessary.
4274 (unless gnus-single-article-buffer
4275 (gnus-article-setup-buffer))
4276 ;; First and last article in this newsgroup.
4277 (when gnus-newsgroup-headers
4278 (setq gnus-newsgroup-begin
4279 (mail-header-number (car gnus-newsgroup-headers))
4282 (gnus-last-element gnus-newsgroup-headers))))
4283 ;; GROUP is successfully selected.
4284 (or gnus-newsgroup-headers t)))))
4286 (defun gnus-articles-to-read (group &optional read-all)
4287 "Find out what articles the user wants to read."
4289 ;; Select all articles if `read-all' is non-nil, or if there
4290 ;; are no unread articles.
4292 (and (zerop (length gnus-newsgroup-marked))
4293 (zerop (length gnus-newsgroup-unreads)))
4294 (eq (gnus-group-find-parameter group 'display)
4297 (gnus-uncompress-range (gnus-active group))
4298 (gnus-cache-articles-in-group group))
4299 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4300 (copy-sequence gnus-newsgroup-unreads))
4302 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4303 (scored (length scored-list))
4304 (number (length articles))
4305 (marked (+ (length gnus-newsgroup-marked)
4306 (length gnus-newsgroup-dormant)))
4314 ((and (or (<= scored marked) (= scored number))
4315 (numberp gnus-large-newsgroup)
4316 (> number gnus-large-newsgroup))
4320 "How many articles from %s (default %d): "
4321 (gnus-limit-string gnus-newsgroup-name 35)
4323 (if (string-match "^[ \t]*$" input) number input)))
4324 ((and (> scored marked) (< scored number)
4325 (> (- scored number) 20))
4328 (format "%s %s (%d scored, %d total): "
4329 "How many articles from"
4330 group scored number))))
4331 (if (string-match "^[ \t]*$" input)
4335 (message "Quit getting the articles to read")
4337 (setq select (if (stringp select) (string-to-number select) select))
4338 (if (or (null select) (zerop select))
4340 (if (and (not (zerop scored)) (<= (abs select) scored))
4342 (setq articles (sort scored-list '<))
4343 (setq number (length articles)))
4344 (setq articles (copy-sequence articles)))
4346 (when (< (abs select) number)
4348 ;; Select the N oldest articles.
4349 (setcdr (nthcdr (1- (abs select)) articles) nil)
4350 ;; Select the N most recent articles.
4351 (setq articles (nthcdr (- number select) articles))))
4352 (setq gnus-newsgroup-unselected
4353 (gnus-sorted-intersection
4354 gnus-newsgroup-unreads
4355 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4356 (when gnus-alter-articles-to-read-function
4357 (setq gnus-newsgroup-unreads
4359 (funcall gnus-alter-articles-to-read-function
4360 gnus-newsgroup-name gnus-newsgroup-unreads)
4364 (defun gnus-killed-articles (killed articles)
4367 (when (inline (gnus-member-of-range (car articles) killed))
4368 (push (car articles) out))
4369 (setq articles (cdr articles)))
4372 (defun gnus-uncompress-marks (marks)
4373 "Uncompress the mark ranges in MARKS."
4374 (let ((uncompressed '(score bookmark))
4377 (if (memq (caar marks) uncompressed)
4378 (push (car marks) out)
4379 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4380 (setq marks (cdr marks)))
4383 (defun gnus-adjust-marked-articles (info)
4384 "Set all article lists and remove all marks that are no longer valid."
4385 (let* ((marked-lists (gnus-info-marks info))
4386 (active (gnus-active (gnus-info-group info)))
4389 (types gnus-article-mark-lists)
4390 (uncompressed '(score bookmark killed))
4391 marks var articles article mark)
4394 (setq marks (pop marked-lists))
4395 (set (setq var (intern (format "gnus-newsgroup-%s"
4396 (car (rassq (setq mark (car marks))
4398 (if (memq (car marks) uncompressed) (cdr marks)
4399 (gnus-uncompress-range (cdr marks))))
4401 (setq articles (symbol-value var))
4403 ;; All articles have to be subsets of the active articles.
4405 ;; Adjust "simple" lists.
4406 ((memq mark '(tick dormant expire reply save))
4408 (when (or (< (setq article (pop articles)) min) (> article max))
4409 (set var (delq article (symbol-value var))))))
4411 ((memq mark uncompressed)
4412 (when (not (listp (cdr (symbol-value var))))
4413 (set var (list (symbol-value var))))
4414 (when (not (listp (cdr articles)))
4415 (setq articles (list articles)))
4417 (when (or (not (consp (setq article (pop articles))))
4418 (< (car article) min)
4419 (> (car article) max))
4420 (set var (delq article (symbol-value var))))))))))
4422 (defun gnus-update-missing-marks (missing)
4423 "Go through the list of MISSING articles and remove them from the mark lists."
4425 (let ((types gnus-article-mark-lists)
4427 ;; Go through all types.
4429 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4430 (when (symbol-value var)
4431 ;; This list has articles. So we delete all missing articles
4435 (set var (delq (pop m) (symbol-value var)))))))))
4437 (defun gnus-update-marks ()
4438 "Enter the various lists of marked articles into the newsgroup info list."
4439 (let ((types gnus-article-mark-lists)
4440 (info (gnus-get-info gnus-newsgroup-name))
4441 (uncompressed '(score bookmark killed))
4442 type list newmarked symbol delta-marks)
4444 ;; Add all marks lists to the list of marks lists.
4445 (while (setq type (pop types))
4446 (setq list (symbol-value
4448 (intern (format "gnus-newsgroup-%s"
4452 ;; Get rid of the entries of the articles that have the
4454 (when (and (eq (cdr type) 'score)
4458 (prev (cons nil list))
4461 (if (or (not (consp (car arts)))
4462 (= (cdar arts) gnus-summary-default-score))
4463 (setcdr prev (cdr arts))
4465 (setq arts (cdr arts)))
4466 (setq list (cdr all)))))
4468 (unless (memq (cdr type) uncompressed)
4469 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4471 (when (gnus-check-backend-function
4472 'request-set-mark gnus-newsgroup-name)
4473 ;; propagate flags to server, with the following exceptions:
4474 ;; uncompressed:s are not proper flags (they are cons cells)
4475 ;; cache is a internal gnus flag
4476 ;; download are local to one gnus installation (well)
4477 ;; unsend are for nndraft groups only
4478 ;; xxx: generality of this? this suits nnimap anyway
4479 (unless (memq (cdr type) (append '(cache download unsend)
4481 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4482 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4483 (add (gnus-remove-from-range
4484 (gnus-copy-sequence list) old)))
4486 (push (list add 'add (list (cdr type))) delta-marks))
4488 (push (list del 'del (list (cdr type))) delta-marks)))))
4491 (push (cons (cdr type) list) newmarked)))
4494 (unless (gnus-check-group gnus-newsgroup-name)
4495 (error "Can't open server for %s" gnus-newsgroup-name))
4496 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4498 ;; Enter these new marks into the info of the group.
4500 (setcar (nthcdr 3 info) newmarked)
4501 ;; Add the marks lists to the end of the info.
4503 (setcdr (nthcdr 2 info) (list newmarked))))
4505 ;; Cut off the end of the info if there's nothing else there.
4509 (when (nthcdr (decf i) info)
4510 (setcdr (nthcdr i info) nil)))))))
4512 (defun gnus-set-mode-line (where)
4513 "Set the mode line of the article or summary buffers.
4514 If WHERE is `summary', the summary mode line format will be used."
4515 ;; Is this mode line one we keep updated?
4516 (when (and (memq where gnus-updated-mode-lines)
4518 (intern (format "gnus-%s-mode-line-format-spec" where))))
4521 ;; We evaluate this in the summary buffer since these
4522 ;; variables are buffer-local to that buffer.
4523 (set-buffer gnus-summary-buffer)
4524 ;; We bind all these variables that are used in the `eval' form
4526 (let* ((mformat (symbol-value
4528 (format "gnus-%s-mode-line-format-spec" where))))
4529 (gnus-tmp-group-name (gnus-group-name-decode
4531 (gnus-group-name-charset
4533 gnus-newsgroup-name)))
4534 (gnus-tmp-article-number (or gnus-current-article 0))
4535 (gnus-tmp-unread gnus-newsgroup-unreads)
4536 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4537 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4538 (gnus-tmp-unread-and-unselected
4539 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4540 (zerop gnus-tmp-unselected))
4542 ((zerop gnus-tmp-unselected)
4543 (format "{%d more}" gnus-tmp-unread-and-unticked))
4544 (t (format "{%d(+%d) more}"
4545 gnus-tmp-unread-and-unticked
4546 gnus-tmp-unselected))))
4548 (if (and gnus-current-headers
4549 (vectorp gnus-current-headers))
4550 (gnus-mode-string-quote
4551 (mail-header-subject gnus-current-headers))
4553 bufname-length max-len
4554 gnus-tmp-header);; passed as argument to any user-format-funcs
4555 (setq mode-string (eval mformat))
4556 (setq bufname-length (if (string-match "%b" mode-string)
4559 (if (eq where 'summary)
4561 (get-buffer gnus-article-buffer))))
4564 (setq max-len (max 4 (if gnus-mode-non-string-length
4566 gnus-mode-non-string-length
4568 (length mode-string))))
4569 ;; We might have to chop a bit of the string off...
4570 (when (> (length mode-string) max-len)
4572 (concat (truncate-string-to-width mode-string (- max-len 3))
4574 ;; Pad the mode string a bit.
4575 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4576 ;; Update the mode line.
4577 (setq mode-line-buffer-identification
4578 (gnus-mode-line-buffer-identification (list mode-string)))
4579 (set-buffer-modified-p t))))
4581 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4582 "Go through the HEADERS list and add all Xrefs to a hash table.
4583 The resulting hash table is returned, or nil if no Xrefs were found."
4584 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4585 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4586 (xref-hashtb (gnus-make-hashtable))
4587 start group entry number xrefs header)
4589 (setq header (pop headers))
4590 (when (and (setq xrefs (mail-header-xref header))
4591 (not (memq (setq number (mail-header-number header))
4594 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4595 (setq start (match-end 0))
4596 (setq group (if prefix
4597 (concat prefix (substring xrefs (match-beginning 1)
4599 (substring xrefs (match-beginning 1) (match-end 1))))
4601 (string-to-int (substring xrefs (match-beginning 2)
4603 (if (setq entry (gnus-gethash group xref-hashtb))
4604 (setcdr entry (cons number (cdr entry)))
4605 (gnus-sethash group (cons number nil) xref-hashtb)))))
4606 (and start xref-hashtb)))
4608 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4609 "Look through all the headers and mark the Xrefs as read."
4610 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4611 name entry info xref-hashtb idlist method nth4)
4613 (set-buffer gnus-group-buffer)
4614 (when (setq xref-hashtb
4615 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4618 (unless (string= from-newsgroup (setq name (symbol-name group)))
4619 (setq idlist (symbol-value group))
4620 ;; Dead groups are not updated.
4622 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4624 (when (stringp (setq nth4 (gnus-info-method info)))
4625 (setq nth4 (gnus-server-to-method nth4))))
4626 ;; Only do the xrefs if the group has the same
4627 ;; select method as the group we have just read.
4628 (or (gnus-methods-equal-p
4629 nth4 (gnus-find-method-for-group from-newsgroup))
4631 (equal nth4 (setq method (gnus-find-method-for-group
4633 (and (equal (car nth4) (car method))
4634 (equal (nth 1 nth4) (nth 1 method))))
4635 gnus-use-cross-reference
4636 (or (not (eq gnus-use-cross-reference t))
4638 ;; Only do cross-references on subscribed
4639 ;; groups, if that is what is wanted.
4640 (<= (gnus-info-level info) gnus-level-subscribed))
4641 (gnus-group-make-articles-read name idlist))))
4644 (defun gnus-compute-read-articles (group articles)
4645 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4646 (info (nth 2 entry))
4647 (active (gnus-active group))
4650 ;; First peel off all invalid article numbers.
4652 (let ((ids articles)
4654 (while (setq id (pop ids))
4655 (when (and first (> id (cdr active)))
4656 ;; We'll end up in this situation in one particular
4657 ;; obscure situation. If you re-scan a group and get
4658 ;; a new article that is cross-posted to a different
4659 ;; group that has not been re-scanned, you might get
4660 ;; crossposted article that has a higher number than
4661 ;; Gnus believes possible. So we re-activate this
4662 ;; group as well. This might mean doing the
4663 ;; crossposting thingy will *increase* the number
4664 ;; of articles in some groups. Tsk, tsk.
4665 (setq active (or (gnus-activate-group group) active)))
4666 (when (or (> id (cdr active))
4667 (< id (car active)))
4668 (setq articles (delq id articles))))))
4669 ;; If the read list is nil, we init it.
4671 (null (gnus-info-read info))
4673 (setq ninfo (cons 1 (1- (car active))))
4674 (setq ninfo (gnus-info-read info)))
4675 ;; Then we add the read articles to the range.
4677 ninfo (setq articles (sort articles '<))))))
4679 (defun gnus-group-make-articles-read (group articles)
4680 "Update the info of GROUP to say that ARTICLES are read."
4682 (entry (gnus-gethash group gnus-newsrc-hashtb))
4683 (info (nth 2 entry))
4684 (active (gnus-active group))
4687 (setq range (gnus-compute-read-articles group articles))
4689 (set-buffer gnus-group-buffer)
4692 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4693 (gnus-info-set-read ',info ',(gnus-info-read info))
4694 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4695 (gnus-group-update-group ,group t))))
4696 ;; Add the read articles to the range.
4697 (gnus-info-set-read info range)
4698 ;; Then we have to re-compute how many unread
4699 ;; articles there are in this group.
4703 (setq num (- (1+ (cdr active)) (car active))))
4704 ((not (listp (cdr range)))
4705 (setq num (- (cdr active) (- (1+ (cdr range))
4709 (if (numberp (car range))
4711 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4712 (setq range (cdr range)))
4713 (setq num (- (cdr active) num))))
4714 ;; Update the number of unread articles.
4716 ;; Update the group buffer.
4717 (gnus-group-update-group group t)))))
4719 (defvar gnus-newsgroup-none-id 0)
4721 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4722 (let ((cur nntp-server-buffer)
4725 (save-excursion (set-buffer gnus-summary-buffer)
4726 gnus-newsgroup-dependencies)))
4728 (mail-parse-charset gnus-newsgroup-charset)
4729 (mail-parse-ignored-charsets
4730 (save-excursion (condition-case nil
4731 (set-buffer gnus-summary-buffer)
4733 gnus-newsgroup-ignored-charsets)))
4735 (set-buffer nntp-server-buffer)
4736 ;; Translate all TAB characters into SPACE characters.
4737 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4738 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4739 (gnus-run-hooks 'gnus-parse-headers-hook)
4740 (let ((case-fold-search t)
4741 in-reply-to header p lines chars)
4742 (goto-char (point-min))
4743 ;; Search to the beginning of the next header. Error messages
4744 ;; do not begin with 2 or 3.
4745 (while (re-search-forward "^[23][0-9]+ " nil t)
4748 ;; This implementation of this function, with nine
4749 ;; search-forwards instead of the one re-search-forward and
4750 ;; a case (which basically was the old function) is actually
4751 ;; about twice as fast, even though it looks messier. You
4752 ;; can't have everything, I guess. Speed and elegance
4753 ;; doesn't always go hand in hand.
4762 (narrow-to-region (point)
4763 (or (and (search-forward "\n.\n" nil t)
4769 (if (search-forward "\nsubject: " nil t)
4770 (funcall gnus-decode-encoded-word-function
4771 (nnheader-header-value))
4776 (if (or (search-forward "\nfrom: " nil t)
4777 (search-forward "\nfrom:" nil t))
4778 (funcall gnus-decode-encoded-word-function
4779 (nnheader-header-value))
4784 (if (search-forward "\ndate: " nil t)
4785 (nnheader-header-value) ""))
4789 (setq id (if (re-search-forward
4790 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4791 ;; We do it this way to make sure the Message-ID
4792 ;; is (somewhat) syntactically valid.
4793 (buffer-substring (match-beginning 1)
4795 ;; If there was no message-id, we just fake one
4796 ;; to make subsequent routines simpler.
4797 (nnheader-generate-fake-message-id))))
4801 (if (search-forward "\nreferences: " nil t)
4805 (nnheader-header-value)
4810 (search-backward ">" end t)
4813 (search-backward "<" end t)
4815 ;; Get the references from the in-reply-to header if there
4816 ;; were no references and the in-reply-to header looks
4818 (if (and (search-forward "\nin-reply-to: " nil t)
4819 (setq in-reply-to (nnheader-header-value))
4820 (string-match "<[^>]+>" in-reply-to))
4822 (setq ref (substring in-reply-to (match-beginning 0)
4824 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4825 (setq ref2 (substring in-reply-to (match-beginning 0)
4827 (when (> (length ref2) (length ref))
4834 (if (search-forward "\nchars: " nil t)
4835 (if (numberp (setq chars (ignore-errors (read cur))))
4841 (if (search-forward "\nlines: " nil t)
4842 (if (numberp (setq lines (ignore-errors (read cur))))
4848 (and (search-forward "\nxref: " nil t)
4849 (nnheader-header-value)))
4851 (when gnus-extra-headers
4852 (let ((extra gnus-extra-headers)
4856 (when (search-forward
4857 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4858 (push (cons (car extra) (nnheader-header-value))
4862 (when (equal id ref)
4865 (when gnus-alter-header-function
4866 (funcall gnus-alter-header-function header)
4867 (setq id (mail-header-id header)
4868 ref (gnus-parent-id (mail-header-references header))))
4871 (gnus-dependencies-add-header
4872 header dependencies force-new))
4873 (push header headers))
4874 (goto-char (point-max))
4876 (nreverse headers)))))
4878 ;; Goes through the xover lines and returns a list of vectors
4879 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4880 force-new dependencies
4881 group also-fetch-heads)
4882 "Parse the news overview data in the server buffer.
4883 Return a list of headers that match SEQUENCE (see
4884 `nntp-retrieve-headers')."
4885 ;; Get the Xref when the users reads the articles since most/some
4886 ;; NNTP servers do not include Xrefs when using XOVER.
4887 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4888 (let ((mail-parse-charset gnus-newsgroup-charset)
4889 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4890 (cur nntp-server-buffer)
4891 (dependencies (or dependencies gnus-newsgroup-dependencies))
4892 number headers header)
4894 (set-buffer nntp-server-buffer)
4895 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4896 ;; Allow the user to mangle the headers before parsing them.
4897 (gnus-run-hooks 'gnus-parse-headers-hook)
4898 (goto-char (point-min))
4901 (while (and sequence (not (eobp)))
4902 (setq number (read cur))
4903 (while (and sequence
4904 (< (car sequence) number))
4905 (setq sequence (cdr sequence)))
4907 (eq number (car sequence))
4909 (setq sequence (cdr sequence))
4910 (setq header (inline
4911 (gnus-nov-parse-line
4912 number dependencies force-new))))
4913 (push header headers))
4916 (gnus-error 4 "Strange nov line (%d)"
4917 (count-lines (point-min) (point)))))
4919 ;; A common bug in inn is that if you have posted an article and
4920 ;; then retrieves the active file, it will answer correctly --
4921 ;; the new article is included. However, a NOV entry for the
4922 ;; article may not have been generated yet, so this may fail.
4923 ;; We work around this problem by retrieving the last few
4924 ;; headers using HEAD.
4925 (if (or (not also-fetch-heads)
4927 ;; We (probably) got all the headers.
4929 (let ((gnus-nov-is-evil t))
4932 (when (gnus-retrieve-headers sequence group)
4933 (gnus-get-newsgroup-headers))))))))
4935 (defun gnus-article-get-xrefs ()
4936 "Fill in the Xref value in `gnus-current-headers', if necessary.
4937 This is meant to be called in `gnus-article-internal-prepare-hook'."
4938 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4939 gnus-current-headers)))
4940 (or (not gnus-use-cross-reference)
4942 (and (mail-header-xref headers)
4943 (not (string= (mail-header-xref headers) "")))
4944 (let ((case-fold-search t)
4947 (nnheader-narrow-to-headers)
4948 (goto-char (point-min))
4949 (when (or (and (not (eobp))
4950 (eq (downcase (char-after)) ?x)
4951 (looking-at "Xref:"))
4952 (search-forward "\nXref:" nil t))
4953 (goto-char (1+ (match-end 0)))
4954 (setq xref (buffer-substring (point)
4955 (progn (end-of-line) (point))))
4956 (mail-header-set-xref headers xref)))))))
4958 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4959 "Find article ID and insert the summary line for that article.
4960 OLD-HEADER can either be a header or a line number to insert
4961 the subject line on."
4962 (let* ((line (and (numberp old-header) old-header))
4963 (old-header (and (vectorp old-header) old-header))
4964 (header (cond ((and old-header use-old-header)
4967 (gnus-number-to-header id))
4968 (gnus-number-to-header id))
4970 (gnus-read-header id))))
4971 (number (and (numberp id) id))
4974 ;; Rebuild the thread that this article is part of and go to the
4975 ;; article we have fetched.
4976 (when (and (not gnus-show-threads)
4979 (setq d (gnus-data-find (mail-header-number old-header))))
4980 (goto-char (gnus-data-pos d))
4983 (- (gnus-point-at-bol)
4985 (1+ (gnus-point-at-eol))
4986 (gnus-delete-line))))))
4988 (mail-header-set-number header (mail-header-number old-header)))
4989 (setq gnus-newsgroup-sparse
4990 (delq (setq number (mail-header-number header))
4991 gnus-newsgroup-sparse))
4992 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4993 (push number gnus-newsgroup-limit)
4994 (gnus-rebuild-thread (mail-header-id header) line)
4995 (gnus-summary-goto-subject number nil t))
4996 (when (and (numberp number)
4998 ;; We have to update the boundaries even if we can't fetch the
4999 ;; article if ID is a number -- so that the next `P' or `N'
5000 ;; command will fetch the previous (or next) article even
5001 ;; if the one we tried to fetch this time has been canceled.
5002 (when (> number gnus-newsgroup-end)
5003 (setq gnus-newsgroup-end number))
5004 (when (< number gnus-newsgroup-begin)
5005 (setq gnus-newsgroup-begin number))
5006 (setq gnus-newsgroup-unselected
5007 (delq number gnus-newsgroup-unselected)))
5008 ;; Report back a success?
5009 (and header (mail-header-number header))))
5011 ;;; Process/prefix in the summary buffer
5013 (defun gnus-summary-work-articles (n)
5014 "Return a list of articles to be worked upon.
5015 The prefix argument, the list of process marked articles, and the
5016 current article will be taken into consideration."
5018 (set-buffer gnus-summary-buffer)
5021 ;; A numerical prefix has been given.
5022 (setq n (prefix-numeric-value n))
5023 (let ((backward (< n 0))
5024 (n (abs (prefix-numeric-value n)))
5029 (push (setq article (gnus-summary-article-number))
5032 (gnus-summary-find-prev nil article)
5033 (gnus-summary-find-next nil article)))
5035 (nreverse articles)))
5036 ((and (gnus-region-active-p) (mark))
5037 (message "region active")
5038 ;; Work on the region between point and mark.
5039 (let ((max (max (point) (mark)))
5042 (goto-char (min (min (point) (mark))))
5045 (push (setq article (gnus-summary-article-number)) articles)
5046 (gnus-summary-find-next nil article)
5048 (nreverse articles))))
5049 (gnus-newsgroup-processable
5050 ;; There are process-marked articles present.
5051 ;; Save current state.
5052 (gnus-summary-save-process-mark)
5054 (reverse gnus-newsgroup-processable))
5056 ;; Just return the current article.
5057 (list (gnus-summary-article-number))))))
5059 (defmacro gnus-summary-iterate (arg &rest forms)
5060 "Iterate over the process/prefixed articles and do FORMS.
5061 ARG is the interactive prefix given to the command. FORMS will be
5062 executed with point over the summary line of the articles."
5063 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5064 `(let ((,articles (gnus-summary-work-articles ,arg)))
5066 (gnus-summary-goto-subject (car ,articles))
5070 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5071 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5073 (defun gnus-summary-save-process-mark ()
5074 "Push the current set of process marked articles on the stack."
5076 (push (copy-sequence gnus-newsgroup-processable)
5077 gnus-newsgroup-process-stack))
5079 (defun gnus-summary-kill-process-mark ()
5080 "Push the current set of process marked articles on the stack and unmark."
5082 (gnus-summary-save-process-mark)
5083 (gnus-summary-unmark-all-processable))
5085 (defun gnus-summary-yank-process-mark ()
5086 "Pop the last process mark state off the stack and restore it."
5088 (unless gnus-newsgroup-process-stack
5089 (error "Empty mark stack"))
5090 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5092 (defun gnus-summary-process-mark-set (set)
5093 "Make SET into the current process marked articles."
5094 (gnus-summary-unmark-all-processable)
5096 (gnus-summary-set-process-mark (pop set))))
5098 ;;; Searching and stuff
5100 (defun gnus-summary-search-group (&optional backward use-level)
5101 "Search for next unread newsgroup.
5102 If optional argument BACKWARD is non-nil, search backward instead."
5104 (set-buffer gnus-group-buffer)
5105 (when (gnus-group-search-forward
5106 backward nil (if use-level (gnus-group-group-level) nil))
5107 (gnus-group-group-name))))
5109 (defun gnus-summary-best-group (&optional exclude-group)
5110 "Find the name of the best unread group.
5111 If EXCLUDE-GROUP, do not go to this group."
5113 (set-buffer gnus-group-buffer)
5115 (gnus-group-best-unread-group exclude-group))))
5117 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5118 (if backward (gnus-summary-find-prev)
5119 (let* ((dummy (gnus-summary-article-intangible-p))
5120 (article (or article (gnus-summary-article-number)))
5121 (arts (gnus-data-find-list article))
5123 (when (and (not dummy)
5124 (or (not gnus-summary-check-current)
5126 (not (gnus-data-unread-p (car arts)))))
5127 (setq arts (cdr arts)))
5132 (when (or (and undownloaded
5133 (eq gnus-undownloaded-mark
5134 (gnus-data-mark (car arts))))
5135 (gnus-data-unread-p (car arts)))
5136 (setq result (car arts)
5138 (setq arts (cdr arts)))
5141 (goto-char (gnus-data-pos result))
5142 (gnus-data-number result)))))
5144 (defun gnus-summary-find-prev (&optional unread article)
5145 (let* ((eobp (eobp))
5146 (article (or article (gnus-summary-article-number)))
5147 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5149 (when (and (not eobp)
5150 (or (not gnus-summary-check-current)
5152 (not (gnus-data-unread-p (car arts)))))
5153 (setq arts (cdr arts)))
5158 (when (gnus-data-unread-p (car arts))
5159 (setq result (car arts)
5161 (setq arts (cdr arts)))
5164 (goto-char (gnus-data-pos result))
5165 (gnus-data-number result))))
5167 (defun gnus-summary-find-subject (subject &optional unread backward article)
5168 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5169 (article (or article (gnus-summary-article-number)))
5170 (articles (gnus-data-list backward))
5171 (arts (gnus-data-find-list article articles))
5173 (when (or (not gnus-summary-check-current)
5175 (not (gnus-data-unread-p (car arts))))
5176 (setq arts (cdr arts)))
5178 (and (or (not unread)
5179 (gnus-data-unread-p (car arts)))
5180 (vectorp (gnus-data-header (car arts)))
5182 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5183 (setq result (car arts)
5185 (setq arts (cdr arts)))
5187 (goto-char (gnus-data-pos result))
5188 (gnus-data-number result))))
5190 (defun gnus-summary-search-forward (&optional unread subject backward)
5191 "Search forward for an article.
5192 If UNREAD, look for unread articles. If SUBJECT, look for
5193 articles with that subject. If BACKWARD, search backward instead."
5194 (cond (subject (gnus-summary-find-subject subject unread backward))
5195 (backward (gnus-summary-find-prev unread))
5196 (t (gnus-summary-find-next unread))))
5198 (defun gnus-recenter (&optional n)
5199 "Center point in window and redisplay frame.
5200 Also do horizontal recentering."
5202 (when (and gnus-auto-center-summary
5203 (not (eq gnus-auto-center-summary 'vertical)))
5204 (gnus-horizontal-recenter))
5207 (defun gnus-summary-recenter ()
5208 "Center point in the summary window.
5209 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5210 displayed, no centering will be performed."
5211 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5212 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5214 (let* ((top (cond ((< (window-height) 4) 0)
5215 ((< (window-height) 7) 1)
5216 (t (if (numberp gnus-auto-center-summary)
5217 gnus-auto-center-summary
5219 (height (1- (window-height)))
5220 (bottom (save-excursion (goto-char (point-max))
5221 (forward-line (- height))
5223 (window (get-buffer-window (current-buffer))))
5224 ;; The user has to want it.
5225 (when gnus-auto-center-summary
5226 (when (get-buffer-window gnus-article-buffer)
5227 ;; Only do recentering when the article buffer is displayed,
5228 ;; Set the window start to either `bottom', which is the biggest
5229 ;; possible valid number, or the second line from the top,
5230 ;; whichever is the least.
5232 window (min bottom (save-excursion
5233 (forward-line (- top)) (point)))
5235 ;; Do horizontal recentering while we're at it.
5236 (when (and (get-buffer-window (current-buffer) t)
5237 (not (eq gnus-auto-center-summary 'vertical)))
5238 (let ((selected (selected-window)))
5239 (select-window (get-buffer-window (current-buffer) t))
5240 (gnus-summary-position-point)
5241 (gnus-horizontal-recenter)
5242 (select-window selected))))))
5244 (defun gnus-summary-jump-to-group (newsgroup)
5245 "Move point to NEWSGROUP in group mode buffer."
5246 ;; Keep update point of group mode buffer if visible.
5247 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5248 (save-window-excursion
5249 ;; Take care of tree window mode.
5250 (when (get-buffer-window gnus-group-buffer)
5251 (pop-to-buffer gnus-group-buffer))
5252 (gnus-group-jump-to-group newsgroup))
5254 ;; Take care of tree window mode.
5255 (if (get-buffer-window gnus-group-buffer)
5256 (pop-to-buffer gnus-group-buffer)
5257 (set-buffer gnus-group-buffer))
5258 (gnus-group-jump-to-group newsgroup))))
5260 ;; This function returns a list of article numbers based on the
5261 ;; difference between the ranges of read articles in this group and
5262 ;; the range of active articles.
5263 (defun gnus-list-of-unread-articles (group)
5264 (let* ((read (gnus-info-read (gnus-get-info group)))
5265 (active (or (gnus-active group) (gnus-activate-group group)))
5268 ;; If none are read, then all are unread.
5270 (setq first (car active))
5271 ;; If the range of read articles is a single range, then the
5272 ;; first unread article is the article after the last read
5273 ;; article. Sounds logical, doesn't it?
5274 (if (and (not (listp (cdr read)))
5275 (or (< (car read) (car active))
5276 (progn (setq read (list read))
5278 (setq first (max (car active) (1+ (cdr read))))
5279 ;; `read' is a list of ranges.
5280 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5283 (setq first (car active)))
5286 (while (< first nlast)
5288 (setq first (1+ first))))
5289 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5290 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5291 (setq read (cdr read)))))
5292 ;; And add the last unread articles.
5293 (while (<= first last)
5295 (setq first (1+ first)))
5296 ;; Return the list of unread articles.
5297 (delq 0 (nreverse unread))))
5299 (defun gnus-list-of-read-articles (group)
5300 "Return a list of unread, unticked and non-dormant articles."
5301 (let* ((info (gnus-get-info group))
5302 (marked (gnus-info-marks info))
5303 (active (gnus-active group)))
5305 (gnus-set-difference
5306 (gnus-sorted-complement
5307 (gnus-uncompress-range active)
5308 (gnus-list-of-unread-articles group))
5310 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5311 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5313 ;; Various summary commands
5315 (defun gnus-summary-select-article-buffer ()
5316 "Reconfigure windows to show article buffer."
5318 (if (not (gnus-buffer-live-p gnus-article-buffer))
5319 (error "There is no article buffer for this summary buffer")
5320 (gnus-configure-windows 'article)
5321 (select-window (get-buffer-window gnus-article-buffer))))
5323 (defun gnus-summary-universal-argument (arg)
5324 "Perform any operation on all articles that are process/prefixed."
5326 (let ((articles (gnus-summary-work-articles arg))
5333 (substitute-command-keys
5334 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5336 (gnus-error 1 "Undefined key")
5339 (gnus-summary-goto-subject (setq article (pop articles)))
5340 (let (gnus-newsgroup-processable)
5341 (command-execute func))
5342 (gnus-summary-remove-process-mark article)))))
5343 (gnus-summary-position-point))
5345 (defun gnus-summary-toggle-truncation (&optional arg)
5346 "Toggle truncation of summary lines.
5347 With arg, turn line truncation on iff arg is positive."
5349 (setq truncate-lines
5350 (if (null arg) (not truncate-lines)
5351 (> (prefix-numeric-value arg) 0)))
5354 (defun gnus-summary-reselect-current-group (&optional all rescan)
5355 "Exit and then reselect the current newsgroup.
5356 The prefix argument ALL means to select all articles."
5358 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5359 (error "Ephemeral groups can't be reselected"))
5360 (let ((current-subject (gnus-summary-article-number))
5361 (group gnus-newsgroup-name))
5362 (setq gnus-newsgroup-begin nil)
5364 ;; We have to adjust the point of group mode buffer because
5365 ;; point was moved to the next unread newsgroup by exiting.
5366 (gnus-summary-jump-to-group group)
5369 (gnus-group-get-new-news-this-group 1)))
5370 (gnus-group-read-group all t)
5371 (gnus-summary-goto-subject current-subject nil t)))
5373 (defun gnus-summary-rescan-group (&optional all)
5374 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5376 (gnus-summary-reselect-current-group all t))
5378 (defun gnus-summary-update-info (&optional non-destructive)
5380 (let ((group gnus-newsgroup-name))
5382 (when gnus-newsgroup-kill-headers
5383 (setq gnus-newsgroup-killed
5384 (gnus-compress-sequence
5386 (gnus-set-sorted-intersection
5387 (gnus-uncompress-range gnus-newsgroup-killed)
5388 (setq gnus-newsgroup-unselected
5389 (sort gnus-newsgroup-unselected '<)))
5390 (setq gnus-newsgroup-unreads
5391 (sort gnus-newsgroup-unreads '<)))
5393 (unless (listp (cdr gnus-newsgroup-killed))
5394 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5395 (let ((headers gnus-newsgroup-headers))
5396 ;; Set the new ranges of read articles.
5398 (set-buffer gnus-group-buffer)
5399 (gnus-undo-force-boundary))
5400 (gnus-update-read-articles
5401 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5402 ;; Set the current article marks.
5403 (let ((gnus-newsgroup-scored
5404 (if (and (not gnus-save-score)
5405 (not non-destructive))
5407 gnus-newsgroup-scored)))
5409 (gnus-update-marks)))
5410 ;; Do the cross-ref thing.
5411 (when gnus-use-cross-reference
5412 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5413 ;; Do not switch windows but change the buffer to work.
5414 (set-buffer gnus-group-buffer)
5415 (unless (gnus-ephemeral-group-p group)
5416 (gnus-group-update-group group)))))))
5418 (defun gnus-summary-save-newsrc (&optional force)
5419 "Save the current number of read/marked articles in the dribble buffer.
5420 The dribble buffer will then be saved.
5421 If FORCE (the prefix), also save the .newsrc file(s)."
5423 (gnus-summary-update-info t)
5425 (gnus-save-newsrc-file)
5426 (gnus-dribble-save)))
5428 (defun gnus-summary-exit (&optional temporary)
5429 "Exit reading current newsgroup, and then return to group selection mode.
5430 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5432 (gnus-set-global-variables)
5433 (when (gnus-buffer-live-p gnus-article-buffer)
5435 (set-buffer gnus-article-buffer)
5436 (mm-destroy-parts gnus-article-mime-handles)
5437 ;; Set it to nil for safety reason.
5438 (setq gnus-article-mime-handle-alist nil)
5439 (setq gnus-article-mime-handles nil)))
5440 (gnus-kill-save-kill-buffer)
5441 (gnus-async-halt-prefetch)
5442 (let* ((group gnus-newsgroup-name)
5443 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5446 (buf (current-buffer)))
5448 ;; Do adaptive scoring, and possibly save score files.
5449 (when gnus-newsgroup-adaptive
5450 (gnus-score-adaptive))
5451 (when gnus-use-scoring
5453 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5454 ;; If we have several article buffers, we kill them at exit.
5455 (unless gnus-single-article-buffer
5456 (gnus-kill-buffer gnus-original-article-buffer)
5457 (setq gnus-article-current nil))
5458 (when gnus-use-cache
5459 (gnus-cache-possibly-remove-articles)
5460 (gnus-cache-save-buffers))
5461 (gnus-async-prefetch-remove-group group)
5462 (when gnus-suppress-duplicates
5463 (gnus-dup-enter-articles))
5464 (when gnus-use-trees
5465 (gnus-tree-close group))
5466 (when gnus-use-cache
5467 (gnus-cache-write-active))
5468 ;; Remove entries for this group.
5469 (nnmail-purge-split-history (gnus-group-real-name group))
5470 ;; Make all changes in this group permanent.
5472 (gnus-run-hooks 'gnus-exit-group-hook)
5473 (gnus-summary-update-info))
5474 (gnus-close-group group)
5475 ;; Make sure where we were, and go to next newsgroup.
5476 (set-buffer gnus-group-buffer)
5478 (gnus-group-jump-to-group group))
5479 (gnus-run-hooks 'gnus-summary-exit-hook)
5480 (unless (or quit-config
5481 ;; If this group has disappeared from the summary
5482 ;; buffer, don't skip forwards.
5483 (not (string= group (gnus-group-group-name))))
5484 (gnus-group-next-unread-group 1))
5485 (setq group-point (point))
5488 ;; If we have several article buffers, we kill them at exit.
5489 (unless gnus-single-article-buffer
5490 (gnus-kill-buffer gnus-article-buffer)
5491 (gnus-kill-buffer gnus-original-article-buffer)
5492 (setq gnus-article-current nil))
5494 (if (not gnus-kill-summary-on-exit)
5495 (gnus-deaden-summary)
5496 ;; We set all buffer-local variables to nil. It is unclear why
5497 ;; this is needed, but if we don't, buffer-local variables are
5498 ;; not garbage-collected, it seems. This would the lead to en
5499 ;; ever-growing Emacs.
5500 (gnus-summary-clear-local-variables)
5501 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5502 (gnus-summary-clear-local-variables))
5503 (when (get-buffer gnus-article-buffer)
5504 (bury-buffer gnus-article-buffer))
5505 ;; We clear the global counterparts of the buffer-local
5506 ;; variables as well, just to be on the safe side.
5507 (set-buffer gnus-group-buffer)
5508 (gnus-summary-clear-local-variables)
5509 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5510 (gnus-summary-clear-local-variables))
5511 ;; Return to group mode buffer.
5512 (when (eq mode 'gnus-summary-mode)
5513 (gnus-kill-buffer buf)))
5514 (setq gnus-current-select-method gnus-select-method)
5515 (pop-to-buffer gnus-group-buffer)
5516 (if (not quit-config)
5518 (goto-char group-point)
5519 (gnus-configure-windows 'group 'force))
5520 (gnus-handle-ephemeral-exit quit-config))
5521 ;; Clear the current group name.
5523 (setq gnus-newsgroup-name nil)))))
5525 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5526 (defun gnus-summary-exit-no-update (&optional no-questions)
5527 "Quit reading current newsgroup without updating read article info."
5529 (let* ((group gnus-newsgroup-name)
5530 (quit-config (gnus-group-quit-config group)))
5531 (when (or no-questions
5533 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5534 (gnus-async-halt-prefetch)
5536 (delq 'gnus-summary-expire-articles
5537 (copy-sequence gnus-summary-prepare-exit-hook)))
5538 (when (gnus-buffer-live-p gnus-article-buffer)
5540 (set-buffer gnus-article-buffer)
5541 (mm-destroy-parts gnus-article-mime-handles)
5542 ;; Set it to nil for safety reason.
5543 (setq gnus-article-mime-handle-alist nil)
5544 (setq gnus-article-mime-handles nil)))
5545 ;; If we have several article buffers, we kill them at exit.
5546 (unless gnus-single-article-buffer
5547 (gnus-kill-buffer gnus-article-buffer)
5548 (gnus-kill-buffer gnus-original-article-buffer)
5549 (setq gnus-article-current nil))
5550 (if (not gnus-kill-summary-on-exit)
5551 (gnus-deaden-summary)
5552 (gnus-close-group group)
5553 (gnus-summary-clear-local-variables)
5554 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5555 (gnus-summary-clear-local-variables))
5556 (set-buffer gnus-group-buffer)
5557 (gnus-summary-clear-local-variables)
5558 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5559 (gnus-summary-clear-local-variables))
5560 (when (get-buffer gnus-summary-buffer)
5561 (kill-buffer gnus-summary-buffer)))
5562 (unless gnus-single-article-buffer
5563 (setq gnus-article-current nil))
5564 (when gnus-use-trees
5565 (gnus-tree-close group))
5566 (gnus-async-prefetch-remove-group group)
5567 (when (get-buffer gnus-article-buffer)
5568 (bury-buffer gnus-article-buffer))
5569 ;; Return to the group buffer.
5570 (gnus-configure-windows 'group 'force)
5571 ;; Clear the current group name.
5572 (setq gnus-newsgroup-name nil)
5573 (when (equal (gnus-group-group-name) group)
5574 (gnus-group-next-unread-group 1))
5576 (gnus-handle-ephemeral-exit quit-config)))))
5578 (defun gnus-handle-ephemeral-exit (quit-config)
5579 "Handle movement when leaving an ephemeral group.
5580 The state which existed when entering the ephemeral is reset."
5581 (if (not (buffer-name (car quit-config)))
5582 (gnus-configure-windows 'group 'force)
5583 (set-buffer (car quit-config))
5584 (cond ((eq major-mode 'gnus-summary-mode)
5585 (gnus-set-global-variables))
5586 ((eq major-mode 'gnus-article-mode)
5588 ;; The `gnus-summary-buffer' variable may point
5589 ;; to the old summary buffer when using a single
5591 (unless (gnus-buffer-live-p gnus-summary-buffer)
5592 (set-buffer gnus-group-buffer))
5593 (set-buffer gnus-summary-buffer)
5594 (gnus-set-global-variables))))
5595 (if (or (eq (cdr quit-config) 'article)
5596 (eq (cdr quit-config) 'pick))
5598 ;; The current article may be from the ephemeral group
5599 ;; thus it is best that we reload this article
5600 (gnus-summary-show-article)
5601 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5602 (gnus-configure-windows 'pick 'force)
5603 (gnus-configure-windows (cdr quit-config) 'force)))
5604 (gnus-configure-windows (cdr quit-config) 'force))
5605 (when (eq major-mode 'gnus-summary-mode)
5606 (gnus-summary-next-subject 1 nil t)
5607 (gnus-summary-recenter)
5608 (gnus-summary-position-point))))
5612 (defvar gnus-dead-summary-mode-map nil)
5614 (unless gnus-dead-summary-mode-map
5615 (setq gnus-dead-summary-mode-map (make-keymap))
5616 (suppress-keymap gnus-dead-summary-mode-map)
5617 (substitute-key-definition
5618 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5619 (let ((keys '("\C-d" "\r" "\177" [delete])))
5621 (define-key gnus-dead-summary-mode-map
5622 (pop keys) 'gnus-summary-wake-up-the-dead))))
5624 (defvar gnus-dead-summary-mode nil
5625 "Minor mode for Gnus summary buffers.")
5627 (defun gnus-dead-summary-mode (&optional arg)
5628 "Minor mode for Gnus summary buffers."
5630 (when (eq major-mode 'gnus-summary-mode)
5631 (make-local-variable 'gnus-dead-summary-mode)
5632 (setq gnus-dead-summary-mode
5633 (if (null arg) (not gnus-dead-summary-mode)
5634 (> (prefix-numeric-value arg) 0)))
5635 (when gnus-dead-summary-mode
5636 (gnus-add-minor-mode
5637 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5639 (defun gnus-deaden-summary ()
5640 "Make the current summary buffer into a dead summary buffer."
5641 ;; Kill any previous dead summary buffer.
5642 (when (and gnus-dead-summary
5643 (buffer-name gnus-dead-summary))
5645 (set-buffer gnus-dead-summary)
5646 (when gnus-dead-summary-mode
5647 (kill-buffer (current-buffer)))))
5648 ;; Make this the current dead summary.
5649 (setq gnus-dead-summary (current-buffer))
5650 (gnus-dead-summary-mode 1)
5651 (let ((name (buffer-name)))
5652 (when (string-match "Summary" name)
5654 (concat (substring name 0 (match-beginning 0)) "Dead "
5655 (substring name (match-beginning 0)))
5659 (defun gnus-kill-or-deaden-summary (buffer)
5660 "Kill or deaden the summary BUFFER."
5662 (when (and (buffer-name buffer)
5663 (not gnus-single-article-buffer))
5666 (gnus-kill-buffer gnus-article-buffer)
5667 (gnus-kill-buffer gnus-original-article-buffer)))
5668 (cond (gnus-kill-summary-on-exit
5669 (when (and gnus-use-trees
5670 (gnus-buffer-exists-p buffer))
5673 (gnus-tree-close gnus-newsgroup-name)))
5674 (gnus-kill-buffer buffer))
5675 ((gnus-buffer-exists-p buffer)
5678 (gnus-deaden-summary))))))
5680 (defun gnus-summary-wake-up-the-dead (&rest args)
5681 "Wake up the dead summary buffer."
5683 (gnus-dead-summary-mode -1)
5684 (let ((name (buffer-name)))
5685 (when (string-match "Dead " name)
5687 (concat (substring name 0 (match-beginning 0))
5688 (substring name (match-end 0)))
5690 (gnus-message 3 "This dead summary is now alive again"))
5692 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5693 (defun gnus-summary-fetch-faq (&optional faq-dir)
5694 "Fetch the FAQ for the current group.
5695 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5699 (when current-prefix-arg
5701 "Faq dir: " (and (listp gnus-group-faq-directory)
5702 (mapcar (lambda (file) (list file))
5703 gnus-group-faq-directory))))))
5704 (let (gnus-faq-buffer)
5705 (when (setq gnus-faq-buffer
5706 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5707 (gnus-configure-windows 'summary-faq))))
5709 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5710 (defun gnus-summary-describe-group (&optional force)
5711 "Describe the current newsgroup."
5713 (gnus-group-describe-group force gnus-newsgroup-name))
5715 (defun gnus-summary-describe-briefly ()
5716 "Describe summary mode commands briefly."
5718 (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")))
5720 ;; Walking around group mode buffer from summary mode.
5722 (defun gnus-summary-next-group (&optional no-article target-group backward)
5723 "Exit current newsgroup and then select next unread newsgroup.
5724 If prefix argument NO-ARTICLE is non-nil, no article is selected
5725 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5726 previous group instead."
5728 ;; Stop pre-fetching.
5729 (gnus-async-halt-prefetch)
5730 (let ((current-group gnus-newsgroup-name)
5731 (current-buffer (current-buffer))
5733 ;; First we semi-exit this group to update Xrefs and all variables.
5734 ;; We can't do a real exit, because the window conf must remain
5735 ;; the same in case the user is prompted for info, and we don't
5736 ;; want the window conf to change before that...
5737 (gnus-summary-exit t)
5738 (while (not entered)
5739 ;; Then we find what group we are supposed to enter.
5740 (set-buffer gnus-group-buffer)
5741 (gnus-group-jump-to-group current-group)
5744 (if (eq gnus-keep-same-level 'best)
5745 (gnus-summary-best-group gnus-newsgroup-name)
5746 (gnus-summary-search-group backward gnus-keep-same-level))))
5747 (if (not target-group)
5748 ;; There are no further groups, so we return to the group
5751 (gnus-message 5 "Returning to the group buffer")
5753 (when (gnus-buffer-live-p current-buffer)
5754 (set-buffer current-buffer)
5755 (gnus-summary-exit))
5756 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5757 ;; We try to enter the target group.
5758 (gnus-group-jump-to-group target-group)
5759 (let ((unreads (gnus-group-group-unread)))
5760 (if (and (or (eq t unreads)
5761 (and unreads (not (zerop unreads))))
5762 (gnus-summary-read-group
5763 target-group nil no-article
5764 (and (buffer-name current-buffer) current-buffer)
5767 (setq current-group target-group
5768 target-group nil)))))))
5770 (defun gnus-summary-prev-group (&optional no-article)
5771 "Exit current newsgroup and then select previous unread newsgroup.
5772 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5774 (gnus-summary-next-group no-article nil t))
5776 ;; Walking around summary lines.
5778 (defun gnus-summary-first-subject (&optional unread undownloaded)
5779 "Go to the first unread subject.
5780 If UNREAD is non-nil, go to the first unread article.
5781 Returns the article selected or nil if there are no unread articles."
5786 ((null gnus-newsgroup-data)
5787 (gnus-message 3 "No articles in the group")
5789 ;; Pick the first article.
5791 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5792 (gnus-data-number (car gnus-newsgroup-data)))
5793 ;; No unread articles.
5794 ((null gnus-newsgroup-unreads)
5795 (gnus-message 3 "No more unread articles")
5797 ;; Find the first unread article.
5799 (let ((data gnus-newsgroup-data))
5801 (and (not (and undownloaded
5802 (eq gnus-undownloaded-mark
5803 (gnus-data-mark (car data)))))
5804 (not (gnus-data-unread-p (car data)))))
5805 (setq data (cdr data)))
5807 (goto-char (gnus-data-pos (car data)))
5808 (gnus-data-number (car data))))))
5809 (gnus-summary-position-point)))
5811 (defun gnus-summary-next-subject (n &optional unread dont-display)
5812 "Go to next N'th summary line.
5813 If N is negative, go to the previous N'th subject line.
5814 If UNREAD is non-nil, only unread articles are selected.
5815 The difference between N and the actual number of steps taken is
5818 (let ((backward (< n 0))
5822 (gnus-summary-find-prev unread)
5823 (gnus-summary-find-next unread)))
5824 (unless (zerop (setq n (1- n)))
5825 (gnus-summary-show-thread)))
5827 (gnus-message 7 "No more%s articles"
5828 (if unread " unread" "")))
5829 (unless dont-display
5830 (gnus-summary-recenter)
5831 (gnus-summary-position-point))
5834 (defun gnus-summary-next-unread-subject (n)
5835 "Go to next N'th unread summary line."
5837 (gnus-summary-next-subject n t))
5839 (defun gnus-summary-prev-subject (n &optional unread)
5840 "Go to previous N'th summary line.
5841 If optional argument UNREAD is non-nil, only unread article is selected."
5843 (gnus-summary-next-subject (- n) unread))
5845 (defun gnus-summary-prev-unread-subject (n)
5846 "Go to previous N'th unread summary line."
5848 (gnus-summary-next-subject (- n) t))
5850 (defun gnus-summary-goto-subject (article &optional force silent)
5851 "Go the subject line of ARTICLE.
5852 If FORCE, also allow jumping to articles not currently shown."
5853 (interactive "nArticle number: ")
5855 (data (gnus-data-find article)))
5856 ;; We read in the article if we have to.
5859 (gnus-summary-insert-subject
5861 (if (or (numberp force) (vectorp force)) force)
5863 (setq data (gnus-data-find article)))
5868 (gnus-message 3 "Can't find article %d" article))
5870 (goto-char (gnus-data-pos data))
5871 (gnus-summary-position-point)
5874 ;; Walking around summary lines with displaying articles.
5876 (defun gnus-summary-expand-window (&optional arg)
5877 "Make the summary buffer take up the entire Emacs frame.
5878 Given a prefix, will force an `article' buffer configuration."
5881 (gnus-configure-windows 'article 'force)
5882 (gnus-configure-windows 'summary 'force)))
5884 (defun gnus-summary-display-article (article &optional all-header)
5885 "Display ARTICLE in article buffer."
5886 (gnus-set-global-variables)
5887 (when (gnus-buffer-live-p gnus-article-buffer)
5888 (with-current-buffer gnus-article-buffer
5889 (setq gnus-article-charset gnus-newsgroup-charset)
5890 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
5891 (mm-enable-multibyte-mule4)))
5895 (if gnus-summary-display-article-function
5896 (funcall gnus-summary-display-article-function article all-header)
5897 (gnus-article-prepare article all-header))
5898 (gnus-run-hooks 'gnus-select-article-hook)
5899 (when (and gnus-current-article
5900 (not (zerop gnus-current-article)))
5901 (gnus-summary-goto-subject gnus-current-article))
5902 (gnus-summary-recenter)
5903 (when (and gnus-use-trees gnus-show-threads)
5904 (gnus-possibly-generate-tree article)
5905 (gnus-highlight-selected-tree article))
5906 ;; Successfully display article.
5907 (gnus-article-set-window-start
5908 (cdr (assq article gnus-newsgroup-bookmarks))))))
5910 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5911 "Select the current article.
5912 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5913 non-nil, the article will be re-fetched even if it already present in
5914 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5916 ;; Make sure we are in the summary buffer to work around bbdb bug.
5917 (unless (eq major-mode 'gnus-summary-mode)
5918 (set-buffer gnus-summary-buffer))
5919 (let ((article (or article (gnus-summary-article-number)))
5920 (all-headers (not (not all-headers))) ;Must be T or NIL.
5921 gnus-summary-display-article-function)
5923 (gnus-summary-article-pseudo-p article)
5924 (error "This is a pseudo-article"))
5926 (set-buffer gnus-summary-buffer)
5927 (if (or (and gnus-single-article-buffer
5928 (or (null gnus-current-article)
5929 (null gnus-article-current)
5930 (null (get-buffer gnus-article-buffer))
5931 (not (eq article (cdr gnus-article-current)))
5932 (not (equal (car gnus-article-current)
5933 gnus-newsgroup-name))))
5934 (and (not gnus-single-article-buffer)
5935 (or (null gnus-current-article)
5936 (not (eq gnus-current-article article))))
5938 ;; The requested article is different from the current article.
5940 (gnus-summary-display-article article all-headers)
5941 (when (gnus-buffer-live-p gnus-article-buffer)
5942 (with-current-buffer gnus-article-buffer
5943 (if (not gnus-article-decoded-p) ;; a local variable
5944 (mm-disable-multibyte-mule4))))
5945 (when (or all-headers gnus-show-all-headers)
5946 (gnus-article-show-all-headers))
5947 (gnus-article-set-window-start
5948 (cdr (assq article gnus-newsgroup-bookmarks)))
5950 (when (or all-headers gnus-show-all-headers)
5951 (gnus-article-show-all-headers))
5954 (defun gnus-summary-force-verify-and-decrypt ()
5956 (let ((mm-verify-option 'known)
5957 (mm-decrypt-option 'known))
5958 (gnus-summary-select-article nil 'force)))
5960 (defun gnus-summary-set-current-mark (&optional current-mark)
5961 "Obsolete function."
5964 (defun gnus-summary-next-article (&optional unread subject backward push)
5965 "Select the next article.
5966 If UNREAD, only unread articles are selected.
5967 If SUBJECT, only articles with SUBJECT are selected.
5968 If BACKWARD, the previous article is selected instead of the next."
5971 ;; Is there such an article?
5972 ((and (gnus-summary-search-forward unread subject backward)
5973 (or (gnus-summary-display-article (gnus-summary-article-number))
5974 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5975 (gnus-summary-position-point))
5976 ;; If not, we try the first unread, if that is wanted.
5978 gnus-auto-select-same
5979 (gnus-summary-first-unread-article))
5980 (gnus-summary-position-point)
5981 (gnus-message 6 "Wrapped"))
5982 ;; Try to get next/previous article not displayed in this group.
5983 ((and gnus-auto-extend-newsgroup
5984 (not unread) (not subject))
5985 (gnus-summary-goto-article
5986 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5987 nil (count-lines (point-min) (point))))
5988 ;; Go to next/previous group.
5990 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5991 (gnus-summary-jump-to-group gnus-newsgroup-name))
5992 (let ((cmd last-command-char)
5995 (set-buffer gnus-group-buffer)
5998 (if (eq gnus-keep-same-level 'best)
5999 (gnus-summary-best-group gnus-newsgroup-name)
6000 (gnus-summary-search-group backward gnus-keep-same-level))))
6001 ;; For some reason, the group window gets selected. We change
6003 (select-window (get-buffer-window (current-buffer)))
6004 ;; Select next unread newsgroup automagically.
6006 ((or (not gnus-auto-select-next)
6008 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6009 ((or (eq gnus-auto-select-next 'quietly)
6010 (and (eq gnus-auto-select-next 'slightly-quietly)
6012 (and (eq gnus-auto-select-next 'almost-quietly)
6013 (gnus-summary-last-article-p)))
6015 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6017 (gnus-message 7 "No more%s articles (%s)..."
6018 (if unread " unread" "")
6019 (if group (concat "selecting " group)
6021 (gnus-summary-next-group nil group backward)))
6023 (when (gnus-key-press-event-p last-input-event)
6024 (gnus-summary-walk-group-buffer
6025 gnus-newsgroup-name cmd unread backward point))))))))
6027 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6028 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6029 (?\C-p (gnus-group-prev-unread-group 1))))
6030 (cursor-in-echo-area t)
6031 keve key group ended)
6033 (set-buffer gnus-group-buffer)
6036 (if (eq gnus-keep-same-level 'best)
6037 (gnus-summary-best-group gnus-newsgroup-name)
6038 (gnus-summary-search-group backward gnus-keep-same-level))))
6041 5 "No more%s articles%s" (if unread " unread" "")
6043 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6044 (format " (Type %s for %s [%s])"
6045 (single-key-description cmd) group
6046 (car (gnus-gethash group gnus-newsrc-hashtb)))
6047 (format " (Type %s to exit %s)"
6048 (single-key-description cmd)
6049 gnus-newsgroup-name)))
6050 ;; Confirm auto selection.
6051 (setq key (car (setq keve (gnus-read-event-char))))
6054 ((assq key keystrokes)
6055 (let ((obuf (current-buffer)))
6056 (switch-to-buffer gnus-group-buffer)
6058 (gnus-group-jump-to-group group))
6059 (eval (cadr (assq key keystrokes)))
6060 (setq group (gnus-group-group-name))
6061 (switch-to-buffer obuf))
6065 (gnus-ephemeral-group-p gnus-newsgroup-name))
6067 (gnus-summary-next-group nil group backward)))
6069 (push (cdr keve) unread-command-events))))))
6071 (defun gnus-summary-next-unread-article ()
6072 "Select unread article after current one."
6074 (gnus-summary-next-article
6075 (or (not (eq gnus-summary-goto-unread 'never))
6076 (gnus-summary-last-article-p (gnus-summary-article-number)))
6077 (and gnus-auto-select-same
6078 (gnus-summary-article-subject))))
6080 (defun gnus-summary-prev-article (&optional unread subject)
6081 "Select the article after the current one.
6082 If UNREAD is non-nil, only unread articles are selected."
6084 (gnus-summary-next-article unread subject t))
6086 (defun gnus-summary-prev-unread-article ()
6087 "Select unread article before current one."
6089 (gnus-summary-prev-article
6090 (or (not (eq gnus-summary-goto-unread 'never))
6091 (gnus-summary-first-article-p (gnus-summary-article-number)))
6092 (and gnus-auto-select-same
6093 (gnus-summary-article-subject))))
6095 (defun gnus-summary-next-page (&optional lines circular)
6096 "Show next page of the selected article.
6097 If at the end of the current article, select the next article.
6098 LINES says how many lines should be scrolled up.
6100 If CIRCULAR is non-nil, go to the start of the article instead of
6101 selecting the next article when reaching the end of the current
6104 (setq gnus-summary-buffer (current-buffer))
6105 (gnus-set-global-variables)
6106 (let ((article (gnus-summary-article-number))
6107 (article-window (get-buffer-window gnus-article-buffer t))
6109 ;; If the buffer is empty, we have no article.
6111 (error "No article to select"))
6112 (gnus-configure-windows 'article)
6113 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6114 (if (and (eq gnus-summary-goto-unread 'never)
6115 (not (gnus-summary-last-article-p article)))
6116 (gnus-summary-next-article)
6117 (gnus-summary-next-unread-article))
6118 (if (or (null gnus-current-article)
6119 (null gnus-article-current)
6120 (/= article (cdr gnus-article-current))
6121 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6122 ;; Selected subject is different from current article's.
6123 (gnus-summary-display-article article)
6124 (when article-window
6125 (gnus-eval-in-buffer-window gnus-article-buffer
6126 (setq endp (gnus-article-next-page lines)))
6129 (gnus-summary-beginning-of-article))
6131 (gnus-message 3 "End of message"))
6133 (if (and (eq gnus-summary-goto-unread 'never)
6134 (not (gnus-summary-last-article-p article)))
6135 (gnus-summary-next-article)
6136 (gnus-summary-next-unread-article))))))))
6137 (gnus-summary-recenter)
6138 (gnus-summary-position-point)))
6140 (defun gnus-summary-prev-page (&optional lines move)
6141 "Show previous page of selected article.
6142 Argument LINES specifies lines to be scrolled down.
6143 If MOVE, move to the previous unread article if point is at
6144 the beginning of the buffer."
6146 (let ((article (gnus-summary-article-number))
6147 (article-window (get-buffer-window gnus-article-buffer t))
6149 (gnus-configure-windows 'article)
6150 (if (or (null gnus-current-article)
6151 (null gnus-article-current)
6152 (/= article (cdr gnus-article-current))
6153 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6154 ;; Selected subject is different from current article's.
6155 (gnus-summary-display-article article)
6156 (gnus-summary-recenter)
6157 (when article-window
6158 (gnus-eval-in-buffer-window gnus-article-buffer
6159 (setq endp (gnus-article-prev-page lines)))
6160 (when (and move endp)
6162 (gnus-message 3 "Beginning of message"))
6164 (if (and (eq gnus-summary-goto-unread 'never)
6165 (not (gnus-summary-first-article-p article)))
6166 (gnus-summary-prev-article)
6167 (gnus-summary-prev-unread-article))))))))
6168 (gnus-summary-position-point))
6170 (defun gnus-summary-prev-page-or-article (&optional lines)
6171 "Show previous page of selected article.
6172 Argument LINES specifies lines to be scrolled down.
6173 If at the beginning of the article, go to the next article."
6175 (gnus-summary-prev-page lines t))
6177 (defun gnus-summary-scroll-up (lines)
6178 "Scroll up (or down) one line current article.
6179 Argument LINES specifies lines to be scrolled up (or down if negative)."
6181 (gnus-configure-windows 'article)
6182 (gnus-summary-show-thread)
6183 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6184 (gnus-eval-in-buffer-window gnus-article-buffer
6186 (when (gnus-article-next-page lines)
6187 (gnus-message 3 "End of message")))
6189 (gnus-article-prev-page (- lines))))))
6190 (gnus-summary-recenter)
6191 (gnus-summary-position-point))
6193 (defun gnus-summary-scroll-down (lines)
6194 "Scroll down (or up) one line current article.
6195 Argument LINES specifies lines to be scrolled down (or up if negative)."
6197 (gnus-summary-scroll-up (- lines)))
6199 (defun gnus-summary-next-same-subject ()
6200 "Select next article which has the same subject as current one."
6202 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6204 (defun gnus-summary-prev-same-subject ()
6205 "Select previous article which has the same subject as current one."
6207 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6209 (defun gnus-summary-next-unread-same-subject ()
6210 "Select next unread article which has the same subject as current one."
6212 (gnus-summary-next-article t (gnus-summary-article-subject)))
6214 (defun gnus-summary-prev-unread-same-subject ()
6215 "Select previous unread article which has the same subject as current one."
6217 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6219 (defun gnus-summary-first-unread-article ()
6220 "Select the first unread article.
6221 Return nil if there are no unread articles."
6224 (when (gnus-summary-first-subject t)
6225 (gnus-summary-show-thread)
6226 (gnus-summary-first-subject t)
6227 (gnus-summary-display-article (gnus-summary-article-number)))
6228 (gnus-summary-position-point)))
6230 (defun gnus-summary-first-unread-subject ()
6231 "Place the point on the subject line of the first unread article.
6232 Return nil if there are no unread articles."
6235 (when (gnus-summary-first-subject t)
6236 (gnus-summary-show-thread)
6237 (gnus-summary-first-subject t))
6238 (gnus-summary-position-point)))
6240 (defun gnus-summary-first-article ()
6241 "Select the first article.
6242 Return nil if there are no articles."
6245 (when (gnus-summary-first-subject)
6246 (gnus-summary-show-thread)
6247 (gnus-summary-first-subject)
6248 (gnus-summary-display-article (gnus-summary-article-number)))
6249 (gnus-summary-position-point)))
6251 (defun gnus-summary-best-unread-article ()
6252 "Select the unread article with the highest score."
6254 (let ((best -1000000)
6255 (data gnus-newsgroup-data)
6258 (and (gnus-data-unread-p (car data))
6260 (gnus-summary-article-score (gnus-data-number (car data))))
6263 article (gnus-data-number (car data))))
6264 (setq data (cdr data)))
6267 (gnus-summary-goto-article article)
6268 (error "No unread articles"))
6269 (gnus-summary-position-point))))
6271 (defun gnus-summary-last-subject ()
6272 "Go to the last displayed subject line in the group."
6273 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6275 (gnus-summary-goto-subject article))))
6277 (defun gnus-summary-goto-article (article &optional all-headers force)
6278 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6279 If ALL-HEADERS is non-nil, no header lines are hidden.
6280 If FORCE, go to the article even if it isn't displayed. If FORCE
6281 is a number, it is the line the article is to be displayed on."
6285 "Article number or Message-ID: "
6286 (mapcar (lambda (number) (list (int-to-string number)))
6287 gnus-newsgroup-limit))
6291 (if (and (stringp article)
6292 (string-match "@" article))
6293 (gnus-summary-refer-article article)
6294 (when (stringp article)
6295 (setq article (string-to-number article)))
6296 (if (gnus-summary-goto-subject article force)
6297 (gnus-summary-display-article article all-headers)
6298 (gnus-message 4 "Couldn't go to article %s" article) nil))
6299 (gnus-summary-position-point)))
6301 (defun gnus-summary-goto-last-article ()
6302 "Go to the previously read article."
6305 (when gnus-last-article
6306 (gnus-summary-goto-article gnus-last-article nil t))
6307 (gnus-summary-position-point)))
6309 (defun gnus-summary-pop-article (number)
6310 "Pop one article off the history and go to the previous.
6311 NUMBER articles will be popped off."
6314 (setq gnus-newsgroup-history
6315 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6317 (gnus-summary-goto-article (car to) nil t)
6318 (error "Article history empty")))
6319 (gnus-summary-position-point))
6321 ;; Summary commands and functions for limiting the summary buffer.
6323 (defun gnus-summary-limit-to-articles (n)
6324 "Limit the summary buffer to the next N articles.
6325 If not given a prefix, use the process marked articles instead."
6328 (let ((articles (gnus-summary-work-articles n)))
6329 (setq gnus-newsgroup-processable nil)
6330 (gnus-summary-limit articles))
6331 (gnus-summary-position-point)))
6333 (defun gnus-summary-pop-limit (&optional total)
6334 "Restore the previous limit.
6335 If given a prefix, remove all limits."
6338 (setq gnus-newsgroup-limits
6339 (list (mapcar (lambda (h) (mail-header-number h))
6340 gnus-newsgroup-headers))))
6341 (unless gnus-newsgroup-limits
6342 (error "No limit to pop"))
6344 (gnus-summary-limit nil 'pop)
6345 (gnus-summary-position-point)))
6347 (defun gnus-summary-limit-to-subject (subject &optional header)
6348 "Limit the summary buffer to articles that have subjects that match a regexp."
6349 (interactive "sLimit to subject (regexp): ")
6351 (setq header "subject"))
6352 (when (not (equal "" subject))
6354 (let ((articles (gnus-summary-find-matching
6355 (or header "subject") subject 'all)))
6357 (error "Found no matches for \"%s\"" subject))
6358 (gnus-summary-limit articles))
6359 (gnus-summary-position-point))))
6361 (defun gnus-summary-limit-to-author (from)
6362 "Limit the summary buffer to articles that have authors that match a regexp."
6363 (interactive "sLimit to author (regexp): ")
6364 (gnus-summary-limit-to-subject from "from"))
6366 (defun gnus-summary-limit-to-age (age &optional younger-p)
6367 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6368 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6369 articles that are younger than AGE days."
6371 (let ((younger current-prefix-arg)
6374 (while (not days-got)
6375 (setq days (if younger
6376 (read-string "Limit to articles within (in days): ")
6377 (read-string "Limit to articles old than (in days): ")))
6378 (when (> (length days) 0)
6379 (setq days (read days)))
6382 (message "Please enter a number.")
6384 (list days younger)))
6386 (let ((data gnus-newsgroup-data)
6387 (cutoff (days-to-time age))
6388 articles d date is-younger)
6389 (while (setq d (pop data))
6390 (when (and (vectorp (gnus-data-header d))
6391 (setq date (mail-header-date (gnus-data-header d))))
6392 (setq is-younger (time-less-p
6393 (time-since (condition-case ()
6400 (push (gnus-data-number d) articles))))
6401 (gnus-summary-limit (nreverse articles)))
6402 (gnus-summary-position-point)))
6404 (defun gnus-summary-limit-to-extra (header regexp)
6405 "Limit the summary buffer to articles that match an 'extra' header."
6409 (gnus-completing-read
6410 (symbol-name (car gnus-extra-headers))
6411 "Limit extra header:"
6413 (cons (symbol-name x) x))
6418 (read-string (format "Limit to header %s (regexp): " header)))))
6419 (when (not (equal "" regexp))
6421 (let ((articles (gnus-summary-find-matching
6422 (cons 'extra header) regexp 'all)))
6424 (error "Found no matches for \"%s\"" regexp))
6425 (gnus-summary-limit articles))
6426 (gnus-summary-position-point))))
6428 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6430 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6432 (defun gnus-summary-limit-to-unread (&optional all)
6433 "Limit the summary buffer to articles that are not marked as read.
6434 If ALL is non-nil, limit strictly to unread articles."
6437 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6438 (gnus-summary-limit-to-marks
6439 ;; Concat all the marks that say that an article is read and have
6441 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6442 gnus-killed-mark gnus-kill-file-mark
6443 gnus-low-score-mark gnus-expirable-mark
6444 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6445 gnus-duplicate-mark gnus-souped-mark)
6448 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6449 (make-obsolete 'gnus-summary-delete-marked-with
6450 'gnus-summary-limit-exlude-marks)
6452 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6453 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6454 If REVERSE, limit the summary buffer to articles that are marked
6455 with MARKS. MARKS can either be a string of marks or a list of marks.
6456 Returns how many articles were removed."
6457 (interactive "sMarks: ")
6458 (gnus-summary-limit-to-marks marks t))
6460 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6461 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6462 If REVERSE (the prefix), limit the summary buffer to articles that are
6463 not marked with MARKS. MARKS can either be a string of marks or a
6465 Returns how many articles were removed."
6466 (interactive "sMarks: \nP")
6468 (let ((data gnus-newsgroup-data)
6469 (marks (if (listp marks) marks
6470 (append marks nil))) ; Transform to list.
6473 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6474 (memq (gnus-data-mark (car data)) marks))
6475 (push (gnus-data-number (car data)) articles))
6476 (setq data (cdr data)))
6477 (gnus-summary-limit articles))
6478 (gnus-summary-position-point)))
6480 (defun gnus-summary-limit-to-score (&optional score)
6481 "Limit to articles with score at or above SCORE."
6483 (setq score (if score
6484 (prefix-numeric-value score)
6485 (or gnus-summary-default-score 0)))
6486 (let ((data gnus-newsgroup-data)
6489 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6491 (push (gnus-data-number (car data)) articles))
6492 (setq data (cdr data)))
6494 (gnus-summary-limit articles)
6495 (gnus-summary-position-point))))
6497 (defun gnus-summary-limit-include-thread (id)
6498 "Display all the hidden articles that in the current thread."
6499 (interactive (list (mail-header-id (gnus-summary-article-header))))
6500 (let ((articles (gnus-articles-in-thread
6501 (gnus-id-to-thread (gnus-root-id id)))))
6503 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6504 (gnus-summary-position-point))))
6506 (defun gnus-summary-limit-include-dormant ()
6507 "Display all the hidden articles that are marked as dormant.
6508 Note that this command only works on a subset of the articles currently
6509 fetched for this group."
6511 (unless gnus-newsgroup-dormant
6512 (error "There are no dormant articles in this group"))
6514 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6515 (gnus-summary-position-point)))
6517 (defun gnus-summary-limit-exclude-dormant ()
6518 "Hide all dormant articles."
6521 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6522 (gnus-summary-position-point)))
6524 (defun gnus-summary-limit-exclude-childless-dormant ()
6525 "Hide all dormant articles that have no children."
6527 (let ((data (gnus-data-list t))
6528 articles d children)
6529 ;; Find all articles that are either not dormant or have
6531 (while (setq d (pop data))
6532 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6534 (gnus-article-children (gnus-data-number d)))
6537 (when (memq (car children) articles)
6542 (push (gnus-data-number d) articles)))
6545 (gnus-summary-limit articles)
6546 (gnus-summary-position-point))))
6548 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6549 "Mark all unread excluded articles as read.
6550 If ALL, mark even excluded ticked and dormants as read."
6552 (let ((articles (gnus-sorted-complement
6554 (mapcar (lambda (h) (mail-header-number h))
6555 gnus-newsgroup-headers)
6557 (sort gnus-newsgroup-limit '<)))
6559 (setq gnus-newsgroup-unreads
6560 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6562 (setq gnus-newsgroup-dormant nil
6563 gnus-newsgroup-marked nil
6564 gnus-newsgroup-reads
6566 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6567 gnus-newsgroup-reads))
6568 (while (setq article (pop articles))
6569 (unless (or (memq article gnus-newsgroup-dormant)
6570 (memq article gnus-newsgroup-marked))
6571 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6573 (defun gnus-summary-limit (articles &optional pop)
6575 ;; We pop the previous limit off the stack and use that.
6576 (setq articles (car gnus-newsgroup-limits)
6577 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6578 ;; We use the new limit, so we push the old limit on the stack.
6579 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6581 (setq gnus-newsgroup-limit articles)
6582 (let ((total (length gnus-newsgroup-data))
6583 (data (gnus-data-find-list (gnus-summary-article-number)))
6584 (gnus-summary-mark-below nil) ; Inhibit this.
6586 ;; This will do all the work of generating the new summary buffer
6587 ;; according to the new limit.
6588 (gnus-summary-prepare)
6589 ;; Hide any threads, possibly.
6590 (and gnus-show-threads
6591 gnus-thread-hide-subtree
6592 (gnus-summary-hide-all-threads))
6593 ;; Try to return to the article you were at, or one in the
6596 ;; We try to find some article after the current one.
6598 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6601 (setq data (cdr data))))
6603 ;; If there is no data, that means that we were after the last
6604 ;; article. The same goes when we can't find any articles
6605 ;; after the current one.
6606 (goto-char (point-max))
6607 (gnus-summary-find-prev))
6608 (gnus-set-mode-line 'summary)
6609 ;; We return how many articles were removed from the summary
6610 ;; buffer as a result of the new limit.
6611 (- total (length gnus-newsgroup-data))))
6613 (defsubst gnus-invisible-cut-children (threads)
6616 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6621 (defsubst gnus-cut-thread (thread)
6622 "Go forwards in the thread until we find an article that we want to display."
6623 (when (or (eq gnus-fetch-old-headers 'some)
6624 (eq gnus-fetch-old-headers 'invisible)
6625 (numberp gnus-fetch-old-headers)
6626 (eq gnus-build-sparse-threads 'some)
6627 (eq gnus-build-sparse-threads 'more))
6628 ;; Deal with old-fetched headers and sparse threads.
6632 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6633 (gnus-summary-article-ancient-p
6634 (mail-header-number (car thread))))
6635 (if (or (<= (length (cdr thread)) 1)
6636 (eq gnus-fetch-old-headers 'invisible))
6637 (setq gnus-newsgroup-limit
6638 (delq (mail-header-number (car thread))
6639 gnus-newsgroup-limit)
6640 thread (cadr thread))
6641 (when (gnus-invisible-cut-children (cdr thread))
6642 (let ((th (cdr thread)))
6644 (if (memq (mail-header-number (caar th))
6645 gnus-newsgroup-limit)
6646 (setq thread (car th)
6648 (setq th (cdr th))))))))))
6651 (defun gnus-cut-threads (threads)
6652 "Cut off all uninteresting articles from the beginning of threads."
6653 (when (or (eq gnus-fetch-old-headers 'some)
6654 (eq gnus-fetch-old-headers 'invisible)
6655 (numberp gnus-fetch-old-headers)
6656 (eq gnus-build-sparse-threads 'some)
6657 (eq gnus-build-sparse-threads 'more))
6660 (setcar th (gnus-cut-thread (car th)))
6661 (setq th (cdr th)))))
6662 ;; Remove nixed out threads.
6665 (defun gnus-summary-initial-limit (&optional show-if-empty)
6666 "Figure out what the initial limit is supposed to be on group entry.
6667 This entails weeding out unwanted dormants, low-scored articles,
6668 fetch-old-headers verbiage, and so on."
6669 ;; Most groups have nothing to remove.
6670 (if (or gnus-inhibit-limiting
6671 (and (null gnus-newsgroup-dormant)
6672 (not (eq gnus-fetch-old-headers 'some))
6673 (not (numberp gnus-fetch-old-headers))
6674 (not (eq gnus-fetch-old-headers 'invisible))
6675 (null gnus-summary-expunge-below)
6676 (not (eq gnus-build-sparse-threads 'some))
6677 (not (eq gnus-build-sparse-threads 'more))
6678 (null gnus-thread-expunge-below)
6679 (not gnus-use-nocem)))
6681 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6682 (setq gnus-newsgroup-limit nil)
6685 (unless (car (symbol-value node))
6686 ;; These threads have no parents -- they are roots.
6687 (let ((nodes (cdr (symbol-value node)))
6690 (if (and gnus-thread-expunge-below
6691 (< (gnus-thread-total-score (car nodes))
6692 gnus-thread-expunge-below))
6693 (gnus-expunge-thread (pop nodes))
6694 (setq thread (pop nodes))
6695 (gnus-summary-limit-children thread))))))
6696 gnus-newsgroup-dependencies)
6697 ;; If this limitation resulted in an empty group, we might
6698 ;; pop the previous limit and use it instead.
6699 (when (and (not gnus-newsgroup-limit)
6701 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6702 gnus-newsgroup-limit))
6704 (defun gnus-summary-limit-children (thread)
6705 "Return 1 if this subthread is visible and 0 if it is not."
6706 ;; First we get the number of visible children to this thread. This
6707 ;; is done by recursing down the thread using this function, so this
6708 ;; will really go down to a leaf article first, before slowly
6709 ;; working its way up towards the root.
6713 (apply '+ (mapcar 'gnus-summary-limit-children
6716 (number (mail-header-number (car thread)))
6719 (not (memq number gnus-newsgroup-marked))
6721 ;; If this article is dormant and has absolutely no visible
6722 ;; children, then this article isn't visible.
6723 (and (memq number gnus-newsgroup-dormant)
6725 ;; If this is "fetch-old-headered" and there is no
6726 ;; visible children, then we don't want this article.
6727 (and (or (eq gnus-fetch-old-headers 'some)
6728 (numberp gnus-fetch-old-headers))
6729 (gnus-summary-article-ancient-p number)
6731 ;; If this is "fetch-old-headered" and `invisible', then
6732 ;; we don't want this article.
6733 (and (eq gnus-fetch-old-headers 'invisible)
6734 (gnus-summary-article-ancient-p number))
6735 ;; If this is a sparsely inserted article with no children,
6736 ;; we don't want it.
6737 (and (eq gnus-build-sparse-threads 'some)
6738 (gnus-summary-article-sparse-p number)
6740 ;; If we use expunging, and this article is really
6741 ;; low-scored, then we don't want this article.
6742 (when (and gnus-summary-expunge-below
6744 (or (cdr (assq number gnus-newsgroup-scored))
6745 gnus-summary-default-score))
6746 gnus-summary-expunge-below))
6747 ;; We increase the expunge-tally here, but that has
6748 ;; nothing to do with the limits, really.
6749 (incf gnus-newsgroup-expunged-tally)
6750 ;; We also mark as read here, if that's wanted.
6751 (when (and gnus-summary-mark-below
6752 (< score gnus-summary-mark-below))
6753 (setq gnus-newsgroup-unreads
6754 (delq number gnus-newsgroup-unreads))
6755 (if gnus-newsgroup-auto-expire
6756 (push number gnus-newsgroup-expirable)
6757 (push (cons number gnus-low-score-mark)
6758 gnus-newsgroup-reads)))
6760 ;; Check NoCeM things.
6761 (if (and gnus-use-nocem
6762 (gnus-nocem-unwanted-article-p
6763 (mail-header-id (car thread))))
6765 (setq gnus-newsgroup-unreads
6766 (delq number gnus-newsgroup-unreads))
6768 ;; Nope, invisible article.
6770 ;; Ok, this article is to be visible, so we add it to the limit
6772 (push number gnus-newsgroup-limit)
6775 (defun gnus-expunge-thread (thread)
6776 "Mark all articles in THREAD as read."
6777 (let* ((number (mail-header-number (car thread))))
6778 (incf gnus-newsgroup-expunged-tally)
6779 ;; We also mark as read here, if that's wanted.
6780 (setq gnus-newsgroup-unreads
6781 (delq number gnus-newsgroup-unreads))
6782 (if gnus-newsgroup-auto-expire
6783 (push number gnus-newsgroup-expirable)
6784 (push (cons number gnus-low-score-mark)
6785 gnus-newsgroup-reads)))
6786 ;; Go recursively through all subthreads.
6787 (mapcar 'gnus-expunge-thread (cdr thread)))
6789 ;; Summary article oriented commands
6791 (defun gnus-summary-refer-parent-article (n)
6792 "Refer parent article N times.
6793 If N is negative, go to ancestor -N instead.
6794 The difference between N and the number of articles fetched is returned."
6798 (when (not (natnump n))
6803 (setq header (gnus-summary-article-header))
6804 (if (and (eq (mail-header-number header)
6805 (cdr gnus-article-current))
6806 (equal gnus-newsgroup-name
6807 (car gnus-article-current)))
6808 ;; If we try to find the parent of the currently
6809 ;; displayed article, then we take a look at the actual
6810 ;; References header, since this is slightly more
6811 ;; reliable than the References field we got from the
6814 (set-buffer gnus-original-article-buffer)
6815 (nnheader-narrow-to-headers)
6816 (unless (setq ref (message-fetch-field "references"))
6817 (setq ref (message-fetch-field "in-reply-to")))
6820 ;; It's not the current article, so we take a bet on
6821 ;; the value we got from the server.
6822 (mail-header-references header)))
6824 (not (equal ref "")))
6825 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6826 (gnus-message 1 "Couldn't find parent"))
6827 (gnus-message 1 "No references in article %d"
6828 (gnus-summary-article-number))
6831 (gnus-summary-position-point)
6834 (defun gnus-summary-refer-references ()
6835 "Fetch all articles mentioned in the References header.
6836 Return the number of articles fetched."
6838 (let ((ref (mail-header-references (gnus-summary-article-header)))
6839 (current (gnus-summary-article-number))
6843 (error "No References in the current article")
6844 ;; For each Message-ID in the References header...
6845 (while (string-match "<[^>]*>" ref)
6847 ;; ... fetch that article.
6848 (gnus-summary-refer-article
6849 (prog1 (match-string 0 ref)
6850 (setq ref (substring ref (match-end 0))))))
6851 (gnus-summary-goto-subject current)
6852 (gnus-summary-position-point)
6855 (defun gnus-summary-refer-thread (&optional limit)
6856 "Fetch all articles in the current thread.
6857 If LIMIT (the numerical prefix), fetch that many old headers instead
6858 of what's specified by the `gnus-refer-thread-limit' variable."
6860 (let ((id (mail-header-id (gnus-summary-article-header)))
6861 (limit (if limit (prefix-numeric-value limit)
6862 gnus-refer-thread-limit)))
6863 ;; We want to fetch LIMIT *old* headers, but we also have to
6864 ;; re-fetch all the headers in the current buffer, because many of
6865 ;; them may be undisplayed. So we adjust LIMIT.
6866 (when (numberp limit)
6867 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6868 (unless (eq gnus-fetch-old-headers 'invisible)
6869 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6870 ;; Retrieve the headers and read them in.
6871 (if (eq (gnus-retrieve-headers
6872 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6874 (gnus-build-all-threads)
6875 (error "Can't fetch thread from backends that don't support NOV"))
6876 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6877 (gnus-summary-limit-include-thread id)))
6879 (defun gnus-summary-refer-article (message-id)
6880 "Fetch an article specified by MESSAGE-ID."
6881 (interactive "sMessage-ID: ")
6882 (when (and (stringp message-id)
6883 (not (zerop (length message-id))))
6884 ;; Construct the correct Message-ID if necessary.
6885 ;; Suggested by tale@pawl.rpi.edu.
6886 (unless (string-match "^<" message-id)
6887 (setq message-id (concat "<" message-id)))
6888 (unless (string-match ">$" message-id)
6889 (setq message-id (concat message-id ">")))
6890 (let* ((header (gnus-id-to-header message-id))
6892 (gnus-summary-article-sparse-p
6893 (mail-header-number header))
6894 (memq (mail-header-number header)
6895 gnus-newsgroup-limit)))
6898 ;; If the article is present in the buffer we just go to it.
6900 (or (not (gnus-summary-article-sparse-p
6901 (mail-header-number header)))
6904 (gnus-summary-goto-article
6905 (mail-header-number header) nil t)
6907 (gnus-summary-update-article (mail-header-number header)))))
6909 ;; We fetch the article.
6911 (dolist (gnus-override-method (gnus-refer-article-methods))
6912 (gnus-check-server gnus-override-method)
6913 ;; Fetch the header, and display the article.
6914 (when (setq number (gnus-summary-insert-subject message-id))
6915 (gnus-summary-select-article nil nil nil number)
6917 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6919 (defun gnus-refer-article-methods ()
6920 "Return a list of referrable methods."
6922 ;; No method, so we default to current and native.
6923 ((null gnus-refer-article-method)
6924 (list gnus-current-select-method gnus-select-method))
6926 ((eq 'current gnus-refer-article-method)
6927 (list gnus-current-select-method))
6928 ;; List of select methods.
6929 ((not (and (symbolp (car gnus-refer-article-method))
6930 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6932 (dolist (method gnus-refer-article-method)
6933 (push (if (eq 'current method)
6934 gnus-current-select-method
6938 ;; One single select method.
6940 (list gnus-refer-article-method))))
6942 (defun gnus-summary-edit-parameters ()
6943 "Edit the group parameters of the current group."
6945 (gnus-group-edit-group gnus-newsgroup-name 'params))
6947 (defun gnus-summary-customize-parameters ()
6948 "Customize the group parameters of the current group."
6950 (gnus-group-customize gnus-newsgroup-name))
6952 (defun gnus-summary-enter-digest-group (&optional force)
6953 "Enter an nndoc group based on the current article.
6954 If FORCE, force a digest interpretation. If not, try
6955 to guess what the document format is."
6957 (let ((conf gnus-current-window-configuration))
6959 (gnus-summary-select-article))
6960 (setq gnus-current-window-configuration conf)
6961 (let* ((name (format "%s-%d"
6962 (gnus-group-prefixed-name
6963 gnus-newsgroup-name (list 'nndoc ""))
6965 (set-buffer gnus-summary-buffer)
6966 gnus-current-article)))
6967 (ogroup gnus-newsgroup-name)
6968 (params (append (gnus-info-params (gnus-get-info ogroup))
6969 (list (cons 'to-group ogroup))
6970 (list (cons 'save-article-group ogroup))))
6971 (case-fold-search t)
6972 (buf (current-buffer))
6975 (set-buffer gnus-original-article-buffer)
6976 ;; Have the digest group inherit the main mail address of
6977 ;; the parent article.
6978 (when (setq to-address (or (message-fetch-field "reply-to")
6979 (message-fetch-field "from")))
6980 (setq params (append
6981 (list (cons 'to-address
6982 (funcall gnus-decode-encoded-word-function
6984 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6985 (insert-buffer-substring gnus-original-article-buffer)
6986 ;; Remove lines that may lead nndoc to misinterpret the
6989 (goto-char (point-min))
6990 (or (search-forward "\n\n" nil t) (point)))
6991 (goto-char (point-min))
6992 (delete-matching-lines "^Path:\\|^From ")
6995 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6996 (gnus-newsgroup-ephemeral-ignored-charsets
6997 gnus-newsgroup-ignored-charsets))
6998 (gnus-group-read-ephemeral-group
6999 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7001 ,(if force 'mbox 'guess))) t))
7002 ;; Make all postings to this group go to the parent group.
7003 (nconc (gnus-info-params (gnus-get-info name))
7005 ;; Couldn't select this doc group.
7006 (switch-to-buffer buf)
7007 (gnus-set-global-variables)
7008 (gnus-configure-windows 'summary)
7009 (gnus-message 3 "Article couldn't be entered?"))
7010 (kill-buffer dig)))))
7012 (defun gnus-summary-read-document (n)
7013 "Open a new group based on the current article(s).
7014 This will allow you to read digests and other similar
7015 documents as newsgroups.
7016 Obeys the standard process/prefix convention."
7018 (let* ((articles (gnus-summary-work-articles n))
7019 (ogroup gnus-newsgroup-name)
7020 (params (append (gnus-info-params (gnus-get-info ogroup))
7021 (list (cons 'to-group ogroup))))
7022 article group egroup groups vgroup)
7023 (while (setq article (pop articles))
7024 (setq group (format "%s-%d" gnus-newsgroup-name article))
7025 (gnus-summary-remove-process-mark article)
7026 (when (gnus-summary-display-article article)
7029 (insert-buffer-substring gnus-original-article-buffer)
7030 ;; Remove some headers that may lead nndoc to make
7032 (message-narrow-to-head)
7033 (goto-char (point-min))
7034 (delete-matching-lines "^\\(Path\\):\\|^From ")
7037 (gnus-group-read-ephemeral-group
7038 group `(nndoc ,group (nndoc-address ,(current-buffer))
7039 (nndoc-article-type guess))
7042 ;; Make all postings to this group go to the parent group.
7043 (nconc (gnus-info-params (gnus-get-info egroup))
7045 (push egroup groups))
7046 ;; Couldn't select this doc group.
7047 (gnus-error 3 "Article couldn't be entered"))))))
7048 ;; Now we have selected all the documents.
7051 (error "None of the articles could be interpreted as documents"))
7052 ((gnus-group-read-ephemeral-group
7053 (setq vgroup (format
7054 "nnvirtual:%s-%s" gnus-newsgroup-name
7055 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7056 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7058 (cons (current-buffer) 'summary)))
7060 (error "Couldn't select virtual nndoc group")))))
7062 (defun gnus-summary-isearch-article (&optional regexp-p)
7063 "Do incremental search forward on the current article.
7064 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7066 (gnus-summary-select-article)
7067 (gnus-configure-windows 'article)
7068 (gnus-eval-in-buffer-window gnus-article-buffer
7071 (isearch-forward regexp-p))))
7073 (defun gnus-summary-search-article-forward (regexp &optional backward)
7074 "Search for an article containing REGEXP forward.
7075 If BACKWARD, search backward instead."
7078 (format "Search article %s (regexp%s): "
7079 (if current-prefix-arg "backward" "forward")
7080 (if gnus-last-search-regexp
7081 (concat ", default " gnus-last-search-regexp)
7083 current-prefix-arg))
7084 (if (string-equal regexp "")
7085 (setq regexp (or gnus-last-search-regexp ""))
7086 (setq gnus-last-search-regexp regexp)
7087 (setq gnus-article-before-search gnus-current-article))
7088 ;; Intentionally set gnus-last-article.
7089 (setq gnus-last-article gnus-article-before-search)
7090 (let ((gnus-last-article gnus-last-article))
7091 (if (gnus-summary-search-article regexp backward)
7092 (gnus-summary-show-thread)
7093 (error "Search failed: \"%s\"" regexp))))
7095 (defun gnus-summary-search-article-backward (regexp)
7096 "Search for an article containing REGEXP backward."
7099 (format "Search article backward (regexp%s): "
7100 (if gnus-last-search-regexp
7101 (concat ", default " gnus-last-search-regexp)
7103 (gnus-summary-search-article-forward regexp 'backward))
7105 (defun gnus-summary-search-article (regexp &optional backward)
7106 "Search for an article containing REGEXP.
7107 Optional argument BACKWARD means do search for backward.
7108 `gnus-select-article-hook' is not called during the search."
7109 ;; We have to require this here to make sure that the following
7110 ;; dynamic binding isn't shadowed by autoloading.
7111 (require 'gnus-async)
7113 (let ((gnus-select-article-hook nil) ;Disable hook.
7114 (gnus-article-prepare-hook nil)
7115 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7116 (gnus-use-article-prefetch nil)
7117 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7118 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7119 (sum (current-buffer))
7120 (gnus-display-mime-function nil)
7123 (gnus-save-hidden-threads
7124 (gnus-summary-select-article)
7125 (set-buffer gnus-article-buffer)
7126 (goto-char (window-point (get-buffer-window (current-buffer))))
7130 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7132 (re-search-backward regexp nil t)
7133 (re-search-forward regexp nil t))
7134 ;; We found the regexp.
7139 (get-buffer-window (current-buffer))
7143 (get-buffer-window (current-buffer))
7146 (setq point (point)))
7147 ;; We didn't find it, so we go to the next article.
7150 (while (eq found 'not)
7151 (if (not (if backward (gnus-summary-find-prev)
7152 (gnus-summary-find-next)))
7153 ;; No more articles.
7155 ;; Select the next article and adjust point.
7156 (unless (gnus-summary-article-sparse-p
7157 (gnus-summary-article-number))
7159 (gnus-summary-select-article)
7160 (set-buffer gnus-article-buffer)
7162 (goto-char (if backward (point-max) (point-min))))))))
7163 (gnus-message 7 ""))
7164 ;; Return whether we found the regexp.
7165 (when (eq found 'found)
7167 (gnus-summary-show-thread)
7168 (gnus-summary-goto-subject gnus-current-article)
7169 (gnus-summary-position-point)
7172 (defun gnus-summary-find-matching (header regexp &optional backward unread
7174 "Return a list of all articles that match REGEXP on HEADER.
7175 The search stars on the current article and goes forwards unless
7176 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7177 If UNREAD is non-nil, only unread articles will
7178 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7179 in the comparisons."
7180 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7181 (gnus-data-find-list
7182 (gnus-summary-article-number) (gnus-data-list backward))))
7183 (case-fold-search (not not-case-fold))
7186 (if (eq (car header) 'extra)
7189 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7191 (error "%s is an invalid header" header))
7192 (unless (fboundp (intern (concat "mail-header-" header)))
7193 (error "%s is not a valid header" header))
7194 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7197 (and (or (not unread) ; We want all articles...
7198 (gnus-data-unread-p d)) ; Or just unreads.
7199 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7200 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7201 (push (gnus-data-number d) articles)) ; Success!
7202 (setq data (cdr data)))
7203 (nreverse articles)))
7205 (defun gnus-summary-execute-command (header regexp command &optional backward)
7206 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7207 If HEADER is an empty string (or nil), the match is done on the entire
7208 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7210 (list (let ((completion-ignore-case t))
7213 (mapcar (lambda (string) (list string))
7214 '("Number" "Subject" "From" "Lines" "Date"
7215 "Message-ID" "Xref" "References" "Body"))
7216 nil 'require-match))
7217 (read-string "Regexp: ")
7218 (read-key-sequence "Command: ")
7219 current-prefix-arg))
7220 (when (equal header "Body")
7222 ;; Hidden thread subtrees must be searched as well.
7223 (gnus-summary-show-all-threads)
7224 ;; We don't want to change current point nor window configuration.
7226 (save-window-excursion
7227 (gnus-message 6 "Executing %s..." (key-description command))
7228 ;; We'd like to execute COMMAND interactively so as to give arguments.
7229 (gnus-execute header regexp
7230 `(call-interactively ',(key-binding command))
7232 (gnus-message 6 "Executing %s...done" (key-description command)))))
7234 (defun gnus-summary-beginning-of-article ()
7235 "Scroll the article back to the beginning."
7237 (gnus-summary-select-article)
7238 (gnus-configure-windows 'article)
7239 (gnus-eval-in-buffer-window gnus-article-buffer
7241 (goto-char (point-min))
7242 (when gnus-page-broken
7243 (gnus-narrow-to-page))))
7245 (defun gnus-summary-end-of-article ()
7246 "Scroll to the end of the article."
7248 (gnus-summary-select-article)
7249 (gnus-configure-windows 'article)
7250 (gnus-eval-in-buffer-window gnus-article-buffer
7252 (goto-char (point-max))
7254 (when gnus-page-broken
7255 (gnus-narrow-to-page))))
7257 (defun gnus-summary-print-article (&optional filename n)
7258 "Generate and print a PostScript image of the N next (mail) articles.
7260 If N is negative, print the N previous articles. If N is nil and articles
7261 have been marked with the process mark, print these instead.
7263 If the optional first argument FILENAME is nil, send the image to the
7264 printer. If FILENAME is a string, save the PostScript image in a file with
7265 that name. If FILENAME is a number, prompt the user for the name of the file
7267 (interactive (list (ps-print-preprint current-prefix-arg)
7268 current-prefix-arg))
7269 (dolist (article (gnus-summary-work-articles n))
7270 (gnus-summary-select-article nil nil 'pseudo article)
7271 (gnus-eval-in-buffer-window gnus-article-buffer
7272 (let ((buffer (generate-new-buffer " *print*")))
7275 (copy-to-buffer buffer (point-min) (point-max))
7277 (gnus-article-delete-invisible-text)
7278 (let ((ps-left-header
7281 (mail-header-subject gnus-current-headers) ")")
7283 (mail-header-from gnus-current-headers) ")")))
7286 "/pagenumberstring load"
7288 (mail-header-date gnus-current-headers) ")"))))
7289 (gnus-run-hooks 'gnus-ps-print-hook)
7291 (ps-print-buffer-with-faces filename))))
7292 (kill-buffer buffer))))))
7294 (defun gnus-summary-show-article (&optional arg)
7295 "Force re-fetching of the current article.
7296 If ARG (the prefix) is a number, show the article with the charset
7297 defined in `gnus-summary-show-article-charset-alist', or the charset
7299 If ARG (the prefix) is non-nil and not a number, show the raw article
7300 without any article massaging functions being run."
7304 (let ((gnus-newsgroup-charset
7305 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7306 (read-coding-system "Charset: ")))
7307 (gnus-newsgroup-ignored-charsets 'gnus-all))
7308 (gnus-summary-select-article nil 'force)
7309 (let ((deps gnus-newsgroup-dependencies)
7312 (set-buffer gnus-original-article-buffer)
7314 (message-narrow-to-head)
7315 (setq head (buffer-string)))
7317 (insert (format "211 %d Article retrieved.\n"
7318 (cdr gnus-article-current)))
7321 (let ((nntp-server-buffer (current-buffer)))
7322 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7323 (gnus-data-set-header
7324 (gnus-data-find (cdr gnus-article-current))
7326 (gnus-summary-update-article-line
7327 (cdr gnus-article-current) header))))
7329 ;; Select the article the normal way.
7330 (gnus-summary-select-article nil 'force))
7332 ;; We have to require this here to make sure that the following
7333 ;; dynamic binding isn't shadowed by autoloading.
7334 (require 'gnus-async)
7336 ;; Bind the article treatment functions to nil.
7337 (let ((gnus-have-all-headers t)
7338 gnus-article-prepare-hook
7339 gnus-article-decode-hook
7340 gnus-display-mime-function
7342 ;; Destroy any MIME parts.
7343 (when (gnus-buffer-live-p gnus-article-buffer)
7345 (set-buffer gnus-article-buffer)
7346 (mm-destroy-parts gnus-article-mime-handles)
7347 ;; Set it to nil for safety reason.
7348 (setq gnus-article-mime-handle-alist nil)
7349 (setq gnus-article-mime-handles nil)))
7350 (gnus-summary-select-article nil 'force))))
7351 (gnus-summary-goto-subject gnus-current-article)
7352 (gnus-summary-position-point))
7354 (defun gnus-summary-verbose-headers (&optional arg)
7355 "Toggle permanent full header display.
7356 If ARG is a positive number, turn header display on.
7357 If ARG is a negative number, turn header display off."
7359 (setq gnus-show-all-headers
7360 (cond ((or (not (numberp arg))
7362 (not gnus-show-all-headers))
7365 (gnus-summary-show-article))
7367 (defun gnus-summary-toggle-header (&optional arg)
7368 "Show the headers if they are hidden, or hide them if they are shown.
7369 If ARG is a positive number, show the entire header.
7370 If ARG is a negative number, hide the unwanted header lines."
7373 (set-buffer gnus-article-buffer)
7375 (let* ((buffer-read-only nil)
7376 (inhibit-point-motion-hooks t)
7382 (article-narrow-to-head)
7383 (gnus-article-hidden-text-p 'headers))))
7384 (goto-char (point-min))
7385 (when (search-forward "\n\n" nil t)
7386 (delete-region (point-min) (1- (point))))
7387 (goto-char (point-min))
7389 (set-buffer gnus-original-article-buffer)
7390 (goto-char (point-min))
7391 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7392 (insert-buffer-substring gnus-original-article-buffer 1 e)
7394 (narrow-to-region (point-min) (point))
7395 (article-decode-encoded-words)
7397 (let ((gnus-treat-hide-headers nil)
7398 (gnus-treat-hide-boring-headers nil))
7399 (setq gnus-article-wash-types
7400 (delq 'headers gnus-article-wash-types))
7401 (gnus-treat-article 'head))
7402 (gnus-treat-article 'head)))
7403 (gnus-set-mode-line 'article)))))
7405 (defun gnus-summary-show-all-headers ()
7406 "Make all header lines visible."
7408 (gnus-article-show-all-headers))
7410 (defun gnus-summary-caesar-message (&optional arg)
7411 "Caesar rotate the current article by 13.
7412 The numerical prefix specifies how many places to rotate each letter
7415 (gnus-summary-select-article)
7416 (let ((mail-header-separator ""))
7417 (gnus-eval-in-buffer-window gnus-article-buffer
7420 (let ((start (window-start))
7422 (message-caesar-buffer-body arg)
7423 (set-window-start (get-buffer-window (current-buffer)) start))))))
7425 (defun gnus-summary-stop-page-breaking ()
7426 "Stop page breaking in the current article."
7428 (gnus-summary-select-article)
7429 (gnus-eval-in-buffer-window gnus-article-buffer
7431 (when (gnus-visual-p 'page-marker)
7432 (let ((buffer-read-only nil))
7433 (gnus-remove-text-with-property 'gnus-prev)
7434 (gnus-remove-text-with-property 'gnus-next))
7435 (setq gnus-page-broken nil))))
7437 (defun gnus-summary-move-article (&optional n to-newsgroup
7438 select-method action)
7439 "Move the current article to a different newsgroup.
7440 If N is a positive number, move the N next articles.
7441 If N is a negative number, move the N previous articles.
7442 If N is nil and any articles have been marked with the process mark,
7443 move those articles instead.
7444 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7445 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7446 re-spool using this method.
7448 For this function to work, both the current newsgroup and the
7449 newsgroup that you want to move to have to support the `request-move'
7450 and `request-accept' functions.
7452 ACTION can be either `move' (the default), `crosspost' or `copy'."
7455 (setq action 'move))
7456 ;; Disable marking as read.
7457 (let (gnus-mark-article-hook)
7458 (save-window-excursion
7459 (gnus-summary-select-article)))
7460 ;; Check whether the source group supports the required functions.
7461 (cond ((and (eq action 'move)
7462 (not (gnus-check-backend-function
7463 'request-move-article gnus-newsgroup-name)))
7464 (error "The current group does not support article moving"))
7465 ((and (eq action 'crosspost)
7466 (not (gnus-check-backend-function
7467 'request-replace-article gnus-newsgroup-name)))
7468 (error "The current group does not support article editing")))
7469 (let ((articles (gnus-summary-work-articles n))
7470 (prefix (if (gnus-check-backend-function
7471 'request-move-article gnus-newsgroup-name)
7472 (gnus-group-real-prefix gnus-newsgroup-name)
7474 (names '((move "Move" "Moving")
7475 (copy "Copy" "Copying")
7476 (crosspost "Crosspost" "Crossposting")))
7477 (copy-buf (save-excursion
7478 (nnheader-set-temp-buffer " *copy article*")))
7479 art-group to-method new-xref article to-groups)
7480 (unless (assq action names)
7481 (error "Unknown action %s" action))
7482 ;; Read the newsgroup name.
7483 (when (and (not to-newsgroup)
7484 (not select-method))
7486 (gnus-read-move-group-name
7487 (cadr (assq action names))
7488 (symbol-value (intern (format "gnus-current-%s-group" action)))
7490 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7491 (setq to-method (or select-method
7492 (gnus-server-to-method
7493 (gnus-group-method to-newsgroup))))
7494 ;; Check the method we are to move this article to...
7495 (unless (gnus-check-backend-function
7496 'request-accept-article (car to-method))
7497 (error "%s does not support article copying" (car to-method)))
7498 (unless (gnus-check-server to-method)
7499 (error "Can't open server %s" (car to-method)))
7500 (gnus-message 6 "%s to %s: %s..."
7501 (caddr (assq action names))
7502 (or (car select-method) to-newsgroup) articles)
7504 (setq article (pop articles))
7508 ;; Move the article.
7510 ;; Remove this article from future suppression.
7511 (gnus-dup-unsuppress-article article)
7512 (gnus-request-move-article
7513 article ; Article to move
7514 gnus-newsgroup-name ; From newsgroup
7515 (nth 1 (gnus-find-method-for-group
7516 gnus-newsgroup-name)) ; Server
7517 (list 'gnus-request-accept-article
7518 to-newsgroup (list 'quote select-method)
7519 (not articles) t) ; Accept form
7520 (not articles))) ; Only save nov last time
7521 ;; Copy the article.
7524 (set-buffer copy-buf)
7525 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7526 (gnus-request-accept-article
7527 to-newsgroup select-method (not articles) t))))
7528 ;; Crosspost the article.
7529 ((eq action 'crosspost)
7530 (let ((xref (message-tokenize-header
7531 (mail-header-xref (gnus-summary-article-header article))
7533 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7536 (setq xref (list (system-name))))
7539 (mapconcat 'identity
7540 (delete "Xref:" (delete new-xref xref))
7544 (set-buffer copy-buf)
7545 ;; First put the article in the destination group.
7546 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7547 (when (consp (setq art-group
7548 (gnus-request-accept-article
7549 to-newsgroup select-method (not articles))))
7550 (setq new-xref (concat new-xref " " (car art-group)
7551 ":" (cdr art-group)))
7552 ;; Now we have the new Xrefs header, so we insert
7553 ;; it and replace the new article.
7554 (nnheader-replace-header "Xref" new-xref)
7555 (gnus-request-replace-article
7556 (cdr art-group) to-newsgroup (current-buffer))
7560 (gnus-message 1 "Couldn't %s article %s: %s"
7561 (cadr (assq action names)) article
7562 (nnheader-get-report (car to-method))))
7563 ((eq art-group 'junk)
7564 (when (eq action 'move)
7565 (gnus-summary-mark-article article gnus-canceled-mark)
7566 (gnus-message 4 "Deleted article %s" article)))
7568 (let* ((pto-group (gnus-group-prefixed-name
7569 (car art-group) to-method))
7571 (gnus-gethash pto-group gnus-newsrc-hashtb))
7572 (info (nth 2 entry))
7573 (to-group (gnus-info-group info))
7575 ;; Update the group that has been moved to.
7577 (memq action '(move copy)))
7578 (unless (member to-group to-groups)
7579 (push to-group to-groups))
7581 (unless (memq article gnus-newsgroup-unreads)
7582 (push 'read to-marks)
7584 info (gnus-add-to-range (gnus-info-read info)
7585 (list (cdr art-group)))))
7587 ;; See whether the article is to be put in the cache.
7588 (let ((marks gnus-article-mark-lists)
7589 (to-article (cdr art-group)))
7591 ;; Enter the article into the cache in the new group,
7592 ;; if that is required.
7593 (when gnus-use-cache
7594 (gnus-cache-possibly-enter-article
7596 (memq article gnus-newsgroup-marked)
7597 (memq article gnus-newsgroup-dormant)
7598 (memq article gnus-newsgroup-unreads)))
7600 (when gnus-preserve-marks
7601 ;; Copy any marks over to the new group.
7602 (when (and (equal to-group gnus-newsgroup-name)
7603 (not (memq article gnus-newsgroup-unreads)))
7604 ;; Mark this article as read in this group.
7605 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7606 (setcdr (gnus-active to-group) to-article)
7607 (setcdr gnus-newsgroup-active to-article))
7610 (when (memq article (symbol-value
7611 (intern (format "gnus-newsgroup-%s"
7613 (push (cdar marks) to-marks)
7614 ;; If the other group is the same as this group,
7615 ;; then we have to add the mark to the list.
7616 (when (equal to-group gnus-newsgroup-name)
7617 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7620 (intern (format "gnus-newsgroup-%s"
7622 ;; Copy the marks to other group.
7623 (gnus-add-marked-articles
7624 to-group (cdar marks) (list to-article) info))
7625 (setq marks (cdr marks)))
7627 (gnus-request-set-mark to-group (list (list (list to-article)
7632 (concat "(gnus-group-set-info '"
7633 (gnus-prin1-to-string (gnus-get-info to-group))
7636 ;; Update the Xref header in this article to point to
7637 ;; the new crossposted article we have just created.
7638 (when (eq action 'crosspost)
7640 (set-buffer copy-buf)
7641 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7642 (nnheader-replace-header "Xref" new-xref)
7643 (gnus-request-replace-article
7644 article gnus-newsgroup-name (current-buffer)))))
7646 ;;;!!!Why is this necessary?
7647 (set-buffer gnus-summary-buffer)
7649 (gnus-summary-goto-subject article)
7650 (when (eq action 'move)
7651 (gnus-summary-mark-article article gnus-canceled-mark))))
7652 (gnus-summary-remove-process-mark article))
7653 ;; Re-activate all groups that have been moved to.
7656 (set-buffer gnus-group-buffer)
7657 (when (gnus-group-goto-group (car to-groups) t)
7658 (gnus-group-get-new-news-this-group 1 t))
7661 (gnus-kill-buffer copy-buf)
7662 (gnus-summary-position-point)
7663 (gnus-set-mode-line 'summary)))
7665 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7666 "Move the current article to a different newsgroup.
7667 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7668 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7669 re-spool using this method."
7671 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7673 (defun gnus-summary-crosspost-article (&optional n)
7674 "Crosspost the current article to some other group."
7676 (gnus-summary-move-article n nil nil 'crosspost))
7678 (defcustom gnus-summary-respool-default-method nil
7679 "Default method for respooling an article.
7680 If nil, use to the current newsgroup method."
7681 :type '(choice (gnus-select-method :value (nnml ""))
7683 :group 'gnus-summary-mail)
7685 (defun gnus-summary-respool-article (&optional n method)
7686 "Respool the current article.
7687 The article will be squeezed through the mail spooling process again,
7688 which means that it will be put in some mail newsgroup or other
7689 depending on `nnmail-split-methods'.
7690 If N is a positive number, respool the N next articles.
7691 If N is a negative number, respool the N previous articles.
7692 If N is nil and any articles have been marked with the process mark,
7693 respool those articles instead.
7695 Respooling can be done both from mail groups and \"real\" newsgroups.
7696 In the former case, the articles in question will be moved from the
7697 current group into whatever groups they are destined to. In the
7698 latter case, they will be copied into the relevant groups."
7700 (list current-prefix-arg
7701 (let* ((methods (gnus-methods-using 'respool))
7703 (symbol-name (or gnus-summary-respool-default-method
7704 (car (gnus-find-method-for-group
7705 gnus-newsgroup-name)))))
7707 (gnus-completing-read
7708 methname "What backend do you want to use when respooling?"
7709 methods nil t nil 'gnus-mail-method-history))
7712 ((zerop (length (setq ms (gnus-servers-using-backend
7714 (list (intern method) ""))
7718 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7719 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7722 (error "No method given for respooling"))
7723 (if (assoc (symbol-name
7724 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7725 (gnus-methods-using 'respool))
7726 (gnus-summary-move-article n nil method)
7727 (gnus-summary-copy-article n nil method)))
7729 (defun gnus-summary-import-article (file)
7730 "Import an arbitrary file into a mail newsgroup."
7731 (interactive "fImport file: ")
7732 (let ((group gnus-newsgroup-name)
7733 (now (current-time))
7735 (unless (gnus-check-backend-function 'request-accept-article group)
7736 (error "%s does not support article importing" group))
7737 (or (file-readable-p file)
7738 (not (file-regular-p file))
7739 (error "Can't read %s" file))
7741 (set-buffer (gnus-get-buffer-create " *import file*"))
7743 (nnheader-insert-file-contents file)
7744 (goto-char (point-min))
7745 (unless (nnheader-article-p)
7746 ;; This doesn't look like an article, so we fudge some headers.
7747 (setq atts (file-attributes file)
7748 lines (count-lines (point-min) (point-max)))
7749 (insert "From: " (read-string "From: ") "\n"
7750 "Subject: " (read-string "Subject: ") "\n"
7751 "Date: " (message-make-date (nth 5 atts))
7753 "Message-ID: " (message-make-message-id) "\n"
7754 "Lines: " (int-to-string lines) "\n"
7755 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7756 (gnus-request-accept-article group nil t)
7757 (kill-buffer (current-buffer)))))
7759 (defun gnus-summary-article-posted-p ()
7760 "Say whether the current (mail) article is available from news as well.
7761 This will be the case if the article has both been mailed and posted."
7763 (let ((id (mail-header-references (gnus-summary-article-header)))
7764 (gnus-override-method (car (gnus-refer-article-methods))))
7765 (if (gnus-request-head id "")
7766 (gnus-message 2 "The current message was found on %s"
7767 gnus-override-method)
7768 (gnus-message 2 "The current message couldn't be found on %s"
7769 gnus-override-method)
7772 (defun gnus-summary-expire-articles (&optional now)
7773 "Expire all articles that are marked as expirable in the current group."
7775 (when (gnus-check-backend-function
7776 'request-expire-articles gnus-newsgroup-name)
7777 ;; This backend supports expiry.
7778 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7779 (expirable (if total
7781 ;; We need to update the info for
7782 ;; this group for `gnus-list-of-read-articles'
7783 ;; to give us the right answer.
7784 (gnus-run-hooks 'gnus-exit-group-hook)
7785 (gnus-summary-update-info)
7786 (gnus-list-of-read-articles gnus-newsgroup-name))
7787 (setq gnus-newsgroup-expirable
7788 (sort gnus-newsgroup-expirable '<))))
7789 (expiry-wait (if now 'immediate
7790 (gnus-group-find-parameter
7791 gnus-newsgroup-name 'expiry-wait)))
7792 (nnmail-expiry-target
7793 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7794 nnmail-expiry-target))
7797 ;; There are expirable articles in this group, so we run them
7798 ;; through the expiry process.
7799 (gnus-message 6 "Expiring articles...")
7800 (unless (gnus-check-group gnus-newsgroup-name)
7801 (error "Can't open server for %s" gnus-newsgroup-name))
7802 ;; The list of articles that weren't expired is returned.
7805 (let ((nnmail-expiry-wait-function nil)
7806 (nnmail-expiry-wait expiry-wait))
7807 (setq es (gnus-request-expire-articles
7808 expirable gnus-newsgroup-name)))
7809 (setq es (gnus-request-expire-articles
7810 expirable gnus-newsgroup-name)))
7812 (setq gnus-newsgroup-expirable es))
7813 ;; We go through the old list of expirable, and mark all
7814 ;; really expired articles as nonexistent.
7815 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7816 (let ((gnus-use-cache nil))
7818 (unless (memq (car expirable) es)
7819 (when (gnus-data-find (car expirable))
7820 (gnus-summary-mark-article
7821 (car expirable) gnus-canceled-mark)))
7822 (setq expirable (cdr expirable))))))
7823 (gnus-message 6 "Expiring articles...done")))))
7825 (defun gnus-summary-expire-articles-now ()
7826 "Expunge all expirable articles in the current group.
7827 This means that *all* articles that are marked as expirable will be
7828 deleted forever, right now."
7830 (or gnus-expert-user
7832 "Are you really, really, really sure you want to delete all these messages? ")
7834 (gnus-summary-expire-articles t))
7836 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7837 (defun gnus-summary-delete-article (&optional n)
7838 "Delete the N next (mail) articles.
7839 This command actually deletes articles. This is not a marking
7840 command. The article will disappear forever from your life, never to
7842 If N is negative, delete backwards.
7843 If N is nil and articles have been marked with the process mark,
7844 delete these instead."
7846 (unless (gnus-check-backend-function 'request-expire-articles
7847 gnus-newsgroup-name)
7848 (error "The current newsgroup does not support article deletion"))
7849 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7850 (error "Couldn't open server"))
7851 ;; Compute the list of articles to delete.
7852 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7854 (if (and gnus-novice-user
7855 (not (gnus-yes-or-no-p
7856 (format "Do you really want to delete %s forever? "
7857 (if (> (length articles) 1)
7858 (format "these %s articles" (length articles))
7861 ;; Delete the articles.
7862 (setq not-deleted (gnus-request-expire-articles
7863 articles gnus-newsgroup-name 'force))
7865 (gnus-summary-remove-process-mark (car articles))
7866 ;; The backend might not have been able to delete the article
7868 (unless (memq (car articles) not-deleted)
7869 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7870 (setq articles (cdr articles)))
7872 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7873 (gnus-summary-position-point)
7874 (gnus-set-mode-line 'summary)
7877 (defun gnus-summary-edit-article (&optional arg)
7878 "Edit the current article.
7879 This will have permanent effect only in mail groups.
7880 If ARG is nil, edit the decoded articles.
7881 If ARG is 1, edit the raw articles.
7882 If ARG is 2, edit the raw articles even in read-only groups.
7883 If ARG is 3, edit the articles with the current handles.
7884 Otherwise, allow editing of articles even in read-only
7887 (let (force raw current-handles)
7890 ((eq arg 1) (setq raw t))
7891 ((eq arg 2) (setq raw t
7893 ((eq arg 3) (setq current-handles
7894 (and (gnus-buffer-live-p gnus-article-buffer)
7895 (with-current-buffer gnus-article-buffer
7897 gnus-article-mime-handles
7898 (setq gnus-article-mime-handles nil))))))
7900 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7901 (error "Can't edit the raw article in group nndraft:drafts."))
7903 (set-buffer gnus-summary-buffer)
7904 (let ((mail-parse-charset gnus-newsgroup-charset)
7905 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7906 (gnus-set-global-variables)
7907 (when (and (not force)
7908 (gnus-group-read-only-p))
7909 (error "The current newsgroup does not support article editing"))
7910 (gnus-summary-show-article t)
7911 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7912 (with-current-buffer gnus-article-buffer
7913 (mm-enable-multibyte-mule4)))
7914 (if (equal gnus-newsgroup-name "nndraft:drafts")
7916 (gnus-article-edit-article
7919 (let ((mbl mml-buffer-list))
7920 (setq mml-buffer-list nil)
7921 (mime-to-mml ,'current-handles)
7922 (make-local-hook 'kill-buffer-hook)
7923 (let ((mbl1 mml-buffer-list))
7924 (setq mml-buffer-list mbl)
7925 (set (make-local-variable 'mml-buffer-list) mbl1))
7926 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7927 `(lambda (no-highlight)
7928 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7929 (message-options message-options)
7930 (message-options-set-recipient)
7931 (mail-parse-ignored-charsets
7932 ',gnus-newsgroup-ignored-charsets))
7933 ,(if (not raw) '(progn
7935 (mml-destroy-buffers)
7936 (remove-hook 'kill-buffer-hook
7937 'mml-destroy-buffers t)
7938 (kill-local-variable 'mml-buffer-list)))
7939 (gnus-summary-edit-article-done
7940 ,(or (mail-header-references gnus-current-headers) "")
7941 ,(gnus-group-read-only-p)
7942 ,gnus-summary-buffer no-highlight))))))))
7944 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7946 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7948 "Make edits to the current article permanent."
7951 ;; The buffer restriction contains the entire article if it exists.
7952 (when (article-goto-body)
7953 (let ((lines (count-lines (point) (point-max)))
7954 (length (- (point-max) (point)))
7955 (case-fold-search t)
7956 (body (copy-marker (point))))
7957 (goto-char (point-min))
7958 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
7959 (delete-region (match-beginning 1) (match-end 1))
7960 (insert (number-to-string length)))
7961 (goto-char (point-min))
7962 (when (re-search-forward
7963 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
7964 (delete-region (match-beginning 1) (match-end 1))
7965 (insert (number-to-string length)))
7966 (goto-char (point-min))
7967 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
7968 (delete-region (match-beginning 1) (match-end 1))
7969 (insert (number-to-string lines))))))
7970 ;; Replace the article.
7971 (let ((buf (current-buffer)))
7973 (insert-buffer-substring buf)
7975 (if (and (not read-only)
7976 (not (gnus-request-replace-article
7977 (cdr gnus-article-current) (car gnus-article-current)
7978 (current-buffer) t)))
7979 (error "Couldn't replace article")
7980 ;; Update the summary buffer.
7982 (equal (message-tokenize-header references " ")
7983 (message-tokenize-header
7984 (or (message-fetch-field "references") "") " ")))
7985 ;; We only have to update this line.
7988 (message-narrow-to-head)
7989 (let ((head (buffer-string))
7992 (insert (format "211 %d Article retrieved.\n"
7993 (cdr gnus-article-current)))
7996 (let ((nntp-server-buffer (current-buffer)))
7997 (setq header (car (gnus-get-newsgroup-headers
7999 (set-buffer gnus-summary-buffer)
8000 gnus-newsgroup-dependencies)
8003 (set-buffer gnus-summary-buffer)
8004 (gnus-data-set-header
8005 (gnus-data-find (cdr gnus-article-current))
8007 (gnus-summary-update-article-line
8008 (cdr gnus-article-current) header))))))
8010 (set-buffer (or buffer gnus-summary-buffer))
8011 (gnus-summary-update-article (cdr gnus-article-current)))
8012 ;; Prettify the article buffer again.
8013 (unless no-highlight
8015 (set-buffer gnus-article-buffer)
8016 ;;;!!! Fix this -- article should be rehighlighted.
8017 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8018 (set-buffer gnus-original-article-buffer)
8019 (gnus-request-article
8020 (cdr gnus-article-current)
8021 (car gnus-article-current) (current-buffer))))
8022 ;; Prettify the summary buffer line.
8023 (when (gnus-visual-p 'summary-highlight 'highlight)
8024 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8026 (defun gnus-summary-edit-wash (key)
8027 "Perform editing command KEY in the article buffer."
8031 (message "%s" (concat (this-command-keys) "- "))
8034 (gnus-summary-edit-article)
8035 (execute-kbd-macro (concat (this-command-keys) key))
8036 (gnus-article-edit-done))
8040 (defun gnus-summary-respool-query (&optional silent trace)
8041 "Query where the respool algorithm would put this article."
8043 (let (gnus-mark-article-hook)
8044 (gnus-summary-select-article)
8046 (set-buffer gnus-original-article-buffer)
8048 (message-narrow-to-head)
8049 (let ((groups (nnmail-article-group 'identity trace)))
8052 (message "This message would go to %s"
8053 (mapconcat 'car groups ", "))
8054 (message "This message would go to no groups"))
8057 (defun gnus-summary-respool-trace ()
8058 "Trace where the respool algorithm would put this article.
8059 Display a buffer showing all fancy splitting patterns which matched."
8061 (gnus-summary-respool-query nil t))
8063 ;; Summary marking commands.
8065 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8066 "Mark articles which has the same subject as read, and then select the next.
8067 If UNMARK is positive, remove any kind of mark.
8068 If UNMARK is negative, tick articles."
8071 (setq unmark (prefix-numeric-value unmark)))
8073 (gnus-summary-mark-same-subject
8074 (gnus-summary-article-subject) unmark)))
8075 ;; Select next unread article. If auto-select-same mode, should
8076 ;; select the first unread article.
8077 (gnus-summary-next-article t (and gnus-auto-select-same
8078 (gnus-summary-article-subject)))
8079 (gnus-message 7 "%d article%s marked as %s"
8080 count (if (= count 1) " is" "s are")
8081 (if unmark "unread" "read"))))
8083 (defun gnus-summary-kill-same-subject (&optional unmark)
8084 "Mark articles which has the same subject as read.
8085 If UNMARK is positive, remove any kind of mark.
8086 If UNMARK is negative, tick articles."
8089 (setq unmark (prefix-numeric-value unmark)))
8091 (gnus-summary-mark-same-subject
8092 (gnus-summary-article-subject) unmark)))
8093 ;; If marked as read, go to next unread subject.
8095 ;; Go to next unread subject.
8096 (gnus-summary-next-subject 1 t))
8097 (gnus-message 7 "%d articles are marked as %s"
8098 count (if unmark "unread" "read"))))
8100 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8101 "Mark articles with same SUBJECT as read, and return marked number.
8102 If optional argument UNMARK is positive, remove any kinds of marks.
8103 If optional argument UNMARK is negative, mark articles as unread instead."
8107 ((null unmark) ; Mark as read.
8110 (gnus-summary-mark-article-as-read gnus-killed-mark)
8111 (gnus-summary-show-thread) t)
8112 (gnus-summary-find-subject subject))
8113 (setq count (1+ count))))
8114 ((> unmark 0) ; Tick.
8117 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8118 (gnus-summary-show-thread) t)
8119 (gnus-summary-find-subject subject))
8120 (setq count (1+ count))))
8121 (t ; Mark as unread.
8124 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8125 (gnus-summary-show-thread) t)
8126 (gnus-summary-find-subject subject))
8127 (setq count (1+ count)))))
8128 (gnus-set-mode-line 'summary)
8129 ;; Return the number of marked articles.
8132 (defun gnus-summary-mark-as-processable (n &optional unmark)
8133 "Set the process mark on the next N articles.
8134 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8135 the process mark instead. The difference between N and the actual
8136 number of articles marked is returned."
8138 (let ((backward (< n 0))
8143 (gnus-summary-remove-process-mark
8144 (gnus-summary-article-number))
8145 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8146 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8149 (gnus-message 7 "No more articles"))
8150 (gnus-summary-recenter)
8151 (gnus-summary-position-point)
8154 (defun gnus-summary-unmark-as-processable (n)
8155 "Remove the process mark from the next N articles.
8156 If N is negative, unmark backward instead. The difference between N and
8157 the actual number of articles unmarked is returned."
8159 (gnus-summary-mark-as-processable n t))
8161 (defun gnus-summary-unmark-all-processable ()
8162 "Remove the process mark from all articles."
8165 (while gnus-newsgroup-processable
8166 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8167 (gnus-summary-position-point))
8169 (defun gnus-summary-mark-as-expirable (n)
8170 "Mark N articles forward as expirable.
8171 If N is negative, mark backward instead. The difference between N and
8172 the actual number of articles marked is returned."
8174 (gnus-summary-mark-forward n gnus-expirable-mark))
8176 (defun gnus-summary-mark-article-as-replied (article)
8177 "Mark ARTICLE replied and update the summary line."
8178 (push article gnus-newsgroup-replied)
8179 (let ((buffer-read-only nil))
8180 (when (gnus-summary-goto-subject article nil t)
8181 (gnus-summary-update-secondary-mark article))))
8183 (defun gnus-summary-set-bookmark (article)
8184 "Set a bookmark in current article."
8185 (interactive (list (gnus-summary-article-number)))
8186 (when (or (not (get-buffer gnus-article-buffer))
8187 (not gnus-current-article)
8188 (not gnus-article-current)
8189 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8190 (error "No current article selected"))
8191 ;; Remove old bookmark, if one exists.
8192 (let ((old (assq article gnus-newsgroup-bookmarks)))
8194 (setq gnus-newsgroup-bookmarks
8195 (delq old gnus-newsgroup-bookmarks))))
8196 ;; Set the new bookmark, which is on the form
8197 ;; (article-number . line-number-in-body).
8201 (set-buffer gnus-article-buffer)
8205 (goto-char (point-min))
8206 (search-forward "\n\n" nil t)
8209 gnus-newsgroup-bookmarks)
8210 (gnus-message 6 "A bookmark has been added to the current article."))
8212 (defun gnus-summary-remove-bookmark (article)
8213 "Remove the bookmark from the current article."
8214 (interactive (list (gnus-summary-article-number)))
8215 ;; Remove old bookmark, if one exists.
8216 (let ((old (assq article gnus-newsgroup-bookmarks)))
8219 (setq gnus-newsgroup-bookmarks
8220 (delq old gnus-newsgroup-bookmarks))
8221 (gnus-message 6 "Removed bookmark."))
8222 (gnus-message 6 "No bookmark in current article."))))
8224 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8225 (defun gnus-summary-mark-as-dormant (n)
8226 "Mark N articles forward as dormant.
8227 If N is negative, mark backward instead. The difference between N and
8228 the actual number of articles marked is returned."
8230 (gnus-summary-mark-forward n gnus-dormant-mark))
8232 (defun gnus-summary-set-process-mark (article)
8233 "Set the process mark on ARTICLE and update the summary line."
8234 (setq gnus-newsgroup-processable
8236 (delq article gnus-newsgroup-processable)))
8237 (when (gnus-summary-goto-subject article)
8238 (gnus-summary-show-thread)
8239 (gnus-summary-goto-subject article)
8240 (gnus-summary-update-secondary-mark article)))
8242 (defun gnus-summary-remove-process-mark (article)
8243 "Remove the process mark from ARTICLE and update the summary line."
8244 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8245 (when (gnus-summary-goto-subject article)
8246 (gnus-summary-show-thread)
8247 (gnus-summary-goto-subject article)
8248 (gnus-summary-update-secondary-mark article)))
8250 (defun gnus-summary-set-saved-mark (article)
8251 "Set the process mark on ARTICLE and update the summary line."
8252 (push article gnus-newsgroup-saved)
8253 (when (gnus-summary-goto-subject article)
8254 (gnus-summary-update-secondary-mark article)))
8256 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8257 "Mark N articles as read forwards.
8258 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8259 The difference between N and the actual number of articles marked is
8261 Iff NO-EXPIRE, auto-expiry will be inhibited."
8263 (gnus-summary-show-thread)
8264 (let ((backward (< n 0))
8265 (gnus-summary-goto-unread
8266 (and gnus-summary-goto-unread
8267 (not (eq gnus-summary-goto-unread 'never))
8268 (not (memq mark (list gnus-unread-mark
8269 gnus-ticked-mark gnus-dormant-mark)))))
8271 (mark (or mark gnus-del-mark)))
8273 (gnus-summary-mark-article nil mark no-expire)
8274 (zerop (gnus-summary-next-subject
8276 (and gnus-summary-goto-unread
8277 (not (eq gnus-summary-goto-unread 'never)))
8281 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8282 (gnus-summary-recenter)
8283 (gnus-summary-position-point)
8284 (gnus-set-mode-line 'summary)
8287 (defun gnus-summary-mark-article-as-read (mark)
8288 "Mark the current article quickly as read with MARK."
8289 (let ((article (gnus-summary-article-number)))
8290 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8291 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8292 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8293 (push (cons article mark) gnus-newsgroup-reads)
8294 ;; Possibly remove from cache, if that is used.
8295 (when gnus-use-cache
8296 (gnus-cache-enter-remove-article article))
8297 ;; Allow the backend to change the mark.
8298 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8299 ;; Check for auto-expiry.
8300 (when (and gnus-newsgroup-auto-expire
8301 (memq mark gnus-auto-expirable-marks))
8302 (setq mark gnus-expirable-mark)
8303 ;; Let the backend know about the mark change.
8304 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8305 (push article gnus-newsgroup-expirable))
8306 ;; Set the mark in the buffer.
8307 (gnus-summary-update-mark mark 'unread)
8310 (defun gnus-summary-mark-article-as-unread (mark)
8311 "Mark the current article quickly as unread with MARK."
8312 (let* ((article (gnus-summary-article-number))
8313 (old-mark (gnus-summary-article-mark article)))
8314 ;; Allow the backend to change the mark.
8315 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8316 (if (eq mark old-mark)
8320 (gnus-error 1 "Can't mark negative article numbers")
8322 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8323 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8324 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8325 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8326 (cond ((= mark gnus-ticked-mark)
8327 (push article gnus-newsgroup-marked))
8328 ((= mark gnus-dormant-mark)
8329 (push article gnus-newsgroup-dormant))
8331 (push article gnus-newsgroup-unreads)))
8332 (gnus-pull article gnus-newsgroup-reads)
8334 ;; See whether the article is to be put in the cache.
8336 (vectorp (gnus-summary-article-header article))
8338 (gnus-cache-possibly-enter-article
8339 gnus-newsgroup-name article
8340 (= mark gnus-ticked-mark)
8341 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8344 (gnus-summary-update-mark mark 'unread)
8347 (defun gnus-summary-mark-article (&optional article mark no-expire)
8348 "Mark ARTICLE with MARK. MARK can be any character.
8349 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8350 `??' (dormant) and `?E' (expirable).
8351 If MARK is nil, then the default character `?r' is used.
8352 If ARTICLE is nil, then the article on the current line will be
8354 Iff NO-EXPIRE, auto-expiry will be inhibited."
8355 ;; The mark might be a string.
8356 (when (stringp mark)
8357 (setq mark (aref mark 0)))
8358 ;; If no mark is given, then we check auto-expiring.
8360 (setq mark gnus-del-mark))
8361 (when (and (not no-expire)
8362 gnus-newsgroup-auto-expire
8363 (memq mark gnus-auto-expirable-marks))
8364 (setq mark gnus-expirable-mark))
8365 (let ((article (or article (gnus-summary-article-number)))
8366 (old-mark (gnus-summary-article-mark article)))
8367 ;; Allow the backend to change the mark.
8368 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8369 (if (eq mark old-mark)
8372 (error "No article on current line"))
8373 (if (not (if (or (= mark gnus-unread-mark)
8374 (= mark gnus-ticked-mark)
8375 (= mark gnus-dormant-mark))
8376 (gnus-mark-article-as-unread article mark)
8377 (gnus-mark-article-as-read article mark)))
8379 ;; See whether the article is to be put in the cache.
8381 (not (= mark gnus-canceled-mark))
8382 (vectorp (gnus-summary-article-header article))
8384 (gnus-cache-possibly-enter-article
8385 gnus-newsgroup-name article
8386 (= mark gnus-ticked-mark)
8387 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8389 (when (gnus-summary-goto-subject article nil t)
8390 (let ((buffer-read-only nil))
8391 (gnus-summary-show-thread)
8393 (gnus-summary-update-mark mark 'unread)
8396 (defun gnus-summary-update-secondary-mark (article)
8397 "Update the secondary (read, process, cache) mark."
8398 (gnus-summary-update-mark
8399 (cond ((memq article gnus-newsgroup-processable)
8401 ((memq article gnus-newsgroup-cached)
8403 ((memq article gnus-newsgroup-replied)
8405 ((memq article gnus-newsgroup-saved)
8407 (t gnus-unread-mark))
8409 (when (gnus-visual-p 'summary-highlight 'highlight)
8410 (gnus-run-hooks 'gnus-summary-update-hook))
8413 (defun gnus-summary-update-mark (mark type)
8414 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8415 (buffer-read-only nil))
8416 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8418 (when (looking-at "\r")
8420 (when (<= (+ forward (point)) (point-max))
8421 ;; Go to the right position on the line.
8422 (goto-char (+ forward (point)))
8423 ;; Replace the old mark with the new mark.
8424 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8425 ;; Optionally update the marks by some user rule.
8426 (when (eq type 'unread)
8428 (gnus-data-find (gnus-summary-article-number)) mark)
8429 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8431 (defun gnus-mark-article-as-read (article &optional mark)
8432 "Enter ARTICLE in the pertinent lists and remove it from others."
8433 ;; Make the article expirable.
8434 (let ((mark (or mark gnus-del-mark)))
8435 (if (= mark gnus-expirable-mark)
8436 (push article gnus-newsgroup-expirable)
8437 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8438 ;; Remove from unread and marked lists.
8439 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8440 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8441 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8442 (push (cons article mark) gnus-newsgroup-reads)
8443 ;; Possibly remove from cache, if that is used.
8444 (when gnus-use-cache
8445 (gnus-cache-enter-remove-article article))
8448 (defun gnus-mark-article-as-unread (article &optional mark)
8449 "Enter ARTICLE in the pertinent lists and remove it from others."
8450 (let ((mark (or mark gnus-ticked-mark)))
8453 (gnus-error 1 "Can't mark negative article numbers")
8455 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8456 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8457 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8458 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8460 ;; Unsuppress duplicates?
8461 (when gnus-suppress-duplicates
8462 (gnus-dup-unsuppress-article article))
8464 (cond ((= mark gnus-ticked-mark)
8465 (push article gnus-newsgroup-marked))
8466 ((= mark gnus-dormant-mark)
8467 (push article gnus-newsgroup-dormant))
8469 (push article gnus-newsgroup-unreads)))
8470 (gnus-pull article gnus-newsgroup-reads)
8473 (defalias 'gnus-summary-mark-as-unread-forward
8474 'gnus-summary-tick-article-forward)
8475 (make-obsolete 'gnus-summary-mark-as-unread-forward
8476 'gnus-summary-tick-article-forward)
8477 (defun gnus-summary-tick-article-forward (n)
8478 "Tick N articles forwards.
8479 If N is negative, tick backwards instead.
8480 The difference between N and the number of articles ticked is returned."
8482 (gnus-summary-mark-forward n gnus-ticked-mark))
8484 (defalias 'gnus-summary-mark-as-unread-backward
8485 'gnus-summary-tick-article-backward)
8486 (make-obsolete 'gnus-summary-mark-as-unread-backward
8487 'gnus-summary-tick-article-backward)
8488 (defun gnus-summary-tick-article-backward (n)
8489 "Tick N articles backwards.
8490 The difference between N and the number of articles ticked is returned."
8492 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8494 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8495 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8496 (defun gnus-summary-tick-article (&optional article clear-mark)
8497 "Mark current article as unread.
8498 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8499 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8501 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8504 (defun gnus-summary-mark-as-read-forward (n)
8505 "Mark N articles as read forwards.
8506 If N is negative, mark backwards instead.
8507 The difference between N and the actual number of articles marked is
8510 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8512 (defun gnus-summary-mark-as-read-backward (n)
8513 "Mark the N articles as read backwards.
8514 The difference between N and the actual number of articles marked is
8517 (gnus-summary-mark-forward
8518 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8520 (defun gnus-summary-mark-as-read (&optional article mark)
8521 "Mark current article as read.
8522 ARTICLE specifies the article to be marked as read.
8523 MARK specifies a string to be inserted at the beginning of the line."
8524 (gnus-summary-mark-article article mark))
8526 (defun gnus-summary-clear-mark-forward (n)
8527 "Clear marks from N articles forward.
8528 If N is negative, clear backward instead.
8529 The difference between N and the number of marks cleared is returned."
8531 (gnus-summary-mark-forward n gnus-unread-mark))
8533 (defun gnus-summary-clear-mark-backward (n)
8534 "Clear marks from N articles backward.
8535 The difference between N and the number of marks cleared is returned."
8537 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8539 (defun gnus-summary-mark-unread-as-read ()
8540 "Intended to be used by `gnus-summary-mark-article-hook'."
8541 (when (memq gnus-current-article gnus-newsgroup-unreads)
8542 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8544 (defun gnus-summary-mark-read-and-unread-as-read ()
8545 "Intended to be used by `gnus-summary-mark-article-hook'."
8546 (let ((mark (gnus-summary-article-mark)))
8547 (when (or (gnus-unread-mark-p mark)
8548 (gnus-read-mark-p mark))
8549 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8551 (defun gnus-summary-mark-region-as-read (point mark all)
8552 "Mark all unread articles between point and mark as read.
8553 If given a prefix, mark all articles between point and mark as read,
8554 even ticked and dormant ones."
8555 (interactive "r\nP")
8564 (memq (setq article (gnus-summary-article-number))
8565 gnus-newsgroup-unreads))
8566 (gnus-summary-mark-article article gnus-del-mark))
8568 (gnus-summary-find-next))))))
8570 (defun gnus-summary-mark-below (score mark)
8571 "Mark articles with score less than SCORE with MARK."
8572 (interactive "P\ncMark: ")
8573 (setq score (if score
8574 (prefix-numeric-value score)
8575 (or gnus-summary-default-score 0)))
8577 (set-buffer gnus-summary-buffer)
8578 (goto-char (point-min))
8581 (and (< (gnus-summary-article-score) score)
8582 (gnus-summary-mark-article nil mark))
8583 (gnus-summary-find-next)))))
8585 (defun gnus-summary-kill-below (&optional score)
8586 "Mark articles with score below SCORE as read."
8588 (gnus-summary-mark-below score gnus-killed-mark))
8590 (defun gnus-summary-clear-above (&optional score)
8591 "Clear all marks from articles with score above SCORE."
8593 (gnus-summary-mark-above score gnus-unread-mark))
8595 (defun gnus-summary-tick-above (&optional score)
8596 "Tick all articles with score above SCORE."
8598 (gnus-summary-mark-above score gnus-ticked-mark))
8600 (defun gnus-summary-mark-above (score mark)
8601 "Mark articles with score over SCORE with MARK."
8602 (interactive "P\ncMark: ")
8603 (setq score (if score
8604 (prefix-numeric-value score)
8605 (or gnus-summary-default-score 0)))
8607 (set-buffer gnus-summary-buffer)
8608 (goto-char (point-min))
8610 (when (> (gnus-summary-article-score) score)
8611 (gnus-summary-mark-article nil mark))
8613 (gnus-summary-find-next)))))
8615 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8616 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8617 (defun gnus-summary-limit-include-expunged (&optional no-error)
8618 "Display all the hidden articles that were expunged for low scores."
8620 (let ((buffer-read-only nil))
8621 (let ((scored gnus-newsgroup-scored)
8624 (unless (gnus-summary-goto-subject (caar scored))
8625 (and (setq h (gnus-summary-article-header (caar scored)))
8626 (< (cdar scored) gnus-summary-expunge-below)
8628 (setq scored (cdr scored)))
8630 (when (not no-error)
8631 (error "No expunged articles hidden"))
8632 (goto-char (point-min))
8633 (gnus-summary-prepare-unthreaded (nreverse headers))
8634 (goto-char (point-min))
8635 (gnus-summary-position-point)
8638 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8639 "Mark all unread articles in this newsgroup as read.
8640 If prefix argument ALL is non-nil, ticked and dormant articles will
8641 also be marked as read.
8642 If QUIETLY is non-nil, no questions will be asked.
8643 If TO-HERE is non-nil, it should be a point in the buffer. All
8644 articles before this point will be marked as read.
8645 Note that this function will only catch up the unread article
8646 in the current summary buffer limitation.
8647 The number of articles marked as read is returned."
8652 (not gnus-interactive-catchup) ;Without confirmation?
8656 "Mark absolutely all articles as read? "
8657 "Mark all unread articles as read? ")))
8659 (not gnus-newsgroup-adaptive)
8660 (not gnus-newsgroup-auto-expire)
8661 (not gnus-suppress-duplicates)
8662 (or (not gnus-use-cache)
8663 (eq gnus-use-cache 'passive)))
8666 (setq gnus-newsgroup-marked nil
8667 gnus-newsgroup-dormant nil))
8668 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8669 ;; We actually mark all articles as canceled, which we
8670 ;; have to do when using auto-expiry or adaptive scoring.
8671 (gnus-summary-show-all-threads)
8672 (when (gnus-summary-first-subject (not all) t)
8674 (if to-here (< (point) to-here) t)
8675 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8676 (gnus-summary-find-next (not all) nil nil t))))
8677 (gnus-set-mode-line 'summary))
8679 (gnus-summary-position-point)))
8681 (defun gnus-summary-catchup-to-here (&optional all)
8682 "Mark all unticked articles before the current one as read.
8683 If ALL is non-nil, also mark ticked and dormant articles as read."
8686 (gnus-save-hidden-threads
8687 (let ((beg (point)))
8688 ;; We check that there are unread articles.
8689 (when (or all (gnus-summary-find-prev))
8690 (gnus-summary-catchup all t beg)))))
8691 (gnus-summary-position-point))
8693 (defun gnus-summary-catchup-all (&optional quietly)
8694 "Mark all articles in this newsgroup as read."
8696 (gnus-summary-catchup t quietly))
8698 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8699 "Mark all unread articles in this group as read, then exit.
8700 If prefix argument ALL is non-nil, all articles are marked as read."
8702 (when (gnus-summary-catchup all quietly nil 'fast)
8703 ;; Select next newsgroup or exit.
8704 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8705 (eq gnus-auto-select-next 'quietly))
8706 (gnus-summary-next-group nil)
8707 (gnus-summary-exit))))
8709 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8710 "Mark all articles in this newsgroup as read, and then exit."
8712 (gnus-summary-catchup-and-exit t quietly))
8714 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8715 "Mark all articles in this group as read and select the next group.
8716 If given a prefix, mark all articles, unread as well as ticked, as
8720 (gnus-summary-catchup all))
8721 (gnus-summary-next-group))
8727 (defmacro gnus-with-article (article &rest forms)
8728 "Select ARTICLE and perform FORMS in the original article buffer.
8729 Then replace the article with the result."
8731 ;; We don't want the article to be marked as read.
8732 (let (gnus-mark-article-hook)
8733 (gnus-summary-select-article t t nil ,article))
8734 (set-buffer gnus-original-article-buffer)
8736 (if (not (gnus-check-backend-function
8737 'request-replace-article (car gnus-article-current)))
8738 (gnus-message 5 "Read-only group; not replacing")
8739 (unless (gnus-request-replace-article
8740 ,article (car gnus-article-current)
8742 (error "Couldn't replace article")))
8743 ;; The cache and backlog have to be flushed somewhat.
8744 (when gnus-keep-backlog
8745 (gnus-backlog-remove-article
8746 (car gnus-article-current) (cdr gnus-article-current)))
8747 (when gnus-use-cache
8748 (gnus-cache-update-article
8749 (car gnus-article-current) (cdr gnus-article-current)))))
8751 (put 'gnus-with-article 'lisp-indent-function 1)
8752 (put 'gnus-with-article 'edebug-form-spec '(form body))
8754 ;; Thread-based commands.
8756 (defun gnus-summary-articles-in-thread (&optional article)
8757 "Return a list of all articles in the current thread.
8758 If ARTICLE is non-nil, return all articles in the thread that starts
8760 (let* ((article (or article (gnus-summary-article-number)))
8761 (data (gnus-data-find-list article))
8762 (top-level (gnus-data-level (car data)))
8764 (cond ((null gnus-thread-operation-ignore-subject)
8765 (gnus-simplify-subject-re
8766 (mail-header-subject (gnus-data-header (car data)))))
8767 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8768 (gnus-simplify-subject-fuzzy
8769 (mail-header-subject (gnus-data-header (car data)))))
8771 (end-point (save-excursion
8772 (if (gnus-summary-go-to-next-thread)
8773 (point) (point-max))))
8776 (< (gnus-data-pos (car data)) end-point))
8777 (when (or (not top-subject)
8778 (string= top-subject
8779 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8780 (gnus-simplify-subject-fuzzy
8781 (mail-header-subject
8782 (gnus-data-header (car data))))
8783 (gnus-simplify-subject-re
8784 (mail-header-subject
8785 (gnus-data-header (car data)))))))
8786 (push (gnus-data-number (car data)) articles))
8787 (unless (and (setq data (cdr data))
8788 (> (gnus-data-level (car data)) top-level))
8790 ;; Return the list of articles.
8791 (nreverse articles)))
8793 (defun gnus-summary-rethread-current ()
8794 "Rethread the thread the current article is part of."
8796 (let* ((gnus-show-threads t)
8797 (article (gnus-summary-article-number))
8798 (id (mail-header-id (gnus-summary-article-header)))
8799 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8801 (error "No article on the current line"))
8802 (gnus-rebuild-thread id)
8803 (gnus-summary-goto-subject article)))
8805 (defun gnus-summary-reparent-thread ()
8806 "Make the current article child of the marked (or previous) article.
8808 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8809 is non-nil or the Subject: of both articles are the same."
8811 (unless (not (gnus-group-read-only-p))
8812 (error "The current newsgroup does not support article editing"))
8813 (unless (<= (length gnus-newsgroup-processable) 1)
8814 (error "No more than one article may be marked"))
8815 (save-window-excursion
8816 (let ((gnus-article-buffer " *reparent*")
8817 (current-article (gnus-summary-article-number))
8818 ;; First grab the marked article, otherwise one line up.
8819 (parent-article (if (not (null gnus-newsgroup-processable))
8820 (car gnus-newsgroup-processable)
8822 (if (eq (forward-line -1) 0)
8823 (gnus-summary-article-number)
8824 (error "Beginning of summary buffer"))))))
8825 (unless (not (eq current-article parent-article))
8826 (error "An article may not be self-referential"))
8827 (let ((message-id (mail-header-id
8828 (gnus-summary-article-header parent-article))))
8829 (unless (and message-id (not (equal message-id "")))
8830 (error "No message-id in desired parent"))
8831 (gnus-with-article current-article
8833 (goto-char (point-min))
8834 (message-narrow-to-head)
8835 (if (re-search-forward "^References: " nil t)
8837 (re-search-forward "^[^ \t]" nil t)
8840 (insert " " message-id))
8841 (insert "References: " message-id "\n"))))
8842 (set-buffer gnus-summary-buffer)
8843 (gnus-summary-unmark-all-processable)
8844 (gnus-summary-update-article current-article)
8845 (gnus-summary-rethread-current)
8846 (gnus-message 3 "Article %d is now the child of article %d"
8847 current-article parent-article)))))
8849 (defun gnus-summary-toggle-threads (&optional arg)
8850 "Toggle showing conversation threads.
8851 If ARG is positive number, turn showing conversation threads on."
8853 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8854 (setq gnus-show-threads
8855 (if (null arg) (not gnus-show-threads)
8856 (> (prefix-numeric-value arg) 0)))
8857 (gnus-summary-prepare)
8858 (gnus-summary-goto-subject current)
8859 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8860 (gnus-summary-position-point)))
8862 (defun gnus-summary-show-all-threads ()
8866 (let ((buffer-read-only nil))
8867 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8868 (gnus-summary-position-point))
8870 (defun gnus-summary-show-thread ()
8871 "Show thread subtrees.
8872 Returns nil if no thread was there to be shown."
8874 (let ((buffer-read-only nil)
8876 ;; first goto end then to beg, to have point at beg after let
8877 (end (progn (end-of-line) (point)))
8878 (beg (progn (beginning-of-line) (point))))
8880 ;; Any hidden lines here?
8881 (search-forward "\r" end t)
8882 (subst-char-in-region beg end ?\^M ?\n t)
8884 (gnus-summary-position-point))))
8886 (defun gnus-summary-hide-all-threads ()
8887 "Hide all thread subtrees."
8890 (goto-char (point-min))
8891 (gnus-summary-hide-thread)
8892 (while (zerop (gnus-summary-next-thread 1 t))
8893 (gnus-summary-hide-thread)))
8894 (gnus-summary-position-point))
8896 (defun gnus-summary-hide-thread ()
8897 "Hide thread subtrees.
8898 Returns nil if no threads were there to be hidden."
8900 (let ((buffer-read-only nil)
8902 (article (gnus-summary-article-number)))
8904 ;; Go forward until either the buffer ends or the subthread
8906 (when (and (not (eobp))
8907 (or (zerop (gnus-summary-next-thread 1 t))
8908 (goto-char (point-max))))
8910 (if (and (> (point) start)
8911 (search-backward "\n" start t))
8913 (subst-char-in-region start (point) ?\n ?\^M)
8914 (gnus-summary-goto-subject article))
8918 (defun gnus-summary-go-to-next-thread (&optional previous)
8919 "Go to the same level (or less) next thread.
8920 If PREVIOUS is non-nil, go to previous thread instead.
8921 Return the article number moved to, or nil if moving was impossible."
8922 (let ((level (gnus-summary-thread-level))
8923 (way (if previous -1 1))
8926 (while (and (not (eobp))
8927 (< level (gnus-summary-thread-level)))
8935 (gnus-summary-article-number)
8938 (defun gnus-summary-next-thread (n &optional silent)
8939 "Go to the same level next N'th thread.
8940 If N is negative, search backward instead.
8941 Returns the difference between N and the number of skips actually
8944 If SILENT, don't output messages."
8946 (let ((backward (< n 0))
8949 (gnus-summary-go-to-next-thread backward))
8952 (gnus-summary-position-point))
8953 (when (and (not silent) (/= 0 n))
8954 (gnus-message 7 "No more threads"))
8957 (defun gnus-summary-prev-thread (n)
8958 "Go to the same level previous N'th thread.
8959 Returns the difference between N and the number of skips actually
8962 (gnus-summary-next-thread (- n)))
8964 (defun gnus-summary-go-down-thread ()
8965 "Go down one level in the current thread."
8966 (let ((children (gnus-summary-article-children)))
8968 (gnus-summary-goto-subject (car children)))))
8970 (defun gnus-summary-go-up-thread ()
8971 "Go up one level in the current thread."
8972 (let ((parent (gnus-summary-article-parent)))
8974 (gnus-summary-goto-subject parent))))
8976 (defun gnus-summary-down-thread (n)
8977 "Go down thread N steps.
8978 If N is negative, go up instead.
8979 Returns the difference between N and how many steps down that were
8985 (if up (gnus-summary-go-up-thread)
8986 (gnus-summary-go-down-thread)))
8988 (gnus-summary-position-point)
8990 (gnus-message 7 "Can't go further"))
8993 (defun gnus-summary-up-thread (n)
8994 "Go up thread N steps.
8995 If N is negative, go up instead.
8996 Returns the difference between N and how many steps down that were
8999 (gnus-summary-down-thread (- n)))
9001 (defun gnus-summary-top-thread ()
9002 "Go to the top of the thread."
9004 (while (gnus-summary-go-up-thread))
9005 (gnus-summary-article-number))
9007 (defun gnus-summary-kill-thread (&optional unmark)
9008 "Mark articles under current thread as read.
9009 If the prefix argument is positive, remove any kinds of marks.
9010 If the prefix argument is negative, tick articles instead."
9013 (setq unmark (prefix-numeric-value unmark)))
9014 (let ((articles (gnus-summary-articles-in-thread)))
9016 ;; Expand the thread.
9017 (gnus-summary-show-thread)
9018 ;; Mark all the articles.
9020 (gnus-summary-goto-subject (car articles))
9021 (cond ((null unmark)
9022 (gnus-summary-mark-article-as-read gnus-killed-mark))
9024 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9026 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9027 (setq articles (cdr articles))))
9028 ;; Hide killed subtrees.
9030 gnus-thread-hide-killed
9031 (gnus-summary-hide-thread))
9032 ;; If marked as read, go to next unread subject.
9034 ;; Go to next unread subject.
9035 (gnus-summary-next-subject 1 t)))
9036 (gnus-set-mode-line 'summary))
9038 ;; Summary sorting commands
9040 (defun gnus-summary-sort-by-number (&optional reverse)
9041 "Sort the summary buffer by article number.
9042 Argument REVERSE means reverse order."
9044 (gnus-summary-sort 'number reverse))
9046 (defun gnus-summary-sort-by-author (&optional reverse)
9047 "Sort the summary buffer by author name alphabetically.
9048 If `case-fold-search' is non-nil, case of letters is ignored.
9049 Argument REVERSE means reverse order."
9051 (gnus-summary-sort 'author reverse))
9053 (defun gnus-summary-sort-by-subject (&optional reverse)
9054 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9055 If `case-fold-search' is non-nil, case of letters is ignored.
9056 Argument REVERSE means reverse order."
9058 (gnus-summary-sort 'subject reverse))
9060 (defun gnus-summary-sort-by-date (&optional reverse)
9061 "Sort the summary buffer by date.
9062 Argument REVERSE means reverse order."
9064 (gnus-summary-sort 'date reverse))
9066 (defun gnus-summary-sort-by-score (&optional reverse)
9067 "Sort the summary buffer by score.
9068 Argument REVERSE means reverse order."
9070 (gnus-summary-sort 'score reverse))
9072 (defun gnus-summary-sort-by-lines (&optional reverse)
9073 "Sort the summary buffer by the number of lines.
9074 Argument REVERSE means reverse order."
9076 (gnus-summary-sort 'lines reverse))
9078 (defun gnus-summary-sort-by-chars (&optional reverse)
9079 "Sort the summary buffer by article length.
9080 Argument REVERSE means reverse order."
9082 (gnus-summary-sort 'chars reverse))
9084 (defun gnus-summary-sort (predicate reverse)
9085 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9086 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9087 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9088 (gnus-thread-sort-functions
9093 (gnus-sort-gathered-threads-function
9094 gnus-thread-sort-functions)
9095 (gnus-article-sort-functions
9101 (gnus-summary-prepare-hook nil))
9102 ;; We do the sorting by regenerating the threads.
9103 (gnus-summary-prepare)
9104 ;; Hide subthreads if needed.
9105 (when (and gnus-show-threads gnus-thread-hide-subtree)
9106 (gnus-summary-hide-all-threads))))
9108 ;; Summary saving commands.
9110 (defun gnus-summary-save-article (&optional n not-saved)
9111 "Save the current article using the default saver function.
9112 If N is a positive number, save the N next articles.
9113 If N is a negative number, save the N previous articles.
9114 If N is nil and any articles have been marked with the process mark,
9115 save those articles instead.
9116 The variable `gnus-default-article-saver' specifies the saver function."
9118 (let* ((articles (gnus-summary-work-articles n))
9119 (save-buffer (save-excursion
9120 (nnheader-set-temp-buffer " *Gnus Save*")))
9121 (num (length articles))
9123 (dolist (article articles)
9124 (setq header (gnus-summary-article-header article))
9125 (if (not (vectorp header))
9126 ;; This is a pseudo-article.
9127 (if (assq 'name header)
9128 (gnus-copy-file (cdr (assq 'name header)))
9129 (gnus-message 1 "Article %d is unsaveable" article))
9130 ;; This is a real article.
9131 (save-window-excursion
9132 (gnus-summary-select-article t nil nil article))
9134 (set-buffer save-buffer)
9136 (insert-buffer-substring gnus-original-article-buffer))
9137 (setq file (gnus-article-save save-buffer file num))
9138 (gnus-summary-remove-process-mark article)
9140 (gnus-summary-set-saved-mark article))))
9141 (gnus-kill-buffer save-buffer)
9142 (gnus-summary-position-point)
9143 (gnus-set-mode-line 'summary)
9146 (defun gnus-summary-pipe-output (&optional arg)
9147 "Pipe the current article to a subprocess.
9148 If N is a positive number, pipe the N next articles.
9149 If N is a negative number, pipe the N previous articles.
9150 If N is nil and any articles have been marked with the process mark,
9151 pipe those articles instead."
9153 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9154 (gnus-summary-save-article arg t))
9155 (gnus-configure-windows 'pipe))
9157 (defun gnus-summary-save-article-mail (&optional arg)
9158 "Append the current article to an mail file.
9159 If N is a positive number, save the N next articles.
9160 If N is a negative number, save the N previous articles.
9161 If N is nil and any articles have been marked with the process mark,
9162 save those articles instead."
9164 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9165 (gnus-summary-save-article arg)))
9167 (defun gnus-summary-save-article-rmail (&optional arg)
9168 "Append the current article to an rmail file.
9169 If N is a positive number, save the N next articles.
9170 If N is a negative number, save the N previous articles.
9171 If N is nil and any articles have been marked with the process mark,
9172 save those articles instead."
9174 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9175 (gnus-summary-save-article arg)))
9177 (defun gnus-summary-save-article-file (&optional arg)
9178 "Append the current article to a file.
9179 If N is a positive number, save the N next articles.
9180 If N is a negative number, save the N previous articles.
9181 If N is nil and any articles have been marked with the process mark,
9182 save those articles instead."
9184 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9185 (gnus-summary-save-article arg)))
9187 (defun gnus-summary-write-article-file (&optional arg)
9188 "Write the current article to a file, deleting the previous file.
9189 If N is a positive number, save the N next articles.
9190 If N is a negative number, save the N previous articles.
9191 If N is nil and any articles have been marked with the process mark,
9192 save those articles instead."
9194 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9195 (gnus-summary-save-article arg)))
9197 (defun gnus-summary-save-article-body-file (&optional arg)
9198 "Append the current article body to a file.
9199 If N is a positive number, save the N next articles.
9200 If N is a negative number, save the N previous articles.
9201 If N is nil and any articles have been marked with the process mark,
9202 save those articles instead."
9204 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9205 (gnus-summary-save-article arg)))
9207 (defun gnus-summary-pipe-message (program)
9208 "Pipe the current article through PROGRAM."
9209 (interactive "sProgram: ")
9210 (gnus-summary-select-article)
9211 (let ((mail-header-separator ""))
9212 (gnus-eval-in-buffer-window gnus-article-buffer
9215 (let ((start (window-start))
9217 (message-pipe-buffer-body program)
9218 (set-window-start (get-buffer-window (current-buffer)) start))))))
9220 (defun gnus-get-split-value (methods)
9221 "Return a value based on the split METHODS."
9222 (let (split-name method result match)
9225 (set-buffer gnus-original-article-buffer)
9227 (nnheader-narrow-to-headers)
9228 (while (and methods (not split-name))
9229 (goto-char (point-min))
9230 (setq method (pop methods))
9231 (setq match (car method))
9234 ;; Regular expression.
9236 (re-search-forward match nil t)))
9237 ((gnus-functionp match)
9241 (setq result (funcall match gnus-newsgroup-name))))
9246 (setq result (eval match)))))
9247 (setq split-name (cdr method))
9248 (cond ((stringp result)
9249 (push (expand-file-name
9250 result gnus-article-save-directory)
9253 (setq split-name (append result split-name)))))))))
9254 (nreverse split-name)))
9256 (defun gnus-valid-move-group-p (group)
9259 (symbol-value group)
9260 (gnus-get-function (gnus-find-method-for-group
9261 (symbol-name group)) 'request-accept-article t)))
9263 (defun gnus-read-move-group-name (prompt default articles prefix)
9264 "Read a group name."
9265 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9266 (minibuffer-confirm-incomplete nil) ; XEmacs
9270 (if (> (length articles) 1)
9271 (format "these %d articles" (length articles))
9276 (gnus-completing-read default prom
9278 'gnus-valid-move-group-p
9280 'gnus-group-history))
9281 ((= 1 (length split-name))
9282 (gnus-completing-read (car split-name) prom
9284 'gnus-valid-move-group-p
9286 'gnus-group-history))
9288 (gnus-completing-read nil prom
9289 (mapcar (lambda (el) (list el))
9290 (nreverse split-name))
9292 'gnus-group-history))))
9293 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9295 (if (or (string= to-newsgroup "")
9296 (string= to-newsgroup prefix))
9297 (setq to-newsgroup default))
9298 (unless to-newsgroup
9299 (error "No group name entered"))
9300 (or (gnus-active to-newsgroup)
9301 (gnus-activate-group to-newsgroup nil nil to-method)
9302 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9304 (or (and (gnus-request-create-group to-newsgroup to-method)
9305 (gnus-activate-group
9306 to-newsgroup nil nil to-method)
9307 (gnus-subscribe-group to-newsgroup))
9308 (error "Couldn't create group %s" to-newsgroup)))
9309 (error "No such group: %s" to-newsgroup)))
9312 (defun gnus-summary-save-parts (type dir n &optional reverse)
9313 "Save parts matching TYPE to DIR.
9314 If REVERSE, save parts that do not match TYPE."
9316 (list (read-string "Save parts of type: "
9317 (or (car gnus-summary-save-parts-type-history)
9318 gnus-summary-save-parts-default-mime)
9319 'gnus-summary-save-parts-type-history)
9320 (setq gnus-summary-save-parts-last-directory
9321 (read-file-name "Save to directory: "
9322 gnus-summary-save-parts-last-directory
9324 current-prefix-arg))
9325 (gnus-summary-iterate n
9326 (let ((gnus-display-mime-function nil)
9327 (gnus-inhibit-treatment t))
9328 (gnus-summary-select-article))
9330 (set-buffer gnus-article-buffer)
9331 (let ((handles (or gnus-article-mime-handles
9332 (mm-dissect-buffer) (mm-uu-dissect))))
9334 (gnus-summary-save-parts-1 type dir handles reverse)
9335 (unless gnus-article-mime-handles ;; Don't destroy this case.
9336 (mm-destroy-parts handles)))))))
9338 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9339 (if (stringp (car handle))
9340 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9343 (not (string-match type (mm-handle-media-type handle)))
9344 (string-match type (mm-handle-media-type handle)))
9345 (let ((file (expand-file-name
9346 (file-name-nondirectory
9348 (mail-content-type-get
9349 (mm-handle-disposition handle) 'filename)
9350 (concat gnus-newsgroup-name
9351 "." (number-to-string
9352 (cdr gnus-article-current)))))
9354 (unless (file-exists-p file)
9355 (mm-save-part-to-file handle file))))))
9357 ;; Summary extract commands
9359 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9360 (let ((buffer-read-only nil)
9361 (article (gnus-summary-article-number))
9363 (unless (gnus-summary-goto-subject article)
9364 (error "No such article: %d" article))
9365 (gnus-summary-position-point)
9366 ;; If all commands are to be bunched up on one line, we collect
9368 (unless gnus-view-pseudos-separately
9369 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9372 (setq action (cdr (assq 'action (car ps))))
9373 (setq files (list (cdr (assq 'name (car ps)))))
9374 (while (and ps (cdr ps)
9375 (string= (or action "1")
9376 (or (cdr (assq 'action (cadr ps))) "2")))
9377 (push (cdr (assq 'name (cadr ps))) files)
9378 (setcdr ps (cddr ps)))
9380 (when (not (string-match "%s" action))
9383 (when (assq 'execute (car ps))
9384 (setcdr (assq 'execute (car ps))
9385 (funcall (if (string-match "%s" action)
9394 (setq ps (cdr ps)))))
9395 (if (and gnus-view-pseudos (not not-view))
9397 (when (assq 'execute (car pslist))
9398 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9399 (eq gnus-view-pseudos 'not-confirm)))
9400 (setq pslist (cdr pslist)))
9403 (setq after-article (or (cdr (assq 'article (car pslist)))
9404 (gnus-summary-article-number)))
9405 (gnus-summary-goto-subject after-article)
9408 (insert " " (file-name-nondirectory
9409 (cdr (assq 'name (car pslist))))
9410 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9412 (forward-line -1) ; back to `b'
9413 (gnus-add-text-properties
9414 b (1- e) (list 'gnus-number gnus-reffed-article-number
9415 gnus-mouse-face-prop gnus-mouse-face))
9417 after-article gnus-reffed-article-number
9418 gnus-unread-mark b (car pslist) 0 (- e b))
9419 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9420 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9421 (setq pslist (cdr pslist)))))))
9423 (defun gnus-pseudos< (p1 p2)
9424 (let ((c1 (cdr (assq 'action p1)))
9425 (c2 (cdr (assq 'action p2))))
9426 (and c1 c2 (string< c1 c2))))
9428 (defun gnus-request-pseudo-article (props)
9429 (cond ((assq 'execute props)
9430 (gnus-execute-command (cdr (assq 'execute props)))))
9431 (let ((gnus-current-article (gnus-summary-article-number)))
9432 (gnus-run-hooks 'gnus-mark-article-hook)))
9434 (defun gnus-execute-command (command &optional automatic)
9436 (gnus-article-setup-buffer)
9437 (set-buffer gnus-article-buffer)
9438 (setq buffer-read-only nil)
9439 (let ((command (if automatic command
9440 (read-string "Command: " (cons command 0)))))
9442 (insert "$ " command "\n\n")
9443 (if gnus-view-pseudo-asynchronously
9444 (start-process "gnus-execute" (current-buffer) shell-file-name
9445 shell-command-switch command)
9446 (call-process shell-file-name nil t nil
9447 shell-command-switch command)))))
9449 ;; Summary kill commands.
9451 (defun gnus-summary-edit-global-kill (article)
9452 "Edit the \"global\" kill file."
9453 (interactive (list (gnus-summary-article-number)))
9454 (gnus-group-edit-global-kill article))
9456 (defun gnus-summary-edit-local-kill ()
9457 "Edit a local kill file applied to the current newsgroup."
9459 (setq gnus-current-headers (gnus-summary-article-header))
9460 (gnus-group-edit-local-kill
9461 (gnus-summary-article-number) gnus-newsgroup-name))
9465 (defun gnus-read-header (id &optional header)
9466 "Read the headers of article ID and enter them into the Gnus system."
9467 (let ((group gnus-newsgroup-name)
9468 (gnus-override-method
9470 gnus-override-method
9471 (and (gnus-news-group-p gnus-newsgroup-name)
9472 (car (gnus-refer-article-methods)))))
9474 ;; First we check to see whether the header in question is already
9477 ;; This is a Message-ID.
9478 (setq header (or header (gnus-id-to-header id)))
9479 ;; This is an article number.
9480 (setq header (or header (gnus-summary-article-header id))))
9482 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9483 ;; We have found the header.
9485 ;; If this is a sparse article, we have to nix out its
9486 ;; previous entry in the thread hashtb.
9488 (gnus-summary-article-sparse-p (mail-header-number header)))
9489 (let* ((parent (gnus-parent-id (mail-header-references header)))
9490 (thread (and parent (gnus-id-to-thread parent))))
9492 (delq (assq header thread) thread))))
9493 ;; We have to really fetch the header to this article.
9495 (set-buffer nntp-server-buffer)
9496 (when (setq where (gnus-request-head id group))
9497 (nnheader-fold-continuation-lines)
9498 (goto-char (point-max))
9500 (goto-char (point-min))
9504 ((cdr where) (cdr where))
9505 (header (mail-header-number header))
9506 (t gnus-reffed-article-number))
9508 (insert " Article retrieved.\n"))
9510 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9511 () ; Malformed head.
9512 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9513 (when (and (stringp id)
9514 (not (string= (gnus-group-real-name group)
9516 ;; If we fetched by Message-ID and the article came
9517 ;; from a different group, we fudge some bogus article
9518 ;; numbers for this article.
9519 (mail-header-set-number header gnus-reffed-article-number))
9521 (set-buffer gnus-summary-buffer)
9522 (decf gnus-reffed-article-number)
9523 (gnus-remove-header (mail-header-number header))
9524 (push header gnus-newsgroup-headers)
9525 (setq gnus-current-headers header)
9526 (push (mail-header-number header) gnus-newsgroup-limit)))
9529 (defun gnus-remove-header (number)
9530 "Remove header NUMBER from `gnus-newsgroup-headers'."
9531 (if (and gnus-newsgroup-headers
9532 (= number (mail-header-number (car gnus-newsgroup-headers))))
9533 (pop gnus-newsgroup-headers)
9534 (let ((headers gnus-newsgroup-headers))
9535 (while (and (cdr headers)
9536 (not (= number (mail-header-number (cadr headers)))))
9539 (setcdr headers (cddr headers))))))
9542 ;;; summary highlights
9545 (defun gnus-highlight-selected-summary ()
9546 "Highlight selected article in summary buffer."
9547 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9548 (when gnus-summary-selected-face
9550 (let* ((beg (progn (beginning-of-line) (point)))
9551 (end (progn (end-of-line) (point)))
9552 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9553 (from (if (get-text-property beg gnus-mouse-face-prop)
9555 (or (next-single-property-change
9556 beg gnus-mouse-face-prop nil end)
9561 (or (next-single-property-change
9562 from gnus-mouse-face-prop nil end)
9564 ;; If no mouse-face prop on line we will have to = from = end,
9565 ;; so we highlight the entire line instead.
9566 (when (= (+ to 2) from)
9569 (if gnus-newsgroup-selected-overlay
9570 ;; Move old overlay.
9572 gnus-newsgroup-selected-overlay from to (current-buffer))
9573 ;; Create new overlay.
9575 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9576 'face gnus-summary-selected-face))))))
9578 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9579 (defun gnus-summary-highlight-line ()
9580 "Highlight current line according to `gnus-summary-highlight'."
9581 (let* ((list gnus-summary-highlight)
9583 (end (progn (end-of-line) (point)))
9584 ;; now find out where the line starts and leave point there.
9585 (beg (progn (beginning-of-line) (point)))
9586 (article (gnus-summary-article-number))
9587 (score (or (cdr (assq (or article gnus-current-article)
9588 gnus-newsgroup-scored))
9589 gnus-summary-default-score 0))
9590 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9591 (inhibit-read-only t))
9592 ;; Eval the cars of the lists until we find a match.
9593 (let ((default gnus-summary-default-score))
9595 (not (eval (caar list))))
9596 (setq list (cdr list))))
9597 (let ((face (cdar list)))
9598 (unless (eq face (get-text-property beg 'face))
9599 (gnus-put-text-property-excluding-characters-with-faces
9601 (setq face (if (boundp face) (symbol-value face) face)))
9602 (when gnus-summary-highlight-line-function
9603 (funcall gnus-summary-highlight-line-function article face))))
9606 (defun gnus-update-read-articles (group unread &optional compute)
9607 "Update the list of read articles in GROUP."
9608 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9609 (entry (gnus-gethash group gnus-newsrc-hashtb))
9610 (info (nth 2 entry))
9612 (unread (sort (copy-sequence unread) '<))
9614 (if (or (not info) (not active))
9615 ;; There is no info on this group if it was, in fact,
9616 ;; killed. Gnus stores no information on killed groups, so
9617 ;; there's nothing to be done.
9618 ;; One could store the information somewhere temporarily,
9619 ;; perhaps... Hmmm...
9621 ;; Remove any negative articles numbers.
9622 (while (and unread (< (car unread) 0))
9623 (setq unread (cdr unread)))
9624 ;; Remove any expired article numbers
9625 (while (and unread (< (car unread) (car active)))
9626 (setq unread (cdr unread)))
9627 ;; Compute the ranges of read articles by looking at the list of
9630 (when (/= (car unread) prev)
9631 (push (if (= prev (1- (car unread))) prev
9632 (cons prev (1- (car unread))))
9634 (setq prev (1+ (car unread)))
9635 (setq unread (cdr unread)))
9636 (when (<= prev (cdr active))
9637 (push (cons prev (cdr active)) read))
9638 (setq read (if (> (length read) 1) (nreverse read) read))
9643 ;; Propagate the read marks to the backend.
9644 (when (gnus-check-backend-function 'request-set-mark group)
9645 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9646 (add (gnus-remove-from-range read (gnus-info-read info))))
9648 (unless (gnus-check-group group)
9649 (error "Can't open server for %s" group))
9650 (gnus-request-set-mark
9651 group (delq nil (list (if add (list add 'add '(read)))
9652 (if del (list del 'del '(read))))))
9654 `(gnus-request-set-mark
9657 (if del (list del 'add '(read)))
9658 (if add (list add 'del '(read))))))))))
9659 (set-buffer gnus-group-buffer)
9662 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9663 (gnus-info-set-read ',info ',(gnus-info-read info))
9664 (gnus-get-unread-articles-in-group ',info
9665 (gnus-active ,group))
9666 (gnus-group-update-group ,group t)
9668 ;; Enter this list into the group info.
9669 (gnus-info-set-read info read)
9670 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9671 (gnus-get-unread-articles-in-group info (gnus-active group))
9674 (defun gnus-offer-save-summaries ()
9675 "Offer to save all active summary buffers."
9677 (let ((buflist (buffer-list))
9679 ;; Go through all buffers and find all summaries.
9681 (and (setq bufname (buffer-name (car buflist)))
9682 (string-match "Summary" bufname)
9684 (set-buffer bufname)
9685 ;; We check that this is, indeed, a summary buffer.
9686 (and (eq major-mode 'gnus-summary-mode)
9687 ;; Also make sure this isn't bogus.
9688 gnus-newsgroup-prepared
9689 ;; Also make sure that this isn't a dead summary buffer.
9690 (not gnus-dead-summary-mode)))
9691 (push bufname buffers))
9692 (setq buflist (cdr buflist)))
9693 ;; Go through all these summary buffers and offer to save them.
9696 "Update summary buffer %s? "
9698 (switch-to-buffer buf)
9699 (gnus-summary-exit))
9702 (defun gnus-summary-setup-default-charset ()
9703 "Setup newsgroup default charset."
9704 (if (equal gnus-newsgroup-name "nndraft:drafts")
9705 (setq gnus-newsgroup-charset nil)
9706 (let* ((name (and gnus-newsgroup-name
9707 (gnus-group-real-name gnus-newsgroup-name)))
9709 (or gnus-newsgroup-ephemeral-ignored-charsets
9711 (and gnus-newsgroup-name
9712 (or (gnus-group-find-parameter gnus-newsgroup-name
9713 'ignored-charsets t)
9714 (let ((alist gnus-group-ignored-charsets-alist)
9715 elem (charsets nil))
9716 (while (setq elem (pop alist))
9718 (string-match (car elem) name))
9720 charsets (cdr elem))))
9722 gnus-newsgroup-ignored-charsets))))
9723 (setq gnus-newsgroup-charset
9724 (or gnus-newsgroup-ephemeral-charset
9725 (and gnus-newsgroup-name
9726 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9727 (let ((alist gnus-group-charset-alist)
9729 (while (setq elem (pop alist))
9731 (string-match (car elem) name))
9733 charset (cadr elem))))
9735 gnus-default-charset))
9736 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9737 ignored-charsets))))
9743 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9744 "Display the current article buffer fully MIME-buttonized.
9745 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9746 treated as multipart/mixed."
9749 (let ((gnus-unbuttonized-mime-types nil)
9750 (gnus-mime-display-multipart-as-mixed show-all-parts))
9751 (gnus-summary-show-article)))
9753 (defun gnus-summary-repair-multipart (article)
9754 "Add a Content-Type header to a multipart article without one."
9755 (interactive (list (gnus-summary-article-number)))
9756 (gnus-with-article article
9757 (message-narrow-to-head)
9758 (goto-char (point-max))
9760 (when (search-forward "\n--" nil t)
9761 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9762 (message-narrow-to-head)
9763 (message-remove-header "Mime-Version")
9764 (message-remove-header "Content-Type")
9765 (goto-char (point-max))
9766 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9768 (insert "Mime-Version: 1.0\n")
9770 (let (gnus-mark-article-hook)
9771 (gnus-summary-select-article t t nil article)))
9773 (defun gnus-summary-toggle-display-buttonized ()
9774 "Toggle the buttonizing of the article buffer."
9777 (if (setq gnus-inhibit-mime-unbuttonizing
9778 (not gnus-inhibit-mime-unbuttonizing))
9779 (let ((gnus-unbuttonized-mime-types nil))
9780 (gnus-summary-show-article))
9781 (gnus-summary-show-article)))
9784 ;;; Generic summary marking commands
9787 (defvar gnus-summary-marking-alist
9788 '((read gnus-del-mark "d")
9789 (unread gnus-unread-mark "u")
9790 (ticked gnus-ticked-mark "!")
9791 (dormant gnus-dormant-mark "?")
9792 (expirable gnus-expirable-mark "e"))
9793 "An alist of names/marks/keystrokes.")
9795 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9796 (defvar gnus-summary-mark-map)
9798 (defun gnus-summary-make-all-marking-commands ()
9799 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9800 (dolist (elem gnus-summary-marking-alist)
9801 (apply 'gnus-summary-make-marking-command elem)))
9803 (defun gnus-summary-make-marking-command (name mark keystroke)
9804 (let ((map (make-sparse-keymap)))
9805 (define-key gnus-summary-generic-mark-map keystroke map)
9806 (dolist (lway `((next "next" next nil "n")
9807 (next-unread "next unread" next t "N")
9808 (prev "previous" prev nil "p")
9809 (prev-unread "previous unread" prev t "P")
9810 (nomove "" nil nil ,keystroke)))
9811 (let ((func (gnus-summary-make-marking-command-1
9812 mark (car lway) lway name)))
9813 (setq func (eval func))
9814 (define-key map (nth 4 lway) func)))))
9816 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9818 (format "gnus-summary-put-mark-as-%s%s"
9819 name (if (eq way 'nomove)
9821 (concat "-" (symbol-name way)))))
9824 "Mark the current article as %s%s.
9825 If N, the prefix, then repeat N times.
9826 If N is negative, move in reverse order.
9827 The difference between N and the actual number of articles marked is
9831 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9833 (defun gnus-summary-generic-mark (n mark move unread)
9834 "Mark N articles with MARK."
9835 (unless (eq major-mode 'gnus-summary-mode)
9836 (error "This command can only be used in the summary buffer"))
9837 (gnus-summary-show-thread)
9841 ((eq move 'prev) -1)
9847 nummove (* -1 nummove))))
9849 (gnus-summary-mark-article nil mark)
9850 (zerop (gnus-summary-next-subject nummove unread t)))
9853 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9854 (gnus-summary-recenter)
9855 (gnus-summary-position-point)
9856 (gnus-set-mode-line 'summary)
9859 (gnus-summary-make-all-marking-commands)
9865 (run-hooks 'gnus-sum-load-hook)
9867 ;;; gnus-sum.el ends here