1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
47 (autoload 'gnus-cache-articles-in-group "gnus-cache")
48 (autoload 'pgg-decrypt-region "pgg" nil t)
49 (autoload 'pgg-verify-region "pgg" nil t))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
54 (defcustom gnus-kill-summary-on-exit t
55 "*If non-nil, kill the summary buffer when you exit from it.
56 If nil, the summary will become a \"*Dead Summary*\" buffer, and
57 it will be killed sometime later."
58 :group 'gnus-summary-exit
61 (defcustom gnus-fetch-old-headers nil
62 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
63 If an unread article in the group refers to an older, already read (or
64 just marked as read) article, the old article will not normally be
65 displayed in the Summary buffer. If this variable is non-nil, Gnus
66 will attempt to grab the headers to the old articles, and thereby
67 build complete threads. If it has the value `some', only enough
68 headers to connect otherwise loose threads will be displayed. This
69 variable can also be a number. In that case, no more than that number
70 of old headers will be fetched. If it has the value `invisible', all
71 old headers will be fetched, but none will be displayed.
73 The server has to support NOV for any of this to work."
75 :type '(choice (const :tag "off" nil)
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-refer-thread-limit 200
81 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
82 If t, fetch all the available old headers."
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-summary-make-false-root 'adopt
88 "*nil means that Gnus won't gather loose threads.
89 If the root of a thread has expired or been read in a previous
90 session, the information necessary to build a complete thread has been
91 lost. Instead of having many small sub-threads from this original thread
92 scattered all over the summary buffer, Gnus can gather them.
94 If non-nil, Gnus will try to gather all loose sub-threads from an
95 original thread into one large thread.
97 If this variable is non-nil, it should be one of `none', `adopt',
100 If this variable is `none', Gnus will not make a false root, but just
101 present the sub-threads after another.
102 If this variable is `dummy', Gnus will create a dummy root that will
103 have all the sub-threads as children.
104 If this variable is `adopt', Gnus will make one of the \"children\"
105 the parent and mark all the step-children as such.
106 If this variable is `empty', the \"children\" are printed with empty
107 subject fields. (Or rather, they will be printed with a string
108 given by the `gnus-summary-same-subject' variable.)"
110 :type '(choice (const :tag "off" nil)
116 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
117 "*A regexp to match subjects to be excluded from loose thread gathering.
118 As loose thread gathering is done on subjects only, that means that
119 there can be many false gatherings performed. By rooting out certain
120 common subjects, gathering might become saner."
124 (defcustom gnus-summary-gather-subject-limit nil
125 "*Maximum length of subject comparisons when gathering loose threads.
126 Use nil to compare full subjects. Setting this variable to a low
127 number will help gather threads that have been corrupted by
128 newsreaders chopping off subject lines, but it might also mean that
129 unrelated articles that have subject that happen to begin with the
130 same few characters will be incorrectly gathered.
132 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
135 :type '(choice (const :tag "off" nil)
137 (sexp :menu-tag "on" t)))
139 (defcustom gnus-simplify-subject-functions nil
140 "List of functions taking a string argument that simplify subjects.
141 The functions are applied recursively.
143 Useful functions to put in this list include: `gnus-simplify-subject-re',
144 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
146 :type '(repeat function))
148 (defcustom gnus-simplify-ignored-prefixes nil
149 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
151 :type '(choice (const :tag "off" nil)
154 (defcustom gnus-build-sparse-threads nil
155 "*If non-nil, fill in the gaps in threads.
156 If `some', only fill in the gaps that are needed to tie loose threads
157 together. If `more', fill in all leaf nodes that Gnus can find. If
158 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
160 :type '(choice (const :tag "off" nil)
163 (sexp :menu-tag "all" t)))
165 (defcustom gnus-summary-thread-gathering-function
166 'gnus-gather-threads-by-subject
167 "*Function used for gathering loose threads.
168 There are two pre-defined functions: `gnus-gather-threads-by-subject',
169 which only takes Subjects into consideration; and
170 `gnus-gather-threads-by-references', which compared the References
171 headers of the articles to find matches."
173 :type '(radio (function-item gnus-gather-threads-by-subject)
174 (function-item gnus-gather-threads-by-references)
175 (function :tag "other")))
177 (defcustom gnus-summary-same-subject ""
178 "*String indicating that the current article has the same subject as the previous.
179 This variable will only be used if the value of
180 `gnus-summary-make-false-root' is `empty'."
181 :group 'gnus-summary-format
184 (defcustom gnus-summary-goto-unread t
185 "*If t, many commands will go to the next unread article.
186 This applies to marking commands as well as other commands that
187 \"naturally\" select the next article, like, for instance, `SPC' at
188 the end of an article.
190 If nil, the marking commands do NOT go to the next unread article
191 (they go to the next article instead). If `never', commands that
192 usually go to the next unread article, will go to the next article,
193 whether it is read or not."
194 :group 'gnus-summary-marks
195 :link '(custom-manual "(gnus)Setting Marks")
196 :type '(choice (const :tag "off" nil)
198 (sexp :menu-tag "on" t)))
200 (defcustom gnus-summary-default-score 0
201 "*Default article score level.
202 All scores generated by the score files will be added to this score.
203 If this variable is nil, scoring will be disabled."
204 :group 'gnus-score-default
205 :type '(choice (const :tag "disable")
208 (defcustom gnus-summary-zcore-fuzz 0
209 "*Fuzziness factor for the zcore in the summary buffer.
210 Articles with scores closer than this to `gnus-summary-default-score'
212 :group 'gnus-summary-format
215 (defcustom gnus-simplify-subject-fuzzy-regexp nil
216 "*Strings to be removed when doing fuzzy matches.
217 This can either be a regular expression or list of regular expressions
218 that will be removed from subject strings if fuzzy subject
219 simplification is selected."
221 :type '(repeat regexp))
223 (defcustom gnus-show-threads t
224 "*If non-nil, display threads in summary mode."
228 (defcustom gnus-thread-hide-subtree nil
229 "*If non-nil, hide all threads initially.
230 If threads are hidden, you have to run the command
231 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
232 to expose hidden threads."
236 (defcustom gnus-thread-hide-killed t
237 "*If non-nil, hide killed threads automatically."
241 (defcustom gnus-thread-ignore-subject t
242 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
243 If nil, articles that have different subjects from their parents will
244 start separate threads."
248 (defcustom gnus-thread-operation-ignore-subject t
249 "*If non-nil, subjects will be ignored when doing thread commands.
250 This affects commands like `gnus-summary-kill-thread' and
251 `gnus-summary-lower-thread'.
253 If this variable is nil, articles in the same thread with different
254 subjects will not be included in the operation in question. If this
255 variable is `fuzzy', only articles that have subjects that are fuzzily
256 equal will be included."
258 :type '(choice (const :tag "off" nil)
262 (defcustom gnus-thread-indent-level 4
263 "*Number that says how much each sub-thread should be indented."
267 (defcustom gnus-auto-extend-newsgroup t
268 "*If non-nil, extend newsgroup forward and backward when requested."
269 :group 'gnus-summary-choose
272 (defcustom gnus-auto-select-first t
273 "*If nil, don't select the first unread article when entering a group.
274 If this variable is `best', select the highest-scored unread article
275 in the group. If t, select the first unread article.
277 This variable can also be a function to place point on a likely
278 subject line. Useful values include `gnus-summary-first-unread-subject',
279 `gnus-summary-first-unread-article' and
280 `gnus-summary-best-unread-article'.
282 If you want to prevent automatic selection of the first unread article
283 in some newsgroups, set the variable to nil in
284 `gnus-select-group-hook'."
285 :group 'gnus-group-select
286 :type '(choice (const :tag "none" nil)
288 (sexp :menu-tag "first" t)
289 (function-item gnus-summary-first-unread-subject)
290 (function-item gnus-summary-first-unread-article)
291 (function-item gnus-summary-best-unread-article)))
293 (defcustom gnus-dont-select-after-jump-to-other-group nil
294 "If non-nil, don't select the first unread article after entering the
295 other group by the command `gnus-summary-jump-to-other-group'. If nil,
296 it is depend on the value of `gnus-auto-select-first' whether to select
298 :group 'gnus-group-select
301 (defcustom gnus-auto-select-next t
302 "*If non-nil, offer to go to the next group from the end of the previous.
303 If the value is t and the next newsgroup is empty, Gnus will exit
304 summary mode and go back to group mode. If the value is neither nil
305 nor t, Gnus will select the following unread newsgroup. In
306 particular, if the value is the symbol `quietly', the next unread
307 newsgroup will be selected without any confirmation, and if it is
308 `almost-quietly', the next group will be selected without any
309 confirmation if you are located on the last article in the group.
310 Finally, if this variable is `slightly-quietly', the `Z n' command
311 will go to the next group without confirmation."
312 :group 'gnus-summary-maneuvering
313 :type '(choice (const :tag "off" nil)
315 (const almost-quietly)
316 (const slightly-quietly)
317 (sexp :menu-tag "on" t)))
319 (defcustom gnus-auto-select-same nil
320 "*If non-nil, select the next article with the same subject.
321 If there are no more articles with the same subject, go to
322 the first unread article."
323 :group 'gnus-summary-maneuvering
326 (defcustom gnus-summary-check-current nil
327 "*If non-nil, consider the current article when moving.
328 The \"unread\" movement commands will stay on the same line if the
329 current article is unread."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-auto-center-summary t
334 "*If non-nil, always center the current summary buffer.
335 In particular, if `vertical' do only vertical recentering. If non-nil
336 and non-`vertical', do both horizontal and vertical recentering."
337 :group 'gnus-summary-maneuvering
338 :type '(choice (const :tag "none" nil)
340 (integer :tag "height")
341 (sexp :menu-tag "both" t)))
343 (defcustom gnus-show-all-headers nil
344 "*If non-nil, don't hide any headers."
345 :group 'gnus-article-hiding
346 :group 'gnus-article-headers
349 (defcustom gnus-summary-ignore-duplicates nil
350 "*If non-nil, ignore articles with identical Message-ID headers."
354 (defcustom gnus-single-article-buffer t
355 "*If non-nil, display all articles in the same buffer.
356 If nil, each group will get its own article buffer."
357 :group 'gnus-article-various
360 (defcustom gnus-break-pages t
361 "*If non-nil, do page breaking on articles.
362 The page delimiter is specified by the `gnus-page-delimiter'
364 :group 'gnus-article-various
367 (defcustom gnus-show-mime t
368 "*If non-nil, do mime processing of articles.
369 The articles will simply be fed to the function given by
370 `gnus-article-display-method-for-mime'."
371 :group 'gnus-article-mime
374 (defcustom gnus-move-split-methods nil
375 "*Variable used to suggest where articles are to be moved to.
376 It uses the same syntax as the `gnus-split-methods' variable."
377 :group 'gnus-summary-mail
378 :type '(repeat (choice (list :value (fun) function)
379 (cons :value ("" "") regexp (repeat string))
382 (defcustom gnus-unread-mark ? ;Whitespace
383 "*Mark used for unread articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-ticked-mark ?!
388 "*Mark used for ticked articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-dormant-mark ??
393 "*Mark used for dormant articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-del-mark ?r
398 "*Mark used for del'd articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-read-mark ?R
403 "*Mark used for read articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-expirable-mark ?E
408 "*Mark used for expirable articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-killed-mark ?K
413 "*Mark used for killed articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-souped-mark ?F
418 "*Mark used for killed articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-kill-file-mark ?X
423 "*Mark used for articles killed by kill files."
424 :group 'gnus-summary-marks
427 (defcustom gnus-low-score-mark ?Y
428 "*Mark used for articles with a low score."
429 :group 'gnus-summary-marks
432 (defcustom gnus-catchup-mark ?C
433 "*Mark used for articles that are caught up."
434 :group 'gnus-summary-marks
437 (defcustom gnus-replied-mark ?A
438 "*Mark used for articles that have been replied to."
439 :group 'gnus-summary-marks
442 (defcustom gnus-cached-mark ?*
443 "*Mark used for articles that are in the cache."
444 :group 'gnus-summary-marks
447 (defcustom gnus-saved-mark ?S
448 "*Mark used for articles that have been saved to."
449 :group 'gnus-summary-marks
452 (defcustom gnus-ancient-mark ?O
453 "*Mark used for ancient articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-sparse-mark ?Q
458 "*Mark used for sparsely reffed articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-canceled-mark ?G
463 "*Mark used for canceled articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-duplicate-mark ?M
468 "*Mark used for duplicate articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-undownloaded-mark ?@
473 "*Mark used for articles that weren't downloaded."
474 :group 'gnus-summary-marks
477 (defcustom gnus-downloadable-mark ?%
478 "*Mark used for articles that are to be downloaded."
479 :group 'gnus-summary-marks
482 (defcustom gnus-unsendable-mark ?=
483 "*Mark used for articles that won't be sent."
484 :group 'gnus-summary-marks
487 (defcustom gnus-score-over-mark ?+
488 "*Score mark used for articles with high scores."
489 :group 'gnus-summary-marks
492 (defcustom gnus-score-below-mark ?-
493 "*Score mark used for articles with low scores."
494 :group 'gnus-summary-marks
497 (defcustom gnus-empty-thread-mark ? ;Whitespace
498 "*There is no thread under the article."
499 :group 'gnus-summary-marks
502 (defcustom gnus-not-empty-thread-mark ?=
503 "*There is a thread under the article."
504 :group 'gnus-summary-marks
507 (defcustom gnus-view-pseudo-asynchronously nil
508 "*If non-nil, Gnus will view pseudo-articles asynchronously."
509 :group 'gnus-extract-view
512 (defcustom gnus-auto-expirable-marks
513 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
514 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
515 gnus-souped-mark gnus-duplicate-mark)
516 "*The list of marks converted into expiration if a group is auto-expirable."
518 :type '(repeat character))
520 (defcustom gnus-inhibit-user-auto-expire t
521 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
525 (defcustom gnus-view-pseudos nil
526 "*If `automatic', pseudo-articles will be viewed automatically.
527 If `not-confirm', pseudos will be viewed automatically, and the user
528 will not be asked to confirm the command."
529 :group 'gnus-extract-view
530 :type '(choice (const :tag "off" nil)
532 (const not-confirm)))
534 (defcustom gnus-view-pseudos-separately t
535 "*If non-nil, one pseudo-article will be created for each file to be viewed.
536 If nil, all files that use the same viewing command will be given as a
537 list of parameters to that command."
538 :group 'gnus-extract-view
541 (defcustom gnus-insert-pseudo-articles t
542 "*If non-nil, insert pseudo-articles when decoding articles."
543 :group 'gnus-extract-view
546 (defcustom gnus-summary-dummy-line-format
548 "*The format specification for the dummy roots in the summary buffer.
549 It works along the same lines as a normal formatting string,
550 with some simple extensions.
553 :group 'gnus-threading
556 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
557 "*The format specification for the summary mode line.
558 It works along the same lines as a normal formatting string,
559 with some simple extensions:
562 %p Unprefixed group name
563 %A Current article number
564 %z Current article score
566 %U Number of unread articles in the group
567 %e Number of unselected articles in the group
568 %Z A string with unread/unselected article counts
569 %g Shortish group name
570 %S Subject of the current article
572 %s Current score file name
573 %d Number of dormant articles
574 %r Number of articles that have been marked as read in this session
575 %E Number of articles expunged by the score files"
576 :group 'gnus-summary-format
579 (defcustom gnus-list-identifiers nil
580 "Regexp that matches list identifiers to be removed from subject.
581 This can also be a list of regexps."
582 :group 'gnus-summary-format
583 :group 'gnus-article-hiding
584 :type '(choice (const :tag "none" nil)
586 (repeat :value (".*") regexp)))
588 (defcustom gnus-summary-mark-below 0
589 "*Mark all articles with a score below this variable as read.
590 This variable is local to each summary buffer and usually set by the
592 :group 'gnus-score-default
595 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
596 "*List of functions used for sorting articles in the summary buffer.
597 This variable is only used when not using a threaded display."
598 :group 'gnus-summary-sort
599 :type '(repeat (choice (function-item gnus-article-sort-by-number)
600 (function-item gnus-article-sort-by-author)
601 (function-item gnus-article-sort-by-subject)
602 (function-item gnus-article-sort-by-date)
603 (function-item gnus-article-sort-by-score)
604 (function :tag "other"))))
606 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
607 "*List of functions used for sorting threads in the summary buffer.
608 By default, threads are sorted by article number.
610 Each function takes two threads and return non-nil if the first thread
611 should be sorted before the other. If you use more than one function,
612 the primary sort function should be the last. You should probably
613 always include `gnus-thread-sort-by-number' in the list of sorting
614 functions -- preferably first.
616 Ready-made functions include `gnus-thread-sort-by-number',
617 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
618 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
619 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
620 :group 'gnus-summary-sort
621 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
622 (function-item gnus-thread-sort-by-author)
623 (function-item gnus-thread-sort-by-subject)
624 (function-item gnus-thread-sort-by-date)
625 (function-item gnus-thread-sort-by-score)
626 (function-item gnus-thread-sort-by-total-score)
627 (function :tag "other"))))
629 (defcustom gnus-thread-score-function '+
630 "*Function used for calculating the total score of a thread.
632 The function is called with the scores of the article and each
633 subthread and should then return the score of the thread.
635 Some functions you can use are `+', `max', or `min'."
636 :group 'gnus-summary-sort
639 (defcustom gnus-summary-expunge-below nil
640 "All articles that have a score less than this variable will be expunged.
641 This variable is local to the summary buffers."
642 :group 'gnus-score-default
643 :type '(choice (const :tag "off" nil)
646 (defcustom gnus-thread-expunge-below nil
647 "All threads that have a total score less than this variable will be expunged.
648 See `gnus-thread-score-function' for en explanation of what a
651 This variable is local to the summary buffers."
652 :group 'gnus-threading
653 :group 'gnus-score-default
654 :type '(choice (const :tag "off" nil)
657 (defcustom gnus-summary-mode-hook nil
658 "*A hook for Gnus summary mode.
659 This hook is run before any variables are set in the summary buffer."
660 :group 'gnus-summary-various
663 (defcustom gnus-summary-menu-hook nil
664 "*Hook run after the creation of the summary mode menu."
665 :group 'gnus-summary-visual
668 (defcustom gnus-summary-exit-hook nil
669 "*A hook called on exit from the summary buffer.
670 It will be called with point in the group buffer."
671 :group 'gnus-summary-exit
674 (defcustom gnus-summary-prepare-hook nil
675 "*A hook called after the summary buffer has been generated.
676 If you want to modify the summary buffer, you can use this hook."
677 :group 'gnus-summary-various
680 (defcustom gnus-summary-prepared-hook nil
681 "*A hook called as the last thing after the summary buffer has been generated."
682 :group 'gnus-summary-various
685 (defcustom gnus-summary-generate-hook nil
686 "*A hook run just before generating the summary buffer.
687 This hook is commonly used to customize threading variables and the
689 :group 'gnus-summary-various
692 (defcustom gnus-select-group-hook nil
693 "*A hook called when a newsgroup is selected.
695 If you'd like to simplify subjects like the
696 `gnus-summary-next-same-subject' command does, you can use the
699 (setq gnus-select-group-hook
702 (mapcar (lambda (header)
703 (mail-header-set-subject
705 (gnus-simplify-subject
706 (mail-header-subject header) 're-only)))
707 gnus-newsgroup-headers))))"
708 :group 'gnus-group-select
711 (defcustom gnus-select-article-hook nil
712 "*A hook called when an article is selected."
713 :group 'gnus-summary-choose
716 (defcustom gnus-visual-mark-article-hook
717 (list 'gnus-highlight-selected-summary)
718 "*Hook run after selecting an article in the summary buffer.
719 It is meant to be used for highlighting the article in some way. It
720 is not run if `gnus-visual' is nil."
721 :group 'gnus-summary-visual
724 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
725 "*A hook called before parsing the headers."
729 (defcustom gnus-exit-group-hook nil
730 "*A hook called when exiting summary mode.
731 This hook is not called from the non-updating exit commands like `Q'."
735 (defcustom gnus-summary-update-hook
736 (list 'gnus-summary-highlight-line)
737 "*A hook called when a summary line is changed.
738 The hook will not be called if `gnus-visual' is nil.
740 The default function `gnus-summary-highlight-line' will
741 highlight the line according to the `gnus-summary-highlight'
743 :group 'gnus-summary-visual
746 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
747 "*A hook called when an article is selected for the first time.
748 The hook is intended to mark an article as read (or unread)
749 automatically when it is selected."
750 :group 'gnus-summary-choose
753 (defcustom gnus-group-no-more-groups-hook nil
754 "*A hook run when returning to group mode having no more (unread) groups."
755 :group 'gnus-group-select
758 (defcustom gnus-ps-print-hook nil
759 "*A hook run before ps-printing something from Gnus."
763 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
764 "Face used for highlighting the current article in the summary buffer."
765 :group 'gnus-summary-visual
768 (defcustom gnus-summary-highlight
769 '(((= mark gnus-canceled-mark)
770 . gnus-summary-cancelled-face)
771 ((and (> score default)
772 (or (= mark gnus-dormant-mark)
773 (= mark gnus-ticked-mark)))
774 . gnus-summary-high-ticked-face)
775 ((and (< score default)
776 (or (= mark gnus-dormant-mark)
777 (= mark gnus-ticked-mark)))
778 . gnus-summary-low-ticked-face)
779 ((or (= mark gnus-dormant-mark)
780 (= mark gnus-ticked-mark))
781 . gnus-summary-normal-ticked-face)
782 ((and (> score default) (= mark gnus-ancient-mark))
783 . gnus-summary-high-ancient-face)
784 ((and (< score default) (= mark gnus-ancient-mark))
785 . gnus-summary-low-ancient-face)
786 ((= mark gnus-ancient-mark)
787 . gnus-summary-normal-ancient-face)
788 ((and (> score default) (= mark gnus-unread-mark))
789 . gnus-summary-high-unread-face)
790 ((and (< score default) (= mark gnus-unread-mark))
791 . gnus-summary-low-unread-face)
792 ((and (memq article gnus-newsgroup-incorporated)
793 (= mark gnus-unread-mark))
794 . gnus-summary-incorporated-face)
795 ((= mark gnus-unread-mark)
796 . gnus-summary-normal-unread-face)
797 ((and (> score default) (memq mark (list gnus-downloadable-mark
798 gnus-undownloaded-mark)))
799 . gnus-summary-high-unread-face)
800 ((and (< score default) (memq mark (list gnus-downloadable-mark
801 gnus-undownloaded-mark)))
802 . gnus-summary-low-unread-face)
803 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
804 . gnus-summary-normal-unread-face)
806 . gnus-summary-high-read-face)
808 . gnus-summary-low-read-face)
810 . gnus-summary-normal-read-face))
811 "*Controls the highlighting of summary buffer lines.
813 A list of (FORM . FACE) pairs. When deciding how a a particular
814 summary line should be displayed, each form is evaluated. The content
815 of the face field after the first true form is used. You can change
816 how those summary lines are displayed, by editing the face field.
818 You can use the following variables in the FORM field.
820 score: The articles score
821 default: The default article score.
822 below: The score below which articles are automatically marked as read.
823 mark: The articles mark."
824 :group 'gnus-summary-visual
825 :type '(repeat (cons (sexp :tag "Form" nil)
828 (defcustom gnus-alter-header-function nil
829 "Function called to allow alteration of article header structures.
830 The function is called with one parameter, the article header vector,
831 which it may alter in any way.")
833 (defvar gnus-decode-encoded-word-function
834 (mime-find-field-decoder 'From 'nov)
835 "Variable that says which function should be used to decode a string with encoded words.")
837 (defcustom gnus-extra-headers nil
838 "*Extra headers to parse."
840 :type '(repeat symbol))
842 (defcustom gnus-ignored-from-addresses
843 (and user-mail-address (regexp-quote user-mail-address))
844 "*Regexp of From headers that may be suppressed in favor of To headers."
848 (defcustom gnus-group-charset-alist
849 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
850 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
851 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
852 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
853 ("^relcom\\>" koi8-r)
855 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
856 ("^israel\\>" iso-8859-1)
858 ("^alt.chinese.text.big5\\>" chinese-big5)
859 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
860 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
862 "Alist of regexps (to match group names) and default charsets to be used when reading."
863 :type '(repeat (list (regexp :tag "Group")
864 (symbol :tag "Charset")))
865 :group 'gnus-charset)
867 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
868 "List of charsets that should be ignored.
869 When these charsets are used in the \"charset\" parameter, the
870 default charset will be used instead."
871 :type '(repeat symbol)
872 :group 'gnus-charset)
874 (defcustom gnus-group-ignored-charsets-alist
875 '(("alt\\.chinese\\.text" iso-8859-1))
876 "Alist of regexps (to match group names) and charsets that should be ignored.
877 When these charsets are used in the \"charset\" parameter, the
878 default charset will be used instead."
879 :type '(repeat (cons (regexp :tag "Group")
881 :group 'gnus-charset)
883 (defcustom gnus-group-highlight-words-alist nil
884 "Alist of group regexps and highlight regexps.
885 This variable uses the same syntax as `gnus-emphasis-alist'."
886 :type '(repeat (cons (regexp :tag "Group")
887 (repeat (list (regexp :tag "Highlight regexp")
888 (number :tag "Group for entire word" 0)
889 (number :tag "Group for displayed part" 0)
891 gnus-emphasis-highlight-words)))))
892 :group 'gnus-summary-visual)
894 (defcustom gnus-use-wheel nil
895 "Use Intelli-mouse on summary movement"
897 :group 'gnus-summary-maneuvering)
899 (defcustom gnus-wheel-scroll-amount '(5 . 1)
900 "Amount to scroll messages by spinning the mouse wheel.
901 This is actually a cons cell, where the first item is the amount to scroll
902 on a normal wheel event, and the second is the amount to scroll when the
903 wheel is moved with the shift key depressed."
904 :type '(cons (integer :tag "Shift") integer)
905 :group 'gnus-summary-maneuvering)
907 (defcustom gnus-wheel-edge-resistance 2
908 "How hard it should be to change the current article
909 by moving the mouse over the edge of the article window."
911 :group 'gnus-summary-maneuvering)
913 (defcustom gnus-summary-show-article-charset-alist
915 "Alist of number and charset.
916 The article will be shown with the charset corresponding to the
918 For example: ((1 . cn-gb-2312) (2 . big5))."
919 :type '(repeat (cons (number :tag "Argument" 1)
920 (symbol :tag "Charset")))
921 :group 'gnus-charset)
923 (defcustom gnus-preserve-marks t
924 "Whether marks are preserved when moving, copying and respooling messages."
926 :group 'gnus-summary-marks)
928 (defcustom gnus-alter-articles-to-read-function nil
929 "Function to be called to alter the list of articles to be selected."
931 :group 'gnus-summary)
933 ;;; Internal variables
935 (defvar gnus-article-mime-handles nil)
936 (defvar gnus-article-decoded-p nil)
937 (defvar gnus-scores-exclude-files nil)
938 (defvar gnus-page-broken nil)
939 (defvar gnus-inhibit-mime-unbuttonizing nil)
941 (defvar gnus-original-article nil)
942 (defvar gnus-article-internal-prepare-hook nil)
943 (defvar gnus-newsgroup-process-stack nil)
945 (defvar gnus-thread-indent-array nil)
946 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
947 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
948 "Function called to sort the articles within a thread after it has been gathered together.")
950 ;; Avoid highlighting in kill files.
951 (defvar gnus-summary-inhibit-highlight nil)
952 (defvar gnus-newsgroup-selected-overlay nil)
953 (defvar gnus-inhibit-limiting nil)
954 (defvar gnus-newsgroup-adaptive-score-file nil)
955 (defvar gnus-current-score-file nil)
956 (defvar gnus-current-move-group nil)
957 (defvar gnus-current-copy-group nil)
958 (defvar gnus-current-crosspost-group nil)
960 (defvar gnus-newsgroup-dependencies nil)
961 (defvar gnus-newsgroup-adaptive nil)
962 (defvar gnus-summary-display-article-function nil)
963 (defvar gnus-summary-highlight-line-function nil
964 "Function called after highlighting a summary line.")
966 (defvar gnus-summary-line-format-alist
967 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
968 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
969 (?s gnus-tmp-subject-or-nil ?s)
970 (?n gnus-tmp-name ?s)
971 (?A (std11-address-string
972 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
973 (?a (or (std11-full-name-string
974 (car (mime-entity-read-field gnus-tmp-header 'From)))
976 (?F gnus-tmp-from ?s)
977 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
978 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
979 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
980 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
981 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
982 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
983 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
984 (?L gnus-tmp-lines ?d)
985 (?I gnus-tmp-indentation ?s)
986 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
987 (?R gnus-tmp-replied ?c)
988 (?\[ gnus-tmp-opening-bracket ?c)
989 (?\] gnus-tmp-closing-bracket ?c)
990 (?\> (make-string gnus-tmp-level ? ) ?s)
991 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
992 (?i gnus-tmp-score ?d)
993 (?z gnus-tmp-score-char ?c)
994 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
995 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
996 (?U gnus-tmp-unread ?c)
997 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
998 (?t (gnus-summary-number-of-articles-in-thread
999 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1001 (?e (gnus-summary-number-of-articles-in-thread
1002 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1004 (?u gnus-tmp-user-defined ?s)
1005 (?P (gnus-pick-line-number) ?d))
1006 "An alist of format specifications that can appear in summary lines,
1007 and what variables they correspond with, along with the type of the
1008 variable (string, integer, character, etc).")
1010 (defvar gnus-summary-dummy-line-format-alist
1011 `((?S gnus-tmp-subject ?s)
1012 (?N gnus-tmp-number ?d)
1013 (?u gnus-tmp-user-defined ?s)))
1015 (defvar gnus-summary-mode-line-format-alist
1016 `((?G gnus-tmp-group-name ?s)
1017 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1018 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1019 (?A gnus-tmp-article-number ?d)
1020 (?Z gnus-tmp-unread-and-unselected ?s)
1021 (?V gnus-version ?s)
1022 (?U gnus-tmp-unread-and-unticked ?d)
1023 (?S gnus-tmp-subject ?s)
1024 (?e gnus-tmp-unselected ?d)
1025 (?u gnus-tmp-user-defined ?s)
1026 (?d (length gnus-newsgroup-dormant) ?d)
1027 (?t (length gnus-newsgroup-marked) ?d)
1028 (?r (length gnus-newsgroup-reads) ?d)
1029 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1030 (?E gnus-newsgroup-expunged-tally ?d)
1031 (?s (gnus-current-score-file-nondirectory) ?s)))
1033 (defvar gnus-last-search-regexp nil
1034 "Default regexp for article search command.")
1036 (defvar gnus-summary-search-article-matched-data nil
1037 "Last matched data of article search command. It is the local variable
1038 in `gnus-article-buffer' which consists of the list of start position,
1039 end position and text.")
1041 (defvar gnus-last-shell-command nil
1042 "Default shell command on article.")
1044 (defvar gnus-newsgroup-begin nil)
1045 (defvar gnus-newsgroup-end nil)
1046 (defvar gnus-newsgroup-last-rmail nil)
1047 (defvar gnus-newsgroup-last-mail nil)
1048 (defvar gnus-newsgroup-last-folder nil)
1049 (defvar gnus-newsgroup-last-file nil)
1050 (defvar gnus-newsgroup-auto-expire nil)
1051 (defvar gnus-newsgroup-active nil)
1053 (defvar gnus-newsgroup-data nil)
1054 (defvar gnus-newsgroup-data-reverse nil)
1055 (defvar gnus-newsgroup-limit nil)
1056 (defvar gnus-newsgroup-limits nil)
1058 (defvar gnus-newsgroup-unreads nil
1059 "List of unread articles in the current newsgroup.")
1061 (defvar gnus-newsgroup-unselected nil
1062 "List of unselected unread articles in the current newsgroup.")
1064 (defvar gnus-newsgroup-reads nil
1065 "Alist of read articles and article marks in the current newsgroup.")
1067 (defvar gnus-newsgroup-expunged-tally nil)
1069 (defvar gnus-newsgroup-marked nil
1070 "List of ticked articles in the current newsgroup (a subset of unread art).")
1072 (defvar gnus-newsgroup-killed nil
1073 "List of ranges of articles that have been through the scoring process.")
1075 (defvar gnus-newsgroup-cached nil
1076 "List of articles that come from the article cache.")
1078 (defvar gnus-newsgroup-saved nil
1079 "List of articles that have been saved.")
1081 (defvar gnus-newsgroup-kill-headers nil)
1083 (defvar gnus-newsgroup-replied nil
1084 "List of articles that have been replied to in the current newsgroup.")
1086 (defvar gnus-newsgroup-expirable nil
1087 "List of articles in the current newsgroup that can be expired.")
1089 (defvar gnus-newsgroup-processable nil
1090 "List of articles in the current newsgroup that can be processed.")
1092 (defvar gnus-newsgroup-downloadable nil
1093 "List of articles in the current newsgroup that can be processed.")
1095 (defvar gnus-newsgroup-undownloaded nil
1096 "List of articles in the current newsgroup that haven't been downloaded..")
1098 (defvar gnus-newsgroup-unsendable nil
1099 "List of articles in the current newsgroup that won't be sent.")
1101 (defvar gnus-newsgroup-bookmarks nil
1102 "List of articles in the current newsgroup that have bookmarks.")
1104 (defvar gnus-newsgroup-dormant nil
1105 "List of dormant articles in the current newsgroup.")
1107 (defvar gnus-newsgroup-scored nil
1108 "List of scored articles in the current newsgroup.")
1110 (defvar gnus-newsgroup-incorporated nil
1111 "List of incorporated articles in the current newsgroup.")
1113 (defvar gnus-newsgroup-headers nil
1114 "List of article headers in the current newsgroup.")
1116 (defvar gnus-newsgroup-threads nil)
1118 (defvar gnus-newsgroup-prepared nil
1119 "Whether the current group has been prepared properly.")
1121 (defvar gnus-newsgroup-ancient nil
1122 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1124 (defvar gnus-newsgroup-sparse nil)
1126 (defvar gnus-current-article nil)
1127 (defvar gnus-article-current nil)
1128 (defvar gnus-current-headers nil)
1129 (defvar gnus-have-all-headers nil)
1130 (defvar gnus-last-article nil)
1131 (defvar gnus-newsgroup-history nil)
1132 (defvar gnus-newsgroup-charset nil)
1133 (defvar gnus-newsgroup-ephemeral-charset nil)
1134 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1136 (defconst gnus-summary-local-variables
1137 '(gnus-newsgroup-name
1138 gnus-newsgroup-begin gnus-newsgroup-end
1139 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1140 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1141 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1142 gnus-newsgroup-unselected gnus-newsgroup-marked
1143 gnus-newsgroup-reads gnus-newsgroup-saved
1144 gnus-newsgroup-replied gnus-newsgroup-expirable
1145 gnus-newsgroup-processable gnus-newsgroup-killed
1146 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1147 gnus-newsgroup-unsendable
1148 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1149 gnus-newsgroup-headers gnus-newsgroup-threads
1150 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1151 gnus-current-article gnus-current-headers gnus-have-all-headers
1152 gnus-last-article gnus-article-internal-prepare-hook
1153 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1154 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1155 gnus-thread-expunge-below
1156 gnus-score-alist gnus-current-score-file
1157 (gnus-summary-expunge-below . global)
1158 (gnus-summary-mark-below . global)
1159 gnus-newsgroup-active gnus-scores-exclude-files
1160 gnus-newsgroup-history gnus-newsgroup-ancient
1161 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1162 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1163 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1164 (gnus-newsgroup-expunged-tally . 0)
1165 gnus-cache-removable-articles gnus-newsgroup-cached
1166 gnus-newsgroup-data gnus-newsgroup-data-reverse
1167 gnus-newsgroup-limit gnus-newsgroup-limits
1168 gnus-newsgroup-charset
1169 gnus-newsgroup-incorporated)
1170 "Variables that are buffer-local to the summary buffers.")
1172 ;; Byte-compiler warning.
1173 (defvar gnus-article-mode-map)
1175 ;; Subject simplification.
1177 (defun gnus-simplify-whitespace (str)
1178 "Remove excessive whitespace."
1181 (while (string-match "[ \t][ \t]+" mystr)
1182 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1184 (substring mystr (match-end 0)))))
1186 (when (string-match "^[ \t]+" mystr)
1187 (setq mystr (substring mystr (match-end 0))))
1189 (when (string-match "[ \t]+$" mystr)
1190 (setq mystr (substring mystr 0 (match-beginning 0))))
1193 (defsubst gnus-simplify-subject-re (subject)
1194 "Remove \"Re:\" from subject lines."
1195 (if (string-match "^[Rr][Ee]: *" subject)
1196 (substring subject (match-end 0))
1199 (defun gnus-simplify-subject (subject &optional re-only)
1200 "Remove `Re:' and words in parentheses.
1201 If RE-ONLY is non-nil, strip leading `Re:'s only."
1202 (let ((case-fold-search t)) ;Ignore case.
1203 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1204 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1205 (setq subject (substring subject (match-end 0))))
1206 ;; Remove uninteresting prefixes.
1207 (when (and (not re-only)
1208 gnus-simplify-ignored-prefixes
1209 (string-match gnus-simplify-ignored-prefixes subject))
1210 (setq subject (substring subject (match-end 0))))
1211 ;; Remove words in parentheses from end.
1213 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1214 (setq subject (substring subject 0 (match-beginning 0)))))
1215 ;; Return subject string.
1218 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1220 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1221 (goto-char (point-min))
1222 (while (re-search-forward regexp nil t)
1223 (replace-match (or newtext ""))))
1225 (defun gnus-simplify-buffer-fuzzy ()
1226 "Simplify string in the buffer fuzzily.
1227 The string in the accessible portion of the current buffer is simplified.
1228 It is assumed to be a single-line subject.
1229 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1230 matter is removed. Additional things can be deleted by setting
1231 gnus-simplify-subject-fuzzy-regexp."
1232 (let ((case-fold-search t)
1234 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1236 (while (not (eq modified-tick (buffer-modified-tick)))
1237 (setq modified-tick (buffer-modified-tick))
1239 ((listp gnus-simplify-subject-fuzzy-regexp)
1240 (mapcar 'gnus-simplify-buffer-fuzzy-step
1241 gnus-simplify-subject-fuzzy-regexp))
1242 (gnus-simplify-subject-fuzzy-regexp
1243 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1244 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1245 (gnus-simplify-buffer-fuzzy-step
1246 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1247 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1249 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1250 (gnus-simplify-buffer-fuzzy-step " +" " ")
1251 (gnus-simplify-buffer-fuzzy-step " $")
1252 (gnus-simplify-buffer-fuzzy-step "^ +")))
1254 (defun gnus-simplify-subject-fuzzy (subject)
1255 "Simplify a subject string fuzzily.
1256 See `gnus-simplify-buffer-fuzzy' for details."
1258 (gnus-set-work-buffer)
1259 (let ((case-fold-search t))
1260 ;; Remove uninteresting prefixes.
1261 (when (and gnus-simplify-ignored-prefixes
1262 (string-match gnus-simplify-ignored-prefixes subject))
1263 (setq subject (substring subject (match-end 0))))
1265 (inline (gnus-simplify-buffer-fuzzy))
1268 (defsubst gnus-simplify-subject-fully (subject)
1269 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1271 (gnus-simplify-subject-functions
1272 (gnus-map-function gnus-simplify-subject-functions subject))
1273 ((null gnus-summary-gather-subject-limit)
1274 (gnus-simplify-subject-re subject))
1275 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1276 (gnus-simplify-subject-fuzzy subject))
1277 ((numberp gnus-summary-gather-subject-limit)
1278 (gnus-limit-string (gnus-simplify-subject-re subject)
1279 gnus-summary-gather-subject-limit))
1283 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1284 "Check whether two subjects are equal.
1285 If optional argument simple-first is t, first argument is already
1288 ((null simple-first)
1289 (equal (gnus-simplify-subject-fully s1)
1290 (gnus-simplify-subject-fully s2)))
1293 (gnus-simplify-subject-fully s2)))))
1295 (defun gnus-summary-bubble-group ()
1296 "Increase the score of the current group.
1297 This is a handy function to add to `gnus-summary-exit-hook' to
1298 increase the score of each group you read."
1299 (gnus-group-add-score gnus-newsgroup-name))
1303 ;;; Gnus summary mode
1306 (put 'gnus-summary-mode 'mode-class 'special)
1309 ;; Non-orthogonal keys
1311 (gnus-define-keys gnus-summary-mode-map
1312 " " gnus-summary-next-page
1313 "\177" gnus-summary-prev-page
1314 [delete] gnus-summary-prev-page
1315 [backspace] gnus-summary-prev-page
1316 "\r" gnus-summary-scroll-up
1317 "\M-\r" gnus-summary-scroll-down
1318 "n" gnus-summary-next-unread-article
1319 "p" gnus-summary-prev-unread-article
1320 "N" gnus-summary-next-article
1321 "P" gnus-summary-prev-article
1322 "\M-\C-n" gnus-summary-next-same-subject
1323 "\M-\C-p" gnus-summary-prev-same-subject
1324 "\M-n" gnus-summary-next-unread-subject
1325 "\M-p" gnus-summary-prev-unread-subject
1326 "." gnus-summary-first-unread-article
1327 "," gnus-summary-best-unread-article
1328 "\M-s" gnus-summary-search-article-forward
1329 "\M-r" gnus-summary-search-article-backward
1330 "<" gnus-summary-beginning-of-article
1331 ">" gnus-summary-end-of-article
1332 "j" gnus-summary-goto-article
1333 "^" gnus-summary-refer-parent-article
1334 "\M-^" gnus-summary-refer-article
1335 "u" gnus-summary-tick-article-forward
1336 "!" gnus-summary-tick-article-forward
1337 "U" gnus-summary-tick-article-backward
1338 "d" gnus-summary-mark-as-read-forward
1339 "D" gnus-summary-mark-as-read-backward
1340 "E" gnus-summary-mark-as-expirable
1341 "\M-u" gnus-summary-clear-mark-forward
1342 "\M-U" gnus-summary-clear-mark-backward
1343 "k" gnus-summary-kill-same-subject-and-select
1344 "\C-k" gnus-summary-kill-same-subject
1345 "\M-\C-k" gnus-summary-kill-thread
1346 "\M-\C-l" gnus-summary-lower-thread
1347 "e" gnus-summary-edit-article
1348 "#" gnus-summary-mark-as-processable
1349 "\M-#" gnus-summary-unmark-as-processable
1350 "\M-\C-t" gnus-summary-toggle-threads
1351 "\M-\C-s" gnus-summary-show-thread
1352 "\M-\C-h" gnus-summary-hide-thread
1353 "\M-\C-f" gnus-summary-next-thread
1354 "\M-\C-b" gnus-summary-prev-thread
1355 [(meta down)] gnus-summary-next-thread
1356 [(meta up)] gnus-summary-prev-thread
1357 "\M-\C-u" gnus-summary-up-thread
1358 "\M-\C-d" gnus-summary-down-thread
1359 "&" gnus-summary-execute-command
1360 "c" gnus-summary-catchup-and-exit
1361 "\C-w" gnus-summary-mark-region-as-read
1362 "\C-t" gnus-summary-toggle-truncation
1363 "?" gnus-summary-mark-as-dormant
1364 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1365 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1366 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1367 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1368 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1369 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1370 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1371 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1372 "=" gnus-summary-expand-window
1373 "\C-x\C-s" gnus-summary-reselect-current-group
1374 "\M-g" gnus-summary-rescan-group
1375 "w" gnus-summary-stop-page-breaking
1376 "\C-c\C-r" gnus-summary-caesar-message
1377 "\M-t" gnus-summary-toggle-mime
1378 "f" gnus-summary-followup
1379 "F" gnus-summary-followup-with-original
1380 "C" gnus-summary-cancel-article
1381 "r" gnus-summary-reply
1382 "R" gnus-summary-reply-with-original
1383 "\C-c\C-f" gnus-summary-mail-forward
1384 "o" gnus-summary-save-article
1385 "\C-o" gnus-summary-save-article-mail
1386 "|" gnus-summary-pipe-output
1387 "\M-k" gnus-summary-edit-local-kill
1388 "\M-K" gnus-summary-edit-global-kill
1390 "\C-c\C-d" gnus-summary-describe-group
1391 "q" gnus-summary-exit
1392 "Q" gnus-summary-exit-no-update
1393 "\C-c\C-i" gnus-info-find-node
1394 gnus-mouse-2 gnus-mouse-pick-article
1395 "m" gnus-summary-mail-other-window
1396 "a" gnus-summary-post-news
1397 "x" gnus-summary-limit-to-unread
1398 "s" gnus-summary-isearch-article
1399 "t" gnus-article-toggle-headers
1400 "g" gnus-summary-show-article
1401 "l" gnus-summary-goto-last-article
1402 "v" gnus-summary-preview-mime-message
1403 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1404 "\C-d" gnus-summary-enter-digest-group
1405 "\M-\C-d" gnus-summary-read-document
1406 "\M-\C-e" gnus-summary-edit-parameters
1407 "\M-\C-a" gnus-summary-customize-parameters
1409 "*" gnus-cache-enter-article
1410 "\M-*" gnus-cache-remove-article
1411 "\M-&" gnus-summary-universal-argument
1412 "\C-l" gnus-recenter
1413 "I" gnus-summary-increase-score
1414 "L" gnus-summary-lower-score
1415 "\M-i" gnus-symbolic-argument
1416 "h" gnus-summary-select-article-buffer
1418 "V" gnus-summary-score-map
1419 "X" gnus-uu-extract-map
1420 "S" gnus-summary-send-map)
1422 ;; Sort of orthogonal keymap
1423 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1424 "t" gnus-summary-tick-article-forward
1425 "!" gnus-summary-tick-article-forward
1426 "d" gnus-summary-mark-as-read-forward
1427 "r" gnus-summary-mark-as-read-forward
1428 "c" gnus-summary-clear-mark-forward
1429 " " gnus-summary-clear-mark-forward
1430 "e" gnus-summary-mark-as-expirable
1431 "x" gnus-summary-mark-as-expirable
1432 "?" gnus-summary-mark-as-dormant
1433 "b" gnus-summary-set-bookmark
1434 "B" gnus-summary-remove-bookmark
1435 "#" gnus-summary-mark-as-processable
1436 "\M-#" gnus-summary-unmark-as-processable
1437 "S" gnus-summary-limit-include-expunged
1438 "C" gnus-summary-catchup
1439 "H" gnus-summary-catchup-to-here
1440 "\C-c" gnus-summary-catchup-all
1441 "k" gnus-summary-kill-same-subject-and-select
1442 "K" gnus-summary-kill-same-subject
1443 "P" gnus-uu-mark-map)
1445 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1446 "c" gnus-summary-clear-above
1447 "u" gnus-summary-tick-above
1448 "m" gnus-summary-mark-above
1449 "k" gnus-summary-kill-below)
1451 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1452 "/" gnus-summary-limit-to-subject
1453 "n" gnus-summary-limit-to-articles
1454 "w" gnus-summary-pop-limit
1455 "s" gnus-summary-limit-to-subject
1456 "a" gnus-summary-limit-to-author
1457 "u" gnus-summary-limit-to-unread
1458 "m" gnus-summary-limit-to-marks
1459 "M" gnus-summary-limit-exclude-marks
1460 "v" gnus-summary-limit-to-score
1461 "*" gnus-summary-limit-include-cached
1462 "D" gnus-summary-limit-include-dormant
1463 "T" gnus-summary-limit-include-thread
1464 "d" gnus-summary-limit-exclude-dormant
1465 "t" gnus-summary-limit-to-age
1466 "x" gnus-summary-limit-to-extra
1467 "E" gnus-summary-limit-include-expunged
1468 "c" gnus-summary-limit-exclude-childless-dormant
1469 "C" gnus-summary-limit-mark-excluded-as-read)
1471 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1472 "n" gnus-summary-next-unread-article
1473 "p" gnus-summary-prev-unread-article
1474 "N" gnus-summary-next-article
1475 "P" gnus-summary-prev-article
1476 "\C-n" gnus-summary-next-same-subject
1477 "\C-p" gnus-summary-prev-same-subject
1478 "\M-n" gnus-summary-next-unread-subject
1479 "\M-p" gnus-summary-prev-unread-subject
1480 "f" gnus-summary-first-unread-article
1481 "b" gnus-summary-best-unread-article
1482 "j" gnus-summary-goto-article
1483 "g" gnus-summary-goto-subject
1484 "l" gnus-summary-goto-last-article
1485 "o" gnus-summary-pop-article)
1487 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1488 "k" gnus-summary-kill-thread
1489 "l" gnus-summary-lower-thread
1490 "i" gnus-summary-raise-thread
1491 "T" gnus-summary-toggle-threads
1492 "t" gnus-summary-rethread-current
1493 "^" gnus-summary-reparent-thread
1494 "s" gnus-summary-show-thread
1495 "S" gnus-summary-show-all-threads
1496 "h" gnus-summary-hide-thread
1497 "H" gnus-summary-hide-all-threads
1498 "n" gnus-summary-next-thread
1499 "p" gnus-summary-prev-thread
1500 "u" gnus-summary-up-thread
1501 "o" gnus-summary-top-thread
1502 "d" gnus-summary-down-thread
1503 "#" gnus-uu-mark-thread
1504 "\M-#" gnus-uu-unmark-thread)
1506 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1507 "g" gnus-summary-prepare
1508 "c" gnus-summary-insert-cached-articles)
1510 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1511 "c" gnus-summary-catchup-and-exit
1512 "C" gnus-summary-catchup-all-and-exit
1513 "E" gnus-summary-exit-no-update
1514 "J" gnus-summary-jump-to-other-group
1515 "Q" gnus-summary-exit
1516 "Z" gnus-summary-exit
1517 "n" gnus-summary-catchup-and-goto-next-group
1518 "R" gnus-summary-reselect-current-group
1519 "G" gnus-summary-rescan-group
1520 "N" gnus-summary-next-group
1521 "s" gnus-summary-save-newsrc
1522 "P" gnus-summary-prev-group)
1524 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1525 " " gnus-summary-next-page
1526 "n" gnus-summary-next-page
1527 "\177" gnus-summary-prev-page
1528 [delete] gnus-summary-prev-page
1529 "p" gnus-summary-prev-page
1530 "\r" gnus-summary-scroll-up
1531 "\M-\r" gnus-summary-scroll-down
1532 "<" gnus-summary-beginning-of-article
1533 ">" gnus-summary-end-of-article
1534 "b" gnus-summary-beginning-of-article
1535 "e" gnus-summary-end-of-article
1536 "^" gnus-summary-refer-parent-article
1537 "r" gnus-summary-refer-parent-article
1538 "D" gnus-summary-enter-digest-group
1539 "R" gnus-summary-refer-references
1540 "T" gnus-summary-refer-thread
1541 "g" gnus-summary-show-article
1542 "s" gnus-summary-isearch-article
1543 "P" gnus-summary-print-article
1544 "t" gnus-article-babel
1545 "d" gnus-summary-decrypt-article
1546 "v" gnus-summary-verify-article)
1548 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1549 "b" gnus-article-add-buttons
1550 "B" gnus-article-add-buttons-to-head
1551 "o" gnus-article-treat-overstrike
1552 "e" gnus-article-emphasize
1553 "w" gnus-article-fill-cited-article
1554 "Q" gnus-article-fill-long-lines
1555 "C" gnus-article-capitalize-sentences
1556 "c" gnus-article-remove-cr
1557 "f" gnus-article-display-x-face
1558 "l" gnus-summary-stop-page-breaking
1559 "r" gnus-summary-caesar-message
1560 "t" gnus-article-toggle-headers
1561 "v" gnus-summary-verbose-headers
1562 "m" gnus-summary-toggle-mime
1563 "H" gnus-article-strip-headers-in-body
1564 "d" gnus-article-treat-dumbquotes
1565 "s" gnus-smiley-display)
1567 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1568 "a" gnus-article-hide
1569 "h" gnus-article-toggle-headers
1570 "b" gnus-article-hide-boring-headers
1571 "s" gnus-article-hide-signature
1572 "c" gnus-article-hide-citation
1573 "C" gnus-article-hide-citation-in-followups
1574 "l" gnus-article-hide-list-identifiers
1575 "p" gnus-article-hide-pgp
1576 "B" gnus-article-strip-banner
1577 "P" gnus-article-hide-pem
1578 "\C-c" gnus-article-hide-citation-maybe)
1580 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1581 "a" gnus-article-highlight
1582 "h" gnus-article-highlight-headers
1583 "c" gnus-article-highlight-citation
1584 "s" gnus-article-highlight-signature)
1586 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1587 "z" gnus-article-date-ut
1588 "u" gnus-article-date-ut
1589 "l" gnus-article-date-local
1590 "e" gnus-article-date-lapsed
1591 "o" gnus-article-date-original
1592 "i" gnus-article-date-iso8601
1593 "s" gnus-article-date-user)
1595 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1596 "t" gnus-article-remove-trailing-blank-lines
1597 "l" gnus-article-strip-leading-blank-lines
1598 "m" gnus-article-strip-multiple-blank-lines
1599 "a" gnus-article-strip-blank-lines
1600 "A" gnus-article-strip-all-blank-lines
1601 "s" gnus-article-strip-leading-space
1602 "e" gnus-article-strip-trailing-space)
1604 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1606 "f" gnus-summary-fetch-faq
1607 "d" gnus-summary-describe-group
1608 "h" gnus-summary-describe-briefly
1609 "i" gnus-info-find-node)
1611 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1612 "e" gnus-summary-expire-articles
1613 "\M-\C-e" gnus-summary-expire-articles-now
1614 "\177" gnus-summary-delete-article
1615 [delete] gnus-summary-delete-article
1616 [backspace] gnus-summary-delete-article
1617 "m" gnus-summary-move-article
1618 "r" gnus-summary-respool-article
1619 "w" gnus-summary-edit-article
1620 "c" gnus-summary-copy-article
1621 "B" gnus-summary-crosspost-article
1622 "q" gnus-summary-respool-query
1623 "t" gnus-summary-respool-trace
1624 "i" gnus-summary-import-article
1625 "p" gnus-summary-article-posted-p)
1627 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1628 "o" gnus-summary-save-article
1629 "m" gnus-summary-save-article-mail
1630 "F" gnus-summary-write-article-file
1631 "r" gnus-summary-save-article-rmail
1632 "f" gnus-summary-save-article-file
1633 "b" gnus-summary-save-article-body-file
1634 "h" gnus-summary-save-article-folder
1635 "v" gnus-summary-save-article-vm
1636 "p" gnus-summary-pipe-output
1637 "s" gnus-soup-add-article)
1639 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1640 "b" gnus-summary-display-buttonized
1641 "m" gnus-summary-repair-multipart
1642 "v" gnus-article-view-part
1643 "o" gnus-article-save-part
1644 "c" gnus-article-copy-part
1645 "e" gnus-article-externalize-part
1646 "i" gnus-article-inline-part
1647 "|" gnus-article-pipe-part))
1649 (defun gnus-summary-make-menu-bar ()
1650 (gnus-turn-off-edit-menu 'summary)
1652 (unless (boundp 'gnus-summary-misc-menu)
1655 gnus-summary-kill-menu gnus-summary-mode-map ""
1660 ["Enter score..." gnus-summary-score-entry t]
1661 ["Customize" gnus-score-customize t])
1662 (gnus-make-score-map 'increase)
1663 (gnus-make-score-map 'lower)
1665 ["Kill below" gnus-summary-kill-below t]
1666 ["Mark above" gnus-summary-mark-above t]
1667 ["Tick above" gnus-summary-tick-above t]
1668 ["Clear above" gnus-summary-clear-above t])
1669 ["Current score" gnus-summary-current-score t]
1670 ["Set score" gnus-summary-set-score t]
1671 ["Switch current score file..." gnus-score-change-score-file t]
1672 ["Set mark below..." gnus-score-set-mark-below t]
1673 ["Set expunge below..." gnus-score-set-expunge-below t]
1674 ["Edit current score file" gnus-score-edit-current-scores t]
1675 ["Edit score file" gnus-score-edit-file t]
1676 ["Trace score" gnus-score-find-trace t]
1677 ["Find words" gnus-score-find-favourite-words t]
1678 ["Rescore buffer" gnus-summary-rescore t]
1679 ["Increase score..." gnus-summary-increase-score t]
1680 ["Lower score..." gnus-summary-lower-score t]))))
1682 ;; Define both the Article menu in the summary buffer and the equivalent
1683 ;; Commands menu in the article buffer here for consistency.
1686 ["All" gnus-article-hide t]
1687 ["Headers" gnus-article-toggle-headers t]
1688 ["Signature" gnus-article-hide-signature t]
1689 ["Citation" gnus-article-hide-citation t]
1690 ["List identifiers" gnus-article-hide-list-identifiers t]
1691 ["PGP" gnus-article-hide-pgp t]
1692 ["Banner" gnus-article-strip-banner t]
1693 ["Boring headers" gnus-article-hide-boring-headers t])
1695 ["All" gnus-article-highlight t]
1696 ["Headers" gnus-article-highlight-headers t]
1697 ["Signature" gnus-article-highlight-signature t]
1698 ["Citation" gnus-article-highlight-citation t])
1700 ["Local" gnus-article-date-local t]
1701 ["ISO8601" gnus-article-date-iso8601 t]
1702 ["UT" gnus-article-date-ut t]
1703 ["Original" gnus-article-date-original t]
1704 ["Lapsed" gnus-article-date-lapsed t]
1705 ["User-defined" gnus-article-date-user t])
1708 ["Leading" gnus-article-strip-leading-blank-lines t]
1709 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1710 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1711 ["All of the above" gnus-article-strip-blank-lines t]
1712 ["All" gnus-article-strip-all-blank-lines t]
1713 ["Leading space" gnus-article-strip-leading-space t]
1714 ["Trailing space" gnus-article-strip-trailing-space t])
1715 ["Overstrike" gnus-article-treat-overstrike t]
1716 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1717 ["Emphasis" gnus-article-emphasize t]
1718 ["Word wrap" gnus-article-fill-cited-article t]
1719 ["Fill long lines" gnus-article-fill-long-lines t]
1720 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1721 ["CR" gnus-article-remove-cr t]
1722 ["Show X-Face" gnus-article-display-x-face t]
1723 ["Rot 13" gnus-summary-caesar-message t]
1724 ["Unix pipe" gnus-summary-pipe-message t]
1725 ["Add buttons" gnus-article-add-buttons t]
1726 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1727 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1728 ["Toggle MIME" gnus-summary-toggle-mime t]
1729 ["Verbose header" gnus-summary-verbose-headers t]
1730 ["Toggle header" gnus-summary-toggle-header t]
1731 ["Toggle smileys" gnus-smiley-display t]
1732 ["HZ" gnus-article-decode-HZ t])
1734 ["Save in default format" gnus-summary-save-article t]
1735 ["Save in file" gnus-summary-save-article-file t]
1736 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1737 ["Save in MH folder" gnus-summary-save-article-folder t]
1738 ["Save in VM folder" gnus-summary-save-article-vm t]
1739 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1740 ["Save body in file" gnus-summary-save-article-body-file t]
1741 ["Pipe through a filter" gnus-summary-pipe-output t]
1742 ["Add to SOUP packet" gnus-soup-add-article t]
1743 ["Print" gnus-summary-print-article t])
1745 ["Respool article..." gnus-summary-respool-article t]
1746 ["Move article..." gnus-summary-move-article
1747 (gnus-check-backend-function
1748 'request-move-article gnus-newsgroup-name)]
1749 ["Copy article..." gnus-summary-copy-article t]
1750 ["Crosspost article..." gnus-summary-crosspost-article
1751 (gnus-check-backend-function
1752 'request-replace-article gnus-newsgroup-name)]
1753 ["Import file..." gnus-summary-import-article t]
1754 ["Check if posted" gnus-summary-article-posted-p t]
1755 ["Edit article" gnus-summary-edit-article
1756 (not (gnus-group-read-only-p))]
1757 ["Delete article" gnus-summary-delete-article
1758 (gnus-check-backend-function
1759 'request-expire-articles gnus-newsgroup-name)]
1760 ["Query respool" gnus-summary-respool-query t]
1761 ["Trace respool" gnus-summary-respool-trace t]
1762 ["Delete expirable articles" gnus-summary-expire-articles-now
1763 (gnus-check-backend-function
1764 'request-expire-articles gnus-newsgroup-name)])
1766 ["Uudecode" gnus-uu-decode-uu t]
1767 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1768 ["Unshar" gnus-uu-decode-unshar t]
1769 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1770 ["Save" gnus-uu-decode-save t]
1771 ["Binhex" gnus-uu-decode-binhex t]
1772 ["Postscript" gnus-uu-decode-postscript t])
1774 ["Enter article" gnus-cache-enter-article t]
1775 ["Remove article" gnus-cache-remove-article t])
1776 ["Translate" gnus-article-babel t]
1777 ["Select article buffer" gnus-summary-select-article-buffer t]
1778 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1779 ["Isearch article..." gnus-summary-isearch-article t]
1780 ["Beginning of the article" gnus-summary-beginning-of-article t]
1781 ["End of the article" gnus-summary-end-of-article t]
1782 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1783 ["Fetch referenced articles" gnus-summary-refer-references t]
1784 ["Fetch current thread" gnus-summary-refer-thread t]
1785 ["Fetch article with id..." gnus-summary-refer-article t]
1786 ["Redisplay" gnus-summary-show-article t])))
1788 gnus-summary-article-menu gnus-summary-mode-map ""
1789 (cons "Article" innards))
1792 gnus-article-commands-menu gnus-article-mode-map ""
1793 (cons "Commands" innards)))
1796 gnus-summary-thread-menu gnus-summary-mode-map ""
1798 ["Toggle threading" gnus-summary-toggle-threads t]
1799 ["Hide threads" gnus-summary-hide-all-threads t]
1800 ["Show threads" gnus-summary-show-all-threads t]
1801 ["Hide thread" gnus-summary-hide-thread t]
1802 ["Show thread" gnus-summary-show-thread t]
1803 ["Go to next thread" gnus-summary-next-thread t]
1804 ["Go to previous thread" gnus-summary-prev-thread t]
1805 ["Go down thread" gnus-summary-down-thread t]
1806 ["Go up thread" gnus-summary-up-thread t]
1807 ["Top of thread" gnus-summary-top-thread t]
1808 ["Mark thread as read" gnus-summary-kill-thread t]
1809 ["Lower thread score" gnus-summary-lower-thread t]
1810 ["Raise thread score" gnus-summary-raise-thread t]
1811 ["Rethread current" gnus-summary-rethread-current t]))
1814 gnus-summary-post-menu gnus-summary-mode-map ""
1816 ["Post an article" gnus-summary-post-news t]
1817 ["Followup" gnus-summary-followup t]
1818 ["Followup and yank" gnus-summary-followup-with-original t]
1819 ["Supersede article" gnus-summary-supersede-article t]
1820 ["Cancel article" gnus-summary-cancel-article t]
1821 ["Reply" gnus-summary-reply t]
1822 ["Reply and yank" gnus-summary-reply-with-original t]
1823 ["Wide reply" gnus-summary-wide-reply t]
1824 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1825 ["Mail forward" gnus-summary-mail-forward t]
1826 ["Post forward" gnus-summary-post-forward t]
1827 ["Digest and mail" gnus-summary-mail-digest t]
1828 ["Digest and post" gnus-summary-post-digest t]
1829 ["Resend message" gnus-summary-resend-message t]
1830 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1831 ["Send a mail" gnus-summary-mail-other-window t]
1832 ["Uuencode and post" gnus-uu-post-news t]
1833 ["Followup via news" gnus-summary-followup-to-mail t]
1834 ["Followup via news and yank"
1835 gnus-summary-followup-to-mail-with-original t]
1837 ;;["Send" gnus-summary-send-draft t]
1838 ;;["Send bounced" gnus-resend-bounced-mail t])
1842 gnus-summary-misc-menu gnus-summary-mode-map ""
1845 ["Mark as read" gnus-summary-mark-as-read-forward t]
1846 ["Mark same subject and select"
1847 gnus-summary-kill-same-subject-and-select t]
1848 ["Mark same subject" gnus-summary-kill-same-subject t]
1849 ["Catchup" gnus-summary-catchup t]
1850 ["Catchup all" gnus-summary-catchup-all t]
1851 ["Catchup to here" gnus-summary-catchup-to-here t]
1852 ["Catchup region" gnus-summary-mark-region-as-read t]
1853 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1855 ["Tick" gnus-summary-tick-article-forward t]
1856 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1857 ["Remove marks" gnus-summary-clear-mark-forward t]
1858 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1859 ["Set bookmark" gnus-summary-set-bookmark t]
1860 ["Remove bookmark" gnus-summary-remove-bookmark t])
1862 ["Marks..." gnus-summary-limit-to-marks t]
1863 ["Subject..." gnus-summary-limit-to-subject t]
1864 ["Author..." gnus-summary-limit-to-author t]
1865 ["Age..." gnus-summary-limit-to-age t]
1866 ["Extra..." gnus-summary-limit-to-extra t]
1867 ["Score" gnus-summary-limit-to-score t]
1868 ["Unread" gnus-summary-limit-to-unread t]
1869 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1870 ["Articles" gnus-summary-limit-to-articles t]
1871 ["Pop limit" gnus-summary-pop-limit t]
1872 ["Show dormant" gnus-summary-limit-include-dormant t]
1873 ["Hide childless dormant"
1874 gnus-summary-limit-exclude-childless-dormant t]
1875 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1876 ["Hide marked" gnus-summary-limit-exclude-marks t]
1877 ["Show expunged" gnus-summary-show-all-expunged t])
1879 ["Set mark" gnus-summary-mark-as-processable t]
1880 ["Remove mark" gnus-summary-unmark-as-processable t]
1881 ["Remove all marks" gnus-summary-unmark-all-processable t]
1882 ["Mark above" gnus-uu-mark-over t]
1883 ["Mark series" gnus-uu-mark-series t]
1884 ["Mark region" gnus-uu-mark-region t]
1885 ["Unmark region" gnus-uu-unmark-region t]
1886 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1887 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1888 ["Mark all" gnus-uu-mark-all t]
1889 ["Mark buffer" gnus-uu-mark-buffer t]
1890 ["Mark sparse" gnus-uu-mark-sparse t]
1891 ["Mark thread" gnus-uu-mark-thread t]
1892 ["Unmark thread" gnus-uu-unmark-thread t]
1893 ("Process Mark Sets"
1894 ["Kill" gnus-summary-kill-process-mark t]
1895 ["Yank" gnus-summary-yank-process-mark
1896 gnus-newsgroup-process-stack]
1897 ["Save" gnus-summary-save-process-mark t]))
1899 ["Page forward" gnus-summary-next-page t]
1900 ["Page backward" gnus-summary-prev-page t]
1901 ["Line forward" gnus-summary-scroll-up t])
1903 ["Next unread article" gnus-summary-next-unread-article t]
1904 ["Previous unread article" gnus-summary-prev-unread-article t]
1905 ["Next article" gnus-summary-next-article t]
1906 ["Previous article" gnus-summary-prev-article t]
1907 ["Next unread subject" gnus-summary-next-unread-subject t]
1908 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1909 ["Next article same subject" gnus-summary-next-same-subject t]
1910 ["Previous article same subject" gnus-summary-prev-same-subject t]
1911 ["First unread article" gnus-summary-first-unread-article t]
1912 ["Best unread article" gnus-summary-best-unread-article t]
1913 ["Go to subject number..." gnus-summary-goto-subject t]
1914 ["Go to article number..." gnus-summary-goto-article t]
1915 ["Go to the last article" gnus-summary-goto-last-article t]
1916 ["Pop article off history" gnus-summary-pop-article t])
1918 ["Sort by number" gnus-summary-sort-by-number t]
1919 ["Sort by author" gnus-summary-sort-by-author t]
1920 ["Sort by subject" gnus-summary-sort-by-subject t]
1921 ["Sort by date" gnus-summary-sort-by-date t]
1922 ["Sort by score" gnus-summary-sort-by-score t]
1923 ["Sort by lines" gnus-summary-sort-by-lines t]
1924 ["Sort by characters" gnus-summary-sort-by-chars t])
1926 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1927 ["Describe group" gnus-summary-describe-group t]
1928 ["Read manual" gnus-info-find-node t])
1930 ["Pick and read" gnus-pick-mode t]
1931 ["Binary" gnus-binary-mode t])
1933 ["Regenerate" gnus-summary-prepare t]
1934 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1935 ["Toggle threading" gnus-summary-toggle-threads t])
1936 ["Filter articles..." gnus-summary-execute-command t]
1937 ["Run command on subjects..." gnus-summary-universal-argument t]
1938 ["Search articles forward..." gnus-summary-search-article-forward t]
1939 ["Search articles backward..." gnus-summary-search-article-backward t]
1940 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1941 ["Expand window" gnus-summary-expand-window t]
1942 ["Expire expirable articles" gnus-summary-expire-articles
1943 (gnus-check-backend-function
1944 'request-expire-articles gnus-newsgroup-name)]
1945 ["Edit local kill file" gnus-summary-edit-local-kill t]
1946 ["Edit main kill file" gnus-summary-edit-global-kill t]
1947 ["Edit group parameters" gnus-summary-edit-parameters t]
1948 ["Customize group parameters" gnus-summary-customize-parameters t]
1949 ["Send a bug report" gnus-bug t]
1951 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1952 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1953 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1954 ["Exit group" gnus-summary-exit t]
1955 ["Exit group without updating" gnus-summary-exit-no-update t]
1956 ["Exit and goto next group" gnus-summary-next-group t]
1957 ["Exit and goto prev group" gnus-summary-prev-group t]
1958 ["Reselect group" gnus-summary-reselect-current-group t]
1959 ["Rescan group" gnus-summary-rescan-group t]
1960 ["Update dribble" gnus-summary-save-newsrc t])))
1962 (gnus-run-hooks 'gnus-summary-menu-hook)))
1964 (defun gnus-score-set-default (var value)
1965 "A version of set that updates the GNU Emacs menu-bar."
1967 ;; It is the message that forces the active status to be updated.
1970 (defun gnus-make-score-map (type)
1971 "Make a summary score map of type TYPE."
1974 (let ((headers '(("author" "from" string)
1975 ("subject" "subject" string)
1976 ("article body" "body" string)
1977 ("article head" "head" string)
1978 ("xref" "xref" string)
1979 ("extra header" "extra" string)
1980 ("lines" "lines" number)
1981 ("followups to author" "followup" string)))
1982 (types '((number ("less than" <)
1985 (string ("substring" s)
1989 (perms '(("temporary" (current-time-string))
1997 (if (eq type 'lower)
2002 (setq header (car headers))
2008 (let ((ts (cdr (assoc (nth 2 header) types)))
2024 'gnus-summary-score-entry
2026 (if (or (string= (nth 1 header)
2028 (string= (nth 1 header)
2031 (list 'gnus-summary-header
2033 (list 'quote (nth 1 (car ts)))
2034 (list 'gnus-score-delta-default
2041 (list (nreverse outp))))
2044 (list (nreverse outt))))
2046 (setq headers (cdr headers)))
2047 (list (nreverse outh))))))))
2051 (defun gnus-summary-mode (&optional group)
2052 "Major mode for reading articles.
2054 All normal editing commands are switched off.
2055 \\<gnus-summary-mode-map>
2056 Each line in this buffer represents one article. To read an
2057 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2058 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2061 You can also post articles and send mail from this buffer. To
2062 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2063 of an article, type `\\[gnus-summary-reply]'.
2065 There are approx. one gazillion commands you can execute in this
2066 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2068 The following commands are available:
2070 \\{gnus-summary-mode-map}"
2072 (when (gnus-visual-p 'summary-menu 'menu)
2073 (gnus-summary-make-menu-bar))
2074 (kill-all-local-variables)
2075 (gnus-summary-make-local-variables)
2076 (gnus-make-thread-indent-array)
2077 (gnus-simplify-mode-line)
2078 (setq major-mode 'gnus-summary-mode)
2079 (setq mode-name "Summary")
2080 (make-local-variable 'minor-mode-alist)
2081 (use-local-map gnus-summary-mode-map)
2082 (buffer-disable-undo)
2083 (setq buffer-read-only t) ;Disable modification
2084 (setq truncate-lines t)
2085 (setq selective-display t)
2086 (setq selective-display-ellipses t) ;Display `...'
2087 (gnus-summary-set-display-table)
2088 (gnus-set-default-directory)
2089 (setq gnus-newsgroup-name group)
2090 (unless (gnus-news-group-p group)
2091 (setq gnus-newsgroup-incorporated
2092 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2093 (make-local-variable 'gnus-summary-line-format)
2094 (make-local-variable 'gnus-summary-line-format-spec)
2095 (make-local-variable 'gnus-summary-dummy-line-format)
2096 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2097 (make-local-variable 'gnus-summary-mark-positions)
2098 (make-local-hook 'pre-command-hook)
2099 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2100 (gnus-run-hooks 'gnus-summary-mode-hook)
2101 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2102 (gnus-update-summary-mark-positions))
2104 (defun gnus-summary-make-local-variables ()
2105 "Make all the local summary buffer variables."
2107 (dolist (local gnus-summary-local-variables)
2110 (if (eq (cdr local) 'global)
2111 ;; Copy the global value of the variable.
2112 (setq global (symbol-value (car local)))
2113 ;; Use the value from the list.
2114 (setq global (eval (cdr local))))
2115 (set (make-local-variable (car local)) global))
2116 ;; Simple nil-valued local variable.
2117 (set (make-local-variable local) nil)))))
2119 (defun gnus-summary-clear-local-variables ()
2120 (let ((locals gnus-summary-local-variables))
2122 (if (consp (car locals))
2123 (and (vectorp (caar locals))
2124 (set (caar locals) nil))
2125 (and (vectorp (car locals))
2126 (set (car locals) nil)))
2127 (setq locals (cdr locals)))))
2129 ;; Summary data functions.
2131 (defmacro gnus-data-number (data)
2134 (defmacro gnus-data-set-number (data number)
2135 `(setcar ,data ,number))
2137 (defmacro gnus-data-mark (data)
2140 (defmacro gnus-data-set-mark (data mark)
2141 `(setcar (nthcdr 1 ,data) ,mark))
2143 (defmacro gnus-data-pos (data)
2146 (defmacro gnus-data-set-pos (data pos)
2147 `(setcar (nthcdr 2 ,data) ,pos))
2149 (defmacro gnus-data-header (data)
2152 (defmacro gnus-data-set-header (data header)
2153 `(setcar (nthcdr 3 ,data) ,header))
2155 (defmacro gnus-data-level (data)
2158 (defmacro gnus-data-unread-p (data)
2159 `(= (nth 1 ,data) gnus-unread-mark))
2161 (defmacro gnus-data-read-p (data)
2162 `(/= (nth 1 ,data) gnus-unread-mark))
2164 (defmacro gnus-data-pseudo-p (data)
2165 `(consp (nth 3 ,data)))
2167 (defmacro gnus-data-find (number)
2168 `(assq ,number gnus-newsgroup-data))
2170 (defmacro gnus-data-find-list (number &optional data)
2171 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2172 (memq (assq ,number bdata)
2175 (defmacro gnus-data-make (number mark pos header level)
2176 `(list ,number ,mark ,pos ,header ,level))
2178 (defun gnus-data-enter (after-article number mark pos header level offset)
2179 (let ((data (gnus-data-find-list after-article)))
2181 (error "No such article: %d" after-article))
2182 (setcdr data (cons (gnus-data-make number mark pos header level)
2184 (setq gnus-newsgroup-data-reverse nil)
2185 (gnus-data-update-list (cddr data) offset)))
2187 (defun gnus-data-enter-list (after-article list &optional offset)
2189 (let ((data (and after-article (gnus-data-find-list after-article)))
2193 (let ((odata gnus-newsgroup-data))
2194 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2196 (gnus-data-update-list odata offset)))
2197 ;; Find the last element in the list to be spliced into the main
2200 (setq list (cdr list)))
2203 (setcdr list gnus-newsgroup-data)
2204 (setq gnus-newsgroup-data ilist)
2206 (gnus-data-update-list (cdr list) offset)))
2207 (setcdr list (cdr data))
2210 (gnus-data-update-list (cdr list) offset))))
2211 (setq gnus-newsgroup-data-reverse nil))))
2213 (defun gnus-data-remove (article &optional offset)
2214 (let ((data gnus-newsgroup-data))
2215 (if (= (gnus-data-number (car data)) article)
2217 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2218 gnus-newsgroup-data-reverse nil)
2220 (gnus-data-update-list gnus-newsgroup-data offset)))
2222 (when (= (gnus-data-number (cadr data)) article)
2223 (setcdr data (cddr data))
2225 (gnus-data-update-list (cdr data) offset))
2227 gnus-newsgroup-data-reverse nil))
2228 (setq data (cdr data))))))
2230 (defmacro gnus-data-list (backward)
2232 (or gnus-newsgroup-data-reverse
2233 (setq gnus-newsgroup-data-reverse
2234 (reverse gnus-newsgroup-data)))
2235 gnus-newsgroup-data))
2237 (defun gnus-data-update-list (data offset)
2238 "Add OFFSET to the POS of all data entries in DATA."
2239 (setq gnus-newsgroup-data-reverse nil)
2241 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2242 (setq data (cdr data))))
2244 (defun gnus-summary-article-pseudo-p (article)
2245 "Say whether this article is a pseudo article or not."
2246 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2248 (defmacro gnus-summary-article-sparse-p (article)
2249 "Say whether this article is a sparse article or not."
2250 `(memq ,article gnus-newsgroup-sparse))
2252 (defmacro gnus-summary-article-ancient-p (article)
2253 "Say whether this article is a sparse article or not."
2254 `(memq ,article gnus-newsgroup-ancient))
2256 (defun gnus-article-parent-p (number)
2257 "Say whether this article is a parent or not."
2258 (let ((data (gnus-data-find-list number)))
2259 (and (cdr data) ; There has to be an article after...
2260 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2261 (gnus-data-level (nth 1 data))))))
2263 (defun gnus-article-children (number)
2264 "Return a list of all children to NUMBER."
2265 (let* ((data (gnus-data-find-list number))
2266 (level (gnus-data-level (car data)))
2268 (setq data (cdr data))
2270 (= (gnus-data-level (car data)) (1+ level)))
2271 (push (gnus-data-number (car data)) children)
2272 (setq data (cdr data)))
2275 (defmacro gnus-summary-skip-intangible ()
2276 "If the current article is intangible, then jump to a different article."
2277 '(let ((to (get-text-property (point) 'gnus-intangible)))
2278 (and to (gnus-summary-goto-subject to))))
2280 (defmacro gnus-summary-article-intangible-p ()
2281 "Say whether this article is intangible or not."
2282 '(get-text-property (point) 'gnus-intangible))
2284 (defun gnus-article-read-p (article)
2285 "Say whether ARTICLE is read or not."
2286 (not (or (memq article gnus-newsgroup-marked)
2287 (memq article gnus-newsgroup-unreads)
2288 (memq article gnus-newsgroup-unselected)
2289 (memq article gnus-newsgroup-dormant))))
2291 ;; Some summary mode macros.
2293 (defmacro gnus-summary-article-number ()
2294 "The article number of the article on the current line.
2295 If there isn's an article number here, then we return the current
2298 (gnus-summary-skip-intangible)
2299 (or (get-text-property (point) 'gnus-number)
2300 (gnus-summary-last-subject))))
2302 (defmacro gnus-summary-article-header (&optional number)
2303 "Return the header of article NUMBER."
2304 `(gnus-data-header (gnus-data-find
2305 ,(or number '(gnus-summary-article-number)))))
2307 (defmacro gnus-summary-thread-level (&optional number)
2308 "Return the level of thread that starts with article NUMBER."
2309 `(if (and (eq gnus-summary-make-false-root 'dummy)
2310 (get-text-property (point) 'gnus-intangible))
2312 (gnus-data-level (gnus-data-find
2313 ,(or number '(gnus-summary-article-number))))))
2315 (defmacro gnus-summary-article-mark (&optional number)
2316 "Return the mark of article NUMBER."
2317 `(gnus-data-mark (gnus-data-find
2318 ,(or number '(gnus-summary-article-number)))))
2320 (defmacro gnus-summary-article-pos (&optional number)
2321 "Return the position of the line of article NUMBER."
2322 `(gnus-data-pos (gnus-data-find
2323 ,(or number '(gnus-summary-article-number)))))
2325 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2326 (defmacro gnus-summary-article-subject (&optional number)
2327 "Return current subject string or nil if nothing."
2330 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2331 '(gnus-data-header (assq (gnus-summary-article-number)
2332 gnus-newsgroup-data)))))
2335 (mail-header-subject headers))))
2337 (defmacro gnus-summary-article-score (&optional number)
2338 "Return current article score."
2339 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2340 gnus-newsgroup-scored))
2341 gnus-summary-default-score 0))
2343 (defun gnus-summary-article-children (&optional number)
2344 "Return a list of article numbers that are children of article NUMBER."
2345 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2346 (level (gnus-data-level (car data)))
2348 (while (and (setq data (cdr data))
2349 (> (setq l (gnus-data-level (car data))) level))
2350 (and (= (1+ level) l)
2351 (push (gnus-data-number (car data))
2353 (nreverse children)))
2355 (defun gnus-summary-article-parent (&optional number)
2356 "Return the article number of the parent of article NUMBER."
2357 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2358 (gnus-data-list t)))
2359 (level (gnus-data-level (car data))))
2361 () ; This is a root.
2362 ;; We search until we find an article with a level less than
2363 ;; this one. That function has to be the parent.
2364 (while (and (setq data (cdr data))
2365 (not (< (gnus-data-level (car data)) level))))
2366 (and data (gnus-data-number (car data))))))
2368 (defun gnus-unread-mark-p (mark)
2369 "Say whether MARK is the unread mark."
2370 (= mark gnus-unread-mark))
2372 (defun gnus-read-mark-p (mark)
2373 "Say whether MARK is one of the marks that mark as read.
2374 This is all marks except unread, ticked, dormant, and expirable."
2375 (not (or (= mark gnus-unread-mark)
2376 (= mark gnus-ticked-mark)
2377 (= mark gnus-dormant-mark)
2378 (= mark gnus-expirable-mark))))
2380 (defmacro gnus-article-mark (number)
2381 "Return the MARK of article NUMBER.
2382 This macro should only be used when computing the mark the \"first\"
2383 time; i.e., when generating the summary lines. After that,
2384 `gnus-summary-article-mark' should be used to examine the
2387 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2388 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2389 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2390 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2391 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2392 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2393 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2394 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2395 gnus-ancient-mark))))
2397 ;; Saving hidden threads.
2399 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2400 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2402 (defmacro gnus-save-hidden-threads (&rest forms)
2403 "Save hidden threads, eval FORMS, and restore the hidden threads."
2404 (let ((config (make-symbol "config")))
2405 `(let ((,config (gnus-hidden-threads-configuration)))
2409 (gnus-restore-hidden-threads-configuration ,config)))))
2411 (defun gnus-data-compute-positions ()
2412 "Compute the positions of all articles."
2413 (setq gnus-newsgroup-data-reverse nil)
2414 (let ((data gnus-newsgroup-data))
2416 (gnus-save-hidden-threads
2417 (gnus-summary-show-all-threads)
2418 (goto-char (point-min))
2420 (while (get-text-property (point) 'gnus-intangible)
2422 (gnus-data-set-pos (car data) (+ (point) 3))
2423 (setq data (cdr data))
2424 (forward-line 1))))))
2426 (defun gnus-hidden-threads-configuration ()
2427 "Return the current hidden threads configuration."
2430 (goto-char (point-min))
2431 (while (search-forward "\r" nil t)
2432 (push (1- (point)) config))
2435 (defun gnus-restore-hidden-threads-configuration (config)
2436 "Restore hidden threads configuration from CONFIG."
2437 (let (point buffer-read-only)
2438 (while (setq point (pop config))
2439 (when (and (< point (point-max))
2441 (eq (char-after) ?\n))
2442 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2444 ;; Various summary mode internalish functions.
2446 (defun gnus-mouse-pick-article (e)
2449 (gnus-summary-next-page nil t))
2451 (defun gnus-summary-set-display-table ()
2452 ;; Change the display table. Odd characters have a tendency to mess
2453 ;; up nicely formatted displays - we make all possible glyphs
2454 ;; display only a single character.
2456 ;; We start from the standard display table, if any.
2457 (let ((table (or (copy-sequence standard-display-table)
2458 (make-display-table)))
2460 ;; Nix out all the control chars...
2461 (while (>= (setq i (1- i)) 0)
2462 (aset table i [??]))
2463 ;; ... but not newline and cr, of course. (cr is necessary for the
2464 ;; selective display).
2465 (aset table ?\n nil)
2466 (aset table ?\r nil)
2467 ;; We keep TAB as well.
2468 (aset table ?\t nil)
2469 ;; We nix out any glyphs over 126 that are not set already.
2471 (while (>= (setq i (1- i)) 127)
2472 ;; Only modify if the entry is nil.
2473 (unless (aref table i)
2474 (aset table i [??]))))
2475 (setq buffer-display-table table)))
2477 (defun gnus-summary-setup-buffer (group)
2478 "Initialize summary buffer."
2479 (let ((buffer (concat "*Summary " group "*")))
2480 (if (get-buffer buffer)
2483 (setq gnus-summary-buffer (current-buffer))
2484 (not gnus-newsgroup-prepared))
2485 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2486 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2487 (gnus-summary-mode group)
2489 (gnus-carpal-setup-buffer 'summary))
2490 (unless gnus-single-article-buffer
2491 (make-local-variable 'gnus-article-buffer)
2492 (make-local-variable 'gnus-article-current)
2493 (make-local-variable 'gnus-original-article-buffer))
2494 (setq gnus-newsgroup-name group)
2497 (defun gnus-set-global-variables ()
2498 ;; Set the global equivalents of the summary buffer-local variables
2499 ;; to the latest values they had. These reflect the summary buffer
2500 ;; that was in action when the last article was fetched.
2501 (when (eq major-mode 'gnus-summary-mode)
2502 (setq gnus-summary-buffer (current-buffer))
2503 (let ((name gnus-newsgroup-name)
2504 (marked gnus-newsgroup-marked)
2505 (unread gnus-newsgroup-unreads)
2506 (headers gnus-current-headers)
2507 (data gnus-newsgroup-data)
2508 (summary gnus-summary-buffer)
2509 (article-buffer gnus-article-buffer)
2510 (original gnus-original-article-buffer)
2511 (gac gnus-article-current)
2512 (reffed gnus-reffed-article-number)
2513 (score-file gnus-current-score-file)
2514 (default-charset gnus-newsgroup-charset))
2516 (set-buffer gnus-group-buffer)
2517 (setq gnus-newsgroup-name name
2518 gnus-newsgroup-marked marked
2519 gnus-newsgroup-unreads unread
2520 gnus-current-headers headers
2521 gnus-newsgroup-data data
2522 gnus-article-current gac
2523 gnus-summary-buffer summary
2524 gnus-article-buffer article-buffer
2525 gnus-original-article-buffer original
2526 gnus-reffed-article-number reffed
2527 gnus-current-score-file score-file
2528 gnus-newsgroup-charset default-charset)
2529 ;; The article buffer also has local variables.
2530 (when (gnus-buffer-live-p gnus-article-buffer)
2531 (set-buffer gnus-article-buffer)
2532 (setq gnus-summary-buffer summary))))))
2534 (defun gnus-summary-article-unread-p (article)
2535 "Say whether ARTICLE is unread or not."
2536 (memq article gnus-newsgroup-unreads))
2538 (defun gnus-summary-first-article-p (&optional article)
2539 "Return whether ARTICLE is the first article in the buffer."
2540 (if (not (setq article (or article (gnus-summary-article-number))))
2542 (eq article (caar gnus-newsgroup-data))))
2544 (defun gnus-summary-last-article-p (&optional article)
2545 "Return whether ARTICLE is the last article in the buffer."
2546 (if (not (setq article (or article (gnus-summary-article-number))))
2547 ;; All non-existent numbers are the last article. :-)
2549 (not (cdr (gnus-data-find-list article)))))
2551 (defun gnus-make-thread-indent-array ()
2553 (unless (and gnus-thread-indent-array
2554 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2555 (setq gnus-thread-indent-array (make-vector 201 "")
2556 gnus-thread-indent-array-level gnus-thread-indent-level)
2558 (aset gnus-thread-indent-array n
2559 (make-string (* n gnus-thread-indent-level) ? ))
2562 (defun gnus-update-summary-mark-positions ()
2563 "Compute where the summary marks are to go."
2565 (when (gnus-buffer-exists-p gnus-summary-buffer)
2566 (set-buffer gnus-summary-buffer))
2567 (let ((gnus-replied-mark 129)
2568 (gnus-score-below-mark 130)
2569 (gnus-score-over-mark 130)
2570 (gnus-download-mark 131)
2571 (spec gnus-summary-line-format-spec)
2574 (gnus-set-work-buffer)
2575 (let ((gnus-summary-line-format-spec spec)
2576 (gnus-newsgroup-downloadable '((0 . t))))
2577 (gnus-summary-insert-line
2578 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2579 0 nil 128 t nil "" nil 1)
2580 (goto-char (point-min))
2581 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2583 (goto-char (point-min))
2584 (push (cons 'replied (and (search-forward "\201" nil t)
2587 (goto-char (point-min))
2588 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2590 (goto-char (point-min))
2591 (push (cons 'download
2592 (and (search-forward "\203" nil t) (- (point) 2)))
2594 (setq gnus-summary-mark-positions pos))))
2596 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2597 "Insert a dummy root in the summary buffer."
2599 (gnus-add-text-properties
2600 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2601 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2603 (defun gnus-summary-from-or-to-or-newsgroups (header)
2604 (let ((to (cdr (assq 'To (mail-header-extra header))))
2605 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2606 (default-mime-charset (with-current-buffer gnus-summary-buffer
2607 default-mime-charset)))
2610 gnus-ignored-from-addresses
2611 (string-match gnus-ignored-from-addresses
2612 (mail-header-from header)))
2614 (or (car (funcall gnus-extract-address-components
2616 gnus-decode-encoded-word-function to)))
2617 (funcall gnus-decode-encoded-word-function to))))
2619 gnus-ignored-from-addresses
2620 (string-match gnus-ignored-from-addresses
2621 (mail-header-from header)))
2622 (concat "=> " newsgroups))
2624 (or (car (funcall gnus-extract-address-components
2625 (mail-header-from header)))
2626 (mail-header-from header))))))
2628 (defun gnus-summary-insert-line (gnus-tmp-header
2629 gnus-tmp-level gnus-tmp-current
2630 gnus-tmp-unread gnus-tmp-replied
2631 gnus-tmp-expirable gnus-tmp-subject-or-nil
2632 &optional gnus-tmp-dummy gnus-tmp-score
2634 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2635 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2636 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2637 (gnus-tmp-score-char
2638 (if (or (null gnus-summary-default-score)
2639 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2640 gnus-summary-zcore-fuzz))
2642 (if (< gnus-tmp-score gnus-summary-default-score)
2643 gnus-score-below-mark gnus-score-over-mark)))
2645 (cond (gnus-tmp-process gnus-process-mark)
2646 ((memq gnus-tmp-current gnus-newsgroup-cached)
2648 (gnus-tmp-replied gnus-replied-mark)
2649 ((memq gnus-tmp-current gnus-newsgroup-saved)
2651 (t gnus-unread-mark)))
2652 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2655 ((string-match "<[^>]+> *$" gnus-tmp-from)
2656 (let ((beg (match-beginning 0)))
2657 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2658 (substring gnus-tmp-from (1+ (match-beginning 0))
2659 (1- (match-end 0))))
2660 (substring gnus-tmp-from 0 beg))))
2661 ((string-match "(.+)" gnus-tmp-from)
2662 (substring gnus-tmp-from
2663 (1+ (match-beginning 0)) (1- (match-end 0))))
2665 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2666 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2667 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2668 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2669 (buffer-read-only nil))
2670 (when (string= gnus-tmp-name "")
2671 (setq gnus-tmp-name gnus-tmp-from))
2672 (unless (numberp gnus-tmp-lines)
2673 (setq gnus-tmp-lines 0))
2674 (gnus-put-text-property-excluding-characters-with-faces
2676 (progn (eval gnus-summary-line-format-spec) (point))
2677 'gnus-number gnus-tmp-number)
2678 (when (gnus-visual-p 'summary-highlight 'highlight)
2680 (gnus-run-hooks 'gnus-summary-update-hook)
2683 (defun gnus-summary-update-line (&optional dont-update)
2684 ;; Update summary line after change.
2685 (when (and gnus-summary-default-score
2686 (not gnus-summary-inhibit-highlight))
2687 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2688 (article (gnus-summary-article-number))
2689 (score (gnus-summary-article-score article)))
2691 (if (and gnus-summary-mark-below
2692 (< (gnus-summary-article-score)
2693 gnus-summary-mark-below))
2694 ;; This article has a low score, so we mark it as read.
2695 (when (memq article gnus-newsgroup-unreads)
2696 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2697 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2698 ;; This article was previously marked as read on account
2699 ;; of a low score, but now it has risen, so we mark it as
2701 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2702 (gnus-summary-update-mark
2703 (if (or (null gnus-summary-default-score)
2704 (<= (abs (- score gnus-summary-default-score))
2705 gnus-summary-zcore-fuzz))
2707 (if (< score gnus-summary-default-score)
2708 gnus-score-below-mark gnus-score-over-mark))
2710 ;; Do visual highlighting.
2711 (when (gnus-visual-p 'summary-highlight 'highlight)
2712 (gnus-run-hooks 'gnus-summary-update-hook)))))
2714 (defvar gnus-tmp-new-adopts nil)
2716 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2717 "Return the number of articles in THREAD.
2718 This may be 0 in some cases -- if none of the articles in
2719 the thread are to be displayed."
2721 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2723 ((not (listp thread))
2725 ((and (consp thread) (cdr thread))
2728 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2731 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2734 (when (and level (zerop level) gnus-tmp-new-adopts)
2737 'gnus-summary-number-of-articles-in-thread
2738 gnus-tmp-new-adopts))))
2740 (if (> number 1) gnus-not-empty-thread-mark
2741 gnus-empty-thread-mark)
2744 (defun gnus-summary-set-local-parameters (group)
2745 "Go through the local params of GROUP and set all variable specs in that list."
2746 (let ((params (gnus-group-find-parameter group))
2749 (setq elem (car params)
2750 params (cdr params))
2751 (and (consp elem) ; Has to be a cons.
2752 (consp (cdr elem)) ; The cdr has to be a list.
2753 (symbolp (car elem)) ; Has to be a symbol in there.
2754 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2755 (ignore-errors ; So we set it.
2756 (make-local-variable (car elem))
2757 (set (car elem) (eval (nth 1 elem))))))))
2759 (defun gnus-summary-read-group (group &optional show-all no-article
2760 kill-buffer no-display backward
2762 "Start reading news in newsgroup GROUP.
2763 If SHOW-ALL is non-nil, already read articles are also listed.
2764 If NO-ARTICLE is non-nil, no article is selected initially.
2765 If NO-DISPLAY, don't generate a summary buffer."
2769 (let ((gnus-auto-select-next nil))
2770 (or (gnus-summary-read-group-1
2771 group show-all no-article
2772 kill-buffer no-display
2775 select-articles nil)))))
2776 (eq gnus-auto-select-next 'quietly))
2777 (set-buffer gnus-group-buffer)
2778 ;; The entry function called above goes to the next
2779 ;; group automatically, so we go two groups back
2780 ;; if we are searching for the previous group.
2782 (gnus-group-prev-unread-group 2))
2783 (if (not (equal group (gnus-group-group-name)))
2784 (setq group (gnus-group-group-name))
2788 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2789 "Directly jump to the other GROUP from summary buffer.
2790 If SHOW-ALL is non-nil, already read articles are also listed."
2792 (if (eq gnus-summary-buffer (current-buffer))
2793 (list (completing-read
2794 "Group: " gnus-active-hashtb nil t
2795 (when (and gnus-newsgroup-name
2796 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2797 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2798 'gnus-group-history)
2800 (error "%s must be invoked from a gnus summary buffer." this-command)))
2801 (unless (or (zerop (length group))
2802 (and gnus-newsgroup-name
2803 (string-equal gnus-newsgroup-name group)))
2805 (gnus-summary-read-group group show-all
2806 gnus-dont-select-after-jump-to-other-group)))
2808 (defun gnus-summary-read-group-1 (group show-all no-article
2809 kill-buffer no-display
2810 &optional select-articles)
2811 ;; Killed foreign groups can't be entered.
2812 (when (and (not (gnus-group-native-p group))
2813 (not (gnus-gethash group gnus-newsrc-hashtb)))
2814 (error "Dead non-native groups can't be entered"))
2815 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2816 (let* ((new-group (gnus-summary-setup-buffer group))
2817 (quit-config (gnus-group-quit-config group))
2818 (did-select (and new-group (gnus-select-newsgroup
2819 group show-all select-articles))))
2821 ;; This summary buffer exists already, so we just select it.
2823 (gnus-set-global-variables)
2825 (gnus-kill-or-deaden-summary kill-buffer))
2826 (gnus-configure-windows 'summary 'force)
2827 (gnus-set-mode-line 'summary)
2828 (gnus-summary-position-point)
2831 ;; We couldn't select this group.
2833 (when (and (eq major-mode 'gnus-summary-mode)
2834 (not (equal (current-buffer) kill-buffer)))
2835 (kill-buffer (current-buffer))
2836 (if (not quit-config)
2838 ;; Update the info -- marks might need to be removed,
2840 (gnus-summary-update-info)
2841 (set-buffer gnus-group-buffer)
2842 (gnus-group-jump-to-group group)
2843 (gnus-group-next-unread-group 1))
2844 (gnus-handle-ephemeral-exit quit-config)))
2845 (gnus-message 3 "Can't select group")
2847 ;; The user did a `C-g' while prompting for number of articles,
2848 ;; so we exit this group.
2849 ((eq did-select 'quit)
2850 (and (eq major-mode 'gnus-summary-mode)
2851 (not (equal (current-buffer) kill-buffer))
2852 (kill-buffer (current-buffer)))
2854 (gnus-kill-or-deaden-summary kill-buffer))
2855 (if (not quit-config)
2857 (set-buffer gnus-group-buffer)
2858 (gnus-group-jump-to-group group)
2859 (gnus-group-next-unread-group 1)
2860 (gnus-configure-windows 'group 'force))
2861 (gnus-handle-ephemeral-exit quit-config))
2862 ;; Finally signal the quit.
2864 ;; The group was successfully selected.
2866 (gnus-set-global-variables)
2867 ;; Save the active value in effect when the group was entered.
2868 (setq gnus-newsgroup-active
2870 (gnus-active gnus-newsgroup-name)))
2871 ;; You can change the summary buffer in some way with this hook.
2872 (gnus-run-hooks 'gnus-select-group-hook)
2873 ;; Set any local variables in the group parameters.
2874 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2875 (gnus-update-format-specifications
2876 nil 'summary 'summary-mode 'summary-dummy)
2877 (gnus-update-summary-mark-positions)
2878 ;; Do score processing.
2879 (when gnus-use-scoring
2880 (gnus-possibly-score-headers))
2881 ;; Check whether to fill in the gaps in the threads.
2882 (when gnus-build-sparse-threads
2883 (gnus-build-sparse-threads))
2884 ;; Find the initial limit.
2885 (if gnus-show-threads
2887 (let ((gnus-newsgroup-dormant nil))
2888 (gnus-summary-initial-limit show-all))
2889 (gnus-summary-initial-limit show-all))
2890 ;; When untreaded, all articles are always shown.
2891 (setq gnus-newsgroup-limit
2893 (lambda (header) (mail-header-number header))
2894 gnus-newsgroup-headers)))
2895 ;; Generate the summary buffer.
2897 (gnus-summary-prepare))
2898 (when gnus-use-trees
2899 (gnus-tree-open group)
2900 (setq gnus-summary-highlight-line-function
2901 'gnus-tree-highlight-article))
2902 ;; If the summary buffer is empty, but there are some low-scored
2903 ;; articles or some excluded dormants, we include these in the
2905 (when (and (zerop (buffer-size))
2907 (cond (gnus-newsgroup-dormant
2908 (gnus-summary-limit-include-dormant))
2909 ((and gnus-newsgroup-scored show-all)
2910 (gnus-summary-limit-include-expunged t))))
2911 ;; Function `gnus-apply-kill-file' must be called in this hook.
2912 (gnus-run-hooks 'gnus-apply-kill-hook)
2913 (if (and (zerop (buffer-size))
2916 ;; This newsgroup is empty.
2917 (gnus-summary-catchup-and-exit nil t)
2918 (gnus-message 6 "No unread news")
2920 (gnus-kill-or-deaden-summary kill-buffer))
2921 ;; Return nil from this function.
2923 ;; Hide conversation thread subtrees. We cannot do this in
2924 ;; gnus-summary-prepare-hook since kill processing may not
2925 ;; work with hidden articles.
2926 (and gnus-show-threads
2927 gnus-thread-hide-subtree
2928 (gnus-summary-hide-all-threads))
2930 (gnus-kill-or-deaden-summary kill-buffer))
2931 ;; Show first unread article if requested.
2932 (if (and (not no-article)
2934 gnus-newsgroup-unreads
2935 gnus-auto-select-first)
2937 (gnus-configure-windows 'summary)
2939 ((eq gnus-auto-select-first 'best)
2940 (gnus-summary-best-unread-article))
2941 ((eq gnus-auto-select-first t)
2942 (gnus-summary-first-unread-article))
2943 ((gnus-functionp gnus-auto-select-first)
2944 (funcall gnus-auto-select-first))))
2945 ;; Don't select any articles, just move point to the first
2946 ;; article in the group.
2947 (goto-char (point-min))
2948 (gnus-summary-position-point)
2949 (gnus-configure-windows 'summary 'force)
2950 (gnus-set-mode-line 'summary))
2951 (when (get-buffer-window gnus-group-buffer t)
2952 ;; Gotta use windows, because recenter does weird stuff if
2953 ;; the current buffer ain't the displayed window.
2954 (let ((owin (selected-window)))
2955 (select-window (get-buffer-window gnus-group-buffer t))
2956 (when (gnus-group-goto-group group)
2958 (select-window owin)))
2959 ;; Mark this buffer as "prepared".
2960 (setq gnus-newsgroup-prepared t)
2961 (gnus-run-hooks 'gnus-summary-prepared-hook)
2964 (defun gnus-summary-prepare ()
2965 "Generate the summary buffer."
2967 (let ((buffer-read-only nil))
2969 (setq gnus-newsgroup-data nil
2970 gnus-newsgroup-data-reverse nil)
2971 (gnus-run-hooks 'gnus-summary-generate-hook)
2972 ;; Generate the buffer, either with threads or without.
2973 (when gnus-newsgroup-headers
2974 (gnus-summary-prepare-threads
2975 (if gnus-show-threads
2976 (gnus-sort-gathered-threads
2977 (funcall gnus-summary-thread-gathering-function
2979 (gnus-cut-threads (gnus-make-threads)))))
2980 ;; Unthreaded display.
2981 (gnus-sort-articles gnus-newsgroup-headers))))
2982 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2983 ;; Call hooks for modifying summary buffer.
2984 (goto-char (point-min))
2985 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2987 (defsubst gnus-general-simplify-subject (subject)
2988 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2991 ;; Truncate the subject.
2992 (gnus-simplify-subject-functions
2993 (gnus-map-function gnus-simplify-subject-functions subject))
2994 ((numberp gnus-summary-gather-subject-limit)
2995 (setq subject (gnus-simplify-subject-re subject))
2996 (if (> (length subject) gnus-summary-gather-subject-limit)
2997 (substring subject 0 gnus-summary-gather-subject-limit)
2999 ;; Fuzzily simplify it.
3000 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3001 (gnus-simplify-subject-fuzzy subject))
3002 ;; Just remove the leading "Re:".
3004 (gnus-simplify-subject-re subject))))
3006 (if (and gnus-summary-gather-exclude-subject
3007 (string-match gnus-summary-gather-exclude-subject subject))
3008 nil ; This article shouldn't be gathered
3011 (defun gnus-summary-simplify-subject-query ()
3012 "Query where the respool algorithm would put this article."
3014 (gnus-summary-select-article)
3016 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3018 (defun gnus-gather-threads-by-subject (threads)
3019 "Gather threads by looking at Subject headers."
3020 (if (not gnus-summary-make-false-root)
3022 (let ((hashtb (gnus-make-hashtable 1024))
3025 subject hthread whole-subject)
3027 (setq subject (gnus-general-simplify-subject
3028 (setq whole-subject (mail-header-subject
3031 (if (setq hthread (gnus-gethash subject hashtb))
3033 ;; We enter a dummy root into the thread, if we
3034 ;; haven't done that already.
3035 (unless (stringp (caar hthread))
3036 (setcar hthread (list whole-subject (car hthread))))
3037 ;; We add this new gathered thread to this gathered
3039 (setcdr (car hthread)
3040 (nconc (cdar hthread) (list (car threads))))
3041 ;; Remove it from the list of threads.
3042 (setcdr prev (cdr threads))
3043 (setq threads prev))
3044 ;; Enter this thread into the hash table.
3045 (gnus-sethash subject threads hashtb)))
3047 (setq threads (cdr threads)))
3050 (defun gnus-gather-threads-by-references (threads)
3051 "Gather threads by looking at References headers."
3052 (let ((idhashtb (gnus-make-hashtable 1024))
3053 (thhashtb (gnus-make-hashtable 1024))
3056 ids references id gthread gid entered ref)
3058 (when (setq references (mail-header-references (caar threads)))
3059 (setq id (mail-header-id (caar threads))
3060 ids (gnus-split-references references)
3062 (while (setq ref (pop ids))
3063 (setq ids (delete ref ids))
3064 (if (not (setq gid (gnus-gethash ref idhashtb)))
3066 (gnus-sethash ref id idhashtb)
3067 (gnus-sethash id threads thhashtb))
3068 (setq gthread (gnus-gethash gid thhashtb))
3070 ;; We enter a dummy root into the thread, if we
3071 ;; haven't done that already.
3072 (unless (stringp (caar gthread))
3073 (setcar gthread (list (mail-header-subject (caar gthread))
3075 ;; We add this new gathered thread to this gathered
3077 (setcdr (car gthread)
3078 (nconc (cdar gthread) (list (car threads)))))
3079 ;; Add it into the thread hash table.
3080 (gnus-sethash id gthread thhashtb)
3082 ;; Remove it from the list of threads.
3083 (setcdr prev (cdr threads))
3084 (setq threads prev))))
3086 (setq threads (cdr threads)))
3089 (defun gnus-sort-gathered-threads (threads)
3090 "Sort subtreads inside each gathered thread by article number."
3091 (let ((result threads))
3093 (when (stringp (caar threads))
3094 (setcdr (car threads)
3095 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3096 (setq threads (cdr threads)))
3099 (defun gnus-thread-loop-p (root thread)
3100 "Say whether ROOT is in THREAD."
3101 (let ((stack (list thread))
3104 (while (setq thread (pop stack))
3105 (setq th (cdr thread))
3107 (not (eq (caar th) root)))
3110 ;; We have found a loop.
3112 (setcdr thread (delq (car th) (cdr thread)))
3113 (if (boundp (setq ref-dep (intern "none"
3114 gnus-newsgroup-dependencies)))
3115 (setcdr (symbol-value ref-dep)
3116 (nconc (cdr (symbol-value ref-dep))
3118 (set ref-dep (list nil (car th))))
3121 ;; Push all the subthreads onto the stack.
3122 (push (cdr thread) stack)))
3125 (defun gnus-make-threads ()
3126 "Go through the dependency hashtb and find the roots. Return all threads."
3128 (while (catch 'infloop
3131 ;; Deal with self-referencing References loops.
3132 (when (and (car (symbol-value refs))
3139 (car (symbol-value refs)) thread))
3140 (cdr (symbol-value refs)))))))
3143 (unless (car (symbol-value refs))
3144 ;; These threads do not refer back to any other articles,
3145 ;; so they're roots.
3146 (setq threads (append (cdr (symbol-value refs)) threads))))
3147 gnus-newsgroup-dependencies)))
3150 ;; Build the thread tree.
3151 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3152 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3154 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3155 if it was already present.
3157 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3158 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3159 Message-IDs will be renamed be renamed to a unique Message-ID before
3162 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3163 (let* ((id (mail-header-id header))
3164 (id-dep (and id (intern id dependencies)))
3165 ref ref-dep ref-header)
3166 ;; Enter this `header' in the `dependencies' table.
3170 ;; The first two cases do the normal part: enter a new `header'
3171 ;; in the `dependencies' table.
3172 ((not (boundp id-dep))
3173 (set id-dep (list header)))
3174 ((null (car (symbol-value id-dep)))
3175 (setcar (symbol-value id-dep) header))
3177 ;; From here the `header' was already present in the
3178 ;; `dependencies' table.
3180 ;; Overrides an existing entry;
3181 ;; just set the header part of the entry.
3182 (setcar (symbol-value id-dep) header))
3184 ;; Renames the existing `header' to a unique Message-ID.
3185 ((not gnus-summary-ignore-duplicates)
3186 ;; An article with this Message-ID has already been seen.
3187 ;; We rename the Message-ID.
3188 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3190 (mail-header-set-id header id))
3192 ;; The last case ignores an existing entry, except it adds any
3193 ;; additional Xrefs (in case the two articles came from different
3195 ;; Also sets `header' to `nil' meaning that the `dependencies'
3196 ;; table was *not* modified.
3198 (mail-header-set-xref
3199 (car (symbol-value id-dep))
3200 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3202 (or (mail-header-xref header) "")))
3206 ;; First check if that we are not creating a References loop.
3207 (setq ref (gnus-parent-id (mail-header-references header)))
3209 (setq ref-dep (intern-soft ref dependencies))
3211 (setq ref-header (car (symbol-value ref-dep))))
3212 (if (string= id ref)
3213 ;; Yuk! This is a reference loop. Make the article be a
3216 (mail-header-set-references (car (symbol-value id-dep)) "none")
3218 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3219 (setq ref (gnus-parent-id (mail-header-references header)))
3220 (setq ref-dep (intern (or ref "none") dependencies))
3221 (if (boundp ref-dep)
3222 (setcdr (symbol-value ref-dep)
3223 (nconc (cdr (symbol-value ref-dep))
3224 (list (symbol-value id-dep))))
3225 (set ref-dep (list nil (symbol-value id-dep)))))
3228 (defun gnus-build-sparse-threads ()
3229 (let ((headers gnus-newsgroup-headers)
3230 (mail-parse-charset gnus-newsgroup-charset)
3231 (gnus-summary-ignore-duplicates t)
3232 header references generation relations
3233 subject child end new-child date)
3234 ;; First we create an alist of generations/relations, where
3235 ;; generations is how much we trust the relation, and the relation
3237 (gnus-message 7 "Making sparse threads...")
3239 (nnheader-set-temp-buffer " *gnus sparse threads*")
3240 (while (setq header (pop headers))
3241 (when (and (setq references (mail-header-references header))
3242 (not (string= references "")))
3244 (setq child (mail-header-id header)
3245 subject (mail-header-subject header)
3246 date (mail-header-date header)
3248 (while (search-backward ">" nil t)
3249 (setq end (1+ (point)))
3250 (when (search-backward "<" nil t)
3251 (setq new-child (buffer-substring (point) end))
3252 (push (list (incf generation)
3253 child (setq child new-child)
3257 (push (list (1+ generation) child nil subject) relations))
3259 (kill-buffer (current-buffer)))
3260 ;; Sort over trustworthiness.
3263 (when (gnus-dependencies-add-header
3264 (make-full-mail-header
3265 gnus-reffed-article-number
3266 (nth 3 relation) "" (or (nth 4 relation) "")
3268 (or (nth 2 relation) "") 0 0 "")
3269 gnus-newsgroup-dependencies nil)
3270 (push gnus-reffed-article-number gnus-newsgroup-limit)
3271 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3272 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3273 gnus-newsgroup-reads)
3274 (decf gnus-reffed-article-number)))
3275 (sort relations 'car-less-than-car))
3276 (gnus-message 7 "Making sparse threads...done")))
3278 (defun gnus-build-old-threads ()
3279 ;; Look at all the articles that refer back to old articles, and
3280 ;; fetch the headers for the articles that aren't there. This will
3281 ;; build complete threads - if the roots haven't been expired by the
3283 (let ((mail-parse-charset gnus-newsgroup-charset)
3287 (when (not (car (symbol-value refs)))
3288 (setq heads (cdr (symbol-value refs)))
3290 (if (memq (mail-header-number (caar heads))
3291 gnus-newsgroup-dormant)
3292 (setq heads (cdr heads))
3293 (setq id (symbol-name refs))
3294 (while (and (setq id (gnus-build-get-header id))
3295 (not (car (gnus-id-to-thread id)))))
3296 (setq heads nil)))))
3297 gnus-newsgroup-dependencies)))
3299 ;; This function has to be called with point after the article number
3300 ;; on the beginning of the line.
3301 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3302 (let ((eol (gnus-point-at-eol))
3303 (buffer (current-buffer))
3306 ;; overview: [num subject from date id refs chars lines misc]
3311 (make-full-mail-header
3313 (nnheader-nov-field) ; subject
3314 (nnheader-nov-field) ; from
3315 (nnheader-nov-field) ; date
3316 (nnheader-nov-read-message-id) ; id
3317 (nnheader-nov-field) ; refs
3318 (nnheader-nov-read-integer) ; chars
3319 (nnheader-nov-read-integer) ; lines
3321 (nnheader-nov-field)) ; misc
3322 (nnheader-nov-parse-extra))) ; extra
3324 (when gnus-alter-header-function
3325 (funcall gnus-alter-header-function header))
3326 (gnus-dependencies-add-header header dependencies force-new)))
3328 (defun gnus-build-get-header (id)
3329 ;; Look through the buffer of NOV lines and find the header to
3330 ;; ID. Enter this line into the dependencies hash table, and return
3331 ;; the id of the parent article (if any).
3332 (let ((deps gnus-newsgroup-dependencies)
3336 (set-buffer nntp-server-buffer)
3337 (let ((case-fold-search nil))
3338 (goto-char (point-min))
3339 (while (and (not found)
3340 (search-forward id nil t))
3342 (setq found (looking-at
3343 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3344 (regexp-quote id))))
3345 (or found (beginning-of-line 2)))
3349 (setq header (gnus-nov-parse-line
3350 (read (current-buffer)) deps))
3351 (gnus-parent-id (mail-header-references header))))))
3353 (let ((number (mail-header-number header)))
3354 (push number gnus-newsgroup-limit)
3355 (push header gnus-newsgroup-headers)
3356 (if (memq number gnus-newsgroup-unselected)
3358 (push number gnus-newsgroup-unreads)
3359 (setq gnus-newsgroup-unselected
3360 (delq number gnus-newsgroup-unselected)))
3361 (push number gnus-newsgroup-ancient)))))))
3363 (defun gnus-build-all-threads ()
3364 "Read all the headers."
3365 (let ((gnus-summary-ignore-duplicates t)
3366 (mail-parse-charset gnus-newsgroup-charset)
3367 (dependencies gnus-newsgroup-dependencies)
3370 (set-buffer nntp-server-buffer)
3371 (let ((case-fold-search nil))
3372 (goto-char (point-min))
3375 (setq article (read (current-buffer))
3376 header (gnus-nov-parse-line article dependencies)))
3379 (set-buffer gnus-summary-buffer)
3380 (push header gnus-newsgroup-headers)
3381 (if (memq (setq article (mail-header-number header))
3382 gnus-newsgroup-unselected)
3384 (push article gnus-newsgroup-unreads)
3385 (setq gnus-newsgroup-unselected
3386 (delq article gnus-newsgroup-unselected)))
3387 (push article gnus-newsgroup-ancient)))
3388 (forward-line 1)))))))
3390 (defun gnus-summary-update-article-line (article header)
3391 "Update the line for ARTICLE using HEADERS."
3392 (let* ((id (mail-header-id header))
3393 (thread (gnus-id-to-thread id)))
3395 (error "Article in no thread"))
3396 ;; Update the thread.
3397 (setcar thread header)
3398 (gnus-summary-goto-subject article)
3399 (let* ((datal (gnus-data-find-list article))
3401 (length (when (cdr datal)
3402 (- (gnus-data-pos data)
3403 (gnus-data-pos (cadr datal)))))
3404 (buffer-read-only nil)
3405 (level (gnus-summary-thread-level)))
3407 (gnus-summary-insert-line
3408 header level nil (gnus-article-mark article)
3409 (memq article gnus-newsgroup-replied)
3410 (memq article gnus-newsgroup-expirable)
3411 ;; Only insert the Subject string when it's different
3412 ;; from the previous Subject string.
3417 (mail-header-subject
3420 (gnus-data-find-list
3422 (gnus-data-list t)))))
3423 ;; Error on the side of excessive subjects.
3425 (mail-header-subject header)))
3427 (mail-header-subject header))
3428 nil (cdr (assq article gnus-newsgroup-scored))
3429 (memq article gnus-newsgroup-processable))
3431 (gnus-data-update-list
3432 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3434 (defun gnus-summary-update-article (article &optional iheader)
3435 "Update ARTICLE in the summary buffer."
3436 (set-buffer gnus-summary-buffer)
3437 (let* ((header (gnus-summary-article-header article))
3438 (id (mail-header-id header))
3439 (data (gnus-data-find article))
3440 (thread (gnus-id-to-thread id))
3441 (references (mail-header-references header))
3445 (when (and references
3446 (not (equal "" references)))
3449 (buffer-read-only nil)
3455 (delq thread parent)))
3456 (if (gnus-summary-insert-subject id header)
3457 ;; Set the (possibly) new article number in the data structure.
3458 (gnus-data-set-number data (gnus-id-to-article id))
3462 (defun gnus-rebuild-thread (id &optional line)
3463 "Rebuild the thread containing ID.
3464 If LINE, insert the rebuilt thread starting on line LINE."
3465 (let ((buffer-read-only nil)
3466 old-pos current thread data)
3467 (if (not gnus-show-threads)
3468 (setq thread (list (car (gnus-id-to-thread id))))
3469 ;; Get the thread this article is part of.
3470 (setq thread (gnus-remove-thread id)))
3471 (setq old-pos (gnus-point-at-bol))
3472 (setq current (save-excursion
3473 (and (zerop (forward-line -1))
3474 (gnus-summary-article-number))))
3475 ;; If this is a gathered thread, we have to go some re-gathering.
3476 (when (stringp (car thread))
3477 (let ((subject (car thread))
3479 (setq thread (cdr thread))
3481 (unless (memq (setq thr (gnus-id-to-thread
3483 (mail-header-id (caar thread)))))
3486 (setq thread (cdr thread)))
3487 ;; We now have all (unique) roots.
3488 (if (= (length roots) 1)
3489 ;; All the loose roots are now one solid root.
3490 (setq thread (car roots))
3491 (setq thread (cons subject (gnus-sort-threads roots))))))
3493 ;; We then insert this thread into the summary buffer.
3495 (goto-char (point-min))
3496 (forward-line (1- line)))
3497 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3498 (if gnus-show-threads
3499 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3500 (gnus-summary-prepare-unthreaded thread))
3501 (setq data (nreverse gnus-newsgroup-data))
3502 (setq threads gnus-newsgroup-threads))
3503 ;; We splice the new data into the data structure.
3504 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3505 ;;!!! then we want to insert at the beginning of the buffer.
3506 ;;!!! That happens to be true with Gnus now, but that may
3507 ;;!!! change in the future. Perhaps.
3508 (gnus-data-enter-list
3509 (if line nil current) data (- (point) old-pos))
3510 (setq gnus-newsgroup-threads
3511 (nconc threads gnus-newsgroup-threads))
3512 (gnus-data-compute-positions))))
3514 (defun gnus-number-to-header (number)
3515 "Return the header for article NUMBER."
3516 (let ((headers gnus-newsgroup-headers))
3518 (not (= number (mail-header-number (car headers)))))
3523 (defun gnus-parent-headers (in-headers &optional generation)
3524 "Return the headers of the GENERATIONeth parent of HEADERS."
3526 (setq generation 1))
3528 (headers in-headers)
3531 (not (zerop generation))
3532 (setq references (mail-header-references headers)))
3533 (setq headers (if (and references
3534 (setq parent (gnus-parent-id references)))
3535 (car (gnus-id-to-thread parent))
3538 (and (not (eq headers in-headers))
3541 (defun gnus-id-to-thread (id)
3542 "Return the (sub-)thread where ID appears."
3543 (gnus-gethash id gnus-newsgroup-dependencies))
3545 (defun gnus-id-to-article (id)
3546 "Return the article number of ID."
3547 (let ((thread (gnus-id-to-thread id)))
3550 (mail-header-number (car thread)))))
3552 (defun gnus-id-to-header (id)
3553 "Return the article headers of ID."
3554 (car (gnus-id-to-thread id)))
3556 (defun gnus-article-displayed-root-p (article)
3557 "Say whether ARTICLE is a root(ish) article."
3558 (let ((level (gnus-summary-thread-level article))
3559 (refs (mail-header-references (gnus-summary-article-header article)))
3565 ((null (gnus-parent-id refs)) t)
3567 (null (setq particle (gnus-id-to-article
3568 (gnus-parent-id refs))))
3569 (null (gnus-summary-thread-level particle)))))))
3571 (defun gnus-root-id (id)
3572 "Return the id of the root of the thread where ID appears."
3574 (while (and id (setq prev (car (gnus-id-to-thread id))))
3576 id (gnus-parent-id (mail-header-references prev))))
3579 (defun gnus-articles-in-thread (thread)
3580 "Return the list of articles in THREAD."
3581 (cons (mail-header-number (car thread))
3582 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3584 (defun gnus-remove-thread (id &optional dont-remove)
3585 "Remove the thread that has ID in it."
3586 (let (headers thread last-id)
3587 ;; First go up in this thread until we find the root.
3588 (setq last-id (gnus-root-id id)
3589 headers (message-flatten-list (gnus-id-to-thread last-id)))
3590 ;; We have now found the real root of this thread. It might have
3591 ;; been gathered into some loose thread, so we have to search
3592 ;; through the threads to find the thread we wanted.
3593 (let ((threads gnus-newsgroup-threads)
3596 (setq sub (car threads))
3597 (if (stringp (car sub))
3598 ;; This is a gathered thread, so we look at the roots
3599 ;; below it to find whether this article is in this
3602 (setq sub (cdr sub))
3604 (when (member (caar sub) headers)
3605 (setq thread (car threads)
3608 (setq sub (cdr sub))))
3609 ;; It's an ordinary thread, so we check it.
3610 (when (eq (car sub) (car headers))
3613 (setq threads (cdr threads)))
3614 ;; If this article is in no thread, then it's a root.
3617 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3618 (setq thread (gnus-id-to-thread last-id)))
3621 thread ; We return this thread.
3623 (if (stringp (car thread))
3625 ;; If we use dummy roots, then we have to remove the
3626 ;; dummy root as well.
3627 (when (eq gnus-summary-make-false-root 'dummy)
3628 ;; We go to the dummy root by going to
3629 ;; the first sub-"thread", and then one line up.
3630 (gnus-summary-goto-article
3631 (mail-header-number (caadr thread)))
3634 (gnus-data-compute-positions))
3635 (setq thread (cdr thread))
3637 (gnus-remove-thread-1 (car thread))
3638 (setq thread (cdr thread))))
3639 (gnus-remove-thread-1 thread))))))))
3641 (defun gnus-remove-thread-1 (thread)
3642 "Remove the thread THREAD recursively."
3643 (let ((number (mail-header-number (pop thread)))
3645 (setq thread (reverse thread))
3647 (gnus-remove-thread-1 (pop thread)))
3648 (when (setq d (gnus-data-find number))
3649 (goto-char (gnus-data-pos d))
3650 (gnus-summary-show-thread)
3653 (- (gnus-point-at-bol)
3655 (1+ (gnus-point-at-eol))
3656 (gnus-delete-line)))))))
3658 (defun gnus-sort-threads (threads)
3660 (if (not gnus-thread-sort-functions)
3662 (gnus-message 8 "Sorting threads...")
3664 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3665 (gnus-message 8 "Sorting threads...done"))))
3667 (defun gnus-sort-articles (articles)
3669 (when gnus-article-sort-functions
3670 (gnus-message 7 "Sorting articles...")
3672 (setq gnus-newsgroup-headers
3673 (sort articles (gnus-make-sort-function
3674 gnus-article-sort-functions)))
3675 (gnus-message 7 "Sorting articles...done"))))
3677 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3678 (defmacro gnus-thread-header (thread)
3679 ;; Return header of first article in THREAD.
3680 ;; Note that THREAD must never, ever be anything else than a variable -
3681 ;; using some other form will lead to serious barfage.
3682 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3683 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3684 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3687 (defsubst gnus-article-sort-by-number (h1 h2)
3688 "Sort articles by article number."
3689 (< (mail-header-number h1)
3690 (mail-header-number h2)))
3692 (defun gnus-thread-sort-by-number (h1 h2)
3693 "Sort threads by root article number."
3694 (gnus-article-sort-by-number
3695 (gnus-thread-header h1) (gnus-thread-header h2)))
3697 (defsubst gnus-article-sort-by-lines (h1 h2)
3698 "Sort articles by article Lines header."
3699 (< (mail-header-lines h1)
3700 (mail-header-lines h2)))
3702 (defun gnus-thread-sort-by-lines (h1 h2)
3703 "Sort threads by root article Lines header."
3704 (gnus-article-sort-by-lines
3705 (gnus-thread-header h1) (gnus-thread-header h2)))
3707 (defsubst gnus-article-sort-by-chars (h1 h2)
3708 "Sort articles by octet length."
3709 (< (mail-header-chars h1)
3710 (mail-header-chars h2)))
3712 (defun gnus-thread-sort-by-chars (h1 h2)
3713 "Sort threads by root article octet length."
3714 (gnus-article-sort-by-chars
3715 (gnus-thread-header h1) (gnus-thread-header h2)))
3717 (defsubst gnus-article-sort-by-author (h1 h2)
3718 "Sort articles by root author."
3720 (let ((addr (car (mime-entity-read-field h1 'From))))
3721 (or (std11-full-name-string addr)
3722 (std11-address-string addr)
3724 (let ((addr (car (mime-entity-read-field h2 'From))))
3725 (or (std11-full-name-string addr)
3726 (std11-address-string addr)
3730 (defun gnus-thread-sort-by-author (h1 h2)
3731 "Sort threads by root author."
3732 (gnus-article-sort-by-author
3733 (gnus-thread-header h1) (gnus-thread-header h2)))
3735 (defsubst gnus-article-sort-by-subject (h1 h2)
3736 "Sort articles by root subject."
3738 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3739 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3741 (defun gnus-thread-sort-by-subject (h1 h2)
3742 "Sort threads by root subject."
3743 (gnus-article-sort-by-subject
3744 (gnus-thread-header h1) (gnus-thread-header h2)))
3746 (defsubst gnus-article-sort-by-date (h1 h2)
3747 "Sort articles by root article date."
3749 (gnus-date-get-time (mail-header-date h1))
3750 (gnus-date-get-time (mail-header-date h2))))
3752 (defun gnus-thread-sort-by-date (h1 h2)
3753 "Sort threads by root article date."
3754 (gnus-article-sort-by-date
3755 (gnus-thread-header h1) (gnus-thread-header h2)))
3757 (defsubst gnus-article-sort-by-score (h1 h2)
3758 "Sort articles by root article score.
3759 Unscored articles will be counted as having a score of zero."
3760 (> (or (cdr (assq (mail-header-number h1)
3761 gnus-newsgroup-scored))
3762 gnus-summary-default-score 0)
3763 (or (cdr (assq (mail-header-number h2)
3764 gnus-newsgroup-scored))
3765 gnus-summary-default-score 0)))
3767 (defun gnus-thread-sort-by-score (h1 h2)
3768 "Sort threads by root article score."
3769 (gnus-article-sort-by-score
3770 (gnus-thread-header h1) (gnus-thread-header h2)))
3772 (defun gnus-thread-sort-by-total-score (h1 h2)
3773 "Sort threads by the sum of all scores in the thread.
3774 Unscored articles will be counted as having a score of zero."
3775 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3777 (defun gnus-thread-total-score (thread)
3778 ;; This function find the total score of THREAD.
3779 (cond ((null thread)
3782 (if (stringp (car thread))
3783 (apply gnus-thread-score-function 0
3784 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3785 (gnus-thread-total-score-1 thread)))
3787 (gnus-thread-total-score-1 (list thread)))))
3789 (defun gnus-thread-total-score-1 (root)
3790 ;; This function find the total score of the thread below ROOT.
3791 (setq root (car root))
3792 (apply gnus-thread-score-function
3794 (mapcar 'gnus-thread-total-score
3795 (cdr (gnus-id-to-thread (mail-header-id root))))
3796 (when (> (mail-header-number root) 0)
3797 (list (or (cdr (assq (mail-header-number root)
3798 gnus-newsgroup-scored))
3799 gnus-summary-default-score 0))))
3800 (list gnus-summary-default-score)
3803 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3804 (defvar gnus-tmp-prev-subject nil)
3805 (defvar gnus-tmp-false-parent nil)
3806 (defvar gnus-tmp-root-expunged nil)
3807 (defvar gnus-tmp-dummy-line nil)
3809 (defvar gnus-tmp-header)
3810 (defun gnus-extra-header (type &optional header)
3811 "Return the extra header of TYPE."
3812 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3815 (defun gnus-summary-prepare-threads (threads)
3816 "Prepare summary buffer from THREADS and indentation LEVEL.
3817 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3818 or a straight list of headers."
3819 (gnus-message 7 "Generating summary...")
3821 (setq gnus-newsgroup-threads threads)
3824 (let ((gnus-tmp-level 0)
3825 (default-score (or gnus-summary-default-score 0))
3826 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3827 thread number subject stack state gnus-tmp-gathered beg-match
3828 new-roots gnus-tmp-new-adopts thread-end
3829 gnus-tmp-header gnus-tmp-unread
3830 gnus-tmp-replied gnus-tmp-subject-or-nil
3831 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3832 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3833 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3835 (setq gnus-tmp-prev-subject nil)
3837 (if (vectorp (car threads))
3838 ;; If this is a straight (sic) list of headers, then a
3839 ;; threaded summary display isn't required, so we just create
3840 ;; an unthreaded one.
3841 (gnus-summary-prepare-unthreaded threads)
3843 ;; Do the threaded display.
3845 (while (or threads stack gnus-tmp-new-adopts new-roots)
3847 (if (and (= gnus-tmp-level 0)
3850 (not gnus-tmp-false-parent)
3851 (or gnus-tmp-new-adopts new-roots))
3852 (if gnus-tmp-new-adopts
3853 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3854 thread (list (car gnus-tmp-new-adopts))
3855 gnus-tmp-header (caar thread)
3856 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3858 (setq thread (list (car new-roots))
3859 gnus-tmp-header (caar thread)
3860 new-roots (cdr new-roots))))
3863 ;; If there are some threads, we do them before the
3864 ;; threads on the stack.
3865 (setq thread threads
3866 gnus-tmp-header (caar thread))
3867 ;; There were no current threads, so we pop something off
3869 (setq state (car stack)
3870 gnus-tmp-level (car state)
3873 gnus-tmp-header (caar thread))))
3875 (setq gnus-tmp-false-parent nil)
3876 (setq gnus-tmp-root-expunged nil)
3877 (setq thread-end nil)
3879 (if (stringp gnus-tmp-header)
3880 ;; The header is a dummy root.
3882 ((eq gnus-summary-make-false-root 'adopt)
3883 ;; We let the first article adopt the rest.
3884 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3886 (setq gnus-tmp-gathered
3888 (lambda (h) (mail-header-number (car h)))
3891 (setq thread (cons (list (caar thread)
3894 (setq gnus-tmp-level -1
3895 gnus-tmp-false-parent t))
3896 ((eq gnus-summary-make-false-root 'empty)
3897 ;; We print adopted articles with empty subject fields.
3898 (setq gnus-tmp-gathered
3900 (lambda (h) (mail-header-number (car h)))
3903 (setq gnus-tmp-level -1))
3904 ((eq gnus-summary-make-false-root 'dummy)
3905 ;; We remember that we probably want to output a dummy
3907 (setq gnus-tmp-dummy-line gnus-tmp-header)
3908 (setq gnus-tmp-prev-subject gnus-tmp-header))
3910 ;; We do not make a root for the gathered
3911 ;; sub-threads at all.
3912 (setq gnus-tmp-level -1)))
3914 (setq number (mail-header-number gnus-tmp-header)
3915 subject (mail-header-subject gnus-tmp-header))
3918 ;; If the thread has changed subject, we might want to make
3919 ;; this subthread into a root.
3920 ((and (null gnus-thread-ignore-subject)
3921 (not (zerop gnus-tmp-level))
3922 gnus-tmp-prev-subject
3924 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3925 (setq new-roots (nconc new-roots (list (car thread)))
3927 gnus-tmp-header nil))
3928 ;; If the article lies outside the current limit,
3929 ;; then we do not display it.
3930 ((not (memq number gnus-newsgroup-limit))
3931 (setq gnus-tmp-gathered
3933 (lambda (h) (mail-header-number (car h)))
3936 (setq gnus-tmp-new-adopts (if (cdar thread)
3937 (append gnus-tmp-new-adopts
3939 gnus-tmp-new-adopts)
3941 gnus-tmp-header nil)
3942 (when (zerop gnus-tmp-level)
3943 (setq gnus-tmp-root-expunged t)))
3944 ;; Perhaps this article is to be marked as read?
3945 ((and gnus-summary-mark-below
3946 (< (or (cdr (assq number gnus-newsgroup-scored))
3948 gnus-summary-mark-below)
3949 ;; Don't touch sparse articles.
3950 (not (gnus-summary-article-sparse-p number))
3951 (not (gnus-summary-article-ancient-p number)))
3952 (setq gnus-newsgroup-unreads
3953 (delq number gnus-newsgroup-unreads))
3954 (if gnus-newsgroup-auto-expire
3955 (push number gnus-newsgroup-expirable)
3956 (push (cons number gnus-low-score-mark)
3957 gnus-newsgroup-reads))))
3959 (when gnus-tmp-header
3960 ;; We may have an old dummy line to output before this
3962 (when (and gnus-tmp-dummy-line
3965 (mail-header-subject gnus-tmp-header)))
3966 (gnus-summary-insert-dummy-line
3967 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3968 (setq gnus-tmp-dummy-line nil))
3970 ;; Compute the mark.
3971 (setq gnus-tmp-unread (gnus-article-mark number))
3973 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3974 gnus-tmp-header gnus-tmp-level)
3975 gnus-newsgroup-data)
3977 ;; Actually insert the line.
3979 gnus-tmp-subject-or-nil
3981 ((and gnus-thread-ignore-subject
3982 gnus-tmp-prev-subject
3983 (not (inline (gnus-subject-equal
3984 gnus-tmp-prev-subject subject))))
3986 ((zerop gnus-tmp-level)
3987 (if (and (eq gnus-summary-make-false-root 'empty)
3988 (memq number gnus-tmp-gathered)
3989 gnus-tmp-prev-subject
3990 (inline (gnus-subject-equal
3991 gnus-tmp-prev-subject subject)))
3992 gnus-summary-same-subject
3994 (t gnus-summary-same-subject)))
3995 (if (and (eq gnus-summary-make-false-root 'adopt)
3996 (= gnus-tmp-level 1)
3997 (memq number gnus-tmp-gathered))
3998 (setq gnus-tmp-opening-bracket ?\<
3999 gnus-tmp-closing-bracket ?\>)
4000 (setq gnus-tmp-opening-bracket ?\[
4001 gnus-tmp-closing-bracket ?\]))
4003 gnus-tmp-indentation
4004 (aref gnus-thread-indent-array gnus-tmp-level)
4005 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4006 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4007 gnus-summary-default-score 0)
4009 (if (or (null gnus-summary-default-score)
4010 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4011 gnus-summary-zcore-fuzz))
4013 (if (< gnus-tmp-score gnus-summary-default-score)
4014 gnus-score-below-mark gnus-score-over-mark))
4016 (cond ((memq number gnus-newsgroup-processable)
4018 ((memq number gnus-newsgroup-cached)
4020 ((memq number gnus-newsgroup-replied)
4022 ((memq number gnus-newsgroup-saved)
4024 (t gnus-unread-mark))
4025 gnus-tmp-from (mail-header-from gnus-tmp-header)
4028 ((string-match "<[^>]+> *$" gnus-tmp-from)
4029 (setq beg-match (match-beginning 0))
4030 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4031 (substring gnus-tmp-from (1+ (match-beginning 0))
4032 (1- (match-end 0))))
4033 (substring gnus-tmp-from 0 beg-match)))
4034 ((string-match "(.+)" gnus-tmp-from)
4035 (substring gnus-tmp-from
4036 (1+ (match-beginning 0)) (1- (match-end 0))))
4038 (when (string= gnus-tmp-name "")
4039 (setq gnus-tmp-name gnus-tmp-from))
4040 (unless (numberp gnus-tmp-lines)
4041 (setq gnus-tmp-lines 0))
4042 (gnus-put-text-property
4044 (progn (eval gnus-summary-line-format-spec) (point))
4045 'gnus-number number)
4048 (gnus-run-hooks 'gnus-summary-update-hook)
4051 (setq gnus-tmp-prev-subject subject)))
4053 (when (nth 1 thread)
4054 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4055 (incf gnus-tmp-level)
4056 (setq threads (if thread-end nil (cdar thread)))
4058 (setq gnus-tmp-level 0)))))
4059 (gnus-message 7 "Generating summary...done"))
4061 (defun gnus-summary-prepare-unthreaded (headers)
4062 "Generate an unthreaded summary buffer based on HEADERS."
4063 (let (header number mark)
4068 ;; We may have to root out some bad articles...
4069 (when (memq (setq number (mail-header-number
4070 (setq header (pop headers))))
4071 gnus-newsgroup-limit)
4072 ;; Mark article as read when it has a low score.
4073 (when (and gnus-summary-mark-below
4074 (< (or (cdr (assq number gnus-newsgroup-scored))
4075 gnus-summary-default-score 0)
4076 gnus-summary-mark-below)
4077 (not (gnus-summary-article-ancient-p number)))
4078 (setq gnus-newsgroup-unreads
4079 (delq number gnus-newsgroup-unreads))
4080 (if gnus-newsgroup-auto-expire
4081 (push number gnus-newsgroup-expirable)
4082 (push (cons number gnus-low-score-mark)
4083 gnus-newsgroup-reads)))
4085 (setq mark (gnus-article-mark number))
4086 (push (gnus-data-make number mark (1+ (point)) header 0)
4087 gnus-newsgroup-data)
4088 (gnus-summary-insert-line
4090 mark (memq number gnus-newsgroup-replied)
4091 (memq number gnus-newsgroup-expirable)
4092 (mail-header-subject header) nil
4093 (cdr (assq number gnus-newsgroup-scored))
4094 (memq number gnus-newsgroup-processable))))))
4096 (defun gnus-summary-remove-list-identifiers ()
4097 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4098 (let ((regexp (if (stringp gnus-list-identifiers)
4099 gnus-list-identifiers
4100 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4101 (dolist (header gnus-newsgroup-headers)
4102 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4103 (mail-header-subject header))
4104 (mail-header-set-subject
4105 header (concat (substring (mail-header-subject header)
4106 0 (match-beginning 2))
4107 (substring (mail-header-subject header)
4108 (match-end 2))))))))
4110 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4111 "Select newsgroup GROUP.
4112 If READ-ALL is non-nil, all articles in the group are selected.
4113 If SELECT-ARTICLES, only select those articles from GROUP."
4114 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4115 ;;!!! Dirty hack; should be removed.
4116 (gnus-summary-ignore-duplicates
4117 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4119 gnus-summary-ignore-duplicates))
4120 (info (nth 2 entry))
4121 articles fetched-articles cached)
4123 (unless (gnus-check-server
4124 (setq gnus-current-select-method
4125 (gnus-find-method-for-group group)))
4126 (error "Couldn't open server"))
4128 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4129 (gnus-activate-group group) ; Or we can activate it...
4130 (progn ; Or we bug out.
4131 (when (equal major-mode 'gnus-summary-mode)
4132 (kill-buffer (current-buffer)))
4133 (error "Couldn't request group %s: %s"
4134 group (gnus-status-message group))))
4136 (unless (gnus-request-group group t)
4137 (when (equal major-mode 'gnus-summary-mode)
4138 (kill-buffer (current-buffer)))
4139 (error "Couldn't request group %s: %s"
4140 group (gnus-status-message group)))
4142 (setq gnus-newsgroup-name group)
4143 (setq gnus-newsgroup-unselected nil)
4144 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4145 (gnus-summary-setup-default-charset)
4147 ;; Adjust and set lists of article marks.
4149 (gnus-adjust-marked-articles info))
4151 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4153 (if (gnus-virtual-group-p group)
4154 gnus-newsgroup-cached
4155 (gnus-cache-articles-in-group group)))
4157 (setq gnus-newsgroup-unreads
4158 (gnus-set-difference
4159 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4160 gnus-newsgroup-dormant))
4162 (setq gnus-newsgroup-processable nil)
4164 (gnus-update-read-articles group gnus-newsgroup-unreads)
4166 (if (setq articles select-articles)
4167 (setq gnus-newsgroup-unselected
4168 (gnus-sorted-intersection
4169 gnus-newsgroup-unreads
4170 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4171 (setq articles (gnus-articles-to-read group read-all)))
4175 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4177 ((eq articles 0) nil)
4179 ;; Init the dependencies hash table.
4180 (setq gnus-newsgroup-dependencies
4181 (gnus-make-hashtable (length articles)))
4182 (gnus-set-global-variables)
4183 ;; Retrieve the headers and read them in.
4184 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4185 (setq gnus-newsgroup-headers
4186 (gnus-retrieve-parsed-headers
4187 articles gnus-newsgroup-name
4188 ;; We might want to fetch old headers, but
4189 ;; not if there is only 1 article.
4190 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4191 (not (numberp gnus-fetch-old-headers)))
4192 (> (length articles) 1))
4193 gnus-fetch-old-headers)))
4194 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4196 ;; Suppress duplicates?
4197 (when gnus-suppress-duplicates
4198 (gnus-dup-suppress-articles))
4200 ;; Set the initial limit.
4201 (setq gnus-newsgroup-limit (copy-sequence articles))
4202 ;; Remove canceled articles from the list of unread articles.
4203 (setq gnus-newsgroup-unreads
4204 (gnus-set-sorted-intersection
4205 gnus-newsgroup-unreads
4206 (setq fetched-articles
4207 (mapcar (lambda (headers) (mail-header-number headers))
4208 gnus-newsgroup-headers))))
4209 ;; Removed marked articles that do not exist.
4210 (gnus-update-missing-marks
4211 (gnus-sorted-complement fetched-articles articles))
4213 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4215 (setq gnus-newsgroup-cached cached))
4217 ;; We might want to build some more threads first.
4218 (when (and gnus-fetch-old-headers
4219 (eq gnus-headers-retrieved-by 'nov))
4220 (if (eq gnus-fetch-old-headers 'invisible)
4221 (gnus-build-all-threads)
4222 (gnus-build-old-threads)))
4223 ;; Let the Gnus agent mark articles as read.
4225 (gnus-agent-get-undownloaded-list))
4226 ;; Remove list identifiers from subject
4227 (when gnus-list-identifiers
4228 (gnus-summary-remove-list-identifiers))
4229 ;; Check whether auto-expire is to be done in this group.
4230 (setq gnus-newsgroup-auto-expire
4231 (gnus-group-auto-expirable-p group))
4232 ;; Set up the article buffer now, if necessary.
4233 (unless gnus-single-article-buffer
4234 (gnus-article-setup-buffer))
4235 ;; First and last article in this newsgroup.
4236 (when gnus-newsgroup-headers
4237 (setq gnus-newsgroup-begin
4238 (mail-header-number (car gnus-newsgroup-headers))
4241 (gnus-last-element gnus-newsgroup-headers))))
4242 ;; GROUP is successfully selected.
4243 (or gnus-newsgroup-headers t)))))
4245 (defun gnus-articles-to-read (group &optional read-all)
4246 ;; Find out what articles the user wants to read.
4248 ;; Select all articles if `read-all' is non-nil, or if there
4249 ;; are no unread articles.
4251 (and (zerop (length gnus-newsgroup-marked))
4252 (zerop (length gnus-newsgroup-unreads)))
4253 (eq (gnus-group-find-parameter group 'display)
4256 (gnus-uncompress-range (gnus-active group))
4257 (gnus-cache-articles-in-group group))
4258 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4259 (copy-sequence gnus-newsgroup-unreads))
4261 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4262 (scored (length scored-list))
4263 (number (length articles))
4264 (marked (+ (length gnus-newsgroup-marked)
4265 (length gnus-newsgroup-dormant)))
4273 ((and (or (<= scored marked) (= scored number))
4274 (natnump gnus-large-newsgroup)
4275 (> number gnus-large-newsgroup))
4276 (let* ((cursor-in-echo-area nil)
4277 (input (read-from-minibuffer
4279 "How many articles from %s (max %d): "
4280 (gnus-limit-string gnus-newsgroup-name 35)
4282 (cons (number-to-string gnus-large-newsgroup)
4284 (if (string-match "^[ \t]*$" input)
4287 ((and (> scored marked) (< scored number)
4288 (> (- scored number) 20))
4291 (format "%s %s (%d scored, %d total): "
4292 "How many articles from"
4293 group scored number))))
4294 (if (string-match "^[ \t]*$" input)
4298 (setq select (if (stringp select) (string-to-number select) select))
4299 (if (or (null select) (zerop select))
4301 (if (and (not (zerop scored)) (<= (abs select) scored))
4303 (setq articles (sort scored-list '<))
4304 (setq number (length articles)))
4305 (setq articles (copy-sequence articles)))
4307 (when (< (abs select) number)
4309 ;; Select the N oldest articles.
4310 (setcdr (nthcdr (1- (abs select)) articles) nil)
4311 ;; Select the N most recent articles.
4312 (setq articles (nthcdr (- number select) articles))))
4313 (setq gnus-newsgroup-unselected
4314 (gnus-sorted-intersection
4315 gnus-newsgroup-unreads
4316 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4317 (when gnus-alter-articles-to-read-function
4318 (setq gnus-newsgroup-unreads
4320 (funcall gnus-alter-articles-to-read-function
4321 gnus-newsgroup-name gnus-newsgroup-unreads)
4325 (defun gnus-killed-articles (killed articles)
4328 (when (inline (gnus-member-of-range (car articles) killed))
4329 (push (car articles) out))
4330 (setq articles (cdr articles)))
4333 (defun gnus-uncompress-marks (marks)
4334 "Uncompress the mark ranges in MARKS."
4335 (let ((uncompressed '(score bookmark))
4338 (if (memq (caar marks) uncompressed)
4339 (push (car marks) out)
4340 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4341 (setq marks (cdr marks)))
4344 (defun gnus-adjust-marked-articles (info)
4345 "Set all article lists and remove all marks that are no longer valid."
4346 (let* ((marked-lists (gnus-info-marks info))
4347 (active (gnus-active (gnus-info-group info)))
4350 (types gnus-article-mark-lists)
4351 (uncompressed '(score bookmark killed))
4352 marks var articles article mark)
4355 (setq marks (pop marked-lists))
4356 (set (setq var (intern (format "gnus-newsgroup-%s"
4357 (car (rassq (setq mark (car marks))
4359 (if (memq (car marks) uncompressed) (cdr marks)
4360 (gnus-uncompress-range (cdr marks))))
4362 (setq articles (symbol-value var))
4364 ;; All articles have to be subsets of the active articles.
4366 ;; Adjust "simple" lists.
4367 ((memq mark '(tick dormant expire reply save))
4369 (when (or (< (setq article (pop articles)) min) (> article max))
4370 (set var (delq article (symbol-value var))))))
4372 ((memq mark uncompressed)
4373 (when (not (listp (cdr (symbol-value var))))
4374 (set var (list (symbol-value var))))
4375 (when (not (listp (cdr articles)))
4376 (setq articles (list articles)))
4378 (when (or (not (consp (setq article (pop articles))))
4379 (< (car article) min)
4380 (> (car article) max))
4381 (set var (delq article (symbol-value var))))))))))
4383 (defun gnus-update-missing-marks (missing)
4384 "Go through the list of MISSING articles and remove them from the mark lists."
4386 (let ((types gnus-article-mark-lists)
4388 ;; Go through all types.
4390 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4391 (when (symbol-value var)
4392 ;; This list has articles. So we delete all missing articles
4396 (set var (delq (pop m) (symbol-value var)))))))))
4398 (defun gnus-update-marks ()
4399 "Enter the various lists of marked articles into the newsgroup info list."
4400 (let ((types gnus-article-mark-lists)
4401 (info (gnus-get-info gnus-newsgroup-name))
4402 (uncompressed '(score bookmark killed))
4403 type list newmarked symbol delta-marks)
4405 ;; Add all marks lists to the list of marks lists.
4406 (while (setq type (pop types))
4407 (setq list (symbol-value
4409 (intern (format "gnus-newsgroup-%s"
4413 ;; Get rid of the entries of the articles that have the
4415 (when (and (eq (cdr type) 'score)
4419 (prev (cons nil list))
4422 (if (or (not (consp (car arts)))
4423 (= (cdar arts) gnus-summary-default-score))
4424 (setcdr prev (cdr arts))
4426 (setq arts (cdr arts)))
4427 (setq list (cdr all)))))
4429 (unless (memq (cdr type) uncompressed)
4430 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4432 (when (gnus-check-backend-function
4433 'request-set-mark gnus-newsgroup-name)
4434 ;; uncompressed:s are not proper flags (they are cons cells)
4435 ;; cache is a internal gnus flag
4436 (unless (memq (cdr type) (cons 'cache uncompressed))
4437 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4438 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4439 (add (gnus-remove-from-range
4440 (gnus-copy-sequence list) old)))
4442 (push (list add 'add (list (cdr type))) delta-marks))
4444 (push (list del 'del (list (cdr type))) delta-marks)))))
4447 (push (cons (cdr type) list) newmarked)))
4450 (unless (gnus-check-group gnus-newsgroup-name)
4451 (error "Can't open server for %s" gnus-newsgroup-name))
4452 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4454 ;; Enter these new marks into the info of the group.
4456 (setcar (nthcdr 3 info) newmarked)
4457 ;; Add the marks lists to the end of the info.
4459 (setcdr (nthcdr 2 info) (list newmarked))))
4461 ;; Cut off the end of the info if there's nothing else there.
4465 (when (nthcdr (decf i) info)
4466 (setcdr (nthcdr i info) nil)))))))
4468 (defun gnus-set-mode-line (where)
4469 "This function sets the mode line of the article or summary buffers.
4470 If WHERE is `summary', the summary mode line format will be used."
4471 ;; Is this mode line one we keep updated?
4472 (when (and (memq where gnus-updated-mode-lines)
4474 (intern (format "gnus-%s-mode-line-format-spec" where))))
4477 ;; We evaluate this in the summary buffer since these
4478 ;; variables are buffer-local to that buffer.
4479 (set-buffer gnus-summary-buffer)
4480 ;; We bind all these variables that are used in the `eval' form
4482 (let* ((mformat (symbol-value
4484 (format "gnus-%s-mode-line-format-spec" where))))
4485 (gnus-tmp-group-name gnus-newsgroup-name)
4486 (gnus-tmp-article-number (or gnus-current-article 0))
4487 (gnus-tmp-unread gnus-newsgroup-unreads)
4488 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4489 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4490 (gnus-tmp-unread-and-unselected
4491 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4492 (zerop gnus-tmp-unselected))
4494 ((zerop gnus-tmp-unselected)
4495 (format "{%d more}" gnus-tmp-unread-and-unticked))
4496 (t (format "{%d(+%d) more}"
4497 gnus-tmp-unread-and-unticked
4498 gnus-tmp-unselected))))
4500 (if (and gnus-current-headers
4501 (vectorp gnus-current-headers))
4502 (gnus-mode-string-quote
4503 (mail-header-subject gnus-current-headers))
4505 bufname-length max-len
4506 gnus-tmp-header);; passed as argument to any user-format-funcs
4507 (setq mode-string (eval mformat))
4508 (setq bufname-length (if (string-match "%b" mode-string)
4511 (if (eq where 'summary)
4513 (get-buffer gnus-article-buffer))))
4516 (setq max-len (max 4 (if gnus-mode-non-string-length
4518 gnus-mode-non-string-length
4520 (length mode-string))))
4521 ;; We might have to chop a bit of the string off...
4522 (when (> (length mode-string) max-len)
4524 (concat (gnus-truncate-string mode-string (- max-len 3))
4526 ;; Pad the mode string a bit.
4527 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4528 ;; Update the mode line.
4529 (setq mode-line-buffer-identification
4530 (gnus-mode-line-buffer-identification (list mode-string)))
4531 (set-buffer-modified-p t))))
4533 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4534 "Go through the HEADERS list and add all Xrefs to a hash table.
4535 The resulting hash table is returned, or nil if no Xrefs were found."
4536 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4537 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4538 (xref-hashtb (gnus-make-hashtable))
4539 start group entry number xrefs header)
4541 (setq header (pop headers))
4542 (when (and (setq xrefs (mail-header-xref header))
4543 (not (memq (setq number (mail-header-number header))
4546 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4547 (setq start (match-end 0))
4548 (setq group (if prefix
4549 (concat prefix (substring xrefs (match-beginning 1)
4551 (substring xrefs (match-beginning 1) (match-end 1))))
4553 (string-to-int (substring xrefs (match-beginning 2)
4555 (if (setq entry (gnus-gethash group xref-hashtb))
4556 (setcdr entry (cons number (cdr entry)))
4557 (gnus-sethash group (cons number nil) xref-hashtb)))))
4558 (and start xref-hashtb)))
4560 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4561 "Look through all the headers and mark the Xrefs as read."
4562 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4563 name entry info xref-hashtb idlist method nth4)
4565 (set-buffer gnus-group-buffer)
4566 (when (setq xref-hashtb
4567 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4570 (unless (string= from-newsgroup (setq name (symbol-name group)))
4571 (setq idlist (symbol-value group))
4572 ;; Dead groups are not updated.
4574 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4576 (when (stringp (setq nth4 (gnus-info-method info)))
4577 (setq nth4 (gnus-server-to-method nth4))))
4578 ;; Only do the xrefs if the group has the same
4579 ;; select method as the group we have just read.
4580 (or (gnus-methods-equal-p
4581 nth4 (gnus-find-method-for-group from-newsgroup))
4583 (equal nth4 (setq method (gnus-find-method-for-group
4585 (and (equal (car nth4) (car method))
4586 (equal (nth 1 nth4) (nth 1 method))))
4587 gnus-use-cross-reference
4588 (or (not (eq gnus-use-cross-reference t))
4590 ;; Only do cross-references on subscribed
4591 ;; groups, if that is what is wanted.
4592 (<= (gnus-info-level info) gnus-level-subscribed))
4593 (gnus-group-make-articles-read name idlist))))
4596 (defun gnus-compute-read-articles (group articles)
4597 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4598 (info (nth 2 entry))
4599 (active (gnus-active group))
4602 ;; First peel off all invalid article numbers.
4604 (let ((ids articles)
4606 (while (setq id (pop ids))
4607 (when (and first (> id (cdr active)))
4608 ;; We'll end up in this situation in one particular
4609 ;; obscure situation. If you re-scan a group and get
4610 ;; a new article that is cross-posted to a different
4611 ;; group that has not been re-scanned, you might get
4612 ;; crossposted article that has a higher number than
4613 ;; Gnus believes possible. So we re-activate this
4614 ;; group as well. This might mean doing the
4615 ;; crossposting thingy will *increase* the number
4616 ;; of articles in some groups. Tsk, tsk.
4617 (setq active (or (gnus-activate-group group) active)))
4618 (when (or (> id (cdr active))
4619 (< id (car active)))
4620 (setq articles (delq id articles))))))
4621 ;; If the read list is nil, we init it.
4623 (null (gnus-info-read info))
4625 (setq ninfo (cons 1 (1- (car active))))
4626 (setq ninfo (gnus-info-read info)))
4627 ;; Then we add the read articles to the range.
4629 ninfo (setq articles (sort articles '<))))))
4631 (defun gnus-group-make-articles-read (group articles)
4632 "Update the info of GROUP to say that ARTICLES are read."
4634 (entry (gnus-gethash group gnus-newsrc-hashtb))
4635 (info (nth 2 entry))
4636 (active (gnus-active group))
4639 (setq range (gnus-compute-read-articles group articles))
4641 (set-buffer gnus-group-buffer)
4644 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4645 (gnus-info-set-read ',info ',(gnus-info-read info))
4646 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4647 (gnus-group-update-group ,group t))))
4648 ;; Add the read articles to the range.
4649 (gnus-info-set-read info range)
4650 ;; Then we have to re-compute how many unread
4651 ;; articles there are in this group.
4655 (setq num (- (1+ (cdr active)) (car active))))
4656 ((not (listp (cdr range)))
4657 (setq num (- (cdr active) (- (1+ (cdr range))
4661 (if (numberp (car range))
4663 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4664 (setq range (cdr range)))
4665 (setq num (- (cdr active) num))))
4666 ;; Update the number of unread articles.
4668 ;; Update the group buffer.
4669 (gnus-group-update-group group t)))))
4671 (defvar gnus-newsgroup-none-id 0)
4673 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4674 (let ((cur nntp-server-buffer)
4677 (save-excursion (set-buffer gnus-summary-buffer)
4678 gnus-newsgroup-dependencies)))
4680 (mail-parse-charset gnus-newsgroup-charset)
4681 (mail-parse-ignored-charsets
4682 (save-excursion (condition-case nil
4683 (set-buffer gnus-summary-buffer)
4685 gnus-newsgroup-ignored-charsets)))
4687 (set-buffer nntp-server-buffer)
4688 ;; Translate all TAB characters into SPACE characters.
4689 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4690 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4691 (gnus-run-hooks 'gnus-parse-headers-hook)
4692 (let ((case-fold-search t)
4693 in-reply-to header p lines chars ctype)
4694 (goto-char (point-min))
4695 ;; Search to the beginning of the next header. Error messages
4696 ;; do not begin with 2 or 3.
4697 (while (re-search-forward "^[23][0-9]+ " nil t)
4700 ;; This implementation of this function, with nine
4701 ;; search-forwards instead of the one re-search-forward and
4702 ;; a case (which basically was the old function) is actually
4703 ;; about twice as fast, even though it looks messier. You
4704 ;; can't have everything, I guess. Speed and elegance
4705 ;; doesn't always go hand in hand.
4708 (make-full-mail-header
4714 (narrow-to-region (point)
4715 (or (and (search-forward "\n.\n" nil t)
4721 (if (search-forward "\nsubject: " nil t)
4722 (buffer-substring (match-end 0) (std11-field-end))
4727 (if (search-forward "\nfrom: " nil t)
4728 (buffer-substring (match-end 0) (std11-field-end))
4733 (if (search-forward "\ndate: " nil t)
4734 (buffer-substring (match-end 0) (std11-field-end))
4739 (setq id (if (re-search-forward
4740 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4741 ;; We do it this way to make sure the Message-ID
4742 ;; is (somewhat) syntactically valid.
4743 (buffer-substring (match-beginning 1)
4745 ;; If there was no message-id, we just fake one
4746 ;; to make subsequent routines simpler.
4747 (nnheader-generate-fake-message-id))))
4751 (if (search-forward "\nreferences: " nil t)
4755 (buffer-substring (match-end 0) (std11-field-end))
4760 (search-backward ">" end t)
4763 (search-backward "<" end t)
4765 ;; Get the references from the in-reply-to header if there
4766 ;; were no references and the in-reply-to header looks
4768 (if (and (search-forward "\nin-reply-to: " nil t)
4770 (buffer-substring (match-end 0)
4772 (string-match "<[^>]+>" in-reply-to))
4774 (setq ref (substring in-reply-to (match-beginning 0)
4776 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4777 (setq ref2 (substring in-reply-to (match-beginning 0)
4779 (when (> (length ref2) (length ref))
4786 (if (search-forward "\nchars: " nil t)
4787 (if (numberp (setq chars (ignore-errors (read cur))))
4793 (if (search-forward "\nlines: " nil t)
4794 (if (numberp (setq lines (ignore-errors (read cur))))
4800 (and (search-forward "\nxref: " nil t)
4801 (buffer-substring (match-end 0) (std11-field-end))))
4803 (when gnus-extra-headers
4804 (let ((extra gnus-extra-headers)
4808 (when (search-forward
4809 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4810 (push (cons (car extra)
4811 (buffer-substring (match-end 0)
4817 (if (and (search-forward "\ncontent-type: " nil t)
4819 (buffer-substring (match-end 0) (std11-field-end))))
4820 (mime-entity-set-content-type-internal
4821 header (mime-parse-Content-Type ctype)))
4822 (when (equal id ref)
4825 (when gnus-alter-header-function
4826 (funcall gnus-alter-header-function header)
4827 (setq id (mail-header-id header)
4828 ref (gnus-parent-id (mail-header-references header))))
4831 (gnus-dependencies-add-header
4832 header dependencies force-new))
4833 (push header headers))
4834 (goto-char (point-max))
4836 (nreverse headers)))))
4838 ;; Goes through the xover lines and returns a list of vectors
4839 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4840 force-new dependencies
4841 group also-fetch-heads)
4842 "Parse the news overview data in the server buffer, and return a
4843 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4844 ;; Get the Xref when the users reads the articles since most/some
4845 ;; NNTP servers do not include Xrefs when using XOVER.
4846 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4847 (let ((mail-parse-charset gnus-newsgroup-charset)
4848 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4849 (cur nntp-server-buffer)
4850 (dependencies (or dependencies gnus-newsgroup-dependencies))
4851 number headers header)
4853 (set-buffer nntp-server-buffer)
4854 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4855 ;; Allow the user to mangle the headers before parsing them.
4856 (gnus-run-hooks 'gnus-parse-headers-hook)
4857 (goto-char (point-min))
4860 (while (and sequence (not (eobp)))
4861 (setq number (read cur))
4862 (while (and sequence
4863 (< (car sequence) number))
4864 (setq sequence (cdr sequence)))
4866 (eq number (car sequence))
4868 (setq sequence (cdr sequence))
4869 (setq header (inline
4870 (gnus-nov-parse-line
4871 number dependencies force-new))))
4872 (push header headers))
4875 (gnus-error 4 "Strange nov line (%d)"
4876 (count-lines (point-min) (point)))))
4878 ;; A common bug in inn is that if you have posted an article and
4879 ;; then retrieves the active file, it will answer correctly --
4880 ;; the new article is included. However, a NOV entry for the
4881 ;; article may not have been generated yet, so this may fail.
4882 ;; We work around this problem by retrieving the last few
4883 ;; headers using HEAD.
4884 (if (or (not also-fetch-heads)
4886 ;; We (probably) got all the headers.
4888 (let ((gnus-nov-is-evil t))
4891 (gnus-retrieve-parsed-headers sequence group)
4894 (defun gnus-article-get-xrefs ()
4895 "Fill in the Xref value in `gnus-current-headers', if necessary.
4896 This is meant to be called in `gnus-article-internal-prepare-hook'."
4897 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4898 gnus-current-headers)))
4899 (or (not gnus-use-cross-reference)
4901 (and (mail-header-xref headers)
4902 (not (string= (mail-header-xref headers) "")))
4903 (let ((case-fold-search t)
4906 (nnheader-narrow-to-headers)
4907 (goto-char (point-min))
4908 (when (or (and (not (eobp))
4909 (eq (downcase (char-after)) ?x)
4910 (looking-at "Xref:"))
4911 (search-forward "\nXref:" nil t))
4912 (goto-char (1+ (match-end 0)))
4913 (setq xref (buffer-substring (point)
4914 (progn (end-of-line) (point))))
4915 (mail-header-set-xref headers xref)))))))
4917 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4918 "Find article ID and insert the summary line for that article.
4919 OLD-HEADER can either be a header or a line number to insert
4920 the subject line on."
4921 (let* ((line (and (numberp old-header) old-header))
4922 (old-header (and (vectorp old-header) old-header))
4923 (header (cond ((and old-header use-old-header)
4926 (gnus-number-to-header id))
4927 (gnus-number-to-header id))
4929 (gnus-read-header id))))
4930 (number (and (numberp id) id))
4933 ;; Rebuild the thread that this article is part of and go to the
4934 ;; article we have fetched.
4935 (when (and (not gnus-show-threads)
4938 (setq d (gnus-data-find (mail-header-number old-header))))
4939 (goto-char (gnus-data-pos d))
4942 (- (gnus-point-at-bol)
4944 (1+ (gnus-point-at-eol))
4945 (gnus-delete-line))))))
4947 (mail-header-set-number header (mail-header-number old-header)))
4948 (setq gnus-newsgroup-sparse
4949 (delq (setq number (mail-header-number header))
4950 gnus-newsgroup-sparse))
4951 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4952 (push number gnus-newsgroup-limit)
4953 (gnus-rebuild-thread (mail-header-id header) line)
4954 (gnus-summary-goto-subject number nil t))
4955 (when (and (numberp number)
4957 ;; We have to update the boundaries even if we can't fetch the
4958 ;; article if ID is a number -- so that the next `P' or `N'
4959 ;; command will fetch the previous (or next) article even
4960 ;; if the one we tried to fetch this time has been canceled.
4961 (when (> number gnus-newsgroup-end)
4962 (setq gnus-newsgroup-end number))
4963 (when (< number gnus-newsgroup-begin)
4964 (setq gnus-newsgroup-begin number))
4965 (setq gnus-newsgroup-unselected
4966 (delq number gnus-newsgroup-unselected)))
4967 ;; Report back a success?
4968 (and header (mail-header-number header))))
4970 ;;; Process/prefix in the summary buffer
4972 (defun gnus-summary-work-articles (n)
4973 "Return a list of articles to be worked upon.
4974 The prefix argument, the list of process marked articles, and the
4975 current article will be taken into consideration."
4977 (set-buffer gnus-summary-buffer)
4980 ;; A numerical prefix has been given.
4981 (setq n (prefix-numeric-value n))
4982 (let ((backward (< n 0))
4983 (n (abs (prefix-numeric-value n)))
4988 (push (setq article (gnus-summary-article-number))
4991 (gnus-summary-find-prev nil article)
4992 (gnus-summary-find-next nil article)))
4994 (nreverse articles)))
4995 ((and (gnus-region-active-p) (mark))
4996 (message "region active")
4997 ;; Work on the region between point and mark.
4998 (let ((max (max (point) (mark)))
5001 (goto-char (min (point) (mark)))
5004 (push (setq article (gnus-summary-article-number)) articles)
5005 (gnus-summary-find-next nil article)
5007 (nreverse articles))))
5008 (gnus-newsgroup-processable
5009 ;; There are process-marked articles present.
5010 ;; Save current state.
5011 (gnus-summary-save-process-mark)
5013 (reverse gnus-newsgroup-processable))
5015 ;; Just return the current article.
5016 (list (gnus-summary-article-number))))))
5018 (defmacro gnus-summary-iterate (arg &rest forms)
5019 "Iterate over the process/prefixed articles and do FORMS.
5020 ARG is the interactive prefix given to the command. FORMS will be
5021 executed with point over the summary line of the articles."
5022 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5023 `(let ((,articles (gnus-summary-work-articles ,arg)))
5025 (gnus-summary-goto-subject (car ,articles))
5029 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5030 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5032 (defun gnus-summary-save-process-mark ()
5033 "Push the current set of process marked articles on the stack."
5035 (push (copy-sequence gnus-newsgroup-processable)
5036 gnus-newsgroup-process-stack))
5038 (defun gnus-summary-kill-process-mark ()
5039 "Push the current set of process marked articles on the stack and unmark."
5041 (gnus-summary-save-process-mark)
5042 (gnus-summary-unmark-all-processable))
5044 (defun gnus-summary-yank-process-mark ()
5045 "Pop the last process mark state off the stack and restore it."
5047 (unless gnus-newsgroup-process-stack
5048 (error "Empty mark stack"))
5049 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5051 (defun gnus-summary-process-mark-set (set)
5052 "Make SET into the current process marked articles."
5053 (gnus-summary-unmark-all-processable)
5055 (gnus-summary-set-process-mark (pop set))))
5057 ;;; Searching and stuff
5059 (defun gnus-summary-search-group (&optional backward use-level)
5060 "Search for next unread newsgroup.
5061 If optional argument BACKWARD is non-nil, search backward instead."
5063 (set-buffer gnus-group-buffer)
5064 (when (gnus-group-search-forward
5065 backward nil (if use-level (gnus-group-group-level) nil))
5066 (gnus-group-group-name))))
5068 (defun gnus-summary-best-group (&optional exclude-group)
5069 "Find the name of the best unread group.
5070 If EXCLUDE-GROUP, do not go to this group."
5072 (set-buffer gnus-group-buffer)
5074 (gnus-group-best-unread-group exclude-group))))
5076 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5077 (if backward (gnus-summary-find-prev)
5078 (let* ((dummy (gnus-summary-article-intangible-p))
5079 (article (or article (gnus-summary-article-number)))
5080 (arts (gnus-data-find-list article))
5082 (when (and (not dummy)
5083 (or (not gnus-summary-check-current)
5085 (not (gnus-data-unread-p (car arts)))))
5086 (setq arts (cdr arts)))
5091 (when (or (and undownloaded
5092 (eq gnus-undownloaded-mark
5093 (gnus-data-mark (car arts))))
5094 (gnus-data-unread-p (car arts)))
5095 (setq result (car arts)
5097 (setq arts (cdr arts)))
5100 (goto-char (gnus-data-pos result))
5101 (gnus-data-number result)))))
5103 (defun gnus-summary-find-prev (&optional unread article)
5104 (let* ((eobp (eobp))
5105 (article (or article (gnus-summary-article-number)))
5106 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5108 (when (and (not eobp)
5109 (or (not gnus-summary-check-current)
5111 (not (gnus-data-unread-p (car arts)))))
5112 (setq arts (cdr arts)))
5117 (when (gnus-data-unread-p (car arts))
5118 (setq result (car arts)
5120 (setq arts (cdr arts)))
5123 (goto-char (gnus-data-pos result))
5124 (gnus-data-number result))))
5126 (defun gnus-summary-find-subject (subject &optional unread backward article)
5127 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5128 (article (or article (gnus-summary-article-number)))
5129 (articles (gnus-data-list backward))
5130 (arts (gnus-data-find-list article articles))
5132 (when (or (not gnus-summary-check-current)
5134 (not (gnus-data-unread-p (car arts))))
5135 (setq arts (cdr arts)))
5137 (and (or (not unread)
5138 (gnus-data-unread-p (car arts)))
5139 (vectorp (gnus-data-header (car arts)))
5141 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5142 (setq result (car arts)
5144 (setq arts (cdr arts)))
5146 (goto-char (gnus-data-pos result))
5147 (gnus-data-number result))))
5149 (defun gnus-summary-search-forward (&optional unread subject backward)
5150 "Search forward for an article.
5151 If UNREAD, look for unread articles. If SUBJECT, look for
5152 articles with that subject. If BACKWARD, search backward instead."
5153 (cond (subject (gnus-summary-find-subject subject unread backward))
5154 (backward (gnus-summary-find-prev unread))
5155 (t (gnus-summary-find-next unread))))
5157 (defun gnus-recenter (&optional n)
5158 "Center point in window and redisplay frame.
5159 Also do horizontal recentering."
5162 gnus-auto-center-summary
5163 (not (eq gnus-auto-center-summary 'vertical)))
5164 (gnus-horizontal-recenter))
5167 (defun gnus-summary-recenter ()
5168 "Center point in the summary window.
5169 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5170 displayed, no centering will be performed."
5171 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5172 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5174 (let* ((top (cond ((< (window-height) 4) 0)
5175 ((< (window-height) 7) 1)
5176 (t (if (numberp gnus-auto-center-summary)
5177 gnus-auto-center-summary
5179 (height (1- (window-height)))
5180 (bottom (save-excursion (goto-char (point-max))
5181 (forward-line (- height))
5183 (window (get-buffer-window (current-buffer))))
5184 ;; The user has to want it.
5185 (when gnus-auto-center-summary
5186 (when (get-buffer-window gnus-article-buffer)
5187 ;; Only do recentering when the article buffer is displayed,
5188 ;; Set the window start to either `bottom', which is the biggest
5189 ;; possible valid number, or the second line from the top,
5190 ;; whichever is the least.
5192 window (min bottom (save-excursion
5193 (forward-line (- top)) (point)))
5195 ;; Do horizontal recentering while we're at it.
5196 (when (and (get-buffer-window (current-buffer) t)
5197 (not (eq gnus-auto-center-summary 'vertical)))
5198 (let ((selected (selected-window)))
5199 (select-window (get-buffer-window (current-buffer) t))
5200 (gnus-summary-position-point)
5201 (gnus-horizontal-recenter)
5202 (select-window selected))))))
5204 (defun gnus-summary-jump-to-group (newsgroup)
5205 "Move point to NEWSGROUP in group mode buffer."
5206 ;; Keep update point of group mode buffer if visible.
5207 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5208 (save-window-excursion
5209 ;; Take care of tree window mode.
5210 (when (get-buffer-window gnus-group-buffer)
5211 (pop-to-buffer gnus-group-buffer))
5212 (gnus-group-jump-to-group newsgroup))
5214 ;; Take care of tree window mode.
5215 (if (get-buffer-window gnus-group-buffer)
5216 (pop-to-buffer gnus-group-buffer)
5217 (set-buffer gnus-group-buffer))
5218 (gnus-group-jump-to-group newsgroup))))
5220 ;; This function returns a list of article numbers based on the
5221 ;; difference between the ranges of read articles in this group and
5222 ;; the range of active articles.
5223 (defun gnus-list-of-unread-articles (group)
5224 (let* ((read (gnus-info-read (gnus-get-info group)))
5225 (active (or (gnus-active group) (gnus-activate-group group)))
5228 ;; If none are read, then all are unread.
5230 (setq first (car active))
5231 ;; If the range of read articles is a single range, then the
5232 ;; first unread article is the article after the last read
5233 ;; article. Sounds logical, doesn't it?
5234 (if (and (not (listp (cdr read)))
5235 (or (< (car read) (car active))
5236 (progn (setq read (list read))
5238 (setq first (max (car active) (1+ (cdr read))))
5239 ;; `read' is a list of ranges.
5240 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5243 (setq first (car active)))
5246 (while (< first nlast)
5248 (setq first (1+ first))))
5249 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5250 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5251 (setq read (cdr read)))))
5252 ;; And add the last unread articles.
5253 (while (<= first last)
5255 (setq first (1+ first)))
5256 ;; Return the list of unread articles.
5257 (delq 0 (nreverse unread))))
5259 (defun gnus-list-of-read-articles (group)
5260 "Return a list of unread, unticked and non-dormant articles."
5261 (let* ((info (gnus-get-info group))
5262 (marked (gnus-info-marks info))
5263 (active (gnus-active group)))
5265 (gnus-set-difference
5266 (gnus-sorted-complement
5267 (gnus-uncompress-range active)
5268 (gnus-list-of-unread-articles group))
5270 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5271 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5273 ;; Various summary commands
5275 (defun gnus-summary-select-article-buffer ()
5276 "Reconfigure windows to show article buffer."
5278 (if (not (gnus-buffer-live-p gnus-article-buffer))
5279 (error "There is no article buffer for this summary buffer")
5280 (gnus-configure-windows 'article)
5281 (select-window (get-buffer-window gnus-article-buffer))))
5283 (defun gnus-summary-universal-argument (arg)
5284 "Perform any operation on all articles that are process/prefixed."
5286 (let ((articles (gnus-summary-work-articles arg))
5293 (substitute-command-keys
5294 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5296 (gnus-error 1 "Undefined key")
5299 (gnus-summary-goto-subject (setq article (pop articles)))
5300 (let (gnus-newsgroup-processable)
5301 (command-execute func))
5302 (gnus-summary-remove-process-mark article)))))
5303 (gnus-summary-position-point))
5305 (defun gnus-summary-toggle-truncation (&optional arg)
5306 "Toggle truncation of summary lines.
5307 With arg, turn line truncation on iff arg is positive."
5309 (setq truncate-lines
5310 (if (null arg) (not truncate-lines)
5311 (> (prefix-numeric-value arg) 0)))
5314 (defun gnus-summary-reselect-current-group (&optional all rescan)
5315 "Exit and then reselect the current newsgroup.
5316 The prefix argument ALL means to select all articles."
5318 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5319 (error "Ephemeral groups can't be reselected"))
5320 (let ((current-subject (gnus-summary-article-number))
5321 (group gnus-newsgroup-name))
5322 (setq gnus-newsgroup-begin nil)
5324 ;; We have to adjust the point of group mode buffer because
5325 ;; point was moved to the next unread newsgroup by exiting.
5326 (gnus-summary-jump-to-group group)
5329 (save-window-excursion
5330 ;; Don't show group contents.
5331 (set-window-start (selected-window) (point-max))
5332 (gnus-group-get-new-news-this-group 1))))
5333 (gnus-group-read-group all t)
5334 (gnus-summary-goto-subject current-subject nil t)))
5336 (defun gnus-summary-rescan-group (&optional all)
5337 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5339 (gnus-summary-reselect-current-group all t))
5341 (defun gnus-summary-update-info (&optional non-destructive)
5343 (let ((group gnus-newsgroup-name))
5345 (when gnus-newsgroup-kill-headers
5346 (setq gnus-newsgroup-killed
5347 (gnus-compress-sequence
5349 (gnus-set-sorted-intersection
5350 (gnus-uncompress-range gnus-newsgroup-killed)
5351 (setq gnus-newsgroup-unselected
5352 (sort gnus-newsgroup-unselected '<)))
5353 (setq gnus-newsgroup-unreads
5354 (sort gnus-newsgroup-unreads '<)))
5356 (unless (listp (cdr gnus-newsgroup-killed))
5357 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5358 (let ((headers gnus-newsgroup-headers))
5359 ;; Set the new ranges of read articles.
5361 (set-buffer gnus-group-buffer)
5362 (gnus-undo-force-boundary))
5363 (gnus-update-read-articles
5364 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5365 ;; Set the current article marks.
5366 (let ((gnus-newsgroup-scored
5367 (if (and (not gnus-save-score)
5368 (not non-destructive))
5370 gnus-newsgroup-scored)))
5372 (gnus-update-marks)))
5373 ;; Do the cross-ref thing.
5374 (when gnus-use-cross-reference
5375 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5376 ;; Do not switch windows but change the buffer to work.
5377 (set-buffer gnus-group-buffer)
5378 (unless (gnus-ephemeral-group-p group)
5379 (gnus-group-update-group group)))))))
5381 (defun gnus-summary-save-newsrc (&optional force)
5382 "Save the current number of read/marked articles in the dribble buffer.
5383 The dribble buffer will then be saved.
5384 If FORCE (the prefix), also save the .newsrc file(s)."
5386 (gnus-summary-update-info t)
5388 (gnus-save-newsrc-file)
5389 (gnus-dribble-save)))
5391 (defun gnus-summary-exit (&optional temporary)
5392 "Exit reading current newsgroup, and then return to group selection mode.
5393 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5395 (gnus-set-global-variables)
5396 (gnus-kill-save-kill-buffer)
5397 (gnus-async-halt-prefetch)
5398 (let* ((group gnus-newsgroup-name)
5399 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5402 (buf (current-buffer)))
5404 ;; Do adaptive scoring, and possibly save score files.
5405 (when gnus-newsgroup-adaptive
5406 (gnus-score-adaptive))
5407 (when gnus-use-scoring
5409 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5410 ;; If we have several article buffers, we kill them at exit.
5411 (unless gnus-single-article-buffer
5412 (gnus-kill-buffer gnus-original-article-buffer)
5413 (setq gnus-article-current nil))
5414 (when gnus-use-cache
5415 (gnus-cache-possibly-remove-articles)
5416 (gnus-cache-save-buffers))
5417 (gnus-async-prefetch-remove-group group)
5418 (when gnus-suppress-duplicates
5419 (gnus-dup-enter-articles))
5420 (when gnus-use-trees
5421 (gnus-tree-close group))
5422 (when gnus-use-cache
5423 (gnus-cache-write-active))
5424 ;; Remove entries for this group.
5425 (nnmail-purge-split-history (gnus-group-real-name group))
5426 ;; Make all changes in this group permanent.
5428 (gnus-run-hooks 'gnus-exit-group-hook)
5429 (gnus-summary-update-info))
5430 (gnus-close-group group)
5431 ;; Make sure where we were, and go to next newsgroup.
5432 (set-buffer gnus-group-buffer)
5434 (gnus-group-jump-to-group group))
5435 (gnus-run-hooks 'gnus-summary-exit-hook)
5436 (unless (or quit-config
5437 ;; If this group has disappeared from the summary
5438 ;; buffer, don't skip forwards.
5439 (not (string= group (gnus-group-group-name))))
5440 (gnus-group-next-unread-group 1))
5441 (setq group-point (point))
5444 ;; If we have several article buffers, we kill them at exit.
5445 (unless gnus-single-article-buffer
5446 (gnus-kill-buffer gnus-article-buffer)
5447 (gnus-kill-buffer gnus-original-article-buffer)
5448 (setq gnus-article-current nil))
5450 (if (not gnus-kill-summary-on-exit)
5451 (gnus-deaden-summary)
5452 ;; We set all buffer-local variables to nil. It is unclear why
5453 ;; this is needed, but if we don't, buffer-local variables are
5454 ;; not garbage-collected, it seems. This would the lead to en
5455 ;; ever-growing Emacs.
5456 (gnus-summary-clear-local-variables)
5457 (when (get-buffer gnus-article-buffer)
5458 (bury-buffer gnus-article-buffer))
5459 ;; We clear the global counterparts of the buffer-local
5460 ;; variables as well, just to be on the safe side.
5461 (set-buffer gnus-group-buffer)
5462 (gnus-summary-clear-local-variables)
5463 ;; Return to group mode buffer.
5464 (when (eq mode 'gnus-summary-mode)
5465 (gnus-kill-buffer buf)))
5466 (setq gnus-current-select-method gnus-select-method)
5467 (pop-to-buffer gnus-group-buffer)
5468 (if (not quit-config)
5470 (goto-char group-point)
5471 (gnus-configure-windows 'group 'force)
5472 (unless (pos-visible-in-window-p)
5473 (forward-line (/ (static-if (featurep 'xemacs)
5474 (window-displayed-height)
5475 (1- (window-height)))
5477 (set-window-start (selected-window) (point))
5478 (goto-char group-point)))
5479 (gnus-handle-ephemeral-exit quit-config))
5480 ;; Clear the current group name.
5482 (setq gnus-newsgroup-name nil)))))
5484 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5485 (defun gnus-summary-exit-no-update (&optional no-questions)
5486 "Quit reading current newsgroup without updating read article info."
5488 (let* ((group gnus-newsgroup-name)
5489 (quit-config (gnus-group-quit-config group)))
5490 (when (or no-questions
5492 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5493 (gnus-async-halt-prefetch)
5495 (delq 'gnus-summary-expire-articles
5496 (copy-sequence gnus-summary-prepare-exit-hook)))
5497 ;; If we have several article buffers, we kill them at exit.
5498 (unless gnus-single-article-buffer
5499 (gnus-kill-buffer gnus-article-buffer)
5500 (gnus-kill-buffer gnus-original-article-buffer)
5501 (setq gnus-article-current nil))
5502 (if (not gnus-kill-summary-on-exit)
5503 (gnus-deaden-summary)
5504 (gnus-close-group group)
5505 (gnus-summary-clear-local-variables)
5506 (set-buffer gnus-group-buffer)
5507 (gnus-summary-clear-local-variables)
5508 (when (get-buffer gnus-summary-buffer)
5509 (kill-buffer gnus-summary-buffer)))
5510 (unless gnus-single-article-buffer
5511 (setq gnus-article-current nil))
5512 (when gnus-use-trees
5513 (gnus-tree-close group))
5514 (gnus-async-prefetch-remove-group group)
5515 (when (get-buffer gnus-article-buffer)
5516 (bury-buffer gnus-article-buffer))
5517 ;; Return to the group buffer.
5518 (gnus-configure-windows 'group 'force)
5519 ;; Clear the current group name.
5520 (setq gnus-newsgroup-name nil)
5521 (when (equal (gnus-group-group-name) group)
5522 (gnus-group-next-unread-group 1))
5524 (gnus-handle-ephemeral-exit quit-config)))))
5526 (defun gnus-handle-ephemeral-exit (quit-config)
5527 "Handle movement when leaving an ephemeral group.
5528 The state which existed when entering the ephemeral is reset."
5529 (if (not (buffer-name (car quit-config)))
5530 (gnus-configure-windows 'group 'force)
5531 (set-buffer (car quit-config))
5532 (cond ((eq major-mode 'gnus-summary-mode)
5533 (gnus-set-global-variables))
5534 ((eq major-mode 'gnus-article-mode)
5536 ;; The `gnus-summary-buffer' variable may point
5537 ;; to the old summary buffer when using a single
5539 (unless (gnus-buffer-live-p gnus-summary-buffer)
5540 (set-buffer gnus-group-buffer))
5541 (set-buffer gnus-summary-buffer)
5542 (gnus-set-global-variables))))
5543 (if (or (eq (cdr quit-config) 'article)
5544 (eq (cdr quit-config) 'pick))
5546 ;; The current article may be from the ephemeral group
5547 ;; thus it is best that we reload this article
5548 (gnus-summary-show-article)
5549 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5550 (gnus-configure-windows 'pick 'force)
5551 (gnus-configure-windows (cdr quit-config) 'force)))
5552 (gnus-configure-windows (cdr quit-config) 'force))
5553 (when (eq major-mode 'gnus-summary-mode)
5554 (gnus-summary-next-subject 1 nil t)
5555 (gnus-summary-recenter)
5556 (gnus-summary-position-point))))
5558 (defun gnus-summary-preview-mime-message ()
5559 "MIME decode and play this message."
5561 (let ((gnus-break-pages nil)
5563 (gnus-summary-select-article gnus-show-all-headers t))
5564 (select-window (get-buffer-window gnus-article-buffer)))
5568 (defvar gnus-dead-summary-mode-map nil)
5570 (unless gnus-dead-summary-mode-map
5571 (setq gnus-dead-summary-mode-map (make-keymap))
5572 (suppress-keymap gnus-dead-summary-mode-map)
5573 (substitute-key-definition
5574 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5575 (let ((keys '("\C-d" "\r" "\177" [delete])))
5577 (define-key gnus-dead-summary-mode-map
5578 (pop keys) 'gnus-summary-wake-up-the-dead))))
5580 (defvar gnus-dead-summary-mode nil
5581 "Minor mode for Gnus summary buffers.")
5583 (defun gnus-dead-summary-mode (&optional arg)
5584 "Minor mode for Gnus summary buffers."
5586 (when (eq major-mode 'gnus-summary-mode)
5587 (make-local-variable 'gnus-dead-summary-mode)
5588 (setq gnus-dead-summary-mode
5589 (if (null arg) (not gnus-dead-summary-mode)
5590 (> (prefix-numeric-value arg) 0)))
5591 (when gnus-dead-summary-mode
5592 (gnus-add-minor-mode
5593 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5595 (defun gnus-deaden-summary ()
5596 "Make the current summary buffer into a dead summary buffer."
5597 ;; Kill any previous dead summary buffer.
5598 (when (and gnus-dead-summary
5599 (buffer-name gnus-dead-summary))
5601 (set-buffer gnus-dead-summary)
5602 (when gnus-dead-summary-mode
5603 (kill-buffer (current-buffer)))))
5604 ;; Make this the current dead summary.
5605 (setq gnus-dead-summary (current-buffer))
5606 (gnus-dead-summary-mode 1)
5607 (let ((name (buffer-name)))
5608 (when (string-match "Summary" name)
5610 (concat (substring name 0 (match-beginning 0)) "Dead "
5611 (substring name (match-beginning 0)))
5615 (defun gnus-kill-or-deaden-summary (buffer)
5616 "Kill or deaden the summary BUFFER."
5618 (when (and (buffer-name buffer)
5619 (not gnus-single-article-buffer))
5622 (gnus-kill-buffer gnus-article-buffer)
5623 (gnus-kill-buffer gnus-original-article-buffer)))
5624 (cond (gnus-kill-summary-on-exit
5625 (when (and gnus-use-trees
5626 (gnus-buffer-exists-p buffer))
5629 (gnus-tree-close gnus-newsgroup-name)))
5630 (gnus-kill-buffer buffer))
5631 ((gnus-buffer-exists-p buffer)
5634 (gnus-deaden-summary))))))
5636 (defun gnus-summary-wake-up-the-dead (&rest args)
5637 "Wake up the dead summary buffer."
5639 (gnus-dead-summary-mode -1)
5640 (let ((name (buffer-name)))
5641 (when (string-match "Dead " name)
5643 (concat (substring name 0 (match-beginning 0))
5644 (substring name (match-end 0)))
5646 (gnus-message 3 "This dead summary is now alive again"))
5648 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5649 (defun gnus-summary-fetch-faq (&optional faq-dir)
5650 "Fetch the FAQ for the current group.
5651 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5655 (when current-prefix-arg
5657 "Faq dir: " (and (listp gnus-group-faq-directory)
5658 (mapcar (lambda (file) (list file))
5659 gnus-group-faq-directory))))))
5660 (let (gnus-faq-buffer)
5661 (when (setq gnus-faq-buffer
5662 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5663 (gnus-configure-windows 'summary-faq))))
5665 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5666 (defun gnus-summary-describe-group (&optional force)
5667 "Describe the current newsgroup."
5669 (gnus-group-describe-group force gnus-newsgroup-name))
5671 (defun gnus-summary-describe-briefly ()
5672 "Describe summary mode commands briefly."
5674 (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")))
5676 ;; Walking around group mode buffer from summary mode.
5678 (defun gnus-summary-next-group (&optional no-article target-group backward)
5679 "Exit current newsgroup and then select next unread newsgroup.
5680 If prefix argument NO-ARTICLE is non-nil, no article is selected
5681 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5682 previous group instead."
5684 ;; Stop pre-fetching.
5685 (gnus-async-halt-prefetch)
5686 (let ((current-group gnus-newsgroup-name)
5687 (current-buffer (current-buffer))
5689 ;; First we semi-exit this group to update Xrefs and all variables.
5690 ;; We can't do a real exit, because the window conf must remain
5691 ;; the same in case the user is prompted for info, and we don't
5692 ;; want the window conf to change before that...
5693 (gnus-summary-exit t)
5694 (while (not entered)
5695 ;; Then we find what group we are supposed to enter.
5696 (set-buffer gnus-group-buffer)
5697 (gnus-group-jump-to-group current-group)
5700 (if (eq gnus-keep-same-level 'best)
5701 (gnus-summary-best-group gnus-newsgroup-name)
5702 (gnus-summary-search-group backward gnus-keep-same-level))))
5703 (if (not target-group)
5704 ;; There are no further groups, so we return to the group
5707 (gnus-message 5 "Returning to the group buffer")
5709 (when (gnus-buffer-live-p current-buffer)
5710 (set-buffer current-buffer)
5711 (gnus-summary-exit))
5712 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5713 ;; We try to enter the target group.
5714 (gnus-group-jump-to-group target-group)
5715 (let ((unreads (gnus-group-group-unread)))
5716 (if (and (or (eq t unreads)
5717 (and unreads (not (zerop unreads))))
5718 (gnus-summary-read-group
5719 target-group nil no-article
5720 (and (buffer-name current-buffer) current-buffer)
5723 (setq current-group target-group
5724 target-group nil)))))))
5726 (defun gnus-summary-prev-group (&optional no-article)
5727 "Exit current newsgroup and then select previous unread newsgroup.
5728 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5730 (gnus-summary-next-group no-article nil t))
5732 ;; Walking around summary lines.
5734 (defun gnus-summary-first-subject (&optional unread undownloaded)
5735 "Go to the first unread subject.
5736 If UNREAD is non-nil, go to the first unread article.
5737 Returns the article selected or nil if there are no unread articles."
5742 ((null gnus-newsgroup-data)
5743 (gnus-message 3 "No articles in the group")
5745 ;; Pick the first article.
5747 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5748 (gnus-data-number (car gnus-newsgroup-data)))
5749 ;; No unread articles.
5750 ((null gnus-newsgroup-unreads)
5751 (gnus-message 3 "No more unread articles")
5753 ;; Find the first unread article.
5755 (let ((data gnus-newsgroup-data))
5757 (and (not (and undownloaded
5758 (eq gnus-undownloaded-mark
5759 (gnus-data-mark (car data)))))
5760 (not (gnus-data-unread-p (car data)))))
5761 (setq data (cdr data)))
5763 (goto-char (gnus-data-pos (car data)))
5764 (gnus-data-number (car data))))))
5765 (gnus-summary-position-point)))
5767 (defun gnus-summary-next-subject (n &optional unread dont-display)
5768 "Go to next N'th summary line.
5769 If N is negative, go to the previous N'th subject line.
5770 If UNREAD is non-nil, only unread articles are selected.
5771 The difference between N and the actual number of steps taken is
5774 (let ((backward (< n 0))
5778 (gnus-summary-find-prev unread)
5779 (gnus-summary-find-next unread)))
5780 (unless (zerop (setq n (1- n)))
5781 (gnus-summary-show-thread)))
5783 (gnus-message 7 "No more%s articles"
5784 (if unread " unread" "")))
5785 (unless dont-display
5786 (gnus-summary-recenter)
5787 (gnus-summary-position-point))
5790 (defun gnus-summary-next-unread-subject (n)
5791 "Go to next N'th unread summary line."
5793 (gnus-summary-next-subject n t))
5795 (defun gnus-summary-prev-subject (n &optional unread)
5796 "Go to previous N'th summary line.
5797 If optional argument UNREAD is non-nil, only unread article is selected."
5799 (gnus-summary-next-subject (- n) unread))
5801 (defun gnus-summary-prev-unread-subject (n)
5802 "Go to previous N'th unread summary line."
5804 (gnus-summary-next-subject (- n) t))
5806 (defun gnus-summary-goto-subject (article &optional force silent)
5807 "Go the subject line of ARTICLE.
5808 If FORCE, also allow jumping to articles not currently shown."
5809 (interactive "nArticle number: ")
5811 (data (gnus-data-find article)))
5812 ;; We read in the article if we have to.
5815 (gnus-summary-insert-subject
5817 (if (or (numberp force) (vectorp force)) force)
5819 (setq data (gnus-data-find article)))
5824 (gnus-message 3 "Can't find article %d" article))
5826 (goto-char (gnus-data-pos data))
5827 (gnus-summary-position-point)
5830 ;; Walking around summary lines with displaying articles.
5832 (defun gnus-summary-expand-window (&optional arg)
5833 "Make the summary buffer take up the entire Emacs frame.
5834 Given a prefix, will force an `article' buffer configuration."
5837 (gnus-configure-windows 'article 'force)
5838 (gnus-configure-windows 'summary 'force)))
5840 (defun gnus-summary-display-article (article &optional all-header)
5841 "Display ARTICLE in article buffer."
5842 (gnus-set-global-variables)
5846 (if gnus-summary-display-article-function
5847 (funcall gnus-summary-display-article-function article all-header)
5848 (gnus-article-prepare article all-header))
5849 (with-current-buffer gnus-article-buffer
5850 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5852 (gnus-run-hooks 'gnus-select-article-hook)
5853 (when (and gnus-current-article
5854 (not (zerop gnus-current-article)))
5855 (gnus-summary-goto-subject gnus-current-article))
5856 (gnus-summary-recenter)
5857 (when (and gnus-use-trees gnus-show-threads)
5858 (gnus-possibly-generate-tree article)
5859 (gnus-highlight-selected-tree article))
5860 ;; Successfully display article.
5861 (gnus-article-set-window-start
5862 (cdr (assq article gnus-newsgroup-bookmarks))))))
5864 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5865 "Select the current article.
5866 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5867 non-nil, the article will be re-fetched even if it already present in
5868 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5870 ;; Make sure we are in the summary buffer to work around bbdb bug.
5871 (unless (eq major-mode 'gnus-summary-mode)
5872 (set-buffer gnus-summary-buffer))
5873 (let ((article (or article (gnus-summary-article-number)))
5874 (all-headers (not (not all-headers))) ;Must be T or NIL.
5875 gnus-summary-display-article-function)
5877 (gnus-summary-article-pseudo-p article)
5878 (error "This is a pseudo-article"))
5880 (set-buffer gnus-summary-buffer)
5881 (if (or (and gnus-single-article-buffer
5882 (or (null gnus-current-article)
5883 (null gnus-article-current)
5884 (null (get-buffer gnus-article-buffer))
5885 (not (eq article (cdr gnus-article-current)))
5886 (not (equal (car gnus-article-current)
5887 gnus-newsgroup-name))))
5888 (and (not gnus-single-article-buffer)
5889 (or (null gnus-current-article)
5890 (not (eq gnus-current-article article))))
5892 ;; The requested article is different from the current article.
5894 (gnus-summary-display-article article all-headers)
5895 (when (or all-headers gnus-show-all-headers)
5896 (gnus-article-show-all-headers))
5897 (gnus-article-set-window-start
5898 (cdr (assq article gnus-newsgroup-bookmarks)))
5900 (when (or all-headers gnus-show-all-headers)
5901 (gnus-article-show-all-headers))
5904 (defun gnus-summary-set-current-mark (&optional current-mark)
5905 "Obsolete function."
5908 (defun gnus-summary-next-article (&optional unread subject backward push)
5909 "Select the next article.
5910 If UNREAD, only unread articles are selected.
5911 If SUBJECT, only articles with SUBJECT are selected.
5912 If BACKWARD, the previous article is selected instead of the next."
5915 ;; Is there such an article?
5916 ((and (gnus-summary-search-forward unread subject backward)
5917 (or (gnus-summary-display-article (gnus-summary-article-number))
5918 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5919 (gnus-summary-position-point))
5920 ;; If not, we try the first unread, if that is wanted.
5922 gnus-auto-select-same
5923 (gnus-summary-first-unread-article))
5924 (gnus-summary-position-point)
5925 (gnus-message 6 "Wrapped"))
5926 ;; Try to get next/previous article not displayed in this group.
5927 ((and gnus-auto-extend-newsgroup
5928 (not unread) (not subject))
5929 (gnus-summary-goto-article
5930 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5931 nil (count-lines (point-min) (point))))
5932 ;; Go to next/previous group.
5934 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5935 (gnus-summary-jump-to-group gnus-newsgroup-name))
5936 (let ((cmd last-command-char)
5939 (set-buffer gnus-group-buffer)
5942 (if (eq gnus-keep-same-level 'best)
5943 (gnus-summary-best-group gnus-newsgroup-name)
5944 (gnus-summary-search-group backward gnus-keep-same-level))))
5945 ;; For some reason, the group window gets selected. We change
5947 (select-window (get-buffer-window (current-buffer)))
5948 ;; Select next unread newsgroup automagically.
5950 ((or (not gnus-auto-select-next)
5952 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5953 ((or (eq gnus-auto-select-next 'quietly)
5954 (and (eq gnus-auto-select-next 'slightly-quietly)
5956 (and (eq gnus-auto-select-next 'almost-quietly)
5957 (gnus-summary-last-article-p)))
5959 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5961 (gnus-message 7 "No more%s articles (%s)..."
5962 (if unread " unread" "")
5963 (if group (concat "selecting " group)
5965 (gnus-summary-next-group nil group backward)))
5967 (when (gnus-key-press-event-p last-input-event)
5968 (gnus-summary-walk-group-buffer
5969 gnus-newsgroup-name cmd unread backward point))))))))
5971 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5972 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5973 (?\C-p (gnus-group-prev-unread-group 1))))
5974 (cursor-in-echo-area t)
5975 keve key group ended)
5977 (set-buffer gnus-group-buffer)
5980 (if (eq gnus-keep-same-level 'best)
5981 (gnus-summary-best-group gnus-newsgroup-name)
5982 (gnus-summary-search-group backward gnus-keep-same-level))))
5985 5 "No more%s articles%s" (if unread " unread" "")
5987 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5988 (format " (Type %s for %s [%s])"
5989 (single-key-description cmd) group
5990 (car (gnus-gethash group gnus-newsrc-hashtb)))
5991 (format " (Type %s to exit %s)"
5992 (single-key-description cmd)
5993 gnus-newsgroup-name)))
5994 ;; Confirm auto selection.
5995 (setq key (car (setq keve (gnus-read-event-char))))
5998 ((assq key keystrokes)
5999 (let ((obuf (current-buffer)))
6000 (switch-to-buffer gnus-group-buffer)
6002 (gnus-group-jump-to-group group))
6003 (eval (cadr (assq key keystrokes)))
6004 (setq group (gnus-group-group-name))
6005 (switch-to-buffer obuf))
6009 (gnus-ephemeral-group-p gnus-newsgroup-name))
6011 (gnus-summary-next-group nil group backward)))
6013 (push (cdr keve) unread-command-events))))))
6015 (defun gnus-summary-next-unread-article ()
6016 "Select unread article after current one."
6018 (gnus-summary-next-article
6019 (or (not (eq gnus-summary-goto-unread 'never))
6020 (gnus-summary-last-article-p (gnus-summary-article-number)))
6021 (and gnus-auto-select-same
6022 (gnus-summary-article-subject))))
6024 (defun gnus-summary-prev-article (&optional unread subject)
6025 "Select the article after the current one.
6026 If UNREAD is non-nil, only unread articles are selected."
6028 (gnus-summary-next-article unread subject t))
6030 (defun gnus-summary-prev-unread-article ()
6031 "Select unread article before current one."
6033 (gnus-summary-prev-article
6034 (or (not (eq gnus-summary-goto-unread 'never))
6035 (gnus-summary-first-article-p (gnus-summary-article-number)))
6036 (and gnus-auto-select-same
6037 (gnus-summary-article-subject))))
6039 (defun gnus-summary-next-page (&optional lines circular)
6040 "Show next page of the selected article.
6041 If at the end of the current article, select the next article.
6042 LINES says how many lines should be scrolled up.
6044 If CIRCULAR is non-nil, go to the start of the article instead of
6045 selecting the next article when reaching the end of the current
6048 (setq gnus-summary-buffer (current-buffer))
6049 (gnus-set-global-variables)
6050 (let ((article (gnus-summary-article-number))
6051 (article-window (get-buffer-window gnus-article-buffer t))
6053 ;; If the buffer is empty, we have no article.
6055 (error "No article to select"))
6056 (gnus-configure-windows 'article)
6057 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6058 (if (and (eq gnus-summary-goto-unread 'never)
6059 (not (gnus-summary-last-article-p article)))
6060 (gnus-summary-next-article)
6061 (gnus-summary-next-unread-article))
6062 (if (or (null gnus-current-article)
6063 (null gnus-article-current)
6064 (/= article (cdr gnus-article-current))
6065 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6066 ;; Selected subject is different from current article's.
6067 (gnus-summary-display-article article)
6068 (when article-window
6069 (gnus-eval-in-buffer-window gnus-article-buffer
6070 (setq endp (gnus-article-next-page lines)))
6073 (gnus-summary-beginning-of-article))
6075 (gnus-message 3 "End of message"))
6077 (if (and (eq gnus-summary-goto-unread 'never)
6078 (not (gnus-summary-last-article-p article)))
6079 (gnus-summary-next-article)
6080 (gnus-summary-next-unread-article))))))))
6081 (gnus-summary-recenter)
6082 (gnus-summary-position-point)))
6084 (defun gnus-summary-prev-page (&optional lines move)
6085 "Show previous page of selected article.
6086 Argument LINES specifies lines to be scrolled down.
6087 If MOVE, move to the previous unread article if point is at
6088 the beginning of the buffer."
6090 (let ((article (gnus-summary-article-number))
6091 (article-window (get-buffer-window gnus-article-buffer t))
6093 (gnus-configure-windows 'article)
6094 (if (or (null gnus-current-article)
6095 (null gnus-article-current)
6096 (/= article (cdr gnus-article-current))
6097 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6098 ;; Selected subject is different from current article's.
6099 (gnus-summary-display-article article)
6100 (gnus-summary-recenter)
6101 (when article-window
6102 (gnus-eval-in-buffer-window gnus-article-buffer
6103 (setq endp (gnus-article-prev-page lines)))
6104 (when (and move endp)
6106 (gnus-message 3 "Beginning of message"))
6108 (if (and (eq gnus-summary-goto-unread 'never)
6109 (not (gnus-summary-first-article-p article)))
6110 (gnus-summary-prev-article)
6111 (gnus-summary-prev-unread-article))))))))
6112 (gnus-summary-position-point))
6114 (defun gnus-summary-prev-page-or-article (&optional lines)
6115 "Show previous page of selected article.
6116 Argument LINES specifies lines to be scrolled down.
6117 If at the beginning of the article, go to the next article."
6119 (gnus-summary-prev-page lines t))
6121 (defun gnus-summary-scroll-up (lines)
6122 "Scroll up (or down) one line current article.
6123 Argument LINES specifies lines to be scrolled up (or down if negative)."
6125 (gnus-configure-windows 'article)
6126 (gnus-summary-show-thread)
6127 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6128 (gnus-eval-in-buffer-window gnus-article-buffer
6130 (when (gnus-article-next-page lines)
6131 (gnus-message 3 "End of message")))
6133 (gnus-article-prev-page (- lines))))))
6134 (gnus-summary-recenter)
6135 (gnus-summary-position-point))
6137 (defun gnus-summary-scroll-down (lines)
6138 "Scroll down (or up) one line current article.
6139 Argument LINES specifies lines to be scrolled down (or up if negative)."
6141 (gnus-summary-scroll-up (- lines)))
6143 (defun gnus-summary-next-same-subject ()
6144 "Select next article which has the same subject as current one."
6146 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6148 (defun gnus-summary-prev-same-subject ()
6149 "Select previous article which has the same subject as current one."
6151 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6153 (defun gnus-summary-next-unread-same-subject ()
6154 "Select next unread article which has the same subject as current one."
6156 (gnus-summary-next-article t (gnus-summary-article-subject)))
6158 (defun gnus-summary-prev-unread-same-subject ()
6159 "Select previous unread article which has the same subject as current one."
6161 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6163 (defun gnus-summary-first-unread-article ()
6164 "Select the first unread article.
6165 Return nil if there are no unread articles."
6168 (when (gnus-summary-first-subject t)
6169 (gnus-summary-show-thread)
6170 (gnus-summary-first-subject t)
6171 (gnus-summary-display-article (gnus-summary-article-number)))
6172 (gnus-summary-position-point)))
6174 (defun gnus-summary-first-unread-subject ()
6175 "Place the point on the subject line of the first unread article.
6176 Return nil if there are no unread articles."
6179 (when (gnus-summary-first-subject t)
6180 (gnus-summary-show-thread)
6181 (gnus-summary-first-subject t))
6182 (gnus-summary-position-point)))
6184 (defun gnus-summary-first-article ()
6185 "Select the first article.
6186 Return nil if there are no articles."
6189 (when (gnus-summary-first-subject)
6190 (gnus-summary-show-thread)
6191 (gnus-summary-first-subject)
6192 (gnus-summary-display-article (gnus-summary-article-number)))
6193 (gnus-summary-position-point)))
6195 (defun gnus-summary-best-unread-article ()
6196 "Select the unread article with the highest score."
6198 (let ((best -1000000)
6199 (data gnus-newsgroup-data)
6202 (and (gnus-data-unread-p (car data))
6204 (gnus-summary-article-score (gnus-data-number (car data))))
6207 article (gnus-data-number (car data))))
6208 (setq data (cdr data)))
6211 (gnus-summary-goto-article article)
6212 (error "No unread articles"))
6213 (gnus-summary-position-point))))
6215 (defun gnus-summary-last-subject ()
6216 "Go to the last displayed subject line in the group."
6217 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6219 (gnus-summary-goto-subject article))))
6221 (defun gnus-summary-goto-article (article &optional all-headers force)
6222 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6223 If ALL-HEADERS is non-nil, no header lines are hidden.
6224 If FORCE, go to the article even if it isn't displayed. If FORCE
6225 is a number, it is the line the article is to be displayed on."
6229 "Article number or Message-ID: "
6230 (mapcar (lambda (number) (list (int-to-string number)))
6231 gnus-newsgroup-limit))
6235 (if (and (stringp article)
6236 (string-match "@" article))
6237 (gnus-summary-refer-article article)
6238 (when (stringp article)
6239 (setq article (string-to-number article)))
6240 (if (gnus-summary-goto-subject article force)
6241 (gnus-summary-display-article article all-headers)
6242 (gnus-message 4 "Couldn't go to article %s" article) nil))
6243 (gnus-summary-position-point)))
6245 (defun gnus-summary-goto-last-article ()
6246 "Go to the previously read article."
6249 (when gnus-last-article
6250 (gnus-summary-goto-article gnus-last-article nil t))
6251 (gnus-summary-position-point)))
6253 (defun gnus-summary-pop-article (number)
6254 "Pop one article off the history and go to the previous.
6255 NUMBER articles will be popped off."
6258 (setq gnus-newsgroup-history
6259 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6261 (gnus-summary-goto-article (car to) nil t)
6262 (error "Article history empty")))
6263 (gnus-summary-position-point))
6265 ;; Summary commands and functions for limiting the summary buffer.
6267 (defun gnus-summary-limit-to-articles (n)
6268 "Limit the summary buffer to the next N articles.
6269 If not given a prefix, use the process marked articles instead."
6272 (let ((articles (gnus-summary-work-articles n)))
6273 (setq gnus-newsgroup-processable nil)
6274 (gnus-summary-limit articles))
6275 (gnus-summary-position-point)))
6277 (defun gnus-summary-pop-limit (&optional total)
6278 "Restore the previous limit.
6279 If given a prefix, remove all limits."
6282 (setq gnus-newsgroup-limits
6283 (list (mapcar (lambda (h) (mail-header-number h))
6284 gnus-newsgroup-headers))))
6285 (unless gnus-newsgroup-limits
6286 (error "No limit to pop"))
6288 (gnus-summary-limit nil 'pop)
6289 (gnus-summary-position-point)))
6291 (defun gnus-summary-limit-to-subject (subject &optional header)
6292 "Limit the summary buffer to articles that have subjects that match a regexp."
6293 (interactive "sLimit to subject (regexp): ")
6295 (setq header "subject"))
6296 (when (not (equal "" subject))
6298 (let ((articles (gnus-summary-find-matching
6299 (or header "subject") subject 'all)))
6301 (error "Found no matches for \"%s\"" subject))
6302 (gnus-summary-limit articles))
6303 (gnus-summary-position-point))))
6305 (defun gnus-summary-limit-to-author (from)
6306 "Limit the summary buffer to articles that have authors that match a regexp."
6307 (interactive "sLimit to author (regexp): ")
6308 (gnus-summary-limit-to-subject from "from"))
6310 (defun gnus-summary-limit-to-age (age &optional younger-p)
6311 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6312 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6313 articles that are younger than AGE days."
6315 (let ((younger current-prefix-arg)
6318 (while (not days-got)
6319 (setq days (if younger
6320 (read-string "Limit to articles within (in days): ")
6321 (read-string "Limit to articles old than (in days): ")))
6322 (when (> (length days) 0)
6323 (setq days (read days)))
6326 (message "Please enter a number.")
6328 (list days younger)))
6330 (let ((data gnus-newsgroup-data)
6331 (cutoff (days-to-time age))
6332 articles d date is-younger)
6333 (while (setq d (pop data))
6334 (when (and (vectorp (gnus-data-header d))
6335 (setq date (mail-header-date (gnus-data-header d))))
6336 (setq is-younger (time-less-p
6337 (time-since (condition-case ()
6344 (push (gnus-data-number d) articles))))
6345 (gnus-summary-limit (nreverse articles)))
6346 (gnus-summary-position-point)))
6348 (defun gnus-summary-limit-to-extra (header regexp)
6349 "Limit the summary buffer to articles that match an 'extra' header."
6353 (gnus-completing-read
6354 (symbol-name (car gnus-extra-headers))
6355 "Limit extra header:"
6357 (cons (symbol-name x) x))
6362 (read-string (format "Limit to header %s (regexp): " header)))))
6363 (when (not (equal "" regexp))
6365 (let ((articles (gnus-summary-find-matching
6366 (cons 'extra header) regexp 'all)))
6368 (error "Found no matches for \"%s\"" regexp))
6369 (gnus-summary-limit articles))
6370 (gnus-summary-position-point))))
6372 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6374 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6376 (defun gnus-summary-limit-to-unread (&optional all)
6377 "Limit the summary buffer to articles that are not marked as read.
6378 If ALL is non-nil, limit strictly to unread articles."
6381 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6382 (gnus-summary-limit-to-marks
6383 ;; Concat all the marks that say that an article is read and have
6385 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6386 gnus-killed-mark gnus-kill-file-mark
6387 gnus-low-score-mark gnus-expirable-mark
6388 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6389 gnus-duplicate-mark gnus-souped-mark)
6392 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6393 (make-obsolete 'gnus-summary-delete-marked-with
6394 'gnus-summary-limit-exlude-marks)
6396 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6397 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6398 If REVERSE, limit the summary buffer to articles that are marked
6399 with MARKS. MARKS can either be a string of marks or a list of marks.
6400 Returns how many articles were removed."
6401 (interactive "sMarks: ")
6402 (gnus-summary-limit-to-marks marks t))
6404 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6405 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6406 If REVERSE (the prefix), limit the summary buffer to articles that are
6407 not marked with MARKS. MARKS can either be a string of marks or a
6409 Returns how many articles were removed."
6410 (interactive "sMarks: \nP")
6412 (let ((data gnus-newsgroup-data)
6413 (marks (if (listp marks) marks
6414 (append marks nil))) ; Transform to list.
6417 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6418 (memq (gnus-data-mark (car data)) marks))
6419 (push (gnus-data-number (car data)) articles))
6420 (setq data (cdr data)))
6421 (gnus-summary-limit articles))
6422 (gnus-summary-position-point)))
6424 (defun gnus-summary-limit-to-score (&optional score)
6425 "Limit to articles with score at or above SCORE."
6427 (setq score (if score
6428 (prefix-numeric-value score)
6429 (or gnus-summary-default-score 0)))
6430 (let ((data gnus-newsgroup-data)
6433 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6435 (push (gnus-data-number (car data)) articles))
6436 (setq data (cdr data)))
6438 (gnus-summary-limit articles)
6439 (gnus-summary-position-point))))
6441 (defun gnus-summary-limit-include-thread (id)
6442 "Display all the hidden articles that in the current thread."
6443 (interactive (list (mail-header-id (gnus-summary-article-header))))
6444 (let ((articles (gnus-articles-in-thread
6445 (gnus-id-to-thread (gnus-root-id id)))))
6447 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6448 (gnus-summary-position-point))))
6450 (defun gnus-summary-limit-include-dormant ()
6451 "Display all the hidden articles that are marked as dormant.
6452 Note that this command only works on a subset of the articles currently
6453 fetched for this group."
6455 (unless gnus-newsgroup-dormant
6456 (error "There are no dormant articles in this group"))
6458 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6459 (gnus-summary-position-point)))
6461 (defun gnus-summary-limit-exclude-dormant ()
6462 "Hide all dormant articles."
6465 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6466 (gnus-summary-position-point)))
6468 (defun gnus-summary-limit-exclude-childless-dormant ()
6469 "Hide all dormant articles that have no children."
6471 (let ((data (gnus-data-list t))
6472 articles d children)
6473 ;; Find all articles that are either not dormant or have
6475 (while (setq d (pop data))
6476 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6478 (gnus-article-children (gnus-data-number d)))
6481 (when (memq (car children) articles)
6486 (push (gnus-data-number d) articles)))
6489 (gnus-summary-limit articles)
6490 (gnus-summary-position-point))))
6492 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6493 "Mark all unread excluded articles as read.
6494 If ALL, mark even excluded ticked and dormants as read."
6496 (let ((articles (gnus-sorted-complement
6498 (mapcar (lambda (h) (mail-header-number h))
6499 gnus-newsgroup-headers)
6501 (sort gnus-newsgroup-limit '<)))
6503 (setq gnus-newsgroup-unreads
6504 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6506 (setq gnus-newsgroup-dormant nil
6507 gnus-newsgroup-marked nil
6508 gnus-newsgroup-reads
6510 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6511 gnus-newsgroup-reads))
6512 (while (setq article (pop articles))
6513 (unless (or (memq article gnus-newsgroup-dormant)
6514 (memq article gnus-newsgroup-marked))
6515 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6517 (defun gnus-summary-limit (articles &optional pop)
6519 ;; We pop the previous limit off the stack and use that.
6520 (setq articles (car gnus-newsgroup-limits)
6521 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6522 ;; We use the new limit, so we push the old limit on the stack.
6523 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6525 (setq gnus-newsgroup-limit articles)
6526 (let ((total (length gnus-newsgroup-data))
6527 (data (gnus-data-find-list (gnus-summary-article-number)))
6528 (gnus-summary-mark-below nil) ; Inhibit this.
6530 ;; This will do all the work of generating the new summary buffer
6531 ;; according to the new limit.
6532 (gnus-summary-prepare)
6533 ;; Hide any threads, possibly.
6534 (and gnus-show-threads
6535 gnus-thread-hide-subtree
6536 (gnus-summary-hide-all-threads))
6537 ;; Try to return to the article you were at, or one in the
6540 ;; We try to find some article after the current one.
6542 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6545 (setq data (cdr data))))
6547 ;; If there is no data, that means that we were after the last
6548 ;; article. The same goes when we can't find any articles
6549 ;; after the current one.
6550 (goto-char (point-max))
6551 (gnus-summary-find-prev))
6552 (gnus-set-mode-line 'summary)
6553 ;; We return how many articles were removed from the summary
6554 ;; buffer as a result of the new limit.
6555 (- total (length gnus-newsgroup-data))))
6557 (defsubst gnus-invisible-cut-children (threads)
6560 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6565 (defsubst gnus-cut-thread (thread)
6566 "Go forwards in the thread until we find an article that we want to display."
6567 (when (or (eq gnus-fetch-old-headers 'some)
6568 (eq gnus-fetch-old-headers 'invisible)
6569 (numberp gnus-fetch-old-headers)
6570 (eq gnus-build-sparse-threads 'some)
6571 (eq gnus-build-sparse-threads 'more))
6572 ;; Deal with old-fetched headers and sparse threads.
6576 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6577 (gnus-summary-article-ancient-p
6578 (mail-header-number (car thread))))
6579 (if (or (<= (length (cdr thread)) 1)
6580 (eq gnus-fetch-old-headers 'invisible))
6581 (setq gnus-newsgroup-limit
6582 (delq (mail-header-number (car thread))
6583 gnus-newsgroup-limit)
6584 thread (cadr thread))
6585 (when (gnus-invisible-cut-children (cdr thread))
6586 (let ((th (cdr thread)))
6588 (if (memq (mail-header-number (caar th))
6589 gnus-newsgroup-limit)
6590 (setq thread (car th)
6592 (setq th (cdr th))))))))))
6595 (defun gnus-cut-threads (threads)
6596 "Cut off all uninteresting articles from the beginning of threads."
6597 (when (or (eq gnus-fetch-old-headers 'some)
6598 (eq gnus-fetch-old-headers 'invisible)
6599 (numberp gnus-fetch-old-headers)
6600 (eq gnus-build-sparse-threads 'some)
6601 (eq gnus-build-sparse-threads 'more))
6604 (setcar th (gnus-cut-thread (car th)))
6605 (setq th (cdr th)))))
6606 ;; Remove nixed out threads.
6609 (defun gnus-summary-initial-limit (&optional show-if-empty)
6610 "Figure out what the initial limit is supposed to be on group entry.
6611 This entails weeding out unwanted dormants, low-scored articles,
6612 fetch-old-headers verbiage, and so on."
6613 ;; Most groups have nothing to remove.
6614 (if (or gnus-inhibit-limiting
6615 (and (null gnus-newsgroup-dormant)
6616 (not (eq gnus-fetch-old-headers 'some))
6617 (not (numberp gnus-fetch-old-headers))
6618 (not (eq gnus-fetch-old-headers 'invisible))
6619 (null gnus-summary-expunge-below)
6620 (not (eq gnus-build-sparse-threads 'some))
6621 (not (eq gnus-build-sparse-threads 'more))
6622 (null gnus-thread-expunge-below)
6623 (not gnus-use-nocem)))
6625 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6626 (setq gnus-newsgroup-limit nil)
6629 (unless (car (symbol-value node))
6630 ;; These threads have no parents -- they are roots.
6631 (let ((nodes (cdr (symbol-value node)))
6634 (if (and gnus-thread-expunge-below
6635 (< (gnus-thread-total-score (car nodes))
6636 gnus-thread-expunge-below))
6637 (gnus-expunge-thread (pop nodes))
6638 (setq thread (pop nodes))
6639 (gnus-summary-limit-children thread))))))
6640 gnus-newsgroup-dependencies)
6641 ;; If this limitation resulted in an empty group, we might
6642 ;; pop the previous limit and use it instead.
6643 (when (and (not gnus-newsgroup-limit)
6645 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6646 gnus-newsgroup-limit))
6648 (defun gnus-summary-limit-children (thread)
6649 "Return 1 if this subthread is visible and 0 if it is not."
6650 ;; First we get the number of visible children to this thread. This
6651 ;; is done by recursing down the thread using this function, so this
6652 ;; will really go down to a leaf article first, before slowly
6653 ;; working its way up towards the root.
6657 (apply '+ (mapcar 'gnus-summary-limit-children
6660 (number (mail-header-number (car thread)))
6663 (not (memq number gnus-newsgroup-marked))
6665 ;; If this article is dormant and has absolutely no visible
6666 ;; children, then this article isn't visible.
6667 (and (memq number gnus-newsgroup-dormant)
6669 ;; If this is "fetch-old-headered" and there is no
6670 ;; visible children, then we don't want this article.
6671 (and (or (eq gnus-fetch-old-headers 'some)
6672 (numberp gnus-fetch-old-headers))
6673 (gnus-summary-article-ancient-p number)
6675 ;; If this is "fetch-old-headered" and `invisible', then
6676 ;; we don't want this article.
6677 (and (eq gnus-fetch-old-headers 'invisible)
6678 (gnus-summary-article-ancient-p number))
6679 ;; If this is a sparsely inserted article with no children,
6680 ;; we don't want it.
6681 (and (eq gnus-build-sparse-threads 'some)
6682 (gnus-summary-article-sparse-p number)
6684 ;; If we use expunging, and this article is really
6685 ;; low-scored, then we don't want this article.
6686 (when (and gnus-summary-expunge-below
6688 (or (cdr (assq number gnus-newsgroup-scored))
6689 gnus-summary-default-score))
6690 gnus-summary-expunge-below))
6691 ;; We increase the expunge-tally here, but that has
6692 ;; nothing to do with the limits, really.
6693 (incf gnus-newsgroup-expunged-tally)
6694 ;; We also mark as read here, if that's wanted.
6695 (when (and gnus-summary-mark-below
6696 (< score gnus-summary-mark-below))
6697 (setq gnus-newsgroup-unreads
6698 (delq number gnus-newsgroup-unreads))
6699 (if gnus-newsgroup-auto-expire
6700 (push number gnus-newsgroup-expirable)
6701 (push (cons number gnus-low-score-mark)
6702 gnus-newsgroup-reads)))
6704 ;; Check NoCeM things.
6705 (if (and gnus-use-nocem
6706 (gnus-nocem-unwanted-article-p
6707 (mail-header-id (car thread))))
6709 (setq gnus-newsgroup-unreads
6710 (delq number gnus-newsgroup-unreads))
6712 ;; Nope, invisible article.
6714 ;; Ok, this article is to be visible, so we add it to the limit
6716 (push number gnus-newsgroup-limit)
6719 (defun gnus-expunge-thread (thread)
6720 "Mark all articles in THREAD as read."
6721 (let* ((number (mail-header-number (car thread))))
6722 (incf gnus-newsgroup-expunged-tally)
6723 ;; We also mark as read here, if that's wanted.
6724 (setq gnus-newsgroup-unreads
6725 (delq number gnus-newsgroup-unreads))
6726 (if gnus-newsgroup-auto-expire
6727 (push number gnus-newsgroup-expirable)
6728 (push (cons number gnus-low-score-mark)
6729 gnus-newsgroup-reads)))
6730 ;; Go recursively through all subthreads.
6731 (mapcar 'gnus-expunge-thread (cdr thread)))
6733 ;; Summary article oriented commands
6735 (defun gnus-summary-refer-parent-article (n)
6736 "Refer parent article N times.
6737 If N is negative, go to ancestor -N instead.
6738 The difference between N and the number of articles fetched is returned."
6742 (when (not (natnump n))
6747 (setq header (gnus-summary-article-header))
6748 (if (and (eq (mail-header-number header)
6749 (cdr gnus-article-current))
6750 (equal gnus-newsgroup-name
6751 (car gnus-article-current)))
6752 ;; If we try to find the parent of the currently
6753 ;; displayed article, then we take a look at the actual
6754 ;; References header, since this is slightly more
6755 ;; reliable than the References field we got from the
6758 (set-buffer gnus-original-article-buffer)
6759 (nnheader-narrow-to-headers)
6760 (unless (setq ref (message-fetch-field "references"))
6761 (setq ref (message-fetch-field "in-reply-to")))
6764 ;; It's not the current article, so we take a bet on
6765 ;; the value we got from the server.
6766 (mail-header-references header)))
6768 (not (equal ref "")))
6769 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6770 (gnus-message 1 "Couldn't find parent"))
6771 (gnus-message 1 "No references in article %d"
6772 (gnus-summary-article-number))
6775 (gnus-summary-position-point)
6778 (defun gnus-summary-refer-references ()
6779 "Fetch all articles mentioned in the References header.
6780 Return the number of articles fetched."
6782 (let ((ref (mail-header-references (gnus-summary-article-header)))
6783 (current (gnus-summary-article-number))
6787 (error "No References in the current article")
6788 ;; For each Message-ID in the References header...
6789 (while (string-match "<[^>]*>" ref)
6791 ;; ... fetch that article.
6792 (gnus-summary-refer-article
6793 (prog1 (match-string 0 ref)
6794 (setq ref (substring ref (match-end 0))))))
6795 (gnus-summary-goto-subject current)
6796 (gnus-summary-position-point)
6799 (defun gnus-summary-refer-thread (&optional limit)
6800 "Fetch all articles in the current thread.
6801 If LIMIT (the numerical prefix), fetch that many old headers instead
6802 of what's specified by the `gnus-refer-thread-limit' variable."
6804 (let ((id (mail-header-id (gnus-summary-article-header)))
6805 (limit (if limit (prefix-numeric-value limit)
6806 gnus-refer-thread-limit)))
6807 ;; We want to fetch LIMIT *old* headers, but we also have to
6808 ;; re-fetch all the headers in the current buffer, because many of
6809 ;; them may be undisplayed. So we adjust LIMIT.
6810 (when (numberp limit)
6811 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6812 (unless (eq gnus-fetch-old-headers 'invisible)
6813 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6814 ;; Retrieve the headers and read them in.
6815 (if (eq (gnus-retrieve-headers
6816 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6818 (gnus-build-all-threads)
6819 (error "Can't fetch thread from backends that don't support NOV"))
6820 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6821 (gnus-summary-limit-include-thread id)))
6823 (defun gnus-summary-refer-article (message-id)
6824 "Fetch an article specified by MESSAGE-ID."
6825 (interactive "sMessage-ID: ")
6826 (when (and (stringp message-id)
6827 (not (zerop (length message-id))))
6828 ;; Construct the correct Message-ID if necessary.
6829 ;; Suggested by tale@pawl.rpi.edu.
6830 (unless (string-match "^<" message-id)
6831 (setq message-id (concat "<" message-id)))
6832 (unless (string-match ">$" message-id)
6833 (setq message-id (concat message-id ">")))
6834 (let* ((header (gnus-id-to-header message-id))
6836 (gnus-summary-article-sparse-p
6837 (mail-header-number header))
6838 (memq (mail-header-number header)
6839 gnus-newsgroup-limit)))
6842 ;; If the article is present in the buffer we just go to it.
6844 (or (not (gnus-summary-article-sparse-p
6845 (mail-header-number header)))
6848 (gnus-summary-goto-article
6849 (mail-header-number header) nil t)
6851 (gnus-summary-update-article (mail-header-number header)))))
6853 ;; We fetch the article.
6855 (dolist (gnus-override-method (gnus-refer-article-methods))
6856 (gnus-check-server gnus-override-method)
6857 ;; Fetch the header, and display the article.
6858 (when (setq number (gnus-summary-insert-subject message-id))
6859 (gnus-summary-select-article nil nil nil number)
6861 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6863 (defun gnus-refer-article-methods ()
6864 "Return a list of referrable methods."
6866 ;; No method, so we default to current and native.
6867 ((null gnus-refer-article-method)
6868 (list gnus-current-select-method gnus-select-method))
6870 ((eq 'current gnus-refer-article-method)
6871 (list gnus-current-select-method))
6872 ;; List of select methods.
6873 ((not (stringp (cadr gnus-refer-article-method)))
6875 (dolist (method gnus-refer-article-method)
6876 (push (if (eq 'current method)
6877 gnus-current-select-method
6881 ;; One single select method.
6883 (list gnus-refer-article-method))))
6885 (defun gnus-summary-edit-parameters ()
6886 "Edit the group parameters of the current group."
6888 (gnus-group-edit-group gnus-newsgroup-name 'params))
6890 (defun gnus-summary-customize-parameters ()
6891 "Customize the group parameters of the current group."
6893 (gnus-group-customize gnus-newsgroup-name))
6895 (defun gnus-summary-enter-digest-group (&optional force)
6896 "Enter an nndoc group based on the current article.
6897 If FORCE, force a digest interpretation. If not, try
6898 to guess what the document format is."
6900 (let ((conf gnus-current-window-configuration))
6902 (gnus-summary-select-article))
6903 (setq gnus-current-window-configuration conf)
6904 (let* ((name (format "%s-%d"
6905 (gnus-group-prefixed-name
6906 gnus-newsgroup-name (list 'nndoc ""))
6908 (set-buffer gnus-summary-buffer)
6909 gnus-current-article)))
6910 (ogroup gnus-newsgroup-name)
6911 (params (append (gnus-info-params (gnus-get-info ogroup))
6912 (list (cons 'to-group ogroup))
6913 (list (cons 'save-article-group ogroup))))
6914 (case-fold-search t)
6915 (buf (current-buffer))
6918 (set-buffer gnus-original-article-buffer)
6919 ;; Have the digest group inherit the main mail address of
6920 ;; the parent article.
6921 (when (setq to-address (or (message-fetch-field "reply-to")
6922 (message-fetch-field "from")))
6923 (setq params (append (list (cons 'to-address to-address)))))
6924 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6925 (insert-buffer-substring gnus-original-article-buffer)
6926 ;; Remove lines that may lead nndoc to misinterpret the
6929 (goto-char (point-min))
6930 (or (search-forward "\n\n" nil t) (point)))
6931 (goto-char (point-min))
6932 (delete-matching-lines "^Path:\\|^From ")
6935 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6936 (gnus-newsgroup-ephemeral-ignored-charsets
6937 gnus-newsgroup-ignored-charsets))
6938 (gnus-group-read-ephemeral-group
6939 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6941 ,(if force 'mbox 'guess))) t))
6942 ;; Make all postings to this group go to the parent group.
6943 (nconc (gnus-info-params (gnus-get-info name))
6945 ;; Couldn't select this doc group.
6946 (switch-to-buffer buf)
6947 (gnus-set-global-variables)
6948 (gnus-configure-windows 'summary)
6949 (gnus-message 3 "Article couldn't be entered?"))
6950 (kill-buffer dig)))))
6952 (defun gnus-summary-read-document (n)
6953 "Open a new group based on the current article(s).
6954 This will allow you to read digests and other similar
6955 documents as newsgroups.
6956 Obeys the standard process/prefix convention."
6958 (let* ((articles (gnus-summary-work-articles n))
6959 (ogroup gnus-newsgroup-name)
6960 (params (append (gnus-info-params (gnus-get-info ogroup))
6961 (list (cons 'to-group ogroup))))
6962 article group egroup groups vgroup)
6963 (while (setq article (pop articles))
6964 (setq group (format "%s-%d" gnus-newsgroup-name article))
6965 (gnus-summary-remove-process-mark article)
6966 (when (gnus-summary-display-article article)
6969 (insert-buffer-substring gnus-original-article-buffer)
6970 ;; Remove some headers that may lead nndoc to make
6972 (message-narrow-to-head)
6973 (goto-char (point-min))
6974 (delete-matching-lines "^\\(Path\\):\\|^From ")
6977 (gnus-group-read-ephemeral-group
6978 group `(nndoc ,group (nndoc-address ,(current-buffer))
6979 (nndoc-article-type guess))
6982 ;; Make all postings to this group go to the parent group.
6983 (nconc (gnus-info-params (gnus-get-info egroup))
6985 (push egroup groups))
6986 ;; Couldn't select this doc group.
6987 (gnus-error 3 "Article couldn't be entered"))))))
6988 ;; Now we have selected all the documents.
6991 (error "None of the articles could be interpreted as documents"))
6992 ((gnus-group-read-ephemeral-group
6993 (setq vgroup (format
6994 "nnvirtual:%s-%s" gnus-newsgroup-name
6995 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6996 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6998 (cons (current-buffer) 'summary)))
7000 (error "Couldn't select virtual nndoc group")))))
7002 (defun gnus-summary-isearch-article (&optional regexp-p)
7003 "Do incremental search forward on the current article.
7004 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7006 (let* ((gnus-inhibit-treatment t)
7007 (old (gnus-summary-select-article)))
7008 (gnus-configure-windows 'article)
7009 (gnus-eval-in-buffer-window gnus-article-buffer
7013 (gnus-article-show-all-headers))
7014 (goto-char (point-min))
7015 (isearch-forward regexp-p)))))
7017 (defun gnus-summary-search-article-forward (regexp &optional backward)
7018 "Search for an article containing REGEXP forward.
7019 If BACKWARD, search backward instead."
7022 (format "Search article %s (regexp%s): "
7023 (if current-prefix-arg "backward" "forward")
7024 (if gnus-last-search-regexp
7025 (concat ", default " gnus-last-search-regexp)
7027 current-prefix-arg))
7028 (if (string-equal regexp "")
7029 (setq regexp (or gnus-last-search-regexp ""))
7030 (setq gnus-last-search-regexp regexp))
7031 (if (gnus-summary-search-article regexp backward)
7032 (gnus-summary-show-thread)
7033 (error "Search failed: \"%s\"" regexp)))
7035 (defun gnus-summary-search-article-backward (regexp)
7036 "Search for an article containing REGEXP backward."
7039 (format "Search article backward (regexp%s): "
7040 (if gnus-last-search-regexp
7041 (concat ", default " gnus-last-search-regexp)
7043 (gnus-summary-search-article-forward regexp 'backward))
7046 (defmacro gnus-summary-search-article-position-point (regexp backward)
7047 "Dehighlight the last matched text and goto the beginning position."
7048 (` (if (and gnus-summary-search-article-matched-data
7049 (let ((text (caddr gnus-summary-search-article-matched-data))
7050 (inhibit-read-only t)
7053 (goto-char (car gnus-summary-search-article-matched-data))
7054 (cadr gnus-summary-search-article-matched-data))
7056 (string-match (, regexp) text)))
7057 (if (, backward) (beginning-of-line) (end-of-line))
7058 (goto-char (if (, backward) (point-max) (point-min))))))
7060 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7061 "Place point where X-Face image is displayed."
7062 (if (featurep 'xemacs)
7063 (` (let ((end (if (search-forward "\n\n" nil t)
7064 (goto-char (1- (point)))
7067 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7068 (unless (and (re-search-forward "^From:" end t)
7069 (setq extent (extent-at (point)))
7070 (extent-begin-glyph extent))
7071 (goto-char (, opoint)))))
7072 (` (let ((end (if (search-forward "\n\n" nil t)
7073 (goto-char (1- (point)))
7076 (or (text-property-any (or (search-backward "\n\n" nil t)
7078 end 'x-face-mule-bitmap-image t)
7081 (defmacro gnus-summary-search-article-highlight-matched-text
7082 (backward treated x-face)
7083 "Highlight matched text in the function `gnus-summary-search-article'."
7084 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7085 (end (set-marker (make-marker) (match-end 0)))
7086 (inhibit-read-only t)
7090 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7092 (lambda (item) (setq items (delq item items)))
7093 '(gnus-treat-buttonize
7094 gnus-treat-fill-article
7095 gnus-treat-fill-long-lines
7096 gnus-treat-emphasize
7097 gnus-treat-highlight-headers
7098 gnus-treat-highlight-citation
7099 gnus-treat-highlight-signature
7100 gnus-treat-overstrike
7101 gnus-treat-display-xface
7102 gnus-treat-buttonize-head
7103 gnus-treat-decode-article-as-default-mime-charset))
7104 (static-if (featurep 'xemacs)
7106 (cons '(x-face-mule-delete-x-face-field
7109 (gnus-treat-display-xface
7110 (when (, x-face) gnus-treat-display-xface)))
7111 (gnus-article-prepare-mime-display)))
7112 (goto-char (if (, backward) start end))
7114 (gnus-summary-search-article-highlight-goto-x-face (point)))
7115 (setq gnus-summary-search-article-matched-data
7116 (list start end (buffer-substring start end)))
7117 (unless (eq start end);; matched text has been deleted. :-<
7118 (put-text-property start end 'face
7119 (or (find-face 'isearch)
7120 'secondary-selection))))))
7123 (defun gnus-summary-search-article (regexp &optional backward)
7124 "Search for an article containing REGEXP.
7125 Optional argument BACKWARD means do search for backward.
7126 `gnus-select-article-hook' is not called during the search."
7127 ;; We have to require this here to make sure that the following
7128 ;; dynamic binding isn't shadowed by autoloading.
7129 (require 'gnus-async)
7131 (let ((gnus-select-article-hook nil) ;Disable hook.
7132 (gnus-article-display-hook nil)
7133 (gnus-article-prepare-hook nil)
7134 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7135 (gnus-use-article-prefetch nil)
7136 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7137 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7138 (sum (current-buffer))
7141 (gnus-save-hidden-threads
7142 (static-if (featurep 'xemacs)
7143 (let ((gnus-inhibit-treatment t))
7144 (setq treated (eq 'old (gnus-summary-select-article)))
7146 (not (and (gnus-buffer-live-p gnus-article-buffer)
7147 (window-live-p (get-buffer-window
7148 gnus-article-buffer t)))))
7149 (gnus-summary-select-article nil t)
7150 (setq treated nil)))
7151 (let ((gnus-inhibit-treatment t)
7152 (x-face-mule-delete-x-face-field 'never))
7153 (setq treated (eq 'old (gnus-summary-select-article)))
7156 (and (gnus-buffer-live-p gnus-article-buffer)
7157 (window-live-p (get-buffer-window
7158 gnus-article-buffer t))
7159 (or (not (string-match "^\\^X-Face:" regexp))
7160 (with-current-buffer gnus-article-buffer
7161 gnus-summary-search-article-matched-data)))))
7162 (gnus-summary-select-article nil t)
7163 (setq treated nil))))
7164 (set-buffer gnus-article-buffer)
7168 (gnus-article-show-all-headers)
7169 (gnus-summary-search-article-position-point regexp backward))
7170 (goto-char (if backward (point-max) (point-min))))
7172 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7174 (re-search-backward regexp nil t)
7175 (re-search-forward regexp nil t))
7176 ;; We found the regexp.
7178 (gnus-summary-search-article-highlight-matched-text
7179 backward treated (string-match "^\\^X-Face:" regexp))
7182 (/ (- 2 (window-height
7183 (get-buffer-window gnus-article-buffer t)))
7186 (get-buffer-window (current-buffer))
7189 (setq point (point)))
7190 ;; We didn't find it, so we go to the next article.
7193 (while (eq found 'not)
7194 (if (not (if backward (gnus-summary-find-prev)
7195 (gnus-summary-find-next)))
7196 ;; No more articles.
7198 ;; Select the next article and adjust point.
7199 (unless (gnus-summary-article-sparse-p
7200 (gnus-summary-article-number))
7202 (let ((gnus-inhibit-treatment t))
7203 (gnus-summary-select-article))
7205 (set-buffer gnus-article-buffer)
7207 (goto-char (if backward (point-max) (point-min))))))))
7208 (gnus-message 7 ""))
7209 ;; Return whether we found the regexp.
7210 (when (eq found 'found)
7212 (gnus-summary-show-thread)
7213 (gnus-summary-goto-subject gnus-current-article)
7214 (gnus-summary-position-point)
7217 (defun gnus-summary-find-matching (header regexp &optional backward unread
7219 "Return a list of all articles that match REGEXP on HEADER.
7220 The search stars on the current article and goes forwards unless
7221 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7222 If UNREAD is non-nil, only unread articles will
7223 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7224 in the comparisons."
7225 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7226 (gnus-data-find-list
7227 (gnus-summary-article-number) (gnus-data-list backward))))
7228 (case-fold-search (not not-case-fold))
7231 (if (eq (car header) 'extra)
7234 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7236 (error "%s is an invalid header" header))
7237 (unless (fboundp (intern (concat "mail-header-" header)))
7238 (error "%s is not a valid header" header))
7239 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7242 (and (or (not unread) ; We want all articles...
7243 (gnus-data-unread-p d)) ; Or just unreads.
7244 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7245 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7246 (push (gnus-data-number d) articles)) ; Success!
7247 (setq data (cdr data)))
7248 (nreverse articles)))
7250 (defun gnus-summary-execute-command (header regexp command &optional backward)
7251 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7252 If HEADER is an empty string (or nil), the match is done on the entire
7253 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7255 (list (let ((completion-ignore-case t))
7258 (mapcar (lambda (string) (list string))
7259 '("Number" "Subject" "From" "Lines" "Date"
7260 "Message-ID" "Xref" "References" "Body"))
7261 nil 'require-match))
7262 (read-string "Regexp: ")
7263 (read-key-sequence "Command: ")
7264 current-prefix-arg))
7265 (when (equal header "Body")
7267 ;; Hidden thread subtrees must be searched as well.
7268 (gnus-summary-show-all-threads)
7269 ;; We don't want to change current point nor window configuration.
7271 (save-window-excursion
7272 (gnus-message 6 "Executing %s..." (key-description command))
7273 ;; We'd like to execute COMMAND interactively so as to give arguments.
7274 (gnus-execute header regexp
7275 `(call-interactively ',(key-binding command))
7277 (gnus-message 6 "Executing %s...done" (key-description command)))))
7279 (defun gnus-summary-beginning-of-article ()
7280 "Scroll the article back to the beginning."
7282 (gnus-summary-select-article)
7283 (gnus-configure-windows 'article)
7284 (gnus-eval-in-buffer-window gnus-article-buffer
7286 (goto-char (point-min))
7287 (when gnus-page-broken
7288 (gnus-narrow-to-page))))
7290 (defun gnus-summary-end-of-article ()
7291 "Scroll to the end of the article."
7293 (gnus-summary-select-article)
7294 (gnus-configure-windows 'article)
7295 (gnus-eval-in-buffer-window gnus-article-buffer
7297 (goto-char (point-max))
7299 (when gnus-page-broken
7300 (gnus-narrow-to-page))))
7302 (defun gnus-summary-print-article (&optional filename n)
7303 "Generate and print a PostScript image of the N next (mail) articles.
7305 If N is negative, print the N previous articles. If N is nil and articles
7306 have been marked with the process mark, print these instead.
7308 If the optional first argument FILENAME is nil, send the image to the
7309 printer. If FILENAME is a string, save the PostScript image in a file with
7310 that name. If FILENAME is a number, prompt the user for the name of the file
7312 (interactive (list (ps-print-preprint current-prefix-arg)
7313 current-prefix-arg))
7314 (dolist (article (gnus-summary-work-articles n))
7315 (gnus-summary-select-article nil nil 'pseudo article)
7316 (gnus-eval-in-buffer-window gnus-article-buffer
7317 (let ((buffer (generate-new-buffer " *print*")))
7320 (copy-to-buffer buffer (point-min) (point-max))
7322 (gnus-article-delete-invisible-text)
7323 (let ((ps-left-header
7326 (mail-header-subject gnus-current-headers) ")")
7328 (mail-header-from gnus-current-headers) ")")))
7331 "/pagenumberstring load"
7333 (mail-header-date gnus-current-headers) ")"))))
7334 (gnus-run-hooks 'gnus-ps-print-hook)
7336 (ps-print-buffer-with-faces filename))))
7337 (kill-buffer buffer))))))
7339 (defun gnus-summary-show-article (&optional arg)
7340 "Force re-fetching of the current article.
7341 If ARG (the prefix) is a number, show the article with the charset
7342 defined in `gnus-summary-show-article-charset-alist', or the charset
7344 If ARG (the prefix) is non-nil and not a number, show the raw article
7345 without any article massaging functions being run."
7349 (let ((gnus-newsgroup-charset
7350 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7351 (read-coding-system "Charset: ")))
7352 (gnus-newsgroup-ignored-charsets 'gnus-all))
7353 (gnus-summary-select-article nil 'force)))
7355 ;; Select the article the normal way.
7356 (gnus-summary-select-article nil 'force))
7358 ;; We have to require this here to make sure that the following
7359 ;; dynamic binding isn't shadowed by autoloading.
7360 (require 'gnus-async)
7362 ;; Bind the article treatment functions to nil.
7363 (let ((gnus-have-all-headers t)
7364 gnus-article-display-hook
7365 gnus-article-prepare-hook
7366 gnus-article-decode-hook
7369 (gnus-summary-select-article nil 'force))))
7370 (gnus-summary-goto-subject gnus-current-article)
7371 (gnus-summary-position-point))
7373 (defun gnus-summary-verbose-headers (&optional arg)
7374 "Toggle permanent full header display.
7375 If ARG is a positive number, turn header display on.
7376 If ARG is a negative number, turn header display off."
7378 (setq gnus-show-all-headers
7379 (cond ((or (not (numberp arg))
7381 (not gnus-show-all-headers))
7384 (gnus-summary-show-article))
7386 (defun gnus-summary-toggle-header (&optional arg)
7387 "Show the headers if they are hidden, or hide them if they are shown.
7388 If ARG is a positive number, show the entire header.
7389 If ARG is a negative number, hide the unwanted header lines."
7392 (set-buffer gnus-article-buffer)
7394 (let* ((buffer-read-only nil)
7395 (inhibit-point-motion-hooks t)
7401 (article-narrow-to-head)
7402 (gnus-article-hidden-text-p 'headers))))
7403 (goto-char (point-min))
7404 (when (search-forward "\n\n" nil t)
7405 (delete-region (point-min) (1- (point))))
7406 (goto-char (point-min))
7408 (set-buffer gnus-original-article-buffer)
7409 (goto-char (point-min))
7410 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7411 (insert-buffer-substring gnus-original-article-buffer 1 e)
7413 (narrow-to-region (point-min) (point))
7414 (article-decode-encoded-words)
7416 (let ((gnus-treat-hide-headers nil)
7417 (gnus-treat-hide-boring-headers nil))
7418 (setq gnus-article-wash-types
7419 (delq 'headers gnus-article-wash-types))
7420 (gnus-treat-article 'head))
7421 (gnus-treat-article 'head)))
7422 (gnus-set-mode-line 'article)))))
7424 (defun gnus-summary-show-all-headers ()
7425 "Make all header lines visible."
7427 (gnus-article-show-all-headers))
7429 (defun gnus-summary-toggle-mime (&optional arg)
7430 "Toggle MIME processing.
7431 If ARG is a positive number, turn MIME processing on."
7433 (setq gnus-show-mime
7435 (not gnus-show-mime)
7436 (> (prefix-numeric-value arg) 0)))
7437 (gnus-summary-select-article t 'force))
7439 (defun gnus-summary-caesar-message (&optional arg)
7440 "Caesar rotate the current article by 13.
7441 The numerical prefix specifies how many places to rotate each letter
7444 (gnus-summary-select-article)
7445 (let ((mail-header-separator ""))
7446 (gnus-eval-in-buffer-window gnus-article-buffer
7449 (let ((start (window-start))
7451 (message-caesar-buffer-body arg)
7452 (set-window-start (get-buffer-window (current-buffer)) start))))))
7454 (defun gnus-summary-stop-page-breaking ()
7455 "Stop page breaking in the current article."
7457 (gnus-summary-select-article)
7458 (gnus-eval-in-buffer-window gnus-article-buffer
7460 (when (gnus-visual-p 'page-marker)
7461 (let ((buffer-read-only nil))
7462 (gnus-remove-text-with-property 'gnus-prev)
7463 (gnus-remove-text-with-property 'gnus-next))
7464 (setq gnus-page-broken nil))))
7466 (defun gnus-summary-move-article (&optional n to-newsgroup
7467 select-method action)
7468 "Move the current article to a different newsgroup.
7469 If N is a positive number, move the N next articles.
7470 If N is a negative number, move the N previous articles.
7471 If N is nil and any articles have been marked with the process mark,
7472 move those articles instead.
7473 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7474 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7475 re-spool using this method.
7477 For this function to work, both the current newsgroup and the
7478 newsgroup that you want to move to have to support the `request-move'
7479 and `request-accept' functions.
7481 ACTION can be either `move' (the default), `crosspost' or `copy'."
7484 (setq action 'move))
7485 ;; Disable marking as read.
7486 (let (gnus-mark-article-hook)
7487 (save-window-excursion
7488 (gnus-summary-select-article)))
7489 ;; Check whether the source group supports the required functions.
7490 (cond ((and (eq action 'move)
7491 (not (gnus-check-backend-function
7492 'request-move-article gnus-newsgroup-name)))
7493 (error "The current group does not support article moving"))
7494 ((and (eq action 'crosspost)
7495 (not (gnus-check-backend-function
7496 'request-replace-article gnus-newsgroup-name)))
7497 (error "The current group does not support article editing")))
7498 (let ((articles (gnus-summary-work-articles n))
7499 (prefix (if (gnus-check-backend-function
7500 'request-move-article gnus-newsgroup-name)
7501 (gnus-group-real-prefix gnus-newsgroup-name)
7503 (names '((move "Move" "Moving")
7504 (copy "Copy" "Copying")
7505 (crosspost "Crosspost" "Crossposting")))
7506 (copy-buf (save-excursion
7507 (nnheader-set-temp-buffer " *copy article*")))
7508 (default-marks gnus-article-mark-lists)
7509 (no-expire-marks (delete '(expirable . expire)
7510 (copy-sequence gnus-article-mark-lists)))
7511 art-group to-method new-xref article to-groups)
7512 (unless (assq action names)
7513 (error "Unknown action %s" action))
7514 ;; Read the newsgroup name.
7515 (when (and (not to-newsgroup)
7516 (not select-method))
7518 (gnus-read-move-group-name
7519 (cadr (assq action names))
7520 (symbol-value (intern (format "gnus-current-%s-group" action)))
7522 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7523 (setq to-method (or select-method
7524 (gnus-server-to-method
7525 (gnus-group-method to-newsgroup))))
7526 ;; Check the method we are to move this article to...
7527 (unless (gnus-check-backend-function
7528 'request-accept-article (car to-method))
7529 (error "%s does not support article copying" (car to-method)))
7530 (unless (gnus-check-server to-method)
7531 (error "Can't open server %s" (car to-method)))
7532 (gnus-message 6 "%s to %s: %s..."
7533 (caddr (assq action names))
7534 (or (car select-method) to-newsgroup) articles)
7536 (setq article (pop articles))
7540 ;; Move the article.
7542 ;; Remove this article from future suppression.
7543 (gnus-dup-unsuppress-article article)
7544 (gnus-request-move-article
7545 article ; Article to move
7546 gnus-newsgroup-name ; From newsgroup
7547 (nth 1 (gnus-find-method-for-group
7548 gnus-newsgroup-name)) ; Server
7549 (list 'gnus-request-accept-article
7550 to-newsgroup (list 'quote select-method)
7551 (not articles) t) ; Accept form
7552 (not articles))) ; Only save nov last time
7553 ;; Copy the article.
7556 (set-buffer copy-buf)
7557 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7558 (gnus-request-accept-article
7559 to-newsgroup select-method (not articles) t))))
7560 ;; Crosspost the article.
7561 ((eq action 'crosspost)
7562 (let ((xref (message-tokenize-header
7563 (mail-header-xref (gnus-summary-article-header article))
7565 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7568 (setq xref (list (system-name))))
7571 (mapconcat 'identity
7572 (delete "Xref:" (delete new-xref xref))
7576 (set-buffer copy-buf)
7577 ;; First put the article in the destination group.
7578 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7579 (when (consp (setq art-group
7580 (gnus-request-accept-article
7581 to-newsgroup select-method (not articles))))
7582 (setq new-xref (concat new-xref " " (car art-group)
7583 ":" (cdr art-group)))
7584 ;; Now we have the new Xrefs header, so we insert
7585 ;; it and replace the new article.
7586 (nnheader-replace-header "Xref" new-xref)
7587 (gnus-request-replace-article
7588 (cdr art-group) to-newsgroup (current-buffer))
7592 (gnus-message 1 "Couldn't %s article %s: %s"
7593 (cadr (assq action names)) article
7594 (nnheader-get-report (car to-method))))
7595 ((eq art-group 'junk)
7596 (when (eq action 'move)
7597 (gnus-summary-mark-article article gnus-canceled-mark)
7598 (gnus-message 4 "Deleted article %s" article)))
7600 (let* ((pto-group (gnus-group-prefixed-name
7601 (car art-group) to-method))
7603 (gnus-gethash pto-group gnus-newsrc-hashtb))
7604 (info (nth 2 entry))
7605 (to-group (gnus-info-group info))
7607 ;; Update the group that has been moved to.
7609 (memq action '(move copy)))
7610 (unless (member to-group to-groups)
7611 (push to-group to-groups))
7613 (unless (memq article gnus-newsgroup-unreads)
7614 (push 'read to-marks)
7616 info (gnus-add-to-range (gnus-info-read info)
7617 (list (cdr art-group)))))
7619 ;; See whether the article is to be put in the cache.
7620 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7623 (to-article (cdr art-group)))
7625 ;; Enter the article into the cache in the new group,
7626 ;; if that is required.
7627 (when gnus-use-cache
7628 (gnus-cache-possibly-enter-article
7630 (let ((header (copy-sequence
7631 (gnus-summary-article-header article))))
7632 (mail-header-set-number header to-article)
7634 (memq article gnus-newsgroup-marked)
7635 (memq article gnus-newsgroup-dormant)
7636 (memq article gnus-newsgroup-unreads)))
7638 (when gnus-preserve-marks
7639 ;; Copy any marks over to the new group.
7640 (when (and (equal to-group gnus-newsgroup-name)
7641 (not (memq article gnus-newsgroup-unreads)))
7642 ;; Mark this article as read in this group.
7643 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7644 (setcdr (gnus-active to-group) to-article)
7645 (setcdr gnus-newsgroup-active to-article))
7648 (when (memq article (symbol-value
7649 (intern (format "gnus-newsgroup-%s"
7651 (push (cdar marks) to-marks)
7652 ;; If the other group is the same as this group,
7653 ;; then we have to add the mark to the list.
7654 (when (equal to-group gnus-newsgroup-name)
7655 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7658 (intern (format "gnus-newsgroup-%s"
7660 ;; Copy the marks to other group.
7661 (gnus-add-marked-articles
7662 to-group (cdar marks) (list to-article) info))
7663 (setq marks (cdr marks)))
7665 (gnus-request-set-mark to-group (list (list (list to-article)
7670 (concat "(gnus-group-set-info '"
7671 (gnus-prin1-to-string (gnus-get-info to-group))
7674 ;; Update the Xref header in this article to point to
7675 ;; the new crossposted article we have just created.
7676 (when (eq action 'crosspost)
7678 (set-buffer copy-buf)
7679 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7680 (nnheader-replace-header "Xref" new-xref)
7681 (gnus-request-replace-article
7682 article gnus-newsgroup-name (current-buffer)))))
7684 ;;;!!!Why is this necessary?
7685 (set-buffer gnus-summary-buffer)
7687 (gnus-summary-goto-subject article)
7688 (when (eq action 'move)
7689 (gnus-summary-mark-article article gnus-canceled-mark))))
7690 (gnus-summary-remove-process-mark article))
7691 ;; Re-activate all groups that have been moved to.
7694 (set-buffer gnus-group-buffer)
7695 (when (gnus-group-goto-group (car to-groups) t)
7696 (gnus-group-get-new-news-this-group 1 t))
7699 (gnus-kill-buffer copy-buf)
7700 (gnus-summary-position-point)
7701 (gnus-set-mode-line 'summary)))
7703 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7704 "Move the current article to a different newsgroup.
7705 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7706 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7707 re-spool using this method."
7709 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7711 (defun gnus-summary-crosspost-article (&optional n)
7712 "Crosspost the current article to some other group."
7714 (gnus-summary-move-article n nil nil 'crosspost))
7716 (defcustom gnus-summary-respool-default-method nil
7717 "Default method for respooling an article.
7718 If nil, use to the current newsgroup method."
7719 :type '(choice (gnus-select-method :value (nnml ""))
7721 :group 'gnus-summary-mail)
7723 (defun gnus-summary-respool-article (&optional n method)
7724 "Respool the current article.
7725 The article will be squeezed through the mail spooling process again,
7726 which means that it will be put in some mail newsgroup or other
7727 depending on `nnmail-split-methods'.
7728 If N is a positive number, respool the N next articles.
7729 If N is a negative number, respool the N previous articles.
7730 If N is nil and any articles have been marked with the process mark,
7731 respool those articles instead.
7733 Respooling can be done both from mail groups and \"real\" newsgroups.
7734 In the former case, the articles in question will be moved from the
7735 current group into whatever groups they are destined to. In the
7736 latter case, they will be copied into the relevant groups."
7738 (list current-prefix-arg
7739 (let* ((methods (gnus-methods-using 'respool))
7741 (symbol-name (or gnus-summary-respool-default-method
7742 (car (gnus-find-method-for-group
7743 gnus-newsgroup-name)))))
7745 (gnus-completing-read
7746 methname "What backend do you want to use when respooling?"
7747 methods nil t nil 'gnus-mail-method-history))
7750 ((zerop (length (setq ms (gnus-servers-using-backend
7752 (list (intern method) ""))
7756 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7757 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7760 (error "No method given for respooling"))
7761 (if (assoc (symbol-name
7762 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7763 (gnus-methods-using 'respool))
7764 (gnus-summary-move-article n nil method)
7765 (gnus-summary-copy-article n nil method)))
7767 (defun gnus-summary-import-article (file)
7768 "Import an arbitrary file into a mail newsgroup."
7769 (interactive "fImport file: ")
7770 (let ((group gnus-newsgroup-name)
7771 (now (current-time))
7773 (unless (gnus-check-backend-function 'request-accept-article group)
7774 (error "%s does not support article importing" group))
7775 (or (file-readable-p file)
7776 (not (file-regular-p file))
7777 (error "Can't read %s" file))
7779 (set-buffer (gnus-get-buffer-create " *import file*"))
7781 (nnheader-insert-file-contents file)
7782 (goto-char (point-min))
7783 (unless (nnheader-article-p)
7784 ;; This doesn't look like an article, so we fudge some headers.
7785 (setq atts (file-attributes file)
7786 lines (count-lines (point-min) (point-max)))
7787 (insert "From: " (read-string "From: ") "\n"
7788 "Subject: " (read-string "Subject: ") "\n"
7789 "Date: " (message-make-date (nth 5 atts))
7791 "Message-ID: " (message-make-message-id) "\n"
7792 "Lines: " (int-to-string lines) "\n"
7793 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7794 (gnus-request-accept-article group nil t)
7795 (kill-buffer (current-buffer)))))
7797 (defun gnus-summary-article-posted-p ()
7798 "Say whether the current (mail) article is available from news as well.
7799 This will be the case if the article has both been mailed and posted."
7801 (let ((id (mail-header-references (gnus-summary-article-header)))
7802 (gnus-override-method (car (gnus-refer-article-methods))))
7803 (if (gnus-request-head id "")
7804 (gnus-message 2 "The current message was found on %s"
7805 gnus-override-method)
7806 (gnus-message 2 "The current message couldn't be found on %s"
7807 gnus-override-method)
7810 (defun gnus-summary-expire-articles (&optional now)
7811 "Expire all articles that are marked as expirable in the current group."
7813 (when (gnus-check-backend-function
7814 'request-expire-articles gnus-newsgroup-name)
7815 ;; This backend supports expiry.
7816 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7817 (expirable (if total
7819 ;; We need to update the info for
7820 ;; this group for `gnus-list-of-read-articles'
7821 ;; to give us the right answer.
7822 (gnus-run-hooks 'gnus-exit-group-hook)
7823 (gnus-summary-update-info)
7824 (gnus-list-of-read-articles gnus-newsgroup-name))
7825 (setq gnus-newsgroup-expirable
7826 (sort gnus-newsgroup-expirable '<))))
7827 (expiry-wait (if now 'immediate
7828 (gnus-group-find-parameter
7829 gnus-newsgroup-name 'expiry-wait)))
7832 ;; There are expirable articles in this group, so we run them
7833 ;; through the expiry process.
7834 (gnus-message 6 "Expiring articles...")
7835 (unless (gnus-check-group gnus-newsgroup-name)
7836 (error "Can't open server for %s" gnus-newsgroup-name))
7837 ;; The list of articles that weren't expired is returned.
7840 (let ((nnmail-expiry-wait-function nil)
7841 (nnmail-expiry-wait expiry-wait))
7842 (setq es (gnus-request-expire-articles
7843 expirable gnus-newsgroup-name)))
7844 (setq es (gnus-request-expire-articles
7845 expirable gnus-newsgroup-name))))
7847 (setq gnus-newsgroup-expirable es))
7848 ;; We go through the old list of expirable, and mark all
7849 ;; really expired articles as nonexistent.
7850 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7851 (let ((gnus-use-cache nil))
7853 (unless (memq (car expirable) es)
7854 (when (gnus-data-find (car expirable))
7855 (gnus-summary-mark-article
7856 (car expirable) gnus-canceled-mark)))
7857 (setq expirable (cdr expirable)))))
7858 (gnus-message 6 "Expiring articles...done")))))
7860 (defun gnus-summary-expire-articles-now ()
7861 "Expunge all expirable articles in the current group.
7862 This means that *all* articles that are marked as expirable will be
7863 deleted forever, right now."
7865 (or gnus-expert-user
7867 "Are you really, really, really sure you want to delete all these messages? ")
7869 (gnus-summary-expire-articles t))
7871 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7872 (defun gnus-summary-delete-article (&optional n)
7873 "Delete the N next (mail) articles.
7874 This command actually deletes articles. This is not a marking
7875 command. The article will disappear forever from your life, never to
7877 If N is negative, delete backwards.
7878 If N is nil and articles have been marked with the process mark,
7879 delete these instead."
7881 (unless (gnus-check-backend-function 'request-expire-articles
7882 gnus-newsgroup-name)
7883 (error "The current newsgroup does not support article deletion"))
7884 ;; Compute the list of articles to delete.
7885 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7887 (if (and gnus-novice-user
7888 (not (gnus-yes-or-no-p
7889 (format "Do you really want to delete %s forever? "
7890 (if (> (length articles) 1)
7891 (format "these %s articles" (length articles))
7894 ;; Delete the articles.
7895 (setq not-deleted (gnus-request-expire-articles
7896 articles gnus-newsgroup-name 'force))
7898 (gnus-summary-remove-process-mark (car articles))
7899 ;; The backend might not have been able to delete the article
7901 (unless (memq (car articles) not-deleted)
7902 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7903 (setq articles (cdr articles)))
7905 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7906 (gnus-summary-position-point)
7907 (gnus-set-mode-line 'summary)
7910 (defun gnus-summary-edit-article (&optional force)
7911 "Edit the current article.
7912 This will have permanent effect only in mail groups.
7913 If FORCE is non-nil, allow editing of articles even in read-only
7917 (set-buffer gnus-summary-buffer)
7918 (let ((mail-parse-charset gnus-newsgroup-charset)
7919 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7920 (gnus-set-global-variables)
7921 (when (and (not force)
7922 (gnus-group-read-only-p))
7923 (error "The current newsgroup does not support article editing"))
7924 (gnus-summary-show-article t)
7925 (gnus-article-edit-article
7927 `(lambda (no-highlight)
7928 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7929 (mail-parse-ignored-charsets
7930 ',gnus-newsgroup-ignored-charsets))
7931 (gnus-summary-edit-article-done
7932 ,(or (mail-header-references gnus-current-headers) "")
7933 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7935 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7937 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7939 "Make edits to the current article permanent."
7941 ;; Replace the article.
7942 (let ((buf (current-buffer)))
7944 (insert-buffer-substring buf)
7945 (if (and (not read-only)
7946 (not (gnus-request-replace-article
7947 (cdr gnus-article-current) (car gnus-article-current)
7948 (current-buffer) t)))
7949 (error "Couldn't replace article")
7950 ;; Update the summary buffer.
7952 (equal (message-tokenize-header references " ")
7953 (message-tokenize-header
7954 (or (message-fetch-field "references") "") " ")))
7955 ;; We only have to update this line.
7958 (message-narrow-to-head)
7959 (let ((head (buffer-string))
7962 (insert (format "211 %d Article retrieved.\n"
7963 (cdr gnus-article-current)))
7966 (let ((nntp-server-buffer (current-buffer)))
7967 (setq header (car (gnus-get-newsgroup-headers
7969 (set-buffer gnus-summary-buffer)
7970 gnus-newsgroup-dependencies)
7973 (set-buffer gnus-summary-buffer)
7974 (gnus-data-set-header
7975 (gnus-data-find (cdr gnus-article-current))
7977 (gnus-summary-update-article-line
7978 (cdr gnus-article-current) header))))))
7980 (set-buffer (or buffer gnus-summary-buffer))
7981 (gnus-summary-update-article (cdr gnus-article-current)))
7982 ;; Prettify the article buffer again.
7983 (unless no-highlight
7985 (set-buffer gnus-article-buffer)
7986 ;;;!!! Fix this -- article should be rehighlighted.
7987 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7988 (set-buffer gnus-original-article-buffer)
7989 (gnus-request-article
7990 (cdr gnus-article-current)
7991 (car gnus-article-current) (current-buffer))))
7992 ;; Prettify the summary buffer line.
7993 (when (gnus-visual-p 'summary-highlight 'highlight)
7994 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7996 (defun gnus-summary-edit-wash (key)
7997 "Perform editing command KEY in the article buffer."
8001 (message "%s" (concat (this-command-keys) "- "))
8004 (gnus-summary-edit-article)
8005 (execute-kbd-macro (concat (this-command-keys) key))
8006 (gnus-article-edit-done))
8010 (defun gnus-summary-respool-query (&optional silent trace)
8011 "Query where the respool algorithm would put this article."
8013 (let (gnus-mark-article-hook)
8014 (gnus-summary-select-article)
8016 (set-buffer gnus-original-article-buffer)
8018 (message-narrow-to-head)
8019 (let ((groups (nnmail-article-group 'identity trace)))
8022 (message "This message would go to %s"
8023 (mapconcat 'car groups ", "))
8024 (message "This message would go to no groups"))
8027 (defun gnus-summary-respool-trace ()
8028 "Trace where the respool algorithm would put this article.
8029 Display a buffer showing all fancy splitting patterns which matched."
8031 (gnus-summary-respool-query nil t))
8033 ;; Summary marking commands.
8035 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8036 "Mark articles which has the same subject as read, and then select the next.
8037 If UNMARK is positive, remove any kind of mark.
8038 If UNMARK is negative, tick articles."
8041 (setq unmark (prefix-numeric-value unmark)))
8043 (gnus-summary-mark-same-subject
8044 (gnus-summary-article-subject) unmark)))
8045 ;; Select next unread article. If auto-select-same mode, should
8046 ;; select the first unread article.
8047 (gnus-summary-next-article t (and gnus-auto-select-same
8048 (gnus-summary-article-subject)))
8049 (gnus-message 7 "%d article%s marked as %s"
8050 count (if (= count 1) " is" "s are")
8051 (if unmark "unread" "read"))))
8053 (defun gnus-summary-kill-same-subject (&optional unmark)
8054 "Mark articles which has the same subject as read.
8055 If UNMARK is positive, remove any kind of mark.
8056 If UNMARK is negative, tick articles."
8059 (setq unmark (prefix-numeric-value unmark)))
8061 (gnus-summary-mark-same-subject
8062 (gnus-summary-article-subject) unmark)))
8063 ;; If marked as read, go to next unread subject.
8065 ;; Go to next unread subject.
8066 (gnus-summary-next-subject 1 t))
8067 (gnus-message 7 "%d articles are marked as %s"
8068 count (if unmark "unread" "read"))))
8070 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8071 "Mark articles with same SUBJECT as read, and return marked number.
8072 If optional argument UNMARK is positive, remove any kinds of marks.
8073 If optional argument UNMARK is negative, mark articles as unread instead."
8077 ((null unmark) ; Mark as read.
8080 (gnus-summary-mark-article-as-read gnus-killed-mark)
8081 (gnus-summary-show-thread) t)
8082 (gnus-summary-find-subject subject))
8083 (setq count (1+ count))))
8084 ((> unmark 0) ; Tick.
8087 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8088 (gnus-summary-show-thread) t)
8089 (gnus-summary-find-subject subject))
8090 (setq count (1+ count))))
8091 (t ; Mark as unread.
8094 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8095 (gnus-summary-show-thread) t)
8096 (gnus-summary-find-subject subject))
8097 (setq count (1+ count)))))
8098 (gnus-set-mode-line 'summary)
8099 ;; Return the number of marked articles.
8102 (defun gnus-summary-mark-as-processable (n &optional unmark)
8103 "Set the process mark on the next N articles.
8104 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8105 the process mark instead. The difference between N and the actual
8106 number of articles marked is returned."
8108 (let ((backward (< n 0))
8113 (gnus-summary-remove-process-mark
8114 (gnus-summary-article-number))
8115 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8116 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8119 (gnus-message 7 "No more articles"))
8120 (gnus-summary-recenter)
8121 (gnus-summary-position-point)
8124 (defun gnus-summary-unmark-as-processable (n)
8125 "Remove the process mark from the next N articles.
8126 If N is negative, unmark backward instead. The difference between N and
8127 the actual number of articles unmarked is returned."
8129 (gnus-summary-mark-as-processable n t))
8131 (defun gnus-summary-unmark-all-processable ()
8132 "Remove the process mark from all articles."
8135 (while gnus-newsgroup-processable
8136 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8137 (gnus-summary-position-point))
8139 (defun gnus-summary-mark-as-expirable (n)
8140 "Mark N articles forward as expirable.
8141 If N is negative, mark backward instead. The difference between N and
8142 the actual number of articles marked is returned."
8144 (gnus-summary-mark-forward n gnus-expirable-mark))
8146 (defun gnus-summary-mark-article-as-replied (article)
8147 "Mark ARTICLE replied and update the summary line."
8148 (push article gnus-newsgroup-replied)
8149 (let ((buffer-read-only nil))
8150 (when (gnus-summary-goto-subject article nil t)
8151 (gnus-summary-update-secondary-mark article))))
8153 (defun gnus-summary-set-bookmark (article)
8154 "Set a bookmark in current article."
8155 (interactive (list (gnus-summary-article-number)))
8156 (when (or (not (get-buffer gnus-article-buffer))
8157 (not gnus-current-article)
8158 (not gnus-article-current)
8159 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8160 (error "No current article selected"))
8161 ;; Remove old bookmark, if one exists.
8162 (let ((old (assq article gnus-newsgroup-bookmarks)))
8164 (setq gnus-newsgroup-bookmarks
8165 (delq old gnus-newsgroup-bookmarks))))
8166 ;; Set the new bookmark, which is on the form
8167 ;; (article-number . line-number-in-body).
8171 (set-buffer gnus-article-buffer)
8175 (goto-char (point-min))
8176 (search-forward "\n\n" nil t)
8179 gnus-newsgroup-bookmarks)
8180 (gnus-message 6 "A bookmark has been added to the current article."))
8182 (defun gnus-summary-remove-bookmark (article)
8183 "Remove the bookmark from the current article."
8184 (interactive (list (gnus-summary-article-number)))
8185 ;; Remove old bookmark, if one exists.
8186 (let ((old (assq article gnus-newsgroup-bookmarks)))
8189 (setq gnus-newsgroup-bookmarks
8190 (delq old gnus-newsgroup-bookmarks))
8191 (gnus-message 6 "Removed bookmark."))
8192 (gnus-message 6 "No bookmark in current article."))))
8194 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8195 (defun gnus-summary-mark-as-dormant (n)
8196 "Mark N articles forward as dormant.
8197 If N is negative, mark backward instead. The difference between N and
8198 the actual number of articles marked is returned."
8200 (gnus-summary-mark-forward n gnus-dormant-mark))
8202 (defun gnus-summary-set-process-mark (article)
8203 "Set the process mark on ARTICLE and update the summary line."
8204 (setq gnus-newsgroup-processable
8206 (delq article gnus-newsgroup-processable)))
8207 (when (gnus-summary-goto-subject article)
8208 (gnus-summary-show-thread)
8209 (gnus-summary-goto-subject article)
8210 (gnus-summary-update-secondary-mark article)))
8212 (defun gnus-summary-remove-process-mark (article)
8213 "Remove the process mark from ARTICLE and update the summary line."
8214 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8215 (when (gnus-summary-goto-subject article)
8216 (gnus-summary-show-thread)
8217 (gnus-summary-goto-subject article)
8218 (gnus-summary-update-secondary-mark article)))
8220 (defun gnus-summary-set-saved-mark (article)
8221 "Set the process mark on ARTICLE and update the summary line."
8222 (push article gnus-newsgroup-saved)
8223 (when (gnus-summary-goto-subject article)
8224 (gnus-summary-update-secondary-mark article)))
8226 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8227 "Mark N articles as read forwards.
8228 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8229 The difference between N and the actual number of articles marked is
8231 Iff NO-EXPIRE, auto-expiry will be inhibited."
8233 (gnus-summary-show-thread)
8234 (let ((backward (< n 0))
8235 (gnus-summary-goto-unread
8236 (and gnus-summary-goto-unread
8237 (not (eq gnus-summary-goto-unread 'never))
8238 (not (memq mark (list gnus-unread-mark
8239 gnus-ticked-mark gnus-dormant-mark)))))
8241 (mark (or mark gnus-del-mark)))
8243 (gnus-summary-mark-article nil mark no-expire)
8244 (zerop (gnus-summary-next-subject
8246 (and gnus-summary-goto-unread
8247 (not (eq gnus-summary-goto-unread 'never)))
8251 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8252 (gnus-summary-recenter)
8253 (gnus-summary-position-point)
8254 (gnus-set-mode-line 'summary)
8257 (defun gnus-summary-mark-article-as-read (mark)
8258 "Mark the current article quickly as read with MARK."
8259 (let ((article (gnus-summary-article-number)))
8260 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8261 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8262 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8263 (push (cons article mark) gnus-newsgroup-reads)
8264 ;; Possibly remove from cache, if that is used.
8265 (when gnus-use-cache
8266 (gnus-cache-enter-remove-article article))
8267 ;; Allow the backend to change the mark.
8268 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8269 ;; Check for auto-expiry.
8270 (when (and gnus-newsgroup-auto-expire
8271 (memq mark gnus-auto-expirable-marks))
8272 (setq mark gnus-expirable-mark)
8273 ;; Let the backend know about the mark change.
8274 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8275 (push article gnus-newsgroup-expirable))
8276 ;; Set the mark in the buffer.
8277 (gnus-summary-update-mark mark 'unread)
8280 (defun gnus-summary-mark-article-as-unread (mark)
8281 "Mark the current article quickly as unread with MARK."
8282 (let* ((article (gnus-summary-article-number))
8283 (old-mark (gnus-summary-article-mark article)))
8284 ;; Allow the backend to change the mark.
8285 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8286 (if (eq mark old-mark)
8290 (gnus-error 1 "Can't mark negative article numbers")
8292 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8293 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8294 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8295 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8296 (cond ((= mark gnus-ticked-mark)
8297 (push article gnus-newsgroup-marked))
8298 ((= mark gnus-dormant-mark)
8299 (push article gnus-newsgroup-dormant))
8301 (push article gnus-newsgroup-unreads)))
8302 (gnus-pull article gnus-newsgroup-reads)
8304 ;; See whether the article is to be put in the cache.
8306 (vectorp (gnus-summary-article-header article))
8308 (gnus-cache-possibly-enter-article
8309 gnus-newsgroup-name article
8310 (gnus-summary-article-header article)
8311 (= mark gnus-ticked-mark)
8312 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8315 (gnus-summary-update-mark mark 'unread)
8318 (defun gnus-summary-mark-article (&optional article mark no-expire)
8319 "Mark ARTICLE with MARK. MARK can be any character.
8320 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8321 `??' (dormant) and `?E' (expirable).
8322 If MARK is nil, then the default character `?r' is used.
8323 If ARTICLE is nil, then the article on the current line will be
8325 Iff NO-EXPIRE, auto-expiry will be inhibited."
8326 ;; The mark might be a string.
8327 (when (stringp mark)
8328 (setq mark (aref mark 0)))
8329 ;; If no mark is given, then we check auto-expiring.
8331 (setq mark gnus-del-mark))
8332 (when (and (not no-expire)
8333 gnus-newsgroup-auto-expire
8334 (memq mark gnus-auto-expirable-marks))
8335 (setq mark gnus-expirable-mark))
8336 (let ((article (or article (gnus-summary-article-number)))
8337 (old-mark (gnus-summary-article-mark article)))
8338 ;; Allow the backend to change the mark.
8339 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8340 (if (eq mark old-mark)
8343 (error "No article on current line"))
8344 (if (not (if (or (= mark gnus-unread-mark)
8345 (= mark gnus-ticked-mark)
8346 (= mark gnus-dormant-mark))
8347 (gnus-mark-article-as-unread article mark)
8348 (gnus-mark-article-as-read article mark)))
8350 ;; See whether the article is to be put in the cache.
8352 (not (= mark gnus-canceled-mark))
8353 (vectorp (gnus-summary-article-header article))
8355 (gnus-cache-possibly-enter-article
8356 gnus-newsgroup-name article
8357 (gnus-summary-article-header article)
8358 (= mark gnus-ticked-mark)
8359 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8361 (when (gnus-summary-goto-subject article nil t)
8362 (let ((buffer-read-only nil))
8363 (gnus-summary-show-thread)
8365 (gnus-summary-update-mark mark 'unread)
8368 (defun gnus-summary-update-secondary-mark (article)
8369 "Update the secondary (read, process, cache) mark."
8370 (gnus-summary-update-mark
8371 (cond ((memq article gnus-newsgroup-processable)
8373 ((memq article gnus-newsgroup-cached)
8375 ((memq article gnus-newsgroup-replied)
8377 ((memq article gnus-newsgroup-saved)
8379 (t gnus-unread-mark))
8381 (when (gnus-visual-p 'summary-highlight 'highlight)
8382 (gnus-run-hooks 'gnus-summary-update-hook))
8385 (defun gnus-summary-update-mark (mark type)
8386 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8387 (buffer-read-only nil))
8388 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8390 (when (looking-at "\r")
8392 (when (<= (+ forward (point)) (point-max))
8393 ;; Go to the right position on the line.
8394 (goto-char (+ forward (point)))
8395 ;; Replace the old mark with the new mark.
8396 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8397 ;; Optionally update the marks by some user rule.
8398 (when (eq type 'unread)
8400 (gnus-data-find (gnus-summary-article-number)) mark)
8401 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8403 (defun gnus-mark-article-as-read (article &optional mark)
8404 "Enter ARTICLE in the pertinent lists and remove it from others."
8405 ;; Make the article expirable.
8406 (let ((mark (or mark gnus-del-mark)))
8407 (if (= mark gnus-expirable-mark)
8408 (push article gnus-newsgroup-expirable)
8409 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8410 ;; Remove from unread and marked lists.
8411 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8412 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8413 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8414 (push (cons article mark) gnus-newsgroup-reads)
8415 ;; Possibly remove from cache, if that is used.
8416 (when gnus-use-cache
8417 (gnus-cache-enter-remove-article article))
8420 (defun gnus-mark-article-as-unread (article &optional mark)
8421 "Enter ARTICLE in the pertinent lists and remove it from others."
8422 (let ((mark (or mark gnus-ticked-mark)))
8425 (gnus-error 1 "Can't mark negative article numbers")
8427 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8428 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8429 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8430 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8432 ;; Unsuppress duplicates?
8433 (when gnus-suppress-duplicates
8434 (gnus-dup-unsuppress-article article))
8436 (cond ((= mark gnus-ticked-mark)
8437 (push article gnus-newsgroup-marked))
8438 ((= mark gnus-dormant-mark)
8439 (push article gnus-newsgroup-dormant))
8441 (push article gnus-newsgroup-unreads)))
8442 (gnus-pull article gnus-newsgroup-reads)
8445 (defalias 'gnus-summary-mark-as-unread-forward
8446 'gnus-summary-tick-article-forward)
8447 (make-obsolete 'gnus-summary-mark-as-unread-forward
8448 'gnus-summary-tick-article-forward)
8449 (defun gnus-summary-tick-article-forward (n)
8450 "Tick N articles forwards.
8451 If N is negative, tick backwards instead.
8452 The difference between N and the number of articles ticked is returned."
8454 (gnus-summary-mark-forward n gnus-ticked-mark))
8456 (defalias 'gnus-summary-mark-as-unread-backward
8457 'gnus-summary-tick-article-backward)
8458 (make-obsolete 'gnus-summary-mark-as-unread-backward
8459 'gnus-summary-tick-article-backward)
8460 (defun gnus-summary-tick-article-backward (n)
8461 "Tick N articles backwards.
8462 The difference between N and the number of articles ticked is returned."
8464 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8466 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8467 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8468 (defun gnus-summary-tick-article (&optional article clear-mark)
8469 "Mark current article as unread.
8470 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8471 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8473 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8476 (defun gnus-summary-mark-as-read-forward (n)
8477 "Mark N articles as read forwards.
8478 If N is negative, mark backwards instead.
8479 The difference between N and the actual number of articles marked is
8482 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8484 (defun gnus-summary-mark-as-read-backward (n)
8485 "Mark the N articles as read backwards.
8486 The difference between N and the actual number of articles marked is
8489 (gnus-summary-mark-forward
8490 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8492 (defun gnus-summary-mark-as-read (&optional article mark)
8493 "Mark current article as read.
8494 ARTICLE specifies the article to be marked as read.
8495 MARK specifies a string to be inserted at the beginning of the line."
8496 (gnus-summary-mark-article article mark))
8498 (defun gnus-summary-clear-mark-forward (n)
8499 "Clear marks from N articles forward.
8500 If N is negative, clear backward instead.
8501 The difference between N and the number of marks cleared is returned."
8503 (gnus-summary-mark-forward n gnus-unread-mark))
8505 (defun gnus-summary-clear-mark-backward (n)
8506 "Clear marks from N articles backward.
8507 The difference between N and the number of marks cleared is returned."
8509 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8511 (defun gnus-summary-mark-unread-as-read ()
8512 "Intended to be used by `gnus-summary-mark-article-hook'."
8513 (when (memq gnus-current-article gnus-newsgroup-unreads)
8514 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8516 (defun gnus-summary-mark-read-and-unread-as-read ()
8517 "Intended to be used by `gnus-summary-mark-article-hook'."
8518 (let ((mark (gnus-summary-article-mark)))
8519 (when (or (gnus-unread-mark-p mark)
8520 (gnus-read-mark-p mark))
8521 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8523 (defun gnus-summary-mark-region-as-read (point mark all)
8524 "Mark all unread articles between point and mark as read.
8525 If given a prefix, mark all articles between point and mark as read,
8526 even ticked and dormant ones."
8527 (interactive "r\nP")
8536 (memq (setq article (gnus-summary-article-number))
8537 gnus-newsgroup-unreads))
8538 (gnus-summary-mark-article article gnus-del-mark))
8540 (gnus-summary-find-next))))))
8542 (defun gnus-summary-mark-below (score mark)
8543 "Mark articles with score less than SCORE with MARK."
8544 (interactive "P\ncMark: ")
8545 (setq score (if score
8546 (prefix-numeric-value score)
8547 (or gnus-summary-default-score 0)))
8549 (set-buffer gnus-summary-buffer)
8550 (goto-char (point-min))
8553 (and (< (gnus-summary-article-score) score)
8554 (gnus-summary-mark-article nil mark))
8555 (gnus-summary-find-next)))))
8557 (defun gnus-summary-kill-below (&optional score)
8558 "Mark articles with score below SCORE as read."
8560 (gnus-summary-mark-below score gnus-killed-mark))
8562 (defun gnus-summary-clear-above (&optional score)
8563 "Clear all marks from articles with score above SCORE."
8565 (gnus-summary-mark-above score gnus-unread-mark))
8567 (defun gnus-summary-tick-above (&optional score)
8568 "Tick all articles with score above SCORE."
8570 (gnus-summary-mark-above score gnus-ticked-mark))
8572 (defun gnus-summary-mark-above (score mark)
8573 "Mark articles with score over SCORE with MARK."
8574 (interactive "P\ncMark: ")
8575 (setq score (if score
8576 (prefix-numeric-value score)
8577 (or gnus-summary-default-score 0)))
8579 (set-buffer gnus-summary-buffer)
8580 (goto-char (point-min))
8582 (when (> (gnus-summary-article-score) score)
8583 (gnus-summary-mark-article nil mark))
8585 (gnus-summary-find-next)))))
8587 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8588 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8589 (defun gnus-summary-limit-include-expunged (&optional no-error)
8590 "Display all the hidden articles that were expunged for low scores."
8592 (let ((buffer-read-only nil))
8593 (let ((scored gnus-newsgroup-scored)
8596 (unless (gnus-summary-goto-subject (caar scored))
8597 (and (setq h (gnus-summary-article-header (caar scored)))
8598 (< (cdar scored) gnus-summary-expunge-below)
8600 (setq scored (cdr scored)))
8602 (when (not no-error)
8603 (error "No expunged articles hidden"))
8604 (goto-char (point-min))
8605 (gnus-summary-prepare-unthreaded (nreverse headers))
8606 (goto-char (point-min))
8607 (gnus-summary-position-point)
8610 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8611 "Mark all unread articles in this newsgroup as read.
8612 If prefix argument ALL is non-nil, ticked and dormant articles will
8613 also be marked as read.
8614 If QUIETLY is non-nil, no questions will be asked.
8615 If TO-HERE is non-nil, it should be a point in the buffer. All
8616 articles before this point will be marked as read.
8617 Note that this function will only catch up the unread article
8618 in the current summary buffer limitation.
8619 The number of articles marked as read is returned."
8624 (not gnus-interactive-catchup) ;Without confirmation?
8628 "Mark absolutely all articles as read? "
8629 "Mark all unread articles as read? ")))
8631 (not gnus-newsgroup-adaptive)
8632 (not gnus-newsgroup-auto-expire)
8633 (not gnus-suppress-duplicates)
8634 (or (not gnus-use-cache)
8635 (eq gnus-use-cache 'passive)))
8638 (setq gnus-newsgroup-marked nil
8639 gnus-newsgroup-dormant nil))
8640 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8641 ;; We actually mark all articles as canceled, which we
8642 ;; have to do when using auto-expiry or adaptive scoring.
8643 (gnus-summary-show-all-threads)
8644 (when (gnus-summary-first-subject (not all) t)
8646 (if to-here (< (point) to-here) t)
8647 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8648 (gnus-summary-find-next (not all) nil nil t))))
8649 (gnus-set-mode-line 'summary))
8651 (gnus-summary-position-point)))
8653 (defun gnus-summary-catchup-to-here (&optional all)
8654 "Mark all unticked articles before the current one as read.
8655 If ALL is non-nil, also mark ticked and dormant articles as read."
8658 (gnus-save-hidden-threads
8659 (let ((beg (point)))
8660 ;; We check that there are unread articles.
8661 (when (or all (gnus-summary-find-prev))
8662 (gnus-summary-catchup all t beg)))))
8663 (gnus-summary-position-point))
8665 (defun gnus-summary-catchup-all (&optional quietly)
8666 "Mark all articles in this newsgroup as read."
8668 (gnus-summary-catchup t quietly))
8670 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8671 "Mark all unread articles in this group as read, then exit.
8672 If prefix argument ALL is non-nil, all articles are marked as read."
8674 (when (gnus-summary-catchup all quietly nil 'fast)
8675 ;; Select next newsgroup or exit.
8676 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8677 (eq gnus-auto-select-next 'quietly))
8678 (gnus-summary-next-group nil)
8679 (gnus-summary-exit))))
8681 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8682 "Mark all articles in this newsgroup as read, and then exit."
8684 (gnus-summary-catchup-and-exit t quietly))
8686 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8687 "Mark all articles in this group as read and select the next group.
8688 If given a prefix, mark all articles, unread as well as ticked, as
8692 (gnus-summary-catchup all))
8693 (gnus-summary-next-group))
8695 ;; Thread-based commands.
8697 (defun gnus-summary-articles-in-thread (&optional article)
8698 "Return a list of all articles in the current thread.
8699 If ARTICLE is non-nil, return all articles in the thread that starts
8701 (let* ((article (or article (gnus-summary-article-number)))
8702 (data (gnus-data-find-list article))
8703 (top-level (gnus-data-level (car data)))
8705 (cond ((null gnus-thread-operation-ignore-subject)
8706 (gnus-simplify-subject-re
8707 (mail-header-subject (gnus-data-header (car data)))))
8708 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8709 (gnus-simplify-subject-fuzzy
8710 (mail-header-subject (gnus-data-header (car data)))))
8712 (end-point (save-excursion
8713 (if (gnus-summary-go-to-next-thread)
8714 (point) (point-max))))
8717 (< (gnus-data-pos (car data)) end-point))
8718 (when (or (not top-subject)
8719 (string= top-subject
8720 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8721 (gnus-simplify-subject-fuzzy
8722 (mail-header-subject
8723 (gnus-data-header (car data))))
8724 (gnus-simplify-subject-re
8725 (mail-header-subject
8726 (gnus-data-header (car data)))))))
8727 (push (gnus-data-number (car data)) articles))
8728 (unless (and (setq data (cdr data))
8729 (> (gnus-data-level (car data)) top-level))
8731 ;; Return the list of articles.
8732 (nreverse articles)))
8734 (defun gnus-summary-rethread-current ()
8735 "Rethread the thread the current article is part of."
8737 (let* ((gnus-show-threads t)
8738 (article (gnus-summary-article-number))
8739 (id (mail-header-id (gnus-summary-article-header)))
8740 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8742 (error "No article on the current line"))
8743 (gnus-rebuild-thread id)
8744 (gnus-summary-goto-subject article)))
8746 (defun gnus-summary-reparent-thread ()
8747 "Make the current article child of the marked (or previous) article.
8749 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8750 is non-nil or the Subject: of both articles are the same."
8752 (unless (not (gnus-group-read-only-p))
8753 (error "The current newsgroup does not support article editing"))
8754 (unless (<= (length gnus-newsgroup-processable) 1)
8755 (error "No more than one article may be marked"))
8756 (save-window-excursion
8757 (let ((gnus-article-buffer " *reparent*")
8758 (current-article (gnus-summary-article-number))
8759 ;; First grab the marked article, otherwise one line up.
8760 (parent-article (if (not (null gnus-newsgroup-processable))
8761 (car gnus-newsgroup-processable)
8763 (if (eq (forward-line -1) 0)
8764 (gnus-summary-article-number)
8765 (error "Beginning of summary buffer"))))))
8766 (unless (not (eq current-article parent-article))
8767 (error "An article may not be self-referential"))
8768 (let ((message-id (mail-header-id
8769 (gnus-summary-article-header parent-article))))
8770 (unless (and message-id (not (equal message-id "")))
8771 (error "No message-id in desired parent"))
8772 (gnus-with-article current-article
8773 (goto-char (point-min))
8774 (if (re-search-forward "^References: " nil t)
8776 (re-search-forward "^[^ \t]" nil t)
8779 (insert " " message-id))
8780 (insert "References: " message-id "\n")))
8781 (set-buffer gnus-summary-buffer)
8782 (gnus-summary-unmark-all-processable)
8783 (gnus-summary-update-article current-article)
8784 (gnus-summary-rethread-current)
8785 (gnus-message 3 "Article %d is now the child of article %d"
8786 current-article parent-article)))))
8788 (defun gnus-summary-toggle-threads (&optional arg)
8789 "Toggle showing conversation threads.
8790 If ARG is positive number, turn showing conversation threads on."
8792 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8793 (setq gnus-show-threads
8794 (if (null arg) (not gnus-show-threads)
8795 (> (prefix-numeric-value arg) 0)))
8796 (gnus-summary-prepare)
8797 (gnus-summary-goto-subject current)
8798 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8799 (gnus-summary-position-point)))
8801 (defun gnus-summary-show-all-threads ()
8805 (let ((buffer-read-only nil))
8806 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8807 (gnus-summary-position-point))
8809 (defun gnus-summary-show-thread ()
8810 "Show thread subtrees.
8811 Returns nil if no thread was there to be shown."
8813 (let ((buffer-read-only nil)
8815 ;; first goto end then to beg, to have point at beg after let
8816 (end (progn (end-of-line) (point)))
8817 (beg (progn (beginning-of-line) (point))))
8819 ;; Any hidden lines here?
8820 (search-forward "\r" end t)
8821 (subst-char-in-region beg end ?\^M ?\n t)
8823 (gnus-summary-position-point))))
8825 (defun gnus-summary-hide-all-threads ()
8826 "Hide all thread subtrees."
8829 (goto-char (point-min))
8830 (gnus-summary-hide-thread)
8831 (while (zerop (gnus-summary-next-thread 1 t))
8832 (gnus-summary-hide-thread)))
8833 (gnus-summary-position-point))
8835 (defun gnus-summary-hide-thread ()
8836 "Hide thread subtrees.
8837 Returns nil if no threads were there to be hidden."
8839 (let ((buffer-read-only nil)
8841 (article (gnus-summary-article-number)))
8843 ;; Go forward until either the buffer ends or the subthread
8845 (when (and (not (eobp))
8846 (or (zerop (gnus-summary-next-thread 1 t))
8847 (goto-char (point-max))))
8849 (if (and (> (point) start)
8850 (search-backward "\n" start t))
8852 (subst-char-in-region start (point) ?\n ?\^M)
8853 (gnus-summary-goto-subject article))
8857 (defun gnus-summary-go-to-next-thread (&optional previous)
8858 "Go to the same level (or less) next thread.
8859 If PREVIOUS is non-nil, go to previous thread instead.
8860 Return the article number moved to, or nil if moving was impossible."
8861 (let ((level (gnus-summary-thread-level))
8862 (way (if previous -1 1))
8865 (while (and (not (eobp))
8866 (< level (gnus-summary-thread-level)))
8874 (gnus-summary-article-number)
8877 (defun gnus-summary-next-thread (n &optional silent)
8878 "Go to the same level next N'th thread.
8879 If N is negative, search backward instead.
8880 Returns the difference between N and the number of skips actually
8883 If SILENT, don't output messages."
8885 (let ((backward (< n 0))
8888 (gnus-summary-go-to-next-thread backward))
8891 (gnus-summary-position-point))
8892 (when (and (not silent) (/= 0 n))
8893 (gnus-message 7 "No more threads"))
8896 (defun gnus-summary-prev-thread (n)
8897 "Go to the same level previous N'th thread.
8898 Returns the difference between N and the number of skips actually
8901 (gnus-summary-next-thread (- n)))
8903 (defun gnus-summary-go-down-thread ()
8904 "Go down one level in the current thread."
8905 (let ((children (gnus-summary-article-children)))
8907 (gnus-summary-goto-subject (car children)))))
8909 (defun gnus-summary-go-up-thread ()
8910 "Go up one level in the current thread."
8911 (let ((parent (gnus-summary-article-parent)))
8913 (gnus-summary-goto-subject parent))))
8915 (defun gnus-summary-down-thread (n)
8916 "Go down thread N steps.
8917 If N is negative, go up instead.
8918 Returns the difference between N and how many steps down that were
8924 (if up (gnus-summary-go-up-thread)
8925 (gnus-summary-go-down-thread)))
8927 (gnus-summary-position-point)
8929 (gnus-message 7 "Can't go further"))
8932 (defun gnus-summary-up-thread (n)
8933 "Go up thread N steps.
8934 If N is negative, go up instead.
8935 Returns the difference between N and how many steps down that were
8938 (gnus-summary-down-thread (- n)))
8940 (defun gnus-summary-top-thread ()
8941 "Go to the top of the thread."
8943 (while (gnus-summary-go-up-thread))
8944 (gnus-summary-article-number))
8946 (defun gnus-summary-kill-thread (&optional unmark)
8947 "Mark articles under current thread as read.
8948 If the prefix argument is positive, remove any kinds of marks.
8949 If the prefix argument is negative, tick articles instead."
8952 (setq unmark (prefix-numeric-value unmark)))
8953 (let ((articles (gnus-summary-articles-in-thread)))
8955 ;; Expand the thread.
8956 (gnus-summary-show-thread)
8957 ;; Mark all the articles.
8959 (gnus-summary-goto-subject (car articles))
8960 (cond ((null unmark)
8961 (gnus-summary-mark-article-as-read gnus-killed-mark))
8963 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8965 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8966 (setq articles (cdr articles))))
8967 ;; Hide killed subtrees.
8969 gnus-thread-hide-killed
8970 (gnus-summary-hide-thread))
8971 ;; If marked as read, go to next unread subject.
8973 ;; Go to next unread subject.
8974 (gnus-summary-next-subject 1 t)))
8975 (gnus-set-mode-line 'summary))
8977 ;; Summary sorting commands
8979 (defun gnus-summary-sort-by-number (&optional reverse)
8980 "Sort the summary buffer by article number.
8981 Argument REVERSE means reverse order."
8983 (gnus-summary-sort 'number reverse))
8985 (defun gnus-summary-sort-by-author (&optional reverse)
8986 "Sort the summary buffer by author name alphabetically.
8987 If case-fold-search is non-nil, case of letters is ignored.
8988 Argument REVERSE means reverse order."
8990 (gnus-summary-sort 'author reverse))
8992 (defun gnus-summary-sort-by-subject (&optional reverse)
8993 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8994 If case-fold-search is non-nil, case of letters is ignored.
8995 Argument REVERSE means reverse order."
8997 (gnus-summary-sort 'subject reverse))
8999 (defun gnus-summary-sort-by-date (&optional reverse)
9000 "Sort the summary buffer by date.
9001 Argument REVERSE means reverse order."
9003 (gnus-summary-sort 'date reverse))
9005 (defun gnus-summary-sort-by-score (&optional reverse)
9006 "Sort the summary buffer by score.
9007 Argument REVERSE means reverse order."
9009 (gnus-summary-sort 'score reverse))
9011 (defun gnus-summary-sort-by-lines (&optional reverse)
9012 "Sort the summary buffer by the number of lines.
9013 Argument REVERSE means reverse order."
9015 (gnus-summary-sort 'lines reverse))
9017 (defun gnus-summary-sort-by-chars (&optional reverse)
9018 "Sort the summary buffer by article length.
9019 Argument REVERSE means reverse order."
9021 (gnus-summary-sort 'chars reverse))
9023 (defun gnus-summary-sort (predicate reverse)
9024 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9025 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9026 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9027 (gnus-thread-sort-functions
9032 (gnus-article-sort-functions
9038 (gnus-summary-prepare-hook nil))
9039 ;; We do the sorting by regenerating the threads.
9040 (gnus-summary-prepare)
9041 ;; Hide subthreads if needed.
9042 (when (and gnus-show-threads gnus-thread-hide-subtree)
9043 (gnus-summary-hide-all-threads))))
9045 ;; Summary saving commands.
9047 (defun gnus-summary-save-article (&optional n not-saved)
9048 "Save the current article using the default saver function.
9049 If N is a positive number, save the N next articles.
9050 If N is a negative number, save the N previous articles.
9051 If N is nil and any articles have been marked with the process mark,
9052 save those articles instead.
9053 The variable `gnus-default-article-saver' specifies the saver function."
9055 (let* ((articles (gnus-summary-work-articles n))
9056 (save-buffer (save-excursion
9057 (nnheader-set-temp-buffer " *Gnus Save*")))
9058 (num (length articles))
9060 (dolist (article articles)
9061 (setq header (gnus-summary-article-header article))
9062 (if (not (vectorp header))
9063 ;; This is a pseudo-article.
9064 (if (assq 'name header)
9065 (gnus-copy-file (cdr (assq 'name header)))
9066 (gnus-message 1 "Article %d is unsaveable" article))
9067 ;; This is a real article.
9068 (save-window-excursion
9069 (gnus-summary-select-article t nil nil article))
9071 (set-buffer save-buffer)
9073 (insert-buffer-substring gnus-original-article-buffer))
9074 (setq file (gnus-article-save save-buffer file num))
9075 (gnus-summary-remove-process-mark article)
9077 (gnus-summary-set-saved-mark article))))
9078 (gnus-kill-buffer save-buffer)
9079 (gnus-summary-position-point)
9080 (gnus-set-mode-line 'summary)
9083 (defun gnus-summary-pipe-output (&optional arg)
9084 "Pipe the current article to a subprocess.
9085 If N is a positive number, pipe the N next articles.
9086 If N is a negative number, pipe the N previous articles.
9087 If N is nil and any articles have been marked with the process mark,
9088 pipe those articles instead."
9090 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9091 (gnus-summary-save-article arg t))
9092 (gnus-configure-windows 'pipe))
9094 (defun gnus-summary-save-article-mail (&optional arg)
9095 "Append the current article to an mail file.
9096 If N is a positive number, save the N next articles.
9097 If N is a negative number, save the N previous articles.
9098 If N is nil and any articles have been marked with the process mark,
9099 save those articles instead."
9101 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9102 (gnus-summary-save-article arg)))
9104 (defun gnus-summary-save-article-rmail (&optional arg)
9105 "Append the current article to an rmail file.
9106 If N is a positive number, save the N next articles.
9107 If N is a negative number, save the N previous articles.
9108 If N is nil and any articles have been marked with the process mark,
9109 save those articles instead."
9111 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9112 (gnus-summary-save-article arg)))
9114 (defun gnus-summary-save-article-file (&optional arg)
9115 "Append the current article to a file.
9116 If N is a positive number, save the N next articles.
9117 If N is a negative number, save the N previous articles.
9118 If N is nil and any articles have been marked with the process mark,
9119 save those articles instead."
9121 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9122 (gnus-summary-save-article arg)))
9124 (defun gnus-summary-write-article-file (&optional arg)
9125 "Write the current article to a file, deleting the previous file.
9126 If N is a positive number, save the N next articles.
9127 If N is a negative number, save the N previous articles.
9128 If N is nil and any articles have been marked with the process mark,
9129 save those articles instead."
9131 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9132 (gnus-summary-save-article arg)))
9134 (defun gnus-summary-save-article-body-file (&optional arg)
9135 "Append the current article body to a file.
9136 If N is a positive number, save the N next articles.
9137 If N is a negative number, save the N previous articles.
9138 If N is nil and any articles have been marked with the process mark,
9139 save those articles instead."
9141 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9142 (gnus-summary-save-article arg)))
9144 (defun gnus-summary-pipe-message (program)
9145 "Pipe the current article through PROGRAM."
9146 (interactive "sProgram: ")
9147 (gnus-summary-select-article)
9148 (let ((mail-header-separator ""))
9149 (gnus-eval-in-buffer-window gnus-article-buffer
9152 (let ((start (window-start))
9154 (message-pipe-buffer-body program)
9155 (set-window-start (get-buffer-window (current-buffer)) start))))))
9157 (defun gnus-get-split-value (methods)
9158 "Return a value based on the split METHODS."
9159 (let (split-name method result match)
9162 (set-buffer gnus-original-article-buffer)
9164 (nnheader-narrow-to-headers)
9166 (goto-char (point-min))
9167 (setq method (pop methods))
9168 (setq match (car method))
9171 ;; Regular expression.
9173 (re-search-forward match nil t)))
9174 ((gnus-functionp match)
9178 (setq result (funcall match gnus-newsgroup-name))))
9183 (setq result (eval match)))))
9184 (setq split-name (append (cdr method) split-name))
9185 (cond ((stringp result)
9186 (push (expand-file-name
9187 result gnus-article-save-directory)
9190 (setq split-name (append result split-name)))))))))
9191 (nreverse split-name)))
9193 (defun gnus-valid-move-group-p (group)
9196 (symbol-value group)
9197 (gnus-get-function (gnus-find-method-for-group
9198 (symbol-name group)) 'request-accept-article t)))
9200 (defun gnus-read-move-group-name (prompt default articles prefix)
9201 "Read a group name."
9202 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9203 (minibuffer-confirm-incomplete nil) ; XEmacs
9207 (if (> (length articles) 1)
9208 (format "these %d articles" (length articles))
9213 (gnus-completing-read default prom
9215 'gnus-valid-move-group-p
9217 'gnus-group-history))
9218 ((= 1 (length split-name))
9219 (gnus-completing-read (car split-name) prom
9221 'gnus-valid-move-group-p
9223 'gnus-group-history))
9225 (gnus-completing-read nil prom
9226 (mapcar (lambda (el) (list el))
9227 (nreverse split-name))
9229 'gnus-group-history))))
9230 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9232 (if (or (string= to-newsgroup "")
9233 (string= to-newsgroup prefix))
9234 (setq to-newsgroup default))
9235 (unless to-newsgroup
9236 (error "No group name entered"))
9237 (or (gnus-active to-newsgroup)
9238 (gnus-activate-group to-newsgroup nil nil to-method)
9239 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9241 (or (and (gnus-request-create-group to-newsgroup to-method)
9242 (gnus-activate-group
9243 to-newsgroup nil nil to-method)
9244 (gnus-subscribe-group to-newsgroup))
9245 (error "Couldn't create group %s" to-newsgroup)))
9246 (error "No such group: %s" to-newsgroup)))
9249 (defun gnus-summary-save-parts (type dir n &optional reverse)
9250 "Save parts matching TYPE to DIR.
9251 If REVERSE, save parts that do not match TYPE."
9253 (list (read-string "Save parts of type: " "image/.*")
9254 (read-file-name "Save to directory: " nil nil t)
9255 current-prefix-arg))
9256 (gnus-summary-iterate n
9257 (let ((gnus-display-mime-function nil)
9258 (gnus-inhibit-treatment t))
9259 (gnus-summary-select-article))
9261 (set-buffer gnus-article-buffer)
9262 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9264 (gnus-summary-save-parts-1 type dir handles reverse)
9265 (mm-destroy-parts handles))))))
9267 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9268 (if (stringp (car handle))
9269 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9272 (not (string-match type (mm-handle-media-type handle)))
9273 (string-match type (mm-handle-media-type handle)))
9274 (let ((file (expand-file-name
9275 (file-name-nondirectory
9277 (mail-content-type-get
9278 (mm-handle-disposition handle) 'filename)
9279 (concat gnus-newsgroup-name "." gnus-current-article)))
9281 (unless (file-exists-p file)
9282 (mm-save-part-to-file handle file))))))
9284 ;; Summary extract commands
9286 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9287 (let ((buffer-read-only nil)
9288 (article (gnus-summary-article-number))
9290 (unless (gnus-summary-goto-subject article)
9291 (error "No such article: %d" article))
9292 (gnus-summary-position-point)
9293 ;; If all commands are to be bunched up on one line, we collect
9295 (unless gnus-view-pseudos-separately
9296 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9299 (setq action (cdr (assq 'action (car ps))))
9300 (setq files (list (cdr (assq 'name (car ps)))))
9301 (while (and ps (cdr ps)
9302 (string= (or action "1")
9303 (or (cdr (assq 'action (cadr ps))) "2")))
9304 (push (cdr (assq 'name (cadr ps))) files)
9305 (setcdr ps (cddr ps)))
9307 (when (not (string-match "%s" action))
9310 (when (assq 'execute (car ps))
9311 (setcdr (assq 'execute (car ps))
9312 (funcall (if (string-match "%s" action)
9319 (gnus-quote-arg-for-sh-or-csh f)))
9321 (setq ps (cdr ps)))))
9322 (if (and gnus-view-pseudos (not not-view))
9324 (when (assq 'execute (car pslist))
9325 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9326 (eq gnus-view-pseudos 'not-confirm)))
9327 (setq pslist (cdr pslist)))
9330 (setq after-article (or (cdr (assq 'article (car pslist)))
9331 (gnus-summary-article-number)))
9332 (gnus-summary-goto-subject after-article)
9335 (insert " " (file-name-nondirectory
9336 (cdr (assq 'name (car pslist))))
9337 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9339 (forward-line -1) ; back to `b'
9340 (gnus-add-text-properties
9341 b (1- e) (list 'gnus-number gnus-reffed-article-number
9342 gnus-mouse-face-prop gnus-mouse-face))
9344 after-article gnus-reffed-article-number
9345 gnus-unread-mark b (car pslist) 0 (- e b))
9346 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9347 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9348 (setq pslist (cdr pslist)))))))
9350 (defun gnus-pseudos< (p1 p2)
9351 (let ((c1 (cdr (assq 'action p1)))
9352 (c2 (cdr (assq 'action p2))))
9353 (and c1 c2 (string< c1 c2))))
9355 (defun gnus-request-pseudo-article (props)
9356 (cond ((assq 'execute props)
9357 (gnus-execute-command (cdr (assq 'execute props)))))
9358 (let ((gnus-current-article (gnus-summary-article-number)))
9359 (gnus-run-hooks 'gnus-mark-article-hook)))
9361 (defun gnus-execute-command (command &optional automatic)
9363 (gnus-article-setup-buffer)
9364 (set-buffer gnus-article-buffer)
9365 (setq buffer-read-only nil)
9366 (let ((command (if automatic command
9367 (read-string "Command: " (cons command 0)))))
9369 (insert "$ " command "\n\n")
9370 (if gnus-view-pseudo-asynchronously
9371 (start-process "gnus-execute" (current-buffer) shell-file-name
9372 shell-command-switch command)
9373 (call-process shell-file-name nil t nil
9374 shell-command-switch command)))))
9376 ;; Summary kill commands.
9378 (defun gnus-summary-edit-global-kill (article)
9379 "Edit the \"global\" kill file."
9380 (interactive (list (gnus-summary-article-number)))
9381 (gnus-group-edit-global-kill article))
9383 (defun gnus-summary-edit-local-kill ()
9384 "Edit a local kill file applied to the current newsgroup."
9386 (setq gnus-current-headers (gnus-summary-article-header))
9387 (gnus-group-edit-local-kill
9388 (gnus-summary-article-number) gnus-newsgroup-name))
9392 (defun gnus-read-header (id &optional header)
9393 "Read the headers of article ID and enter them into the Gnus system."
9394 (let ((group gnus-newsgroup-name)
9395 (gnus-override-method
9397 gnus-override-method
9398 (and (gnus-news-group-p gnus-newsgroup-name)
9399 (car (gnus-refer-article-methods)))))
9401 ;; First we check to see whether the header in question is already
9404 ;; This is a Message-ID.
9405 (setq header (or header (gnus-id-to-header id)))
9406 ;; This is an article number.
9407 (setq header (or header (gnus-summary-article-header id))))
9409 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9410 ;; We have found the header.
9412 ;; If this is a sparse article, we have to nix out its
9413 ;; previous entry in the thread hashtb.
9415 (gnus-summary-article-sparse-p (mail-header-number header)))
9416 (let* ((parent (gnus-parent-id (mail-header-references header)))
9417 (thread (and parent (gnus-id-to-thread parent))))
9419 (delq (assq header thread) thread))))
9420 ;; We have to really fetch the header to this article.
9422 (set-buffer nntp-server-buffer)
9423 (when (setq where (gnus-request-head id group))
9424 (nnheader-fold-continuation-lines)
9425 (goto-char (point-max))
9427 (goto-char (point-min))
9431 ((cdr where) (cdr where))
9432 (header (mail-header-number header))
9433 (t gnus-reffed-article-number))
9435 (insert " Article retrieved.\n"))
9437 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9438 () ; Malformed head.
9439 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9440 (when (and (stringp id)
9441 (not (string= (gnus-group-real-name group)
9443 ;; If we fetched by Message-ID and the article came
9444 ;; from a different group, we fudge some bogus article
9445 ;; numbers for this article.
9446 (mail-header-set-number header gnus-reffed-article-number))
9448 (set-buffer gnus-summary-buffer)
9449 (decf gnus-reffed-article-number)
9450 (gnus-remove-header (mail-header-number header))
9451 (push header gnus-newsgroup-headers)
9452 (setq gnus-current-headers header)
9453 (push (mail-header-number header) gnus-newsgroup-limit)))
9456 (defun gnus-remove-header (number)
9457 "Remove header NUMBER from `gnus-newsgroup-headers'."
9458 (if (and gnus-newsgroup-headers
9459 (= number (mail-header-number (car gnus-newsgroup-headers))))
9460 (pop gnus-newsgroup-headers)
9461 (let ((headers gnus-newsgroup-headers))
9462 (while (and (cdr headers)
9463 (not (= number (mail-header-number (cadr headers)))))
9466 (setcdr headers (cddr headers))))))
9469 ;;; summary highlights
9472 (defun gnus-highlight-selected-summary ()
9473 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9474 ;; Highlight selected article in summary buffer
9475 (when gnus-summary-selected-face
9477 (let* ((beg (progn (beginning-of-line) (point)))
9478 (end (progn (end-of-line) (point)))
9479 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9480 (from (if (get-text-property beg gnus-mouse-face-prop)
9482 (or (next-single-property-change
9483 beg gnus-mouse-face-prop nil end)
9488 (or (next-single-property-change
9489 from gnus-mouse-face-prop nil end)
9491 ;; If no mouse-face prop on line we will have to = from = end,
9492 ;; so we highlight the entire line instead.
9493 (when (= (+ to 2) from)
9496 (if gnus-newsgroup-selected-overlay
9497 ;; Move old overlay.
9499 gnus-newsgroup-selected-overlay from to (current-buffer))
9500 ;; Create new overlay.
9502 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9503 'face gnus-summary-selected-face))))))
9505 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9506 (defun gnus-summary-highlight-line ()
9507 "Highlight current line according to `gnus-summary-highlight'."
9508 (let* ((list gnus-summary-highlight)
9510 (end (progn (end-of-line) (point)))
9511 ;; now find out where the line starts and leave point there.
9512 (beg (progn (beginning-of-line) (point)))
9513 (article (gnus-summary-article-number))
9514 (score (or (cdr (assq (or article gnus-current-article)
9515 gnus-newsgroup-scored))
9516 gnus-summary-default-score 0))
9517 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9518 (inhibit-read-only t))
9519 ;; Eval the cars of the lists until we find a match.
9520 (let ((default gnus-summary-default-score))
9522 (not (eval (caar list))))
9523 (setq list (cdr list))))
9524 (let ((face (cdar list)))
9525 (unless (eq face (get-text-property beg 'face))
9526 (gnus-put-text-property-excluding-characters-with-faces
9528 (setq face (if (boundp face) (symbol-value face) face)))
9529 (when gnus-summary-highlight-line-function
9530 (funcall gnus-summary-highlight-line-function article face))))
9533 (defun gnus-update-read-articles (group unread &optional compute)
9534 "Update the list of read articles in GROUP."
9535 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9536 (entry (gnus-gethash group gnus-newsrc-hashtb))
9537 (info (nth 2 entry))
9539 (unread (sort (copy-sequence unread) '<))
9541 (if (or (not info) (not active))
9542 ;; There is no info on this group if it was, in fact,
9543 ;; killed. Gnus stores no information on killed groups, so
9544 ;; there's nothing to be done.
9545 ;; One could store the information somewhere temporarily,
9546 ;; perhaps... Hmmm...
9548 ;; Remove any negative articles numbers.
9549 (while (and unread (< (car unread) 0))
9550 (setq unread (cdr unread)))
9551 ;; Remove any expired article numbers
9552 (while (and unread (< (car unread) (car active)))
9553 (setq unread (cdr unread)))
9554 ;; Compute the ranges of read articles by looking at the list of
9557 (when (/= (car unread) prev)
9558 (push (if (= prev (1- (car unread))) prev
9559 (cons prev (1- (car unread))))
9561 (setq prev (1+ (car unread)))
9562 (setq unread (cdr unread)))
9563 (when (<= prev (cdr active))
9564 (push (cons prev (cdr active)) read))
9565 (setq read (if (> (length read) 1) (nreverse read) read))
9569 (set-buffer gnus-group-buffer)
9572 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9573 (gnus-info-set-read ',info ',(gnus-info-read info))
9574 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9575 (gnus-group-update-group ,group t))))
9576 ;; Propagate the read marks to the backend.
9577 (if (gnus-check-backend-function 'request-set-mark group)
9578 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9579 (add (gnus-remove-from-range read (gnus-info-read info))))
9581 (unless (gnus-check-group group)
9582 (error "Can't open server for %s" group))
9583 (gnus-request-set-mark
9584 group (delq nil (list (if add (list add 'add '(read)))
9585 (if del (list del 'del '(read)))))))))
9586 ;; Enter this list into the group info.
9587 (gnus-info-set-read info read)
9588 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9589 (gnus-get-unread-articles-in-group info (gnus-active group))
9592 (defun gnus-offer-save-summaries ()
9593 "Offer to save all active summary buffers."
9595 (let ((buflist (buffer-list))
9597 ;; Go through all buffers and find all summaries.
9599 (and (setq bufname (buffer-name (car buflist)))
9600 (string-match "Summary" bufname)
9602 (set-buffer bufname)
9603 ;; We check that this is, indeed, a summary buffer.
9604 (and (eq major-mode 'gnus-summary-mode)
9605 ;; Also make sure this isn't bogus.
9606 gnus-newsgroup-prepared
9607 ;; Also make sure that this isn't a dead summary buffer.
9608 (not gnus-dead-summary-mode)))
9609 (push bufname buffers))
9610 (setq buflist (cdr buflist)))
9611 ;; Go through all these summary buffers and offer to save them.
9614 "Update summary buffer %s? "
9616 (switch-to-buffer buf)
9617 (gnus-summary-exit))
9621 ;;; @ for mime-partial
9624 (defun gnus-request-partial-message ()
9626 (let ((number (gnus-summary-article-number))
9627 (group gnus-newsgroup-name)
9628 (mother gnus-article-buffer))
9629 (set-buffer (get-buffer-create " *Partial Article*"))
9631 (setq mime-preview-buffer mother)
9632 (gnus-request-article-this-buffer number group)
9636 (autoload 'mime-combine-message/partial-pieces-automatically
9638 "Internal method to combine message/partial messages automatically.")
9641 'action '((type . message)(subtype . partial)
9642 (major-mode . gnus-original-article-mode)
9643 (method . mime-combine-message/partial-pieces-automatically)
9644 (summary-buffer-exp . gnus-summary-buffer)
9645 (request-partial-message-method . gnus-request-partial-message)
9649 ;;; @ for message/rfc822
9652 (defun gnus-mime-extract-message/rfc822 (entity situation)
9653 (let (group article num cwin swin cur)
9654 (with-current-buffer (mime-entity-buffer entity)
9656 (narrow-to-region (mime-entity-body-start entity)
9657 (mime-entity-body-end entity))
9658 (setq group (or (cdr (assq 'group situation))
9659 (completing-read "Group: "
9662 (gnus-read-active-file-p)
9663 gnus-newsgroup-name))
9664 article (gnus-request-accept-article group)
9667 (when (and (consp article)
9668 (numberp (setq article (cdr article))))
9669 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9670 cwin (get-buffer-window (current-buffer) t)
9672 (save-window-excursion
9673 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9674 (select-window swin)
9675 (set-buffer gnus-summary-buffer)
9677 (setq cur gnus-current-article)
9679 (let (gnus-show-threads)
9680 (gnus-summary-goto-subject article t)
9682 (gnus-summary-clear-mark-forward 1)
9683 (gnus-summary-goto-subject cur)
9685 (when (and cwin (window-frame cwin))
9686 (select-frame (window-frame cwin))
9688 (when (boundp 'mime-acting-situation-to-override)
9689 (set-alist 'mime-acting-situation-to-override
9692 (set-alist 'mime-acting-situation-to-override
9695 (save-current-buffer
9696 (set-buffer gnus-group-buffer)
9697 (gnus-activate-group ,group)
9699 (gnus-summary-goto-article ,cur
9700 gnus-show-all-headers)
9702 (set-alist 'mime-acting-situation-to-override
9708 'action '((type . message)(subtype . rfc822)
9709 (major-mode . gnus-original-article-mode)
9710 (method . gnus-mime-extract-message/rfc822)
9715 'action '((type . message)(subtype . news)
9716 (major-mode . gnus-original-article-mode)
9717 (method . gnus-mime-extract-message/rfc822)
9721 (defun gnus-mime-extract-multipart (entity situation)
9722 (let ((children (mime-entity-children entity))
9723 mime-acting-situation-to-override
9726 (mime-play-entity (car children)
9727 (cons (assq 'mode situation)
9728 mime-acting-situation-to-override))
9729 (setq children (cdr children)))
9730 (if (setq f (cdr (assq 'after-method
9731 mime-acting-situation-to-override)))
9736 'action '((type . multipart)
9737 (method . gnus-mime-extract-multipart)
9746 (defun gnus-summary-setup-default-charset ()
9747 "Setup newsgroup default charset."
9748 (if (equal gnus-newsgroup-name "nndraft:drafts")
9749 (setq gnus-newsgroup-charset nil)
9750 (let* ((name (and gnus-newsgroup-name
9751 (gnus-group-real-name gnus-newsgroup-name)))
9753 (or gnus-newsgroup-ephemeral-ignored-charsets
9755 (and gnus-newsgroup-name
9756 (or (gnus-group-find-parameter gnus-newsgroup-name
9757 'ignored-charsets t)
9758 (let ((alist gnus-group-ignored-charsets-alist)
9759 elem (charsets nil))
9760 (while (setq elem (pop alist))
9762 (string-match (car elem) name))
9764 charsets (cdr elem))))
9766 gnus-newsgroup-ignored-charsets))))
9767 (setq gnus-newsgroup-charset
9768 (or gnus-newsgroup-ephemeral-charset
9769 (and gnus-newsgroup-name
9770 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9771 (let ((alist gnus-group-charset-alist)
9773 (while (setq elem (pop alist))
9775 (string-match (car elem) name))
9777 charset (cadr elem))))
9779 gnus-default-charset))
9780 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9781 ignored-charsets))))
9787 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9788 "Display the current article buffer fully MIME-buttonized.
9789 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9790 treated as multipart/mixed."
9793 (let ((gnus-unbuttonized-mime-types nil)
9794 (gnus-mime-display-multipart-as-mixed show-all-parts))
9795 (gnus-summary-show-article)))
9797 (defun gnus-summary-repair-multipart (article)
9798 "Add a Content-Type header to a multipart article without one."
9799 (interactive (list (gnus-summary-article-number)))
9800 (gnus-with-article article
9801 (message-narrow-to-head)
9802 (goto-char (point-max))
9804 (when (search-forward "\n--" nil t)
9805 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9806 (message-narrow-to-head)
9807 (message-remove-header "Mime-Version")
9808 (message-remove-header "Content-Type")
9809 (goto-char (point-max))
9810 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9812 (insert "Mime-Version: 1.0\n")
9814 (let (gnus-mark-article-hook)
9815 (gnus-summary-select-article t t nil article)))
9817 (defun gnus-summary-toggle-display-buttonized ()
9818 "Toggle the buttonizing of the article buffer."
9821 (if (setq gnus-inhibit-mime-unbuttonizing
9822 (not gnus-inhibit-mime-unbuttonizing))
9823 (let ((gnus-unbuttonized-mime-types nil))
9824 (gnus-summary-show-article))
9825 (gnus-summary-show-article)))
9828 ;;; Intelli-mouse commmands
9831 (defun gnus-wheel-summary-scroll (event)
9833 (let ((amount (if (memq 'shift (event-modifiers event))
9834 (car gnus-wheel-scroll-amount)
9835 (cdr gnus-wheel-scroll-amount)))
9836 (direction (- (* (static-if (featurep 'xemacs)
9837 (event-button event)
9838 (cond ((eq 'mouse-4 (event-basic-type event))
9840 ((eq 'mouse-5 (event-basic-type event))
9844 (gnus-summary-scroll-up (* amount direction))
9845 (when (gnus-eval-in-buffer-window gnus-article-buffer
9848 (and (if (< 0 direction)
9849 (gnus-article-next-page 0)
9850 (gnus-article-prev-page 0)
9852 (if (setq edge (get-text-property
9853 (point-min) 'gnus-wheel-edge))
9854 (setq edge (* edge direction))
9857 (let ((buffer-read-only nil)
9858 (inhibit-read-only t))
9859 (put-text-property (point-min) (point-max)
9860 'gnus-wheel-edge direction)
9862 (or (> edge gnus-wheel-edge-resistance)
9863 (let ((buffer-read-only nil)
9864 (inhibit-read-only t))
9865 (put-text-property (point-min) (point-max)
9867 (* (1+ edge) direction))
9869 (eq last-command 'gnus-wheel-summary-scroll))))
9870 (gnus-summary-next-article nil nil (minusp direction)))))
9872 (defun gnus-wheel-install ()
9873 "Enable mouse wheel support on summary window."
9874 (when gnus-use-wheel
9876 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
9878 (define-key gnus-summary-mode-map key
9879 'gnus-wheel-summary-scroll)))))
9881 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
9884 ;;; Traditional PGP commmands
9887 (defun gnus-summary-decrypt-article (&optional force)
9888 "Decrypt the current article in traditional PGP way.
9889 This will have permanent effect only in mail groups.
9890 If FORCE is non-nil, allow editing of articles even in read-only
9893 (gnus-summary-select-article t)
9894 (gnus-eval-in-buffer-window gnus-article-buffer
9898 (goto-char (point-min))
9899 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
9900 (error "Not a traditional PGP message!"))
9901 (let ((armor-start (match-beginning 0)))
9902 (if (and (pgg-decrypt-region armor-start (point-max))
9903 (or force (not (gnus-group-read-only-p))))
9904 (let ((inhibit-read-only t)
9906 (delete-region armor-start
9908 (re-search-forward "^-+END PGP" nil t)
9909 (beginning-of-line 2)
9911 (insert-buffer-substring pgg-output-buffer))))))))
9913 (defun gnus-summary-verify-article ()
9914 "Verify the current article in traditional PGP way."
9917 (set-buffer gnus-original-article-buffer)
9918 (goto-char (point-min))
9919 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
9920 (error "Not a traditional PGP message!"))
9921 (re-search-forward "^-+END PGP" nil t)
9922 (beginning-of-line 2)
9923 (call-interactively (function pgg-verify-region))))
9929 (defmacro gnus-with-article (article &rest forms)
9930 "Select ARTICLE and perform FORMS in the original article buffer.
9931 Then replace the article with the result."
9933 ;; We don't want the article to be marked as read.
9934 (let (gnus-mark-article-hook)
9935 (gnus-summary-select-article t t nil ,article))
9936 (set-buffer gnus-original-article-buffer)
9938 (if (not (gnus-check-backend-function
9939 'request-replace-article (car gnus-article-current)))
9940 (gnus-message 5 "Read-only group; not replacing")
9941 (unless (gnus-request-replace-article
9942 ,article (car gnus-article-current)
9944 (error "Couldn't replace article")))
9945 ;; The cache and backlog have to be flushed somewhat.
9946 (when gnus-keep-backlog
9947 (gnus-backlog-remove-article
9948 (car gnus-article-current) (cdr gnus-article-current)))
9949 (when gnus-use-cache
9950 (gnus-cache-update-article
9951 (car gnus-article-current) (cdr gnus-article-current)))))
9953 (put 'gnus-with-article 'lisp-indent-function 1)
9954 (put 'gnus-with-article 'edebug-form-spec '(form body))
9957 ;;; Generic summary marking commands
9960 (defvar gnus-summary-marking-alist
9961 '((read gnus-del-mark "d")
9962 (unread gnus-unread-mark "u")
9963 (ticked gnus-ticked-mark "!")
9964 (dormant gnus-dormant-mark "?")
9965 (expirable gnus-expirable-mark "e"))
9966 "An alist of names/marks/keystrokes.")
9968 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9969 (defvar gnus-summary-mark-map)
9971 (defun gnus-summary-make-all-marking-commands ()
9972 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9973 (dolist (elem gnus-summary-marking-alist)
9974 (apply 'gnus-summary-make-marking-command elem)))
9976 (defun gnus-summary-make-marking-command (name mark keystroke)
9977 (let ((map (make-sparse-keymap)))
9978 (define-key gnus-summary-generic-mark-map keystroke map)
9979 (dolist (lway `((next "next" next nil "n")
9980 (next-unread "next unread" next t "N")
9981 (prev "previous" prev nil "p")
9982 (prev-unread "previous unread" prev t "P")
9983 (nomove "" nil nil ,keystroke)))
9984 (let ((func (gnus-summary-make-marking-command-1
9985 mark (car lway) lway name)))
9986 (setq func (eval func))
9987 (define-key map (nth 4 lway) func)))))
9989 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9991 (format "gnus-summary-put-mark-as-%s%s"
9992 name (if (eq way 'nomove)
9994 (concat "-" (symbol-name way)))))
9997 "Mark the current article as %s%s.
9998 If N, the prefix, then repeat N times.
9999 If N is negative, move in reverse order.
10000 The difference between N and the actual number of articles marked is
10002 name (car (cdr lway)))
10004 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10006 (defun gnus-summary-generic-mark (n mark move unread)
10007 "Mark N articles with MARK."
10008 (unless (eq major-mode 'gnus-summary-mode)
10009 (error "This command can only be used in the summary buffer"))
10010 (gnus-summary-show-thread)
10013 ((eq move 'next) 1)
10014 ((eq move 'prev) -1)
10016 (if (zerop nummove)
10020 nummove (* -1 nummove))))
10021 (while (and (> n 0)
10022 (gnus-summary-mark-article nil mark)
10023 (zerop (gnus-summary-next-subject nummove unread t)))
10026 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10027 (gnus-summary-recenter)
10028 (gnus-summary-position-point)
10029 (gnus-set-mode-line 'summary)
10032 (gnus-summary-make-all-marking-commands)
10034 (gnus-ems-redefine)
10036 (provide 'gnus-sum)
10038 (run-hooks 'gnus-sum-load-hook)
10040 ;;; gnus-sum.el ends here