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-scores-exclude-files nil)
936 (defvar gnus-page-broken nil)
937 (defvar gnus-inhibit-mime-unbuttonizing nil)
939 (defvar gnus-original-article nil)
940 (defvar gnus-article-internal-prepare-hook nil)
941 (defvar gnus-newsgroup-process-stack nil)
943 (defvar gnus-thread-indent-array nil)
944 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
945 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
946 "Function called to sort the articles within a thread after it has been gathered together.")
948 ;; Avoid highlighting in kill files.
949 (defvar gnus-summary-inhibit-highlight nil)
950 (defvar gnus-newsgroup-selected-overlay nil)
951 (defvar gnus-inhibit-limiting nil)
952 (defvar gnus-newsgroup-adaptive-score-file nil)
953 (defvar gnus-current-score-file nil)
954 (defvar gnus-current-move-group nil)
955 (defvar gnus-current-copy-group nil)
956 (defvar gnus-current-crosspost-group nil)
958 (defvar gnus-newsgroup-dependencies nil)
959 (defvar gnus-newsgroup-adaptive nil)
960 (defvar gnus-summary-display-article-function nil)
961 (defvar gnus-summary-highlight-line-function nil
962 "Function called after highlighting a summary line.")
964 (defvar gnus-summary-line-format-alist
965 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
966 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
967 (?s gnus-tmp-subject-or-nil ?s)
968 (?n gnus-tmp-name ?s)
969 (?A (std11-address-string
970 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
971 (?a (or (std11-full-name-string
972 (car (mime-entity-read-field gnus-tmp-header 'From)))
974 (?F gnus-tmp-from ?s)
975 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
976 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
977 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
978 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
979 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
980 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
981 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
982 (?L gnus-tmp-lines ?d)
983 (?I gnus-tmp-indentation ?s)
984 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
985 (?R gnus-tmp-replied ?c)
986 (?\[ gnus-tmp-opening-bracket ?c)
987 (?\] gnus-tmp-closing-bracket ?c)
988 (?\> (make-string gnus-tmp-level ? ) ?s)
989 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
990 (?i gnus-tmp-score ?d)
991 (?z gnus-tmp-score-char ?c)
992 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
993 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
994 (?U gnus-tmp-unread ?c)
995 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
996 (?t (gnus-summary-number-of-articles-in-thread
997 (and (boundp 'thread) (car thread)) gnus-tmp-level)
999 (?e (gnus-summary-number-of-articles-in-thread
1000 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1002 (?u gnus-tmp-user-defined ?s)
1003 (?P (gnus-pick-line-number) ?d))
1004 "An alist of format specifications that can appear in summary lines,
1005 and what variables they correspond with, along with the type of the
1006 variable (string, integer, character, etc).")
1008 (defvar gnus-summary-dummy-line-format-alist
1009 `((?S gnus-tmp-subject ?s)
1010 (?N gnus-tmp-number ?d)
1011 (?u gnus-tmp-user-defined ?s)))
1013 (defvar gnus-summary-mode-line-format-alist
1014 `((?G gnus-tmp-group-name ?s)
1015 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1016 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1017 (?A gnus-tmp-article-number ?d)
1018 (?Z gnus-tmp-unread-and-unselected ?s)
1019 (?V gnus-version ?s)
1020 (?U gnus-tmp-unread-and-unticked ?d)
1021 (?S gnus-tmp-subject ?s)
1022 (?e gnus-tmp-unselected ?d)
1023 (?u gnus-tmp-user-defined ?s)
1024 (?d (length gnus-newsgroup-dormant) ?d)
1025 (?t (length gnus-newsgroup-marked) ?d)
1026 (?r (length gnus-newsgroup-reads) ?d)
1027 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1028 (?E gnus-newsgroup-expunged-tally ?d)
1029 (?s (gnus-current-score-file-nondirectory) ?s)))
1031 (defvar gnus-last-search-regexp nil
1032 "Default regexp for article search command.")
1034 (defvar gnus-summary-search-article-matched-data nil
1035 "Last matched data of article search command. It is the local variable
1036 in `gnus-article-buffer' which consists of the list of start position,
1037 end position and text.")
1039 (defvar gnus-last-shell-command nil
1040 "Default shell command on article.")
1042 (defvar gnus-newsgroup-begin nil)
1043 (defvar gnus-newsgroup-end nil)
1044 (defvar gnus-newsgroup-last-rmail nil)
1045 (defvar gnus-newsgroup-last-mail nil)
1046 (defvar gnus-newsgroup-last-folder nil)
1047 (defvar gnus-newsgroup-last-file nil)
1048 (defvar gnus-newsgroup-auto-expire nil)
1049 (defvar gnus-newsgroup-active nil)
1051 (defvar gnus-newsgroup-data nil)
1052 (defvar gnus-newsgroup-data-reverse nil)
1053 (defvar gnus-newsgroup-limit nil)
1054 (defvar gnus-newsgroup-limits nil)
1056 (defvar gnus-newsgroup-unreads nil
1057 "List of unread articles in the current newsgroup.")
1059 (defvar gnus-newsgroup-unselected nil
1060 "List of unselected unread articles in the current newsgroup.")
1062 (defvar gnus-newsgroup-reads nil
1063 "Alist of read articles and article marks in the current newsgroup.")
1065 (defvar gnus-newsgroup-expunged-tally nil)
1067 (defvar gnus-newsgroup-marked nil
1068 "List of ticked articles in the current newsgroup (a subset of unread art).")
1070 (defvar gnus-newsgroup-killed nil
1071 "List of ranges of articles that have been through the scoring process.")
1073 (defvar gnus-newsgroup-cached nil
1074 "List of articles that come from the article cache.")
1076 (defvar gnus-newsgroup-saved nil
1077 "List of articles that have been saved.")
1079 (defvar gnus-newsgroup-kill-headers nil)
1081 (defvar gnus-newsgroup-replied nil
1082 "List of articles that have been replied to in the current newsgroup.")
1084 (defvar gnus-newsgroup-expirable nil
1085 "List of articles in the current newsgroup that can be expired.")
1087 (defvar gnus-newsgroup-processable nil
1088 "List of articles in the current newsgroup that can be processed.")
1090 (defvar gnus-newsgroup-downloadable nil
1091 "List of articles in the current newsgroup that can be processed.")
1093 (defvar gnus-newsgroup-undownloaded nil
1094 "List of articles in the current newsgroup that haven't been downloaded..")
1096 (defvar gnus-newsgroup-unsendable nil
1097 "List of articles in the current newsgroup that won't be sent.")
1099 (defvar gnus-newsgroup-bookmarks nil
1100 "List of articles in the current newsgroup that have bookmarks.")
1102 (defvar gnus-newsgroup-dormant nil
1103 "List of dormant articles in the current newsgroup.")
1105 (defvar gnus-newsgroup-scored nil
1106 "List of scored articles in the current newsgroup.")
1108 (defvar gnus-newsgroup-incorporated nil
1109 "List of incorporated articles in the current newsgroup.")
1111 (defvar gnus-newsgroup-headers nil
1112 "List of article headers in the current newsgroup.")
1114 (defvar gnus-newsgroup-threads nil)
1116 (defvar gnus-newsgroup-prepared nil
1117 "Whether the current group has been prepared properly.")
1119 (defvar gnus-newsgroup-ancient nil
1120 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1122 (defvar gnus-newsgroup-sparse nil)
1124 (defvar gnus-current-article nil)
1125 (defvar gnus-article-current nil)
1126 (defvar gnus-current-headers nil)
1127 (defvar gnus-have-all-headers nil)
1128 (defvar gnus-last-article nil)
1129 (defvar gnus-newsgroup-history nil)
1130 (defvar gnus-newsgroup-charset nil)
1131 (defvar gnus-newsgroup-ephemeral-charset nil)
1132 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1134 (defconst gnus-summary-local-variables
1135 '(gnus-newsgroup-name
1136 gnus-newsgroup-begin gnus-newsgroup-end
1137 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1138 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1139 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1140 gnus-newsgroup-unselected gnus-newsgroup-marked
1141 gnus-newsgroup-reads gnus-newsgroup-saved
1142 gnus-newsgroup-replied gnus-newsgroup-expirable
1143 gnus-newsgroup-processable gnus-newsgroup-killed
1144 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1145 gnus-newsgroup-unsendable
1146 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1147 gnus-newsgroup-headers gnus-newsgroup-threads
1148 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1149 gnus-current-article gnus-current-headers gnus-have-all-headers
1150 gnus-last-article gnus-article-internal-prepare-hook
1151 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1152 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1153 gnus-thread-expunge-below
1154 gnus-score-alist gnus-current-score-file
1155 (gnus-summary-expunge-below . global)
1156 (gnus-summary-mark-below . global)
1157 gnus-newsgroup-active gnus-scores-exclude-files
1158 gnus-newsgroup-history gnus-newsgroup-ancient
1159 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1160 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1161 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1162 (gnus-newsgroup-expunged-tally . 0)
1163 gnus-cache-removable-articles gnus-newsgroup-cached
1164 gnus-newsgroup-data gnus-newsgroup-data-reverse
1165 gnus-newsgroup-limit gnus-newsgroup-limits
1166 gnus-newsgroup-charset
1167 gnus-newsgroup-incorporated)
1168 "Variables that are buffer-local to the summary buffers.")
1170 ;; Byte-compiler warning.
1171 (defvar gnus-article-mode-map)
1173 ;; Subject simplification.
1175 (defun gnus-simplify-whitespace (str)
1176 "Remove excessive whitespace."
1179 (while (string-match "[ \t][ \t]+" mystr)
1180 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1182 (substring mystr (match-end 0)))))
1184 (when (string-match "^[ \t]+" mystr)
1185 (setq mystr (substring mystr (match-end 0))))
1187 (when (string-match "[ \t]+$" mystr)
1188 (setq mystr (substring mystr 0 (match-beginning 0))))
1191 (defsubst gnus-simplify-subject-re (subject)
1192 "Remove \"Re:\" from subject lines."
1193 (if (string-match "^[Rr][Ee]: *" subject)
1194 (substring subject (match-end 0))
1197 (defun gnus-simplify-subject (subject &optional re-only)
1198 "Remove `Re:' and words in parentheses.
1199 If RE-ONLY is non-nil, strip leading `Re:'s only."
1200 (let ((case-fold-search t)) ;Ignore case.
1201 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1202 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1203 (setq subject (substring subject (match-end 0))))
1204 ;; Remove uninteresting prefixes.
1205 (when (and (not re-only)
1206 gnus-simplify-ignored-prefixes
1207 (string-match gnus-simplify-ignored-prefixes subject))
1208 (setq subject (substring subject (match-end 0))))
1209 ;; Remove words in parentheses from end.
1211 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1212 (setq subject (substring subject 0 (match-beginning 0)))))
1213 ;; Return subject string.
1216 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1218 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1219 (goto-char (point-min))
1220 (while (re-search-forward regexp nil t)
1221 (replace-match (or newtext ""))))
1223 (defun gnus-simplify-buffer-fuzzy ()
1224 "Simplify string in the buffer fuzzily.
1225 The string in the accessible portion of the current buffer is simplified.
1226 It is assumed to be a single-line subject.
1227 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1228 matter is removed. Additional things can be deleted by setting
1229 gnus-simplify-subject-fuzzy-regexp."
1230 (let ((case-fold-search t)
1232 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1234 (while (not (eq modified-tick (buffer-modified-tick)))
1235 (setq modified-tick (buffer-modified-tick))
1237 ((listp gnus-simplify-subject-fuzzy-regexp)
1238 (mapcar 'gnus-simplify-buffer-fuzzy-step
1239 gnus-simplify-subject-fuzzy-regexp))
1240 (gnus-simplify-subject-fuzzy-regexp
1241 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1242 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1243 (gnus-simplify-buffer-fuzzy-step
1244 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1245 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1247 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1248 (gnus-simplify-buffer-fuzzy-step " +" " ")
1249 (gnus-simplify-buffer-fuzzy-step " $")
1250 (gnus-simplify-buffer-fuzzy-step "^ +")))
1252 (defun gnus-simplify-subject-fuzzy (subject)
1253 "Simplify a subject string fuzzily.
1254 See `gnus-simplify-buffer-fuzzy' for details."
1256 (gnus-set-work-buffer)
1257 (let ((case-fold-search t))
1258 ;; Remove uninteresting prefixes.
1259 (when (and gnus-simplify-ignored-prefixes
1260 (string-match gnus-simplify-ignored-prefixes subject))
1261 (setq subject (substring subject (match-end 0))))
1263 (inline (gnus-simplify-buffer-fuzzy))
1266 (defsubst gnus-simplify-subject-fully (subject)
1267 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1269 (gnus-simplify-subject-functions
1270 (gnus-map-function gnus-simplify-subject-functions subject))
1271 ((null gnus-summary-gather-subject-limit)
1272 (gnus-simplify-subject-re subject))
1273 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1274 (gnus-simplify-subject-fuzzy subject))
1275 ((numberp gnus-summary-gather-subject-limit)
1276 (gnus-limit-string (gnus-simplify-subject-re subject)
1277 gnus-summary-gather-subject-limit))
1281 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1282 "Check whether two subjects are equal.
1283 If optional argument simple-first is t, first argument is already
1286 ((null simple-first)
1287 (equal (gnus-simplify-subject-fully s1)
1288 (gnus-simplify-subject-fully s2)))
1291 (gnus-simplify-subject-fully s2)))))
1293 (defun gnus-summary-bubble-group ()
1294 "Increase the score of the current group.
1295 This is a handy function to add to `gnus-summary-exit-hook' to
1296 increase the score of each group you read."
1297 (gnus-group-add-score gnus-newsgroup-name))
1301 ;;; Gnus summary mode
1304 (put 'gnus-summary-mode 'mode-class 'special)
1307 ;; Non-orthogonal keys
1309 (gnus-define-keys gnus-summary-mode-map
1310 " " gnus-summary-next-page
1311 "\177" gnus-summary-prev-page
1312 [delete] gnus-summary-prev-page
1313 [backspace] gnus-summary-prev-page
1314 "\r" gnus-summary-scroll-up
1315 "\M-\r" gnus-summary-scroll-down
1316 "n" gnus-summary-next-unread-article
1317 "p" gnus-summary-prev-unread-article
1318 "N" gnus-summary-next-article
1319 "P" gnus-summary-prev-article
1320 "\M-\C-n" gnus-summary-next-same-subject
1321 "\M-\C-p" gnus-summary-prev-same-subject
1322 "\M-n" gnus-summary-next-unread-subject
1323 "\M-p" gnus-summary-prev-unread-subject
1324 "." gnus-summary-first-unread-article
1325 "," gnus-summary-best-unread-article
1326 "\M-s" gnus-summary-search-article-forward
1327 "\M-r" gnus-summary-search-article-backward
1328 "<" gnus-summary-beginning-of-article
1329 ">" gnus-summary-end-of-article
1330 "j" gnus-summary-goto-article
1331 "^" gnus-summary-refer-parent-article
1332 "\M-^" gnus-summary-refer-article
1333 "u" gnus-summary-tick-article-forward
1334 "!" gnus-summary-tick-article-forward
1335 "U" gnus-summary-tick-article-backward
1336 "d" gnus-summary-mark-as-read-forward
1337 "D" gnus-summary-mark-as-read-backward
1338 "E" gnus-summary-mark-as-expirable
1339 "\M-u" gnus-summary-clear-mark-forward
1340 "\M-U" gnus-summary-clear-mark-backward
1341 "k" gnus-summary-kill-same-subject-and-select
1342 "\C-k" gnus-summary-kill-same-subject
1343 "\M-\C-k" gnus-summary-kill-thread
1344 "\M-\C-l" gnus-summary-lower-thread
1345 "e" gnus-summary-edit-article
1346 "#" gnus-summary-mark-as-processable
1347 "\M-#" gnus-summary-unmark-as-processable
1348 "\M-\C-t" gnus-summary-toggle-threads
1349 "\M-\C-s" gnus-summary-show-thread
1350 "\M-\C-h" gnus-summary-hide-thread
1351 "\M-\C-f" gnus-summary-next-thread
1352 "\M-\C-b" gnus-summary-prev-thread
1353 [(meta down)] gnus-summary-next-thread
1354 [(meta up)] gnus-summary-prev-thread
1355 "\M-\C-u" gnus-summary-up-thread
1356 "\M-\C-d" gnus-summary-down-thread
1357 "&" gnus-summary-execute-command
1358 "c" gnus-summary-catchup-and-exit
1359 "\C-w" gnus-summary-mark-region-as-read
1360 "\C-t" gnus-summary-toggle-truncation
1361 "?" gnus-summary-mark-as-dormant
1362 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1363 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1364 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1365 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1366 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1367 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1368 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1369 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1370 "=" gnus-summary-expand-window
1371 "\C-x\C-s" gnus-summary-reselect-current-group
1372 "\M-g" gnus-summary-rescan-group
1373 "w" gnus-summary-stop-page-breaking
1374 "\C-c\C-r" gnus-summary-caesar-message
1375 "\M-t" gnus-summary-toggle-mime
1376 "f" gnus-summary-followup
1377 "F" gnus-summary-followup-with-original
1378 "C" gnus-summary-cancel-article
1379 "r" gnus-summary-reply
1380 "R" gnus-summary-reply-with-original
1381 "\C-c\C-f" gnus-summary-mail-forward
1382 "o" gnus-summary-save-article
1383 "\C-o" gnus-summary-save-article-mail
1384 "|" gnus-summary-pipe-output
1385 "\M-k" gnus-summary-edit-local-kill
1386 "\M-K" gnus-summary-edit-global-kill
1388 "\C-c\C-d" gnus-summary-describe-group
1389 "q" gnus-summary-exit
1390 "Q" gnus-summary-exit-no-update
1391 "\C-c\C-i" gnus-info-find-node
1392 gnus-mouse-2 gnus-mouse-pick-article
1393 "m" gnus-summary-mail-other-window
1394 "a" gnus-summary-post-news
1395 "x" gnus-summary-limit-to-unread
1396 "s" gnus-summary-isearch-article
1397 "t" gnus-article-toggle-headers
1398 "g" gnus-summary-show-article
1399 "l" gnus-summary-goto-last-article
1400 "v" gnus-summary-preview-mime-message
1401 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1402 "\C-d" gnus-summary-enter-digest-group
1403 "\M-\C-d" gnus-summary-read-document
1404 "\M-\C-e" gnus-summary-edit-parameters
1405 "\M-\C-a" gnus-summary-customize-parameters
1407 "*" gnus-cache-enter-article
1408 "\M-*" gnus-cache-remove-article
1409 "\M-&" gnus-summary-universal-argument
1410 "\C-l" gnus-recenter
1411 "I" gnus-summary-increase-score
1412 "L" gnus-summary-lower-score
1413 "\M-i" gnus-symbolic-argument
1414 "h" gnus-summary-select-article-buffer
1416 "V" gnus-summary-score-map
1417 "X" gnus-uu-extract-map
1418 "S" gnus-summary-send-map)
1420 ;; Sort of orthogonal keymap
1421 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1422 "t" gnus-summary-tick-article-forward
1423 "!" gnus-summary-tick-article-forward
1424 "d" gnus-summary-mark-as-read-forward
1425 "r" gnus-summary-mark-as-read-forward
1426 "c" gnus-summary-clear-mark-forward
1427 " " gnus-summary-clear-mark-forward
1428 "e" gnus-summary-mark-as-expirable
1429 "x" gnus-summary-mark-as-expirable
1430 "?" gnus-summary-mark-as-dormant
1431 "b" gnus-summary-set-bookmark
1432 "B" gnus-summary-remove-bookmark
1433 "#" gnus-summary-mark-as-processable
1434 "\M-#" gnus-summary-unmark-as-processable
1435 "S" gnus-summary-limit-include-expunged
1436 "C" gnus-summary-catchup
1437 "H" gnus-summary-catchup-to-here
1438 "\C-c" gnus-summary-catchup-all
1439 "k" gnus-summary-kill-same-subject-and-select
1440 "K" gnus-summary-kill-same-subject
1441 "P" gnus-uu-mark-map)
1443 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1444 "c" gnus-summary-clear-above
1445 "u" gnus-summary-tick-above
1446 "m" gnus-summary-mark-above
1447 "k" gnus-summary-kill-below)
1449 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1450 "/" gnus-summary-limit-to-subject
1451 "n" gnus-summary-limit-to-articles
1452 "w" gnus-summary-pop-limit
1453 "s" gnus-summary-limit-to-subject
1454 "a" gnus-summary-limit-to-author
1455 "u" gnus-summary-limit-to-unread
1456 "m" gnus-summary-limit-to-marks
1457 "M" gnus-summary-limit-exclude-marks
1458 "v" gnus-summary-limit-to-score
1459 "*" gnus-summary-limit-include-cached
1460 "D" gnus-summary-limit-include-dormant
1461 "T" gnus-summary-limit-include-thread
1462 "d" gnus-summary-limit-exclude-dormant
1463 "t" gnus-summary-limit-to-age
1464 "x" gnus-summary-limit-to-extra
1465 "E" gnus-summary-limit-include-expunged
1466 "c" gnus-summary-limit-exclude-childless-dormant
1467 "C" gnus-summary-limit-mark-excluded-as-read)
1469 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1470 "n" gnus-summary-next-unread-article
1471 "p" gnus-summary-prev-unread-article
1472 "N" gnus-summary-next-article
1473 "P" gnus-summary-prev-article
1474 "\C-n" gnus-summary-next-same-subject
1475 "\C-p" gnus-summary-prev-same-subject
1476 "\M-n" gnus-summary-next-unread-subject
1477 "\M-p" gnus-summary-prev-unread-subject
1478 "f" gnus-summary-first-unread-article
1479 "b" gnus-summary-best-unread-article
1480 "j" gnus-summary-goto-article
1481 "g" gnus-summary-goto-subject
1482 "l" gnus-summary-goto-last-article
1483 "o" gnus-summary-pop-article)
1485 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1486 "k" gnus-summary-kill-thread
1487 "l" gnus-summary-lower-thread
1488 "i" gnus-summary-raise-thread
1489 "T" gnus-summary-toggle-threads
1490 "t" gnus-summary-rethread-current
1491 "^" gnus-summary-reparent-thread
1492 "s" gnus-summary-show-thread
1493 "S" gnus-summary-show-all-threads
1494 "h" gnus-summary-hide-thread
1495 "H" gnus-summary-hide-all-threads
1496 "n" gnus-summary-next-thread
1497 "p" gnus-summary-prev-thread
1498 "u" gnus-summary-up-thread
1499 "o" gnus-summary-top-thread
1500 "d" gnus-summary-down-thread
1501 "#" gnus-uu-mark-thread
1502 "\M-#" gnus-uu-unmark-thread)
1504 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1505 "g" gnus-summary-prepare
1506 "c" gnus-summary-insert-cached-articles)
1508 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1509 "c" gnus-summary-catchup-and-exit
1510 "C" gnus-summary-catchup-all-and-exit
1511 "E" gnus-summary-exit-no-update
1512 "J" gnus-summary-jump-to-other-group
1513 "Q" gnus-summary-exit
1514 "Z" gnus-summary-exit
1515 "n" gnus-summary-catchup-and-goto-next-group
1516 "R" gnus-summary-reselect-current-group
1517 "G" gnus-summary-rescan-group
1518 "N" gnus-summary-next-group
1519 "s" gnus-summary-save-newsrc
1520 "P" gnus-summary-prev-group)
1522 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1523 " " gnus-summary-next-page
1524 "n" gnus-summary-next-page
1525 "\177" gnus-summary-prev-page
1526 [delete] gnus-summary-prev-page
1527 "p" gnus-summary-prev-page
1528 "\r" gnus-summary-scroll-up
1529 "\M-\r" gnus-summary-scroll-down
1530 "<" gnus-summary-beginning-of-article
1531 ">" gnus-summary-end-of-article
1532 "b" gnus-summary-beginning-of-article
1533 "e" gnus-summary-end-of-article
1534 "^" gnus-summary-refer-parent-article
1535 "r" gnus-summary-refer-parent-article
1536 "D" gnus-summary-enter-digest-group
1537 "R" gnus-summary-refer-references
1538 "T" gnus-summary-refer-thread
1539 "g" gnus-summary-show-article
1540 "s" gnus-summary-isearch-article
1541 "P" gnus-summary-print-article
1542 "t" gnus-article-babel
1543 "d" gnus-summary-decrypt-article
1544 "v" gnus-summary-verify-article)
1546 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1547 "b" gnus-article-add-buttons
1548 "B" gnus-article-add-buttons-to-head
1549 "o" gnus-article-treat-overstrike
1550 "e" gnus-article-emphasize
1551 "w" gnus-article-fill-cited-article
1552 "Q" gnus-article-fill-long-lines
1553 "C" gnus-article-capitalize-sentences
1554 "c" gnus-article-remove-cr
1555 "f" gnus-article-display-x-face
1556 "l" gnus-summary-stop-page-breaking
1557 "r" gnus-summary-caesar-message
1558 "t" gnus-article-toggle-headers
1559 "v" gnus-summary-verbose-headers
1560 "m" gnus-summary-toggle-mime
1561 "H" gnus-article-strip-headers-in-body
1562 "d" gnus-article-treat-dumbquotes
1563 "s" gnus-smiley-display)
1565 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1566 "a" gnus-article-hide
1567 "h" gnus-article-toggle-headers
1568 "b" gnus-article-hide-boring-headers
1569 "s" gnus-article-hide-signature
1570 "c" gnus-article-hide-citation
1571 "C" gnus-article-hide-citation-in-followups
1572 "l" gnus-article-hide-list-identifiers
1573 "p" gnus-article-hide-pgp
1574 "B" gnus-article-strip-banner
1575 "P" gnus-article-hide-pem
1576 "\C-c" gnus-article-hide-citation-maybe)
1578 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1579 "a" gnus-article-highlight
1580 "h" gnus-article-highlight-headers
1581 "c" gnus-article-highlight-citation
1582 "s" gnus-article-highlight-signature)
1584 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1585 "z" gnus-article-date-ut
1586 "u" gnus-article-date-ut
1587 "l" gnus-article-date-local
1588 "e" gnus-article-date-lapsed
1589 "o" gnus-article-date-original
1590 "i" gnus-article-date-iso8601
1591 "s" gnus-article-date-user)
1593 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1594 "t" gnus-article-remove-trailing-blank-lines
1595 "l" gnus-article-strip-leading-blank-lines
1596 "m" gnus-article-strip-multiple-blank-lines
1597 "a" gnus-article-strip-blank-lines
1598 "A" gnus-article-strip-all-blank-lines
1599 "s" gnus-article-strip-leading-space
1600 "e" gnus-article-strip-trailing-space)
1602 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1604 "f" gnus-summary-fetch-faq
1605 "d" gnus-summary-describe-group
1606 "h" gnus-summary-describe-briefly
1607 "i" gnus-info-find-node)
1609 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1610 "e" gnus-summary-expire-articles
1611 "\M-\C-e" gnus-summary-expire-articles-now
1612 "\177" gnus-summary-delete-article
1613 [delete] gnus-summary-delete-article
1614 [backspace] gnus-summary-delete-article
1615 "m" gnus-summary-move-article
1616 "r" gnus-summary-respool-article
1617 "w" gnus-summary-edit-article
1618 "c" gnus-summary-copy-article
1619 "B" gnus-summary-crosspost-article
1620 "q" gnus-summary-respool-query
1621 "t" gnus-summary-respool-trace
1622 "i" gnus-summary-import-article
1623 "p" gnus-summary-article-posted-p)
1625 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1626 "o" gnus-summary-save-article
1627 "m" gnus-summary-save-article-mail
1628 "F" gnus-summary-write-article-file
1629 "r" gnus-summary-save-article-rmail
1630 "f" gnus-summary-save-article-file
1631 "b" gnus-summary-save-article-body-file
1632 "h" gnus-summary-save-article-folder
1633 "v" gnus-summary-save-article-vm
1634 "p" gnus-summary-pipe-output
1635 "s" gnus-soup-add-article)
1637 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1638 "b" gnus-summary-display-buttonized
1639 "m" gnus-summary-repair-multipart
1640 "v" gnus-article-view-part
1641 "o" gnus-article-save-part
1642 "c" gnus-article-copy-part
1643 "e" gnus-article-externalize-part
1644 "i" gnus-article-inline-part
1645 "|" gnus-article-pipe-part))
1647 (defun gnus-summary-make-menu-bar ()
1648 (gnus-turn-off-edit-menu 'summary)
1650 (unless (boundp 'gnus-summary-misc-menu)
1653 gnus-summary-kill-menu gnus-summary-mode-map ""
1658 ["Enter score..." gnus-summary-score-entry t]
1659 ["Customize" gnus-score-customize t])
1660 (gnus-make-score-map 'increase)
1661 (gnus-make-score-map 'lower)
1663 ["Kill below" gnus-summary-kill-below t]
1664 ["Mark above" gnus-summary-mark-above t]
1665 ["Tick above" gnus-summary-tick-above t]
1666 ["Clear above" gnus-summary-clear-above t])
1667 ["Current score" gnus-summary-current-score t]
1668 ["Set score" gnus-summary-set-score t]
1669 ["Switch current score file..." gnus-score-change-score-file t]
1670 ["Set mark below..." gnus-score-set-mark-below t]
1671 ["Set expunge below..." gnus-score-set-expunge-below t]
1672 ["Edit current score file" gnus-score-edit-current-scores t]
1673 ["Edit score file" gnus-score-edit-file t]
1674 ["Trace score" gnus-score-find-trace t]
1675 ["Find words" gnus-score-find-favourite-words t]
1676 ["Rescore buffer" gnus-summary-rescore t]
1677 ["Increase score..." gnus-summary-increase-score t]
1678 ["Lower score..." gnus-summary-lower-score t]))))
1680 ;; Define both the Article menu in the summary buffer and the equivalent
1681 ;; Commands menu in the article buffer here for consistency.
1684 ["All" gnus-article-hide t]
1685 ["Headers" gnus-article-toggle-headers t]
1686 ["Signature" gnus-article-hide-signature t]
1687 ["Citation" gnus-article-hide-citation t]
1688 ["List identifiers" gnus-article-hide-list-identifiers t]
1689 ["PGP" gnus-article-hide-pgp t]
1690 ["Banner" gnus-article-strip-banner t]
1691 ["Boring headers" gnus-article-hide-boring-headers t])
1693 ["All" gnus-article-highlight t]
1694 ["Headers" gnus-article-highlight-headers t]
1695 ["Signature" gnus-article-highlight-signature t]
1696 ["Citation" gnus-article-highlight-citation t])
1698 ["Local" gnus-article-date-local t]
1699 ["ISO8601" gnus-article-date-iso8601 t]
1700 ["UT" gnus-article-date-ut t]
1701 ["Original" gnus-article-date-original t]
1702 ["Lapsed" gnus-article-date-lapsed t]
1703 ["User-defined" gnus-article-date-user t])
1706 ["Leading" gnus-article-strip-leading-blank-lines t]
1707 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1708 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1709 ["All of the above" gnus-article-strip-blank-lines t]
1710 ["All" gnus-article-strip-all-blank-lines t]
1711 ["Leading space" gnus-article-strip-leading-space t]
1712 ["Trailing space" gnus-article-strip-trailing-space t])
1713 ["Overstrike" gnus-article-treat-overstrike t]
1714 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1715 ["Emphasis" gnus-article-emphasize t]
1716 ["Word wrap" gnus-article-fill-cited-article t]
1717 ["Fill long lines" gnus-article-fill-long-lines t]
1718 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1719 ["CR" gnus-article-remove-cr t]
1720 ["Show X-Face" gnus-article-display-x-face t]
1721 ["Rot 13" gnus-summary-caesar-message t]
1722 ["Unix pipe" gnus-summary-pipe-message t]
1723 ["Add buttons" gnus-article-add-buttons t]
1724 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1725 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1726 ["Toggle MIME" gnus-summary-toggle-mime t]
1727 ["Verbose header" gnus-summary-verbose-headers t]
1728 ["Toggle header" gnus-summary-toggle-header t]
1729 ["Toggle smileys" gnus-smiley-display t]
1730 ["HZ" gnus-article-decode-HZ t])
1732 ["Save in default format" gnus-summary-save-article t]
1733 ["Save in file" gnus-summary-save-article-file t]
1734 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1735 ["Save in MH folder" gnus-summary-save-article-folder t]
1736 ["Save in VM folder" gnus-summary-save-article-vm t]
1737 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1738 ["Save body in file" gnus-summary-save-article-body-file t]
1739 ["Pipe through a filter" gnus-summary-pipe-output t]
1740 ["Add to SOUP packet" gnus-soup-add-article t]
1741 ["Print" gnus-summary-print-article t])
1743 ["Respool article..." gnus-summary-respool-article t]
1744 ["Move article..." gnus-summary-move-article
1745 (gnus-check-backend-function
1746 'request-move-article gnus-newsgroup-name)]
1747 ["Copy article..." gnus-summary-copy-article t]
1748 ["Crosspost article..." gnus-summary-crosspost-article
1749 (gnus-check-backend-function
1750 'request-replace-article gnus-newsgroup-name)]
1751 ["Import file..." gnus-summary-import-article t]
1752 ["Check if posted" gnus-summary-article-posted-p t]
1753 ["Edit article" gnus-summary-edit-article
1754 (not (gnus-group-read-only-p))]
1755 ["Delete article" gnus-summary-delete-article
1756 (gnus-check-backend-function
1757 'request-expire-articles gnus-newsgroup-name)]
1758 ["Query respool" gnus-summary-respool-query t]
1759 ["Trace respool" gnus-summary-respool-trace t]
1760 ["Delete expirable articles" gnus-summary-expire-articles-now
1761 (gnus-check-backend-function
1762 'request-expire-articles gnus-newsgroup-name)])
1764 ["Uudecode" gnus-uu-decode-uu t]
1765 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1766 ["Unshar" gnus-uu-decode-unshar t]
1767 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1768 ["Save" gnus-uu-decode-save t]
1769 ["Binhex" gnus-uu-decode-binhex t]
1770 ["Postscript" gnus-uu-decode-postscript t])
1772 ["Enter article" gnus-cache-enter-article t]
1773 ["Remove article" gnus-cache-remove-article t])
1774 ["Translate" gnus-article-babel t]
1775 ["Select article buffer" gnus-summary-select-article-buffer t]
1776 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1777 ["Isearch article..." gnus-summary-isearch-article t]
1778 ["Beginning of the article" gnus-summary-beginning-of-article t]
1779 ["End of the article" gnus-summary-end-of-article t]
1780 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1781 ["Fetch referenced articles" gnus-summary-refer-references t]
1782 ["Fetch current thread" gnus-summary-refer-thread t]
1783 ["Fetch article with id..." gnus-summary-refer-article t]
1784 ["Redisplay" gnus-summary-show-article t])))
1786 gnus-summary-article-menu gnus-summary-mode-map ""
1787 (cons "Article" innards))
1790 gnus-article-commands-menu gnus-article-mode-map ""
1791 (cons "Commands" innards)))
1794 gnus-summary-thread-menu gnus-summary-mode-map ""
1796 ["Toggle threading" gnus-summary-toggle-threads t]
1797 ["Hide threads" gnus-summary-hide-all-threads t]
1798 ["Show threads" gnus-summary-show-all-threads t]
1799 ["Hide thread" gnus-summary-hide-thread t]
1800 ["Show thread" gnus-summary-show-thread t]
1801 ["Go to next thread" gnus-summary-next-thread t]
1802 ["Go to previous thread" gnus-summary-prev-thread t]
1803 ["Go down thread" gnus-summary-down-thread t]
1804 ["Go up thread" gnus-summary-up-thread t]
1805 ["Top of thread" gnus-summary-top-thread t]
1806 ["Mark thread as read" gnus-summary-kill-thread t]
1807 ["Lower thread score" gnus-summary-lower-thread t]
1808 ["Raise thread score" gnus-summary-raise-thread t]
1809 ["Rethread current" gnus-summary-rethread-current t]))
1812 gnus-summary-post-menu gnus-summary-mode-map ""
1814 ["Post an article" gnus-summary-post-news t]
1815 ["Followup" gnus-summary-followup t]
1816 ["Followup and yank" gnus-summary-followup-with-original t]
1817 ["Supersede article" gnus-summary-supersede-article t]
1818 ["Cancel article" gnus-summary-cancel-article t]
1819 ["Reply" gnus-summary-reply t]
1820 ["Reply and yank" gnus-summary-reply-with-original t]
1821 ["Wide reply" gnus-summary-wide-reply t]
1822 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1823 ["Mail forward" gnus-summary-mail-forward t]
1824 ["Post forward" gnus-summary-post-forward t]
1825 ["Digest and mail" gnus-summary-mail-digest t]
1826 ["Digest and post" gnus-summary-post-digest t]
1827 ["Resend message" gnus-summary-resend-message t]
1828 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1829 ["Send a mail" gnus-summary-mail-other-window t]
1830 ["Uuencode and post" gnus-uu-post-news t]
1831 ["Followup via news" gnus-summary-followup-to-mail t]
1832 ["Followup via news and yank"
1833 gnus-summary-followup-to-mail-with-original t]
1835 ;;["Send" gnus-summary-send-draft t]
1836 ;;["Send bounced" gnus-resend-bounced-mail t])
1840 gnus-summary-misc-menu gnus-summary-mode-map ""
1843 ["Mark as read" gnus-summary-mark-as-read-forward t]
1844 ["Mark same subject and select"
1845 gnus-summary-kill-same-subject-and-select t]
1846 ["Mark same subject" gnus-summary-kill-same-subject t]
1847 ["Catchup" gnus-summary-catchup t]
1848 ["Catchup all" gnus-summary-catchup-all t]
1849 ["Catchup to here" gnus-summary-catchup-to-here t]
1850 ["Catchup region" gnus-summary-mark-region-as-read t]
1851 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1853 ["Tick" gnus-summary-tick-article-forward t]
1854 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1855 ["Remove marks" gnus-summary-clear-mark-forward t]
1856 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1857 ["Set bookmark" gnus-summary-set-bookmark t]
1858 ["Remove bookmark" gnus-summary-remove-bookmark t])
1860 ["Marks..." gnus-summary-limit-to-marks t]
1861 ["Subject..." gnus-summary-limit-to-subject t]
1862 ["Author..." gnus-summary-limit-to-author t]
1863 ["Age..." gnus-summary-limit-to-age t]
1864 ["Extra..." gnus-summary-limit-to-extra t]
1865 ["Score" gnus-summary-limit-to-score t]
1866 ["Unread" gnus-summary-limit-to-unread t]
1867 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1868 ["Articles" gnus-summary-limit-to-articles t]
1869 ["Pop limit" gnus-summary-pop-limit t]
1870 ["Show dormant" gnus-summary-limit-include-dormant t]
1871 ["Hide childless dormant"
1872 gnus-summary-limit-exclude-childless-dormant t]
1873 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1874 ["Hide marked" gnus-summary-limit-exclude-marks t]
1875 ["Show expunged" gnus-summary-show-all-expunged t])
1877 ["Set mark" gnus-summary-mark-as-processable t]
1878 ["Remove mark" gnus-summary-unmark-as-processable t]
1879 ["Remove all marks" gnus-summary-unmark-all-processable t]
1880 ["Mark above" gnus-uu-mark-over t]
1881 ["Mark series" gnus-uu-mark-series t]
1882 ["Mark region" gnus-uu-mark-region t]
1883 ["Unmark region" gnus-uu-unmark-region t]
1884 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1885 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1886 ["Mark all" gnus-uu-mark-all t]
1887 ["Mark buffer" gnus-uu-mark-buffer t]
1888 ["Mark sparse" gnus-uu-mark-sparse t]
1889 ["Mark thread" gnus-uu-mark-thread t]
1890 ["Unmark thread" gnus-uu-unmark-thread t]
1891 ("Process Mark Sets"
1892 ["Kill" gnus-summary-kill-process-mark t]
1893 ["Yank" gnus-summary-yank-process-mark
1894 gnus-newsgroup-process-stack]
1895 ["Save" gnus-summary-save-process-mark t]))
1897 ["Page forward" gnus-summary-next-page t]
1898 ["Page backward" gnus-summary-prev-page t]
1899 ["Line forward" gnus-summary-scroll-up t])
1901 ["Next unread article" gnus-summary-next-unread-article t]
1902 ["Previous unread article" gnus-summary-prev-unread-article t]
1903 ["Next article" gnus-summary-next-article t]
1904 ["Previous article" gnus-summary-prev-article t]
1905 ["Next unread subject" gnus-summary-next-unread-subject t]
1906 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1907 ["Next article same subject" gnus-summary-next-same-subject t]
1908 ["Previous article same subject" gnus-summary-prev-same-subject t]
1909 ["First unread article" gnus-summary-first-unread-article t]
1910 ["Best unread article" gnus-summary-best-unread-article t]
1911 ["Go to subject number..." gnus-summary-goto-subject t]
1912 ["Go to article number..." gnus-summary-goto-article t]
1913 ["Go to the last article" gnus-summary-goto-last-article t]
1914 ["Pop article off history" gnus-summary-pop-article t])
1916 ["Sort by number" gnus-summary-sort-by-number t]
1917 ["Sort by author" gnus-summary-sort-by-author t]
1918 ["Sort by subject" gnus-summary-sort-by-subject t]
1919 ["Sort by date" gnus-summary-sort-by-date t]
1920 ["Sort by score" gnus-summary-sort-by-score t]
1921 ["Sort by lines" gnus-summary-sort-by-lines t]
1922 ["Sort by characters" gnus-summary-sort-by-chars t])
1924 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1925 ["Describe group" gnus-summary-describe-group t]
1926 ["Read manual" gnus-info-find-node t])
1928 ["Pick and read" gnus-pick-mode t]
1929 ["Binary" gnus-binary-mode t])
1931 ["Regenerate" gnus-summary-prepare t]
1932 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1933 ["Toggle threading" gnus-summary-toggle-threads t])
1934 ["Filter articles..." gnus-summary-execute-command t]
1935 ["Run command on subjects..." gnus-summary-universal-argument t]
1936 ["Search articles forward..." gnus-summary-search-article-forward t]
1937 ["Search articles backward..." gnus-summary-search-article-backward t]
1938 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1939 ["Expand window" gnus-summary-expand-window t]
1940 ["Expire expirable articles" gnus-summary-expire-articles
1941 (gnus-check-backend-function
1942 'request-expire-articles gnus-newsgroup-name)]
1943 ["Edit local kill file" gnus-summary-edit-local-kill t]
1944 ["Edit main kill file" gnus-summary-edit-global-kill t]
1945 ["Edit group parameters" gnus-summary-edit-parameters t]
1946 ["Customize group parameters" gnus-summary-customize-parameters t]
1947 ["Send a bug report" gnus-bug t]
1949 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1950 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1951 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1952 ["Exit group" gnus-summary-exit t]
1953 ["Exit group without updating" gnus-summary-exit-no-update t]
1954 ["Exit and goto next group" gnus-summary-next-group t]
1955 ["Exit and goto prev group" gnus-summary-prev-group t]
1956 ["Reselect group" gnus-summary-reselect-current-group t]
1957 ["Rescan group" gnus-summary-rescan-group t]
1958 ["Update dribble" gnus-summary-save-newsrc t])))
1960 (gnus-run-hooks 'gnus-summary-menu-hook)))
1962 (defun gnus-score-set-default (var value)
1963 "A version of set that updates the GNU Emacs menu-bar."
1965 ;; It is the message that forces the active status to be updated.
1968 (defun gnus-make-score-map (type)
1969 "Make a summary score map of type TYPE."
1972 (let ((headers '(("author" "from" string)
1973 ("subject" "subject" string)
1974 ("article body" "body" string)
1975 ("article head" "head" string)
1976 ("xref" "xref" string)
1977 ("extra header" "extra" string)
1978 ("lines" "lines" number)
1979 ("followups to author" "followup" string)))
1980 (types '((number ("less than" <)
1983 (string ("substring" s)
1987 (perms '(("temporary" (current-time-string))
1995 (if (eq type 'lower)
2000 (setq header (car headers))
2006 (let ((ts (cdr (assoc (nth 2 header) types)))
2022 'gnus-summary-score-entry
2024 (if (or (string= (nth 1 header)
2026 (string= (nth 1 header)
2029 (list 'gnus-summary-header
2031 (list 'quote (nth 1 (car ts)))
2032 (list 'gnus-score-delta-default
2039 (list (nreverse outp))))
2042 (list (nreverse outt))))
2044 (setq headers (cdr headers)))
2045 (list (nreverse outh))))))))
2049 (defun gnus-summary-mode (&optional group)
2050 "Major mode for reading articles.
2052 All normal editing commands are switched off.
2053 \\<gnus-summary-mode-map>
2054 Each line in this buffer represents one article. To read an
2055 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2056 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2059 You can also post articles and send mail from this buffer. To
2060 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2061 of an article, type `\\[gnus-summary-reply]'.
2063 There are approx. one gazillion commands you can execute in this
2064 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2066 The following commands are available:
2068 \\{gnus-summary-mode-map}"
2070 (when (gnus-visual-p 'summary-menu 'menu)
2071 (gnus-summary-make-menu-bar))
2072 (kill-all-local-variables)
2073 (gnus-summary-make-local-variables)
2074 (gnus-make-thread-indent-array)
2075 (gnus-simplify-mode-line)
2076 (setq major-mode 'gnus-summary-mode)
2077 (setq mode-name "Summary")
2078 (make-local-variable 'minor-mode-alist)
2079 (use-local-map gnus-summary-mode-map)
2080 (buffer-disable-undo)
2081 (setq buffer-read-only t) ;Disable modification
2082 (setq truncate-lines t)
2083 (setq selective-display t)
2084 (setq selective-display-ellipses t) ;Display `...'
2085 (gnus-summary-set-display-table)
2086 (gnus-set-default-directory)
2087 (setq gnus-newsgroup-name group)
2088 (unless (gnus-news-group-p group)
2089 (setq gnus-newsgroup-incorporated
2090 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2091 (make-local-variable 'gnus-summary-line-format)
2092 (make-local-variable 'gnus-summary-line-format-spec)
2093 (make-local-variable 'gnus-summary-dummy-line-format)
2094 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2095 (make-local-variable 'gnus-summary-mark-positions)
2096 (make-local-hook 'pre-command-hook)
2097 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2098 (gnus-run-hooks 'gnus-summary-mode-hook)
2099 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2100 (gnus-update-summary-mark-positions))
2102 (defun gnus-summary-make-local-variables ()
2103 "Make all the local summary buffer variables."
2105 (dolist (local gnus-summary-local-variables)
2108 (if (eq (cdr local) 'global)
2109 ;; Copy the global value of the variable.
2110 (setq global (symbol-value (car local)))
2111 ;; Use the value from the list.
2112 (setq global (eval (cdr local))))
2113 (set (make-local-variable (car local)) global))
2114 ;; Simple nil-valued local variable.
2115 (set (make-local-variable local) nil)))))
2117 (defun gnus-summary-clear-local-variables ()
2118 (let ((locals gnus-summary-local-variables))
2120 (if (consp (car locals))
2121 (and (vectorp (caar locals))
2122 (set (caar locals) nil))
2123 (and (vectorp (car locals))
2124 (set (car locals) nil)))
2125 (setq locals (cdr locals)))))
2127 ;; Summary data functions.
2129 (defmacro gnus-data-number (data)
2132 (defmacro gnus-data-set-number (data number)
2133 `(setcar ,data ,number))
2135 (defmacro gnus-data-mark (data)
2138 (defmacro gnus-data-set-mark (data mark)
2139 `(setcar (nthcdr 1 ,data) ,mark))
2141 (defmacro gnus-data-pos (data)
2144 (defmacro gnus-data-set-pos (data pos)
2145 `(setcar (nthcdr 2 ,data) ,pos))
2147 (defmacro gnus-data-header (data)
2150 (defmacro gnus-data-set-header (data header)
2151 `(setcar (nthcdr 3 ,data) ,header))
2153 (defmacro gnus-data-level (data)
2156 (defmacro gnus-data-unread-p (data)
2157 `(= (nth 1 ,data) gnus-unread-mark))
2159 (defmacro gnus-data-read-p (data)
2160 `(/= (nth 1 ,data) gnus-unread-mark))
2162 (defmacro gnus-data-pseudo-p (data)
2163 `(consp (nth 3 ,data)))
2165 (defmacro gnus-data-find (number)
2166 `(assq ,number gnus-newsgroup-data))
2168 (defmacro gnus-data-find-list (number &optional data)
2169 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2170 (memq (assq ,number bdata)
2173 (defmacro gnus-data-make (number mark pos header level)
2174 `(list ,number ,mark ,pos ,header ,level))
2176 (defun gnus-data-enter (after-article number mark pos header level offset)
2177 (let ((data (gnus-data-find-list after-article)))
2179 (error "No such article: %d" after-article))
2180 (setcdr data (cons (gnus-data-make number mark pos header level)
2182 (setq gnus-newsgroup-data-reverse nil)
2183 (gnus-data-update-list (cddr data) offset)))
2185 (defun gnus-data-enter-list (after-article list &optional offset)
2187 (let ((data (and after-article (gnus-data-find-list after-article)))
2191 (let ((odata gnus-newsgroup-data))
2192 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2194 (gnus-data-update-list odata offset)))
2195 ;; Find the last element in the list to be spliced into the main
2198 (setq list (cdr list)))
2201 (setcdr list gnus-newsgroup-data)
2202 (setq gnus-newsgroup-data ilist)
2204 (gnus-data-update-list (cdr list) offset)))
2205 (setcdr list (cdr data))
2208 (gnus-data-update-list (cdr list) offset))))
2209 (setq gnus-newsgroup-data-reverse nil))))
2211 (defun gnus-data-remove (article &optional offset)
2212 (let ((data gnus-newsgroup-data))
2213 (if (= (gnus-data-number (car data)) article)
2215 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2216 gnus-newsgroup-data-reverse nil)
2218 (gnus-data-update-list gnus-newsgroup-data offset)))
2220 (when (= (gnus-data-number (cadr data)) article)
2221 (setcdr data (cddr data))
2223 (gnus-data-update-list (cdr data) offset))
2225 gnus-newsgroup-data-reverse nil))
2226 (setq data (cdr data))))))
2228 (defmacro gnus-data-list (backward)
2230 (or gnus-newsgroup-data-reverse
2231 (setq gnus-newsgroup-data-reverse
2232 (reverse gnus-newsgroup-data)))
2233 gnus-newsgroup-data))
2235 (defun gnus-data-update-list (data offset)
2236 "Add OFFSET to the POS of all data entries in DATA."
2237 (setq gnus-newsgroup-data-reverse nil)
2239 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2240 (setq data (cdr data))))
2242 (defun gnus-summary-article-pseudo-p (article)
2243 "Say whether this article is a pseudo article or not."
2244 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2246 (defmacro gnus-summary-article-sparse-p (article)
2247 "Say whether this article is a sparse article or not."
2248 `(memq ,article gnus-newsgroup-sparse))
2250 (defmacro gnus-summary-article-ancient-p (article)
2251 "Say whether this article is a sparse article or not."
2252 `(memq ,article gnus-newsgroup-ancient))
2254 (defun gnus-article-parent-p (number)
2255 "Say whether this article is a parent or not."
2256 (let ((data (gnus-data-find-list number)))
2257 (and (cdr data) ; There has to be an article after...
2258 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2259 (gnus-data-level (nth 1 data))))))
2261 (defun gnus-article-children (number)
2262 "Return a list of all children to NUMBER."
2263 (let* ((data (gnus-data-find-list number))
2264 (level (gnus-data-level (car data)))
2266 (setq data (cdr data))
2268 (= (gnus-data-level (car data)) (1+ level)))
2269 (push (gnus-data-number (car data)) children)
2270 (setq data (cdr data)))
2273 (defmacro gnus-summary-skip-intangible ()
2274 "If the current article is intangible, then jump to a different article."
2275 '(let ((to (get-text-property (point) 'gnus-intangible)))
2276 (and to (gnus-summary-goto-subject to))))
2278 (defmacro gnus-summary-article-intangible-p ()
2279 "Say whether this article is intangible or not."
2280 '(get-text-property (point) 'gnus-intangible))
2282 (defun gnus-article-read-p (article)
2283 "Say whether ARTICLE is read or not."
2284 (not (or (memq article gnus-newsgroup-marked)
2285 (memq article gnus-newsgroup-unreads)
2286 (memq article gnus-newsgroup-unselected)
2287 (memq article gnus-newsgroup-dormant))))
2289 ;; Some summary mode macros.
2291 (defmacro gnus-summary-article-number ()
2292 "The article number of the article on the current line.
2293 If there isn's an article number here, then we return the current
2296 (gnus-summary-skip-intangible)
2297 (or (get-text-property (point) 'gnus-number)
2298 (gnus-summary-last-subject))))
2300 (defmacro gnus-summary-article-header (&optional number)
2301 "Return the header of article NUMBER."
2302 `(gnus-data-header (gnus-data-find
2303 ,(or number '(gnus-summary-article-number)))))
2305 (defmacro gnus-summary-thread-level (&optional number)
2306 "Return the level of thread that starts with article NUMBER."
2307 `(if (and (eq gnus-summary-make-false-root 'dummy)
2308 (get-text-property (point) 'gnus-intangible))
2310 (gnus-data-level (gnus-data-find
2311 ,(or number '(gnus-summary-article-number))))))
2313 (defmacro gnus-summary-article-mark (&optional number)
2314 "Return the mark of article NUMBER."
2315 `(gnus-data-mark (gnus-data-find
2316 ,(or number '(gnus-summary-article-number)))))
2318 (defmacro gnus-summary-article-pos (&optional number)
2319 "Return the position of the line of article NUMBER."
2320 `(gnus-data-pos (gnus-data-find
2321 ,(or number '(gnus-summary-article-number)))))
2323 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2324 (defmacro gnus-summary-article-subject (&optional number)
2325 "Return current subject string or nil if nothing."
2328 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2329 '(gnus-data-header (assq (gnus-summary-article-number)
2330 gnus-newsgroup-data)))))
2333 (mail-header-subject headers))))
2335 (defmacro gnus-summary-article-score (&optional number)
2336 "Return current article score."
2337 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2338 gnus-newsgroup-scored))
2339 gnus-summary-default-score 0))
2341 (defun gnus-summary-article-children (&optional number)
2342 "Return a list of article numbers that are children of article NUMBER."
2343 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2344 (level (gnus-data-level (car data)))
2346 (while (and (setq data (cdr data))
2347 (> (setq l (gnus-data-level (car data))) level))
2348 (and (= (1+ level) l)
2349 (push (gnus-data-number (car data))
2351 (nreverse children)))
2353 (defun gnus-summary-article-parent (&optional number)
2354 "Return the article number of the parent of article NUMBER."
2355 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2356 (gnus-data-list t)))
2357 (level (gnus-data-level (car data))))
2359 () ; This is a root.
2360 ;; We search until we find an article with a level less than
2361 ;; this one. That function has to be the parent.
2362 (while (and (setq data (cdr data))
2363 (not (< (gnus-data-level (car data)) level))))
2364 (and data (gnus-data-number (car data))))))
2366 (defun gnus-unread-mark-p (mark)
2367 "Say whether MARK is the unread mark."
2368 (= mark gnus-unread-mark))
2370 (defun gnus-read-mark-p (mark)
2371 "Say whether MARK is one of the marks that mark as read.
2372 This is all marks except unread, ticked, dormant, and expirable."
2373 (not (or (= mark gnus-unread-mark)
2374 (= mark gnus-ticked-mark)
2375 (= mark gnus-dormant-mark)
2376 (= mark gnus-expirable-mark))))
2378 (defmacro gnus-article-mark (number)
2379 "Return the MARK of article NUMBER.
2380 This macro should only be used when computing the mark the \"first\"
2381 time; i.e., when generating the summary lines. After that,
2382 `gnus-summary-article-mark' should be used to examine the
2385 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2386 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2387 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2388 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2389 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2390 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2391 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2392 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2393 gnus-ancient-mark))))
2395 ;; Saving hidden threads.
2397 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2398 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2400 (defmacro gnus-save-hidden-threads (&rest forms)
2401 "Save hidden threads, eval FORMS, and restore the hidden threads."
2402 (let ((config (make-symbol "config")))
2403 `(let ((,config (gnus-hidden-threads-configuration)))
2407 (gnus-restore-hidden-threads-configuration ,config)))))
2409 (defun gnus-data-compute-positions ()
2410 "Compute the positions of all articles."
2411 (setq gnus-newsgroup-data-reverse nil)
2412 (let ((data gnus-newsgroup-data))
2414 (gnus-save-hidden-threads
2415 (gnus-summary-show-all-threads)
2416 (goto-char (point-min))
2418 (while (get-text-property (point) 'gnus-intangible)
2420 (gnus-data-set-pos (car data) (+ (point) 3))
2421 (setq data (cdr data))
2422 (forward-line 1))))))
2424 (defun gnus-hidden-threads-configuration ()
2425 "Return the current hidden threads configuration."
2428 (goto-char (point-min))
2429 (while (search-forward "\r" nil t)
2430 (push (1- (point)) config))
2433 (defun gnus-restore-hidden-threads-configuration (config)
2434 "Restore hidden threads configuration from CONFIG."
2435 (let (point buffer-read-only)
2436 (while (setq point (pop config))
2437 (when (and (< point (point-max))
2439 (eq (char-after) ?\n))
2440 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2442 ;; Various summary mode internalish functions.
2444 (defun gnus-mouse-pick-article (e)
2447 (gnus-summary-next-page nil t))
2449 (defun gnus-summary-set-display-table ()
2450 ;; Change the display table. Odd characters have a tendency to mess
2451 ;; up nicely formatted displays - we make all possible glyphs
2452 ;; display only a single character.
2454 ;; We start from the standard display table, if any.
2455 (let ((table (or (copy-sequence standard-display-table)
2456 (make-display-table)))
2458 ;; Nix out all the control chars...
2459 (while (>= (setq i (1- i)) 0)
2460 (aset table i [??]))
2461 ;; ... but not newline and cr, of course. (cr is necessary for the
2462 ;; selective display).
2463 (aset table ?\n nil)
2464 (aset table ?\r nil)
2465 ;; We keep TAB as well.
2466 (aset table ?\t nil)
2467 ;; We nix out any glyphs over 126 that are not set already.
2469 (while (>= (setq i (1- i)) 127)
2470 ;; Only modify if the entry is nil.
2471 (unless (aref table i)
2472 (aset table i [??]))))
2473 (setq buffer-display-table table)))
2475 (defun gnus-summary-setup-buffer (group)
2476 "Initialize summary buffer."
2477 (let ((buffer (concat "*Summary " group "*")))
2478 (if (get-buffer buffer)
2481 (setq gnus-summary-buffer (current-buffer))
2482 (not gnus-newsgroup-prepared))
2483 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2484 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2485 (gnus-summary-mode group)
2487 (gnus-carpal-setup-buffer 'summary))
2488 (unless gnus-single-article-buffer
2489 (make-local-variable 'gnus-article-buffer)
2490 (make-local-variable 'gnus-article-current)
2491 (make-local-variable 'gnus-original-article-buffer))
2492 (setq gnus-newsgroup-name group)
2495 (defun gnus-set-global-variables ()
2496 ;; Set the global equivalents of the summary buffer-local variables
2497 ;; to the latest values they had. These reflect the summary buffer
2498 ;; that was in action when the last article was fetched.
2499 (when (eq major-mode 'gnus-summary-mode)
2500 (setq gnus-summary-buffer (current-buffer))
2501 (let ((name gnus-newsgroup-name)
2502 (marked gnus-newsgroup-marked)
2503 (unread gnus-newsgroup-unreads)
2504 (headers gnus-current-headers)
2505 (data gnus-newsgroup-data)
2506 (summary gnus-summary-buffer)
2507 (article-buffer gnus-article-buffer)
2508 (original gnus-original-article-buffer)
2509 (gac gnus-article-current)
2510 (reffed gnus-reffed-article-number)
2511 (score-file gnus-current-score-file)
2512 (default-charset gnus-newsgroup-charset))
2514 (set-buffer gnus-group-buffer)
2515 (setq gnus-newsgroup-name name
2516 gnus-newsgroup-marked marked
2517 gnus-newsgroup-unreads unread
2518 gnus-current-headers headers
2519 gnus-newsgroup-data data
2520 gnus-article-current gac
2521 gnus-summary-buffer summary
2522 gnus-article-buffer article-buffer
2523 gnus-original-article-buffer original
2524 gnus-reffed-article-number reffed
2525 gnus-current-score-file score-file
2526 gnus-newsgroup-charset default-charset)
2527 ;; The article buffer also has local variables.
2528 (when (gnus-buffer-live-p gnus-article-buffer)
2529 (set-buffer gnus-article-buffer)
2530 (setq gnus-summary-buffer summary))))))
2532 (defun gnus-summary-article-unread-p (article)
2533 "Say whether ARTICLE is unread or not."
2534 (memq article gnus-newsgroup-unreads))
2536 (defun gnus-summary-first-article-p (&optional article)
2537 "Return whether ARTICLE is the first article in the buffer."
2538 (if (not (setq article (or article (gnus-summary-article-number))))
2540 (eq article (caar gnus-newsgroup-data))))
2542 (defun gnus-summary-last-article-p (&optional article)
2543 "Return whether ARTICLE is the last article in the buffer."
2544 (if (not (setq article (or article (gnus-summary-article-number))))
2545 ;; All non-existent numbers are the last article. :-)
2547 (not (cdr (gnus-data-find-list article)))))
2549 (defun gnus-make-thread-indent-array ()
2551 (unless (and gnus-thread-indent-array
2552 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2553 (setq gnus-thread-indent-array (make-vector 201 "")
2554 gnus-thread-indent-array-level gnus-thread-indent-level)
2556 (aset gnus-thread-indent-array n
2557 (make-string (* n gnus-thread-indent-level) ? ))
2560 (defun gnus-update-summary-mark-positions ()
2561 "Compute where the summary marks are to go."
2563 (when (gnus-buffer-exists-p gnus-summary-buffer)
2564 (set-buffer gnus-summary-buffer))
2565 (let ((gnus-replied-mark 129)
2566 (gnus-score-below-mark 130)
2567 (gnus-score-over-mark 130)
2568 (gnus-download-mark 131)
2569 (spec gnus-summary-line-format-spec)
2572 (gnus-set-work-buffer)
2573 (let ((gnus-summary-line-format-spec spec)
2574 (gnus-newsgroup-downloadable '((0 . t))))
2575 (gnus-summary-insert-line
2576 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2577 0 nil 128 t nil "" nil 1)
2578 (goto-char (point-min))
2579 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2581 (goto-char (point-min))
2582 (push (cons 'replied (and (search-forward "\201" nil t)
2585 (goto-char (point-min))
2586 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2588 (goto-char (point-min))
2589 (push (cons 'download
2590 (and (search-forward "\203" nil t) (- (point) 2)))
2592 (setq gnus-summary-mark-positions pos))))
2594 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2595 "Insert a dummy root in the summary buffer."
2597 (gnus-add-text-properties
2598 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2599 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2601 (defun gnus-summary-from-or-to-or-newsgroups (header)
2602 (let ((to (cdr (assq 'To (mail-header-extra header))))
2603 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2604 (default-mime-charset (with-current-buffer gnus-summary-buffer
2605 default-mime-charset)))
2608 gnus-ignored-from-addresses
2609 (string-match gnus-ignored-from-addresses
2610 (mail-header-from header)))
2612 (or (car (funcall gnus-extract-address-components
2614 gnus-decode-encoded-word-function to)))
2615 (funcall gnus-decode-encoded-word-function to))))
2617 gnus-ignored-from-addresses
2618 (string-match gnus-ignored-from-addresses
2619 (mail-header-from header)))
2620 (concat "=> " newsgroups))
2622 (or (car (funcall gnus-extract-address-components
2623 (mail-header-from header)))
2624 (mail-header-from header))))))
2626 (defun gnus-summary-insert-line (gnus-tmp-header
2627 gnus-tmp-level gnus-tmp-current
2628 gnus-tmp-unread gnus-tmp-replied
2629 gnus-tmp-expirable gnus-tmp-subject-or-nil
2630 &optional gnus-tmp-dummy gnus-tmp-score
2632 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2633 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2634 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2635 (gnus-tmp-score-char
2636 (if (or (null gnus-summary-default-score)
2637 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2638 gnus-summary-zcore-fuzz))
2640 (if (< gnus-tmp-score gnus-summary-default-score)
2641 gnus-score-below-mark gnus-score-over-mark)))
2643 (cond (gnus-tmp-process gnus-process-mark)
2644 ((memq gnus-tmp-current gnus-newsgroup-cached)
2646 (gnus-tmp-replied gnus-replied-mark)
2647 ((memq gnus-tmp-current gnus-newsgroup-saved)
2649 (t gnus-unread-mark)))
2650 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2653 ((string-match "<[^>]+> *$" gnus-tmp-from)
2654 (let ((beg (match-beginning 0)))
2655 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2656 (substring gnus-tmp-from (1+ (match-beginning 0))
2657 (1- (match-end 0))))
2658 (substring gnus-tmp-from 0 beg))))
2659 ((string-match "(.+)" gnus-tmp-from)
2660 (substring gnus-tmp-from
2661 (1+ (match-beginning 0)) (1- (match-end 0))))
2663 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2664 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2665 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2666 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2667 (buffer-read-only nil))
2668 (when (string= gnus-tmp-name "")
2669 (setq gnus-tmp-name gnus-tmp-from))
2670 (unless (numberp gnus-tmp-lines)
2671 (setq gnus-tmp-lines 0))
2672 (gnus-put-text-property-excluding-characters-with-faces
2674 (progn (eval gnus-summary-line-format-spec) (point))
2675 'gnus-number gnus-tmp-number)
2676 (when (gnus-visual-p 'summary-highlight 'highlight)
2678 (gnus-run-hooks 'gnus-summary-update-hook)
2681 (defun gnus-summary-update-line (&optional dont-update)
2682 ;; Update summary line after change.
2683 (when (and gnus-summary-default-score
2684 (not gnus-summary-inhibit-highlight))
2685 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2686 (article (gnus-summary-article-number))
2687 (score (gnus-summary-article-score article)))
2689 (if (and gnus-summary-mark-below
2690 (< (gnus-summary-article-score)
2691 gnus-summary-mark-below))
2692 ;; This article has a low score, so we mark it as read.
2693 (when (memq article gnus-newsgroup-unreads)
2694 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2695 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2696 ;; This article was previously marked as read on account
2697 ;; of a low score, but now it has risen, so we mark it as
2699 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2700 (gnus-summary-update-mark
2701 (if (or (null gnus-summary-default-score)
2702 (<= (abs (- score gnus-summary-default-score))
2703 gnus-summary-zcore-fuzz))
2705 (if (< score gnus-summary-default-score)
2706 gnus-score-below-mark gnus-score-over-mark))
2708 ;; Do visual highlighting.
2709 (when (gnus-visual-p 'summary-highlight 'highlight)
2710 (gnus-run-hooks 'gnus-summary-update-hook)))))
2712 (defvar gnus-tmp-new-adopts nil)
2714 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2715 "Return the number of articles in THREAD.
2716 This may be 0 in some cases -- if none of the articles in
2717 the thread are to be displayed."
2719 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2721 ((not (listp thread))
2723 ((and (consp thread) (cdr thread))
2726 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2729 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2732 (when (and level (zerop level) gnus-tmp-new-adopts)
2735 'gnus-summary-number-of-articles-in-thread
2736 gnus-tmp-new-adopts))))
2738 (if (> number 1) gnus-not-empty-thread-mark
2739 gnus-empty-thread-mark)
2742 (defun gnus-summary-set-local-parameters (group)
2743 "Go through the local params of GROUP and set all variable specs in that list."
2744 (let ((params (gnus-group-find-parameter group))
2747 (setq elem (car params)
2748 params (cdr params))
2749 (and (consp elem) ; Has to be a cons.
2750 (consp (cdr elem)) ; The cdr has to be a list.
2751 (symbolp (car elem)) ; Has to be a symbol in there.
2752 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2753 (ignore-errors ; So we set it.
2754 (make-local-variable (car elem))
2755 (set (car elem) (eval (nth 1 elem))))))))
2757 (defun gnus-summary-read-group (group &optional show-all no-article
2758 kill-buffer no-display backward
2760 "Start reading news in newsgroup GROUP.
2761 If SHOW-ALL is non-nil, already read articles are also listed.
2762 If NO-ARTICLE is non-nil, no article is selected initially.
2763 If NO-DISPLAY, don't generate a summary buffer."
2767 (let ((gnus-auto-select-next nil))
2768 (or (gnus-summary-read-group-1
2769 group show-all no-article
2770 kill-buffer no-display
2773 select-articles nil)))))
2774 (eq gnus-auto-select-next 'quietly))
2775 (set-buffer gnus-group-buffer)
2776 ;; The entry function called above goes to the next
2777 ;; group automatically, so we go two groups back
2778 ;; if we are searching for the previous group.
2780 (gnus-group-prev-unread-group 2))
2781 (if (not (equal group (gnus-group-group-name)))
2782 (setq group (gnus-group-group-name))
2786 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2787 "Directly jump to the other GROUP from summary buffer.
2788 If SHOW-ALL is non-nil, already read articles are also listed."
2790 (if (eq gnus-summary-buffer (current-buffer))
2791 (list (completing-read
2792 "Group: " gnus-active-hashtb nil t
2793 (when (and gnus-newsgroup-name
2794 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2795 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2796 'gnus-group-history)
2798 (error "%s must be invoked from a gnus summary buffer." this-command)))
2799 (unless (or (zerop (length group))
2800 (and gnus-newsgroup-name
2801 (string-equal gnus-newsgroup-name group)))
2803 (gnus-summary-read-group group show-all
2804 gnus-dont-select-after-jump-to-other-group)))
2806 (defun gnus-summary-read-group-1 (group show-all no-article
2807 kill-buffer no-display
2808 &optional select-articles)
2809 ;; Killed foreign groups can't be entered.
2810 (when (and (not (gnus-group-native-p group))
2811 (not (gnus-gethash group gnus-newsrc-hashtb)))
2812 (error "Dead non-native groups can't be entered"))
2813 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2814 (let* ((new-group (gnus-summary-setup-buffer group))
2815 (quit-config (gnus-group-quit-config group))
2816 (did-select (and new-group (gnus-select-newsgroup
2817 group show-all select-articles))))
2819 ;; This summary buffer exists already, so we just select it.
2821 (gnus-set-global-variables)
2823 (gnus-kill-or-deaden-summary kill-buffer))
2824 (gnus-configure-windows 'summary 'force)
2825 (gnus-set-mode-line 'summary)
2826 (gnus-summary-position-point)
2829 ;; We couldn't select this group.
2831 (when (and (eq major-mode 'gnus-summary-mode)
2832 (not (equal (current-buffer) kill-buffer)))
2833 (kill-buffer (current-buffer))
2834 (if (not quit-config)
2836 ;; Update the info -- marks might need to be removed,
2838 (gnus-summary-update-info)
2839 (set-buffer gnus-group-buffer)
2840 (gnus-group-jump-to-group group)
2841 (gnus-group-next-unread-group 1))
2842 (gnus-handle-ephemeral-exit quit-config)))
2843 (gnus-message 3 "Can't select group")
2845 ;; The user did a `C-g' while prompting for number of articles,
2846 ;; so we exit this group.
2847 ((eq did-select 'quit)
2848 (and (eq major-mode 'gnus-summary-mode)
2849 (not (equal (current-buffer) kill-buffer))
2850 (kill-buffer (current-buffer)))
2852 (gnus-kill-or-deaden-summary kill-buffer))
2853 (if (not quit-config)
2855 (set-buffer gnus-group-buffer)
2856 (gnus-group-jump-to-group group)
2857 (gnus-group-next-unread-group 1)
2858 (gnus-configure-windows 'group 'force))
2859 (gnus-handle-ephemeral-exit quit-config))
2860 ;; Finally signal the quit.
2862 ;; The group was successfully selected.
2864 (gnus-set-global-variables)
2865 ;; Save the active value in effect when the group was entered.
2866 (setq gnus-newsgroup-active
2868 (gnus-active gnus-newsgroup-name)))
2869 ;; You can change the summary buffer in some way with this hook.
2870 (gnus-run-hooks 'gnus-select-group-hook)
2871 ;; Set any local variables in the group parameters.
2872 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2873 (gnus-update-format-specifications
2874 nil 'summary 'summary-mode 'summary-dummy)
2875 (gnus-update-summary-mark-positions)
2876 ;; Do score processing.
2877 (when gnus-use-scoring
2878 (gnus-possibly-score-headers))
2879 ;; Check whether to fill in the gaps in the threads.
2880 (when gnus-build-sparse-threads
2881 (gnus-build-sparse-threads))
2882 ;; Find the initial limit.
2883 (if gnus-show-threads
2885 (let ((gnus-newsgroup-dormant nil))
2886 (gnus-summary-initial-limit show-all))
2887 (gnus-summary-initial-limit show-all))
2888 ;; When untreaded, all articles are always shown.
2889 (setq gnus-newsgroup-limit
2891 (lambda (header) (mail-header-number header))
2892 gnus-newsgroup-headers)))
2893 ;; Generate the summary buffer.
2895 (gnus-summary-prepare))
2896 (when gnus-use-trees
2897 (gnus-tree-open group)
2898 (setq gnus-summary-highlight-line-function
2899 'gnus-tree-highlight-article))
2900 ;; If the summary buffer is empty, but there are some low-scored
2901 ;; articles or some excluded dormants, we include these in the
2903 (when (and (zerop (buffer-size))
2905 (cond (gnus-newsgroup-dormant
2906 (gnus-summary-limit-include-dormant))
2907 ((and gnus-newsgroup-scored show-all)
2908 (gnus-summary-limit-include-expunged t))))
2909 ;; Function `gnus-apply-kill-file' must be called in this hook.
2910 (gnus-run-hooks 'gnus-apply-kill-hook)
2911 (if (and (zerop (buffer-size))
2914 ;; This newsgroup is empty.
2915 (gnus-summary-catchup-and-exit nil t)
2916 (gnus-message 6 "No unread news")
2918 (gnus-kill-or-deaden-summary kill-buffer))
2919 ;; Return nil from this function.
2921 ;; Hide conversation thread subtrees. We cannot do this in
2922 ;; gnus-summary-prepare-hook since kill processing may not
2923 ;; work with hidden articles.
2924 (and gnus-show-threads
2925 gnus-thread-hide-subtree
2926 (gnus-summary-hide-all-threads))
2928 (gnus-kill-or-deaden-summary kill-buffer))
2929 ;; Show first unread article if requested.
2930 (if (and (not no-article)
2932 gnus-newsgroup-unreads
2933 gnus-auto-select-first)
2935 (gnus-configure-windows 'summary)
2937 ((eq gnus-auto-select-first 'best)
2938 (gnus-summary-best-unread-article))
2939 ((eq gnus-auto-select-first t)
2940 (gnus-summary-first-unread-article))
2941 ((gnus-functionp gnus-auto-select-first)
2942 (funcall gnus-auto-select-first))))
2943 ;; Don't select any articles, just move point to the first
2944 ;; article in the group.
2945 (goto-char (point-min))
2946 (gnus-summary-position-point)
2947 (gnus-configure-windows 'summary 'force)
2948 (gnus-set-mode-line 'summary))
2949 (when (get-buffer-window gnus-group-buffer t)
2950 ;; Gotta use windows, because recenter does weird stuff if
2951 ;; the current buffer ain't the displayed window.
2952 (let ((owin (selected-window)))
2953 (select-window (get-buffer-window gnus-group-buffer t))
2954 (when (gnus-group-goto-group group)
2956 (select-window owin)))
2957 ;; Mark this buffer as "prepared".
2958 (setq gnus-newsgroup-prepared t)
2959 (gnus-run-hooks 'gnus-summary-prepared-hook)
2962 (defun gnus-summary-prepare ()
2963 "Generate the summary buffer."
2965 (let ((buffer-read-only nil))
2967 (setq gnus-newsgroup-data nil
2968 gnus-newsgroup-data-reverse nil)
2969 (gnus-run-hooks 'gnus-summary-generate-hook)
2970 ;; Generate the buffer, either with threads or without.
2971 (when gnus-newsgroup-headers
2972 (gnus-summary-prepare-threads
2973 (if gnus-show-threads
2974 (gnus-sort-gathered-threads
2975 (funcall gnus-summary-thread-gathering-function
2977 (gnus-cut-threads (gnus-make-threads)))))
2978 ;; Unthreaded display.
2979 (gnus-sort-articles gnus-newsgroup-headers))))
2980 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2981 ;; Call hooks for modifying summary buffer.
2982 (goto-char (point-min))
2983 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2985 (defsubst gnus-general-simplify-subject (subject)
2986 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2989 ;; Truncate the subject.
2990 (gnus-simplify-subject-functions
2991 (gnus-map-function gnus-simplify-subject-functions subject))
2992 ((numberp gnus-summary-gather-subject-limit)
2993 (setq subject (gnus-simplify-subject-re subject))
2994 (if (> (length subject) gnus-summary-gather-subject-limit)
2995 (substring subject 0 gnus-summary-gather-subject-limit)
2997 ;; Fuzzily simplify it.
2998 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2999 (gnus-simplify-subject-fuzzy subject))
3000 ;; Just remove the leading "Re:".
3002 (gnus-simplify-subject-re subject))))
3004 (if (and gnus-summary-gather-exclude-subject
3005 (string-match gnus-summary-gather-exclude-subject subject))
3006 nil ; This article shouldn't be gathered
3009 (defun gnus-summary-simplify-subject-query ()
3010 "Query where the respool algorithm would put this article."
3012 (gnus-summary-select-article)
3014 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3016 (defun gnus-gather-threads-by-subject (threads)
3017 "Gather threads by looking at Subject headers."
3018 (if (not gnus-summary-make-false-root)
3020 (let ((hashtb (gnus-make-hashtable 1024))
3023 subject hthread whole-subject)
3025 (setq subject (gnus-general-simplify-subject
3026 (setq whole-subject (mail-header-subject
3029 (if (setq hthread (gnus-gethash subject hashtb))
3031 ;; We enter a dummy root into the thread, if we
3032 ;; haven't done that already.
3033 (unless (stringp (caar hthread))
3034 (setcar hthread (list whole-subject (car hthread))))
3035 ;; We add this new gathered thread to this gathered
3037 (setcdr (car hthread)
3038 (nconc (cdar hthread) (list (car threads))))
3039 ;; Remove it from the list of threads.
3040 (setcdr prev (cdr threads))
3041 (setq threads prev))
3042 ;; Enter this thread into the hash table.
3043 (gnus-sethash subject threads hashtb)))
3045 (setq threads (cdr threads)))
3048 (defun gnus-gather-threads-by-references (threads)
3049 "Gather threads by looking at References headers."
3050 (let ((idhashtb (gnus-make-hashtable 1024))
3051 (thhashtb (gnus-make-hashtable 1024))
3054 ids references id gthread gid entered ref)
3056 (when (setq references (mail-header-references (caar threads)))
3057 (setq id (mail-header-id (caar threads))
3058 ids (gnus-split-references references)
3060 (while (setq ref (pop ids))
3061 (setq ids (delete ref ids))
3062 (if (not (setq gid (gnus-gethash ref idhashtb)))
3064 (gnus-sethash ref id idhashtb)
3065 (gnus-sethash id threads thhashtb))
3066 (setq gthread (gnus-gethash gid thhashtb))
3068 ;; We enter a dummy root into the thread, if we
3069 ;; haven't done that already.
3070 (unless (stringp (caar gthread))
3071 (setcar gthread (list (mail-header-subject (caar gthread))
3073 ;; We add this new gathered thread to this gathered
3075 (setcdr (car gthread)
3076 (nconc (cdar gthread) (list (car threads)))))
3077 ;; Add it into the thread hash table.
3078 (gnus-sethash id gthread thhashtb)
3080 ;; Remove it from the list of threads.
3081 (setcdr prev (cdr threads))
3082 (setq threads prev))))
3084 (setq threads (cdr threads)))
3087 (defun gnus-sort-gathered-threads (threads)
3088 "Sort subtreads inside each gathered thread by article number."
3089 (let ((result threads))
3091 (when (stringp (caar threads))
3092 (setcdr (car threads)
3093 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3094 (setq threads (cdr threads)))
3097 (defun gnus-thread-loop-p (root thread)
3098 "Say whether ROOT is in THREAD."
3099 (let ((stack (list thread))
3102 (while (setq thread (pop stack))
3103 (setq th (cdr thread))
3105 (not (eq (caar th) root)))
3108 ;; We have found a loop.
3110 (setcdr thread (delq (car th) (cdr thread)))
3111 (if (boundp (setq ref-dep (intern "none"
3112 gnus-newsgroup-dependencies)))
3113 (setcdr (symbol-value ref-dep)
3114 (nconc (cdr (symbol-value ref-dep))
3116 (set ref-dep (list nil (car th))))
3119 ;; Push all the subthreads onto the stack.
3120 (push (cdr thread) stack)))
3123 (defun gnus-make-threads ()
3124 "Go through the dependency hashtb and find the roots. Return all threads."
3126 (while (catch 'infloop
3129 ;; Deal with self-referencing References loops.
3130 (when (and (car (symbol-value refs))
3137 (car (symbol-value refs)) thread))
3138 (cdr (symbol-value refs)))))))
3141 (unless (car (symbol-value refs))
3142 ;; These threads do not refer back to any other articles,
3143 ;; so they're roots.
3144 (setq threads (append (cdr (symbol-value refs)) threads))))
3145 gnus-newsgroup-dependencies)))
3148 ;; Build the thread tree.
3149 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3150 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3152 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3153 if it was already present.
3155 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3156 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3157 Message-IDs will be renamed be renamed to a unique Message-ID before
3160 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3161 (let* ((id (mail-header-id header))
3162 (id-dep (and id (intern id dependencies)))
3163 ref ref-dep ref-header)
3164 ;; Enter this `header' in the `dependencies' table.
3168 ;; The first two cases do the normal part: enter a new `header'
3169 ;; in the `dependencies' table.
3170 ((not (boundp id-dep))
3171 (set id-dep (list header)))
3172 ((null (car (symbol-value id-dep)))
3173 (setcar (symbol-value id-dep) header))
3175 ;; From here the `header' was already present in the
3176 ;; `dependencies' table.
3178 ;; Overrides an existing entry;
3179 ;; just set the header part of the entry.
3180 (setcar (symbol-value id-dep) header))
3182 ;; Renames the existing `header' to a unique Message-ID.
3183 ((not gnus-summary-ignore-duplicates)
3184 ;; An article with this Message-ID has already been seen.
3185 ;; We rename the Message-ID.
3186 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3188 (mail-header-set-id header id))
3190 ;; The last case ignores an existing entry, except it adds any
3191 ;; additional Xrefs (in case the two articles came from different
3193 ;; Also sets `header' to `nil' meaning that the `dependencies'
3194 ;; table was *not* modified.
3196 (mail-header-set-xref
3197 (car (symbol-value id-dep))
3198 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3200 (or (mail-header-xref header) "")))
3204 ;; First check if that we are not creating a References loop.
3205 (setq ref (gnus-parent-id (mail-header-references header)))
3207 (setq ref-dep (intern-soft ref dependencies))
3209 (setq ref-header (car (symbol-value ref-dep))))
3210 (if (string= id ref)
3211 ;; Yuk! This is a reference loop. Make the article be a
3214 (mail-header-set-references (car (symbol-value id-dep)) "none")
3216 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3217 (setq ref (gnus-parent-id (mail-header-references header)))
3218 (setq ref-dep (intern (or ref "none") dependencies))
3219 (if (boundp ref-dep)
3220 (setcdr (symbol-value ref-dep)
3221 (nconc (cdr (symbol-value ref-dep))
3222 (list (symbol-value id-dep))))
3223 (set ref-dep (list nil (symbol-value id-dep)))))
3226 (defun gnus-build-sparse-threads ()
3227 (let ((headers gnus-newsgroup-headers)
3228 (mail-parse-charset gnus-newsgroup-charset)
3229 (gnus-summary-ignore-duplicates t)
3230 header references generation relations
3231 subject child end new-child date)
3232 ;; First we create an alist of generations/relations, where
3233 ;; generations is how much we trust the relation, and the relation
3235 (gnus-message 7 "Making sparse threads...")
3237 (nnheader-set-temp-buffer " *gnus sparse threads*")
3238 (while (setq header (pop headers))
3239 (when (and (setq references (mail-header-references header))
3240 (not (string= references "")))
3242 (setq child (mail-header-id header)
3243 subject (mail-header-subject header)
3244 date (mail-header-date header)
3246 (while (search-backward ">" nil t)
3247 (setq end (1+ (point)))
3248 (when (search-backward "<" nil t)
3249 (setq new-child (buffer-substring (point) end))
3250 (push (list (incf generation)
3251 child (setq child new-child)
3255 (push (list (1+ generation) child nil subject) relations))
3257 (kill-buffer (current-buffer)))
3258 ;; Sort over trustworthiness.
3261 (when (gnus-dependencies-add-header
3262 (make-full-mail-header
3263 gnus-reffed-article-number
3264 (nth 3 relation) "" (or (nth 4 relation) "")
3266 (or (nth 2 relation) "") 0 0 "")
3267 gnus-newsgroup-dependencies nil)
3268 (push gnus-reffed-article-number gnus-newsgroup-limit)
3269 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3270 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3271 gnus-newsgroup-reads)
3272 (decf gnus-reffed-article-number)))
3273 (sort relations 'car-less-than-car))
3274 (gnus-message 7 "Making sparse threads...done")))
3276 (defun gnus-build-old-threads ()
3277 ;; Look at all the articles that refer back to old articles, and
3278 ;; fetch the headers for the articles that aren't there. This will
3279 ;; build complete threads - if the roots haven't been expired by the
3281 (let ((mail-parse-charset gnus-newsgroup-charset)
3285 (when (not (car (symbol-value refs)))
3286 (setq heads (cdr (symbol-value refs)))
3288 (if (memq (mail-header-number (caar heads))
3289 gnus-newsgroup-dormant)
3290 (setq heads (cdr heads))
3291 (setq id (symbol-name refs))
3292 (while (and (setq id (gnus-build-get-header id))
3293 (not (car (gnus-id-to-thread id)))))
3294 (setq heads nil)))))
3295 gnus-newsgroup-dependencies)))
3297 ;; This function has to be called with point after the article number
3298 ;; on the beginning of the line.
3299 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3300 (let ((eol (gnus-point-at-eol))
3301 (buffer (current-buffer))
3304 ;; overview: [num subject from date id refs chars lines misc]
3309 (make-full-mail-header
3311 (nnheader-nov-field) ; subject
3312 (nnheader-nov-field) ; from
3313 (nnheader-nov-field) ; date
3314 (nnheader-nov-read-message-id) ; id
3315 (nnheader-nov-field) ; refs
3316 (nnheader-nov-read-integer) ; chars
3317 (nnheader-nov-read-integer) ; lines
3319 (nnheader-nov-field)) ; misc
3320 (nnheader-nov-parse-extra))) ; extra
3322 (when gnus-alter-header-function
3323 (funcall gnus-alter-header-function header))
3324 (gnus-dependencies-add-header header dependencies force-new)))
3326 (defun gnus-build-get-header (id)
3327 ;; Look through the buffer of NOV lines and find the header to
3328 ;; ID. Enter this line into the dependencies hash table, and return
3329 ;; the id of the parent article (if any).
3330 (let ((deps gnus-newsgroup-dependencies)
3334 (set-buffer nntp-server-buffer)
3335 (let ((case-fold-search nil))
3336 (goto-char (point-min))
3337 (while (and (not found)
3338 (search-forward id nil t))
3340 (setq found (looking-at
3341 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3342 (regexp-quote id))))
3343 (or found (beginning-of-line 2)))
3347 (setq header (gnus-nov-parse-line
3348 (read (current-buffer)) deps))
3349 (gnus-parent-id (mail-header-references header))))))
3351 (let ((number (mail-header-number header)))
3352 (push number gnus-newsgroup-limit)
3353 (push header gnus-newsgroup-headers)
3354 (if (memq number gnus-newsgroup-unselected)
3356 (push number gnus-newsgroup-unreads)
3357 (setq gnus-newsgroup-unselected
3358 (delq number gnus-newsgroup-unselected)))
3359 (push number gnus-newsgroup-ancient)))))))
3361 (defun gnus-build-all-threads ()
3362 "Read all the headers."
3363 (let ((gnus-summary-ignore-duplicates t)
3364 (mail-parse-charset gnus-newsgroup-charset)
3365 (dependencies gnus-newsgroup-dependencies)
3368 (set-buffer nntp-server-buffer)
3369 (let ((case-fold-search nil))
3370 (goto-char (point-min))
3373 (setq article (read (current-buffer))
3374 header (gnus-nov-parse-line article dependencies)))
3377 (set-buffer gnus-summary-buffer)
3378 (push header gnus-newsgroup-headers)
3379 (if (memq (setq article (mail-header-number header))
3380 gnus-newsgroup-unselected)
3382 (push article gnus-newsgroup-unreads)
3383 (setq gnus-newsgroup-unselected
3384 (delq article gnus-newsgroup-unselected)))
3385 (push article gnus-newsgroup-ancient)))
3386 (forward-line 1)))))))
3388 (defun gnus-summary-update-article-line (article header)
3389 "Update the line for ARTICLE using HEADERS."
3390 (let* ((id (mail-header-id header))
3391 (thread (gnus-id-to-thread id)))
3393 (error "Article in no thread"))
3394 ;; Update the thread.
3395 (setcar thread header)
3396 (gnus-summary-goto-subject article)
3397 (let* ((datal (gnus-data-find-list article))
3399 (length (when (cdr datal)
3400 (- (gnus-data-pos data)
3401 (gnus-data-pos (cadr datal)))))
3402 (buffer-read-only nil)
3403 (level (gnus-summary-thread-level)))
3405 (gnus-summary-insert-line
3406 header level nil (gnus-article-mark article)
3407 (memq article gnus-newsgroup-replied)
3408 (memq article gnus-newsgroup-expirable)
3409 ;; Only insert the Subject string when it's different
3410 ;; from the previous Subject string.
3415 (mail-header-subject
3418 (gnus-data-find-list
3420 (gnus-data-list t)))))
3421 ;; Error on the side of excessive subjects.
3423 (mail-header-subject header)))
3425 (mail-header-subject header))
3426 nil (cdr (assq article gnus-newsgroup-scored))
3427 (memq article gnus-newsgroup-processable))
3429 (gnus-data-update-list
3430 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3432 (defun gnus-summary-update-article (article &optional iheader)
3433 "Update ARTICLE in the summary buffer."
3434 (set-buffer gnus-summary-buffer)
3435 (let* ((header (gnus-summary-article-header article))
3436 (id (mail-header-id header))
3437 (data (gnus-data-find article))
3438 (thread (gnus-id-to-thread id))
3439 (references (mail-header-references header))
3443 (when (and references
3444 (not (equal "" references)))
3447 (buffer-read-only nil)
3453 (delq thread parent)))
3454 (if (gnus-summary-insert-subject id header)
3455 ;; Set the (possibly) new article number in the data structure.
3456 (gnus-data-set-number data (gnus-id-to-article id))
3460 (defun gnus-rebuild-thread (id &optional line)
3461 "Rebuild the thread containing ID.
3462 If LINE, insert the rebuilt thread starting on line LINE."
3463 (let ((buffer-read-only nil)
3464 old-pos current thread data)
3465 (if (not gnus-show-threads)
3466 (setq thread (list (car (gnus-id-to-thread id))))
3467 ;; Get the thread this article is part of.
3468 (setq thread (gnus-remove-thread id)))
3469 (setq old-pos (gnus-point-at-bol))
3470 (setq current (save-excursion
3471 (and (zerop (forward-line -1))
3472 (gnus-summary-article-number))))
3473 ;; If this is a gathered thread, we have to go some re-gathering.
3474 (when (stringp (car thread))
3475 (let ((subject (car thread))
3477 (setq thread (cdr thread))
3479 (unless (memq (setq thr (gnus-id-to-thread
3481 (mail-header-id (caar thread)))))
3484 (setq thread (cdr thread)))
3485 ;; We now have all (unique) roots.
3486 (if (= (length roots) 1)
3487 ;; All the loose roots are now one solid root.
3488 (setq thread (car roots))
3489 (setq thread (cons subject (gnus-sort-threads roots))))))
3491 ;; We then insert this thread into the summary buffer.
3493 (goto-char (point-min))
3494 (forward-line (1- line)))
3495 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3496 (if gnus-show-threads
3497 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3498 (gnus-summary-prepare-unthreaded thread))
3499 (setq data (nreverse gnus-newsgroup-data))
3500 (setq threads gnus-newsgroup-threads))
3501 ;; We splice the new data into the data structure.
3502 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3503 ;;!!! then we want to insert at the beginning of the buffer.
3504 ;;!!! That happens to be true with Gnus now, but that may
3505 ;;!!! change in the future. Perhaps.
3506 (gnus-data-enter-list
3507 (if line nil current) data (- (point) old-pos))
3508 (setq gnus-newsgroup-threads
3509 (nconc threads gnus-newsgroup-threads))
3510 (gnus-data-compute-positions))))
3512 (defun gnus-number-to-header (number)
3513 "Return the header for article NUMBER."
3514 (let ((headers gnus-newsgroup-headers))
3516 (not (= number (mail-header-number (car headers)))))
3521 (defun gnus-parent-headers (in-headers &optional generation)
3522 "Return the headers of the GENERATIONeth parent of HEADERS."
3524 (setq generation 1))
3526 (headers in-headers)
3529 (not (zerop generation))
3530 (setq references (mail-header-references headers)))
3531 (setq headers (if (and references
3532 (setq parent (gnus-parent-id references)))
3533 (car (gnus-id-to-thread parent))
3536 (and (not (eq headers in-headers))
3539 (defun gnus-id-to-thread (id)
3540 "Return the (sub-)thread where ID appears."
3541 (gnus-gethash id gnus-newsgroup-dependencies))
3543 (defun gnus-id-to-article (id)
3544 "Return the article number of ID."
3545 (let ((thread (gnus-id-to-thread id)))
3548 (mail-header-number (car thread)))))
3550 (defun gnus-id-to-header (id)
3551 "Return the article headers of ID."
3552 (car (gnus-id-to-thread id)))
3554 (defun gnus-article-displayed-root-p (article)
3555 "Say whether ARTICLE is a root(ish) article."
3556 (let ((level (gnus-summary-thread-level article))
3557 (refs (mail-header-references (gnus-summary-article-header article)))
3563 ((null (gnus-parent-id refs)) t)
3565 (null (setq particle (gnus-id-to-article
3566 (gnus-parent-id refs))))
3567 (null (gnus-summary-thread-level particle)))))))
3569 (defun gnus-root-id (id)
3570 "Return the id of the root of the thread where ID appears."
3572 (while (and id (setq prev (car (gnus-id-to-thread id))))
3574 id (gnus-parent-id (mail-header-references prev))))
3577 (defun gnus-articles-in-thread (thread)
3578 "Return the list of articles in THREAD."
3579 (cons (mail-header-number (car thread))
3580 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3582 (defun gnus-remove-thread (id &optional dont-remove)
3583 "Remove the thread that has ID in it."
3584 (let (headers thread last-id)
3585 ;; First go up in this thread until we find the root.
3586 (setq last-id (gnus-root-id id)
3587 headers (message-flatten-list (gnus-id-to-thread last-id)))
3588 ;; We have now found the real root of this thread. It might have
3589 ;; been gathered into some loose thread, so we have to search
3590 ;; through the threads to find the thread we wanted.
3591 (let ((threads gnus-newsgroup-threads)
3594 (setq sub (car threads))
3595 (if (stringp (car sub))
3596 ;; This is a gathered thread, so we look at the roots
3597 ;; below it to find whether this article is in this
3600 (setq sub (cdr sub))
3602 (when (member (caar sub) headers)
3603 (setq thread (car threads)
3606 (setq sub (cdr sub))))
3607 ;; It's an ordinary thread, so we check it.
3608 (when (eq (car sub) (car headers))
3611 (setq threads (cdr threads)))
3612 ;; If this article is in no thread, then it's a root.
3615 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3616 (setq thread (gnus-id-to-thread last-id)))
3619 thread ; We return this thread.
3621 (if (stringp (car thread))
3623 ;; If we use dummy roots, then we have to remove the
3624 ;; dummy root as well.
3625 (when (eq gnus-summary-make-false-root 'dummy)
3626 ;; We go to the dummy root by going to
3627 ;; the first sub-"thread", and then one line up.
3628 (gnus-summary-goto-article
3629 (mail-header-number (caadr thread)))
3632 (gnus-data-compute-positions))
3633 (setq thread (cdr thread))
3635 (gnus-remove-thread-1 (car thread))
3636 (setq thread (cdr thread))))
3637 (gnus-remove-thread-1 thread))))))))
3639 (defun gnus-remove-thread-1 (thread)
3640 "Remove the thread THREAD recursively."
3641 (let ((number (mail-header-number (pop thread)))
3643 (setq thread (reverse thread))
3645 (gnus-remove-thread-1 (pop thread)))
3646 (when (setq d (gnus-data-find number))
3647 (goto-char (gnus-data-pos d))
3648 (gnus-summary-show-thread)
3651 (- (gnus-point-at-bol)
3653 (1+ (gnus-point-at-eol))
3654 (gnus-delete-line)))))))
3656 (defun gnus-sort-threads (threads)
3658 (if (not gnus-thread-sort-functions)
3660 (gnus-message 8 "Sorting threads...")
3662 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3663 (gnus-message 8 "Sorting threads...done"))))
3665 (defun gnus-sort-articles (articles)
3667 (when gnus-article-sort-functions
3668 (gnus-message 7 "Sorting articles...")
3670 (setq gnus-newsgroup-headers
3671 (sort articles (gnus-make-sort-function
3672 gnus-article-sort-functions)))
3673 (gnus-message 7 "Sorting articles...done"))))
3675 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3676 (defmacro gnus-thread-header (thread)
3677 ;; Return header of first article in THREAD.
3678 ;; Note that THREAD must never, ever be anything else than a variable -
3679 ;; using some other form will lead to serious barfage.
3680 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3681 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3682 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3685 (defsubst gnus-article-sort-by-number (h1 h2)
3686 "Sort articles by article number."
3687 (< (mail-header-number h1)
3688 (mail-header-number h2)))
3690 (defun gnus-thread-sort-by-number (h1 h2)
3691 "Sort threads by root article number."
3692 (gnus-article-sort-by-number
3693 (gnus-thread-header h1) (gnus-thread-header h2)))
3695 (defsubst gnus-article-sort-by-lines (h1 h2)
3696 "Sort articles by article Lines header."
3697 (< (mail-header-lines h1)
3698 (mail-header-lines h2)))
3700 (defun gnus-thread-sort-by-lines (h1 h2)
3701 "Sort threads by root article Lines header."
3702 (gnus-article-sort-by-lines
3703 (gnus-thread-header h1) (gnus-thread-header h2)))
3705 (defsubst gnus-article-sort-by-chars (h1 h2)
3706 "Sort articles by octet length."
3707 (< (mail-header-chars h1)
3708 (mail-header-chars h2)))
3710 (defun gnus-thread-sort-by-chars (h1 h2)
3711 "Sort threads by root article octet length."
3712 (gnus-article-sort-by-chars
3713 (gnus-thread-header h1) (gnus-thread-header h2)))
3715 (defsubst gnus-article-sort-by-author (h1 h2)
3716 "Sort articles by root author."
3718 (let ((addr (car (mime-entity-read-field h1 'From))))
3719 (or (std11-full-name-string addr)
3720 (std11-address-string addr)
3722 (let ((addr (car (mime-entity-read-field h2 'From))))
3723 (or (std11-full-name-string addr)
3724 (std11-address-string addr)
3728 (defun gnus-thread-sort-by-author (h1 h2)
3729 "Sort threads by root author."
3730 (gnus-article-sort-by-author
3731 (gnus-thread-header h1) (gnus-thread-header h2)))
3733 (defsubst gnus-article-sort-by-subject (h1 h2)
3734 "Sort articles by root subject."
3736 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3737 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3739 (defun gnus-thread-sort-by-subject (h1 h2)
3740 "Sort threads by root subject."
3741 (gnus-article-sort-by-subject
3742 (gnus-thread-header h1) (gnus-thread-header h2)))
3744 (defsubst gnus-article-sort-by-date (h1 h2)
3745 "Sort articles by root article date."
3747 (gnus-date-get-time (mail-header-date h1))
3748 (gnus-date-get-time (mail-header-date h2))))
3750 (defun gnus-thread-sort-by-date (h1 h2)
3751 "Sort threads by root article date."
3752 (gnus-article-sort-by-date
3753 (gnus-thread-header h1) (gnus-thread-header h2)))
3755 (defsubst gnus-article-sort-by-score (h1 h2)
3756 "Sort articles by root article score.
3757 Unscored articles will be counted as having a score of zero."
3758 (> (or (cdr (assq (mail-header-number h1)
3759 gnus-newsgroup-scored))
3760 gnus-summary-default-score 0)
3761 (or (cdr (assq (mail-header-number h2)
3762 gnus-newsgroup-scored))
3763 gnus-summary-default-score 0)))
3765 (defun gnus-thread-sort-by-score (h1 h2)
3766 "Sort threads by root article score."
3767 (gnus-article-sort-by-score
3768 (gnus-thread-header h1) (gnus-thread-header h2)))
3770 (defun gnus-thread-sort-by-total-score (h1 h2)
3771 "Sort threads by the sum of all scores in the thread.
3772 Unscored articles will be counted as having a score of zero."
3773 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3775 (defun gnus-thread-total-score (thread)
3776 ;; This function find the total score of THREAD.
3777 (cond ((null thread)
3780 (if (stringp (car thread))
3781 (apply gnus-thread-score-function 0
3782 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3783 (gnus-thread-total-score-1 thread)))
3785 (gnus-thread-total-score-1 (list thread)))))
3787 (defun gnus-thread-total-score-1 (root)
3788 ;; This function find the total score of the thread below ROOT.
3789 (setq root (car root))
3790 (apply gnus-thread-score-function
3792 (mapcar 'gnus-thread-total-score
3793 (cdr (gnus-id-to-thread (mail-header-id root))))
3794 (when (> (mail-header-number root) 0)
3795 (list (or (cdr (assq (mail-header-number root)
3796 gnus-newsgroup-scored))
3797 gnus-summary-default-score 0))))
3798 (list gnus-summary-default-score)
3801 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3802 (defvar gnus-tmp-prev-subject nil)
3803 (defvar gnus-tmp-false-parent nil)
3804 (defvar gnus-tmp-root-expunged nil)
3805 (defvar gnus-tmp-dummy-line nil)
3807 (defvar gnus-tmp-header)
3808 (defun gnus-extra-header (type &optional header)
3809 "Return the extra header of TYPE."
3810 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3813 (defun gnus-summary-prepare-threads (threads)
3814 "Prepare summary buffer from THREADS and indentation LEVEL.
3815 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3816 or a straight list of headers."
3817 (gnus-message 7 "Generating summary...")
3819 (setq gnus-newsgroup-threads threads)
3822 (let ((gnus-tmp-level 0)
3823 (default-score (or gnus-summary-default-score 0))
3824 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3825 thread number subject stack state gnus-tmp-gathered beg-match
3826 new-roots gnus-tmp-new-adopts thread-end
3827 gnus-tmp-header gnus-tmp-unread
3828 gnus-tmp-replied gnus-tmp-subject-or-nil
3829 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3830 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3831 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3833 (setq gnus-tmp-prev-subject nil)
3835 (if (vectorp (car threads))
3836 ;; If this is a straight (sic) list of headers, then a
3837 ;; threaded summary display isn't required, so we just create
3838 ;; an unthreaded one.
3839 (gnus-summary-prepare-unthreaded threads)
3841 ;; Do the threaded display.
3843 (while (or threads stack gnus-tmp-new-adopts new-roots)
3845 (if (and (= gnus-tmp-level 0)
3848 (not gnus-tmp-false-parent)
3849 (or gnus-tmp-new-adopts new-roots))
3850 (if gnus-tmp-new-adopts
3851 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3852 thread (list (car gnus-tmp-new-adopts))
3853 gnus-tmp-header (caar thread)
3854 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3856 (setq thread (list (car new-roots))
3857 gnus-tmp-header (caar thread)
3858 new-roots (cdr new-roots))))
3861 ;; If there are some threads, we do them before the
3862 ;; threads on the stack.
3863 (setq thread threads
3864 gnus-tmp-header (caar thread))
3865 ;; There were no current threads, so we pop something off
3867 (setq state (car stack)
3868 gnus-tmp-level (car state)
3871 gnus-tmp-header (caar thread))))
3873 (setq gnus-tmp-false-parent nil)
3874 (setq gnus-tmp-root-expunged nil)
3875 (setq thread-end nil)
3877 (if (stringp gnus-tmp-header)
3878 ;; The header is a dummy root.
3880 ((eq gnus-summary-make-false-root 'adopt)
3881 ;; We let the first article adopt the rest.
3882 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3884 (setq gnus-tmp-gathered
3886 (lambda (h) (mail-header-number (car h)))
3889 (setq thread (cons (list (caar thread)
3892 (setq gnus-tmp-level -1
3893 gnus-tmp-false-parent t))
3894 ((eq gnus-summary-make-false-root 'empty)
3895 ;; We print adopted articles with empty subject fields.
3896 (setq gnus-tmp-gathered
3898 (lambda (h) (mail-header-number (car h)))
3901 (setq gnus-tmp-level -1))
3902 ((eq gnus-summary-make-false-root 'dummy)
3903 ;; We remember that we probably want to output a dummy
3905 (setq gnus-tmp-dummy-line gnus-tmp-header)
3906 (setq gnus-tmp-prev-subject gnus-tmp-header))
3908 ;; We do not make a root for the gathered
3909 ;; sub-threads at all.
3910 (setq gnus-tmp-level -1)))
3912 (setq number (mail-header-number gnus-tmp-header)
3913 subject (mail-header-subject gnus-tmp-header))
3916 ;; If the thread has changed subject, we might want to make
3917 ;; this subthread into a root.
3918 ((and (null gnus-thread-ignore-subject)
3919 (not (zerop gnus-tmp-level))
3920 gnus-tmp-prev-subject
3922 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3923 (setq new-roots (nconc new-roots (list (car thread)))
3925 gnus-tmp-header nil))
3926 ;; If the article lies outside the current limit,
3927 ;; then we do not display it.
3928 ((not (memq number gnus-newsgroup-limit))
3929 (setq gnus-tmp-gathered
3931 (lambda (h) (mail-header-number (car h)))
3934 (setq gnus-tmp-new-adopts (if (cdar thread)
3935 (append gnus-tmp-new-adopts
3937 gnus-tmp-new-adopts)
3939 gnus-tmp-header nil)
3940 (when (zerop gnus-tmp-level)
3941 (setq gnus-tmp-root-expunged t)))
3942 ;; Perhaps this article is to be marked as read?
3943 ((and gnus-summary-mark-below
3944 (< (or (cdr (assq number gnus-newsgroup-scored))
3946 gnus-summary-mark-below)
3947 ;; Don't touch sparse articles.
3948 (not (gnus-summary-article-sparse-p number))
3949 (not (gnus-summary-article-ancient-p number)))
3950 (setq gnus-newsgroup-unreads
3951 (delq number gnus-newsgroup-unreads))
3952 (if gnus-newsgroup-auto-expire
3953 (push number gnus-newsgroup-expirable)
3954 (push (cons number gnus-low-score-mark)
3955 gnus-newsgroup-reads))))
3957 (when gnus-tmp-header
3958 ;; We may have an old dummy line to output before this
3960 (when (and gnus-tmp-dummy-line
3963 (mail-header-subject gnus-tmp-header)))
3964 (gnus-summary-insert-dummy-line
3965 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3966 (setq gnus-tmp-dummy-line nil))
3968 ;; Compute the mark.
3969 (setq gnus-tmp-unread (gnus-article-mark number))
3971 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3972 gnus-tmp-header gnus-tmp-level)
3973 gnus-newsgroup-data)
3975 ;; Actually insert the line.
3977 gnus-tmp-subject-or-nil
3979 ((and gnus-thread-ignore-subject
3980 gnus-tmp-prev-subject
3981 (not (inline (gnus-subject-equal
3982 gnus-tmp-prev-subject subject))))
3984 ((zerop gnus-tmp-level)
3985 (if (and (eq gnus-summary-make-false-root 'empty)
3986 (memq number gnus-tmp-gathered)
3987 gnus-tmp-prev-subject
3988 (inline (gnus-subject-equal
3989 gnus-tmp-prev-subject subject)))
3990 gnus-summary-same-subject
3992 (t gnus-summary-same-subject)))
3993 (if (and (eq gnus-summary-make-false-root 'adopt)
3994 (= gnus-tmp-level 1)
3995 (memq number gnus-tmp-gathered))
3996 (setq gnus-tmp-opening-bracket ?\<
3997 gnus-tmp-closing-bracket ?\>)
3998 (setq gnus-tmp-opening-bracket ?\[
3999 gnus-tmp-closing-bracket ?\]))
4001 gnus-tmp-indentation
4002 (aref gnus-thread-indent-array gnus-tmp-level)
4003 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4004 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4005 gnus-summary-default-score 0)
4007 (if (or (null gnus-summary-default-score)
4008 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4009 gnus-summary-zcore-fuzz))
4011 (if (< gnus-tmp-score gnus-summary-default-score)
4012 gnus-score-below-mark gnus-score-over-mark))
4014 (cond ((memq number gnus-newsgroup-processable)
4016 ((memq number gnus-newsgroup-cached)
4018 ((memq number gnus-newsgroup-replied)
4020 ((memq number gnus-newsgroup-saved)
4022 (t gnus-unread-mark))
4023 gnus-tmp-from (mail-header-from gnus-tmp-header)
4026 ((string-match "<[^>]+> *$" gnus-tmp-from)
4027 (setq beg-match (match-beginning 0))
4028 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4029 (substring gnus-tmp-from (1+ (match-beginning 0))
4030 (1- (match-end 0))))
4031 (substring gnus-tmp-from 0 beg-match)))
4032 ((string-match "(.+)" gnus-tmp-from)
4033 (substring gnus-tmp-from
4034 (1+ (match-beginning 0)) (1- (match-end 0))))
4036 (when (string= gnus-tmp-name "")
4037 (setq gnus-tmp-name gnus-tmp-from))
4038 (unless (numberp gnus-tmp-lines)
4039 (setq gnus-tmp-lines 0))
4040 (gnus-put-text-property
4042 (progn (eval gnus-summary-line-format-spec) (point))
4043 'gnus-number number)
4046 (gnus-run-hooks 'gnus-summary-update-hook)
4049 (setq gnus-tmp-prev-subject subject)))
4051 (when (nth 1 thread)
4052 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4053 (incf gnus-tmp-level)
4054 (setq threads (if thread-end nil (cdar thread)))
4056 (setq gnus-tmp-level 0)))))
4057 (gnus-message 7 "Generating summary...done"))
4059 (defun gnus-summary-prepare-unthreaded (headers)
4060 "Generate an unthreaded summary buffer based on HEADERS."
4061 (let (header number mark)
4066 ;; We may have to root out some bad articles...
4067 (when (memq (setq number (mail-header-number
4068 (setq header (pop headers))))
4069 gnus-newsgroup-limit)
4070 ;; Mark article as read when it has a low score.
4071 (when (and gnus-summary-mark-below
4072 (< (or (cdr (assq number gnus-newsgroup-scored))
4073 gnus-summary-default-score 0)
4074 gnus-summary-mark-below)
4075 (not (gnus-summary-article-ancient-p number)))
4076 (setq gnus-newsgroup-unreads
4077 (delq number gnus-newsgroup-unreads))
4078 (if gnus-newsgroup-auto-expire
4079 (push number gnus-newsgroup-expirable)
4080 (push (cons number gnus-low-score-mark)
4081 gnus-newsgroup-reads)))
4083 (setq mark (gnus-article-mark number))
4084 (push (gnus-data-make number mark (1+ (point)) header 0)
4085 gnus-newsgroup-data)
4086 (gnus-summary-insert-line
4088 mark (memq number gnus-newsgroup-replied)
4089 (memq number gnus-newsgroup-expirable)
4090 (mail-header-subject header) nil
4091 (cdr (assq number gnus-newsgroup-scored))
4092 (memq number gnus-newsgroup-processable))))))
4094 (defun gnus-summary-remove-list-identifiers ()
4095 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4096 (let ((regexp (if (stringp gnus-list-identifiers)
4097 gnus-list-identifiers
4098 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4099 (dolist (header gnus-newsgroup-headers)
4100 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4101 (mail-header-subject header))
4102 (mail-header-set-subject
4103 header (concat (substring (mail-header-subject header)
4104 0 (match-beginning 2))
4105 (substring (mail-header-subject header)
4106 (match-end 2))))))))
4108 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4109 "Select newsgroup GROUP.
4110 If READ-ALL is non-nil, all articles in the group are selected.
4111 If SELECT-ARTICLES, only select those articles from GROUP."
4112 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4113 ;;!!! Dirty hack; should be removed.
4114 (gnus-summary-ignore-duplicates
4115 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4117 gnus-summary-ignore-duplicates))
4118 (info (nth 2 entry))
4119 articles fetched-articles cached)
4121 (unless (gnus-check-server
4122 (setq gnus-current-select-method
4123 (gnus-find-method-for-group group)))
4124 (error "Couldn't open server"))
4126 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4127 (gnus-activate-group group) ; Or we can activate it...
4128 (progn ; Or we bug out.
4129 (when (equal major-mode 'gnus-summary-mode)
4130 (kill-buffer (current-buffer)))
4131 (error "Couldn't request group %s: %s"
4132 group (gnus-status-message group))))
4134 (unless (gnus-request-group group t)
4135 (when (equal major-mode 'gnus-summary-mode)
4136 (kill-buffer (current-buffer)))
4137 (error "Couldn't request group %s: %s"
4138 group (gnus-status-message group)))
4140 (setq gnus-newsgroup-name group)
4141 (setq gnus-newsgroup-unselected nil)
4142 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4143 (gnus-summary-setup-default-charset)
4145 ;; Adjust and set lists of article marks.
4147 (gnus-adjust-marked-articles info))
4149 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4151 (if (gnus-virtual-group-p group)
4152 gnus-newsgroup-cached
4153 (gnus-cache-articles-in-group group)))
4155 (setq gnus-newsgroup-unreads
4156 (gnus-set-difference
4157 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4158 gnus-newsgroup-dormant))
4160 (setq gnus-newsgroup-processable nil)
4162 (gnus-update-read-articles group gnus-newsgroup-unreads)
4164 (if (setq articles select-articles)
4165 (setq gnus-newsgroup-unselected
4166 (gnus-sorted-intersection
4167 gnus-newsgroup-unreads
4168 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4169 (setq articles (gnus-articles-to-read group read-all)))
4173 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4175 ((eq articles 0) nil)
4177 ;; Init the dependencies hash table.
4178 (setq gnus-newsgroup-dependencies
4179 (gnus-make-hashtable (length articles)))
4180 (gnus-set-global-variables)
4181 ;; Retrieve the headers and read them in.
4182 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4183 (setq gnus-newsgroup-headers
4184 (gnus-retrieve-parsed-headers
4185 articles gnus-newsgroup-name
4186 ;; We might want to fetch old headers, but
4187 ;; not if there is only 1 article.
4188 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4189 (not (numberp gnus-fetch-old-headers)))
4190 (> (length articles) 1))
4191 gnus-fetch-old-headers)))
4192 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4194 ;; Suppress duplicates?
4195 (when gnus-suppress-duplicates
4196 (gnus-dup-suppress-articles))
4198 ;; Set the initial limit.
4199 (setq gnus-newsgroup-limit (copy-sequence articles))
4200 ;; Remove canceled articles from the list of unread articles.
4201 (setq gnus-newsgroup-unreads
4202 (gnus-set-sorted-intersection
4203 gnus-newsgroup-unreads
4204 (setq fetched-articles
4205 (mapcar (lambda (headers) (mail-header-number headers))
4206 gnus-newsgroup-headers))))
4207 ;; Removed marked articles that do not exist.
4208 (gnus-update-missing-marks
4209 (gnus-sorted-complement fetched-articles articles))
4211 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4213 (setq gnus-newsgroup-cached cached))
4215 ;; We might want to build some more threads first.
4216 (when (and gnus-fetch-old-headers
4217 (eq gnus-headers-retrieved-by 'nov))
4218 (if (eq gnus-fetch-old-headers 'invisible)
4219 (gnus-build-all-threads)
4220 (gnus-build-old-threads)))
4221 ;; Let the Gnus agent mark articles as read.
4223 (gnus-agent-get-undownloaded-list))
4224 ;; Remove list identifiers from subject
4225 (when gnus-list-identifiers
4226 (gnus-summary-remove-list-identifiers))
4227 ;; Check whether auto-expire is to be done in this group.
4228 (setq gnus-newsgroup-auto-expire
4229 (gnus-group-auto-expirable-p group))
4230 ;; Set up the article buffer now, if necessary.
4231 (unless gnus-single-article-buffer
4232 (gnus-article-setup-buffer))
4233 ;; First and last article in this newsgroup.
4234 (when gnus-newsgroup-headers
4235 (setq gnus-newsgroup-begin
4236 (mail-header-number (car gnus-newsgroup-headers))
4239 (gnus-last-element gnus-newsgroup-headers))))
4240 ;; GROUP is successfully selected.
4241 (or gnus-newsgroup-headers t)))))
4243 (defun gnus-articles-to-read (group &optional read-all)
4244 ;; Find out what articles the user wants to read.
4246 ;; Select all articles if `read-all' is non-nil, or if there
4247 ;; are no unread articles.
4249 (and (zerop (length gnus-newsgroup-marked))
4250 (zerop (length gnus-newsgroup-unreads)))
4251 (eq (gnus-group-find-parameter group 'display)
4254 (gnus-uncompress-range (gnus-active group))
4255 (gnus-cache-articles-in-group group))
4256 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4257 (copy-sequence gnus-newsgroup-unreads))
4259 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4260 (scored (length scored-list))
4261 (number (length articles))
4262 (marked (+ (length gnus-newsgroup-marked)
4263 (length gnus-newsgroup-dormant)))
4271 ((and (or (<= scored marked) (= scored number))
4272 (natnump gnus-large-newsgroup)
4273 (> number gnus-large-newsgroup))
4274 (let* ((cursor-in-echo-area nil)
4275 (input (read-from-minibuffer
4277 "How many articles from %s (max %d): "
4278 (gnus-limit-string gnus-newsgroup-name 35)
4280 (cons (number-to-string gnus-large-newsgroup)
4282 (if (string-match "^[ \t]*$" input)
4285 ((and (> scored marked) (< scored number)
4286 (> (- scored number) 20))
4289 (format "%s %s (%d scored, %d total): "
4290 "How many articles from"
4291 group scored number))))
4292 (if (string-match "^[ \t]*$" input)
4296 (setq select (if (stringp select) (string-to-number select) select))
4297 (if (or (null select) (zerop select))
4299 (if (and (not (zerop scored)) (<= (abs select) scored))
4301 (setq articles (sort scored-list '<))
4302 (setq number (length articles)))
4303 (setq articles (copy-sequence articles)))
4305 (when (< (abs select) number)
4307 ;; Select the N oldest articles.
4308 (setcdr (nthcdr (1- (abs select)) articles) nil)
4309 ;; Select the N most recent articles.
4310 (setq articles (nthcdr (- number select) articles))))
4311 (setq gnus-newsgroup-unselected
4312 (gnus-sorted-intersection
4313 gnus-newsgroup-unreads
4314 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4315 (when gnus-alter-articles-to-read-function
4316 (setq gnus-newsgroup-unreads
4318 (funcall gnus-alter-articles-to-read-function
4319 gnus-newsgroup-name gnus-newsgroup-unreads)
4323 (defun gnus-killed-articles (killed articles)
4326 (when (inline (gnus-member-of-range (car articles) killed))
4327 (push (car articles) out))
4328 (setq articles (cdr articles)))
4331 (defun gnus-uncompress-marks (marks)
4332 "Uncompress the mark ranges in MARKS."
4333 (let ((uncompressed '(score bookmark))
4336 (if (memq (caar marks) uncompressed)
4337 (push (car marks) out)
4338 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4339 (setq marks (cdr marks)))
4342 (defun gnus-adjust-marked-articles (info)
4343 "Set all article lists and remove all marks that are no longer valid."
4344 (let* ((marked-lists (gnus-info-marks info))
4345 (active (gnus-active (gnus-info-group info)))
4348 (types gnus-article-mark-lists)
4349 (uncompressed '(score bookmark killed))
4350 marks var articles article mark)
4353 (setq marks (pop marked-lists))
4354 (set (setq var (intern (format "gnus-newsgroup-%s"
4355 (car (rassq (setq mark (car marks))
4357 (if (memq (car marks) uncompressed) (cdr marks)
4358 (gnus-uncompress-range (cdr marks))))
4360 (setq articles (symbol-value var))
4362 ;; All articles have to be subsets of the active articles.
4364 ;; Adjust "simple" lists.
4365 ((memq mark '(tick dormant expire reply save))
4367 (when (or (< (setq article (pop articles)) min) (> article max))
4368 (set var (delq article (symbol-value var))))))
4370 ((memq mark uncompressed)
4371 (when (not (listp (cdr (symbol-value var))))
4372 (set var (list (symbol-value var))))
4373 (when (not (listp (cdr articles)))
4374 (setq articles (list articles)))
4376 (when (or (not (consp (setq article (pop articles))))
4377 (< (car article) min)
4378 (> (car article) max))
4379 (set var (delq article (symbol-value var))))))))))
4381 (defun gnus-update-missing-marks (missing)
4382 "Go through the list of MISSING articles and remove them from the mark lists."
4384 (let ((types gnus-article-mark-lists)
4386 ;; Go through all types.
4388 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4389 (when (symbol-value var)
4390 ;; This list has articles. So we delete all missing articles
4394 (set var (delq (pop m) (symbol-value var)))))))))
4396 (defun gnus-update-marks ()
4397 "Enter the various lists of marked articles into the newsgroup info list."
4398 (let ((types gnus-article-mark-lists)
4399 (info (gnus-get-info gnus-newsgroup-name))
4400 (uncompressed '(score bookmark killed))
4401 type list newmarked symbol delta-marks)
4403 ;; Add all marks lists to the list of marks lists.
4404 (while (setq type (pop types))
4405 (setq list (symbol-value
4407 (intern (format "gnus-newsgroup-%s"
4411 ;; Get rid of the entries of the articles that have the
4413 (when (and (eq (cdr type) 'score)
4417 (prev (cons nil list))
4420 (if (or (not (consp (car arts)))
4421 (= (cdar arts) gnus-summary-default-score))
4422 (setcdr prev (cdr arts))
4424 (setq arts (cdr arts)))
4425 (setq list (cdr all)))))
4427 (unless (memq (cdr type) uncompressed)
4428 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4430 (when (gnus-check-backend-function
4431 'request-set-mark gnus-newsgroup-name)
4432 ;; uncompressed:s are not proper flags (they are cons cells)
4433 ;; cache is a internal gnus flag
4434 (unless (memq (cdr type) (cons 'cache uncompressed))
4435 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4436 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4437 (add (gnus-remove-from-range
4438 (gnus-copy-sequence list) old)))
4440 (push (list add 'add (list (cdr type))) delta-marks))
4442 (push (list del 'del (list (cdr type))) delta-marks)))))
4445 (push (cons (cdr type) list) newmarked)))
4448 (unless (gnus-check-group gnus-newsgroup-name)
4449 (error "Can't open server for %s" gnus-newsgroup-name))
4450 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4452 ;; Enter these new marks into the info of the group.
4454 (setcar (nthcdr 3 info) newmarked)
4455 ;; Add the marks lists to the end of the info.
4457 (setcdr (nthcdr 2 info) (list newmarked))))
4459 ;; Cut off the end of the info if there's nothing else there.
4463 (when (nthcdr (decf i) info)
4464 (setcdr (nthcdr i info) nil)))))))
4466 (defun gnus-set-mode-line (where)
4467 "This function sets the mode line of the article or summary buffers.
4468 If WHERE is `summary', the summary mode line format will be used."
4469 ;; Is this mode line one we keep updated?
4470 (when (and (memq where gnus-updated-mode-lines)
4472 (intern (format "gnus-%s-mode-line-format-spec" where))))
4475 ;; We evaluate this in the summary buffer since these
4476 ;; variables are buffer-local to that buffer.
4477 (set-buffer gnus-summary-buffer)
4478 ;; We bind all these variables that are used in the `eval' form
4480 (let* ((mformat (symbol-value
4482 (format "gnus-%s-mode-line-format-spec" where))))
4483 (gnus-tmp-group-name gnus-newsgroup-name)
4484 (gnus-tmp-article-number (or gnus-current-article 0))
4485 (gnus-tmp-unread gnus-newsgroup-unreads)
4486 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4487 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4488 (gnus-tmp-unread-and-unselected
4489 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4490 (zerop gnus-tmp-unselected))
4492 ((zerop gnus-tmp-unselected)
4493 (format "{%d more}" gnus-tmp-unread-and-unticked))
4494 (t (format "{%d(+%d) more}"
4495 gnus-tmp-unread-and-unticked
4496 gnus-tmp-unselected))))
4498 (if (and gnus-current-headers
4499 (vectorp gnus-current-headers))
4500 (gnus-mode-string-quote
4501 (mail-header-subject gnus-current-headers))
4503 bufname-length max-len
4504 gnus-tmp-header);; passed as argument to any user-format-funcs
4505 (setq mode-string (eval mformat))
4506 (setq bufname-length (if (string-match "%b" mode-string)
4509 (if (eq where 'summary)
4511 (get-buffer gnus-article-buffer))))
4514 (setq max-len (max 4 (if gnus-mode-non-string-length
4516 gnus-mode-non-string-length
4518 (length mode-string))))
4519 ;; We might have to chop a bit of the string off...
4520 (when (> (length mode-string) max-len)
4522 (concat (gnus-truncate-string mode-string (- max-len 3))
4524 ;; Pad the mode string a bit.
4525 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4526 ;; Update the mode line.
4527 (setq mode-line-buffer-identification
4528 (gnus-mode-line-buffer-identification (list mode-string)))
4529 (set-buffer-modified-p t))))
4531 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4532 "Go through the HEADERS list and add all Xrefs to a hash table.
4533 The resulting hash table is returned, or nil if no Xrefs were found."
4534 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4535 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4536 (xref-hashtb (gnus-make-hashtable))
4537 start group entry number xrefs header)
4539 (setq header (pop headers))
4540 (when (and (setq xrefs (mail-header-xref header))
4541 (not (memq (setq number (mail-header-number header))
4544 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4545 (setq start (match-end 0))
4546 (setq group (if prefix
4547 (concat prefix (substring xrefs (match-beginning 1)
4549 (substring xrefs (match-beginning 1) (match-end 1))))
4551 (string-to-int (substring xrefs (match-beginning 2)
4553 (if (setq entry (gnus-gethash group xref-hashtb))
4554 (setcdr entry (cons number (cdr entry)))
4555 (gnus-sethash group (cons number nil) xref-hashtb)))))
4556 (and start xref-hashtb)))
4558 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4559 "Look through all the headers and mark the Xrefs as read."
4560 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4561 name entry info xref-hashtb idlist method nth4)
4563 (set-buffer gnus-group-buffer)
4564 (when (setq xref-hashtb
4565 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4568 (unless (string= from-newsgroup (setq name (symbol-name group)))
4569 (setq idlist (symbol-value group))
4570 ;; Dead groups are not updated.
4572 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4574 (when (stringp (setq nth4 (gnus-info-method info)))
4575 (setq nth4 (gnus-server-to-method nth4))))
4576 ;; Only do the xrefs if the group has the same
4577 ;; select method as the group we have just read.
4578 (or (gnus-methods-equal-p
4579 nth4 (gnus-find-method-for-group from-newsgroup))
4581 (equal nth4 (setq method (gnus-find-method-for-group
4583 (and (equal (car nth4) (car method))
4584 (equal (nth 1 nth4) (nth 1 method))))
4585 gnus-use-cross-reference
4586 (or (not (eq gnus-use-cross-reference t))
4588 ;; Only do cross-references on subscribed
4589 ;; groups, if that is what is wanted.
4590 (<= (gnus-info-level info) gnus-level-subscribed))
4591 (gnus-group-make-articles-read name idlist))))
4594 (defun gnus-compute-read-articles (group articles)
4595 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4596 (info (nth 2 entry))
4597 (active (gnus-active group))
4600 ;; First peel off all invalid article numbers.
4602 (let ((ids articles)
4604 (while (setq id (pop ids))
4605 (when (and first (> id (cdr active)))
4606 ;; We'll end up in this situation in one particular
4607 ;; obscure situation. If you re-scan a group and get
4608 ;; a new article that is cross-posted to a different
4609 ;; group that has not been re-scanned, you might get
4610 ;; crossposted article that has a higher number than
4611 ;; Gnus believes possible. So we re-activate this
4612 ;; group as well. This might mean doing the
4613 ;; crossposting thingy will *increase* the number
4614 ;; of articles in some groups. Tsk, tsk.
4615 (setq active (or (gnus-activate-group group) active)))
4616 (when (or (> id (cdr active))
4617 (< id (car active)))
4618 (setq articles (delq id articles))))))
4619 ;; If the read list is nil, we init it.
4621 (null (gnus-info-read info))
4623 (setq ninfo (cons 1 (1- (car active))))
4624 (setq ninfo (gnus-info-read info)))
4625 ;; Then we add the read articles to the range.
4627 ninfo (setq articles (sort articles '<))))))
4629 (defun gnus-group-make-articles-read (group articles)
4630 "Update the info of GROUP to say that ARTICLES are read."
4632 (entry (gnus-gethash group gnus-newsrc-hashtb))
4633 (info (nth 2 entry))
4634 (active (gnus-active group))
4637 (setq range (gnus-compute-read-articles group articles))
4639 (set-buffer gnus-group-buffer)
4642 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4643 (gnus-info-set-read ',info ',(gnus-info-read info))
4644 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4645 (gnus-group-update-group ,group t))))
4646 ;; Add the read articles to the range.
4647 (gnus-info-set-read info range)
4648 ;; Then we have to re-compute how many unread
4649 ;; articles there are in this group.
4653 (setq num (- (1+ (cdr active)) (car active))))
4654 ((not (listp (cdr range)))
4655 (setq num (- (cdr active) (- (1+ (cdr range))
4659 (if (numberp (car range))
4661 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4662 (setq range (cdr range)))
4663 (setq num (- (cdr active) num))))
4664 ;; Update the number of unread articles.
4666 ;; Update the group buffer.
4667 (gnus-group-update-group group t)))))
4669 (defvar gnus-newsgroup-none-id 0)
4671 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4672 (let ((cur nntp-server-buffer)
4675 (save-excursion (set-buffer gnus-summary-buffer)
4676 gnus-newsgroup-dependencies)))
4678 (mail-parse-charset gnus-newsgroup-charset)
4679 (mail-parse-ignored-charsets
4680 (save-excursion (condition-case nil
4681 (set-buffer gnus-summary-buffer)
4683 gnus-newsgroup-ignored-charsets)))
4685 (set-buffer nntp-server-buffer)
4686 ;; Translate all TAB characters into SPACE characters.
4687 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4688 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4689 (gnus-run-hooks 'gnus-parse-headers-hook)
4690 (let ((case-fold-search t)
4691 in-reply-to header p lines chars ctype)
4692 (goto-char (point-min))
4693 ;; Search to the beginning of the next header. Error messages
4694 ;; do not begin with 2 or 3.
4695 (while (re-search-forward "^[23][0-9]+ " nil t)
4698 ;; This implementation of this function, with nine
4699 ;; search-forwards instead of the one re-search-forward and
4700 ;; a case (which basically was the old function) is actually
4701 ;; about twice as fast, even though it looks messier. You
4702 ;; can't have everything, I guess. Speed and elegance
4703 ;; doesn't always go hand in hand.
4706 (make-full-mail-header
4712 (narrow-to-region (point)
4713 (or (and (search-forward "\n.\n" nil t)
4719 (if (search-forward "\nsubject: " nil t)
4720 (buffer-substring (match-end 0) (std11-field-end))
4725 (if (search-forward "\nfrom: " nil t)
4726 (buffer-substring (match-end 0) (std11-field-end))
4731 (if (search-forward "\ndate: " nil t)
4732 (buffer-substring (match-end 0) (std11-field-end))
4737 (setq id (if (re-search-forward
4738 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4739 ;; We do it this way to make sure the Message-ID
4740 ;; is (somewhat) syntactically valid.
4741 (buffer-substring (match-beginning 1)
4743 ;; If there was no message-id, we just fake one
4744 ;; to make subsequent routines simpler.
4745 (nnheader-generate-fake-message-id))))
4749 (if (search-forward "\nreferences: " nil t)
4753 (buffer-substring (match-end 0) (std11-field-end))
4758 (search-backward ">" end t)
4761 (search-backward "<" end t)
4763 ;; Get the references from the in-reply-to header if there
4764 ;; were no references and the in-reply-to header looks
4766 (if (and (search-forward "\nin-reply-to: " nil t)
4768 (buffer-substring (match-end 0)
4770 (string-match "<[^>]+>" in-reply-to))
4772 (setq ref (substring in-reply-to (match-beginning 0)
4774 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4775 (setq ref2 (substring in-reply-to (match-beginning 0)
4777 (when (> (length ref2) (length ref))
4784 (if (search-forward "\nchars: " nil t)
4785 (if (numberp (setq chars (ignore-errors (read cur))))
4791 (if (search-forward "\nlines: " nil t)
4792 (if (numberp (setq lines (ignore-errors (read cur))))
4798 (and (search-forward "\nxref: " nil t)
4799 (buffer-substring (match-end 0) (std11-field-end))))
4801 (when gnus-extra-headers
4802 (let ((extra gnus-extra-headers)
4806 (when (search-forward
4807 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4808 (push (cons (car extra)
4809 (buffer-substring (match-end 0)
4815 (if (and (search-forward "\ncontent-type: " nil t)
4817 (buffer-substring (match-end 0) (std11-field-end))))
4818 (mime-entity-set-content-type-internal
4819 header (mime-parse-Content-Type ctype)))
4820 (when (equal id ref)
4823 (when gnus-alter-header-function
4824 (funcall gnus-alter-header-function header)
4825 (setq id (mail-header-id header)
4826 ref (gnus-parent-id (mail-header-references header))))
4829 (gnus-dependencies-add-header
4830 header dependencies force-new))
4831 (push header headers))
4832 (goto-char (point-max))
4834 (nreverse headers)))))
4836 ;; Goes through the xover lines and returns a list of vectors
4837 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4838 force-new dependencies
4839 group also-fetch-heads)
4840 "Parse the news overview data in the server buffer, and return a
4841 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4842 ;; Get the Xref when the users reads the articles since most/some
4843 ;; NNTP servers do not include Xrefs when using XOVER.
4844 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4845 (let ((mail-parse-charset gnus-newsgroup-charset)
4846 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4847 (cur nntp-server-buffer)
4848 (dependencies (or dependencies gnus-newsgroup-dependencies))
4849 number headers header)
4851 (set-buffer nntp-server-buffer)
4852 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4853 ;; Allow the user to mangle the headers before parsing them.
4854 (gnus-run-hooks 'gnus-parse-headers-hook)
4855 (goto-char (point-min))
4858 (while (and sequence (not (eobp)))
4859 (setq number (read cur))
4860 (while (and sequence
4861 (< (car sequence) number))
4862 (setq sequence (cdr sequence)))
4864 (eq number (car sequence))
4866 (setq sequence (cdr sequence))
4867 (setq header (inline
4868 (gnus-nov-parse-line
4869 number dependencies force-new))))
4870 (push header headers))
4873 (gnus-error 4 "Strange nov line (%d)"
4874 (count-lines (point-min) (point)))))
4876 ;; A common bug in inn is that if you have posted an article and
4877 ;; then retrieves the active file, it will answer correctly --
4878 ;; the new article is included. However, a NOV entry for the
4879 ;; article may not have been generated yet, so this may fail.
4880 ;; We work around this problem by retrieving the last few
4881 ;; headers using HEAD.
4882 (if (or (not also-fetch-heads)
4884 ;; We (probably) got all the headers.
4886 (let ((gnus-nov-is-evil t))
4889 (gnus-retrieve-parsed-headers sequence group)
4892 (defun gnus-article-get-xrefs ()
4893 "Fill in the Xref value in `gnus-current-headers', if necessary.
4894 This is meant to be called in `gnus-article-internal-prepare-hook'."
4895 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4896 gnus-current-headers)))
4897 (or (not gnus-use-cross-reference)
4899 (and (mail-header-xref headers)
4900 (not (string= (mail-header-xref headers) "")))
4901 (let ((case-fold-search t)
4904 (nnheader-narrow-to-headers)
4905 (goto-char (point-min))
4906 (when (or (and (not (eobp))
4907 (eq (downcase (char-after)) ?x)
4908 (looking-at "Xref:"))
4909 (search-forward "\nXref:" nil t))
4910 (goto-char (1+ (match-end 0)))
4911 (setq xref (buffer-substring (point)
4912 (progn (end-of-line) (point))))
4913 (mail-header-set-xref headers xref)))))))
4915 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4916 "Find article ID and insert the summary line for that article.
4917 OLD-HEADER can either be a header or a line number to insert
4918 the subject line on."
4919 (let* ((line (and (numberp old-header) old-header))
4920 (old-header (and (vectorp old-header) old-header))
4921 (header (cond ((and old-header use-old-header)
4924 (gnus-number-to-header id))
4925 (gnus-number-to-header id))
4927 (gnus-read-header id))))
4928 (number (and (numberp id) id))
4931 ;; Rebuild the thread that this article is part of and go to the
4932 ;; article we have fetched.
4933 (when (and (not gnus-show-threads)
4936 (setq d (gnus-data-find (mail-header-number old-header))))
4937 (goto-char (gnus-data-pos d))
4940 (- (gnus-point-at-bol)
4942 (1+ (gnus-point-at-eol))
4943 (gnus-delete-line))))))
4945 (mail-header-set-number header (mail-header-number old-header)))
4946 (setq gnus-newsgroup-sparse
4947 (delq (setq number (mail-header-number header))
4948 gnus-newsgroup-sparse))
4949 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4950 (push number gnus-newsgroup-limit)
4951 (gnus-rebuild-thread (mail-header-id header) line)
4952 (gnus-summary-goto-subject number nil t))
4953 (when (and (numberp number)
4955 ;; We have to update the boundaries even if we can't fetch the
4956 ;; article if ID is a number -- so that the next `P' or `N'
4957 ;; command will fetch the previous (or next) article even
4958 ;; if the one we tried to fetch this time has been canceled.
4959 (when (> number gnus-newsgroup-end)
4960 (setq gnus-newsgroup-end number))
4961 (when (< number gnus-newsgroup-begin)
4962 (setq gnus-newsgroup-begin number))
4963 (setq gnus-newsgroup-unselected
4964 (delq number gnus-newsgroup-unselected)))
4965 ;; Report back a success?
4966 (and header (mail-header-number header))))
4968 ;;; Process/prefix in the summary buffer
4970 (defun gnus-summary-work-articles (n)
4971 "Return a list of articles to be worked upon.
4972 The prefix argument, the list of process marked articles, and the
4973 current article will be taken into consideration."
4975 (set-buffer gnus-summary-buffer)
4978 ;; A numerical prefix has been given.
4979 (setq n (prefix-numeric-value n))
4980 (let ((backward (< n 0))
4981 (n (abs (prefix-numeric-value n)))
4986 (push (setq article (gnus-summary-article-number))
4989 (gnus-summary-find-prev nil article)
4990 (gnus-summary-find-next nil article)))
4992 (nreverse articles)))
4993 ((and (gnus-region-active-p) (mark))
4994 (message "region active")
4995 ;; Work on the region between point and mark.
4996 (let ((max (max (point) (mark)))
4999 (goto-char (min (point) (mark)))
5002 (push (setq article (gnus-summary-article-number)) articles)
5003 (gnus-summary-find-next nil article)
5005 (nreverse articles))))
5006 (gnus-newsgroup-processable
5007 ;; There are process-marked articles present.
5008 ;; Save current state.
5009 (gnus-summary-save-process-mark)
5011 (reverse gnus-newsgroup-processable))
5013 ;; Just return the current article.
5014 (list (gnus-summary-article-number))))))
5016 (defmacro gnus-summary-iterate (arg &rest forms)
5017 "Iterate over the process/prefixed articles and do FORMS.
5018 ARG is the interactive prefix given to the command. FORMS will be
5019 executed with point over the summary line of the articles."
5020 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5021 `(let ((,articles (gnus-summary-work-articles ,arg)))
5023 (gnus-summary-goto-subject (car ,articles))
5027 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5028 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5030 (defun gnus-summary-save-process-mark ()
5031 "Push the current set of process marked articles on the stack."
5033 (push (copy-sequence gnus-newsgroup-processable)
5034 gnus-newsgroup-process-stack))
5036 (defun gnus-summary-kill-process-mark ()
5037 "Push the current set of process marked articles on the stack and unmark."
5039 (gnus-summary-save-process-mark)
5040 (gnus-summary-unmark-all-processable))
5042 (defun gnus-summary-yank-process-mark ()
5043 "Pop the last process mark state off the stack and restore it."
5045 (unless gnus-newsgroup-process-stack
5046 (error "Empty mark stack"))
5047 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5049 (defun gnus-summary-process-mark-set (set)
5050 "Make SET into the current process marked articles."
5051 (gnus-summary-unmark-all-processable)
5053 (gnus-summary-set-process-mark (pop set))))
5055 ;;; Searching and stuff
5057 (defun gnus-summary-search-group (&optional backward use-level)
5058 "Search for next unread newsgroup.
5059 If optional argument BACKWARD is non-nil, search backward instead."
5061 (set-buffer gnus-group-buffer)
5062 (when (gnus-group-search-forward
5063 backward nil (if use-level (gnus-group-group-level) nil))
5064 (gnus-group-group-name))))
5066 (defun gnus-summary-best-group (&optional exclude-group)
5067 "Find the name of the best unread group.
5068 If EXCLUDE-GROUP, do not go to this group."
5070 (set-buffer gnus-group-buffer)
5072 (gnus-group-best-unread-group exclude-group))))
5074 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5075 (if backward (gnus-summary-find-prev)
5076 (let* ((dummy (gnus-summary-article-intangible-p))
5077 (article (or article (gnus-summary-article-number)))
5078 (arts (gnus-data-find-list article))
5080 (when (and (not dummy)
5081 (or (not gnus-summary-check-current)
5083 (not (gnus-data-unread-p (car arts)))))
5084 (setq arts (cdr arts)))
5089 (when (or (and undownloaded
5090 (eq gnus-undownloaded-mark
5091 (gnus-data-mark (car arts))))
5092 (gnus-data-unread-p (car arts)))
5093 (setq result (car arts)
5095 (setq arts (cdr arts)))
5098 (goto-char (gnus-data-pos result))
5099 (gnus-data-number result)))))
5101 (defun gnus-summary-find-prev (&optional unread article)
5102 (let* ((eobp (eobp))
5103 (article (or article (gnus-summary-article-number)))
5104 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5106 (when (and (not eobp)
5107 (or (not gnus-summary-check-current)
5109 (not (gnus-data-unread-p (car arts)))))
5110 (setq arts (cdr arts)))
5115 (when (gnus-data-unread-p (car arts))
5116 (setq result (car arts)
5118 (setq arts (cdr arts)))
5121 (goto-char (gnus-data-pos result))
5122 (gnus-data-number result))))
5124 (defun gnus-summary-find-subject (subject &optional unread backward article)
5125 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5126 (article (or article (gnus-summary-article-number)))
5127 (articles (gnus-data-list backward))
5128 (arts (gnus-data-find-list article articles))
5130 (when (or (not gnus-summary-check-current)
5132 (not (gnus-data-unread-p (car arts))))
5133 (setq arts (cdr arts)))
5135 (and (or (not unread)
5136 (gnus-data-unread-p (car arts)))
5137 (vectorp (gnus-data-header (car arts)))
5139 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5140 (setq result (car arts)
5142 (setq arts (cdr arts)))
5144 (goto-char (gnus-data-pos result))
5145 (gnus-data-number result))))
5147 (defun gnus-summary-search-forward (&optional unread subject backward)
5148 "Search forward for an article.
5149 If UNREAD, look for unread articles. If SUBJECT, look for
5150 articles with that subject. If BACKWARD, search backward instead."
5151 (cond (subject (gnus-summary-find-subject subject unread backward))
5152 (backward (gnus-summary-find-prev unread))
5153 (t (gnus-summary-find-next unread))))
5155 (defun gnus-recenter (&optional n)
5156 "Center point in window and redisplay frame.
5157 Also do horizontal recentering."
5160 gnus-auto-center-summary
5161 (not (eq gnus-auto-center-summary 'vertical)))
5162 (gnus-horizontal-recenter))
5165 (defun gnus-summary-recenter ()
5166 "Center point in the summary window.
5167 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5168 displayed, no centering will be performed."
5169 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5170 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5172 (let* ((top (cond ((< (window-height) 4) 0)
5173 ((< (window-height) 7) 1)
5174 (t (if (numberp gnus-auto-center-summary)
5175 gnus-auto-center-summary
5177 (height (1- (window-height)))
5178 (bottom (save-excursion (goto-char (point-max))
5179 (forward-line (- height))
5181 (window (get-buffer-window (current-buffer))))
5182 ;; The user has to want it.
5183 (when gnus-auto-center-summary
5184 (when (get-buffer-window gnus-article-buffer)
5185 ;; Only do recentering when the article buffer is displayed,
5186 ;; Set the window start to either `bottom', which is the biggest
5187 ;; possible valid number, or the second line from the top,
5188 ;; whichever is the least.
5190 window (min bottom (save-excursion
5191 (forward-line (- top)) (point)))
5193 ;; Do horizontal recentering while we're at it.
5194 (when (and (get-buffer-window (current-buffer) t)
5195 (not (eq gnus-auto-center-summary 'vertical)))
5196 (let ((selected (selected-window)))
5197 (select-window (get-buffer-window (current-buffer) t))
5198 (gnus-summary-position-point)
5199 (gnus-horizontal-recenter)
5200 (select-window selected))))))
5202 (defun gnus-summary-jump-to-group (newsgroup)
5203 "Move point to NEWSGROUP in group mode buffer."
5204 ;; Keep update point of group mode buffer if visible.
5205 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5206 (save-window-excursion
5207 ;; Take care of tree window mode.
5208 (when (get-buffer-window gnus-group-buffer)
5209 (pop-to-buffer gnus-group-buffer))
5210 (gnus-group-jump-to-group newsgroup))
5212 ;; Take care of tree window mode.
5213 (if (get-buffer-window gnus-group-buffer)
5214 (pop-to-buffer gnus-group-buffer)
5215 (set-buffer gnus-group-buffer))
5216 (gnus-group-jump-to-group newsgroup))))
5218 ;; This function returns a list of article numbers based on the
5219 ;; difference between the ranges of read articles in this group and
5220 ;; the range of active articles.
5221 (defun gnus-list-of-unread-articles (group)
5222 (let* ((read (gnus-info-read (gnus-get-info group)))
5223 (active (or (gnus-active group) (gnus-activate-group group)))
5226 ;; If none are read, then all are unread.
5228 (setq first (car active))
5229 ;; If the range of read articles is a single range, then the
5230 ;; first unread article is the article after the last read
5231 ;; article. Sounds logical, doesn't it?
5232 (if (and (not (listp (cdr read)))
5233 (or (< (car read) (car active))
5234 (progn (setq read (list read))
5236 (setq first (max (car active) (1+ (cdr read))))
5237 ;; `read' is a list of ranges.
5238 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5241 (setq first (car active)))
5244 (while (< first nlast)
5246 (setq first (1+ first))))
5247 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5248 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5249 (setq read (cdr read)))))
5250 ;; And add the last unread articles.
5251 (while (<= first last)
5253 (setq first (1+ first)))
5254 ;; Return the list of unread articles.
5255 (delq 0 (nreverse unread))))
5257 (defun gnus-list-of-read-articles (group)
5258 "Return a list of unread, unticked and non-dormant articles."
5259 (let* ((info (gnus-get-info group))
5260 (marked (gnus-info-marks info))
5261 (active (gnus-active group)))
5263 (gnus-set-difference
5264 (gnus-sorted-complement
5265 (gnus-uncompress-range active)
5266 (gnus-list-of-unread-articles group))
5268 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5269 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5271 ;; Various summary commands
5273 (defun gnus-summary-select-article-buffer ()
5274 "Reconfigure windows to show article buffer."
5276 (if (not (gnus-buffer-live-p gnus-article-buffer))
5277 (error "There is no article buffer for this summary buffer")
5278 (gnus-configure-windows 'article)
5279 (select-window (get-buffer-window gnus-article-buffer))))
5281 (defun gnus-summary-universal-argument (arg)
5282 "Perform any operation on all articles that are process/prefixed."
5284 (let ((articles (gnus-summary-work-articles arg))
5291 (substitute-command-keys
5292 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5294 (gnus-error 1 "Undefined key")
5297 (gnus-summary-goto-subject (setq article (pop articles)))
5298 (let (gnus-newsgroup-processable)
5299 (command-execute func))
5300 (gnus-summary-remove-process-mark article)))))
5301 (gnus-summary-position-point))
5303 (defun gnus-summary-toggle-truncation (&optional arg)
5304 "Toggle truncation of summary lines.
5305 With arg, turn line truncation on iff arg is positive."
5307 (setq truncate-lines
5308 (if (null arg) (not truncate-lines)
5309 (> (prefix-numeric-value arg) 0)))
5312 (defun gnus-summary-reselect-current-group (&optional all rescan)
5313 "Exit and then reselect the current newsgroup.
5314 The prefix argument ALL means to select all articles."
5316 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5317 (error "Ephemeral groups can't be reselected"))
5318 (let ((current-subject (gnus-summary-article-number))
5319 (group gnus-newsgroup-name))
5320 (setq gnus-newsgroup-begin nil)
5322 ;; We have to adjust the point of group mode buffer because
5323 ;; point was moved to the next unread newsgroup by exiting.
5324 (gnus-summary-jump-to-group group)
5327 (save-window-excursion
5328 ;; Don't show group contents.
5329 (set-window-start (selected-window) (point-max))
5330 (gnus-group-get-new-news-this-group 1))))
5331 (gnus-group-read-group all t)
5332 (gnus-summary-goto-subject current-subject nil t)))
5334 (defun gnus-summary-rescan-group (&optional all)
5335 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5337 (gnus-summary-reselect-current-group all t))
5339 (defun gnus-summary-update-info (&optional non-destructive)
5341 (let ((group gnus-newsgroup-name))
5343 (when gnus-newsgroup-kill-headers
5344 (setq gnus-newsgroup-killed
5345 (gnus-compress-sequence
5347 (gnus-set-sorted-intersection
5348 (gnus-uncompress-range gnus-newsgroup-killed)
5349 (setq gnus-newsgroup-unselected
5350 (sort gnus-newsgroup-unselected '<)))
5351 (setq gnus-newsgroup-unreads
5352 (sort gnus-newsgroup-unreads '<)))
5354 (unless (listp (cdr gnus-newsgroup-killed))
5355 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5356 (let ((headers gnus-newsgroup-headers))
5357 ;; Set the new ranges of read articles.
5359 (set-buffer gnus-group-buffer)
5360 (gnus-undo-force-boundary))
5361 (gnus-update-read-articles
5362 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5363 ;; Set the current article marks.
5364 (let ((gnus-newsgroup-scored
5365 (if (and (not gnus-save-score)
5366 (not non-destructive))
5368 gnus-newsgroup-scored)))
5370 (gnus-update-marks)))
5371 ;; Do the cross-ref thing.
5372 (when gnus-use-cross-reference
5373 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5374 ;; Do not switch windows but change the buffer to work.
5375 (set-buffer gnus-group-buffer)
5376 (unless (gnus-ephemeral-group-p group)
5377 (gnus-group-update-group group)))))))
5379 (defun gnus-summary-save-newsrc (&optional force)
5380 "Save the current number of read/marked articles in the dribble buffer.
5381 The dribble buffer will then be saved.
5382 If FORCE (the prefix), also save the .newsrc file(s)."
5384 (gnus-summary-update-info t)
5386 (gnus-save-newsrc-file)
5387 (gnus-dribble-save)))
5389 (defun gnus-summary-exit (&optional temporary)
5390 "Exit reading current newsgroup, and then return to group selection mode.
5391 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5393 (gnus-set-global-variables)
5394 (gnus-kill-save-kill-buffer)
5395 (gnus-async-halt-prefetch)
5396 (let* ((group gnus-newsgroup-name)
5397 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5400 (buf (current-buffer)))
5402 ;; Do adaptive scoring, and possibly save score files.
5403 (when gnus-newsgroup-adaptive
5404 (gnus-score-adaptive))
5405 (when gnus-use-scoring
5407 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5408 ;; If we have several article buffers, we kill them at exit.
5409 (unless gnus-single-article-buffer
5410 (gnus-kill-buffer gnus-original-article-buffer)
5411 (setq gnus-article-current nil))
5412 (when gnus-use-cache
5413 (gnus-cache-possibly-remove-articles)
5414 (gnus-cache-save-buffers))
5415 (gnus-async-prefetch-remove-group group)
5416 (when gnus-suppress-duplicates
5417 (gnus-dup-enter-articles))
5418 (when gnus-use-trees
5419 (gnus-tree-close group))
5420 (when gnus-use-cache
5421 (gnus-cache-write-active))
5422 ;; Remove entries for this group.
5423 (nnmail-purge-split-history (gnus-group-real-name group))
5424 ;; Make all changes in this group permanent.
5426 (gnus-run-hooks 'gnus-exit-group-hook)
5427 (gnus-summary-update-info))
5428 (gnus-close-group group)
5429 ;; Make sure where we were, and go to next newsgroup.
5430 (set-buffer gnus-group-buffer)
5432 (gnus-group-jump-to-group group))
5433 (gnus-run-hooks 'gnus-summary-exit-hook)
5434 (unless (or quit-config
5435 ;; If this group has disappeared from the summary
5436 ;; buffer, don't skip forwards.
5437 (not (string= group (gnus-group-group-name))))
5438 (gnus-group-next-unread-group 1))
5439 (setq group-point (point))
5442 ;; If we have several article buffers, we kill them at exit.
5443 (unless gnus-single-article-buffer
5444 (gnus-kill-buffer gnus-article-buffer)
5445 (gnus-kill-buffer gnus-original-article-buffer)
5446 (setq gnus-article-current nil))
5448 (if (not gnus-kill-summary-on-exit)
5449 (gnus-deaden-summary)
5450 ;; We set all buffer-local variables to nil. It is unclear why
5451 ;; this is needed, but if we don't, buffer-local variables are
5452 ;; not garbage-collected, it seems. This would the lead to en
5453 ;; ever-growing Emacs.
5454 (gnus-summary-clear-local-variables)
5455 (when (get-buffer gnus-article-buffer)
5456 (bury-buffer gnus-article-buffer))
5457 ;; We clear the global counterparts of the buffer-local
5458 ;; variables as well, just to be on the safe side.
5459 (set-buffer gnus-group-buffer)
5460 (gnus-summary-clear-local-variables)
5461 ;; Return to group mode buffer.
5462 (when (eq mode 'gnus-summary-mode)
5463 (gnus-kill-buffer buf)))
5464 (setq gnus-current-select-method gnus-select-method)
5465 (pop-to-buffer gnus-group-buffer)
5466 (if (not quit-config)
5468 (goto-char group-point)
5469 (gnus-configure-windows 'group 'force)
5470 (unless (pos-visible-in-window-p)
5471 (forward-line (/ (static-if (featurep 'xemacs)
5472 (window-displayed-height)
5473 (1- (window-height)))
5475 (set-window-start (selected-window) (point))
5476 (goto-char group-point)))
5477 (gnus-handle-ephemeral-exit quit-config))
5478 ;; Clear the current group name.
5480 (setq gnus-newsgroup-name nil)))))
5482 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5483 (defun gnus-summary-exit-no-update (&optional no-questions)
5484 "Quit reading current newsgroup without updating read article info."
5486 (let* ((group gnus-newsgroup-name)
5487 (quit-config (gnus-group-quit-config group)))
5488 (when (or no-questions
5490 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5491 (gnus-async-halt-prefetch)
5493 (delq 'gnus-summary-expire-articles
5494 (copy-sequence gnus-summary-prepare-exit-hook)))
5495 ;; If we have several article buffers, we kill them at exit.
5496 (unless gnus-single-article-buffer
5497 (gnus-kill-buffer gnus-article-buffer)
5498 (gnus-kill-buffer gnus-original-article-buffer)
5499 (setq gnus-article-current nil))
5500 (if (not gnus-kill-summary-on-exit)
5501 (gnus-deaden-summary)
5502 (gnus-close-group group)
5503 (gnus-summary-clear-local-variables)
5504 (set-buffer gnus-group-buffer)
5505 (gnus-summary-clear-local-variables)
5506 (when (get-buffer gnus-summary-buffer)
5507 (kill-buffer gnus-summary-buffer)))
5508 (unless gnus-single-article-buffer
5509 (setq gnus-article-current nil))
5510 (when gnus-use-trees
5511 (gnus-tree-close group))
5512 (gnus-async-prefetch-remove-group group)
5513 (when (get-buffer gnus-article-buffer)
5514 (bury-buffer gnus-article-buffer))
5515 ;; Return to the group buffer.
5516 (gnus-configure-windows 'group 'force)
5517 ;; Clear the current group name.
5518 (setq gnus-newsgroup-name nil)
5519 (when (equal (gnus-group-group-name) group)
5520 (gnus-group-next-unread-group 1))
5522 (gnus-handle-ephemeral-exit quit-config)))))
5524 (defun gnus-handle-ephemeral-exit (quit-config)
5525 "Handle movement when leaving an ephemeral group.
5526 The state which existed when entering the ephemeral is reset."
5527 (if (not (buffer-name (car quit-config)))
5528 (gnus-configure-windows 'group 'force)
5529 (set-buffer (car quit-config))
5530 (cond ((eq major-mode 'gnus-summary-mode)
5531 (gnus-set-global-variables))
5532 ((eq major-mode 'gnus-article-mode)
5534 ;; The `gnus-summary-buffer' variable may point
5535 ;; to the old summary buffer when using a single
5537 (unless (gnus-buffer-live-p gnus-summary-buffer)
5538 (set-buffer gnus-group-buffer))
5539 (set-buffer gnus-summary-buffer)
5540 (gnus-set-global-variables))))
5541 (if (or (eq (cdr quit-config) 'article)
5542 (eq (cdr quit-config) 'pick))
5544 ;; The current article may be from the ephemeral group
5545 ;; thus it is best that we reload this article
5546 (gnus-summary-show-article)
5547 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5548 (gnus-configure-windows 'pick 'force)
5549 (gnus-configure-windows (cdr quit-config) 'force)))
5550 (gnus-configure-windows (cdr quit-config) 'force))
5551 (when (eq major-mode 'gnus-summary-mode)
5552 (gnus-summary-next-subject 1 nil t)
5553 (gnus-summary-recenter)
5554 (gnus-summary-position-point))))
5556 (defun gnus-summary-preview-mime-message ()
5557 "MIME decode and play this message."
5559 (let ((gnus-break-pages nil)
5561 (gnus-summary-select-article gnus-show-all-headers t))
5562 (select-window (get-buffer-window gnus-article-buffer)))
5566 (defvar gnus-dead-summary-mode-map nil)
5568 (unless gnus-dead-summary-mode-map
5569 (setq gnus-dead-summary-mode-map (make-keymap))
5570 (suppress-keymap gnus-dead-summary-mode-map)
5571 (substitute-key-definition
5572 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5573 (let ((keys '("\C-d" "\r" "\177" [delete])))
5575 (define-key gnus-dead-summary-mode-map
5576 (pop keys) 'gnus-summary-wake-up-the-dead))))
5578 (defvar gnus-dead-summary-mode nil
5579 "Minor mode for Gnus summary buffers.")
5581 (defun gnus-dead-summary-mode (&optional arg)
5582 "Minor mode for Gnus summary buffers."
5584 (when (eq major-mode 'gnus-summary-mode)
5585 (make-local-variable 'gnus-dead-summary-mode)
5586 (setq gnus-dead-summary-mode
5587 (if (null arg) (not gnus-dead-summary-mode)
5588 (> (prefix-numeric-value arg) 0)))
5589 (when gnus-dead-summary-mode
5590 (gnus-add-minor-mode
5591 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5593 (defun gnus-deaden-summary ()
5594 "Make the current summary buffer into a dead summary buffer."
5595 ;; Kill any previous dead summary buffer.
5596 (when (and gnus-dead-summary
5597 (buffer-name gnus-dead-summary))
5599 (set-buffer gnus-dead-summary)
5600 (when gnus-dead-summary-mode
5601 (kill-buffer (current-buffer)))))
5602 ;; Make this the current dead summary.
5603 (setq gnus-dead-summary (current-buffer))
5604 (gnus-dead-summary-mode 1)
5605 (let ((name (buffer-name)))
5606 (when (string-match "Summary" name)
5608 (concat (substring name 0 (match-beginning 0)) "Dead "
5609 (substring name (match-beginning 0)))
5613 (defun gnus-kill-or-deaden-summary (buffer)
5614 "Kill or deaden the summary BUFFER."
5616 (when (and (buffer-name buffer)
5617 (not gnus-single-article-buffer))
5620 (gnus-kill-buffer gnus-article-buffer)
5621 (gnus-kill-buffer gnus-original-article-buffer)))
5622 (cond (gnus-kill-summary-on-exit
5623 (when (and gnus-use-trees
5624 (gnus-buffer-exists-p buffer))
5627 (gnus-tree-close gnus-newsgroup-name)))
5628 (gnus-kill-buffer buffer))
5629 ((gnus-buffer-exists-p buffer)
5632 (gnus-deaden-summary))))))
5634 (defun gnus-summary-wake-up-the-dead (&rest args)
5635 "Wake up the dead summary buffer."
5637 (gnus-dead-summary-mode -1)
5638 (let ((name (buffer-name)))
5639 (when (string-match "Dead " name)
5641 (concat (substring name 0 (match-beginning 0))
5642 (substring name (match-end 0)))
5644 (gnus-message 3 "This dead summary is now alive again"))
5646 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5647 (defun gnus-summary-fetch-faq (&optional faq-dir)
5648 "Fetch the FAQ for the current group.
5649 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5653 (when current-prefix-arg
5655 "Faq dir: " (and (listp gnus-group-faq-directory)
5656 (mapcar (lambda (file) (list file))
5657 gnus-group-faq-directory))))))
5658 (let (gnus-faq-buffer)
5659 (when (setq gnus-faq-buffer
5660 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5661 (gnus-configure-windows 'summary-faq))))
5663 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5664 (defun gnus-summary-describe-group (&optional force)
5665 "Describe the current newsgroup."
5667 (gnus-group-describe-group force gnus-newsgroup-name))
5669 (defun gnus-summary-describe-briefly ()
5670 "Describe summary mode commands briefly."
5672 (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")))
5674 ;; Walking around group mode buffer from summary mode.
5676 (defun gnus-summary-next-group (&optional no-article target-group backward)
5677 "Exit current newsgroup and then select next unread newsgroup.
5678 If prefix argument NO-ARTICLE is non-nil, no article is selected
5679 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5680 previous group instead."
5682 ;; Stop pre-fetching.
5683 (gnus-async-halt-prefetch)
5684 (let ((current-group gnus-newsgroup-name)
5685 (current-buffer (current-buffer))
5687 ;; First we semi-exit this group to update Xrefs and all variables.
5688 ;; We can't do a real exit, because the window conf must remain
5689 ;; the same in case the user is prompted for info, and we don't
5690 ;; want the window conf to change before that...
5691 (gnus-summary-exit t)
5692 (while (not entered)
5693 ;; Then we find what group we are supposed to enter.
5694 (set-buffer gnus-group-buffer)
5695 (gnus-group-jump-to-group current-group)
5698 (if (eq gnus-keep-same-level 'best)
5699 (gnus-summary-best-group gnus-newsgroup-name)
5700 (gnus-summary-search-group backward gnus-keep-same-level))))
5701 (if (not target-group)
5702 ;; There are no further groups, so we return to the group
5705 (gnus-message 5 "Returning to the group buffer")
5707 (when (gnus-buffer-live-p current-buffer)
5708 (set-buffer current-buffer)
5709 (gnus-summary-exit))
5710 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5711 ;; We try to enter the target group.
5712 (gnus-group-jump-to-group target-group)
5713 (let ((unreads (gnus-group-group-unread)))
5714 (if (and (or (eq t unreads)
5715 (and unreads (not (zerop unreads))))
5716 (gnus-summary-read-group
5717 target-group nil no-article
5718 (and (buffer-name current-buffer) current-buffer)
5721 (setq current-group target-group
5722 target-group nil)))))))
5724 (defun gnus-summary-prev-group (&optional no-article)
5725 "Exit current newsgroup and then select previous unread newsgroup.
5726 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5728 (gnus-summary-next-group no-article nil t))
5730 ;; Walking around summary lines.
5732 (defun gnus-summary-first-subject (&optional unread undownloaded)
5733 "Go to the first unread subject.
5734 If UNREAD is non-nil, go to the first unread article.
5735 Returns the article selected or nil if there are no unread articles."
5740 ((null gnus-newsgroup-data)
5741 (gnus-message 3 "No articles in the group")
5743 ;; Pick the first article.
5745 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5746 (gnus-data-number (car gnus-newsgroup-data)))
5747 ;; No unread articles.
5748 ((null gnus-newsgroup-unreads)
5749 (gnus-message 3 "No more unread articles")
5751 ;; Find the first unread article.
5753 (let ((data gnus-newsgroup-data))
5755 (and (not (and undownloaded
5756 (eq gnus-undownloaded-mark
5757 (gnus-data-mark (car data)))))
5758 (not (gnus-data-unread-p (car data)))))
5759 (setq data (cdr data)))
5761 (goto-char (gnus-data-pos (car data)))
5762 (gnus-data-number (car data))))))
5763 (gnus-summary-position-point)))
5765 (defun gnus-summary-next-subject (n &optional unread dont-display)
5766 "Go to next N'th summary line.
5767 If N is negative, go to the previous N'th subject line.
5768 If UNREAD is non-nil, only unread articles are selected.
5769 The difference between N and the actual number of steps taken is
5772 (let ((backward (< n 0))
5776 (gnus-summary-find-prev unread)
5777 (gnus-summary-find-next unread)))
5778 (unless (zerop (setq n (1- n)))
5779 (gnus-summary-show-thread)))
5781 (gnus-message 7 "No more%s articles"
5782 (if unread " unread" "")))
5783 (unless dont-display
5784 (gnus-summary-recenter)
5785 (gnus-summary-position-point))
5788 (defun gnus-summary-next-unread-subject (n)
5789 "Go to next N'th unread summary line."
5791 (gnus-summary-next-subject n t))
5793 (defun gnus-summary-prev-subject (n &optional unread)
5794 "Go to previous N'th summary line.
5795 If optional argument UNREAD is non-nil, only unread article is selected."
5797 (gnus-summary-next-subject (- n) unread))
5799 (defun gnus-summary-prev-unread-subject (n)
5800 "Go to previous N'th unread summary line."
5802 (gnus-summary-next-subject (- n) t))
5804 (defun gnus-summary-goto-subject (article &optional force silent)
5805 "Go the subject line of ARTICLE.
5806 If FORCE, also allow jumping to articles not currently shown."
5807 (interactive "nArticle number: ")
5809 (data (gnus-data-find article)))
5810 ;; We read in the article if we have to.
5813 (gnus-summary-insert-subject
5815 (if (or (numberp force) (vectorp force)) force)
5817 (setq data (gnus-data-find article)))
5822 (gnus-message 3 "Can't find article %d" article))
5824 (goto-char (gnus-data-pos data))
5825 (gnus-summary-position-point)
5828 ;; Walking around summary lines with displaying articles.
5830 (defun gnus-summary-expand-window (&optional arg)
5831 "Make the summary buffer take up the entire Emacs frame.
5832 Given a prefix, will force an `article' buffer configuration."
5835 (gnus-configure-windows 'article 'force)
5836 (gnus-configure-windows 'summary 'force)))
5838 (defun gnus-summary-display-article (article &optional all-header)
5839 "Display ARTICLE in article buffer."
5840 (gnus-set-global-variables)
5844 (if gnus-summary-display-article-function
5845 (funcall gnus-summary-display-article-function article all-header)
5846 (gnus-article-prepare article all-header))
5847 (with-current-buffer gnus-article-buffer
5848 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5850 (gnus-run-hooks 'gnus-select-article-hook)
5851 (when (and gnus-current-article
5852 (not (zerop gnus-current-article)))
5853 (gnus-summary-goto-subject gnus-current-article))
5854 (gnus-summary-recenter)
5855 (when (and gnus-use-trees gnus-show-threads)
5856 (gnus-possibly-generate-tree article)
5857 (gnus-highlight-selected-tree article))
5858 ;; Successfully display article.
5859 (gnus-article-set-window-start
5860 (cdr (assq article gnus-newsgroup-bookmarks))))))
5862 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5863 "Select the current article.
5864 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5865 non-nil, the article will be re-fetched even if it already present in
5866 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5868 ;; Make sure we are in the summary buffer to work around bbdb bug.
5869 (unless (eq major-mode 'gnus-summary-mode)
5870 (set-buffer gnus-summary-buffer))
5871 (let ((article (or article (gnus-summary-article-number)))
5872 (all-headers (not (not all-headers))) ;Must be T or NIL.
5873 gnus-summary-display-article-function)
5875 (gnus-summary-article-pseudo-p article)
5876 (error "This is a pseudo-article"))
5878 (set-buffer gnus-summary-buffer)
5879 (if (or (and gnus-single-article-buffer
5880 (or (null gnus-current-article)
5881 (null gnus-article-current)
5882 (null (get-buffer gnus-article-buffer))
5883 (not (eq article (cdr gnus-article-current)))
5884 (not (equal (car gnus-article-current)
5885 gnus-newsgroup-name))))
5886 (and (not gnus-single-article-buffer)
5887 (or (null gnus-current-article)
5888 (not (eq gnus-current-article article))))
5890 ;; The requested article is different from the current article.
5892 (gnus-summary-display-article article all-headers)
5893 (when (or all-headers gnus-show-all-headers)
5894 (gnus-article-show-all-headers))
5895 (gnus-article-set-window-start
5896 (cdr (assq article gnus-newsgroup-bookmarks)))
5898 (when (or all-headers gnus-show-all-headers)
5899 (gnus-article-show-all-headers))
5902 (defun gnus-summary-set-current-mark (&optional current-mark)
5903 "Obsolete function."
5906 (defun gnus-summary-next-article (&optional unread subject backward push)
5907 "Select the next article.
5908 If UNREAD, only unread articles are selected.
5909 If SUBJECT, only articles with SUBJECT are selected.
5910 If BACKWARD, the previous article is selected instead of the next."
5913 ;; Is there such an article?
5914 ((and (gnus-summary-search-forward unread subject backward)
5915 (or (gnus-summary-display-article (gnus-summary-article-number))
5916 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5917 (gnus-summary-position-point))
5918 ;; If not, we try the first unread, if that is wanted.
5920 gnus-auto-select-same
5921 (gnus-summary-first-unread-article))
5922 (gnus-summary-position-point)
5923 (gnus-message 6 "Wrapped"))
5924 ;; Try to get next/previous article not displayed in this group.
5925 ((and gnus-auto-extend-newsgroup
5926 (not unread) (not subject))
5927 (gnus-summary-goto-article
5928 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5929 nil (count-lines (point-min) (point))))
5930 ;; Go to next/previous group.
5932 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5933 (gnus-summary-jump-to-group gnus-newsgroup-name))
5934 (let ((cmd last-command-char)
5937 (set-buffer gnus-group-buffer)
5940 (if (eq gnus-keep-same-level 'best)
5941 (gnus-summary-best-group gnus-newsgroup-name)
5942 (gnus-summary-search-group backward gnus-keep-same-level))))
5943 ;; For some reason, the group window gets selected. We change
5945 (select-window (get-buffer-window (current-buffer)))
5946 ;; Select next unread newsgroup automagically.
5948 ((or (not gnus-auto-select-next)
5950 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5951 ((or (eq gnus-auto-select-next 'quietly)
5952 (and (eq gnus-auto-select-next 'slightly-quietly)
5954 (and (eq gnus-auto-select-next 'almost-quietly)
5955 (gnus-summary-last-article-p)))
5957 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5959 (gnus-message 7 "No more%s articles (%s)..."
5960 (if unread " unread" "")
5961 (if group (concat "selecting " group)
5963 (gnus-summary-next-group nil group backward)))
5965 (when (gnus-key-press-event-p last-input-event)
5966 (gnus-summary-walk-group-buffer
5967 gnus-newsgroup-name cmd unread backward point))))))))
5969 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5970 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5971 (?\C-p (gnus-group-prev-unread-group 1))))
5972 (cursor-in-echo-area t)
5973 keve key group ended)
5975 (set-buffer gnus-group-buffer)
5978 (if (eq gnus-keep-same-level 'best)
5979 (gnus-summary-best-group gnus-newsgroup-name)
5980 (gnus-summary-search-group backward gnus-keep-same-level))))
5983 5 "No more%s articles%s" (if unread " unread" "")
5985 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5986 (format " (Type %s for %s [%s])"
5987 (single-key-description cmd) group
5988 (car (gnus-gethash group gnus-newsrc-hashtb)))
5989 (format " (Type %s to exit %s)"
5990 (single-key-description cmd)
5991 gnus-newsgroup-name)))
5992 ;; Confirm auto selection.
5993 (setq key (car (setq keve (gnus-read-event-char))))
5996 ((assq key keystrokes)
5997 (let ((obuf (current-buffer)))
5998 (switch-to-buffer gnus-group-buffer)
6000 (gnus-group-jump-to-group group))
6001 (eval (cadr (assq key keystrokes)))
6002 (setq group (gnus-group-group-name))
6003 (switch-to-buffer obuf))
6007 (gnus-ephemeral-group-p gnus-newsgroup-name))
6009 (gnus-summary-next-group nil group backward)))
6011 (push (cdr keve) unread-command-events))))))
6013 (defun gnus-summary-next-unread-article ()
6014 "Select unread article after current one."
6016 (gnus-summary-next-article
6017 (or (not (eq gnus-summary-goto-unread 'never))
6018 (gnus-summary-last-article-p (gnus-summary-article-number)))
6019 (and gnus-auto-select-same
6020 (gnus-summary-article-subject))))
6022 (defun gnus-summary-prev-article (&optional unread subject)
6023 "Select the article after the current one.
6024 If UNREAD is non-nil, only unread articles are selected."
6026 (gnus-summary-next-article unread subject t))
6028 (defun gnus-summary-prev-unread-article ()
6029 "Select unread article before current one."
6031 (gnus-summary-prev-article
6032 (or (not (eq gnus-summary-goto-unread 'never))
6033 (gnus-summary-first-article-p (gnus-summary-article-number)))
6034 (and gnus-auto-select-same
6035 (gnus-summary-article-subject))))
6037 (defun gnus-summary-next-page (&optional lines circular)
6038 "Show next page of the selected article.
6039 If at the end of the current article, select the next article.
6040 LINES says how many lines should be scrolled up.
6042 If CIRCULAR is non-nil, go to the start of the article instead of
6043 selecting the next article when reaching the end of the current
6046 (setq gnus-summary-buffer (current-buffer))
6047 (gnus-set-global-variables)
6048 (let ((article (gnus-summary-article-number))
6049 (article-window (get-buffer-window gnus-article-buffer t))
6051 ;; If the buffer is empty, we have no article.
6053 (error "No article to select"))
6054 (gnus-configure-windows 'article)
6055 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6056 (if (and (eq gnus-summary-goto-unread 'never)
6057 (not (gnus-summary-last-article-p article)))
6058 (gnus-summary-next-article)
6059 (gnus-summary-next-unread-article))
6060 (if (or (null gnus-current-article)
6061 (null gnus-article-current)
6062 (/= article (cdr gnus-article-current))
6063 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6064 ;; Selected subject is different from current article's.
6065 (gnus-summary-display-article article)
6066 (when article-window
6067 (gnus-eval-in-buffer-window gnus-article-buffer
6068 (setq endp (gnus-article-next-page lines)))
6071 (gnus-summary-beginning-of-article))
6073 (gnus-message 3 "End of message"))
6075 (if (and (eq gnus-summary-goto-unread 'never)
6076 (not (gnus-summary-last-article-p article)))
6077 (gnus-summary-next-article)
6078 (gnus-summary-next-unread-article))))))))
6079 (gnus-summary-recenter)
6080 (gnus-summary-position-point)))
6082 (defun gnus-summary-prev-page (&optional lines move)
6083 "Show previous page of selected article.
6084 Argument LINES specifies lines to be scrolled down.
6085 If MOVE, move to the previous unread article if point is at
6086 the beginning of the buffer."
6088 (let ((article (gnus-summary-article-number))
6089 (article-window (get-buffer-window gnus-article-buffer t))
6091 (gnus-configure-windows 'article)
6092 (if (or (null gnus-current-article)
6093 (null gnus-article-current)
6094 (/= article (cdr gnus-article-current))
6095 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6096 ;; Selected subject is different from current article's.
6097 (gnus-summary-display-article article)
6098 (gnus-summary-recenter)
6099 (when article-window
6100 (gnus-eval-in-buffer-window gnus-article-buffer
6101 (setq endp (gnus-article-prev-page lines)))
6102 (when (and move endp)
6104 (gnus-message 3 "Beginning of message"))
6106 (if (and (eq gnus-summary-goto-unread 'never)
6107 (not (gnus-summary-first-article-p article)))
6108 (gnus-summary-prev-article)
6109 (gnus-summary-prev-unread-article))))))))
6110 (gnus-summary-position-point))
6112 (defun gnus-summary-prev-page-or-article (&optional lines)
6113 "Show previous page of selected article.
6114 Argument LINES specifies lines to be scrolled down.
6115 If at the beginning of the article, go to the next article."
6117 (gnus-summary-prev-page lines t))
6119 (defun gnus-summary-scroll-up (lines)
6120 "Scroll up (or down) one line current article.
6121 Argument LINES specifies lines to be scrolled up (or down if negative)."
6123 (gnus-configure-windows 'article)
6124 (gnus-summary-show-thread)
6125 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6126 (gnus-eval-in-buffer-window gnus-article-buffer
6128 (when (gnus-article-next-page lines)
6129 (gnus-message 3 "End of message")))
6131 (gnus-article-prev-page (- lines))))))
6132 (gnus-summary-recenter)
6133 (gnus-summary-position-point))
6135 (defun gnus-summary-scroll-down (lines)
6136 "Scroll down (or up) one line current article.
6137 Argument LINES specifies lines to be scrolled down (or up if negative)."
6139 (gnus-summary-scroll-up (- lines)))
6141 (defun gnus-summary-next-same-subject ()
6142 "Select next article which has the same subject as current one."
6144 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6146 (defun gnus-summary-prev-same-subject ()
6147 "Select previous article which has the same subject as current one."
6149 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6151 (defun gnus-summary-next-unread-same-subject ()
6152 "Select next unread article which has the same subject as current one."
6154 (gnus-summary-next-article t (gnus-summary-article-subject)))
6156 (defun gnus-summary-prev-unread-same-subject ()
6157 "Select previous unread article which has the same subject as current one."
6159 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6161 (defun gnus-summary-first-unread-article ()
6162 "Select the first unread article.
6163 Return nil if there are no unread articles."
6166 (when (gnus-summary-first-subject t)
6167 (gnus-summary-show-thread)
6168 (gnus-summary-first-subject t)
6169 (gnus-summary-display-article (gnus-summary-article-number)))
6170 (gnus-summary-position-point)))
6172 (defun gnus-summary-first-unread-subject ()
6173 "Place the point on the subject line of the first unread article.
6174 Return nil if there are no unread articles."
6177 (when (gnus-summary-first-subject t)
6178 (gnus-summary-show-thread)
6179 (gnus-summary-first-subject t))
6180 (gnus-summary-position-point)))
6182 (defun gnus-summary-first-article ()
6183 "Select the first article.
6184 Return nil if there are no articles."
6187 (when (gnus-summary-first-subject)
6188 (gnus-summary-show-thread)
6189 (gnus-summary-first-subject)
6190 (gnus-summary-display-article (gnus-summary-article-number)))
6191 (gnus-summary-position-point)))
6193 (defun gnus-summary-best-unread-article ()
6194 "Select the unread article with the highest score."
6196 (let ((best -1000000)
6197 (data gnus-newsgroup-data)
6200 (and (gnus-data-unread-p (car data))
6202 (gnus-summary-article-score (gnus-data-number (car data))))
6205 article (gnus-data-number (car data))))
6206 (setq data (cdr data)))
6209 (gnus-summary-goto-article article)
6210 (error "No unread articles"))
6211 (gnus-summary-position-point))))
6213 (defun gnus-summary-last-subject ()
6214 "Go to the last displayed subject line in the group."
6215 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6217 (gnus-summary-goto-subject article))))
6219 (defun gnus-summary-goto-article (article &optional all-headers force)
6220 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6221 If ALL-HEADERS is non-nil, no header lines are hidden.
6222 If FORCE, go to the article even if it isn't displayed. If FORCE
6223 is a number, it is the line the article is to be displayed on."
6227 "Article number or Message-ID: "
6228 (mapcar (lambda (number) (list (int-to-string number)))
6229 gnus-newsgroup-limit))
6233 (if (and (stringp article)
6234 (string-match "@" article))
6235 (gnus-summary-refer-article article)
6236 (when (stringp article)
6237 (setq article (string-to-number article)))
6238 (if (gnus-summary-goto-subject article force)
6239 (gnus-summary-display-article article all-headers)
6240 (gnus-message 4 "Couldn't go to article %s" article) nil))
6241 (gnus-summary-position-point)))
6243 (defun gnus-summary-goto-last-article ()
6244 "Go to the previously read article."
6247 (when gnus-last-article
6248 (gnus-summary-goto-article gnus-last-article nil t))
6249 (gnus-summary-position-point)))
6251 (defun gnus-summary-pop-article (number)
6252 "Pop one article off the history and go to the previous.
6253 NUMBER articles will be popped off."
6256 (setq gnus-newsgroup-history
6257 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6259 (gnus-summary-goto-article (car to) nil t)
6260 (error "Article history empty")))
6261 (gnus-summary-position-point))
6263 ;; Summary commands and functions for limiting the summary buffer.
6265 (defun gnus-summary-limit-to-articles (n)
6266 "Limit the summary buffer to the next N articles.
6267 If not given a prefix, use the process marked articles instead."
6270 (let ((articles (gnus-summary-work-articles n)))
6271 (setq gnus-newsgroup-processable nil)
6272 (gnus-summary-limit articles))
6273 (gnus-summary-position-point)))
6275 (defun gnus-summary-pop-limit (&optional total)
6276 "Restore the previous limit.
6277 If given a prefix, remove all limits."
6280 (setq gnus-newsgroup-limits
6281 (list (mapcar (lambda (h) (mail-header-number h))
6282 gnus-newsgroup-headers))))
6283 (unless gnus-newsgroup-limits
6284 (error "No limit to pop"))
6286 (gnus-summary-limit nil 'pop)
6287 (gnus-summary-position-point)))
6289 (defun gnus-summary-limit-to-subject (subject &optional header)
6290 "Limit the summary buffer to articles that have subjects that match a regexp."
6291 (interactive "sLimit to subject (regexp): ")
6293 (setq header "subject"))
6294 (when (not (equal "" subject))
6296 (let ((articles (gnus-summary-find-matching
6297 (or header "subject") subject 'all)))
6299 (error "Found no matches for \"%s\"" subject))
6300 (gnus-summary-limit articles))
6301 (gnus-summary-position-point))))
6303 (defun gnus-summary-limit-to-author (from)
6304 "Limit the summary buffer to articles that have authors that match a regexp."
6305 (interactive "sLimit to author (regexp): ")
6306 (gnus-summary-limit-to-subject from "from"))
6308 (defun gnus-summary-limit-to-age (age &optional younger-p)
6309 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6310 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6311 articles that are younger than AGE days."
6313 (let ((younger current-prefix-arg)
6316 (while (not days-got)
6317 (setq days (if younger
6318 (read-string "Limit to articles within (in days): ")
6319 (read-string "Limit to articles old than (in days): ")))
6320 (when (> (length days) 0)
6321 (setq days (read days)))
6324 (message "Please enter a number.")
6326 (list days younger)))
6328 (let ((data gnus-newsgroup-data)
6329 (cutoff (days-to-time age))
6330 articles d date is-younger)
6331 (while (setq d (pop data))
6332 (when (and (vectorp (gnus-data-header d))
6333 (setq date (mail-header-date (gnus-data-header d))))
6334 (setq is-younger (time-less-p
6335 (time-since (condition-case ()
6342 (push (gnus-data-number d) articles))))
6343 (gnus-summary-limit (nreverse articles)))
6344 (gnus-summary-position-point)))
6346 (defun gnus-summary-limit-to-extra (header regexp)
6347 "Limit the summary buffer to articles that match an 'extra' header."
6351 (gnus-completing-read
6352 (symbol-name (car gnus-extra-headers))
6353 "Limit extra header:"
6355 (cons (symbol-name x) x))
6360 (read-string (format "Limit to header %s (regexp): " header)))))
6361 (when (not (equal "" regexp))
6363 (let ((articles (gnus-summary-find-matching
6364 (cons 'extra header) regexp 'all)))
6366 (error "Found no matches for \"%s\"" regexp))
6367 (gnus-summary-limit articles))
6368 (gnus-summary-position-point))))
6370 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6372 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6374 (defun gnus-summary-limit-to-unread (&optional all)
6375 "Limit the summary buffer to articles that are not marked as read.
6376 If ALL is non-nil, limit strictly to unread articles."
6379 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6380 (gnus-summary-limit-to-marks
6381 ;; Concat all the marks that say that an article is read and have
6383 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6384 gnus-killed-mark gnus-kill-file-mark
6385 gnus-low-score-mark gnus-expirable-mark
6386 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6387 gnus-duplicate-mark gnus-souped-mark)
6390 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6391 (make-obsolete 'gnus-summary-delete-marked-with
6392 'gnus-summary-limit-exlude-marks)
6394 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6395 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6396 If REVERSE, limit the summary buffer to articles that are marked
6397 with MARKS. MARKS can either be a string of marks or a list of marks.
6398 Returns how many articles were removed."
6399 (interactive "sMarks: ")
6400 (gnus-summary-limit-to-marks marks t))
6402 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6403 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6404 If REVERSE (the prefix), limit the summary buffer to articles that are
6405 not marked with MARKS. MARKS can either be a string of marks or a
6407 Returns how many articles were removed."
6408 (interactive "sMarks: \nP")
6410 (let ((data gnus-newsgroup-data)
6411 (marks (if (listp marks) marks
6412 (append marks nil))) ; Transform to list.
6415 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6416 (memq (gnus-data-mark (car data)) marks))
6417 (push (gnus-data-number (car data)) articles))
6418 (setq data (cdr data)))
6419 (gnus-summary-limit articles))
6420 (gnus-summary-position-point)))
6422 (defun gnus-summary-limit-to-score (&optional score)
6423 "Limit to articles with score at or above SCORE."
6425 (setq score (if score
6426 (prefix-numeric-value score)
6427 (or gnus-summary-default-score 0)))
6428 (let ((data gnus-newsgroup-data)
6431 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6433 (push (gnus-data-number (car data)) articles))
6434 (setq data (cdr data)))
6436 (gnus-summary-limit articles)
6437 (gnus-summary-position-point))))
6439 (defun gnus-summary-limit-include-thread (id)
6440 "Display all the hidden articles that in the current thread."
6441 (interactive (list (mail-header-id (gnus-summary-article-header))))
6442 (let ((articles (gnus-articles-in-thread
6443 (gnus-id-to-thread (gnus-root-id id)))))
6445 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6446 (gnus-summary-position-point))))
6448 (defun gnus-summary-limit-include-dormant ()
6449 "Display all the hidden articles that are marked as dormant.
6450 Note that this command only works on a subset of the articles currently
6451 fetched for this group."
6453 (unless gnus-newsgroup-dormant
6454 (error "There are no dormant articles in this group"))
6456 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6457 (gnus-summary-position-point)))
6459 (defun gnus-summary-limit-exclude-dormant ()
6460 "Hide all dormant articles."
6463 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6464 (gnus-summary-position-point)))
6466 (defun gnus-summary-limit-exclude-childless-dormant ()
6467 "Hide all dormant articles that have no children."
6469 (let ((data (gnus-data-list t))
6470 articles d children)
6471 ;; Find all articles that are either not dormant or have
6473 (while (setq d (pop data))
6474 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6476 (gnus-article-children (gnus-data-number d)))
6479 (when (memq (car children) articles)
6484 (push (gnus-data-number d) articles)))
6487 (gnus-summary-limit articles)
6488 (gnus-summary-position-point))))
6490 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6491 "Mark all unread excluded articles as read.
6492 If ALL, mark even excluded ticked and dormants as read."
6494 (let ((articles (gnus-sorted-complement
6496 (mapcar (lambda (h) (mail-header-number h))
6497 gnus-newsgroup-headers)
6499 (sort gnus-newsgroup-limit '<)))
6501 (setq gnus-newsgroup-unreads
6502 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6504 (setq gnus-newsgroup-dormant nil
6505 gnus-newsgroup-marked nil
6506 gnus-newsgroup-reads
6508 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6509 gnus-newsgroup-reads))
6510 (while (setq article (pop articles))
6511 (unless (or (memq article gnus-newsgroup-dormant)
6512 (memq article gnus-newsgroup-marked))
6513 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6515 (defun gnus-summary-limit (articles &optional pop)
6517 ;; We pop the previous limit off the stack and use that.
6518 (setq articles (car gnus-newsgroup-limits)
6519 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6520 ;; We use the new limit, so we push the old limit on the stack.
6521 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6523 (setq gnus-newsgroup-limit articles)
6524 (let ((total (length gnus-newsgroup-data))
6525 (data (gnus-data-find-list (gnus-summary-article-number)))
6526 (gnus-summary-mark-below nil) ; Inhibit this.
6528 ;; This will do all the work of generating the new summary buffer
6529 ;; according to the new limit.
6530 (gnus-summary-prepare)
6531 ;; Hide any threads, possibly.
6532 (and gnus-show-threads
6533 gnus-thread-hide-subtree
6534 (gnus-summary-hide-all-threads))
6535 ;; Try to return to the article you were at, or one in the
6538 ;; We try to find some article after the current one.
6540 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6543 (setq data (cdr data))))
6545 ;; If there is no data, that means that we were after the last
6546 ;; article. The same goes when we can't find any articles
6547 ;; after the current one.
6548 (goto-char (point-max))
6549 (gnus-summary-find-prev))
6550 (gnus-set-mode-line 'summary)
6551 ;; We return how many articles were removed from the summary
6552 ;; buffer as a result of the new limit.
6553 (- total (length gnus-newsgroup-data))))
6555 (defsubst gnus-invisible-cut-children (threads)
6558 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6563 (defsubst gnus-cut-thread (thread)
6564 "Go forwards in the thread until we find an article that we want to display."
6565 (when (or (eq gnus-fetch-old-headers 'some)
6566 (eq gnus-fetch-old-headers 'invisible)
6567 (numberp gnus-fetch-old-headers)
6568 (eq gnus-build-sparse-threads 'some)
6569 (eq gnus-build-sparse-threads 'more))
6570 ;; Deal with old-fetched headers and sparse threads.
6574 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6575 (gnus-summary-article-ancient-p
6576 (mail-header-number (car thread))))
6577 (if (or (<= (length (cdr thread)) 1)
6578 (eq gnus-fetch-old-headers 'invisible))
6579 (setq gnus-newsgroup-limit
6580 (delq (mail-header-number (car thread))
6581 gnus-newsgroup-limit)
6582 thread (cadr thread))
6583 (when (gnus-invisible-cut-children (cdr thread))
6584 (let ((th (cdr thread)))
6586 (if (memq (mail-header-number (caar th))
6587 gnus-newsgroup-limit)
6588 (setq thread (car th)
6590 (setq th (cdr th))))))))))
6593 (defun gnus-cut-threads (threads)
6594 "Cut off all uninteresting articles from the beginning of threads."
6595 (when (or (eq gnus-fetch-old-headers 'some)
6596 (eq gnus-fetch-old-headers 'invisible)
6597 (numberp gnus-fetch-old-headers)
6598 (eq gnus-build-sparse-threads 'some)
6599 (eq gnus-build-sparse-threads 'more))
6602 (setcar th (gnus-cut-thread (car th)))
6603 (setq th (cdr th)))))
6604 ;; Remove nixed out threads.
6607 (defun gnus-summary-initial-limit (&optional show-if-empty)
6608 "Figure out what the initial limit is supposed to be on group entry.
6609 This entails weeding out unwanted dormants, low-scored articles,
6610 fetch-old-headers verbiage, and so on."
6611 ;; Most groups have nothing to remove.
6612 (if (or gnus-inhibit-limiting
6613 (and (null gnus-newsgroup-dormant)
6614 (not (eq gnus-fetch-old-headers 'some))
6615 (not (numberp gnus-fetch-old-headers))
6616 (not (eq gnus-fetch-old-headers 'invisible))
6617 (null gnus-summary-expunge-below)
6618 (not (eq gnus-build-sparse-threads 'some))
6619 (not (eq gnus-build-sparse-threads 'more))
6620 (null gnus-thread-expunge-below)
6621 (not gnus-use-nocem)))
6623 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6624 (setq gnus-newsgroup-limit nil)
6627 (unless (car (symbol-value node))
6628 ;; These threads have no parents -- they are roots.
6629 (let ((nodes (cdr (symbol-value node)))
6632 (if (and gnus-thread-expunge-below
6633 (< (gnus-thread-total-score (car nodes))
6634 gnus-thread-expunge-below))
6635 (gnus-expunge-thread (pop nodes))
6636 (setq thread (pop nodes))
6637 (gnus-summary-limit-children thread))))))
6638 gnus-newsgroup-dependencies)
6639 ;; If this limitation resulted in an empty group, we might
6640 ;; pop the previous limit and use it instead.
6641 (when (and (not gnus-newsgroup-limit)
6643 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6644 gnus-newsgroup-limit))
6646 (defun gnus-summary-limit-children (thread)
6647 "Return 1 if this subthread is visible and 0 if it is not."
6648 ;; First we get the number of visible children to this thread. This
6649 ;; is done by recursing down the thread using this function, so this
6650 ;; will really go down to a leaf article first, before slowly
6651 ;; working its way up towards the root.
6655 (apply '+ (mapcar 'gnus-summary-limit-children
6658 (number (mail-header-number (car thread)))
6661 (not (memq number gnus-newsgroup-marked))
6663 ;; If this article is dormant and has absolutely no visible
6664 ;; children, then this article isn't visible.
6665 (and (memq number gnus-newsgroup-dormant)
6667 ;; If this is "fetch-old-headered" and there is no
6668 ;; visible children, then we don't want this article.
6669 (and (or (eq gnus-fetch-old-headers 'some)
6670 (numberp gnus-fetch-old-headers))
6671 (gnus-summary-article-ancient-p number)
6673 ;; If this is "fetch-old-headered" and `invisible', then
6674 ;; we don't want this article.
6675 (and (eq gnus-fetch-old-headers 'invisible)
6676 (gnus-summary-article-ancient-p number))
6677 ;; If this is a sparsely inserted article with no children,
6678 ;; we don't want it.
6679 (and (eq gnus-build-sparse-threads 'some)
6680 (gnus-summary-article-sparse-p number)
6682 ;; If we use expunging, and this article is really
6683 ;; low-scored, then we don't want this article.
6684 (when (and gnus-summary-expunge-below
6686 (or (cdr (assq number gnus-newsgroup-scored))
6687 gnus-summary-default-score))
6688 gnus-summary-expunge-below))
6689 ;; We increase the expunge-tally here, but that has
6690 ;; nothing to do with the limits, really.
6691 (incf gnus-newsgroup-expunged-tally)
6692 ;; We also mark as read here, if that's wanted.
6693 (when (and gnus-summary-mark-below
6694 (< score gnus-summary-mark-below))
6695 (setq gnus-newsgroup-unreads
6696 (delq number gnus-newsgroup-unreads))
6697 (if gnus-newsgroup-auto-expire
6698 (push number gnus-newsgroup-expirable)
6699 (push (cons number gnus-low-score-mark)
6700 gnus-newsgroup-reads)))
6702 ;; Check NoCeM things.
6703 (if (and gnus-use-nocem
6704 (gnus-nocem-unwanted-article-p
6705 (mail-header-id (car thread))))
6707 (setq gnus-newsgroup-unreads
6708 (delq number gnus-newsgroup-unreads))
6710 ;; Nope, invisible article.
6712 ;; Ok, this article is to be visible, so we add it to the limit
6714 (push number gnus-newsgroup-limit)
6717 (defun gnus-expunge-thread (thread)
6718 "Mark all articles in THREAD as read."
6719 (let* ((number (mail-header-number (car thread))))
6720 (incf gnus-newsgroup-expunged-tally)
6721 ;; We also mark as read here, if that's wanted.
6722 (setq gnus-newsgroup-unreads
6723 (delq number gnus-newsgroup-unreads))
6724 (if gnus-newsgroup-auto-expire
6725 (push number gnus-newsgroup-expirable)
6726 (push (cons number gnus-low-score-mark)
6727 gnus-newsgroup-reads)))
6728 ;; Go recursively through all subthreads.
6729 (mapcar 'gnus-expunge-thread (cdr thread)))
6731 ;; Summary article oriented commands
6733 (defun gnus-summary-refer-parent-article (n)
6734 "Refer parent article N times.
6735 If N is negative, go to ancestor -N instead.
6736 The difference between N and the number of articles fetched is returned."
6740 (when (not (natnump n))
6745 (setq header (gnus-summary-article-header))
6746 (if (and (eq (mail-header-number header)
6747 (cdr gnus-article-current))
6748 (equal gnus-newsgroup-name
6749 (car gnus-article-current)))
6750 ;; If we try to find the parent of the currently
6751 ;; displayed article, then we take a look at the actual
6752 ;; References header, since this is slightly more
6753 ;; reliable than the References field we got from the
6756 (set-buffer gnus-original-article-buffer)
6757 (nnheader-narrow-to-headers)
6758 (unless (setq ref (message-fetch-field "references"))
6759 (setq ref (message-fetch-field "in-reply-to")))
6762 ;; It's not the current article, so we take a bet on
6763 ;; the value we got from the server.
6764 (mail-header-references header)))
6766 (not (equal ref "")))
6767 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6768 (gnus-message 1 "Couldn't find parent"))
6769 (gnus-message 1 "No references in article %d"
6770 (gnus-summary-article-number))
6773 (gnus-summary-position-point)
6776 (defun gnus-summary-refer-references ()
6777 "Fetch all articles mentioned in the References header.
6778 Return the number of articles fetched."
6780 (let ((ref (mail-header-references (gnus-summary-article-header)))
6781 (current (gnus-summary-article-number))
6785 (error "No References in the current article")
6786 ;; For each Message-ID in the References header...
6787 (while (string-match "<[^>]*>" ref)
6789 ;; ... fetch that article.
6790 (gnus-summary-refer-article
6791 (prog1 (match-string 0 ref)
6792 (setq ref (substring ref (match-end 0))))))
6793 (gnus-summary-goto-subject current)
6794 (gnus-summary-position-point)
6797 (defun gnus-summary-refer-thread (&optional limit)
6798 "Fetch all articles in the current thread.
6799 If LIMIT (the numerical prefix), fetch that many old headers instead
6800 of what's specified by the `gnus-refer-thread-limit' variable."
6802 (let ((id (mail-header-id (gnus-summary-article-header)))
6803 (limit (if limit (prefix-numeric-value limit)
6804 gnus-refer-thread-limit)))
6805 ;; We want to fetch LIMIT *old* headers, but we also have to
6806 ;; re-fetch all the headers in the current buffer, because many of
6807 ;; them may be undisplayed. So we adjust LIMIT.
6808 (when (numberp limit)
6809 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6810 (unless (eq gnus-fetch-old-headers 'invisible)
6811 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6812 ;; Retrieve the headers and read them in.
6813 (if (eq (gnus-retrieve-headers
6814 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6816 (gnus-build-all-threads)
6817 (error "Can't fetch thread from backends that don't support NOV"))
6818 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6819 (gnus-summary-limit-include-thread id)))
6821 (defun gnus-summary-refer-article (message-id)
6822 "Fetch an article specified by MESSAGE-ID."
6823 (interactive "sMessage-ID: ")
6824 (when (and (stringp message-id)
6825 (not (zerop (length message-id))))
6826 ;; Construct the correct Message-ID if necessary.
6827 ;; Suggested by tale@pawl.rpi.edu.
6828 (unless (string-match "^<" message-id)
6829 (setq message-id (concat "<" message-id)))
6830 (unless (string-match ">$" message-id)
6831 (setq message-id (concat message-id ">")))
6832 (let* ((header (gnus-id-to-header message-id))
6834 (gnus-summary-article-sparse-p
6835 (mail-header-number header))
6836 (memq (mail-header-number header)
6837 gnus-newsgroup-limit)))
6840 ;; If the article is present in the buffer we just go to it.
6842 (or (not (gnus-summary-article-sparse-p
6843 (mail-header-number header)))
6846 (gnus-summary-goto-article
6847 (mail-header-number header) nil t)
6849 (gnus-summary-update-article (mail-header-number header)))))
6851 ;; We fetch the article.
6853 (dolist (gnus-override-method (gnus-refer-article-methods))
6854 (gnus-check-server gnus-override-method)
6855 ;; Fetch the header, and display the article.
6856 (when (setq number (gnus-summary-insert-subject message-id))
6857 (gnus-summary-select-article nil nil nil number)
6859 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6861 (defun gnus-refer-article-methods ()
6862 "Return a list of referrable methods."
6864 ;; No method, so we default to current and native.
6865 ((null gnus-refer-article-method)
6866 (list gnus-current-select-method gnus-select-method))
6868 ((eq 'current gnus-refer-article-method)
6869 (list gnus-current-select-method))
6870 ;; List of select methods.
6871 ((not (stringp (cadr gnus-refer-article-method)))
6873 (dolist (method gnus-refer-article-method)
6874 (push (if (eq 'current method)
6875 gnus-current-select-method
6879 ;; One single select method.
6881 (list gnus-refer-article-method))))
6883 (defun gnus-summary-edit-parameters ()
6884 "Edit the group parameters of the current group."
6886 (gnus-group-edit-group gnus-newsgroup-name 'params))
6888 (defun gnus-summary-customize-parameters ()
6889 "Customize the group parameters of the current group."
6891 (gnus-group-customize gnus-newsgroup-name))
6893 (defun gnus-summary-enter-digest-group (&optional force)
6894 "Enter an nndoc group based on the current article.
6895 If FORCE, force a digest interpretation. If not, try
6896 to guess what the document format is."
6898 (let ((conf gnus-current-window-configuration))
6900 (gnus-summary-select-article))
6901 (setq gnus-current-window-configuration conf)
6902 (let* ((name (format "%s-%d"
6903 (gnus-group-prefixed-name
6904 gnus-newsgroup-name (list 'nndoc ""))
6906 (set-buffer gnus-summary-buffer)
6907 gnus-current-article)))
6908 (ogroup gnus-newsgroup-name)
6909 (params (append (gnus-info-params (gnus-get-info ogroup))
6910 (list (cons 'to-group ogroup))
6911 (list (cons 'save-article-group ogroup))))
6912 (case-fold-search t)
6913 (buf (current-buffer))
6916 (set-buffer gnus-original-article-buffer)
6917 ;; Have the digest group inherit the main mail address of
6918 ;; the parent article.
6919 (when (setq to-address (or (message-fetch-field "reply-to")
6920 (message-fetch-field "from")))
6921 (setq params (append (list (cons 'to-address to-address)))))
6922 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6923 (insert-buffer-substring gnus-original-article-buffer)
6924 ;; Remove lines that may lead nndoc to misinterpret the
6927 (goto-char (point-min))
6928 (or (search-forward "\n\n" nil t) (point)))
6929 (goto-char (point-min))
6930 (delete-matching-lines "^Path:\\|^From ")
6933 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6934 (gnus-newsgroup-ephemeral-ignored-charsets
6935 gnus-newsgroup-ignored-charsets))
6936 (gnus-group-read-ephemeral-group
6937 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6939 ,(if force 'mbox 'guess))) t))
6940 ;; Make all postings to this group go to the parent group.
6941 (nconc (gnus-info-params (gnus-get-info name))
6943 ;; Couldn't select this doc group.
6944 (switch-to-buffer buf)
6945 (gnus-set-global-variables)
6946 (gnus-configure-windows 'summary)
6947 (gnus-message 3 "Article couldn't be entered?"))
6948 (kill-buffer dig)))))
6950 (defun gnus-summary-read-document (n)
6951 "Open a new group based on the current article(s).
6952 This will allow you to read digests and other similar
6953 documents as newsgroups.
6954 Obeys the standard process/prefix convention."
6956 (let* ((articles (gnus-summary-work-articles n))
6957 (ogroup gnus-newsgroup-name)
6958 (params (append (gnus-info-params (gnus-get-info ogroup))
6959 (list (cons 'to-group ogroup))))
6960 article group egroup groups vgroup)
6961 (while (setq article (pop articles))
6962 (setq group (format "%s-%d" gnus-newsgroup-name article))
6963 (gnus-summary-remove-process-mark article)
6964 (when (gnus-summary-display-article article)
6967 (insert-buffer-substring gnus-original-article-buffer)
6968 ;; Remove some headers that may lead nndoc to make
6970 (message-narrow-to-head)
6971 (goto-char (point-min))
6972 (delete-matching-lines "^\\(Path\\):\\|^From ")
6975 (gnus-group-read-ephemeral-group
6976 group `(nndoc ,group (nndoc-address ,(current-buffer))
6977 (nndoc-article-type guess))
6980 ;; Make all postings to this group go to the parent group.
6981 (nconc (gnus-info-params (gnus-get-info egroup))
6983 (push egroup groups))
6984 ;; Couldn't select this doc group.
6985 (gnus-error 3 "Article couldn't be entered"))))))
6986 ;; Now we have selected all the documents.
6989 (error "None of the articles could be interpreted as documents"))
6990 ((gnus-group-read-ephemeral-group
6991 (setq vgroup (format
6992 "nnvirtual:%s-%s" gnus-newsgroup-name
6993 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6994 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6996 (cons (current-buffer) 'summary)))
6998 (error "Couldn't select virtual nndoc group")))))
7000 (defun gnus-summary-isearch-article (&optional regexp-p)
7001 "Do incremental search forward on the current article.
7002 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7004 (let* ((gnus-inhibit-treatment t)
7005 (old (gnus-summary-select-article)))
7006 (gnus-configure-windows 'article)
7007 (gnus-eval-in-buffer-window gnus-article-buffer
7011 (gnus-article-show-all-headers))
7012 (goto-char (point-min))
7013 (isearch-forward regexp-p)))))
7015 (defun gnus-summary-search-article-forward (regexp &optional backward)
7016 "Search for an article containing REGEXP forward.
7017 If BACKWARD, search backward instead."
7020 (format "Search article %s (regexp%s): "
7021 (if current-prefix-arg "backward" "forward")
7022 (if gnus-last-search-regexp
7023 (concat ", default " gnus-last-search-regexp)
7025 current-prefix-arg))
7026 (if (string-equal regexp "")
7027 (setq regexp (or gnus-last-search-regexp ""))
7028 (setq gnus-last-search-regexp regexp))
7029 (if (gnus-summary-search-article regexp backward)
7030 (gnus-summary-show-thread)
7031 (error "Search failed: \"%s\"" regexp)))
7033 (defun gnus-summary-search-article-backward (regexp)
7034 "Search for an article containing REGEXP backward."
7037 (format "Search article backward (regexp%s): "
7038 (if gnus-last-search-regexp
7039 (concat ", default " gnus-last-search-regexp)
7041 (gnus-summary-search-article-forward regexp 'backward))
7044 (defmacro gnus-summary-search-article-position-point (regexp backward)
7045 "Dehighlight the last matched text and goto the beginning position."
7046 (` (if (and gnus-summary-search-article-matched-data
7047 (let ((text (caddr gnus-summary-search-article-matched-data))
7048 (inhibit-read-only t)
7051 (goto-char (car gnus-summary-search-article-matched-data))
7052 (cadr gnus-summary-search-article-matched-data))
7054 (string-match (, regexp) text)))
7055 (if (, backward) (beginning-of-line) (end-of-line))
7056 (goto-char (if (, backward) (point-max) (point-min))))))
7058 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7059 "Place point where X-Face image is displayed."
7060 (if (featurep 'xemacs)
7061 (` (let ((end (if (search-forward "\n\n" nil t)
7062 (goto-char (1- (point)))
7065 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7066 (unless (and (re-search-forward "^From:" end t)
7067 (setq extent (extent-at (point)))
7068 (extent-begin-glyph extent))
7069 (goto-char (, opoint)))))
7070 (` (let ((end (if (search-forward "\n\n" nil t)
7071 (goto-char (1- (point)))
7074 (or (text-property-any (or (search-backward "\n\n" nil t)
7076 end 'x-face-mule-bitmap-image t)
7079 (defmacro gnus-summary-search-article-highlight-matched-text
7080 (backward treated x-face)
7081 "Highlight matched text in the function `gnus-summary-search-article'."
7082 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7083 (end (set-marker (make-marker) (match-end 0)))
7084 (inhibit-read-only t)
7088 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7090 (lambda (item) (setq items (delq item items)))
7091 '(gnus-treat-buttonize
7092 gnus-treat-fill-article
7093 gnus-treat-fill-long-lines
7094 gnus-treat-emphasize
7095 gnus-treat-highlight-headers
7096 gnus-treat-highlight-citation
7097 gnus-treat-highlight-signature
7098 gnus-treat-overstrike
7099 gnus-treat-display-xface
7100 gnus-treat-buttonize-head
7101 gnus-treat-decode-article-as-default-mime-charset))
7102 (static-if (featurep 'xemacs)
7104 (cons '(x-face-mule-delete-x-face-field
7107 (gnus-treat-display-xface
7108 (when (, x-face) gnus-treat-display-xface)))
7109 (gnus-article-prepare-mime-display)))
7110 (goto-char (if (, backward) start end))
7112 (gnus-summary-search-article-highlight-goto-x-face (point)))
7113 (setq gnus-summary-search-article-matched-data
7114 (list start end (buffer-substring start end)))
7115 (unless (eq start end);; matched text has been deleted. :-<
7116 (put-text-property start end 'face
7117 (or (find-face 'isearch)
7118 'secondary-selection))))))
7121 (defun gnus-summary-search-article (regexp &optional backward)
7122 "Search for an article containing REGEXP.
7123 Optional argument BACKWARD means do search for backward.
7124 `gnus-select-article-hook' is not called during the search."
7125 ;; We have to require this here to make sure that the following
7126 ;; dynamic binding isn't shadowed by autoloading.
7127 (require 'gnus-async)
7129 (let ((gnus-select-article-hook nil) ;Disable hook.
7130 (gnus-article-display-hook nil)
7131 (gnus-article-prepare-hook nil)
7132 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7133 (gnus-use-article-prefetch nil)
7134 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7135 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7136 (sum (current-buffer))
7139 (gnus-save-hidden-threads
7140 (static-if (featurep 'xemacs)
7141 (let ((gnus-inhibit-treatment t))
7142 (setq treated (eq 'old (gnus-summary-select-article)))
7144 (not (and (gnus-buffer-live-p gnus-article-buffer)
7145 (window-live-p (get-buffer-window
7146 gnus-article-buffer t)))))
7147 (gnus-summary-select-article nil t)
7148 (setq treated nil)))
7149 (let ((gnus-inhibit-treatment t)
7150 (x-face-mule-delete-x-face-field 'never))
7151 (setq treated (eq 'old (gnus-summary-select-article)))
7154 (and (gnus-buffer-live-p gnus-article-buffer)
7155 (window-live-p (get-buffer-window
7156 gnus-article-buffer t))
7157 (or (not (string-match "^\\^X-Face:" regexp))
7158 (with-current-buffer gnus-article-buffer
7159 gnus-summary-search-article-matched-data)))))
7160 (gnus-summary-select-article nil t)
7161 (setq treated nil))))
7162 (set-buffer gnus-article-buffer)
7166 (gnus-article-show-all-headers)
7167 (gnus-summary-search-article-position-point regexp backward))
7168 (goto-char (if backward (point-max) (point-min))))
7170 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7172 (re-search-backward regexp nil t)
7173 (re-search-forward regexp nil t))
7174 ;; We found the regexp.
7176 (gnus-summary-search-article-highlight-matched-text
7177 backward treated (string-match "^\\^X-Face:" regexp))
7180 (/ (- 2 (window-height
7181 (get-buffer-window gnus-article-buffer t)))
7184 (get-buffer-window (current-buffer))
7187 (setq point (point)))
7188 ;; We didn't find it, so we go to the next article.
7191 (while (eq found 'not)
7192 (if (not (if backward (gnus-summary-find-prev)
7193 (gnus-summary-find-next)))
7194 ;; No more articles.
7196 ;; Select the next article and adjust point.
7197 (unless (gnus-summary-article-sparse-p
7198 (gnus-summary-article-number))
7200 (let ((gnus-inhibit-treatment t))
7201 (gnus-summary-select-article))
7203 (set-buffer gnus-article-buffer)
7205 (goto-char (if backward (point-max) (point-min))))))))
7206 (gnus-message 7 ""))
7207 ;; Return whether we found the regexp.
7208 (when (eq found 'found)
7210 (gnus-summary-show-thread)
7211 (gnus-summary-goto-subject gnus-current-article)
7212 (gnus-summary-position-point)
7215 (defun gnus-summary-find-matching (header regexp &optional backward unread
7217 "Return a list of all articles that match REGEXP on HEADER.
7218 The search stars on the current article and goes forwards unless
7219 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7220 If UNREAD is non-nil, only unread articles will
7221 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7222 in the comparisons."
7223 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7224 (gnus-data-find-list
7225 (gnus-summary-article-number) (gnus-data-list backward))))
7226 (case-fold-search (not not-case-fold))
7229 (if (eq (car header) 'extra)
7232 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7234 (error "%s is an invalid header" header))
7235 (unless (fboundp (intern (concat "mail-header-" header)))
7236 (error "%s is not a valid header" header))
7237 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7240 (and (or (not unread) ; We want all articles...
7241 (gnus-data-unread-p d)) ; Or just unreads.
7242 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7243 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7244 (push (gnus-data-number d) articles)) ; Success!
7245 (setq data (cdr data)))
7246 (nreverse articles)))
7248 (defun gnus-summary-execute-command (header regexp command &optional backward)
7249 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7250 If HEADER is an empty string (or nil), the match is done on the entire
7251 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7253 (list (let ((completion-ignore-case t))
7256 (mapcar (lambda (string) (list string))
7257 '("Number" "Subject" "From" "Lines" "Date"
7258 "Message-ID" "Xref" "References" "Body"))
7259 nil 'require-match))
7260 (read-string "Regexp: ")
7261 (read-key-sequence "Command: ")
7262 current-prefix-arg))
7263 (when (equal header "Body")
7265 ;; Hidden thread subtrees must be searched as well.
7266 (gnus-summary-show-all-threads)
7267 ;; We don't want to change current point nor window configuration.
7269 (save-window-excursion
7270 (gnus-message 6 "Executing %s..." (key-description command))
7271 ;; We'd like to execute COMMAND interactively so as to give arguments.
7272 (gnus-execute header regexp
7273 `(call-interactively ',(key-binding command))
7275 (gnus-message 6 "Executing %s...done" (key-description command)))))
7277 (defun gnus-summary-beginning-of-article ()
7278 "Scroll the article back to the beginning."
7280 (gnus-summary-select-article)
7281 (gnus-configure-windows 'article)
7282 (gnus-eval-in-buffer-window gnus-article-buffer
7284 (goto-char (point-min))
7285 (when gnus-page-broken
7286 (gnus-narrow-to-page))))
7288 (defun gnus-summary-end-of-article ()
7289 "Scroll to the end of the article."
7291 (gnus-summary-select-article)
7292 (gnus-configure-windows 'article)
7293 (gnus-eval-in-buffer-window gnus-article-buffer
7295 (goto-char (point-max))
7297 (when gnus-page-broken
7298 (gnus-narrow-to-page))))
7300 (defun gnus-summary-print-article (&optional filename n)
7301 "Generate and print a PostScript image of the N next (mail) articles.
7303 If N is negative, print the N previous articles. If N is nil and articles
7304 have been marked with the process mark, print these instead.
7306 If the optional first argument FILENAME is nil, send the image to the
7307 printer. If FILENAME is a string, save the PostScript image in a file with
7308 that name. If FILENAME is a number, prompt the user for the name of the file
7310 (interactive (list (ps-print-preprint current-prefix-arg)
7311 current-prefix-arg))
7312 (dolist (article (gnus-summary-work-articles n))
7313 (gnus-summary-select-article nil nil 'pseudo article)
7314 (gnus-eval-in-buffer-window gnus-article-buffer
7315 (let ((buffer (generate-new-buffer " *print*")))
7318 (copy-to-buffer buffer (point-min) (point-max))
7320 (gnus-article-delete-invisible-text)
7321 (let ((ps-left-header
7324 (mail-header-subject gnus-current-headers) ")")
7326 (mail-header-from gnus-current-headers) ")")))
7329 "/pagenumberstring load"
7331 (mail-header-date gnus-current-headers) ")"))))
7332 (gnus-run-hooks 'gnus-ps-print-hook)
7334 (ps-print-buffer-with-faces filename))))
7335 (kill-buffer buffer))))))
7337 (defun gnus-summary-show-article (&optional arg)
7338 "Force re-fetching of the current article.
7339 If ARG (the prefix) is a number, show the article with the charset
7340 defined in `gnus-summary-show-article-charset-alist', or the charset
7342 If ARG (the prefix) is non-nil and not a number, show the raw article
7343 without any article massaging functions being run."
7347 (let ((gnus-newsgroup-charset
7348 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7349 (read-coding-system "Charset: ")))
7350 (gnus-newsgroup-ignored-charsets 'gnus-all))
7351 (gnus-summary-select-article nil 'force)))
7353 ;; Select the article the normal way.
7354 (gnus-summary-select-article nil 'force))
7356 ;; We have to require this here to make sure that the following
7357 ;; dynamic binding isn't shadowed by autoloading.
7358 (require 'gnus-async)
7360 ;; Bind the article treatment functions to nil.
7361 (let ((gnus-have-all-headers t)
7362 gnus-article-display-hook
7363 gnus-article-prepare-hook
7364 gnus-article-decode-hook
7367 (gnus-summary-select-article nil 'force))))
7368 (gnus-summary-goto-subject gnus-current-article)
7369 (gnus-summary-position-point))
7371 (defun gnus-summary-verbose-headers (&optional arg)
7372 "Toggle permanent full header display.
7373 If ARG is a positive number, turn header display on.
7374 If ARG is a negative number, turn header display off."
7376 (setq gnus-show-all-headers
7377 (cond ((or (not (numberp arg))
7379 (not gnus-show-all-headers))
7382 (gnus-summary-show-article))
7384 (defun gnus-summary-toggle-header (&optional arg)
7385 "Show the headers if they are hidden, or hide them if they are shown.
7386 If ARG is a positive number, show the entire header.
7387 If ARG is a negative number, hide the unwanted header lines."
7390 (set-buffer gnus-article-buffer)
7392 (let* ((buffer-read-only nil)
7393 (inhibit-point-motion-hooks t)
7399 (article-narrow-to-head)
7400 (gnus-article-hidden-text-p 'headers))))
7401 (goto-char (point-min))
7402 (when (search-forward "\n\n" nil t)
7403 (delete-region (point-min) (1- (point))))
7404 (goto-char (point-min))
7406 (set-buffer gnus-original-article-buffer)
7407 (goto-char (point-min))
7408 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7409 (insert-buffer-substring gnus-original-article-buffer 1 e)
7411 (narrow-to-region (point-min) (point))
7412 (article-decode-encoded-words)
7414 (let ((gnus-treat-hide-headers nil)
7415 (gnus-treat-hide-boring-headers nil))
7416 (setq gnus-article-wash-types
7417 (delq 'headers gnus-article-wash-types))
7418 (gnus-treat-article 'head))
7419 (gnus-treat-article 'head)))
7420 (gnus-set-mode-line 'article)))))
7422 (defun gnus-summary-show-all-headers ()
7423 "Make all header lines visible."
7425 (gnus-article-show-all-headers))
7427 (defun gnus-summary-toggle-mime (&optional arg)
7428 "Toggle MIME processing.
7429 If ARG is a positive number, turn MIME processing on."
7431 (setq gnus-show-mime
7433 (not gnus-show-mime)
7434 (> (prefix-numeric-value arg) 0)))
7435 (gnus-summary-select-article t 'force))
7437 (defun gnus-summary-caesar-message (&optional arg)
7438 "Caesar rotate the current article by 13.
7439 The numerical prefix specifies how many places to rotate each letter
7442 (gnus-summary-select-article)
7443 (let ((mail-header-separator ""))
7444 (gnus-eval-in-buffer-window gnus-article-buffer
7447 (let ((start (window-start))
7449 (message-caesar-buffer-body arg)
7450 (set-window-start (get-buffer-window (current-buffer)) start))))))
7452 (defun gnus-summary-stop-page-breaking ()
7453 "Stop page breaking in the current article."
7455 (gnus-summary-select-article)
7456 (gnus-eval-in-buffer-window gnus-article-buffer
7458 (when (gnus-visual-p 'page-marker)
7459 (let ((buffer-read-only nil))
7460 (gnus-remove-text-with-property 'gnus-prev)
7461 (gnus-remove-text-with-property 'gnus-next))
7462 (setq gnus-page-broken nil))))
7464 (defun gnus-summary-move-article (&optional n to-newsgroup
7465 select-method action)
7466 "Move the current article to a different newsgroup.
7467 If N is a positive number, move the N next articles.
7468 If N is a negative number, move the N previous articles.
7469 If N is nil and any articles have been marked with the process mark,
7470 move those articles instead.
7471 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7472 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7473 re-spool using this method.
7475 For this function to work, both the current newsgroup and the
7476 newsgroup that you want to move to have to support the `request-move'
7477 and `request-accept' functions.
7479 ACTION can be either `move' (the default), `crosspost' or `copy'."
7482 (setq action 'move))
7483 ;; Disable marking as read.
7484 (let (gnus-mark-article-hook)
7485 (save-window-excursion
7486 (gnus-summary-select-article)))
7487 ;; Check whether the source group supports the required functions.
7488 (cond ((and (eq action 'move)
7489 (not (gnus-check-backend-function
7490 'request-move-article gnus-newsgroup-name)))
7491 (error "The current group does not support article moving"))
7492 ((and (eq action 'crosspost)
7493 (not (gnus-check-backend-function
7494 'request-replace-article gnus-newsgroup-name)))
7495 (error "The current group does not support article editing")))
7496 (let ((articles (gnus-summary-work-articles n))
7497 (prefix (if (gnus-check-backend-function
7498 'request-move-article gnus-newsgroup-name)
7499 (gnus-group-real-prefix gnus-newsgroup-name)
7501 (names '((move "Move" "Moving")
7502 (copy "Copy" "Copying")
7503 (crosspost "Crosspost" "Crossposting")))
7504 (copy-buf (save-excursion
7505 (nnheader-set-temp-buffer " *copy article*")))
7506 (default-marks gnus-article-mark-lists)
7507 (no-expire-marks (delete '(expirable . expire)
7508 (copy-sequence gnus-article-mark-lists)))
7509 art-group to-method new-xref article to-groups)
7510 (unless (assq action names)
7511 (error "Unknown action %s" action))
7512 ;; Read the newsgroup name.
7513 (when (and (not to-newsgroup)
7514 (not select-method))
7516 (gnus-read-move-group-name
7517 (cadr (assq action names))
7518 (symbol-value (intern (format "gnus-current-%s-group" action)))
7520 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7521 (setq to-method (or select-method
7522 (gnus-server-to-method
7523 (gnus-group-method to-newsgroup))))
7524 ;; Check the method we are to move this article to...
7525 (unless (gnus-check-backend-function
7526 'request-accept-article (car to-method))
7527 (error "%s does not support article copying" (car to-method)))
7528 (unless (gnus-check-server to-method)
7529 (error "Can't open server %s" (car to-method)))
7530 (gnus-message 6 "%s to %s: %s..."
7531 (caddr (assq action names))
7532 (or (car select-method) to-newsgroup) articles)
7534 (setq article (pop articles))
7538 ;; Move the article.
7540 ;; Remove this article from future suppression.
7541 (gnus-dup-unsuppress-article article)
7542 (gnus-request-move-article
7543 article ; Article to move
7544 gnus-newsgroup-name ; From newsgroup
7545 (nth 1 (gnus-find-method-for-group
7546 gnus-newsgroup-name)) ; Server
7547 (list 'gnus-request-accept-article
7548 to-newsgroup (list 'quote select-method)
7549 (not articles) t) ; Accept form
7550 (not articles))) ; Only save nov last time
7551 ;; Copy the article.
7554 (set-buffer copy-buf)
7555 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7556 (gnus-request-accept-article
7557 to-newsgroup select-method (not articles) t))))
7558 ;; Crosspost the article.
7559 ((eq action 'crosspost)
7560 (let ((xref (message-tokenize-header
7561 (mail-header-xref (gnus-summary-article-header article))
7563 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7566 (setq xref (list (system-name))))
7569 (mapconcat 'identity
7570 (delete "Xref:" (delete new-xref xref))
7574 (set-buffer copy-buf)
7575 ;; First put the article in the destination group.
7576 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7577 (when (consp (setq art-group
7578 (gnus-request-accept-article
7579 to-newsgroup select-method (not articles))))
7580 (setq new-xref (concat new-xref " " (car art-group)
7581 ":" (cdr art-group)))
7582 ;; Now we have the new Xrefs header, so we insert
7583 ;; it and replace the new article.
7584 (nnheader-replace-header "Xref" new-xref)
7585 (gnus-request-replace-article
7586 (cdr art-group) to-newsgroup (current-buffer))
7590 (gnus-message 1 "Couldn't %s article %s: %s"
7591 (cadr (assq action names)) article
7592 (nnheader-get-report (car to-method))))
7593 ((eq art-group 'junk)
7594 (when (eq action 'move)
7595 (gnus-summary-mark-article article gnus-canceled-mark)
7596 (gnus-message 4 "Deleted article %s" article)))
7598 (let* ((pto-group (gnus-group-prefixed-name
7599 (car art-group) to-method))
7601 (gnus-gethash pto-group gnus-newsrc-hashtb))
7602 (info (nth 2 entry))
7603 (to-group (gnus-info-group info))
7605 ;; Update the group that has been moved to.
7607 (memq action '(move copy)))
7608 (unless (member to-group to-groups)
7609 (push to-group to-groups))
7611 (unless (memq article gnus-newsgroup-unreads)
7612 (push 'read to-marks)
7614 info (gnus-add-to-range (gnus-info-read info)
7615 (list (cdr art-group)))))
7617 ;; See whether the article is to be put in the cache.
7618 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7621 (to-article (cdr art-group)))
7623 ;; Enter the article into the cache in the new group,
7624 ;; if that is required.
7625 (when gnus-use-cache
7626 (gnus-cache-possibly-enter-article
7628 (let ((header (copy-sequence
7629 (gnus-summary-article-header article))))
7630 (mail-header-set-number header to-article)
7632 (memq article gnus-newsgroup-marked)
7633 (memq article gnus-newsgroup-dormant)
7634 (memq article gnus-newsgroup-unreads)))
7636 (when gnus-preserve-marks
7637 ;; Copy any marks over to the new group.
7638 (when (and (equal to-group gnus-newsgroup-name)
7639 (not (memq article gnus-newsgroup-unreads)))
7640 ;; Mark this article as read in this group.
7641 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7642 (setcdr (gnus-active to-group) to-article)
7643 (setcdr gnus-newsgroup-active to-article))
7646 (when (memq article (symbol-value
7647 (intern (format "gnus-newsgroup-%s"
7649 (push (cdar marks) to-marks)
7650 ;; If the other group is the same as this group,
7651 ;; then we have to add the mark to the list.
7652 (when (equal to-group gnus-newsgroup-name)
7653 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7656 (intern (format "gnus-newsgroup-%s"
7658 ;; Copy the marks to other group.
7659 (gnus-add-marked-articles
7660 to-group (cdar marks) (list to-article) info))
7661 (setq marks (cdr marks)))
7663 (gnus-request-set-mark to-group (list (list (list to-article)
7668 (concat "(gnus-group-set-info '"
7669 (gnus-prin1-to-string (gnus-get-info to-group))
7672 ;; Update the Xref header in this article to point to
7673 ;; the new crossposted article we have just created.
7674 (when (eq action 'crosspost)
7676 (set-buffer copy-buf)
7677 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7678 (nnheader-replace-header "Xref" new-xref)
7679 (gnus-request-replace-article
7680 article gnus-newsgroup-name (current-buffer)))))
7682 ;;;!!!Why is this necessary?
7683 (set-buffer gnus-summary-buffer)
7685 (gnus-summary-goto-subject article)
7686 (when (eq action 'move)
7687 (gnus-summary-mark-article article gnus-canceled-mark))))
7688 (gnus-summary-remove-process-mark article))
7689 ;; Re-activate all groups that have been moved to.
7692 (set-buffer gnus-group-buffer)
7693 (when (gnus-group-goto-group (car to-groups) t)
7694 (gnus-group-get-new-news-this-group 1 t))
7697 (gnus-kill-buffer copy-buf)
7698 (gnus-summary-position-point)
7699 (gnus-set-mode-line 'summary)))
7701 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7702 "Move the current article to a different newsgroup.
7703 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7704 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7705 re-spool using this method."
7707 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7709 (defun gnus-summary-crosspost-article (&optional n)
7710 "Crosspost the current article to some other group."
7712 (gnus-summary-move-article n nil nil 'crosspost))
7714 (defcustom gnus-summary-respool-default-method nil
7715 "Default method for respooling an article.
7716 If nil, use to the current newsgroup method."
7717 :type '(choice (gnus-select-method :value (nnml ""))
7719 :group 'gnus-summary-mail)
7721 (defun gnus-summary-respool-article (&optional n method)
7722 "Respool the current article.
7723 The article will be squeezed through the mail spooling process again,
7724 which means that it will be put in some mail newsgroup or other
7725 depending on `nnmail-split-methods'.
7726 If N is a positive number, respool the N next articles.
7727 If N is a negative number, respool the N previous articles.
7728 If N is nil and any articles have been marked with the process mark,
7729 respool those articles instead.
7731 Respooling can be done both from mail groups and \"real\" newsgroups.
7732 In the former case, the articles in question will be moved from the
7733 current group into whatever groups they are destined to. In the
7734 latter case, they will be copied into the relevant groups."
7736 (list current-prefix-arg
7737 (let* ((methods (gnus-methods-using 'respool))
7739 (symbol-name (or gnus-summary-respool-default-method
7740 (car (gnus-find-method-for-group
7741 gnus-newsgroup-name)))))
7743 (gnus-completing-read
7744 methname "What backend do you want to use when respooling?"
7745 methods nil t nil 'gnus-mail-method-history))
7748 ((zerop (length (setq ms (gnus-servers-using-backend
7750 (list (intern method) ""))
7754 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7755 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7758 (error "No method given for respooling"))
7759 (if (assoc (symbol-name
7760 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7761 (gnus-methods-using 'respool))
7762 (gnus-summary-move-article n nil method)
7763 (gnus-summary-copy-article n nil method)))
7765 (defun gnus-summary-import-article (file)
7766 "Import an arbitrary file into a mail newsgroup."
7767 (interactive "fImport file: ")
7768 (let ((group gnus-newsgroup-name)
7769 (now (current-time))
7771 (unless (gnus-check-backend-function 'request-accept-article group)
7772 (error "%s does not support article importing" group))
7773 (or (file-readable-p file)
7774 (not (file-regular-p file))
7775 (error "Can't read %s" file))
7777 (set-buffer (gnus-get-buffer-create " *import file*"))
7779 (nnheader-insert-file-contents file)
7780 (goto-char (point-min))
7781 (unless (nnheader-article-p)
7782 ;; This doesn't look like an article, so we fudge some headers.
7783 (setq atts (file-attributes file)
7784 lines (count-lines (point-min) (point-max)))
7785 (insert "From: " (read-string "From: ") "\n"
7786 "Subject: " (read-string "Subject: ") "\n"
7787 "Date: " (message-make-date (nth 5 atts))
7789 "Message-ID: " (message-make-message-id) "\n"
7790 "Lines: " (int-to-string lines) "\n"
7791 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7792 (gnus-request-accept-article group nil t)
7793 (kill-buffer (current-buffer)))))
7795 (defun gnus-summary-article-posted-p ()
7796 "Say whether the current (mail) article is available from news as well.
7797 This will be the case if the article has both been mailed and posted."
7799 (let ((id (mail-header-references (gnus-summary-article-header)))
7800 (gnus-override-method (car (gnus-refer-article-methods))))
7801 (if (gnus-request-head id "")
7802 (gnus-message 2 "The current message was found on %s"
7803 gnus-override-method)
7804 (gnus-message 2 "The current message couldn't be found on %s"
7805 gnus-override-method)
7808 (defun gnus-summary-expire-articles (&optional now)
7809 "Expire all articles that are marked as expirable in the current group."
7811 (when (gnus-check-backend-function
7812 'request-expire-articles gnus-newsgroup-name)
7813 ;; This backend supports expiry.
7814 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7815 (expirable (if total
7817 ;; We need to update the info for
7818 ;; this group for `gnus-list-of-read-articles'
7819 ;; to give us the right answer.
7820 (gnus-run-hooks 'gnus-exit-group-hook)
7821 (gnus-summary-update-info)
7822 (gnus-list-of-read-articles gnus-newsgroup-name))
7823 (setq gnus-newsgroup-expirable
7824 (sort gnus-newsgroup-expirable '<))))
7825 (expiry-wait (if now 'immediate
7826 (gnus-group-find-parameter
7827 gnus-newsgroup-name 'expiry-wait)))
7830 ;; There are expirable articles in this group, so we run them
7831 ;; through the expiry process.
7832 (gnus-message 6 "Expiring articles...")
7833 (unless (gnus-check-group gnus-newsgroup-name)
7834 (error "Can't open server for %s" gnus-newsgroup-name))
7835 ;; The list of articles that weren't expired is returned.
7838 (let ((nnmail-expiry-wait-function nil)
7839 (nnmail-expiry-wait expiry-wait))
7840 (setq es (gnus-request-expire-articles
7841 expirable gnus-newsgroup-name)))
7842 (setq es (gnus-request-expire-articles
7843 expirable gnus-newsgroup-name))))
7845 (setq gnus-newsgroup-expirable es))
7846 ;; We go through the old list of expirable, and mark all
7847 ;; really expired articles as nonexistent.
7848 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7849 (let ((gnus-use-cache nil))
7851 (unless (memq (car expirable) es)
7852 (when (gnus-data-find (car expirable))
7853 (gnus-summary-mark-article
7854 (car expirable) gnus-canceled-mark)))
7855 (setq expirable (cdr expirable)))))
7856 (gnus-message 6 "Expiring articles...done")))))
7858 (defun gnus-summary-expire-articles-now ()
7859 "Expunge all expirable articles in the current group.
7860 This means that *all* articles that are marked as expirable will be
7861 deleted forever, right now."
7863 (or gnus-expert-user
7865 "Are you really, really, really sure you want to delete all these messages? ")
7867 (gnus-summary-expire-articles t))
7869 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7870 (defun gnus-summary-delete-article (&optional n)
7871 "Delete the N next (mail) articles.
7872 This command actually deletes articles. This is not a marking
7873 command. The article will disappear forever from your life, never to
7875 If N is negative, delete backwards.
7876 If N is nil and articles have been marked with the process mark,
7877 delete these instead."
7879 (unless (gnus-check-backend-function 'request-expire-articles
7880 gnus-newsgroup-name)
7881 (error "The current newsgroup does not support article deletion"))
7882 ;; Compute the list of articles to delete.
7883 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7885 (if (and gnus-novice-user
7886 (not (gnus-yes-or-no-p
7887 (format "Do you really want to delete %s forever? "
7888 (if (> (length articles) 1)
7889 (format "these %s articles" (length articles))
7892 ;; Delete the articles.
7893 (setq not-deleted (gnus-request-expire-articles
7894 articles gnus-newsgroup-name 'force))
7896 (gnus-summary-remove-process-mark (car articles))
7897 ;; The backend might not have been able to delete the article
7899 (unless (memq (car articles) not-deleted)
7900 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7901 (setq articles (cdr articles)))
7903 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7904 (gnus-summary-position-point)
7905 (gnus-set-mode-line 'summary)
7908 (defun gnus-summary-edit-article (&optional force)
7909 "Edit the current article.
7910 This will have permanent effect only in mail groups.
7911 If FORCE is non-nil, allow editing of articles even in read-only
7915 (set-buffer gnus-summary-buffer)
7916 (let ((mail-parse-charset gnus-newsgroup-charset)
7917 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7918 (gnus-set-global-variables)
7919 (when (and (not force)
7920 (gnus-group-read-only-p))
7921 (error "The current newsgroup does not support article editing"))
7922 (gnus-summary-show-article t)
7923 (gnus-article-edit-article
7925 `(lambda (no-highlight)
7926 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7927 (mail-parse-ignored-charsets
7928 ',gnus-newsgroup-ignored-charsets))
7929 (gnus-summary-edit-article-done
7930 ,(or (mail-header-references gnus-current-headers) "")
7931 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7933 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7935 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7937 "Make edits to the current article permanent."
7939 ;; Replace the article.
7940 (let ((buf (current-buffer)))
7942 (insert-buffer-substring buf)
7943 (if (and (not read-only)
7944 (not (gnus-request-replace-article
7945 (cdr gnus-article-current) (car gnus-article-current)
7946 (current-buffer) t)))
7947 (error "Couldn't replace article")
7948 ;; Update the summary buffer.
7950 (equal (message-tokenize-header references " ")
7951 (message-tokenize-header
7952 (or (message-fetch-field "references") "") " ")))
7953 ;; We only have to update this line.
7956 (message-narrow-to-head)
7957 (let ((head (buffer-string))
7960 (insert (format "211 %d Article retrieved.\n"
7961 (cdr gnus-article-current)))
7964 (let ((nntp-server-buffer (current-buffer)))
7965 (setq header (car (gnus-get-newsgroup-headers
7967 (set-buffer gnus-summary-buffer)
7968 gnus-newsgroup-dependencies)
7971 (set-buffer gnus-summary-buffer)
7972 (gnus-data-set-header
7973 (gnus-data-find (cdr gnus-article-current))
7975 (gnus-summary-update-article-line
7976 (cdr gnus-article-current) header))))))
7978 (set-buffer (or buffer gnus-summary-buffer))
7979 (gnus-summary-update-article (cdr gnus-article-current)))
7980 ;; Prettify the article buffer again.
7981 (unless no-highlight
7983 (set-buffer gnus-article-buffer)
7984 ;;;!!! Fix this -- article should be rehighlighted.
7985 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7986 (set-buffer gnus-original-article-buffer)
7987 (gnus-request-article
7988 (cdr gnus-article-current)
7989 (car gnus-article-current) (current-buffer))))
7990 ;; Prettify the summary buffer line.
7991 (when (gnus-visual-p 'summary-highlight 'highlight)
7992 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7994 (defun gnus-summary-edit-wash (key)
7995 "Perform editing command KEY in the article buffer."
7999 (message "%s" (concat (this-command-keys) "- "))
8002 (gnus-summary-edit-article)
8003 (execute-kbd-macro (concat (this-command-keys) key))
8004 (gnus-article-edit-done))
8008 (defun gnus-summary-respool-query (&optional silent trace)
8009 "Query where the respool algorithm would put this article."
8011 (let (gnus-mark-article-hook)
8012 (gnus-summary-select-article)
8014 (set-buffer gnus-original-article-buffer)
8016 (message-narrow-to-head)
8017 (let ((groups (nnmail-article-group 'identity trace)))
8020 (message "This message would go to %s"
8021 (mapconcat 'car groups ", "))
8022 (message "This message would go to no groups"))
8025 (defun gnus-summary-respool-trace ()
8026 "Trace where the respool algorithm would put this article.
8027 Display a buffer showing all fancy splitting patterns which matched."
8029 (gnus-summary-respool-query nil t))
8031 ;; Summary marking commands.
8033 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8034 "Mark articles which has the same subject as read, and then select the next.
8035 If UNMARK is positive, remove any kind of mark.
8036 If UNMARK is negative, tick articles."
8039 (setq unmark (prefix-numeric-value unmark)))
8041 (gnus-summary-mark-same-subject
8042 (gnus-summary-article-subject) unmark)))
8043 ;; Select next unread article. If auto-select-same mode, should
8044 ;; select the first unread article.
8045 (gnus-summary-next-article t (and gnus-auto-select-same
8046 (gnus-summary-article-subject)))
8047 (gnus-message 7 "%d article%s marked as %s"
8048 count (if (= count 1) " is" "s are")
8049 (if unmark "unread" "read"))))
8051 (defun gnus-summary-kill-same-subject (&optional unmark)
8052 "Mark articles which has the same subject as read.
8053 If UNMARK is positive, remove any kind of mark.
8054 If UNMARK is negative, tick articles."
8057 (setq unmark (prefix-numeric-value unmark)))
8059 (gnus-summary-mark-same-subject
8060 (gnus-summary-article-subject) unmark)))
8061 ;; If marked as read, go to next unread subject.
8063 ;; Go to next unread subject.
8064 (gnus-summary-next-subject 1 t))
8065 (gnus-message 7 "%d articles are marked as %s"
8066 count (if unmark "unread" "read"))))
8068 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8069 "Mark articles with same SUBJECT as read, and return marked number.
8070 If optional argument UNMARK is positive, remove any kinds of marks.
8071 If optional argument UNMARK is negative, mark articles as unread instead."
8075 ((null unmark) ; Mark as read.
8078 (gnus-summary-mark-article-as-read gnus-killed-mark)
8079 (gnus-summary-show-thread) t)
8080 (gnus-summary-find-subject subject))
8081 (setq count (1+ count))))
8082 ((> unmark 0) ; Tick.
8085 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8086 (gnus-summary-show-thread) t)
8087 (gnus-summary-find-subject subject))
8088 (setq count (1+ count))))
8089 (t ; Mark as unread.
8092 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8093 (gnus-summary-show-thread) t)
8094 (gnus-summary-find-subject subject))
8095 (setq count (1+ count)))))
8096 (gnus-set-mode-line 'summary)
8097 ;; Return the number of marked articles.
8100 (defun gnus-summary-mark-as-processable (n &optional unmark)
8101 "Set the process mark on the next N articles.
8102 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8103 the process mark instead. The difference between N and the actual
8104 number of articles marked is returned."
8106 (let ((backward (< n 0))
8111 (gnus-summary-remove-process-mark
8112 (gnus-summary-article-number))
8113 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8114 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8117 (gnus-message 7 "No more articles"))
8118 (gnus-summary-recenter)
8119 (gnus-summary-position-point)
8122 (defun gnus-summary-unmark-as-processable (n)
8123 "Remove the process mark from the next N articles.
8124 If N is negative, unmark backward instead. The difference between N and
8125 the actual number of articles unmarked is returned."
8127 (gnus-summary-mark-as-processable n t))
8129 (defun gnus-summary-unmark-all-processable ()
8130 "Remove the process mark from all articles."
8133 (while gnus-newsgroup-processable
8134 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8135 (gnus-summary-position-point))
8137 (defun gnus-summary-mark-as-expirable (n)
8138 "Mark N articles forward as expirable.
8139 If N is negative, mark backward instead. The difference between N and
8140 the actual number of articles marked is returned."
8142 (gnus-summary-mark-forward n gnus-expirable-mark))
8144 (defun gnus-summary-mark-article-as-replied (article)
8145 "Mark ARTICLE replied and update the summary line."
8146 (push article gnus-newsgroup-replied)
8147 (let ((buffer-read-only nil))
8148 (when (gnus-summary-goto-subject article nil t)
8149 (gnus-summary-update-secondary-mark article))))
8151 (defun gnus-summary-set-bookmark (article)
8152 "Set a bookmark in current article."
8153 (interactive (list (gnus-summary-article-number)))
8154 (when (or (not (get-buffer gnus-article-buffer))
8155 (not gnus-current-article)
8156 (not gnus-article-current)
8157 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8158 (error "No current article selected"))
8159 ;; Remove old bookmark, if one exists.
8160 (let ((old (assq article gnus-newsgroup-bookmarks)))
8162 (setq gnus-newsgroup-bookmarks
8163 (delq old gnus-newsgroup-bookmarks))))
8164 ;; Set the new bookmark, which is on the form
8165 ;; (article-number . line-number-in-body).
8169 (set-buffer gnus-article-buffer)
8173 (goto-char (point-min))
8174 (search-forward "\n\n" nil t)
8177 gnus-newsgroup-bookmarks)
8178 (gnus-message 6 "A bookmark has been added to the current article."))
8180 (defun gnus-summary-remove-bookmark (article)
8181 "Remove the bookmark from the current article."
8182 (interactive (list (gnus-summary-article-number)))
8183 ;; Remove old bookmark, if one exists.
8184 (let ((old (assq article gnus-newsgroup-bookmarks)))
8187 (setq gnus-newsgroup-bookmarks
8188 (delq old gnus-newsgroup-bookmarks))
8189 (gnus-message 6 "Removed bookmark."))
8190 (gnus-message 6 "No bookmark in current article."))))
8192 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8193 (defun gnus-summary-mark-as-dormant (n)
8194 "Mark N articles forward as dormant.
8195 If N is negative, mark backward instead. The difference between N and
8196 the actual number of articles marked is returned."
8198 (gnus-summary-mark-forward n gnus-dormant-mark))
8200 (defun gnus-summary-set-process-mark (article)
8201 "Set the process mark on ARTICLE and update the summary line."
8202 (setq gnus-newsgroup-processable
8204 (delq article gnus-newsgroup-processable)))
8205 (when (gnus-summary-goto-subject article)
8206 (gnus-summary-show-thread)
8207 (gnus-summary-goto-subject article)
8208 (gnus-summary-update-secondary-mark article)))
8210 (defun gnus-summary-remove-process-mark (article)
8211 "Remove the process mark from ARTICLE and update the summary line."
8212 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8213 (when (gnus-summary-goto-subject article)
8214 (gnus-summary-show-thread)
8215 (gnus-summary-goto-subject article)
8216 (gnus-summary-update-secondary-mark article)))
8218 (defun gnus-summary-set-saved-mark (article)
8219 "Set the process mark on ARTICLE and update the summary line."
8220 (push article gnus-newsgroup-saved)
8221 (when (gnus-summary-goto-subject article)
8222 (gnus-summary-update-secondary-mark article)))
8224 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8225 "Mark N articles as read forwards.
8226 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8227 The difference between N and the actual number of articles marked is
8229 Iff NO-EXPIRE, auto-expiry will be inhibited."
8231 (gnus-summary-show-thread)
8232 (let ((backward (< n 0))
8233 (gnus-summary-goto-unread
8234 (and gnus-summary-goto-unread
8235 (not (eq gnus-summary-goto-unread 'never))
8236 (not (memq mark (list gnus-unread-mark
8237 gnus-ticked-mark gnus-dormant-mark)))))
8239 (mark (or mark gnus-del-mark)))
8241 (gnus-summary-mark-article nil mark no-expire)
8242 (zerop (gnus-summary-next-subject
8244 (and gnus-summary-goto-unread
8245 (not (eq gnus-summary-goto-unread 'never)))
8249 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8250 (gnus-summary-recenter)
8251 (gnus-summary-position-point)
8252 (gnus-set-mode-line 'summary)
8255 (defun gnus-summary-mark-article-as-read (mark)
8256 "Mark the current article quickly as read with MARK."
8257 (let ((article (gnus-summary-article-number)))
8258 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8259 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8260 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8261 (push (cons article mark) gnus-newsgroup-reads)
8262 ;; Possibly remove from cache, if that is used.
8263 (when gnus-use-cache
8264 (gnus-cache-enter-remove-article article))
8265 ;; Allow the backend to change the mark.
8266 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8267 ;; Check for auto-expiry.
8268 (when (and gnus-newsgroup-auto-expire
8269 (memq mark gnus-auto-expirable-marks))
8270 (setq mark gnus-expirable-mark)
8271 ;; Let the backend know about the mark change.
8272 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8273 (push article gnus-newsgroup-expirable))
8274 ;; Set the mark in the buffer.
8275 (gnus-summary-update-mark mark 'unread)
8278 (defun gnus-summary-mark-article-as-unread (mark)
8279 "Mark the current article quickly as unread with MARK."
8280 (let* ((article (gnus-summary-article-number))
8281 (old-mark (gnus-summary-article-mark article)))
8282 ;; Allow the backend to change the mark.
8283 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8284 (if (eq mark old-mark)
8288 (gnus-error 1 "Can't mark negative article numbers")
8290 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8291 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8292 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8293 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8294 (cond ((= mark gnus-ticked-mark)
8295 (push article gnus-newsgroup-marked))
8296 ((= mark gnus-dormant-mark)
8297 (push article gnus-newsgroup-dormant))
8299 (push article gnus-newsgroup-unreads)))
8300 (gnus-pull article gnus-newsgroup-reads)
8302 ;; See whether the article is to be put in the cache.
8304 (vectorp (gnus-summary-article-header article))
8306 (gnus-cache-possibly-enter-article
8307 gnus-newsgroup-name article
8308 (gnus-summary-article-header article)
8309 (= mark gnus-ticked-mark)
8310 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8313 (gnus-summary-update-mark mark 'unread)
8316 (defun gnus-summary-mark-article (&optional article mark no-expire)
8317 "Mark ARTICLE with MARK. MARK can be any character.
8318 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8319 `??' (dormant) and `?E' (expirable).
8320 If MARK is nil, then the default character `?r' is used.
8321 If ARTICLE is nil, then the article on the current line will be
8323 Iff NO-EXPIRE, auto-expiry will be inhibited."
8324 ;; The mark might be a string.
8325 (when (stringp mark)
8326 (setq mark (aref mark 0)))
8327 ;; If no mark is given, then we check auto-expiring.
8329 (setq mark gnus-del-mark))
8330 (when (and (not no-expire)
8331 gnus-newsgroup-auto-expire
8332 (memq mark gnus-auto-expirable-marks))
8333 (setq mark gnus-expirable-mark))
8334 (let ((article (or article (gnus-summary-article-number)))
8335 (old-mark (gnus-summary-article-mark article)))
8336 ;; Allow the backend to change the mark.
8337 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8338 (if (eq mark old-mark)
8341 (error "No article on current line"))
8342 (if (not (if (or (= mark gnus-unread-mark)
8343 (= mark gnus-ticked-mark)
8344 (= mark gnus-dormant-mark))
8345 (gnus-mark-article-as-unread article mark)
8346 (gnus-mark-article-as-read article mark)))
8348 ;; See whether the article is to be put in the cache.
8350 (not (= mark gnus-canceled-mark))
8351 (vectorp (gnus-summary-article-header article))
8353 (gnus-cache-possibly-enter-article
8354 gnus-newsgroup-name article
8355 (gnus-summary-article-header article)
8356 (= mark gnus-ticked-mark)
8357 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8359 (when (gnus-summary-goto-subject article nil t)
8360 (let ((buffer-read-only nil))
8361 (gnus-summary-show-thread)
8363 (gnus-summary-update-mark mark 'unread)
8366 (defun gnus-summary-update-secondary-mark (article)
8367 "Update the secondary (read, process, cache) mark."
8368 (gnus-summary-update-mark
8369 (cond ((memq article gnus-newsgroup-processable)
8371 ((memq article gnus-newsgroup-cached)
8373 ((memq article gnus-newsgroup-replied)
8375 ((memq article gnus-newsgroup-saved)
8377 (t gnus-unread-mark))
8379 (when (gnus-visual-p 'summary-highlight 'highlight)
8380 (gnus-run-hooks 'gnus-summary-update-hook))
8383 (defun gnus-summary-update-mark (mark type)
8384 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8385 (buffer-read-only nil))
8386 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8388 (when (looking-at "\r")
8390 (when (<= (+ forward (point)) (point-max))
8391 ;; Go to the right position on the line.
8392 (goto-char (+ forward (point)))
8393 ;; Replace the old mark with the new mark.
8394 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8395 ;; Optionally update the marks by some user rule.
8396 (when (eq type 'unread)
8398 (gnus-data-find (gnus-summary-article-number)) mark)
8399 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8401 (defun gnus-mark-article-as-read (article &optional mark)
8402 "Enter ARTICLE in the pertinent lists and remove it from others."
8403 ;; Make the article expirable.
8404 (let ((mark (or mark gnus-del-mark)))
8405 (if (= mark gnus-expirable-mark)
8406 (push article gnus-newsgroup-expirable)
8407 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8408 ;; Remove from unread and marked lists.
8409 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8410 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8411 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8412 (push (cons article mark) gnus-newsgroup-reads)
8413 ;; Possibly remove from cache, if that is used.
8414 (when gnus-use-cache
8415 (gnus-cache-enter-remove-article article))
8418 (defun gnus-mark-article-as-unread (article &optional mark)
8419 "Enter ARTICLE in the pertinent lists and remove it from others."
8420 (let ((mark (or mark gnus-ticked-mark)))
8423 (gnus-error 1 "Can't mark negative article numbers")
8425 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8426 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8427 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8428 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8430 ;; Unsuppress duplicates?
8431 (when gnus-suppress-duplicates
8432 (gnus-dup-unsuppress-article article))
8434 (cond ((= mark gnus-ticked-mark)
8435 (push article gnus-newsgroup-marked))
8436 ((= mark gnus-dormant-mark)
8437 (push article gnus-newsgroup-dormant))
8439 (push article gnus-newsgroup-unreads)))
8440 (gnus-pull article gnus-newsgroup-reads)
8443 (defalias 'gnus-summary-mark-as-unread-forward
8444 'gnus-summary-tick-article-forward)
8445 (make-obsolete 'gnus-summary-mark-as-unread-forward
8446 'gnus-summary-tick-article-forward)
8447 (defun gnus-summary-tick-article-forward (n)
8448 "Tick N articles forwards.
8449 If N is negative, tick backwards instead.
8450 The difference between N and the number of articles ticked is returned."
8452 (gnus-summary-mark-forward n gnus-ticked-mark))
8454 (defalias 'gnus-summary-mark-as-unread-backward
8455 'gnus-summary-tick-article-backward)
8456 (make-obsolete 'gnus-summary-mark-as-unread-backward
8457 'gnus-summary-tick-article-backward)
8458 (defun gnus-summary-tick-article-backward (n)
8459 "Tick N articles backwards.
8460 The difference between N and the number of articles ticked is returned."
8462 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8464 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8465 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8466 (defun gnus-summary-tick-article (&optional article clear-mark)
8467 "Mark current article as unread.
8468 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8469 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8471 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8474 (defun gnus-summary-mark-as-read-forward (n)
8475 "Mark N articles as read forwards.
8476 If N is negative, mark backwards instead.
8477 The difference between N and the actual number of articles marked is
8480 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8482 (defun gnus-summary-mark-as-read-backward (n)
8483 "Mark the N articles as read backwards.
8484 The difference between N and the actual number of articles marked is
8487 (gnus-summary-mark-forward
8488 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8490 (defun gnus-summary-mark-as-read (&optional article mark)
8491 "Mark current article as read.
8492 ARTICLE specifies the article to be marked as read.
8493 MARK specifies a string to be inserted at the beginning of the line."
8494 (gnus-summary-mark-article article mark))
8496 (defun gnus-summary-clear-mark-forward (n)
8497 "Clear marks from N articles forward.
8498 If N is negative, clear backward instead.
8499 The difference between N and the number of marks cleared is returned."
8501 (gnus-summary-mark-forward n gnus-unread-mark))
8503 (defun gnus-summary-clear-mark-backward (n)
8504 "Clear marks from N articles backward.
8505 The difference between N and the number of marks cleared is returned."
8507 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8509 (defun gnus-summary-mark-unread-as-read ()
8510 "Intended to be used by `gnus-summary-mark-article-hook'."
8511 (when (memq gnus-current-article gnus-newsgroup-unreads)
8512 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8514 (defun gnus-summary-mark-read-and-unread-as-read ()
8515 "Intended to be used by `gnus-summary-mark-article-hook'."
8516 (let ((mark (gnus-summary-article-mark)))
8517 (when (or (gnus-unread-mark-p mark)
8518 (gnus-read-mark-p mark))
8519 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8521 (defun gnus-summary-mark-region-as-read (point mark all)
8522 "Mark all unread articles between point and mark as read.
8523 If given a prefix, mark all articles between point and mark as read,
8524 even ticked and dormant ones."
8525 (interactive "r\nP")
8534 (memq (setq article (gnus-summary-article-number))
8535 gnus-newsgroup-unreads))
8536 (gnus-summary-mark-article article gnus-del-mark))
8538 (gnus-summary-find-next))))))
8540 (defun gnus-summary-mark-below (score mark)
8541 "Mark articles with score less than SCORE with MARK."
8542 (interactive "P\ncMark: ")
8543 (setq score (if score
8544 (prefix-numeric-value score)
8545 (or gnus-summary-default-score 0)))
8547 (set-buffer gnus-summary-buffer)
8548 (goto-char (point-min))
8551 (and (< (gnus-summary-article-score) score)
8552 (gnus-summary-mark-article nil mark))
8553 (gnus-summary-find-next)))))
8555 (defun gnus-summary-kill-below (&optional score)
8556 "Mark articles with score below SCORE as read."
8558 (gnus-summary-mark-below score gnus-killed-mark))
8560 (defun gnus-summary-clear-above (&optional score)
8561 "Clear all marks from articles with score above SCORE."
8563 (gnus-summary-mark-above score gnus-unread-mark))
8565 (defun gnus-summary-tick-above (&optional score)
8566 "Tick all articles with score above SCORE."
8568 (gnus-summary-mark-above score gnus-ticked-mark))
8570 (defun gnus-summary-mark-above (score mark)
8571 "Mark articles with score over SCORE with MARK."
8572 (interactive "P\ncMark: ")
8573 (setq score (if score
8574 (prefix-numeric-value score)
8575 (or gnus-summary-default-score 0)))
8577 (set-buffer gnus-summary-buffer)
8578 (goto-char (point-min))
8580 (when (> (gnus-summary-article-score) score)
8581 (gnus-summary-mark-article nil mark))
8583 (gnus-summary-find-next)))))
8585 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8586 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8587 (defun gnus-summary-limit-include-expunged (&optional no-error)
8588 "Display all the hidden articles that were expunged for low scores."
8590 (let ((buffer-read-only nil))
8591 (let ((scored gnus-newsgroup-scored)
8594 (unless (gnus-summary-goto-subject (caar scored))
8595 (and (setq h (gnus-summary-article-header (caar scored)))
8596 (< (cdar scored) gnus-summary-expunge-below)
8598 (setq scored (cdr scored)))
8600 (when (not no-error)
8601 (error "No expunged articles hidden"))
8602 (goto-char (point-min))
8603 (gnus-summary-prepare-unthreaded (nreverse headers))
8604 (goto-char (point-min))
8605 (gnus-summary-position-point)
8608 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8609 "Mark all unread articles in this newsgroup as read.
8610 If prefix argument ALL is non-nil, ticked and dormant articles will
8611 also be marked as read.
8612 If QUIETLY is non-nil, no questions will be asked.
8613 If TO-HERE is non-nil, it should be a point in the buffer. All
8614 articles before this point will be marked as read.
8615 Note that this function will only catch up the unread article
8616 in the current summary buffer limitation.
8617 The number of articles marked as read is returned."
8622 (not gnus-interactive-catchup) ;Without confirmation?
8626 "Mark absolutely all articles as read? "
8627 "Mark all unread articles as read? ")))
8629 (not gnus-newsgroup-adaptive)
8630 (not gnus-newsgroup-auto-expire)
8631 (not gnus-suppress-duplicates)
8632 (or (not gnus-use-cache)
8633 (eq gnus-use-cache 'passive)))
8636 (setq gnus-newsgroup-marked nil
8637 gnus-newsgroup-dormant nil))
8638 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8639 ;; We actually mark all articles as canceled, which we
8640 ;; have to do when using auto-expiry or adaptive scoring.
8641 (gnus-summary-show-all-threads)
8642 (when (gnus-summary-first-subject (not all) t)
8644 (if to-here (< (point) to-here) t)
8645 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8646 (gnus-summary-find-next (not all) nil nil t))))
8647 (gnus-set-mode-line 'summary))
8649 (gnus-summary-position-point)))
8651 (defun gnus-summary-catchup-to-here (&optional all)
8652 "Mark all unticked articles before the current one as read.
8653 If ALL is non-nil, also mark ticked and dormant articles as read."
8656 (gnus-save-hidden-threads
8657 (let ((beg (point)))
8658 ;; We check that there are unread articles.
8659 (when (or all (gnus-summary-find-prev))
8660 (gnus-summary-catchup all t beg)))))
8661 (gnus-summary-position-point))
8663 (defun gnus-summary-catchup-all (&optional quietly)
8664 "Mark all articles in this newsgroup as read."
8666 (gnus-summary-catchup t quietly))
8668 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8669 "Mark all unread articles in this group as read, then exit.
8670 If prefix argument ALL is non-nil, all articles are marked as read."
8672 (when (gnus-summary-catchup all quietly nil 'fast)
8673 ;; Select next newsgroup or exit.
8674 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8675 (eq gnus-auto-select-next 'quietly))
8676 (gnus-summary-next-group nil)
8677 (gnus-summary-exit))))
8679 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8680 "Mark all articles in this newsgroup as read, and then exit."
8682 (gnus-summary-catchup-and-exit t quietly))
8684 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8685 "Mark all articles in this group as read and select the next group.
8686 If given a prefix, mark all articles, unread as well as ticked, as
8690 (gnus-summary-catchup all))
8691 (gnus-summary-next-group))
8693 ;; Thread-based commands.
8695 (defun gnus-summary-articles-in-thread (&optional article)
8696 "Return a list of all articles in the current thread.
8697 If ARTICLE is non-nil, return all articles in the thread that starts
8699 (let* ((article (or article (gnus-summary-article-number)))
8700 (data (gnus-data-find-list article))
8701 (top-level (gnus-data-level (car data)))
8703 (cond ((null gnus-thread-operation-ignore-subject)
8704 (gnus-simplify-subject-re
8705 (mail-header-subject (gnus-data-header (car data)))))
8706 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8707 (gnus-simplify-subject-fuzzy
8708 (mail-header-subject (gnus-data-header (car data)))))
8710 (end-point (save-excursion
8711 (if (gnus-summary-go-to-next-thread)
8712 (point) (point-max))))
8715 (< (gnus-data-pos (car data)) end-point))
8716 (when (or (not top-subject)
8717 (string= top-subject
8718 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8719 (gnus-simplify-subject-fuzzy
8720 (mail-header-subject
8721 (gnus-data-header (car data))))
8722 (gnus-simplify-subject-re
8723 (mail-header-subject
8724 (gnus-data-header (car data)))))))
8725 (push (gnus-data-number (car data)) articles))
8726 (unless (and (setq data (cdr data))
8727 (> (gnus-data-level (car data)) top-level))
8729 ;; Return the list of articles.
8730 (nreverse articles)))
8732 (defun gnus-summary-rethread-current ()
8733 "Rethread the thread the current article is part of."
8735 (let* ((gnus-show-threads t)
8736 (article (gnus-summary-article-number))
8737 (id (mail-header-id (gnus-summary-article-header)))
8738 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8740 (error "No article on the current line"))
8741 (gnus-rebuild-thread id)
8742 (gnus-summary-goto-subject article)))
8744 (defun gnus-summary-reparent-thread ()
8745 "Make the current article child of the marked (or previous) article.
8747 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8748 is non-nil or the Subject: of both articles are the same."
8750 (unless (not (gnus-group-read-only-p))
8751 (error "The current newsgroup does not support article editing"))
8752 (unless (<= (length gnus-newsgroup-processable) 1)
8753 (error "No more than one article may be marked"))
8754 (save-window-excursion
8755 (let ((gnus-article-buffer " *reparent*")
8756 (current-article (gnus-summary-article-number))
8757 ;; First grab the marked article, otherwise one line up.
8758 (parent-article (if (not (null gnus-newsgroup-processable))
8759 (car gnus-newsgroup-processable)
8761 (if (eq (forward-line -1) 0)
8762 (gnus-summary-article-number)
8763 (error "Beginning of summary buffer"))))))
8764 (unless (not (eq current-article parent-article))
8765 (error "An article may not be self-referential"))
8766 (let ((message-id (mail-header-id
8767 (gnus-summary-article-header parent-article))))
8768 (unless (and message-id (not (equal message-id "")))
8769 (error "No message-id in desired parent"))
8770 (gnus-with-article current-article
8771 (goto-char (point-min))
8772 (if (re-search-forward "^References: " nil t)
8774 (re-search-forward "^[^ \t]" nil t)
8777 (insert " " message-id))
8778 (insert "References: " message-id "\n")))
8779 (set-buffer gnus-summary-buffer)
8780 (gnus-summary-unmark-all-processable)
8781 (gnus-summary-update-article current-article)
8782 (gnus-summary-rethread-current)
8783 (gnus-message 3 "Article %d is now the child of article %d"
8784 current-article parent-article)))))
8786 (defun gnus-summary-toggle-threads (&optional arg)
8787 "Toggle showing conversation threads.
8788 If ARG is positive number, turn showing conversation threads on."
8790 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8791 (setq gnus-show-threads
8792 (if (null arg) (not gnus-show-threads)
8793 (> (prefix-numeric-value arg) 0)))
8794 (gnus-summary-prepare)
8795 (gnus-summary-goto-subject current)
8796 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8797 (gnus-summary-position-point)))
8799 (defun gnus-summary-show-all-threads ()
8803 (let ((buffer-read-only nil))
8804 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8805 (gnus-summary-position-point))
8807 (defun gnus-summary-show-thread ()
8808 "Show thread subtrees.
8809 Returns nil if no thread was there to be shown."
8811 (let ((buffer-read-only nil)
8813 ;; first goto end then to beg, to have point at beg after let
8814 (end (progn (end-of-line) (point)))
8815 (beg (progn (beginning-of-line) (point))))
8817 ;; Any hidden lines here?
8818 (search-forward "\r" end t)
8819 (subst-char-in-region beg end ?\^M ?\n t)
8821 (gnus-summary-position-point))))
8823 (defun gnus-summary-hide-all-threads ()
8824 "Hide all thread subtrees."
8827 (goto-char (point-min))
8828 (gnus-summary-hide-thread)
8829 (while (zerop (gnus-summary-next-thread 1 t))
8830 (gnus-summary-hide-thread)))
8831 (gnus-summary-position-point))
8833 (defun gnus-summary-hide-thread ()
8834 "Hide thread subtrees.
8835 Returns nil if no threads were there to be hidden."
8837 (let ((buffer-read-only nil)
8839 (article (gnus-summary-article-number)))
8841 ;; Go forward until either the buffer ends or the subthread
8843 (when (and (not (eobp))
8844 (or (zerop (gnus-summary-next-thread 1 t))
8845 (goto-char (point-max))))
8847 (if (and (> (point) start)
8848 (search-backward "\n" start t))
8850 (subst-char-in-region start (point) ?\n ?\^M)
8851 (gnus-summary-goto-subject article))
8855 (defun gnus-summary-go-to-next-thread (&optional previous)
8856 "Go to the same level (or less) next thread.
8857 If PREVIOUS is non-nil, go to previous thread instead.
8858 Return the article number moved to, or nil if moving was impossible."
8859 (let ((level (gnus-summary-thread-level))
8860 (way (if previous -1 1))
8863 (while (and (not (eobp))
8864 (< level (gnus-summary-thread-level)))
8872 (gnus-summary-article-number)
8875 (defun gnus-summary-next-thread (n &optional silent)
8876 "Go to the same level next N'th thread.
8877 If N is negative, search backward instead.
8878 Returns the difference between N and the number of skips actually
8881 If SILENT, don't output messages."
8883 (let ((backward (< n 0))
8886 (gnus-summary-go-to-next-thread backward))
8889 (gnus-summary-position-point))
8890 (when (and (not silent) (/= 0 n))
8891 (gnus-message 7 "No more threads"))
8894 (defun gnus-summary-prev-thread (n)
8895 "Go to the same level previous N'th thread.
8896 Returns the difference between N and the number of skips actually
8899 (gnus-summary-next-thread (- n)))
8901 (defun gnus-summary-go-down-thread ()
8902 "Go down one level in the current thread."
8903 (let ((children (gnus-summary-article-children)))
8905 (gnus-summary-goto-subject (car children)))))
8907 (defun gnus-summary-go-up-thread ()
8908 "Go up one level in the current thread."
8909 (let ((parent (gnus-summary-article-parent)))
8911 (gnus-summary-goto-subject parent))))
8913 (defun gnus-summary-down-thread (n)
8914 "Go down thread N steps.
8915 If N is negative, go up instead.
8916 Returns the difference between N and how many steps down that were
8922 (if up (gnus-summary-go-up-thread)
8923 (gnus-summary-go-down-thread)))
8925 (gnus-summary-position-point)
8927 (gnus-message 7 "Can't go further"))
8930 (defun gnus-summary-up-thread (n)
8931 "Go up thread N steps.
8932 If N is negative, go up instead.
8933 Returns the difference between N and how many steps down that were
8936 (gnus-summary-down-thread (- n)))
8938 (defun gnus-summary-top-thread ()
8939 "Go to the top of the thread."
8941 (while (gnus-summary-go-up-thread))
8942 (gnus-summary-article-number))
8944 (defun gnus-summary-kill-thread (&optional unmark)
8945 "Mark articles under current thread as read.
8946 If the prefix argument is positive, remove any kinds of marks.
8947 If the prefix argument is negative, tick articles instead."
8950 (setq unmark (prefix-numeric-value unmark)))
8951 (let ((articles (gnus-summary-articles-in-thread)))
8953 ;; Expand the thread.
8954 (gnus-summary-show-thread)
8955 ;; Mark all the articles.
8957 (gnus-summary-goto-subject (car articles))
8958 (cond ((null unmark)
8959 (gnus-summary-mark-article-as-read gnus-killed-mark))
8961 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8963 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8964 (setq articles (cdr articles))))
8965 ;; Hide killed subtrees.
8967 gnus-thread-hide-killed
8968 (gnus-summary-hide-thread))
8969 ;; If marked as read, go to next unread subject.
8971 ;; Go to next unread subject.
8972 (gnus-summary-next-subject 1 t)))
8973 (gnus-set-mode-line 'summary))
8975 ;; Summary sorting commands
8977 (defun gnus-summary-sort-by-number (&optional reverse)
8978 "Sort the summary buffer by article number.
8979 Argument REVERSE means reverse order."
8981 (gnus-summary-sort 'number reverse))
8983 (defun gnus-summary-sort-by-author (&optional reverse)
8984 "Sort the summary buffer by author name alphabetically.
8985 If case-fold-search is non-nil, case of letters is ignored.
8986 Argument REVERSE means reverse order."
8988 (gnus-summary-sort 'author reverse))
8990 (defun gnus-summary-sort-by-subject (&optional reverse)
8991 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8992 If case-fold-search is non-nil, case of letters is ignored.
8993 Argument REVERSE means reverse order."
8995 (gnus-summary-sort 'subject reverse))
8997 (defun gnus-summary-sort-by-date (&optional reverse)
8998 "Sort the summary buffer by date.
8999 Argument REVERSE means reverse order."
9001 (gnus-summary-sort 'date reverse))
9003 (defun gnus-summary-sort-by-score (&optional reverse)
9004 "Sort the summary buffer by score.
9005 Argument REVERSE means reverse order."
9007 (gnus-summary-sort 'score reverse))
9009 (defun gnus-summary-sort-by-lines (&optional reverse)
9010 "Sort the summary buffer by the number of lines.
9011 Argument REVERSE means reverse order."
9013 (gnus-summary-sort 'lines reverse))
9015 (defun gnus-summary-sort-by-chars (&optional reverse)
9016 "Sort the summary buffer by article length.
9017 Argument REVERSE means reverse order."
9019 (gnus-summary-sort 'chars reverse))
9021 (defun gnus-summary-sort (predicate reverse)
9022 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9023 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9024 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9025 (gnus-thread-sort-functions
9030 (gnus-article-sort-functions
9036 (gnus-summary-prepare-hook nil))
9037 ;; We do the sorting by regenerating the threads.
9038 (gnus-summary-prepare)
9039 ;; Hide subthreads if needed.
9040 (when (and gnus-show-threads gnus-thread-hide-subtree)
9041 (gnus-summary-hide-all-threads))))
9043 ;; Summary saving commands.
9045 (defun gnus-summary-save-article (&optional n not-saved)
9046 "Save the current article using the default saver function.
9047 If N is a positive number, save the N next articles.
9048 If N is a negative number, save the N previous articles.
9049 If N is nil and any articles have been marked with the process mark,
9050 save those articles instead.
9051 The variable `gnus-default-article-saver' specifies the saver function."
9053 (let* ((articles (gnus-summary-work-articles n))
9054 (save-buffer (save-excursion
9055 (nnheader-set-temp-buffer " *Gnus Save*")))
9056 (num (length articles))
9058 (dolist (article articles)
9059 (setq header (gnus-summary-article-header article))
9060 (if (not (vectorp header))
9061 ;; This is a pseudo-article.
9062 (if (assq 'name header)
9063 (gnus-copy-file (cdr (assq 'name header)))
9064 (gnus-message 1 "Article %d is unsaveable" article))
9065 ;; This is a real article.
9066 (save-window-excursion
9067 (gnus-summary-select-article t nil nil article))
9069 (set-buffer save-buffer)
9071 (insert-buffer-substring gnus-original-article-buffer))
9072 (setq file (gnus-article-save save-buffer file num))
9073 (gnus-summary-remove-process-mark article)
9075 (gnus-summary-set-saved-mark article))))
9076 (gnus-kill-buffer save-buffer)
9077 (gnus-summary-position-point)
9078 (gnus-set-mode-line 'summary)
9081 (defun gnus-summary-pipe-output (&optional arg)
9082 "Pipe the current article to a subprocess.
9083 If N is a positive number, pipe the N next articles.
9084 If N is a negative number, pipe the N previous articles.
9085 If N is nil and any articles have been marked with the process mark,
9086 pipe those articles instead."
9088 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9089 (gnus-summary-save-article arg t))
9090 (gnus-configure-windows 'pipe))
9092 (defun gnus-summary-save-article-mail (&optional arg)
9093 "Append the current article to an mail file.
9094 If N is a positive number, save the N next articles.
9095 If N is a negative number, save the N previous articles.
9096 If N is nil and any articles have been marked with the process mark,
9097 save those articles instead."
9099 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9100 (gnus-summary-save-article arg)))
9102 (defun gnus-summary-save-article-rmail (&optional arg)
9103 "Append the current article to an rmail file.
9104 If N is a positive number, save the N next articles.
9105 If N is a negative number, save the N previous articles.
9106 If N is nil and any articles have been marked with the process mark,
9107 save those articles instead."
9109 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9110 (gnus-summary-save-article arg)))
9112 (defun gnus-summary-save-article-file (&optional arg)
9113 "Append the current article to a file.
9114 If N is a positive number, save the N next articles.
9115 If N is a negative number, save the N previous articles.
9116 If N is nil and any articles have been marked with the process mark,
9117 save those articles instead."
9119 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9120 (gnus-summary-save-article arg)))
9122 (defun gnus-summary-write-article-file (&optional arg)
9123 "Write the current article to a file, deleting the previous file.
9124 If N is a positive number, save the N next articles.
9125 If N is a negative number, save the N previous articles.
9126 If N is nil and any articles have been marked with the process mark,
9127 save those articles instead."
9129 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9130 (gnus-summary-save-article arg)))
9132 (defun gnus-summary-save-article-body-file (&optional arg)
9133 "Append the current article body to a file.
9134 If N is a positive number, save the N next articles.
9135 If N is a negative number, save the N previous articles.
9136 If N is nil and any articles have been marked with the process mark,
9137 save those articles instead."
9139 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9140 (gnus-summary-save-article arg)))
9142 (defun gnus-summary-pipe-message (program)
9143 "Pipe the current article through PROGRAM."
9144 (interactive "sProgram: ")
9145 (gnus-summary-select-article)
9146 (let ((mail-header-separator ""))
9147 (gnus-eval-in-buffer-window gnus-article-buffer
9150 (let ((start (window-start))
9152 (message-pipe-buffer-body program)
9153 (set-window-start (get-buffer-window (current-buffer)) start))))))
9155 (defun gnus-get-split-value (methods)
9156 "Return a value based on the split METHODS."
9157 (let (split-name method result match)
9160 (set-buffer gnus-original-article-buffer)
9162 (nnheader-narrow-to-headers)
9164 (goto-char (point-min))
9165 (setq method (pop methods))
9166 (setq match (car method))
9169 ;; Regular expression.
9171 (re-search-forward match nil t)))
9172 ((gnus-functionp match)
9176 (setq result (funcall match gnus-newsgroup-name))))
9181 (setq result (eval match)))))
9182 (setq split-name (append (cdr method) split-name))
9183 (cond ((stringp result)
9184 (push (expand-file-name
9185 result gnus-article-save-directory)
9188 (setq split-name (append result split-name)))))))))
9189 (nreverse split-name)))
9191 (defun gnus-valid-move-group-p (group)
9194 (symbol-value group)
9195 (gnus-get-function (gnus-find-method-for-group
9196 (symbol-name group)) 'request-accept-article t)))
9198 (defun gnus-read-move-group-name (prompt default articles prefix)
9199 "Read a group name."
9200 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9201 (minibuffer-confirm-incomplete nil) ; XEmacs
9205 (if (> (length articles) 1)
9206 (format "these %d articles" (length articles))
9211 (gnus-completing-read default prom
9213 'gnus-valid-move-group-p
9215 'gnus-group-history))
9216 ((= 1 (length split-name))
9217 (gnus-completing-read (car split-name) prom
9219 'gnus-valid-move-group-p
9221 'gnus-group-history))
9223 (gnus-completing-read nil prom
9224 (mapcar (lambda (el) (list el))
9225 (nreverse split-name))
9227 'gnus-group-history))))
9228 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9230 (if (or (string= to-newsgroup "")
9231 (string= to-newsgroup prefix))
9232 (setq to-newsgroup default))
9233 (unless to-newsgroup
9234 (error "No group name entered"))
9235 (or (gnus-active to-newsgroup)
9236 (gnus-activate-group to-newsgroup nil nil to-method)
9237 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9239 (or (and (gnus-request-create-group to-newsgroup to-method)
9240 (gnus-activate-group
9241 to-newsgroup nil nil to-method)
9242 (gnus-subscribe-group to-newsgroup))
9243 (error "Couldn't create group %s" to-newsgroup)))
9244 (error "No such group: %s" to-newsgroup)))
9247 (defun gnus-summary-save-parts (type dir n &optional reverse)
9248 "Save parts matching TYPE to DIR.
9249 If REVERSE, save parts that do not match TYPE."
9251 (list (read-string "Save parts of type: " "image/.*")
9252 (read-file-name "Save to directory: " nil nil t)
9253 current-prefix-arg))
9254 (gnus-summary-iterate n
9255 (let ((gnus-display-mime-function nil)
9256 (gnus-inhibit-treatment t))
9257 (gnus-summary-select-article))
9259 (set-buffer gnus-article-buffer)
9260 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9262 (gnus-summary-save-parts-1 type dir handles reverse)
9263 (mm-destroy-parts handles))))))
9265 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9266 (if (stringp (car handle))
9267 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9270 (not (string-match type (mm-handle-media-type handle)))
9271 (string-match type (mm-handle-media-type handle)))
9272 (let ((file (expand-file-name
9273 (file-name-nondirectory
9275 (mail-content-type-get
9276 (mm-handle-disposition handle) 'filename)
9277 (concat gnus-newsgroup-name "." gnus-current-article)))
9279 (unless (file-exists-p file)
9280 (mm-save-part-to-file handle file))))))
9282 ;; Summary extract commands
9284 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9285 (let ((buffer-read-only nil)
9286 (article (gnus-summary-article-number))
9288 (unless (gnus-summary-goto-subject article)
9289 (error "No such article: %d" article))
9290 (gnus-summary-position-point)
9291 ;; If all commands are to be bunched up on one line, we collect
9293 (unless gnus-view-pseudos-separately
9294 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9297 (setq action (cdr (assq 'action (car ps))))
9298 (setq files (list (cdr (assq 'name (car ps)))))
9299 (while (and ps (cdr ps)
9300 (string= (or action "1")
9301 (or (cdr (assq 'action (cadr ps))) "2")))
9302 (push (cdr (assq 'name (cadr ps))) files)
9303 (setcdr ps (cddr ps)))
9305 (when (not (string-match "%s" action))
9308 (when (assq 'execute (car ps))
9309 (setcdr (assq 'execute (car ps))
9310 (funcall (if (string-match "%s" action)
9317 (gnus-quote-arg-for-sh-or-csh f)))
9319 (setq ps (cdr ps)))))
9320 (if (and gnus-view-pseudos (not not-view))
9322 (when (assq 'execute (car pslist))
9323 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9324 (eq gnus-view-pseudos 'not-confirm)))
9325 (setq pslist (cdr pslist)))
9328 (setq after-article (or (cdr (assq 'article (car pslist)))
9329 (gnus-summary-article-number)))
9330 (gnus-summary-goto-subject after-article)
9333 (insert " " (file-name-nondirectory
9334 (cdr (assq 'name (car pslist))))
9335 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9337 (forward-line -1) ; back to `b'
9338 (gnus-add-text-properties
9339 b (1- e) (list 'gnus-number gnus-reffed-article-number
9340 gnus-mouse-face-prop gnus-mouse-face))
9342 after-article gnus-reffed-article-number
9343 gnus-unread-mark b (car pslist) 0 (- e b))
9344 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9345 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9346 (setq pslist (cdr pslist)))))))
9348 (defun gnus-pseudos< (p1 p2)
9349 (let ((c1 (cdr (assq 'action p1)))
9350 (c2 (cdr (assq 'action p2))))
9351 (and c1 c2 (string< c1 c2))))
9353 (defun gnus-request-pseudo-article (props)
9354 (cond ((assq 'execute props)
9355 (gnus-execute-command (cdr (assq 'execute props)))))
9356 (let ((gnus-current-article (gnus-summary-article-number)))
9357 (gnus-run-hooks 'gnus-mark-article-hook)))
9359 (defun gnus-execute-command (command &optional automatic)
9361 (gnus-article-setup-buffer)
9362 (set-buffer gnus-article-buffer)
9363 (setq buffer-read-only nil)
9364 (let ((command (if automatic command
9365 (read-string "Command: " (cons command 0)))))
9367 (insert "$ " command "\n\n")
9368 (if gnus-view-pseudo-asynchronously
9369 (start-process "gnus-execute" (current-buffer) shell-file-name
9370 shell-command-switch command)
9371 (call-process shell-file-name nil t nil
9372 shell-command-switch command)))))
9374 ;; Summary kill commands.
9376 (defun gnus-summary-edit-global-kill (article)
9377 "Edit the \"global\" kill file."
9378 (interactive (list (gnus-summary-article-number)))
9379 (gnus-group-edit-global-kill article))
9381 (defun gnus-summary-edit-local-kill ()
9382 "Edit a local kill file applied to the current newsgroup."
9384 (setq gnus-current-headers (gnus-summary-article-header))
9385 (gnus-group-edit-local-kill
9386 (gnus-summary-article-number) gnus-newsgroup-name))
9390 (defun gnus-read-header (id &optional header)
9391 "Read the headers of article ID and enter them into the Gnus system."
9392 (let ((group gnus-newsgroup-name)
9393 (gnus-override-method
9395 gnus-override-method
9396 (and (gnus-news-group-p gnus-newsgroup-name)
9397 (car (gnus-refer-article-methods)))))
9399 ;; First we check to see whether the header in question is already
9402 ;; This is a Message-ID.
9403 (setq header (or header (gnus-id-to-header id)))
9404 ;; This is an article number.
9405 (setq header (or header (gnus-summary-article-header id))))
9407 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9408 ;; We have found the header.
9410 ;; If this is a sparse article, we have to nix out its
9411 ;; previous entry in the thread hashtb.
9413 (gnus-summary-article-sparse-p (mail-header-number header)))
9414 (let* ((parent (gnus-parent-id (mail-header-references header)))
9415 (thread (and parent (gnus-id-to-thread parent))))
9417 (delq (assq header thread) thread))))
9418 ;; We have to really fetch the header to this article.
9420 (set-buffer nntp-server-buffer)
9421 (when (setq where (gnus-request-head id group))
9422 (nnheader-fold-continuation-lines)
9423 (goto-char (point-max))
9425 (goto-char (point-min))
9429 ((cdr where) (cdr where))
9430 (header (mail-header-number header))
9431 (t gnus-reffed-article-number))
9433 (insert " Article retrieved.\n"))
9435 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9436 () ; Malformed head.
9437 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9438 (when (and (stringp id)
9439 (not (string= (gnus-group-real-name group)
9441 ;; If we fetched by Message-ID and the article came
9442 ;; from a different group, we fudge some bogus article
9443 ;; numbers for this article.
9444 (mail-header-set-number header gnus-reffed-article-number))
9446 (set-buffer gnus-summary-buffer)
9447 (decf gnus-reffed-article-number)
9448 (gnus-remove-header (mail-header-number header))
9449 (push header gnus-newsgroup-headers)
9450 (setq gnus-current-headers header)
9451 (push (mail-header-number header) gnus-newsgroup-limit)))
9454 (defun gnus-remove-header (number)
9455 "Remove header NUMBER from `gnus-newsgroup-headers'."
9456 (if (and gnus-newsgroup-headers
9457 (= number (mail-header-number (car gnus-newsgroup-headers))))
9458 (pop gnus-newsgroup-headers)
9459 (let ((headers gnus-newsgroup-headers))
9460 (while (and (cdr headers)
9461 (not (= number (mail-header-number (cadr headers)))))
9464 (setcdr headers (cddr headers))))))
9467 ;;; summary highlights
9470 (defun gnus-highlight-selected-summary ()
9471 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9472 ;; Highlight selected article in summary buffer
9473 (when gnus-summary-selected-face
9475 (let* ((beg (progn (beginning-of-line) (point)))
9476 (end (progn (end-of-line) (point)))
9477 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9478 (from (if (get-text-property beg gnus-mouse-face-prop)
9480 (or (next-single-property-change
9481 beg gnus-mouse-face-prop nil end)
9486 (or (next-single-property-change
9487 from gnus-mouse-face-prop nil end)
9489 ;; If no mouse-face prop on line we will have to = from = end,
9490 ;; so we highlight the entire line instead.
9491 (when (= (+ to 2) from)
9494 (if gnus-newsgroup-selected-overlay
9495 ;; Move old overlay.
9497 gnus-newsgroup-selected-overlay from to (current-buffer))
9498 ;; Create new overlay.
9500 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9501 'face gnus-summary-selected-face))))))
9503 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9504 (defun gnus-summary-highlight-line ()
9505 "Highlight current line according to `gnus-summary-highlight'."
9506 (let* ((list gnus-summary-highlight)
9508 (end (progn (end-of-line) (point)))
9509 ;; now find out where the line starts and leave point there.
9510 (beg (progn (beginning-of-line) (point)))
9511 (article (gnus-summary-article-number))
9512 (score (or (cdr (assq (or article gnus-current-article)
9513 gnus-newsgroup-scored))
9514 gnus-summary-default-score 0))
9515 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9516 (inhibit-read-only t))
9517 ;; Eval the cars of the lists until we find a match.
9518 (let ((default gnus-summary-default-score))
9520 (not (eval (caar list))))
9521 (setq list (cdr list))))
9522 (let ((face (cdar list)))
9523 (unless (eq face (get-text-property beg 'face))
9524 (gnus-put-text-property-excluding-characters-with-faces
9526 (setq face (if (boundp face) (symbol-value face) face)))
9527 (when gnus-summary-highlight-line-function
9528 (funcall gnus-summary-highlight-line-function article face))))
9531 (defun gnus-update-read-articles (group unread &optional compute)
9532 "Update the list of read articles in GROUP."
9533 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9534 (entry (gnus-gethash group gnus-newsrc-hashtb))
9535 (info (nth 2 entry))
9537 (unread (sort (copy-sequence unread) '<))
9539 (if (or (not info) (not active))
9540 ;; There is no info on this group if it was, in fact,
9541 ;; killed. Gnus stores no information on killed groups, so
9542 ;; there's nothing to be done.
9543 ;; One could store the information somewhere temporarily,
9544 ;; perhaps... Hmmm...
9546 ;; Remove any negative articles numbers.
9547 (while (and unread (< (car unread) 0))
9548 (setq unread (cdr unread)))
9549 ;; Remove any expired article numbers
9550 (while (and unread (< (car unread) (car active)))
9551 (setq unread (cdr unread)))
9552 ;; Compute the ranges of read articles by looking at the list of
9555 (when (/= (car unread) prev)
9556 (push (if (= prev (1- (car unread))) prev
9557 (cons prev (1- (car unread))))
9559 (setq prev (1+ (car unread)))
9560 (setq unread (cdr unread)))
9561 (when (<= prev (cdr active))
9562 (push (cons prev (cdr active)) read))
9563 (setq read (if (> (length read) 1) (nreverse read) read))
9567 (set-buffer gnus-group-buffer)
9570 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9571 (gnus-info-set-read ',info ',(gnus-info-read info))
9572 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9573 (gnus-group-update-group ,group t))))
9574 ;; Propagate the read marks to the backend.
9575 (if (gnus-check-backend-function 'request-set-mark group)
9576 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9577 (add (gnus-remove-from-range read (gnus-info-read info))))
9579 (unless (gnus-check-group group)
9580 (error "Can't open server for %s" group))
9581 (gnus-request-set-mark
9582 group (delq nil (list (if add (list add 'add '(read)))
9583 (if del (list del 'del '(read)))))))))
9584 ;; Enter this list into the group info.
9585 (gnus-info-set-read info read)
9586 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9587 (gnus-get-unread-articles-in-group info (gnus-active group))
9590 (defun gnus-offer-save-summaries ()
9591 "Offer to save all active summary buffers."
9593 (let ((buflist (buffer-list))
9595 ;; Go through all buffers and find all summaries.
9597 (and (setq bufname (buffer-name (car buflist)))
9598 (string-match "Summary" bufname)
9600 (set-buffer bufname)
9601 ;; We check that this is, indeed, a summary buffer.
9602 (and (eq major-mode 'gnus-summary-mode)
9603 ;; Also make sure this isn't bogus.
9604 gnus-newsgroup-prepared
9605 ;; Also make sure that this isn't a dead summary buffer.
9606 (not gnus-dead-summary-mode)))
9607 (push bufname buffers))
9608 (setq buflist (cdr buflist)))
9609 ;; Go through all these summary buffers and offer to save them.
9612 "Update summary buffer %s? "
9614 (switch-to-buffer buf)
9615 (gnus-summary-exit))
9619 ;;; @ for mime-partial
9622 (defun gnus-request-partial-message ()
9624 (let ((number (gnus-summary-article-number))
9625 (group gnus-newsgroup-name)
9626 (mother gnus-article-buffer))
9627 (set-buffer (get-buffer-create " *Partial Article*"))
9629 (setq mime-preview-buffer mother)
9630 (gnus-request-article-this-buffer number group)
9634 (autoload 'mime-combine-message/partial-pieces-automatically
9636 "Internal method to combine message/partial messages automatically.")
9639 'action '((type . message)(subtype . partial)
9640 (major-mode . gnus-original-article-mode)
9641 (method . mime-combine-message/partial-pieces-automatically)
9642 (summary-buffer-exp . gnus-summary-buffer)
9643 (request-partial-message-method . gnus-request-partial-message)
9647 ;;; @ for message/rfc822
9650 (defun gnus-mime-extract-message/rfc822 (entity situation)
9651 (let (group article num cwin swin cur)
9652 (with-current-buffer (mime-entity-buffer entity)
9654 (narrow-to-region (mime-entity-body-start entity)
9655 (mime-entity-body-end entity))
9656 (setq group (or (cdr (assq 'group situation))
9657 (completing-read "Group: "
9660 (gnus-read-active-file-p)
9661 gnus-newsgroup-name))
9662 article (gnus-request-accept-article group)
9665 (when (and (consp article)
9666 (numberp (setq article (cdr article))))
9667 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9668 cwin (get-buffer-window (current-buffer) t)
9670 (save-window-excursion
9671 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9672 (select-window swin)
9673 (set-buffer gnus-summary-buffer)
9675 (setq cur gnus-current-article)
9677 (let (gnus-show-threads)
9678 (gnus-summary-goto-subject article t)
9680 (gnus-summary-clear-mark-forward 1)
9681 (gnus-summary-goto-subject cur)
9683 (when (and cwin (window-frame cwin))
9684 (select-frame (window-frame cwin))
9686 (when (boundp 'mime-acting-situation-to-override)
9687 (set-alist 'mime-acting-situation-to-override
9690 (set-alist 'mime-acting-situation-to-override
9693 (save-current-buffer
9694 (set-buffer gnus-group-buffer)
9695 (gnus-activate-group ,group)
9697 (gnus-summary-goto-article ,cur
9698 gnus-show-all-headers)
9700 (set-alist 'mime-acting-situation-to-override
9706 'action '((type . message)(subtype . rfc822)
9707 (major-mode . gnus-original-article-mode)
9708 (method . gnus-mime-extract-message/rfc822)
9713 'action '((type . message)(subtype . news)
9714 (major-mode . gnus-original-article-mode)
9715 (method . gnus-mime-extract-message/rfc822)
9719 (defun gnus-mime-extract-multipart (entity situation)
9720 (let ((children (mime-entity-children entity))
9721 mime-acting-situation-to-override
9724 (mime-play-entity (car children)
9725 (cons (assq 'mode situation)
9726 mime-acting-situation-to-override))
9727 (setq children (cdr children)))
9728 (if (setq f (cdr (assq 'after-method
9729 mime-acting-situation-to-override)))
9734 'action '((type . multipart)
9735 (method . gnus-mime-extract-multipart)
9744 (defun gnus-summary-setup-default-charset ()
9745 "Setup newsgroup default charset."
9746 (if (equal gnus-newsgroup-name "nndraft:drafts")
9747 (setq gnus-newsgroup-charset nil)
9748 (let* ((name (and gnus-newsgroup-name
9749 (gnus-group-real-name gnus-newsgroup-name)))
9751 (or gnus-newsgroup-ephemeral-ignored-charsets
9753 (and gnus-newsgroup-name
9754 (or (gnus-group-find-parameter gnus-newsgroup-name
9755 'ignored-charsets t)
9756 (let ((alist gnus-group-ignored-charsets-alist)
9757 elem (charsets nil))
9758 (while (setq elem (pop alist))
9760 (string-match (car elem) name))
9762 charsets (cdr elem))))
9764 gnus-newsgroup-ignored-charsets))))
9765 (setq gnus-newsgroup-charset
9766 (or gnus-newsgroup-ephemeral-charset
9767 (and gnus-newsgroup-name
9768 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9769 (let ((alist gnus-group-charset-alist)
9771 (while (setq elem (pop alist))
9773 (string-match (car elem) name))
9775 charset (cadr elem))))
9777 gnus-default-charset))
9778 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9779 ignored-charsets))))
9785 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9786 "Display the current article buffer fully MIME-buttonized.
9787 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9788 treated as multipart/mixed."
9791 (let ((gnus-unbuttonized-mime-types nil)
9792 (gnus-mime-display-multipart-as-mixed show-all-parts))
9793 (gnus-summary-show-article)))
9795 (defun gnus-summary-repair-multipart (article)
9796 "Add a Content-Type header to a multipart article without one."
9797 (interactive (list (gnus-summary-article-number)))
9798 (gnus-with-article article
9799 (message-narrow-to-head)
9800 (goto-char (point-max))
9802 (when (search-forward "\n--" nil t)
9803 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9804 (message-narrow-to-head)
9805 (message-remove-header "Mime-Version")
9806 (message-remove-header "Content-Type")
9807 (goto-char (point-max))
9808 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9810 (insert "Mime-Version: 1.0\n")
9812 (let (gnus-mark-article-hook)
9813 (gnus-summary-select-article t t nil article)))
9815 (defun gnus-summary-toggle-display-buttonized ()
9816 "Toggle the buttonizing of the article buffer."
9819 (if (setq gnus-inhibit-mime-unbuttonizing
9820 (not gnus-inhibit-mime-unbuttonizing))
9821 (let ((gnus-unbuttonized-mime-types nil))
9822 (gnus-summary-show-article))
9823 (gnus-summary-show-article)))
9826 ;;; Intelli-mouse commmands
9829 (defun gnus-wheel-summary-scroll (event)
9831 (let ((amount (if (memq 'shift (event-modifiers event))
9832 (car gnus-wheel-scroll-amount)
9833 (cdr gnus-wheel-scroll-amount)))
9834 (direction (- (* (static-if (featurep 'xemacs)
9835 (event-button event)
9836 (cond ((eq 'mouse-4 (event-basic-type event))
9838 ((eq 'mouse-5 (event-basic-type event))
9842 (gnus-summary-scroll-up (* amount direction))
9843 (when (gnus-eval-in-buffer-window gnus-article-buffer
9846 (and (if (< 0 direction)
9847 (gnus-article-next-page 0)
9848 (gnus-article-prev-page 0)
9850 (if (setq edge (get-text-property
9851 (point-min) 'gnus-wheel-edge))
9852 (setq edge (* edge direction))
9855 (let ((buffer-read-only nil)
9856 (inhibit-read-only t))
9857 (put-text-property (point-min) (point-max)
9858 'gnus-wheel-edge direction)
9860 (or (> edge gnus-wheel-edge-resistance)
9861 (let ((buffer-read-only nil)
9862 (inhibit-read-only t))
9863 (put-text-property (point-min) (point-max)
9865 (* (1+ edge) direction))
9867 (eq last-command 'gnus-wheel-summary-scroll))))
9868 (gnus-summary-next-article nil nil (minusp direction)))))
9870 (defun gnus-wheel-install ()
9871 "Enable mouse wheel support on summary window."
9872 (when gnus-use-wheel
9874 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
9876 (define-key gnus-summary-mode-map key
9877 'gnus-wheel-summary-scroll)))))
9879 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
9882 ;;; Traditional PGP commmands
9885 (defun gnus-summary-decrypt-article (&optional force)
9886 "Decrypt the current article in traditional PGP way.
9887 This will have permanent effect only in mail groups.
9888 If FORCE is non-nil, allow editing of articles even in read-only
9891 (gnus-summary-select-article t)
9892 (gnus-eval-in-buffer-window gnus-article-buffer
9896 (goto-char (point-min))
9897 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
9898 (error "Not a traditional PGP message!"))
9899 (let ((armor-start (match-beginning 0)))
9900 (if (and (pgg-decrypt-region armor-start (point-max))
9901 (or force (not (gnus-group-read-only-p))))
9902 (let ((inhibit-read-only t)
9904 (delete-region armor-start
9906 (re-search-forward "^-+END PGP" nil t)
9907 (beginning-of-line 2)
9909 (insert-buffer-substring pgg-output-buffer))))))))
9911 (defun gnus-summary-verify-article ()
9912 "Verify the current article in traditional PGP way."
9915 (set-buffer gnus-original-article-buffer)
9916 (goto-char (point-min))
9917 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
9918 (error "Not a traditional PGP message!"))
9919 (re-search-forward "^-+END PGP" nil t)
9920 (beginning-of-line 2)
9921 (call-interactively (function pgg-verify-region))))
9927 (defmacro gnus-with-article (article &rest forms)
9928 "Select ARTICLE and perform FORMS in the original article buffer.
9929 Then replace the article with the result."
9931 ;; We don't want the article to be marked as read.
9932 (let (gnus-mark-article-hook)
9933 (gnus-summary-select-article t t nil ,article))
9934 (set-buffer gnus-original-article-buffer)
9936 (if (not (gnus-check-backend-function
9937 'request-replace-article (car gnus-article-current)))
9938 (gnus-message 5 "Read-only group; not replacing")
9939 (unless (gnus-request-replace-article
9940 ,article (car gnus-article-current)
9942 (error "Couldn't replace article")))
9943 ;; The cache and backlog have to be flushed somewhat.
9944 (when gnus-keep-backlog
9945 (gnus-backlog-remove-article
9946 (car gnus-article-current) (cdr gnus-article-current)))
9947 (when gnus-use-cache
9948 (gnus-cache-update-article
9949 (car gnus-article-current) (cdr gnus-article-current)))))
9951 (put 'gnus-with-article 'lisp-indent-function 1)
9952 (put 'gnus-with-article 'edebug-form-spec '(form body))
9955 ;;; Generic summary marking commands
9958 (defvar gnus-summary-marking-alist
9959 '((read gnus-del-mark "d")
9960 (unread gnus-unread-mark "u")
9961 (ticked gnus-ticked-mark "!")
9962 (dormant gnus-dormant-mark "?")
9963 (expirable gnus-expirable-mark "e"))
9964 "An alist of names/marks/keystrokes.")
9966 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9967 (defvar gnus-summary-mark-map)
9969 (defun gnus-summary-make-all-marking-commands ()
9970 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9971 (dolist (elem gnus-summary-marking-alist)
9972 (apply 'gnus-summary-make-marking-command elem)))
9974 (defun gnus-summary-make-marking-command (name mark keystroke)
9975 (let ((map (make-sparse-keymap)))
9976 (define-key gnus-summary-generic-mark-map keystroke map)
9977 (dolist (lway `((next "next" next nil "n")
9978 (next-unread "next unread" next t "N")
9979 (prev "previous" prev nil "p")
9980 (prev-unread "previous unread" prev t "P")
9981 (nomove "" nil nil ,keystroke)))
9982 (let ((func (gnus-summary-make-marking-command-1
9983 mark (car lway) lway name)))
9984 (setq func (eval func))
9985 (define-key map (nth 4 lway) func)))))
9987 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9989 (format "gnus-summary-put-mark-as-%s%s"
9990 name (if (eq way 'nomove)
9992 (concat "-" (symbol-name way)))))
9995 "Mark the current article as %s%s.
9996 If N, the prefix, then repeat N times.
9997 If N is negative, move in reverse order.
9998 The difference between N and the actual number of articles marked is
10000 name (car (cdr lway)))
10002 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10004 (defun gnus-summary-generic-mark (n mark move unread)
10005 "Mark N articles with MARK."
10006 (unless (eq major-mode 'gnus-summary-mode)
10007 (error "This command can only be used in the summary buffer"))
10008 (gnus-summary-show-thread)
10011 ((eq move 'next) 1)
10012 ((eq move 'prev) -1)
10014 (if (zerop nummove)
10018 nummove (* -1 nummove))))
10019 (while (and (> n 0)
10020 (gnus-summary-mark-article nil mark)
10021 (zerop (gnus-summary-next-subject nummove unread t)))
10024 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10025 (gnus-summary-recenter)
10026 (gnus-summary-position-point)
10027 (gnus-set-mode-line 'summary)
10030 (gnus-summary-make-all-marking-commands)
10032 (gnus-ems-redefine)
10034 (provide 'gnus-sum)
10036 (run-hooks 'gnus-sum-load-hook)
10038 ;;; gnus-sum.el ends here