1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
46 (autoload 'gnus-cache-articles-in-group "gnus-cache")
47 (autoload 'pgg-decrypt-region "pgg" nil t)
48 (autoload 'pgg-verify-region "pgg" nil t))
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
53 (defcustom gnus-kill-summary-on-exit t
54 "*If non-nil, kill the summary buffer when you exit from it.
55 If nil, the summary will become a \"*Dead Summary*\" buffer, and
56 it will be killed sometime later."
57 :group 'gnus-summary-exit
60 (defcustom gnus-fetch-old-headers nil
61 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
62 If an unread article in the group refers to an older, already read (or
63 just marked as read) article, the old article will not normally be
64 displayed in the Summary buffer. If this variable is non-nil, Gnus
65 will attempt to grab the headers to the old articles, and thereby
66 build complete threads. If it has the value `some', only enough
67 headers to connect otherwise loose threads will be displayed. This
68 variable can also be a number. In that case, no more than that number
69 of old headers will be fetched. If it has the value `invisible', all
70 old headers will be fetched, but none will be displayed.
72 The server has to support NOV for any of this to work."
74 :type '(choice (const :tag "off" nil)
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-refer-thread-limit 200
80 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
81 If t, fetch all the available old headers."
84 (sexp :menu-tag "other" t)))
86 (defcustom gnus-summary-make-false-root 'adopt
87 "*nil means that Gnus won't gather loose threads.
88 If the root of a thread has expired or been read in a previous
89 session, the information necessary to build a complete thread has been
90 lost. Instead of having many small sub-threads from this original thread
91 scattered all over the summary buffer, Gnus can gather them.
93 If non-nil, Gnus will try to gather all loose sub-threads from an
94 original thread into one large thread.
96 If this variable is non-nil, it should be one of `none', `adopt',
99 If this variable is `none', Gnus will not make a false root, but just
100 present the sub-threads after another.
101 If this variable is `dummy', Gnus will create a dummy root that will
102 have all the sub-threads as children.
103 If this variable is `adopt', Gnus will make one of the \"children\"
104 the parent and mark all the step-children as such.
105 If this variable is `empty', the \"children\" are printed with empty
106 subject fields. (Or rather, they will be printed with a string
107 given by the `gnus-summary-same-subject' variable.)"
109 :type '(choice (const :tag "off" nil)
115 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
116 "*A regexp to match subjects to be excluded from loose thread gathering.
117 As loose thread gathering is done on subjects only, that means that
118 there can be many false gatherings performed. By rooting out certain
119 common subjects, gathering might become saner."
123 (defcustom gnus-summary-gather-subject-limit nil
124 "*Maximum length of subject comparisons when gathering loose threads.
125 Use nil to compare full subjects. Setting this variable to a low
126 number will help gather threads that have been corrupted by
127 newsreaders chopping off subject lines, but it might also mean that
128 unrelated articles that have subject that happen to begin with the
129 same few characters will be incorrectly gathered.
131 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
134 :type '(choice (const :tag "off" nil)
136 (sexp :menu-tag "on" t)))
138 (defcustom gnus-simplify-subject-functions nil
139 "List of functions taking a string argument that simplify subjects.
140 The functions are applied recursively.
142 Useful functions to put in this list include: `gnus-simplify-subject-re',
143 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
145 :type '(repeat function))
147 (defcustom gnus-simplify-ignored-prefixes nil
148 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
150 :type '(choice (const :tag "off" nil)
153 (defcustom gnus-build-sparse-threads nil
154 "*If non-nil, fill in the gaps in threads.
155 If `some', only fill in the gaps that are needed to tie loose threads
156 together. If `more', fill in all leaf nodes that Gnus can find. If
157 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
159 :type '(choice (const :tag "off" nil)
162 (sexp :menu-tag "all" t)))
164 (defcustom gnus-summary-thread-gathering-function
165 'gnus-gather-threads-by-subject
166 "*Function used for gathering loose threads.
167 There are two pre-defined functions: `gnus-gather-threads-by-subject',
168 which only takes Subjects into consideration; and
169 `gnus-gather-threads-by-references', which compared the References
170 headers of the articles to find matches."
172 :type '(radio (function-item gnus-gather-threads-by-subject)
173 (function-item gnus-gather-threads-by-references)
174 (function :tag "other")))
176 (defcustom gnus-summary-same-subject ""
177 "*String indicating that the current article has the same subject as the previous.
178 This variable will only be used if the value of
179 `gnus-summary-make-false-root' is `empty'."
180 :group 'gnus-summary-format
183 (defcustom gnus-summary-goto-unread t
184 "*If t, many commands will go to the next unread article.
185 This applies to marking commands as well as other commands that
186 \"naturally\" select the next article, like, for instance, `SPC' at
187 the end of an article.
188 If nil, only the marking commands will go to the next (un)read article.
189 If `never', commands that usually go to the next unread article, will
190 go to the next article, whether it is read or not."
191 :group 'gnus-summary-marks
192 :link '(custom-manual "(gnus)Setting Marks")
193 :type '(choice (const :tag "off" nil)
195 (sexp :menu-tag "on" t)))
197 (defcustom gnus-summary-default-score 0
198 "*Default article score level.
199 All scores generated by the score files will be added to this score.
200 If this variable is nil, scoring will be disabled."
201 :group 'gnus-score-default
202 :type '(choice (const :tag "disable")
205 (defcustom gnus-summary-zcore-fuzz 0
206 "*Fuzziness factor for the zcore in the summary buffer.
207 Articles with scores closer than this to `gnus-summary-default-score'
209 :group 'gnus-summary-format
212 (defcustom gnus-simplify-subject-fuzzy-regexp nil
213 "*Strings to be removed when doing fuzzy matches.
214 This can either be a regular expression or list of regular expressions
215 that will be removed from subject strings if fuzzy subject
216 simplification is selected."
218 :type '(repeat regexp))
220 (defcustom gnus-show-threads t
221 "*If non-nil, display threads in summary mode."
225 (defcustom gnus-thread-hide-subtree nil
226 "*If non-nil, hide all threads initially.
227 If threads are hidden, you have to run the command
228 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
229 to expose hidden threads."
233 (defcustom gnus-thread-hide-killed t
234 "*If non-nil, hide killed threads automatically."
238 (defcustom gnus-thread-ignore-subject t
239 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
240 If nil, articles that have different subjects from their parents will
241 start separate threads."
245 (defcustom gnus-thread-operation-ignore-subject t
246 "*If non-nil, subjects will be ignored when doing thread commands.
247 This affects commands like `gnus-summary-kill-thread' and
248 `gnus-summary-lower-thread'.
250 If this variable is nil, articles in the same thread with different
251 subjects will not be included in the operation in question. If this
252 variable is `fuzzy', only articles that have subjects that are fuzzily
253 equal will be included."
255 :type '(choice (const :tag "off" nil)
259 (defcustom gnus-thread-indent-level 4
260 "*Number that says how much each sub-thread should be indented."
264 (defcustom gnus-auto-extend-newsgroup t
265 "*If non-nil, extend newsgroup forward and backward when requested."
266 :group 'gnus-summary-choose
269 (defcustom gnus-auto-select-first t
270 "*If nil, don't select the first unread article when entering a group.
271 If this variable is `best', select the highest-scored unread article
272 in the group. If t, select the first unread article.
274 This variable can also be a function to place point on a likely
275 subject line. Useful values include `gnus-summary-first-unread-subject',
276 `gnus-summary-first-unread-article' and
277 `gnus-summary-best-unread-article'.
279 If you want to prevent automatic selection of the first unread article
280 in some newsgroups, set the variable to nil in
281 `gnus-select-group-hook'."
282 :group 'gnus-group-select
283 :type '(choice (const :tag "none" nil)
285 (sexp :menu-tag "first" t)
286 (function-item gnus-summary-first-unread-subject)
287 (function-item gnus-summary-first-unread-article)
288 (function-item gnus-summary-best-unread-article)))
290 (defcustom gnus-dont-select-after-jump-to-other-group nil
291 "If non-nil, don't select the first unread article after entering the
292 other group by the command `gnus-summary-jump-to-other-group'. If nil,
293 it is depend on the value of `gnus-auto-select-first' whether to select
295 :group 'gnus-group-select
298 (defcustom gnus-auto-select-next t
299 "*If non-nil, offer to go to the next group from the end of the previous.
300 If the value is t and the next newsgroup is empty, Gnus will exit
301 summary mode and go back to group mode. If the value is neither nil
302 nor t, Gnus will select the following unread newsgroup. In
303 particular, if the value is the symbol `quietly', the next unread
304 newsgroup will be selected without any confirmation, and if it is
305 `almost-quietly', the next group will be selected without any
306 confirmation if you are located on the last article in the group.
307 Finally, if this variable is `slightly-quietly', the `Z n' command
308 will go to the next group without confirmation."
309 :group 'gnus-summary-maneuvering
310 :type '(choice (const :tag "off" nil)
312 (const almost-quietly)
313 (const slightly-quietly)
314 (sexp :menu-tag "on" t)))
316 (defcustom gnus-auto-select-same nil
317 "*If non-nil, select the next article with the same subject.
318 If there are no more articles with the same subject, go to
319 the first unread article."
320 :group 'gnus-summary-maneuvering
323 (defcustom gnus-summary-check-current nil
324 "*If non-nil, consider the current article when moving.
325 The \"unread\" movement commands will stay on the same line if the
326 current article is unread."
327 :group 'gnus-summary-maneuvering
330 (defcustom gnus-auto-center-summary t
331 "*If non-nil, always center the current summary buffer.
332 In particular, if `vertical' do only vertical recentering. If non-nil
333 and non-`vertical', do both horizontal and vertical recentering."
334 :group 'gnus-summary-maneuvering
335 :type '(choice (const :tag "none" nil)
337 (integer :tag "height")
338 (sexp :menu-tag "both" t)))
340 (defcustom gnus-show-all-headers nil
341 "*If non-nil, don't hide any headers."
342 :group 'gnus-article-hiding
343 :group 'gnus-article-headers
346 (defcustom gnus-summary-ignore-duplicates nil
347 "*If non-nil, ignore articles with identical Message-ID headers."
351 (defcustom gnus-single-article-buffer t
352 "*If non-nil, display all articles in the same buffer.
353 If nil, each group will get its own article buffer."
354 :group 'gnus-article-various
357 (defcustom gnus-break-pages t
358 "*If non-nil, do page breaking on articles.
359 The page delimiter is specified by the `gnus-page-delimiter'
361 :group 'gnus-article-various
364 (defcustom gnus-show-mime t
365 "*If non-nil, do mime processing of articles.
366 The articles will simply be fed to the function given by
367 `gnus-article-display-method-for-mime'."
368 :group 'gnus-article-mime
371 (defcustom gnus-move-split-methods nil
372 "*Variable used to suggest where articles are to be moved to.
373 It uses the same syntax as the `gnus-split-methods' variable."
374 :group 'gnus-summary-mail
375 :type '(repeat (choice (list :value (fun) function)
376 (cons :value ("" "") regexp (repeat string))
379 (defcustom gnus-unread-mark ? ;Whitespace
380 "*Mark used for unread articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-ticked-mark ?!
385 "*Mark used for ticked articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-dormant-mark ??
390 "*Mark used for dormant articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-del-mark ?r
395 "*Mark used for del'd articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-read-mark ?R
400 "*Mark used for read articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-expirable-mark ?E
405 "*Mark used for expirable articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-killed-mark ?K
410 "*Mark used for killed articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-souped-mark ?F
415 "*Mark used for killed articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-kill-file-mark ?X
420 "*Mark used for articles killed by kill files."
421 :group 'gnus-summary-marks
424 (defcustom gnus-low-score-mark ?Y
425 "*Mark used for articles with a low score."
426 :group 'gnus-summary-marks
429 (defcustom gnus-catchup-mark ?C
430 "*Mark used for articles that are caught up."
431 :group 'gnus-summary-marks
434 (defcustom gnus-replied-mark ?A
435 "*Mark used for articles that have been replied to."
436 :group 'gnus-summary-marks
439 (defcustom gnus-cached-mark ?*
440 "*Mark used for articles that are in the cache."
441 :group 'gnus-summary-marks
444 (defcustom gnus-saved-mark ?S
445 "*Mark used for articles that have been saved to."
446 :group 'gnus-summary-marks
449 (defcustom gnus-ancient-mark ?O
450 "*Mark used for ancient articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-sparse-mark ?Q
455 "*Mark used for sparsely reffed articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-canceled-mark ?G
460 "*Mark used for canceled articles."
461 :group 'gnus-summary-marks
464 (defcustom gnus-duplicate-mark ?M
465 "*Mark used for duplicate articles."
466 :group 'gnus-summary-marks
469 (defcustom gnus-undownloaded-mark ?@
470 "*Mark used for articles that weren't downloaded."
471 :group 'gnus-summary-marks
474 (defcustom gnus-downloadable-mark ?%
475 "*Mark used for articles that are to be downloaded."
476 :group 'gnus-summary-marks
479 (defcustom gnus-unsendable-mark ?=
480 "*Mark used for articles that won't be sent."
481 :group 'gnus-summary-marks
484 (defcustom gnus-score-over-mark ?+
485 "*Score mark used for articles with high scores."
486 :group 'gnus-summary-marks
489 (defcustom gnus-score-below-mark ?-
490 "*Score mark used for articles with low scores."
491 :group 'gnus-summary-marks
494 (defcustom gnus-empty-thread-mark ? ;Whitespace
495 "*There is no thread under the article."
496 :group 'gnus-summary-marks
499 (defcustom gnus-not-empty-thread-mark ?=
500 "*There is a thread under the article."
501 :group 'gnus-summary-marks
504 (defcustom gnus-view-pseudo-asynchronously nil
505 "*If non-nil, Gnus will view pseudo-articles asynchronously."
506 :group 'gnus-extract-view
509 (defcustom gnus-auto-expirable-marks
510 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
511 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
512 gnus-souped-mark gnus-duplicate-mark)
513 "*The list of marks converted into expiration if a group is auto-expirable."
515 :type '(repeat character))
517 (defcustom gnus-inhibit-user-auto-expire t
518 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
522 (defcustom gnus-view-pseudos nil
523 "*If `automatic', pseudo-articles will be viewed automatically.
524 If `not-confirm', pseudos will be viewed automatically, and the user
525 will not be asked to confirm the command."
526 :group 'gnus-extract-view
527 :type '(choice (const :tag "off" nil)
529 (const not-confirm)))
531 (defcustom gnus-view-pseudos-separately t
532 "*If non-nil, one pseudo-article will be created for each file to be viewed.
533 If nil, all files that use the same viewing command will be given as a
534 list of parameters to that command."
535 :group 'gnus-extract-view
538 (defcustom gnus-insert-pseudo-articles t
539 "*If non-nil, insert pseudo-articles when decoding articles."
540 :group 'gnus-extract-view
543 (defcustom gnus-summary-dummy-line-format
545 "*The format specification for the dummy roots in the summary buffer.
546 It works along the same lines as a normal formatting string,
547 with some simple extensions.
550 :group 'gnus-threading
553 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
554 "*The format specification for the summary mode line.
555 It works along the same lines as a normal formatting string,
556 with some simple extensions:
559 %p Unprefixed group name
560 %A Current article number
561 %z Current article score
563 %U Number of unread articles in the group
564 %e Number of unselected articles in the group
565 %Z A string with unread/unselected article counts
566 %g Shortish group name
567 %S Subject of the current article
569 %s Current score file name
570 %d Number of dormant articles
571 %r Number of articles that have been marked as read in this session
572 %E Number of articles expunged by the score files"
573 :group 'gnus-summary-format
576 (defcustom gnus-list-identifiers nil
577 "Regexp that matches list identifiers to be removed from subject.
578 This can also be a list of regexps."
579 :group 'gnus-summary-format
580 :group 'gnus-article-hiding
581 :type '(choice (const :tag "none" nil)
583 (repeat :value (".*") regexp)))
585 (defcustom gnus-summary-mark-below 0
586 "*Mark all articles with a score below this variable as read.
587 This variable is local to each summary buffer and usually set by the
589 :group 'gnus-score-default
592 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
593 "*List of functions used for sorting articles in the summary buffer.
594 This variable is only used when not using a threaded display."
595 :group 'gnus-summary-sort
596 :type '(repeat (choice (function-item gnus-article-sort-by-number)
597 (function-item gnus-article-sort-by-author)
598 (function-item gnus-article-sort-by-subject)
599 (function-item gnus-article-sort-by-date)
600 (function-item gnus-article-sort-by-score)
601 (function :tag "other"))))
603 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
604 "*List of functions used for sorting threads in the summary buffer.
605 By default, threads are sorted by article number.
607 Each function takes two threads and return non-nil if the first thread
608 should be sorted before the other. If you use more than one function,
609 the primary sort function should be the last. You should probably
610 always include `gnus-thread-sort-by-number' in the list of sorting
611 functions -- preferably first.
613 Ready-made functions include `gnus-thread-sort-by-number',
614 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
615 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
616 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
617 :group 'gnus-summary-sort
618 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
619 (function-item gnus-thread-sort-by-author)
620 (function-item gnus-thread-sort-by-subject)
621 (function-item gnus-thread-sort-by-date)
622 (function-item gnus-thread-sort-by-score)
623 (function-item gnus-thread-sort-by-total-score)
624 (function :tag "other"))))
626 (defcustom gnus-thread-score-function '+
627 "*Function used for calculating the total score of a thread.
629 The function is called with the scores of the article and each
630 subthread and should then return the score of the thread.
632 Some functions you can use are `+', `max', or `min'."
633 :group 'gnus-summary-sort
636 (defcustom gnus-summary-expunge-below nil
637 "All articles that have a score less than this variable will be expunged.
638 This variable is local to the summary buffers."
639 :group 'gnus-score-default
640 :type '(choice (const :tag "off" nil)
643 (defcustom gnus-thread-expunge-below nil
644 "All threads that have a total score less than this variable will be expunged.
645 See `gnus-thread-score-function' for en explanation of what a
648 This variable is local to the summary buffers."
649 :group 'gnus-threading
650 :group 'gnus-score-default
651 :type '(choice (const :tag "off" nil)
654 (defcustom gnus-summary-mode-hook nil
655 "*A hook for Gnus summary mode.
656 This hook is run before any variables are set in the summary buffer."
657 :group 'gnus-summary-various
660 (defcustom gnus-summary-menu-hook nil
661 "*Hook run after the creation of the summary mode menu."
662 :group 'gnus-summary-visual
665 (defcustom gnus-summary-exit-hook nil
666 "*A hook called on exit from the summary buffer.
667 It will be called with point in the group buffer."
668 :group 'gnus-summary-exit
671 (defcustom gnus-summary-prepare-hook nil
672 "*A hook called after the summary buffer has been generated.
673 If you want to modify the summary buffer, you can use this hook."
674 :group 'gnus-summary-various
677 (defcustom gnus-summary-prepared-hook nil
678 "*A hook called as the last thing after the summary buffer has been generated."
679 :group 'gnus-summary-various
682 (defcustom gnus-summary-generate-hook nil
683 "*A hook run just before generating the summary buffer.
684 This hook is commonly used to customize threading variables and the
686 :group 'gnus-summary-various
689 (defcustom gnus-select-group-hook nil
690 "*A hook called when a newsgroup is selected.
692 If you'd like to simplify subjects like the
693 `gnus-summary-next-same-subject' command does, you can use the
696 (setq gnus-select-group-hook
699 (mapcar (lambda (header)
700 (mail-header-set-subject
702 (gnus-simplify-subject
703 (mail-header-subject header) 're-only)))
704 gnus-newsgroup-headers))))"
705 :group 'gnus-group-select
708 (defcustom gnus-select-article-hook nil
709 "*A hook called when an article is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-visual-mark-article-hook
714 (list 'gnus-highlight-selected-summary)
715 "*Hook run after selecting an article in the summary buffer.
716 It is meant to be used for highlighting the article in some way. It
717 is not run if `gnus-visual' is nil."
718 :group 'gnus-summary-visual
721 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
722 "*A hook called before parsing the headers."
726 (defcustom gnus-exit-group-hook nil
727 "*A hook called when exiting summary mode.
728 This hook is not called from the non-updating exit commands like `Q'."
732 (defcustom gnus-summary-update-hook
733 (list 'gnus-summary-highlight-line)
734 "*A hook called when a summary line is changed.
735 The hook will not be called if `gnus-visual' is nil.
737 The default function `gnus-summary-highlight-line' will
738 highlight the line according to the `gnus-summary-highlight'
740 :group 'gnus-summary-visual
743 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
744 "*A hook called when an article is selected for the first time.
745 The hook is intended to mark an article as read (or unread)
746 automatically when it is selected."
747 :group 'gnus-summary-choose
750 (defcustom gnus-group-no-more-groups-hook nil
751 "*A hook run when returning to group mode having no more (unread) groups."
752 :group 'gnus-group-select
755 (defcustom gnus-ps-print-hook nil
756 "*A hook run before ps-printing something from Gnus."
760 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
761 "Face used for highlighting the current article in the summary buffer."
762 :group 'gnus-summary-visual
765 (defcustom gnus-summary-highlight
766 '(((= mark gnus-canceled-mark)
767 . gnus-summary-cancelled-face)
768 ((and (> score default)
769 (or (= mark gnus-dormant-mark)
770 (= mark gnus-ticked-mark)))
771 . gnus-summary-high-ticked-face)
772 ((and (< score default)
773 (or (= mark gnus-dormant-mark)
774 (= mark gnus-ticked-mark)))
775 . gnus-summary-low-ticked-face)
776 ((or (= mark gnus-dormant-mark)
777 (= mark gnus-ticked-mark))
778 . gnus-summary-normal-ticked-face)
779 ((and (> score default) (= mark gnus-ancient-mark))
780 . gnus-summary-high-ancient-face)
781 ((and (< score default) (= mark gnus-ancient-mark))
782 . gnus-summary-low-ancient-face)
783 ((= mark gnus-ancient-mark)
784 . gnus-summary-normal-ancient-face)
785 ((and (> score default) (= mark gnus-unread-mark))
786 . gnus-summary-high-unread-face)
787 ((and (< score default) (= mark gnus-unread-mark))
788 . gnus-summary-low-unread-face)
789 ((and (memq article gnus-newsgroup-incorporated)
790 (= mark gnus-unread-mark))
791 . gnus-summary-incorporated-face)
792 ((= mark gnus-unread-mark)
793 . gnus-summary-normal-unread-face)
794 ((and (> score default) (memq mark (list gnus-downloadable-mark
795 gnus-undownloaded-mark)))
796 . gnus-summary-high-unread-face)
797 ((and (< score default) (memq mark (list gnus-downloadable-mark
798 gnus-undownloaded-mark)))
799 . gnus-summary-low-unread-face)
800 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
801 . gnus-summary-normal-unread-face)
803 . gnus-summary-high-read-face)
805 . gnus-summary-low-read-face)
807 . gnus-summary-normal-read-face))
808 "*Controls the highlighting of summary buffer lines.
810 A list of (FORM . FACE) pairs. When deciding how a a particular
811 summary line should be displayed, each form is evaluated. The content
812 of the face field after the first true form is used. You can change
813 how those summary lines are displayed, by editing the face field.
815 You can use the following variables in the FORM field.
817 score: The articles score
818 default: The default article score.
819 below: The score below which articles are automatically marked as read.
820 mark: The articles mark."
821 :group 'gnus-summary-visual
822 :type '(repeat (cons (sexp :tag "Form" nil)
825 (defcustom gnus-alter-header-function nil
826 "Function called to allow alteration of article header structures.
827 The function is called with one parameter, the article header vector,
828 which it may alter in any way.")
830 (defvar gnus-decode-encoded-word-function
831 (mime-find-field-decoder 'From 'nov)
832 "Variable that says which function should be used to decode a string with encoded words.")
834 (defcustom gnus-extra-headers nil
835 "*Extra headers to parse."
837 :type '(repeat symbol))
839 (defcustom gnus-ignored-from-addresses
840 (and user-mail-address (regexp-quote user-mail-address))
841 "*Regexp of From headers that may be suppressed in favor of To headers."
845 (defcustom gnus-group-charset-alist
846 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
847 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
848 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
849 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
850 ("^relcom\\>" koi8-r)
852 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
853 ("^israel\\>" iso-8859-1)
855 ("^alt.chinese.text.big5\\>" chinese-big5)
856 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
857 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
859 "Alist of regexps (to match group names) and default charsets to be used when reading."
860 :type '(repeat (list (regexp :tag "Group")
861 (symbol :tag "Charset")))
862 :group 'gnus-charset)
864 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
865 "List of charsets that should be ignored.
866 When these charsets are used in the \"charset\" parameter, the
867 default charset will be used instead."
868 :type '(repeat symbol)
869 :group 'gnus-charset)
871 (defcustom gnus-group-ignored-charsets-alist
872 '(("alt\\.chinese\\.text" iso-8859-1))
873 "Alist of regexps (to match group names) and charsets that should be ignored.
874 When these charsets are used in the \"charset\" parameter, the
875 default charset will be used instead."
876 :type '(repeat (cons (regexp :tag "Group")
878 :group 'gnus-charset)
880 (defcustom gnus-group-highlight-words-alist nil
881 "Alist of group regexps and highlight regexps.
882 This variable uses the same syntax as `gnus-emphasis-alist'."
883 :type '(repeat (cons (regexp :tag "Group")
884 (repeat (list (regexp :tag "Highlight regexp")
885 (number :tag "Group for entire word" 0)
886 (number :tag "Group for displayed part" 0)
888 gnus-emphasis-highlight-words)))))
889 :group 'gnus-summary-visual)
891 (defcustom gnus-use-wheel nil
892 "Use Intelli-mouse on summary movement"
894 :group 'gnus-summary-maneuvering)
896 (defcustom gnus-wheel-scroll-amount '(5 . 1)
897 "Amount to scroll messages by spinning the mouse wheel.
898 This is actually a cons cell, where the first item is the amount to scroll
899 on a normal wheel event, and the second is the amount to scroll when the
900 wheel is moved with the shift key depressed."
901 :type '(cons (integer :tag "Shift") integer)
902 :group 'gnus-summary-maneuvering)
904 (defcustom gnus-wheel-edge-resistance 2
905 "How hard it should be to change the current article
906 by moving the mouse over the edge of the article window."
908 :group 'gnus-summary-maneuvering)
910 (defcustom gnus-summary-show-article-charset-alist
912 "Alist of number and charset.
913 The article will be shown with the charset corresponding to the
915 For example: ((1 . cn-gb-2312) (2 . big5))."
916 :type '(repeat (cons (number :tag "Argument" 1)
917 (symbol :tag "Charset")))
918 :group 'gnus-charset)
920 (defcustom gnus-preserve-marks t
921 "Whether marks are preserved when moving, copying and respooling messages."
923 :group 'gnus-summary-marks)
925 ;;; Internal variables
927 (defvar gnus-scores-exclude-files nil)
928 (defvar gnus-page-broken nil)
929 (defvar gnus-inhibit-mime-unbuttonizing nil)
931 (defvar gnus-original-article nil)
932 (defvar gnus-article-internal-prepare-hook nil)
933 (defvar gnus-newsgroup-process-stack nil)
935 (defvar gnus-thread-indent-array nil)
936 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
937 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
938 "Function called to sort the articles within a thread after it has been gathered together.")
940 ;; Avoid highlighting in kill files.
941 (defvar gnus-summary-inhibit-highlight nil)
942 (defvar gnus-newsgroup-selected-overlay nil)
943 (defvar gnus-inhibit-limiting nil)
944 (defvar gnus-newsgroup-adaptive-score-file nil)
945 (defvar gnus-current-score-file nil)
946 (defvar gnus-current-move-group nil)
947 (defvar gnus-current-copy-group nil)
948 (defvar gnus-current-crosspost-group nil)
950 (defvar gnus-newsgroup-dependencies nil)
951 (defvar gnus-newsgroup-adaptive nil)
952 (defvar gnus-summary-display-article-function nil)
953 (defvar gnus-summary-highlight-line-function nil
954 "Function called after highlighting a summary line.")
956 (defvar gnus-summary-line-format-alist
957 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
958 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
959 (?s gnus-tmp-subject-or-nil ?s)
960 (?n gnus-tmp-name ?s)
961 (?A (std11-address-string
962 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
963 (?a (or (std11-full-name-string
964 (car (mime-entity-read-field gnus-tmp-header 'From)))
966 (?F gnus-tmp-from ?s)
967 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
968 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
969 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
970 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
971 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
972 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
973 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
974 (?L gnus-tmp-lines ?d)
975 (?I gnus-tmp-indentation ?s)
976 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
977 (?R gnus-tmp-replied ?c)
978 (?\[ gnus-tmp-opening-bracket ?c)
979 (?\] gnus-tmp-closing-bracket ?c)
980 (?\> (make-string gnus-tmp-level ? ) ?s)
981 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
982 (?i gnus-tmp-score ?d)
983 (?z gnus-tmp-score-char ?c)
984 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
985 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
986 (?U gnus-tmp-unread ?c)
987 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
988 (?t (gnus-summary-number-of-articles-in-thread
989 (and (boundp 'thread) (car thread)) gnus-tmp-level)
991 (?e (gnus-summary-number-of-articles-in-thread
992 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
994 (?u gnus-tmp-user-defined ?s)
995 (?P (gnus-pick-line-number) ?d))
996 "An alist of format specifications that can appear in summary lines,
997 and what variables they correspond with, along with the type of the
998 variable (string, integer, character, etc).")
1000 (defvar gnus-summary-dummy-line-format-alist
1001 `((?S gnus-tmp-subject ?s)
1002 (?N gnus-tmp-number ?d)
1003 (?u gnus-tmp-user-defined ?s)))
1005 (defvar gnus-summary-mode-line-format-alist
1006 `((?G gnus-tmp-group-name ?s)
1007 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1008 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1009 (?A gnus-tmp-article-number ?d)
1010 (?Z gnus-tmp-unread-and-unselected ?s)
1011 (?V gnus-version ?s)
1012 (?U gnus-tmp-unread-and-unticked ?d)
1013 (?S gnus-tmp-subject ?s)
1014 (?e gnus-tmp-unselected ?d)
1015 (?u gnus-tmp-user-defined ?s)
1016 (?d (length gnus-newsgroup-dormant) ?d)
1017 (?t (length gnus-newsgroup-marked) ?d)
1018 (?r (length gnus-newsgroup-reads) ?d)
1019 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1020 (?E gnus-newsgroup-expunged-tally ?d)
1021 (?s (gnus-current-score-file-nondirectory) ?s)))
1023 (defvar gnus-last-search-regexp nil
1024 "Default regexp for article search command.")
1026 (defvar gnus-summary-search-article-matched-data nil
1027 "Last matched data of article search command. It is the local variable
1028 in `gnus-article-buffer' which consists of the list of start position,
1029 end position and text.")
1031 (defvar gnus-last-shell-command nil
1032 "Default shell command on article.")
1034 (defvar gnus-newsgroup-begin nil)
1035 (defvar gnus-newsgroup-end nil)
1036 (defvar gnus-newsgroup-last-rmail nil)
1037 (defvar gnus-newsgroup-last-mail nil)
1038 (defvar gnus-newsgroup-last-folder nil)
1039 (defvar gnus-newsgroup-last-file nil)
1040 (defvar gnus-newsgroup-auto-expire nil)
1041 (defvar gnus-newsgroup-active nil)
1043 (defvar gnus-newsgroup-data nil)
1044 (defvar gnus-newsgroup-data-reverse nil)
1045 (defvar gnus-newsgroup-limit nil)
1046 (defvar gnus-newsgroup-limits nil)
1048 (defvar gnus-newsgroup-unreads nil
1049 "List of unread articles in the current newsgroup.")
1051 (defvar gnus-newsgroup-unselected nil
1052 "List of unselected unread articles in the current newsgroup.")
1054 (defvar gnus-newsgroup-reads nil
1055 "Alist of read articles and article marks in the current newsgroup.")
1057 (defvar gnus-newsgroup-expunged-tally nil)
1059 (defvar gnus-newsgroup-marked nil
1060 "List of ticked articles in the current newsgroup (a subset of unread art).")
1062 (defvar gnus-newsgroup-killed nil
1063 "List of ranges of articles that have been through the scoring process.")
1065 (defvar gnus-newsgroup-cached nil
1066 "List of articles that come from the article cache.")
1068 (defvar gnus-newsgroup-saved nil
1069 "List of articles that have been saved.")
1071 (defvar gnus-newsgroup-kill-headers nil)
1073 (defvar gnus-newsgroup-replied nil
1074 "List of articles that have been replied to in the current newsgroup.")
1076 (defvar gnus-newsgroup-expirable nil
1077 "List of articles in the current newsgroup that can be expired.")
1079 (defvar gnus-newsgroup-processable nil
1080 "List of articles in the current newsgroup that can be processed.")
1082 (defvar gnus-newsgroup-downloadable nil
1083 "List of articles in the current newsgroup that can be processed.")
1085 (defvar gnus-newsgroup-undownloaded nil
1086 "List of articles in the current newsgroup that haven't been downloaded..")
1088 (defvar gnus-newsgroup-unsendable nil
1089 "List of articles in the current newsgroup that won't be sent.")
1091 (defvar gnus-newsgroup-bookmarks nil
1092 "List of articles in the current newsgroup that have bookmarks.")
1094 (defvar gnus-newsgroup-dormant nil
1095 "List of dormant articles in the current newsgroup.")
1097 (defvar gnus-newsgroup-scored nil
1098 "List of scored articles in the current newsgroup.")
1100 (defvar gnus-newsgroup-incorporated nil
1101 "List of incorporated articles in the current newsgroup.")
1103 (defvar gnus-newsgroup-headers nil
1104 "List of article headers in the current newsgroup.")
1106 (defvar gnus-newsgroup-threads nil)
1108 (defvar gnus-newsgroup-prepared nil
1109 "Whether the current group has been prepared properly.")
1111 (defvar gnus-newsgroup-ancient nil
1112 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1114 (defvar gnus-newsgroup-sparse nil)
1116 (defvar gnus-current-article nil)
1117 (defvar gnus-article-current nil)
1118 (defvar gnus-current-headers nil)
1119 (defvar gnus-have-all-headers nil)
1120 (defvar gnus-last-article nil)
1121 (defvar gnus-newsgroup-history nil)
1122 (defvar gnus-newsgroup-charset nil)
1123 (defvar gnus-newsgroup-ephemeral-charset nil)
1124 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1126 (defconst gnus-summary-local-variables
1127 '(gnus-newsgroup-name
1128 gnus-newsgroup-begin gnus-newsgroup-end
1129 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1130 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1131 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1132 gnus-newsgroup-unselected gnus-newsgroup-marked
1133 gnus-newsgroup-reads gnus-newsgroup-saved
1134 gnus-newsgroup-replied gnus-newsgroup-expirable
1135 gnus-newsgroup-processable gnus-newsgroup-killed
1136 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1137 gnus-newsgroup-unsendable
1138 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1139 gnus-newsgroup-headers gnus-newsgroup-threads
1140 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1141 gnus-current-article gnus-current-headers gnus-have-all-headers
1142 gnus-last-article gnus-article-internal-prepare-hook
1143 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1144 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1145 gnus-thread-expunge-below
1146 gnus-score-alist gnus-current-score-file
1147 (gnus-summary-expunge-below . global)
1148 (gnus-summary-mark-below . global)
1149 gnus-newsgroup-active gnus-scores-exclude-files
1150 gnus-newsgroup-history gnus-newsgroup-ancient
1151 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1152 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1153 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1154 (gnus-newsgroup-expunged-tally . 0)
1155 gnus-cache-removable-articles gnus-newsgroup-cached
1156 gnus-newsgroup-data gnus-newsgroup-data-reverse
1157 gnus-newsgroup-limit gnus-newsgroup-limits
1158 gnus-newsgroup-charset
1159 gnus-newsgroup-incorporated)
1160 "Variables that are buffer-local to the summary buffers.")
1162 ;; Byte-compiler warning.
1163 (defvar gnus-article-mode-map)
1165 ;; Subject simplification.
1167 (defun gnus-simplify-whitespace (str)
1168 "Remove excessive whitespace."
1171 (while (string-match "[ \t][ \t]+" mystr)
1172 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1174 (substring mystr (match-end 0)))))
1176 (when (string-match "^[ \t]+" mystr)
1177 (setq mystr (substring mystr (match-end 0))))
1179 (when (string-match "[ \t]+$" mystr)
1180 (setq mystr (substring mystr 0 (match-beginning 0))))
1183 (defsubst gnus-simplify-subject-re (subject)
1184 "Remove \"Re:\" from subject lines."
1185 (if (string-match "^[Rr][Ee]: *" subject)
1186 (substring subject (match-end 0))
1189 (defun gnus-simplify-subject (subject &optional re-only)
1190 "Remove `Re:' and words in parentheses.
1191 If RE-ONLY is non-nil, strip leading `Re:'s only."
1192 (let ((case-fold-search t)) ;Ignore case.
1193 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1194 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1195 (setq subject (substring subject (match-end 0))))
1196 ;; Remove uninteresting prefixes.
1197 (when (and (not re-only)
1198 gnus-simplify-ignored-prefixes
1199 (string-match gnus-simplify-ignored-prefixes subject))
1200 (setq subject (substring subject (match-end 0))))
1201 ;; Remove words in parentheses from end.
1203 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1204 (setq subject (substring subject 0 (match-beginning 0)))))
1205 ;; Return subject string.
1208 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1210 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1211 (goto-char (point-min))
1212 (while (re-search-forward regexp nil t)
1213 (replace-match (or newtext ""))))
1215 (defun gnus-simplify-buffer-fuzzy ()
1216 "Simplify string in the buffer fuzzily.
1217 The string in the accessible portion of the current buffer is simplified.
1218 It is assumed to be a single-line subject.
1219 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1220 matter is removed. Additional things can be deleted by setting
1221 gnus-simplify-subject-fuzzy-regexp."
1222 (let ((case-fold-search t)
1224 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1226 (while (not (eq modified-tick (buffer-modified-tick)))
1227 (setq modified-tick (buffer-modified-tick))
1229 ((listp gnus-simplify-subject-fuzzy-regexp)
1230 (mapcar 'gnus-simplify-buffer-fuzzy-step
1231 gnus-simplify-subject-fuzzy-regexp))
1232 (gnus-simplify-subject-fuzzy-regexp
1233 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1234 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1235 (gnus-simplify-buffer-fuzzy-step
1236 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1237 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1239 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1240 (gnus-simplify-buffer-fuzzy-step " +" " ")
1241 (gnus-simplify-buffer-fuzzy-step " $")
1242 (gnus-simplify-buffer-fuzzy-step "^ +")))
1244 (defun gnus-simplify-subject-fuzzy (subject)
1245 "Simplify a subject string fuzzily.
1246 See `gnus-simplify-buffer-fuzzy' for details."
1248 (gnus-set-work-buffer)
1249 (let ((case-fold-search t))
1250 ;; Remove uninteresting prefixes.
1251 (when (and gnus-simplify-ignored-prefixes
1252 (string-match gnus-simplify-ignored-prefixes subject))
1253 (setq subject (substring subject (match-end 0))))
1255 (inline (gnus-simplify-buffer-fuzzy))
1258 (defsubst gnus-simplify-subject-fully (subject)
1259 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1261 (gnus-simplify-subject-functions
1262 (gnus-map-function gnus-simplify-subject-functions subject))
1263 ((null gnus-summary-gather-subject-limit)
1264 (gnus-simplify-subject-re subject))
1265 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1266 (gnus-simplify-subject-fuzzy subject))
1267 ((numberp gnus-summary-gather-subject-limit)
1268 (gnus-limit-string (gnus-simplify-subject-re subject)
1269 gnus-summary-gather-subject-limit))
1273 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1274 "Check whether two subjects are equal.
1275 If optional argument simple-first is t, first argument is already
1278 ((null simple-first)
1279 (equal (gnus-simplify-subject-fully s1)
1280 (gnus-simplify-subject-fully s2)))
1283 (gnus-simplify-subject-fully s2)))))
1285 (defun gnus-summary-bubble-group ()
1286 "Increase the score of the current group.
1287 This is a handy function to add to `gnus-summary-exit-hook' to
1288 increase the score of each group you read."
1289 (gnus-group-add-score gnus-newsgroup-name))
1293 ;;; Gnus summary mode
1296 (put 'gnus-summary-mode 'mode-class 'special)
1299 ;; Non-orthogonal keys
1301 (gnus-define-keys gnus-summary-mode-map
1302 " " gnus-summary-next-page
1303 "\177" gnus-summary-prev-page
1304 [delete] gnus-summary-prev-page
1305 [backspace] gnus-summary-prev-page
1306 "\r" gnus-summary-scroll-up
1307 "\M-\r" gnus-summary-scroll-down
1308 "n" gnus-summary-next-unread-article
1309 "p" gnus-summary-prev-unread-article
1310 "N" gnus-summary-next-article
1311 "P" gnus-summary-prev-article
1312 "\M-\C-n" gnus-summary-next-same-subject
1313 "\M-\C-p" gnus-summary-prev-same-subject
1314 "\M-n" gnus-summary-next-unread-subject
1315 "\M-p" gnus-summary-prev-unread-subject
1316 "." gnus-summary-first-unread-article
1317 "," gnus-summary-best-unread-article
1318 "\M-s" gnus-summary-search-article-forward
1319 "\M-r" gnus-summary-search-article-backward
1320 "<" gnus-summary-beginning-of-article
1321 ">" gnus-summary-end-of-article
1322 "j" gnus-summary-goto-article
1323 "^" gnus-summary-refer-parent-article
1324 "\M-^" gnus-summary-refer-article
1325 "u" gnus-summary-tick-article-forward
1326 "!" gnus-summary-tick-article-forward
1327 "U" gnus-summary-tick-article-backward
1328 "d" gnus-summary-mark-as-read-forward
1329 "D" gnus-summary-mark-as-read-backward
1330 "E" gnus-summary-mark-as-expirable
1331 "\M-u" gnus-summary-clear-mark-forward
1332 "\M-U" gnus-summary-clear-mark-backward
1333 "k" gnus-summary-kill-same-subject-and-select
1334 "\C-k" gnus-summary-kill-same-subject
1335 "\M-\C-k" gnus-summary-kill-thread
1336 "\M-\C-l" gnus-summary-lower-thread
1337 "e" gnus-summary-edit-article
1338 "#" gnus-summary-mark-as-processable
1339 "\M-#" gnus-summary-unmark-as-processable
1340 "\M-\C-t" gnus-summary-toggle-threads
1341 "\M-\C-s" gnus-summary-show-thread
1342 "\M-\C-h" gnus-summary-hide-thread
1343 "\M-\C-f" gnus-summary-next-thread
1344 "\M-\C-b" gnus-summary-prev-thread
1345 "\M-\C-u" gnus-summary-up-thread
1346 "\M-\C-d" gnus-summary-down-thread
1347 "&" gnus-summary-execute-command
1348 "c" gnus-summary-catchup-and-exit
1349 "\C-w" gnus-summary-mark-region-as-read
1350 "\C-t" gnus-summary-toggle-truncation
1351 "?" gnus-summary-mark-as-dormant
1352 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1353 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1354 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1355 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1356 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1357 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1358 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1359 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1360 "=" gnus-summary-expand-window
1361 "\C-x\C-s" gnus-summary-reselect-current-group
1362 "\M-g" gnus-summary-rescan-group
1363 "w" gnus-summary-stop-page-breaking
1364 "\C-c\C-r" gnus-summary-caesar-message
1365 "\M-t" gnus-summary-toggle-mime
1366 "f" gnus-summary-followup
1367 "F" gnus-summary-followup-with-original
1368 "C" gnus-summary-cancel-article
1369 "r" gnus-summary-reply
1370 "R" gnus-summary-reply-with-original
1371 "\C-c\C-f" gnus-summary-mail-forward
1372 "o" gnus-summary-save-article
1373 "\C-o" gnus-summary-save-article-mail
1374 "|" gnus-summary-pipe-output
1375 "\M-k" gnus-summary-edit-local-kill
1376 "\M-K" gnus-summary-edit-global-kill
1378 "\C-c\C-d" gnus-summary-describe-group
1379 "q" gnus-summary-exit
1380 "Q" gnus-summary-exit-no-update
1381 "\C-c\C-i" gnus-info-find-node
1382 gnus-mouse-2 gnus-mouse-pick-article
1383 "m" gnus-summary-mail-other-window
1384 "a" gnus-summary-post-news
1385 "x" gnus-summary-limit-to-unread
1386 "s" gnus-summary-isearch-article
1387 "t" gnus-article-toggle-headers
1388 "g" gnus-summary-show-article
1389 "l" gnus-summary-goto-last-article
1390 "v" gnus-summary-preview-mime-message
1391 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1392 "\C-d" gnus-summary-enter-digest-group
1393 "\M-\C-d" gnus-summary-read-document
1394 "\M-\C-e" gnus-summary-edit-parameters
1395 "\M-\C-a" gnus-summary-customize-parameters
1397 "*" gnus-cache-enter-article
1398 "\M-*" gnus-cache-remove-article
1399 "\M-&" gnus-summary-universal-argument
1400 "\C-l" gnus-recenter
1401 "I" gnus-summary-increase-score
1402 "L" gnus-summary-lower-score
1403 "\M-i" gnus-symbolic-argument
1404 "h" gnus-summary-select-article-buffer
1406 "V" gnus-summary-score-map
1407 "X" gnus-uu-extract-map
1408 "S" gnus-summary-send-map)
1410 ;; Sort of orthogonal keymap
1411 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1412 "t" gnus-summary-tick-article-forward
1413 "!" gnus-summary-tick-article-forward
1414 "d" gnus-summary-mark-as-read-forward
1415 "r" gnus-summary-mark-as-read-forward
1416 "c" gnus-summary-clear-mark-forward
1417 " " gnus-summary-clear-mark-forward
1418 "e" gnus-summary-mark-as-expirable
1419 "x" gnus-summary-mark-as-expirable
1420 "?" gnus-summary-mark-as-dormant
1421 "b" gnus-summary-set-bookmark
1422 "B" gnus-summary-remove-bookmark
1423 "#" gnus-summary-mark-as-processable
1424 "\M-#" gnus-summary-unmark-as-processable
1425 "S" gnus-summary-limit-include-expunged
1426 "C" gnus-summary-catchup
1427 "H" gnus-summary-catchup-to-here
1428 "\C-c" gnus-summary-catchup-all
1429 "k" gnus-summary-kill-same-subject-and-select
1430 "K" gnus-summary-kill-same-subject
1431 "P" gnus-uu-mark-map)
1433 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1434 "c" gnus-summary-clear-above
1435 "u" gnus-summary-tick-above
1436 "m" gnus-summary-mark-above
1437 "k" gnus-summary-kill-below)
1439 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1440 "/" gnus-summary-limit-to-subject
1441 "n" gnus-summary-limit-to-articles
1442 "w" gnus-summary-pop-limit
1443 "s" gnus-summary-limit-to-subject
1444 "a" gnus-summary-limit-to-author
1445 "u" gnus-summary-limit-to-unread
1446 "m" gnus-summary-limit-to-marks
1447 "M" gnus-summary-limit-exclude-marks
1448 "v" gnus-summary-limit-to-score
1449 "*" gnus-summary-limit-include-cached
1450 "D" gnus-summary-limit-include-dormant
1451 "T" gnus-summary-limit-include-thread
1452 "d" gnus-summary-limit-exclude-dormant
1453 "t" gnus-summary-limit-to-age
1454 "x" gnus-summary-limit-to-extra
1455 "E" gnus-summary-limit-include-expunged
1456 "c" gnus-summary-limit-exclude-childless-dormant
1457 "C" gnus-summary-limit-mark-excluded-as-read)
1459 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1460 "n" gnus-summary-next-unread-article
1461 "p" gnus-summary-prev-unread-article
1462 "N" gnus-summary-next-article
1463 "P" gnus-summary-prev-article
1464 "\C-n" gnus-summary-next-same-subject
1465 "\C-p" gnus-summary-prev-same-subject
1466 "\M-n" gnus-summary-next-unread-subject
1467 "\M-p" gnus-summary-prev-unread-subject
1468 "f" gnus-summary-first-unread-article
1469 "b" gnus-summary-best-unread-article
1470 "j" gnus-summary-goto-article
1471 "g" gnus-summary-goto-subject
1472 "l" gnus-summary-goto-last-article
1473 "o" gnus-summary-pop-article)
1475 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1476 "k" gnus-summary-kill-thread
1477 "l" gnus-summary-lower-thread
1478 "i" gnus-summary-raise-thread
1479 "T" gnus-summary-toggle-threads
1480 "t" gnus-summary-rethread-current
1481 "^" gnus-summary-reparent-thread
1482 "s" gnus-summary-show-thread
1483 "S" gnus-summary-show-all-threads
1484 "h" gnus-summary-hide-thread
1485 "H" gnus-summary-hide-all-threads
1486 "n" gnus-summary-next-thread
1487 "p" gnus-summary-prev-thread
1488 "u" gnus-summary-up-thread
1489 "o" gnus-summary-top-thread
1490 "d" gnus-summary-down-thread
1491 "#" gnus-uu-mark-thread
1492 "\M-#" gnus-uu-unmark-thread)
1494 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1495 "g" gnus-summary-prepare
1496 "c" gnus-summary-insert-cached-articles)
1498 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1499 "c" gnus-summary-catchup-and-exit
1500 "C" gnus-summary-catchup-all-and-exit
1501 "E" gnus-summary-exit-no-update
1502 "J" gnus-summary-jump-to-other-group
1503 "Q" gnus-summary-exit
1504 "Z" gnus-summary-exit
1505 "n" gnus-summary-catchup-and-goto-next-group
1506 "R" gnus-summary-reselect-current-group
1507 "G" gnus-summary-rescan-group
1508 "N" gnus-summary-next-group
1509 "s" gnus-summary-save-newsrc
1510 "P" gnus-summary-prev-group)
1512 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1513 " " gnus-summary-next-page
1514 "n" gnus-summary-next-page
1515 "\177" gnus-summary-prev-page
1516 [delete] gnus-summary-prev-page
1517 "p" gnus-summary-prev-page
1518 "\r" gnus-summary-scroll-up
1519 "\M-\r" gnus-summary-scroll-down
1520 "<" gnus-summary-beginning-of-article
1521 ">" gnus-summary-end-of-article
1522 "b" gnus-summary-beginning-of-article
1523 "e" gnus-summary-end-of-article
1524 "^" gnus-summary-refer-parent-article
1525 "r" gnus-summary-refer-parent-article
1526 "D" gnus-summary-enter-digest-group
1527 "R" gnus-summary-refer-references
1528 "T" gnus-summary-refer-thread
1529 "g" gnus-summary-show-article
1530 "s" gnus-summary-isearch-article
1531 "P" gnus-summary-print-article
1532 "t" gnus-article-babel
1533 "d" gnus-summary-decrypt-article
1534 "v" gnus-summary-verify-article)
1536 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1537 "b" gnus-article-add-buttons
1538 "B" gnus-article-add-buttons-to-head
1539 "o" gnus-article-treat-overstrike
1540 "e" gnus-article-emphasize
1541 "w" gnus-article-fill-cited-article
1542 "Q" gnus-article-fill-long-lines
1543 "C" gnus-article-capitalize-sentences
1544 "c" gnus-article-remove-cr
1545 "f" gnus-article-display-x-face
1546 "l" gnus-summary-stop-page-breaking
1547 "r" gnus-summary-caesar-message
1548 "t" gnus-article-toggle-headers
1549 "v" gnus-summary-verbose-headers
1550 "m" gnus-summary-toggle-mime
1551 "H" gnus-article-strip-headers-in-body
1552 "d" gnus-article-treat-dumbquotes
1553 "s" gnus-smiley-display)
1555 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1556 "a" gnus-article-hide
1557 "h" gnus-article-toggle-headers
1558 "b" gnus-article-hide-boring-headers
1559 "s" gnus-article-hide-signature
1560 "c" gnus-article-hide-citation
1561 "C" gnus-article-hide-citation-in-followups
1562 "l" gnus-article-hide-list-identifiers
1563 "p" gnus-article-hide-pgp
1564 "B" gnus-article-strip-banner
1565 "P" gnus-article-hide-pem
1566 "\C-c" gnus-article-hide-citation-maybe)
1568 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1569 "a" gnus-article-highlight
1570 "h" gnus-article-highlight-headers
1571 "c" gnus-article-highlight-citation
1572 "s" gnus-article-highlight-signature)
1574 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1575 "z" gnus-article-date-ut
1576 "u" gnus-article-date-ut
1577 "l" gnus-article-date-local
1578 "e" gnus-article-date-lapsed
1579 "o" gnus-article-date-original
1580 "i" gnus-article-date-iso8601
1581 "s" gnus-article-date-user)
1583 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1584 "t" gnus-article-remove-trailing-blank-lines
1585 "l" gnus-article-strip-leading-blank-lines
1586 "m" gnus-article-strip-multiple-blank-lines
1587 "a" gnus-article-strip-blank-lines
1588 "A" gnus-article-strip-all-blank-lines
1589 "s" gnus-article-strip-leading-space
1590 "e" gnus-article-strip-trailing-space)
1592 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1594 "f" gnus-summary-fetch-faq
1595 "d" gnus-summary-describe-group
1596 "h" gnus-summary-describe-briefly
1597 "i" gnus-info-find-node)
1599 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1600 "e" gnus-summary-expire-articles
1601 "\M-\C-e" gnus-summary-expire-articles-now
1602 "\177" gnus-summary-delete-article
1603 [delete] gnus-summary-delete-article
1604 [backspace] gnus-summary-delete-article
1605 "m" gnus-summary-move-article
1606 "r" gnus-summary-respool-article
1607 "w" gnus-summary-edit-article
1608 "c" gnus-summary-copy-article
1609 "B" gnus-summary-crosspost-article
1610 "q" gnus-summary-respool-query
1611 "t" gnus-summary-respool-trace
1612 "i" gnus-summary-import-article
1613 "p" gnus-summary-article-posted-p)
1615 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1616 "o" gnus-summary-save-article
1617 "m" gnus-summary-save-article-mail
1618 "F" gnus-summary-write-article-file
1619 "r" gnus-summary-save-article-rmail
1620 "f" gnus-summary-save-article-file
1621 "b" gnus-summary-save-article-body-file
1622 "h" gnus-summary-save-article-folder
1623 "v" gnus-summary-save-article-vm
1624 "p" gnus-summary-pipe-output
1625 "s" gnus-soup-add-article)
1627 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1628 "b" gnus-summary-display-buttonized
1629 "m" gnus-summary-repair-multipart
1630 "v" gnus-article-view-part
1631 "o" gnus-article-save-part
1632 "c" gnus-article-copy-part
1633 "e" gnus-article-externalize-part
1634 "i" gnus-article-inline-part
1635 "|" gnus-article-pipe-part))
1637 (defun gnus-summary-make-menu-bar ()
1638 (gnus-turn-off-edit-menu 'summary)
1640 (unless (boundp 'gnus-summary-misc-menu)
1643 gnus-summary-kill-menu gnus-summary-mode-map ""
1648 ["Enter score..." gnus-summary-score-entry t]
1649 ["Customize" gnus-score-customize t])
1650 (gnus-make-score-map 'increase)
1651 (gnus-make-score-map 'lower)
1653 ["Kill below" gnus-summary-kill-below t]
1654 ["Mark above" gnus-summary-mark-above t]
1655 ["Tick above" gnus-summary-tick-above t]
1656 ["Clear above" gnus-summary-clear-above t])
1657 ["Current score" gnus-summary-current-score t]
1658 ["Set score" gnus-summary-set-score t]
1659 ["Switch current score file..." gnus-score-change-score-file t]
1660 ["Set mark below..." gnus-score-set-mark-below t]
1661 ["Set expunge below..." gnus-score-set-expunge-below t]
1662 ["Edit current score file" gnus-score-edit-current-scores t]
1663 ["Edit score file" gnus-score-edit-file t]
1664 ["Trace score" gnus-score-find-trace t]
1665 ["Find words" gnus-score-find-favourite-words t]
1666 ["Rescore buffer" gnus-summary-rescore t]
1667 ["Increase score..." gnus-summary-increase-score t]
1668 ["Lower score..." gnus-summary-lower-score t]))))
1670 ;; Define both the Article menu in the summary buffer and the equivalent
1671 ;; Commands menu in the article buffer here for consistency.
1674 ["All" gnus-article-hide t]
1675 ["Headers" gnus-article-toggle-headers t]
1676 ["Signature" gnus-article-hide-signature t]
1677 ["Citation" gnus-article-hide-citation t]
1678 ["List identifiers" gnus-article-hide-list-identifiers t]
1679 ["PGP" gnus-article-hide-pgp t]
1680 ["Banner" gnus-article-strip-banner t]
1681 ["Boring headers" gnus-article-hide-boring-headers t])
1683 ["All" gnus-article-highlight t]
1684 ["Headers" gnus-article-highlight-headers t]
1685 ["Signature" gnus-article-highlight-signature t]
1686 ["Citation" gnus-article-highlight-citation t])
1688 ["Local" gnus-article-date-local t]
1689 ["ISO8601" gnus-article-date-iso8601 t]
1690 ["UT" gnus-article-date-ut t]
1691 ["Original" gnus-article-date-original t]
1692 ["Lapsed" gnus-article-date-lapsed t]
1693 ["User-defined" gnus-article-date-user t])
1696 ["Leading" gnus-article-strip-leading-blank-lines t]
1697 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1698 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1699 ["All of the above" gnus-article-strip-blank-lines t]
1700 ["All" gnus-article-strip-all-blank-lines t]
1701 ["Leading space" gnus-article-strip-leading-space t]
1702 ["Trailing space" gnus-article-strip-trailing-space t])
1703 ["Overstrike" gnus-article-treat-overstrike t]
1704 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1705 ["Emphasis" gnus-article-emphasize t]
1706 ["Word wrap" gnus-article-fill-cited-article t]
1707 ["Fill long lines" gnus-article-fill-long-lines t]
1708 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1709 ["CR" gnus-article-remove-cr t]
1710 ["Show X-Face" gnus-article-display-x-face t]
1711 ["Rot 13" gnus-summary-caesar-message t]
1712 ["Unix pipe" gnus-summary-pipe-message t]
1713 ["Add buttons" gnus-article-add-buttons t]
1714 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1715 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1716 ["Toggle MIME" gnus-summary-toggle-mime t]
1717 ["Verbose header" gnus-summary-verbose-headers t]
1718 ["Toggle header" gnus-summary-toggle-header t]
1719 ["Toggle smileys" gnus-smiley-display t]
1720 ["HZ" gnus-article-decode-HZ t])
1722 ["Save in default format" gnus-summary-save-article t]
1723 ["Save in file" gnus-summary-save-article-file t]
1724 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1725 ["Save in MH folder" gnus-summary-save-article-folder t]
1726 ["Save in VM folder" gnus-summary-save-article-vm t]
1727 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1728 ["Save body in file" gnus-summary-save-article-body-file t]
1729 ["Pipe through a filter" gnus-summary-pipe-output t]
1730 ["Add to SOUP packet" gnus-soup-add-article t]
1731 ["Print" gnus-summary-print-article t])
1733 ["Respool article..." gnus-summary-respool-article t]
1734 ["Move article..." gnus-summary-move-article
1735 (gnus-check-backend-function
1736 'request-move-article gnus-newsgroup-name)]
1737 ["Copy article..." gnus-summary-copy-article t]
1738 ["Crosspost article..." gnus-summary-crosspost-article
1739 (gnus-check-backend-function
1740 'request-replace-article gnus-newsgroup-name)]
1741 ["Import file..." gnus-summary-import-article t]
1742 ["Check if posted" gnus-summary-article-posted-p t]
1743 ["Edit article" gnus-summary-edit-article
1744 (not (gnus-group-read-only-p))]
1745 ["Delete article" gnus-summary-delete-article
1746 (gnus-check-backend-function
1747 'request-expire-articles gnus-newsgroup-name)]
1748 ["Query respool" gnus-summary-respool-query t]
1749 ["Trace respool" gnus-summary-respool-trace t]
1750 ["Delete expirable articles" gnus-summary-expire-articles-now
1751 (gnus-check-backend-function
1752 'request-expire-articles gnus-newsgroup-name)])
1754 ["Uudecode" gnus-uu-decode-uu t]
1755 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1756 ["Unshar" gnus-uu-decode-unshar t]
1757 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1758 ["Save" gnus-uu-decode-save t]
1759 ["Binhex" gnus-uu-decode-binhex t]
1760 ["Postscript" gnus-uu-decode-postscript t])
1762 ["Enter article" gnus-cache-enter-article t]
1763 ["Remove article" gnus-cache-remove-article t])
1764 ["Translate" gnus-article-babel t]
1765 ["Select article buffer" gnus-summary-select-article-buffer t]
1766 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1767 ["Isearch article..." gnus-summary-isearch-article t]
1768 ["Beginning of the article" gnus-summary-beginning-of-article t]
1769 ["End of the article" gnus-summary-end-of-article t]
1770 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1771 ["Fetch referenced articles" gnus-summary-refer-references t]
1772 ["Fetch current thread" gnus-summary-refer-thread t]
1773 ["Fetch article with id..." gnus-summary-refer-article t]
1774 ["Redisplay" gnus-summary-show-article t])))
1776 gnus-summary-article-menu gnus-summary-mode-map ""
1777 (cons "Article" innards))
1780 gnus-article-commands-menu gnus-article-mode-map ""
1781 (cons "Commands" innards)))
1784 gnus-summary-thread-menu gnus-summary-mode-map ""
1786 ["Toggle threading" gnus-summary-toggle-threads t]
1787 ["Hide threads" gnus-summary-hide-all-threads t]
1788 ["Show threads" gnus-summary-show-all-threads t]
1789 ["Hide thread" gnus-summary-hide-thread t]
1790 ["Show thread" gnus-summary-show-thread t]
1791 ["Go to next thread" gnus-summary-next-thread t]
1792 ["Go to previous thread" gnus-summary-prev-thread t]
1793 ["Go down thread" gnus-summary-down-thread t]
1794 ["Go up thread" gnus-summary-up-thread t]
1795 ["Top of thread" gnus-summary-top-thread t]
1796 ["Mark thread as read" gnus-summary-kill-thread t]
1797 ["Lower thread score" gnus-summary-lower-thread t]
1798 ["Raise thread score" gnus-summary-raise-thread t]
1799 ["Rethread current" gnus-summary-rethread-current t]))
1802 gnus-summary-post-menu gnus-summary-mode-map ""
1804 ["Post an article" gnus-summary-post-news t]
1805 ["Followup" gnus-summary-followup t]
1806 ["Followup and yank" gnus-summary-followup-with-original t]
1807 ["Supersede article" gnus-summary-supersede-article t]
1808 ["Cancel article" gnus-summary-cancel-article t]
1809 ["Reply" gnus-summary-reply t]
1810 ["Reply and yank" gnus-summary-reply-with-original t]
1811 ["Wide reply" gnus-summary-wide-reply t]
1812 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1813 ["Mail forward" gnus-summary-mail-forward t]
1814 ["Post forward" gnus-summary-post-forward t]
1815 ["Digest and mail" gnus-summary-mail-digest t]
1816 ["Digest and post" gnus-summary-post-digest t]
1817 ["Resend message" gnus-summary-resend-message t]
1818 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1819 ["Send a mail" gnus-summary-mail-other-window t]
1820 ["Uuencode and post" gnus-uu-post-news t]
1821 ["Followup via news" gnus-summary-followup-to-mail t]
1822 ["Followup via news and yank"
1823 gnus-summary-followup-to-mail-with-original t]
1825 ;;["Send" gnus-summary-send-draft t]
1826 ;;["Send bounced" gnus-resend-bounced-mail t])
1830 gnus-summary-misc-menu gnus-summary-mode-map ""
1833 ["Mark as read" gnus-summary-mark-as-read-forward t]
1834 ["Mark same subject and select"
1835 gnus-summary-kill-same-subject-and-select t]
1836 ["Mark same subject" gnus-summary-kill-same-subject t]
1837 ["Catchup" gnus-summary-catchup t]
1838 ["Catchup all" gnus-summary-catchup-all t]
1839 ["Catchup to here" gnus-summary-catchup-to-here t]
1840 ["Catchup region" gnus-summary-mark-region-as-read t]
1841 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1843 ["Tick" gnus-summary-tick-article-forward t]
1844 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1845 ["Remove marks" gnus-summary-clear-mark-forward t]
1846 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1847 ["Set bookmark" gnus-summary-set-bookmark t]
1848 ["Remove bookmark" gnus-summary-remove-bookmark t])
1850 ["Marks..." gnus-summary-limit-to-marks t]
1851 ["Subject..." gnus-summary-limit-to-subject t]
1852 ["Author..." gnus-summary-limit-to-author t]
1853 ["Age..." gnus-summary-limit-to-age t]
1854 ["Extra..." gnus-summary-limit-to-extra t]
1855 ["Score" gnus-summary-limit-to-score t]
1856 ["Unread" gnus-summary-limit-to-unread t]
1857 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1858 ["Articles" gnus-summary-limit-to-articles t]
1859 ["Pop limit" gnus-summary-pop-limit t]
1860 ["Show dormant" gnus-summary-limit-include-dormant t]
1861 ["Hide childless dormant"
1862 gnus-summary-limit-exclude-childless-dormant t]
1863 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1864 ["Hide marked" gnus-summary-limit-exclude-marks t]
1865 ["Show expunged" gnus-summary-show-all-expunged t])
1867 ["Set mark" gnus-summary-mark-as-processable t]
1868 ["Remove mark" gnus-summary-unmark-as-processable t]
1869 ["Remove all marks" gnus-summary-unmark-all-processable t]
1870 ["Mark above" gnus-uu-mark-over t]
1871 ["Mark series" gnus-uu-mark-series t]
1872 ["Mark region" gnus-uu-mark-region t]
1873 ["Unmark region" gnus-uu-unmark-region t]
1874 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1875 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1876 ["Mark all" gnus-uu-mark-all t]
1877 ["Mark buffer" gnus-uu-mark-buffer t]
1878 ["Mark sparse" gnus-uu-mark-sparse t]
1879 ["Mark thread" gnus-uu-mark-thread t]
1880 ["Unmark thread" gnus-uu-unmark-thread t]
1881 ("Process Mark Sets"
1882 ["Kill" gnus-summary-kill-process-mark t]
1883 ["Yank" gnus-summary-yank-process-mark
1884 gnus-newsgroup-process-stack]
1885 ["Save" gnus-summary-save-process-mark t]))
1887 ["Page forward" gnus-summary-next-page t]
1888 ["Page backward" gnus-summary-prev-page t]
1889 ["Line forward" gnus-summary-scroll-up t])
1891 ["Next unread article" gnus-summary-next-unread-article t]
1892 ["Previous unread article" gnus-summary-prev-unread-article t]
1893 ["Next article" gnus-summary-next-article t]
1894 ["Previous article" gnus-summary-prev-article t]
1895 ["Next unread subject" gnus-summary-next-unread-subject t]
1896 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1897 ["Next article same subject" gnus-summary-next-same-subject t]
1898 ["Previous article same subject" gnus-summary-prev-same-subject t]
1899 ["First unread article" gnus-summary-first-unread-article t]
1900 ["Best unread article" gnus-summary-best-unread-article t]
1901 ["Go to subject number..." gnus-summary-goto-subject t]
1902 ["Go to article number..." gnus-summary-goto-article t]
1903 ["Go to the last article" gnus-summary-goto-last-article t]
1904 ["Pop article off history" gnus-summary-pop-article t])
1906 ["Sort by number" gnus-summary-sort-by-number t]
1907 ["Sort by author" gnus-summary-sort-by-author t]
1908 ["Sort by subject" gnus-summary-sort-by-subject t]
1909 ["Sort by date" gnus-summary-sort-by-date t]
1910 ["Sort by score" gnus-summary-sort-by-score t]
1911 ["Sort by lines" gnus-summary-sort-by-lines t]
1912 ["Sort by characters" gnus-summary-sort-by-chars t])
1914 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1915 ["Describe group" gnus-summary-describe-group t]
1916 ["Read manual" gnus-info-find-node t])
1918 ["Pick and read" gnus-pick-mode t]
1919 ["Binary" gnus-binary-mode t])
1921 ["Regenerate" gnus-summary-prepare t]
1922 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1923 ["Toggle threading" gnus-summary-toggle-threads t])
1924 ["Filter articles..." gnus-summary-execute-command t]
1925 ["Run command on subjects..." gnus-summary-universal-argument t]
1926 ["Search articles forward..." gnus-summary-search-article-forward t]
1927 ["Search articles backward..." gnus-summary-search-article-backward t]
1928 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1929 ["Expand window" gnus-summary-expand-window t]
1930 ["Expire expirable articles" gnus-summary-expire-articles
1931 (gnus-check-backend-function
1932 'request-expire-articles gnus-newsgroup-name)]
1933 ["Edit local kill file" gnus-summary-edit-local-kill t]
1934 ["Edit main kill file" gnus-summary-edit-global-kill t]
1935 ["Edit group parameters" gnus-summary-edit-parameters t]
1936 ["Customize group parameters" gnus-summary-customize-parameters t]
1937 ["Send a bug report" gnus-bug t]
1939 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1940 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1941 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1942 ["Exit group" gnus-summary-exit t]
1943 ["Exit group without updating" gnus-summary-exit-no-update t]
1944 ["Exit and goto next group" gnus-summary-next-group t]
1945 ["Exit and goto prev group" gnus-summary-prev-group t]
1946 ["Reselect group" gnus-summary-reselect-current-group t]
1947 ["Rescan group" gnus-summary-rescan-group t]
1948 ["Update dribble" gnus-summary-save-newsrc t])))
1950 (gnus-run-hooks 'gnus-summary-menu-hook)))
1952 (defun gnus-score-set-default (var value)
1953 "A version of set that updates the GNU Emacs menu-bar."
1955 ;; It is the message that forces the active status to be updated.
1958 (defun gnus-make-score-map (type)
1959 "Make a summary score map of type TYPE."
1962 (let ((headers '(("author" "from" string)
1963 ("subject" "subject" string)
1964 ("article body" "body" string)
1965 ("article head" "head" string)
1966 ("xref" "xref" string)
1967 ("extra header" "extra" string)
1968 ("lines" "lines" number)
1969 ("followups to author" "followup" string)))
1970 (types '((number ("less than" <)
1973 (string ("substring" s)
1977 (perms '(("temporary" (current-time-string))
1985 (if (eq type 'lower)
1990 (setq header (car headers))
1996 (let ((ts (cdr (assoc (nth 2 header) types)))
2012 'gnus-summary-score-entry
2014 (if (or (string= (nth 1 header)
2016 (string= (nth 1 header)
2019 (list 'gnus-summary-header
2021 (list 'quote (nth 1 (car ts)))
2022 (list 'gnus-score-delta-default
2029 (list (nreverse outp))))
2032 (list (nreverse outt))))
2034 (setq headers (cdr headers)))
2035 (list (nreverse outh))))))))
2039 (defun gnus-summary-mode (&optional group)
2040 "Major mode for reading articles.
2042 All normal editing commands are switched off.
2043 \\<gnus-summary-mode-map>
2044 Each line in this buffer represents one article. To read an
2045 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2046 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2049 You can also post articles and send mail from this buffer. To
2050 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2051 of an article, type `\\[gnus-summary-reply]'.
2053 There are approx. one gazillion commands you can execute in this
2054 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2056 The following commands are available:
2058 \\{gnus-summary-mode-map}"
2060 (when (gnus-visual-p 'summary-menu 'menu)
2061 (gnus-summary-make-menu-bar))
2062 (kill-all-local-variables)
2063 (gnus-summary-make-local-variables)
2064 (gnus-make-thread-indent-array)
2065 (gnus-simplify-mode-line)
2066 (setq major-mode 'gnus-summary-mode)
2067 (setq mode-name "Summary")
2068 (make-local-variable 'minor-mode-alist)
2069 (use-local-map gnus-summary-mode-map)
2070 (buffer-disable-undo)
2071 (setq buffer-read-only t) ;Disable modification
2072 (setq truncate-lines t)
2073 (setq selective-display t)
2074 (setq selective-display-ellipses t) ;Display `...'
2075 (gnus-summary-set-display-table)
2076 (gnus-set-default-directory)
2077 (setq gnus-newsgroup-name group)
2078 (unless (gnus-news-group-p group)
2079 (setq gnus-newsgroup-incorporated
2080 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2081 (make-local-variable 'gnus-summary-line-format)
2082 (make-local-variable 'gnus-summary-line-format-spec)
2083 (make-local-variable 'gnus-summary-dummy-line-format)
2084 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2085 (make-local-variable 'gnus-summary-mark-positions)
2086 (make-local-hook 'pre-command-hook)
2087 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2088 (gnus-run-hooks 'gnus-summary-mode-hook)
2089 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2090 (gnus-update-summary-mark-positions))
2092 (defun gnus-summary-make-local-variables ()
2093 "Make all the local summary buffer variables."
2095 (dolist (local gnus-summary-local-variables)
2098 (if (eq (cdr local) 'global)
2099 ;; Copy the global value of the variable.
2100 (setq global (symbol-value (car local)))
2101 ;; Use the value from the list.
2102 (setq global (eval (cdr local))))
2103 (set (make-local-variable (car local)) global))
2104 ;; Simple nil-valued local variable.
2105 (set (make-local-variable local) nil)))))
2107 (defun gnus-summary-clear-local-variables ()
2108 (let ((locals gnus-summary-local-variables))
2110 (if (consp (car locals))
2111 (and (vectorp (caar locals))
2112 (set (caar locals) nil))
2113 (and (vectorp (car locals))
2114 (set (car locals) nil)))
2115 (setq locals (cdr locals)))))
2117 ;; Summary data functions.
2119 (defmacro gnus-data-number (data)
2122 (defmacro gnus-data-set-number (data number)
2123 `(setcar ,data ,number))
2125 (defmacro gnus-data-mark (data)
2128 (defmacro gnus-data-set-mark (data mark)
2129 `(setcar (nthcdr 1 ,data) ,mark))
2131 (defmacro gnus-data-pos (data)
2134 (defmacro gnus-data-set-pos (data pos)
2135 `(setcar (nthcdr 2 ,data) ,pos))
2137 (defmacro gnus-data-header (data)
2140 (defmacro gnus-data-set-header (data header)
2141 `(setcar (nthcdr 3 ,data) ,header))
2143 (defmacro gnus-data-level (data)
2146 (defmacro gnus-data-unread-p (data)
2147 `(= (nth 1 ,data) gnus-unread-mark))
2149 (defmacro gnus-data-read-p (data)
2150 `(/= (nth 1 ,data) gnus-unread-mark))
2152 (defmacro gnus-data-pseudo-p (data)
2153 `(consp (nth 3 ,data)))
2155 (defmacro gnus-data-find (number)
2156 `(assq ,number gnus-newsgroup-data))
2158 (defmacro gnus-data-find-list (number &optional data)
2159 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2160 (memq (assq ,number bdata)
2163 (defmacro gnus-data-make (number mark pos header level)
2164 `(list ,number ,mark ,pos ,header ,level))
2166 (defun gnus-data-enter (after-article number mark pos header level offset)
2167 (let ((data (gnus-data-find-list after-article)))
2169 (error "No such article: %d" after-article))
2170 (setcdr data (cons (gnus-data-make number mark pos header level)
2172 (setq gnus-newsgroup-data-reverse nil)
2173 (gnus-data-update-list (cddr data) offset)))
2175 (defun gnus-data-enter-list (after-article list &optional offset)
2177 (let ((data (and after-article (gnus-data-find-list after-article)))
2181 (let ((odata gnus-newsgroup-data))
2182 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2184 (gnus-data-update-list odata offset)))
2185 ;; Find the last element in the list to be spliced into the main
2188 (setq list (cdr list)))
2191 (setcdr list gnus-newsgroup-data)
2192 (setq gnus-newsgroup-data ilist)
2194 (gnus-data-update-list (cdr list) offset)))
2195 (setcdr list (cdr data))
2198 (gnus-data-update-list (cdr list) offset))))
2199 (setq gnus-newsgroup-data-reverse nil))))
2201 (defun gnus-data-remove (article &optional offset)
2202 (let ((data gnus-newsgroup-data))
2203 (if (= (gnus-data-number (car data)) article)
2205 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2206 gnus-newsgroup-data-reverse nil)
2208 (gnus-data-update-list gnus-newsgroup-data offset)))
2210 (when (= (gnus-data-number (cadr data)) article)
2211 (setcdr data (cddr data))
2213 (gnus-data-update-list (cdr data) offset))
2215 gnus-newsgroup-data-reverse nil))
2216 (setq data (cdr data))))))
2218 (defmacro gnus-data-list (backward)
2220 (or gnus-newsgroup-data-reverse
2221 (setq gnus-newsgroup-data-reverse
2222 (reverse gnus-newsgroup-data)))
2223 gnus-newsgroup-data))
2225 (defun gnus-data-update-list (data offset)
2226 "Add OFFSET to the POS of all data entries in DATA."
2227 (setq gnus-newsgroup-data-reverse nil)
2229 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2230 (setq data (cdr data))))
2232 (defun gnus-summary-article-pseudo-p (article)
2233 "Say whether this article is a pseudo article or not."
2234 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2236 (defmacro gnus-summary-article-sparse-p (article)
2237 "Say whether this article is a sparse article or not."
2238 `(memq ,article gnus-newsgroup-sparse))
2240 (defmacro gnus-summary-article-ancient-p (article)
2241 "Say whether this article is a sparse article or not."
2242 `(memq ,article gnus-newsgroup-ancient))
2244 (defun gnus-article-parent-p (number)
2245 "Say whether this article is a parent or not."
2246 (let ((data (gnus-data-find-list number)))
2247 (and (cdr data) ; There has to be an article after...
2248 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2249 (gnus-data-level (nth 1 data))))))
2251 (defun gnus-article-children (number)
2252 "Return a list of all children to NUMBER."
2253 (let* ((data (gnus-data-find-list number))
2254 (level (gnus-data-level (car data)))
2256 (setq data (cdr data))
2258 (= (gnus-data-level (car data)) (1+ level)))
2259 (push (gnus-data-number (car data)) children)
2260 (setq data (cdr data)))
2263 (defmacro gnus-summary-skip-intangible ()
2264 "If the current article is intangible, then jump to a different article."
2265 '(let ((to (get-text-property (point) 'gnus-intangible)))
2266 (and to (gnus-summary-goto-subject to))))
2268 (defmacro gnus-summary-article-intangible-p ()
2269 "Say whether this article is intangible or not."
2270 '(get-text-property (point) 'gnus-intangible))
2272 (defun gnus-article-read-p (article)
2273 "Say whether ARTICLE is read or not."
2274 (not (or (memq article gnus-newsgroup-marked)
2275 (memq article gnus-newsgroup-unreads)
2276 (memq article gnus-newsgroup-unselected)
2277 (memq article gnus-newsgroup-dormant))))
2279 ;; Some summary mode macros.
2281 (defmacro gnus-summary-article-number ()
2282 "The article number of the article on the current line.
2283 If there isn's an article number here, then we return the current
2286 (gnus-summary-skip-intangible)
2287 (or (get-text-property (point) 'gnus-number)
2288 (gnus-summary-last-subject))))
2290 (defmacro gnus-summary-article-header (&optional number)
2291 "Return the header of article NUMBER."
2292 `(gnus-data-header (gnus-data-find
2293 ,(or number '(gnus-summary-article-number)))))
2295 (defmacro gnus-summary-thread-level (&optional number)
2296 "Return the level of thread that starts with article NUMBER."
2297 `(if (and (eq gnus-summary-make-false-root 'dummy)
2298 (get-text-property (point) 'gnus-intangible))
2300 (gnus-data-level (gnus-data-find
2301 ,(or number '(gnus-summary-article-number))))))
2303 (defmacro gnus-summary-article-mark (&optional number)
2304 "Return the mark of article NUMBER."
2305 `(gnus-data-mark (gnus-data-find
2306 ,(or number '(gnus-summary-article-number)))))
2308 (defmacro gnus-summary-article-pos (&optional number)
2309 "Return the position of the line of article NUMBER."
2310 `(gnus-data-pos (gnus-data-find
2311 ,(or number '(gnus-summary-article-number)))))
2313 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2314 (defmacro gnus-summary-article-subject (&optional number)
2315 "Return current subject string or nil if nothing."
2318 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2319 '(gnus-data-header (assq (gnus-summary-article-number)
2320 gnus-newsgroup-data)))))
2323 (mail-header-subject headers))))
2325 (defmacro gnus-summary-article-score (&optional number)
2326 "Return current article score."
2327 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2328 gnus-newsgroup-scored))
2329 gnus-summary-default-score 0))
2331 (defun gnus-summary-article-children (&optional number)
2332 "Return a list of article numbers that are children of article NUMBER."
2333 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2334 (level (gnus-data-level (car data)))
2336 (while (and (setq data (cdr data))
2337 (> (setq l (gnus-data-level (car data))) level))
2338 (and (= (1+ level) l)
2339 (push (gnus-data-number (car data))
2341 (nreverse children)))
2343 (defun gnus-summary-article-parent (&optional number)
2344 "Return the article number of the parent of article NUMBER."
2345 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2346 (gnus-data-list t)))
2347 (level (gnus-data-level (car data))))
2349 () ; This is a root.
2350 ;; We search until we find an article with a level less than
2351 ;; this one. That function has to be the parent.
2352 (while (and (setq data (cdr data))
2353 (not (< (gnus-data-level (car data)) level))))
2354 (and data (gnus-data-number (car data))))))
2356 (defun gnus-unread-mark-p (mark)
2357 "Say whether MARK is the unread mark."
2358 (= mark gnus-unread-mark))
2360 (defun gnus-read-mark-p (mark)
2361 "Say whether MARK is one of the marks that mark as read.
2362 This is all marks except unread, ticked, dormant, and expirable."
2363 (not (or (= mark gnus-unread-mark)
2364 (= mark gnus-ticked-mark)
2365 (= mark gnus-dormant-mark)
2366 (= mark gnus-expirable-mark))))
2368 (defmacro gnus-article-mark (number)
2369 "Return the MARK of article NUMBER.
2370 This macro should only be used when computing the mark the \"first\"
2371 time; i.e., when generating the summary lines. After that,
2372 `gnus-summary-article-mark' should be used to examine the
2375 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2376 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2377 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2378 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2379 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2380 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2381 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2382 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2383 gnus-ancient-mark))))
2385 ;; Saving hidden threads.
2387 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2388 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2390 (defmacro gnus-save-hidden-threads (&rest forms)
2391 "Save hidden threads, eval FORMS, and restore the hidden threads."
2392 (let ((config (make-symbol "config")))
2393 `(let ((,config (gnus-hidden-threads-configuration)))
2397 (gnus-restore-hidden-threads-configuration ,config)))))
2399 (defun gnus-data-compute-positions ()
2400 "Compute the positions of all articles."
2401 (setq gnus-newsgroup-data-reverse nil)
2402 (let ((data gnus-newsgroup-data))
2404 (gnus-save-hidden-threads
2405 (gnus-summary-show-all-threads)
2406 (goto-char (point-min))
2408 (while (get-text-property (point) 'gnus-intangible)
2410 (gnus-data-set-pos (car data) (+ (point) 3))
2411 (setq data (cdr data))
2412 (forward-line 1))))))
2414 (defun gnus-hidden-threads-configuration ()
2415 "Return the current hidden threads configuration."
2418 (goto-char (point-min))
2419 (while (search-forward "\r" nil t)
2420 (push (1- (point)) config))
2423 (defun gnus-restore-hidden-threads-configuration (config)
2424 "Restore hidden threads configuration from CONFIG."
2425 (let (point buffer-read-only)
2426 (while (setq point (pop config))
2427 (when (and (< point (point-max))
2429 (eq (char-after) ?\n))
2430 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2432 ;; Various summary mode internalish functions.
2434 (defun gnus-mouse-pick-article (e)
2437 (gnus-summary-next-page nil t))
2439 (defun gnus-summary-set-display-table ()
2440 ;; Change the display table. Odd characters have a tendency to mess
2441 ;; up nicely formatted displays - we make all possible glyphs
2442 ;; display only a single character.
2444 ;; We start from the standard display table, if any.
2445 (let ((table (or (copy-sequence standard-display-table)
2446 (make-display-table)))
2448 ;; Nix out all the control chars...
2449 (while (>= (setq i (1- i)) 0)
2450 (aset table i [??]))
2451 ;; ... but not newline and cr, of course. (cr is necessary for the
2452 ;; selective display).
2453 (aset table ?\n nil)
2454 (aset table ?\r nil)
2455 ;; We keep TAB as well.
2456 (aset table ?\t nil)
2457 ;; We nix out any glyphs over 126 that are not set already.
2459 (while (>= (setq i (1- i)) 127)
2460 ;; Only modify if the entry is nil.
2461 (unless (aref table i)
2462 (aset table i [??]))))
2463 (setq buffer-display-table table)))
2465 (defun gnus-summary-setup-buffer (group)
2466 "Initialize summary buffer."
2467 (let ((buffer (concat "*Summary " group "*")))
2468 (if (get-buffer buffer)
2471 (setq gnus-summary-buffer (current-buffer))
2472 (not gnus-newsgroup-prepared))
2473 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2474 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2475 (gnus-summary-mode group)
2477 (gnus-carpal-setup-buffer 'summary))
2478 (unless gnus-single-article-buffer
2479 (make-local-variable 'gnus-article-buffer)
2480 (make-local-variable 'gnus-article-current)
2481 (make-local-variable 'gnus-original-article-buffer))
2482 (setq gnus-newsgroup-name group)
2485 (defun gnus-set-global-variables ()
2486 ;; Set the global equivalents of the summary buffer-local variables
2487 ;; to the latest values they had. These reflect the summary buffer
2488 ;; that was in action when the last article was fetched.
2489 (when (eq major-mode 'gnus-summary-mode)
2490 (setq gnus-summary-buffer (current-buffer))
2491 (let ((name gnus-newsgroup-name)
2492 (marked gnus-newsgroup-marked)
2493 (unread gnus-newsgroup-unreads)
2494 (headers gnus-current-headers)
2495 (data gnus-newsgroup-data)
2496 (summary gnus-summary-buffer)
2497 (article-buffer gnus-article-buffer)
2498 (original gnus-original-article-buffer)
2499 (gac gnus-article-current)
2500 (reffed gnus-reffed-article-number)
2501 (score-file gnus-current-score-file)
2502 (default-charset gnus-newsgroup-charset))
2504 (set-buffer gnus-group-buffer)
2505 (setq gnus-newsgroup-name name
2506 gnus-newsgroup-marked marked
2507 gnus-newsgroup-unreads unread
2508 gnus-current-headers headers
2509 gnus-newsgroup-data data
2510 gnus-article-current gac
2511 gnus-summary-buffer summary
2512 gnus-article-buffer article-buffer
2513 gnus-original-article-buffer original
2514 gnus-reffed-article-number reffed
2515 gnus-current-score-file score-file
2516 gnus-newsgroup-charset default-charset)
2517 ;; The article buffer also has local variables.
2518 (when (gnus-buffer-live-p gnus-article-buffer)
2519 (set-buffer gnus-article-buffer)
2520 (setq gnus-summary-buffer summary))))))
2522 (defun gnus-summary-article-unread-p (article)
2523 "Say whether ARTICLE is unread or not."
2524 (memq article gnus-newsgroup-unreads))
2526 (defun gnus-summary-first-article-p (&optional article)
2527 "Return whether ARTICLE is the first article in the buffer."
2528 (if (not (setq article (or article (gnus-summary-article-number))))
2530 (eq article (caar gnus-newsgroup-data))))
2532 (defun gnus-summary-last-article-p (&optional article)
2533 "Return whether ARTICLE is the last article in the buffer."
2534 (if (not (setq article (or article (gnus-summary-article-number))))
2535 ;; All non-existent numbers are the last article. :-)
2537 (not (cdr (gnus-data-find-list article)))))
2539 (defun gnus-make-thread-indent-array ()
2541 (unless (and gnus-thread-indent-array
2542 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2543 (setq gnus-thread-indent-array (make-vector 201 "")
2544 gnus-thread-indent-array-level gnus-thread-indent-level)
2546 (aset gnus-thread-indent-array n
2547 (make-string (* n gnus-thread-indent-level) ? ))
2550 (defun gnus-update-summary-mark-positions ()
2551 "Compute where the summary marks are to go."
2553 (when (gnus-buffer-exists-p gnus-summary-buffer)
2554 (set-buffer gnus-summary-buffer))
2555 (let ((gnus-replied-mark 129)
2556 (gnus-score-below-mark 130)
2557 (gnus-score-over-mark 130)
2558 (gnus-download-mark 131)
2559 (spec gnus-summary-line-format-spec)
2562 (gnus-set-work-buffer)
2563 (let ((gnus-summary-line-format-spec spec)
2564 (gnus-newsgroup-downloadable '((0 . t))))
2565 (gnus-summary-insert-line
2566 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2567 0 nil 128 t nil "" nil 1)
2568 (goto-char (point-min))
2569 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2571 (goto-char (point-min))
2572 (push (cons 'replied (and (search-forward "\201" nil t)
2575 (goto-char (point-min))
2576 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2578 (goto-char (point-min))
2579 (push (cons 'download
2580 (and (search-forward "\203" nil t) (- (point) 2)))
2582 (setq gnus-summary-mark-positions pos))))
2584 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2585 "Insert a dummy root in the summary buffer."
2587 (gnus-add-text-properties
2588 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2589 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2591 (defun gnus-summary-from-or-to-or-newsgroups (header)
2592 (let ((to (cdr (assq 'To (mail-header-extra header))))
2593 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2594 (default-mime-charset (with-current-buffer gnus-summary-buffer
2595 default-mime-charset)))
2598 gnus-ignored-from-addresses
2599 (string-match gnus-ignored-from-addresses
2600 (mail-header-from header)))
2602 (or (car (funcall gnus-extract-address-components
2604 gnus-decode-encoded-word-function to)))
2605 (funcall gnus-decode-encoded-word-function to))))
2607 gnus-ignored-from-addresses
2608 (string-match gnus-ignored-from-addresses
2609 (mail-header-from header)))
2610 (concat "=> " newsgroups))
2612 (or (car (funcall gnus-extract-address-components
2613 (mail-header-from header)))
2614 (mail-header-from header))))))
2616 (defun gnus-summary-insert-line (gnus-tmp-header
2617 gnus-tmp-level gnus-tmp-current
2618 gnus-tmp-unread gnus-tmp-replied
2619 gnus-tmp-expirable gnus-tmp-subject-or-nil
2620 &optional gnus-tmp-dummy gnus-tmp-score
2622 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2623 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2624 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2625 (gnus-tmp-score-char
2626 (if (or (null gnus-summary-default-score)
2627 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2628 gnus-summary-zcore-fuzz))
2630 (if (< gnus-tmp-score gnus-summary-default-score)
2631 gnus-score-below-mark gnus-score-over-mark)))
2633 (cond (gnus-tmp-process gnus-process-mark)
2634 ((memq gnus-tmp-current gnus-newsgroup-cached)
2636 (gnus-tmp-replied gnus-replied-mark)
2637 ((memq gnus-tmp-current gnus-newsgroup-saved)
2639 (t gnus-unread-mark)))
2640 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2643 ((string-match "<[^>]+> *$" gnus-tmp-from)
2644 (let ((beg (match-beginning 0)))
2645 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2646 (substring gnus-tmp-from (1+ (match-beginning 0))
2647 (1- (match-end 0))))
2648 (substring gnus-tmp-from 0 beg))))
2649 ((string-match "(.+)" gnus-tmp-from)
2650 (substring gnus-tmp-from
2651 (1+ (match-beginning 0)) (1- (match-end 0))))
2653 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2654 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2655 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2656 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2657 (buffer-read-only nil))
2658 (when (string= gnus-tmp-name "")
2659 (setq gnus-tmp-name gnus-tmp-from))
2660 (unless (numberp gnus-tmp-lines)
2661 (setq gnus-tmp-lines 0))
2662 (gnus-put-text-property-excluding-characters-with-faces
2664 (progn (eval gnus-summary-line-format-spec) (point))
2665 'gnus-number gnus-tmp-number)
2666 (when (gnus-visual-p 'summary-highlight 'highlight)
2668 (gnus-run-hooks 'gnus-summary-update-hook)
2671 (defun gnus-summary-update-line (&optional dont-update)
2672 ;; Update summary line after change.
2673 (when (and gnus-summary-default-score
2674 (not gnus-summary-inhibit-highlight))
2675 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2676 (article (gnus-summary-article-number))
2677 (score (gnus-summary-article-score article)))
2679 (if (and gnus-summary-mark-below
2680 (< (gnus-summary-article-score)
2681 gnus-summary-mark-below))
2682 ;; This article has a low score, so we mark it as read.
2683 (when (memq article gnus-newsgroup-unreads)
2684 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2685 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2686 ;; This article was previously marked as read on account
2687 ;; of a low score, but now it has risen, so we mark it as
2689 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2690 (gnus-summary-update-mark
2691 (if (or (null gnus-summary-default-score)
2692 (<= (abs (- score gnus-summary-default-score))
2693 gnus-summary-zcore-fuzz))
2695 (if (< score gnus-summary-default-score)
2696 gnus-score-below-mark gnus-score-over-mark))
2698 ;; Do visual highlighting.
2699 (when (gnus-visual-p 'summary-highlight 'highlight)
2700 (gnus-run-hooks 'gnus-summary-update-hook)))))
2702 (defvar gnus-tmp-new-adopts nil)
2704 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2705 "Return the number of articles in THREAD.
2706 This may be 0 in some cases -- if none of the articles in
2707 the thread are to be displayed."
2709 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2711 ((not (listp thread))
2713 ((and (consp thread) (cdr thread))
2716 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2719 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2722 (when (and level (zerop level) gnus-tmp-new-adopts)
2725 'gnus-summary-number-of-articles-in-thread
2726 gnus-tmp-new-adopts))))
2728 (if (> number 1) gnus-not-empty-thread-mark
2729 gnus-empty-thread-mark)
2732 (defun gnus-summary-set-local-parameters (group)
2733 "Go through the local params of GROUP and set all variable specs in that list."
2734 (let ((params (gnus-group-find-parameter group))
2737 (setq elem (car params)
2738 params (cdr params))
2739 (and (consp elem) ; Has to be a cons.
2740 (consp (cdr elem)) ; The cdr has to be a list.
2741 (symbolp (car elem)) ; Has to be a symbol in there.
2742 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2743 (ignore-errors ; So we set it.
2744 (make-local-variable (car elem))
2745 (set (car elem) (eval (nth 1 elem))))))))
2747 (defun gnus-summary-read-group (group &optional show-all no-article
2748 kill-buffer no-display backward
2750 "Start reading news in newsgroup GROUP.
2751 If SHOW-ALL is non-nil, already read articles are also listed.
2752 If NO-ARTICLE is non-nil, no article is selected initially.
2753 If NO-DISPLAY, don't generate a summary buffer."
2757 (let ((gnus-auto-select-next nil))
2758 (or (gnus-summary-read-group-1
2759 group show-all no-article
2760 kill-buffer no-display
2763 select-articles nil)))))
2764 (eq gnus-auto-select-next 'quietly))
2765 (set-buffer gnus-group-buffer)
2766 ;; The entry function called above goes to the next
2767 ;; group automatically, so we go two groups back
2768 ;; if we are searching for the previous group.
2770 (gnus-group-prev-unread-group 2))
2771 (if (not (equal group (gnus-group-group-name)))
2772 (setq group (gnus-group-group-name))
2776 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2777 "Directly jump to the other GROUP from summary buffer.
2778 If SHOW-ALL is non-nil, already read articles are also listed."
2780 (if (eq gnus-summary-buffer (current-buffer))
2781 (list (completing-read
2782 "Group: " gnus-active-hashtb nil t
2783 (when (and gnus-newsgroup-name
2784 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2785 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2786 'gnus-group-history)
2788 (error "%s must be invoked from a gnus summary buffer." this-command)))
2789 (unless (or (zerop (length group))
2790 (and gnus-newsgroup-name
2791 (string-equal gnus-newsgroup-name group)))
2793 (gnus-summary-read-group group show-all
2794 gnus-dont-select-after-jump-to-other-group)))
2796 (defun gnus-summary-read-group-1 (group show-all no-article
2797 kill-buffer no-display
2798 &optional select-articles)
2799 ;; Killed foreign groups can't be entered.
2800 (when (and (not (gnus-group-native-p group))
2801 (not (gnus-gethash group gnus-newsrc-hashtb)))
2802 (error "Dead non-native groups can't be entered"))
2803 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2804 (let* ((new-group (gnus-summary-setup-buffer group))
2805 (quit-config (gnus-group-quit-config group))
2806 (did-select (and new-group (gnus-select-newsgroup
2807 group show-all select-articles))))
2809 ;; This summary buffer exists already, so we just select it.
2811 (gnus-set-global-variables)
2813 (gnus-kill-or-deaden-summary kill-buffer))
2814 (gnus-configure-windows 'summary 'force)
2815 (gnus-set-mode-line 'summary)
2816 (gnus-summary-position-point)
2819 ;; We couldn't select this group.
2821 (when (and (eq major-mode 'gnus-summary-mode)
2822 (not (equal (current-buffer) kill-buffer)))
2823 (kill-buffer (current-buffer))
2824 (if (not quit-config)
2826 ;; Update the info -- marks might need to be removed,
2828 (gnus-summary-update-info)
2829 (set-buffer gnus-group-buffer)
2830 (gnus-group-jump-to-group group)
2831 (gnus-group-next-unread-group 1))
2832 (gnus-handle-ephemeral-exit quit-config)))
2833 (gnus-message 3 "Can't select group")
2835 ;; The user did a `C-g' while prompting for number of articles,
2836 ;; so we exit this group.
2837 ((eq did-select 'quit)
2838 (and (eq major-mode 'gnus-summary-mode)
2839 (not (equal (current-buffer) kill-buffer))
2840 (kill-buffer (current-buffer)))
2842 (gnus-kill-or-deaden-summary kill-buffer))
2843 (if (not quit-config)
2845 (set-buffer gnus-group-buffer)
2846 (gnus-group-jump-to-group group)
2847 (gnus-group-next-unread-group 1)
2848 (gnus-configure-windows 'group 'force))
2849 (gnus-handle-ephemeral-exit quit-config))
2850 ;; Finally signal the quit.
2852 ;; The group was successfully selected.
2854 (gnus-set-global-variables)
2855 ;; Save the active value in effect when the group was entered.
2856 (setq gnus-newsgroup-active
2858 (gnus-active gnus-newsgroup-name)))
2859 ;; You can change the summary buffer in some way with this hook.
2860 (gnus-run-hooks 'gnus-select-group-hook)
2861 ;; Set any local variables in the group parameters.
2862 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2863 (gnus-update-format-specifications
2864 nil 'summary 'summary-mode 'summary-dummy)
2865 (gnus-update-summary-mark-positions)
2866 ;; Do score processing.
2867 (when gnus-use-scoring
2868 (gnus-possibly-score-headers))
2869 ;; Check whether to fill in the gaps in the threads.
2870 (when gnus-build-sparse-threads
2871 (gnus-build-sparse-threads))
2872 ;; Find the initial limit.
2873 (if gnus-show-threads
2875 (let ((gnus-newsgroup-dormant nil))
2876 (gnus-summary-initial-limit show-all))
2877 (gnus-summary-initial-limit show-all))
2878 ;; When untreaded, all articles are always shown.
2879 (setq gnus-newsgroup-limit
2881 (lambda (header) (mail-header-number header))
2882 gnus-newsgroup-headers)))
2883 ;; Generate the summary buffer.
2885 (gnus-summary-prepare))
2886 (when gnus-use-trees
2887 (gnus-tree-open group)
2888 (setq gnus-summary-highlight-line-function
2889 'gnus-tree-highlight-article))
2890 ;; If the summary buffer is empty, but there are some low-scored
2891 ;; articles or some excluded dormants, we include these in the
2893 (when (and (zerop (buffer-size))
2895 (cond (gnus-newsgroup-dormant
2896 (gnus-summary-limit-include-dormant))
2897 ((and gnus-newsgroup-scored show-all)
2898 (gnus-summary-limit-include-expunged t))))
2899 ;; Function `gnus-apply-kill-file' must be called in this hook.
2900 (gnus-run-hooks 'gnus-apply-kill-hook)
2901 (if (and (zerop (buffer-size))
2904 ;; This newsgroup is empty.
2905 (gnus-summary-catchup-and-exit nil t)
2906 (gnus-message 6 "No unread news")
2908 (gnus-kill-or-deaden-summary kill-buffer))
2909 ;; Return nil from this function.
2911 ;; Hide conversation thread subtrees. We cannot do this in
2912 ;; gnus-summary-prepare-hook since kill processing may not
2913 ;; work with hidden articles.
2914 (and gnus-show-threads
2915 gnus-thread-hide-subtree
2916 (gnus-summary-hide-all-threads))
2918 (gnus-kill-or-deaden-summary kill-buffer))
2919 ;; Show first unread article if requested.
2920 (if (and (not no-article)
2922 gnus-newsgroup-unreads
2923 gnus-auto-select-first)
2925 (gnus-configure-windows 'summary)
2927 ((eq gnus-auto-select-first 'best)
2928 (gnus-summary-best-unread-article))
2929 ((eq gnus-auto-select-first t)
2930 (gnus-summary-first-unread-article))
2931 ((gnus-functionp gnus-auto-select-first)
2932 (funcall gnus-auto-select-first))))
2933 ;; Don't select any articles, just move point to the first
2934 ;; article in the group.
2935 (goto-char (point-min))
2936 (gnus-summary-position-point)
2937 (gnus-configure-windows 'summary 'force)
2938 (gnus-set-mode-line 'summary))
2939 (when (get-buffer-window gnus-group-buffer t)
2940 ;; Gotta use windows, because recenter does weird stuff if
2941 ;; the current buffer ain't the displayed window.
2942 (let ((owin (selected-window)))
2943 (select-window (get-buffer-window gnus-group-buffer t))
2944 (when (gnus-group-goto-group group)
2946 (select-window owin)))
2947 ;; Mark this buffer as "prepared".
2948 (setq gnus-newsgroup-prepared t)
2949 (gnus-run-hooks 'gnus-summary-prepared-hook)
2952 (defun gnus-summary-prepare ()
2953 "Generate the summary buffer."
2955 (let ((buffer-read-only nil))
2957 (setq gnus-newsgroup-data nil
2958 gnus-newsgroup-data-reverse nil)
2959 (gnus-run-hooks 'gnus-summary-generate-hook)
2960 ;; Generate the buffer, either with threads or without.
2961 (when gnus-newsgroup-headers
2962 (gnus-summary-prepare-threads
2963 (if gnus-show-threads
2964 (gnus-sort-gathered-threads
2965 (funcall gnus-summary-thread-gathering-function
2967 (gnus-cut-threads (gnus-make-threads)))))
2968 ;; Unthreaded display.
2969 (gnus-sort-articles gnus-newsgroup-headers))))
2970 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2971 ;; Call hooks for modifying summary buffer.
2972 (goto-char (point-min))
2973 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2975 (defsubst gnus-general-simplify-subject (subject)
2976 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2979 ;; Truncate the subject.
2980 (gnus-simplify-subject-functions
2981 (gnus-map-function gnus-simplify-subject-functions subject))
2982 ((numberp gnus-summary-gather-subject-limit)
2983 (setq subject (gnus-simplify-subject-re subject))
2984 (if (> (length subject) gnus-summary-gather-subject-limit)
2985 (substring subject 0 gnus-summary-gather-subject-limit)
2987 ;; Fuzzily simplify it.
2988 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2989 (gnus-simplify-subject-fuzzy subject))
2990 ;; Just remove the leading "Re:".
2992 (gnus-simplify-subject-re subject))))
2994 (if (and gnus-summary-gather-exclude-subject
2995 (string-match gnus-summary-gather-exclude-subject subject))
2996 nil ; This article shouldn't be gathered
2999 (defun gnus-summary-simplify-subject-query ()
3000 "Query where the respool algorithm would put this article."
3002 (gnus-summary-select-article)
3004 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3006 (defun gnus-gather-threads-by-subject (threads)
3007 "Gather threads by looking at Subject headers."
3008 (if (not gnus-summary-make-false-root)
3010 (let ((hashtb (gnus-make-hashtable 1024))
3013 subject hthread whole-subject)
3015 (setq subject (gnus-general-simplify-subject
3016 (setq whole-subject (mail-header-subject
3019 (if (setq hthread (gnus-gethash subject hashtb))
3021 ;; We enter a dummy root into the thread, if we
3022 ;; haven't done that already.
3023 (unless (stringp (caar hthread))
3024 (setcar hthread (list whole-subject (car hthread))))
3025 ;; We add this new gathered thread to this gathered
3027 (setcdr (car hthread)
3028 (nconc (cdar hthread) (list (car threads))))
3029 ;; Remove it from the list of threads.
3030 (setcdr prev (cdr threads))
3031 (setq threads prev))
3032 ;; Enter this thread into the hash table.
3033 (gnus-sethash subject threads hashtb)))
3035 (setq threads (cdr threads)))
3038 (defun gnus-gather-threads-by-references (threads)
3039 "Gather threads by looking at References headers."
3040 (let ((idhashtb (gnus-make-hashtable 1024))
3041 (thhashtb (gnus-make-hashtable 1024))
3044 ids references id gthread gid entered ref)
3046 (when (setq references (mail-header-references (caar threads)))
3047 (setq id (mail-header-id (caar threads))
3048 ids (gnus-split-references references)
3050 (while (setq ref (pop ids))
3051 (setq ids (delete ref ids))
3052 (if (not (setq gid (gnus-gethash ref idhashtb)))
3054 (gnus-sethash ref id idhashtb)
3055 (gnus-sethash id threads thhashtb))
3056 (setq gthread (gnus-gethash gid thhashtb))
3058 ;; We enter a dummy root into the thread, if we
3059 ;; haven't done that already.
3060 (unless (stringp (caar gthread))
3061 (setcar gthread (list (mail-header-subject (caar gthread))
3063 ;; We add this new gathered thread to this gathered
3065 (setcdr (car gthread)
3066 (nconc (cdar gthread) (list (car threads)))))
3067 ;; Add it into the thread hash table.
3068 (gnus-sethash id gthread thhashtb)
3070 ;; Remove it from the list of threads.
3071 (setcdr prev (cdr threads))
3072 (setq threads prev))))
3074 (setq threads (cdr threads)))
3077 (defun gnus-sort-gathered-threads (threads)
3078 "Sort subtreads inside each gathered thread by article number."
3079 (let ((result threads))
3081 (when (stringp (caar threads))
3082 (setcdr (car threads)
3083 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3084 (setq threads (cdr threads)))
3087 (defun gnus-thread-loop-p (root thread)
3088 "Say whether ROOT is in THREAD."
3089 (let ((stack (list thread))
3092 (while (setq thread (pop stack))
3093 (setq th (cdr thread))
3095 (not (eq (caar th) root)))
3098 ;; We have found a loop.
3100 (setcdr thread (delq (car th) (cdr thread)))
3101 (if (boundp (setq ref-dep (intern "none"
3102 gnus-newsgroup-dependencies)))
3103 (setcdr (symbol-value ref-dep)
3104 (nconc (cdr (symbol-value ref-dep))
3106 (set ref-dep (list nil (car th))))
3109 ;; Push all the subthreads onto the stack.
3110 (push (cdr thread) stack)))
3113 (defun gnus-make-threads ()
3114 "Go through the dependency hashtb and find the roots. Return all threads."
3116 (while (catch 'infloop
3119 ;; Deal with self-referencing References loops.
3120 (when (and (car (symbol-value refs))
3127 (car (symbol-value refs)) thread))
3128 (cdr (symbol-value refs)))))))
3131 (unless (car (symbol-value refs))
3132 ;; These threads do not refer back to any other articles,
3133 ;; so they're roots.
3134 (setq threads (append (cdr (symbol-value refs)) threads))))
3135 gnus-newsgroup-dependencies)))
3138 ;; Build the thread tree.
3139 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3140 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3142 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3143 if it was already present.
3145 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3146 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3147 Message-IDs will be renamed be renamed to a unique Message-ID before
3150 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3151 (let* ((id (mail-header-id header))
3152 (id-dep (and id (intern id dependencies)))
3153 ref ref-dep ref-header)
3154 ;; Enter this `header' in the `dependencies' table.
3158 ;; The first two cases do the normal part: enter a new `header'
3159 ;; in the `dependencies' table.
3160 ((not (boundp id-dep))
3161 (set id-dep (list header)))
3162 ((null (car (symbol-value id-dep)))
3163 (setcar (symbol-value id-dep) header))
3165 ;; From here the `header' was already present in the
3166 ;; `dependencies' table.
3168 ;; Overrides an existing entry;
3169 ;; just set the header part of the entry.
3170 (setcar (symbol-value id-dep) header))
3172 ;; Renames the existing `header' to a unique Message-ID.
3173 ((not gnus-summary-ignore-duplicates)
3174 ;; An article with this Message-ID has already been seen.
3175 ;; We rename the Message-ID.
3176 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3178 (mail-header-set-id header id))
3180 ;; The last case ignores an existing entry, except it adds any
3181 ;; additional Xrefs (in case the two articles came from different
3183 ;; Also sets `header' to `nil' meaning that the `dependencies'
3184 ;; table was *not* modified.
3186 (mail-header-set-xref
3187 (car (symbol-value id-dep))
3188 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3190 (or (mail-header-xref header) "")))
3194 ;; First check if that we are not creating a References loop.
3195 (setq ref (gnus-parent-id (mail-header-references header)))
3197 (setq ref-dep (intern-soft ref dependencies))
3199 (setq ref-header (car (symbol-value ref-dep))))
3200 (if (string= id ref)
3201 ;; Yuk! This is a reference loop. Make the article be a
3204 (mail-header-set-references (car (symbol-value id-dep)) "none")
3206 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3207 (setq ref (gnus-parent-id (mail-header-references header)))
3208 (setq ref-dep (intern (or ref "none") dependencies))
3209 (if (boundp ref-dep)
3210 (setcdr (symbol-value ref-dep)
3211 (nconc (cdr (symbol-value ref-dep))
3212 (list (symbol-value id-dep))))
3213 (set ref-dep (list nil (symbol-value id-dep)))))
3216 (defun gnus-build-sparse-threads ()
3217 (let ((headers gnus-newsgroup-headers)
3218 (mail-parse-charset gnus-newsgroup-charset)
3219 (gnus-summary-ignore-duplicates t)
3220 header references generation relations
3221 subject child end new-child date)
3222 ;; First we create an alist of generations/relations, where
3223 ;; generations is how much we trust the relation, and the relation
3225 (gnus-message 7 "Making sparse threads...")
3227 (nnheader-set-temp-buffer " *gnus sparse threads*")
3228 (while (setq header (pop headers))
3229 (when (and (setq references (mail-header-references header))
3230 (not (string= references "")))
3232 (setq child (mail-header-id header)
3233 subject (mail-header-subject header)
3234 date (mail-header-date header)
3236 (while (search-backward ">" nil t)
3237 (setq end (1+ (point)))
3238 (when (search-backward "<" nil t)
3239 (setq new-child (buffer-substring (point) end))
3240 (push (list (incf generation)
3241 child (setq child new-child)
3245 (push (list (1+ generation) child nil subject) relations))
3247 (kill-buffer (current-buffer)))
3248 ;; Sort over trustworthiness.
3251 (when (gnus-dependencies-add-header
3252 (make-full-mail-header
3253 gnus-reffed-article-number
3254 (nth 3 relation) "" (or (nth 4 relation) "")
3256 (or (nth 2 relation) "") 0 0 "")
3257 gnus-newsgroup-dependencies nil)
3258 (push gnus-reffed-article-number gnus-newsgroup-limit)
3259 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3260 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3261 gnus-newsgroup-reads)
3262 (decf gnus-reffed-article-number)))
3263 (sort relations 'car-less-than-car))
3264 (gnus-message 7 "Making sparse threads...done")))
3266 (defun gnus-build-old-threads ()
3267 ;; Look at all the articles that refer back to old articles, and
3268 ;; fetch the headers for the articles that aren't there. This will
3269 ;; build complete threads - if the roots haven't been expired by the
3271 (let ((mail-parse-charset gnus-newsgroup-charset)
3275 (when (not (car (symbol-value refs)))
3276 (setq heads (cdr (symbol-value refs)))
3278 (if (memq (mail-header-number (caar heads))
3279 gnus-newsgroup-dormant)
3280 (setq heads (cdr heads))
3281 (setq id (symbol-name refs))
3282 (while (and (setq id (gnus-build-get-header id))
3283 (not (car (gnus-id-to-thread id)))))
3284 (setq heads nil)))))
3285 gnus-newsgroup-dependencies)))
3287 ;; This function has to be called with point after the article number
3288 ;; on the beginning of the line.
3289 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3290 (let ((eol (gnus-point-at-eol))
3291 (buffer (current-buffer))
3294 ;; overview: [num subject from date id refs chars lines misc]
3299 (make-full-mail-header
3301 (nnheader-nov-field) ; subject
3302 (nnheader-nov-field) ; from
3303 (nnheader-nov-field) ; date
3304 (nnheader-nov-read-message-id) ; id
3305 (nnheader-nov-field) ; refs
3306 (nnheader-nov-read-integer) ; chars
3307 (nnheader-nov-read-integer) ; lines
3309 (nnheader-nov-field)) ; misc
3310 (nnheader-nov-parse-extra))) ; extra
3312 (when gnus-alter-header-function
3313 (funcall gnus-alter-header-function header))
3314 (gnus-dependencies-add-header header dependencies force-new)))
3316 (defun gnus-build-get-header (id)
3317 ;; Look through the buffer of NOV lines and find the header to
3318 ;; ID. Enter this line into the dependencies hash table, and return
3319 ;; the id of the parent article (if any).
3320 (let ((deps gnus-newsgroup-dependencies)
3324 (set-buffer nntp-server-buffer)
3325 (let ((case-fold-search nil))
3326 (goto-char (point-min))
3327 (while (and (not found)
3328 (search-forward id nil t))
3330 (setq found (looking-at
3331 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3332 (regexp-quote id))))
3333 (or found (beginning-of-line 2)))
3337 (setq header (gnus-nov-parse-line
3338 (read (current-buffer)) deps))
3339 (gnus-parent-id (mail-header-references header))))))
3341 (let ((number (mail-header-number header)))
3342 (push number gnus-newsgroup-limit)
3343 (push header gnus-newsgroup-headers)
3344 (if (memq number gnus-newsgroup-unselected)
3346 (push number gnus-newsgroup-unreads)
3347 (setq gnus-newsgroup-unselected
3348 (delq number gnus-newsgroup-unselected)))
3349 (push number gnus-newsgroup-ancient)))))))
3351 (defun gnus-build-all-threads ()
3352 "Read all the headers."
3353 (let ((gnus-summary-ignore-duplicates t)
3354 (mail-parse-charset gnus-newsgroup-charset)
3355 (dependencies gnus-newsgroup-dependencies)
3358 (set-buffer nntp-server-buffer)
3359 (let ((case-fold-search nil))
3360 (goto-char (point-min))
3363 (setq article (read (current-buffer))
3364 header (gnus-nov-parse-line article dependencies)))
3367 (set-buffer gnus-summary-buffer)
3368 (push header gnus-newsgroup-headers)
3369 (if (memq (setq article (mail-header-number header))
3370 gnus-newsgroup-unselected)
3372 (push article gnus-newsgroup-unreads)
3373 (setq gnus-newsgroup-unselected
3374 (delq article gnus-newsgroup-unselected)))
3375 (push article gnus-newsgroup-ancient)))
3376 (forward-line 1)))))))
3378 (defun gnus-summary-update-article-line (article header)
3379 "Update the line for ARTICLE using HEADERS."
3380 (let* ((id (mail-header-id header))
3381 (thread (gnus-id-to-thread id)))
3383 (error "Article in no thread"))
3384 ;; Update the thread.
3385 (setcar thread header)
3386 (gnus-summary-goto-subject article)
3387 (let* ((datal (gnus-data-find-list article))
3389 (length (when (cdr datal)
3390 (- (gnus-data-pos data)
3391 (gnus-data-pos (cadr datal)))))
3392 (buffer-read-only nil)
3393 (level (gnus-summary-thread-level)))
3395 (gnus-summary-insert-line
3396 header level nil (gnus-article-mark article)
3397 (memq article gnus-newsgroup-replied)
3398 (memq article gnus-newsgroup-expirable)
3399 ;; Only insert the Subject string when it's different
3400 ;; from the previous Subject string.
3401 (if (gnus-subject-equal
3403 (mail-header-subject
3406 (gnus-data-find-list
3408 (gnus-data-list t)))))
3409 ;; Error on the side of excessive subjects.
3411 (mail-header-subject header))
3413 (mail-header-subject header))
3414 nil (cdr (assq article gnus-newsgroup-scored))
3415 (memq article gnus-newsgroup-processable))
3417 (gnus-data-update-list
3418 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3420 (defun gnus-summary-update-article (article &optional iheader)
3421 "Update ARTICLE in the summary buffer."
3422 (set-buffer gnus-summary-buffer)
3423 (let* ((header (gnus-summary-article-header article))
3424 (id (mail-header-id header))
3425 (data (gnus-data-find article))
3426 (thread (gnus-id-to-thread id))
3427 (references (mail-header-references header))
3431 (when (and references
3432 (not (equal "" references)))
3435 (buffer-read-only nil)
3441 (delq thread parent)))
3442 (if (gnus-summary-insert-subject id header)
3443 ;; Set the (possibly) new article number in the data structure.
3444 (gnus-data-set-number data (gnus-id-to-article id))
3448 (defun gnus-rebuild-thread (id &optional line)
3449 "Rebuild the thread containing ID.
3450 If LINE, insert the rebuilt thread starting on line LINE."
3451 (let ((buffer-read-only nil)
3452 old-pos current thread data)
3453 (if (not gnus-show-threads)
3454 (setq thread (list (car (gnus-id-to-thread id))))
3455 ;; Get the thread this article is part of.
3456 (setq thread (gnus-remove-thread id)))
3457 (setq old-pos (gnus-point-at-bol))
3458 (setq current (save-excursion
3459 (and (zerop (forward-line -1))
3460 (gnus-summary-article-number))))
3461 ;; If this is a gathered thread, we have to go some re-gathering.
3462 (when (stringp (car thread))
3463 (let ((subject (car thread))
3465 (setq thread (cdr thread))
3467 (unless (memq (setq thr (gnus-id-to-thread
3469 (mail-header-id (caar thread)))))
3472 (setq thread (cdr thread)))
3473 ;; We now have all (unique) roots.
3474 (if (= (length roots) 1)
3475 ;; All the loose roots are now one solid root.
3476 (setq thread (car roots))
3477 (setq thread (cons subject (gnus-sort-threads roots))))))
3479 ;; We then insert this thread into the summary buffer.
3481 (goto-char (point-min))
3482 (forward-line (1- line)))
3483 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3484 (if gnus-show-threads
3485 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3486 (gnus-summary-prepare-unthreaded thread))
3487 (setq data (nreverse gnus-newsgroup-data))
3488 (setq threads gnus-newsgroup-threads))
3489 ;; We splice the new data into the data structure.
3490 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3491 ;;!!! then we want to insert at the beginning of the buffer.
3492 ;;!!! That happens to be true with Gnus now, but that may
3493 ;;!!! change in the future. Perhaps.
3494 (gnus-data-enter-list
3495 (if line nil current) data (- (point) old-pos))
3496 (setq gnus-newsgroup-threads
3497 (nconc threads gnus-newsgroup-threads))
3498 (gnus-data-compute-positions))))
3500 (defun gnus-number-to-header (number)
3501 "Return the header for article NUMBER."
3502 (let ((headers gnus-newsgroup-headers))
3504 (not (= number (mail-header-number (car headers)))))
3509 (defun gnus-parent-headers (in-headers &optional generation)
3510 "Return the headers of the GENERATIONeth parent of HEADERS."
3512 (setq generation 1))
3514 (headers in-headers)
3517 (not (zerop generation))
3518 (setq references (mail-header-references headers)))
3519 (setq headers (if (and references
3520 (setq parent (gnus-parent-id references)))
3521 (car (gnus-id-to-thread parent))
3524 (and (not (eq headers in-headers))
3527 (defun gnus-id-to-thread (id)
3528 "Return the (sub-)thread where ID appears."
3529 (gnus-gethash id gnus-newsgroup-dependencies))
3531 (defun gnus-id-to-article (id)
3532 "Return the article number of ID."
3533 (let ((thread (gnus-id-to-thread id)))
3536 (mail-header-number (car thread)))))
3538 (defun gnus-id-to-header (id)
3539 "Return the article headers of ID."
3540 (car (gnus-id-to-thread id)))
3542 (defun gnus-article-displayed-root-p (article)
3543 "Say whether ARTICLE is a root(ish) article."
3544 (let ((level (gnus-summary-thread-level article))
3545 (refs (mail-header-references (gnus-summary-article-header article)))
3551 ((null (gnus-parent-id refs)) t)
3553 (null (setq particle (gnus-id-to-article
3554 (gnus-parent-id refs))))
3555 (null (gnus-summary-thread-level particle)))))))
3557 (defun gnus-root-id (id)
3558 "Return the id of the root of the thread where ID appears."
3560 (while (and id (setq prev (car (gnus-id-to-thread id))))
3562 id (gnus-parent-id (mail-header-references prev))))
3565 (defun gnus-articles-in-thread (thread)
3566 "Return the list of articles in THREAD."
3567 (cons (mail-header-number (car thread))
3568 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3570 (defun gnus-remove-thread (id &optional dont-remove)
3571 "Remove the thread that has ID in it."
3572 (let (headers thread last-id)
3573 ;; First go up in this thread until we find the root.
3574 (setq last-id (gnus-root-id id)
3575 headers (message-flatten-list (gnus-id-to-thread last-id)))
3576 ;; We have now found the real root of this thread. It might have
3577 ;; been gathered into some loose thread, so we have to search
3578 ;; through the threads to find the thread we wanted.
3579 (let ((threads gnus-newsgroup-threads)
3582 (setq sub (car threads))
3583 (if (stringp (car sub))
3584 ;; This is a gathered thread, so we look at the roots
3585 ;; below it to find whether this article is in this
3588 (setq sub (cdr sub))
3590 (when (member (caar sub) headers)
3591 (setq thread (car threads)
3594 (setq sub (cdr sub))))
3595 ;; It's an ordinary thread, so we check it.
3596 (when (eq (car sub) (car headers))
3599 (setq threads (cdr threads)))
3600 ;; If this article is in no thread, then it's a root.
3603 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3604 (setq thread (gnus-id-to-thread last-id)))
3607 thread ; We return this thread.
3609 (if (stringp (car thread))
3611 ;; If we use dummy roots, then we have to remove the
3612 ;; dummy root as well.
3613 (when (eq gnus-summary-make-false-root 'dummy)
3614 ;; We go to the dummy root by going to
3615 ;; the first sub-"thread", and then one line up.
3616 (gnus-summary-goto-article
3617 (mail-header-number (caadr thread)))
3620 (gnus-data-compute-positions))
3621 (setq thread (cdr thread))
3623 (gnus-remove-thread-1 (car thread))
3624 (setq thread (cdr thread))))
3625 (gnus-summary-show-all-threads)
3626 (gnus-remove-thread-1 thread))))))))
3628 (defun gnus-remove-thread-1 (thread)
3629 "Remove the thread THREAD recursively."
3630 (let ((number (mail-header-number (pop thread)))
3632 (setq thread (reverse thread))
3634 (gnus-remove-thread-1 (pop thread)))
3635 (when (setq d (gnus-data-find number))
3636 (goto-char (gnus-data-pos d))
3639 (- (gnus-point-at-bol)
3641 (1+ (gnus-point-at-eol))
3642 (gnus-delete-line)))))))
3644 (defun gnus-sort-threads (threads)
3646 (if (not gnus-thread-sort-functions)
3648 (gnus-message 8 "Sorting threads...")
3650 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3651 (gnus-message 8 "Sorting threads...done"))))
3653 (defun gnus-sort-articles (articles)
3655 (when gnus-article-sort-functions
3656 (gnus-message 7 "Sorting articles...")
3658 (setq gnus-newsgroup-headers
3659 (sort articles (gnus-make-sort-function
3660 gnus-article-sort-functions)))
3661 (gnus-message 7 "Sorting articles...done"))))
3663 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3664 (defmacro gnus-thread-header (thread)
3665 ;; Return header of first article in THREAD.
3666 ;; Note that THREAD must never, ever be anything else than a variable -
3667 ;; using some other form will lead to serious barfage.
3668 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3669 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3670 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3673 (defsubst gnus-article-sort-by-number (h1 h2)
3674 "Sort articles by article number."
3675 (< (mail-header-number h1)
3676 (mail-header-number h2)))
3678 (defun gnus-thread-sort-by-number (h1 h2)
3679 "Sort threads by root article number."
3680 (gnus-article-sort-by-number
3681 (gnus-thread-header h1) (gnus-thread-header h2)))
3683 (defsubst gnus-article-sort-by-lines (h1 h2)
3684 "Sort articles by article Lines header."
3685 (< (mail-header-lines h1)
3686 (mail-header-lines h2)))
3688 (defun gnus-thread-sort-by-lines (h1 h2)
3689 "Sort threads by root article Lines header."
3690 (gnus-article-sort-by-lines
3691 (gnus-thread-header h1) (gnus-thread-header h2)))
3693 (defsubst gnus-article-sort-by-chars (h1 h2)
3694 "Sort articles by octet length."
3695 (< (mail-header-chars h1)
3696 (mail-header-chars h2)))
3698 (defun gnus-thread-sort-by-chars (h1 h2)
3699 "Sort threads by root article octet length."
3700 (gnus-article-sort-by-chars
3701 (gnus-thread-header h1) (gnus-thread-header h2)))
3703 (defsubst gnus-article-sort-by-author (h1 h2)
3704 "Sort articles by root author."
3706 (let ((addr (car (mime-entity-read-field h1 'From))))
3707 (or (std11-full-name-string addr)
3708 (std11-address-string addr)
3710 (let ((addr (car (mime-entity-read-field h2 'From))))
3711 (or (std11-full-name-string addr)
3712 (std11-address-string addr)
3716 (defun gnus-thread-sort-by-author (h1 h2)
3717 "Sort threads by root author."
3718 (gnus-article-sort-by-author
3719 (gnus-thread-header h1) (gnus-thread-header h2)))
3721 (defsubst gnus-article-sort-by-subject (h1 h2)
3722 "Sort articles by root subject."
3724 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3725 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3727 (defun gnus-thread-sort-by-subject (h1 h2)
3728 "Sort threads by root subject."
3729 (gnus-article-sort-by-subject
3730 (gnus-thread-header h1) (gnus-thread-header h2)))
3732 (defsubst gnus-article-sort-by-date (h1 h2)
3733 "Sort articles by root article date."
3735 (gnus-date-get-time (mail-header-date h1))
3736 (gnus-date-get-time (mail-header-date h2))))
3738 (defun gnus-thread-sort-by-date (h1 h2)
3739 "Sort threads by root article date."
3740 (gnus-article-sort-by-date
3741 (gnus-thread-header h1) (gnus-thread-header h2)))
3743 (defsubst gnus-article-sort-by-score (h1 h2)
3744 "Sort articles by root article score.
3745 Unscored articles will be counted as having a score of zero."
3746 (> (or (cdr (assq (mail-header-number h1)
3747 gnus-newsgroup-scored))
3748 gnus-summary-default-score 0)
3749 (or (cdr (assq (mail-header-number h2)
3750 gnus-newsgroup-scored))
3751 gnus-summary-default-score 0)))
3753 (defun gnus-thread-sort-by-score (h1 h2)
3754 "Sort threads by root article score."
3755 (gnus-article-sort-by-score
3756 (gnus-thread-header h1) (gnus-thread-header h2)))
3758 (defun gnus-thread-sort-by-total-score (h1 h2)
3759 "Sort threads by the sum of all scores in the thread.
3760 Unscored articles will be counted as having a score of zero."
3761 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3763 (defun gnus-thread-total-score (thread)
3764 ;; This function find the total score of THREAD.
3765 (cond ((null thread)
3768 (if (stringp (car thread))
3769 (apply gnus-thread-score-function 0
3770 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3771 (gnus-thread-total-score-1 thread)))
3773 (gnus-thread-total-score-1 (list thread)))))
3775 (defun gnus-thread-total-score-1 (root)
3776 ;; This function find the total score of the thread below ROOT.
3777 (setq root (car root))
3778 (apply gnus-thread-score-function
3780 (mapcar 'gnus-thread-total-score
3781 (cdr (gnus-id-to-thread (mail-header-id root))))
3782 (when (> (mail-header-number root) 0)
3783 (list (or (cdr (assq (mail-header-number root)
3784 gnus-newsgroup-scored))
3785 gnus-summary-default-score 0))))
3786 (list gnus-summary-default-score)
3789 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3790 (defvar gnus-tmp-prev-subject nil)
3791 (defvar gnus-tmp-false-parent nil)
3792 (defvar gnus-tmp-root-expunged nil)
3793 (defvar gnus-tmp-dummy-line nil)
3795 (defvar gnus-tmp-header)
3796 (defun gnus-extra-header (type &optional header)
3797 "Return the extra header of TYPE."
3798 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3801 (defun gnus-summary-prepare-threads (threads)
3802 "Prepare summary buffer from THREADS and indentation LEVEL.
3803 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3804 or a straight list of headers."
3805 (gnus-message 7 "Generating summary...")
3807 (setq gnus-newsgroup-threads threads)
3810 (let ((gnus-tmp-level 0)
3811 (default-score (or gnus-summary-default-score 0))
3812 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3813 thread number subject stack state gnus-tmp-gathered beg-match
3814 new-roots gnus-tmp-new-adopts thread-end
3815 gnus-tmp-header gnus-tmp-unread
3816 gnus-tmp-replied gnus-tmp-subject-or-nil
3817 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3818 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3819 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3821 (setq gnus-tmp-prev-subject nil)
3823 (if (vectorp (car threads))
3824 ;; If this is a straight (sic) list of headers, then a
3825 ;; threaded summary display isn't required, so we just create
3826 ;; an unthreaded one.
3827 (gnus-summary-prepare-unthreaded threads)
3829 ;; Do the threaded display.
3831 (while (or threads stack gnus-tmp-new-adopts new-roots)
3833 (if (and (= gnus-tmp-level 0)
3836 (not gnus-tmp-false-parent)
3837 (or gnus-tmp-new-adopts new-roots))
3838 (if gnus-tmp-new-adopts
3839 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3840 thread (list (car gnus-tmp-new-adopts))
3841 gnus-tmp-header (caar thread)
3842 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3844 (setq thread (list (car new-roots))
3845 gnus-tmp-header (caar thread)
3846 new-roots (cdr new-roots))))
3849 ;; If there are some threads, we do them before the
3850 ;; threads on the stack.
3851 (setq thread threads
3852 gnus-tmp-header (caar thread))
3853 ;; There were no current threads, so we pop something off
3855 (setq state (car stack)
3856 gnus-tmp-level (car state)
3859 gnus-tmp-header (caar thread))))
3861 (setq gnus-tmp-false-parent nil)
3862 (setq gnus-tmp-root-expunged nil)
3863 (setq thread-end nil)
3865 (if (stringp gnus-tmp-header)
3866 ;; The header is a dummy root.
3868 ((eq gnus-summary-make-false-root 'adopt)
3869 ;; We let the first article adopt the rest.
3870 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3872 (setq gnus-tmp-gathered
3874 (lambda (h) (mail-header-number (car h)))
3877 (setq thread (cons (list (caar thread)
3880 (setq gnus-tmp-level -1
3881 gnus-tmp-false-parent t))
3882 ((eq gnus-summary-make-false-root 'empty)
3883 ;; We print adopted articles with empty subject fields.
3884 (setq gnus-tmp-gathered
3886 (lambda (h) (mail-header-number (car h)))
3889 (setq gnus-tmp-level -1))
3890 ((eq gnus-summary-make-false-root 'dummy)
3891 ;; We remember that we probably want to output a dummy
3893 (setq gnus-tmp-dummy-line gnus-tmp-header)
3894 (setq gnus-tmp-prev-subject gnus-tmp-header))
3896 ;; We do not make a root for the gathered
3897 ;; sub-threads at all.
3898 (setq gnus-tmp-level -1)))
3900 (setq number (mail-header-number gnus-tmp-header)
3901 subject (mail-header-subject gnus-tmp-header))
3904 ;; If the thread has changed subject, we might want to make
3905 ;; this subthread into a root.
3906 ((and (null gnus-thread-ignore-subject)
3907 (not (zerop gnus-tmp-level))
3908 gnus-tmp-prev-subject
3910 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3911 (setq new-roots (nconc new-roots (list (car thread)))
3913 gnus-tmp-header nil))
3914 ;; If the article lies outside the current limit,
3915 ;; then we do not display it.
3916 ((not (memq number gnus-newsgroup-limit))
3917 (setq gnus-tmp-gathered
3919 (lambda (h) (mail-header-number (car h)))
3922 (setq gnus-tmp-new-adopts (if (cdar thread)
3923 (append gnus-tmp-new-adopts
3925 gnus-tmp-new-adopts)
3927 gnus-tmp-header nil)
3928 (when (zerop gnus-tmp-level)
3929 (setq gnus-tmp-root-expunged t)))
3930 ;; Perhaps this article is to be marked as read?
3931 ((and gnus-summary-mark-below
3932 (< (or (cdr (assq number gnus-newsgroup-scored))
3934 gnus-summary-mark-below)
3935 ;; Don't touch sparse articles.
3936 (not (gnus-summary-article-sparse-p number))
3937 (not (gnus-summary-article-ancient-p number)))
3938 (setq gnus-newsgroup-unreads
3939 (delq number gnus-newsgroup-unreads))
3940 (if gnus-newsgroup-auto-expire
3941 (push number gnus-newsgroup-expirable)
3942 (push (cons number gnus-low-score-mark)
3943 gnus-newsgroup-reads))))
3945 (when gnus-tmp-header
3946 ;; We may have an old dummy line to output before this
3948 (when (and gnus-tmp-dummy-line
3951 (mail-header-subject gnus-tmp-header)))
3952 (gnus-summary-insert-dummy-line
3953 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3954 (setq gnus-tmp-dummy-line nil))
3956 ;; Compute the mark.
3957 (setq gnus-tmp-unread (gnus-article-mark number))
3959 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3960 gnus-tmp-header gnus-tmp-level)
3961 gnus-newsgroup-data)
3963 ;; Actually insert the line.
3965 gnus-tmp-subject-or-nil
3967 ((and gnus-thread-ignore-subject
3968 gnus-tmp-prev-subject
3969 (not (inline (gnus-subject-equal
3970 gnus-tmp-prev-subject subject))))
3972 ((zerop gnus-tmp-level)
3973 (if (and (eq gnus-summary-make-false-root 'empty)
3974 (memq number gnus-tmp-gathered)
3975 gnus-tmp-prev-subject
3976 (inline (gnus-subject-equal
3977 gnus-tmp-prev-subject subject)))
3978 gnus-summary-same-subject
3980 (t gnus-summary-same-subject)))
3981 (if (and (eq gnus-summary-make-false-root 'adopt)
3982 (= gnus-tmp-level 1)
3983 (memq number gnus-tmp-gathered))
3984 (setq gnus-tmp-opening-bracket ?\<
3985 gnus-tmp-closing-bracket ?\>)
3986 (setq gnus-tmp-opening-bracket ?\[
3987 gnus-tmp-closing-bracket ?\]))
3989 gnus-tmp-indentation
3990 (aref gnus-thread-indent-array gnus-tmp-level)
3991 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3992 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3993 gnus-summary-default-score 0)
3995 (if (or (null gnus-summary-default-score)
3996 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3997 gnus-summary-zcore-fuzz))
3999 (if (< gnus-tmp-score gnus-summary-default-score)
4000 gnus-score-below-mark gnus-score-over-mark))
4002 (cond ((memq number gnus-newsgroup-processable)
4004 ((memq number gnus-newsgroup-cached)
4006 ((memq number gnus-newsgroup-replied)
4008 ((memq number gnus-newsgroup-saved)
4010 (t gnus-unread-mark))
4011 gnus-tmp-from (mail-header-from gnus-tmp-header)
4014 ((string-match "<[^>]+> *$" gnus-tmp-from)
4015 (setq beg-match (match-beginning 0))
4016 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4017 (substring gnus-tmp-from (1+ (match-beginning 0))
4018 (1- (match-end 0))))
4019 (substring gnus-tmp-from 0 beg-match)))
4020 ((string-match "(.+)" gnus-tmp-from)
4021 (substring gnus-tmp-from
4022 (1+ (match-beginning 0)) (1- (match-end 0))))
4024 (when (string= gnus-tmp-name "")
4025 (setq gnus-tmp-name gnus-tmp-from))
4026 (unless (numberp gnus-tmp-lines)
4027 (setq gnus-tmp-lines 0))
4028 (gnus-put-text-property
4030 (progn (eval gnus-summary-line-format-spec) (point))
4031 'gnus-number number)
4034 (gnus-run-hooks 'gnus-summary-update-hook)
4037 (setq gnus-tmp-prev-subject subject)))
4039 (when (nth 1 thread)
4040 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4041 (incf gnus-tmp-level)
4042 (setq threads (if thread-end nil (cdar thread)))
4044 (setq gnus-tmp-level 0)))))
4045 (gnus-message 7 "Generating summary...done"))
4047 (defun gnus-summary-prepare-unthreaded (headers)
4048 "Generate an unthreaded summary buffer based on HEADERS."
4049 (let (header number mark)
4054 ;; We may have to root out some bad articles...
4055 (when (memq (setq number (mail-header-number
4056 (setq header (pop headers))))
4057 gnus-newsgroup-limit)
4058 ;; Mark article as read when it has a low score.
4059 (when (and gnus-summary-mark-below
4060 (< (or (cdr (assq number gnus-newsgroup-scored))
4061 gnus-summary-default-score 0)
4062 gnus-summary-mark-below)
4063 (not (gnus-summary-article-ancient-p number)))
4064 (setq gnus-newsgroup-unreads
4065 (delq number gnus-newsgroup-unreads))
4066 (if gnus-newsgroup-auto-expire
4067 (push number gnus-newsgroup-expirable)
4068 (push (cons number gnus-low-score-mark)
4069 gnus-newsgroup-reads)))
4071 (setq mark (gnus-article-mark number))
4072 (push (gnus-data-make number mark (1+ (point)) header 0)
4073 gnus-newsgroup-data)
4074 (gnus-summary-insert-line
4076 mark (memq number gnus-newsgroup-replied)
4077 (memq number gnus-newsgroup-expirable)
4078 (mail-header-subject header) nil
4079 (cdr (assq number gnus-newsgroup-scored))
4080 (memq number gnus-newsgroup-processable))))))
4082 (defun gnus-summary-remove-list-identifiers ()
4083 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4084 (let ((regexp (if (stringp gnus-list-identifiers)
4085 gnus-list-identifiers
4086 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4087 (dolist (header gnus-newsgroup-headers)
4088 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4089 (mail-header-subject header))
4090 (mail-header-set-subject
4091 header (concat (substring (mail-header-subject header)
4092 0 (match-beginning 2))
4093 (substring (mail-header-subject header)
4094 (match-end 2))))))))
4096 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4097 "Select newsgroup GROUP.
4098 If READ-ALL is non-nil, all articles in the group are selected.
4099 If SELECT-ARTICLES, only select those articles from GROUP."
4100 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4101 ;;!!! Dirty hack; should be removed.
4102 (gnus-summary-ignore-duplicates
4103 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4105 gnus-summary-ignore-duplicates))
4106 (info (nth 2 entry))
4107 articles fetched-articles cached)
4109 (unless (gnus-check-server
4110 (setq gnus-current-select-method
4111 (gnus-find-method-for-group group)))
4112 (error "Couldn't open server"))
4114 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4115 (gnus-activate-group group) ; Or we can activate it...
4116 (progn ; Or we bug out.
4117 (when (equal major-mode 'gnus-summary-mode)
4118 (kill-buffer (current-buffer)))
4119 (error "Couldn't request group %s: %s"
4120 group (gnus-status-message group))))
4122 (unless (gnus-request-group group t)
4123 (when (equal major-mode 'gnus-summary-mode)
4124 (kill-buffer (current-buffer)))
4125 (error "Couldn't request group %s: %s"
4126 group (gnus-status-message group)))
4128 (setq gnus-newsgroup-name group)
4129 (setq gnus-newsgroup-unselected nil)
4130 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4131 (gnus-summary-setup-default-charset)
4133 ;; Adjust and set lists of article marks.
4135 (gnus-adjust-marked-articles info))
4137 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4139 (if (gnus-virtual-group-p group)
4140 gnus-newsgroup-cached
4141 (gnus-cache-articles-in-group group)))
4143 (setq gnus-newsgroup-unreads
4144 (gnus-set-difference
4145 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4146 gnus-newsgroup-dormant))
4148 (setq gnus-newsgroup-processable nil)
4150 (gnus-update-read-articles group gnus-newsgroup-unreads)
4152 (if (setq articles select-articles)
4153 (setq gnus-newsgroup-unselected
4154 (gnus-sorted-intersection
4155 gnus-newsgroup-unreads
4156 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4157 (setq articles (gnus-articles-to-read group read-all)))
4161 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4163 ((eq articles 0) nil)
4165 ;; Init the dependencies hash table.
4166 (setq gnus-newsgroup-dependencies
4167 (gnus-make-hashtable (length articles)))
4168 (gnus-set-global-variables)
4169 ;; Retrieve the headers and read them in.
4170 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4171 (setq gnus-newsgroup-headers
4172 (gnus-retrieve-parsed-headers
4173 articles gnus-newsgroup-name
4174 ;; We might want to fetch old headers, but
4175 ;; not if there is only 1 article.
4176 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4177 (not (numberp gnus-fetch-old-headers)))
4178 (> (length articles) 1))
4179 gnus-fetch-old-headers)))
4180 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4182 ;; Suppress duplicates?
4183 (when gnus-suppress-duplicates
4184 (gnus-dup-suppress-articles))
4186 ;; Set the initial limit.
4187 (setq gnus-newsgroup-limit (copy-sequence articles))
4188 ;; Remove canceled articles from the list of unread articles.
4189 (setq gnus-newsgroup-unreads
4190 (gnus-set-sorted-intersection
4191 gnus-newsgroup-unreads
4192 (setq fetched-articles
4193 (mapcar (lambda (headers) (mail-header-number headers))
4194 gnus-newsgroup-headers))))
4195 ;; Removed marked articles that do not exist.
4196 (gnus-update-missing-marks
4197 (gnus-sorted-complement fetched-articles articles))
4199 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4201 (setq gnus-newsgroup-cached cached))
4203 ;; We might want to build some more threads first.
4204 (when (and gnus-fetch-old-headers
4205 (eq gnus-headers-retrieved-by 'nov))
4206 (if (eq gnus-fetch-old-headers 'invisible)
4207 (gnus-build-all-threads)
4208 (gnus-build-old-threads)))
4209 ;; Let the Gnus agent mark articles as read.
4211 (gnus-agent-get-undownloaded-list))
4212 ;; Remove list identifiers from subject
4213 (when gnus-list-identifiers
4214 (gnus-summary-remove-list-identifiers))
4215 ;; Check whether auto-expire is to be done in this group.
4216 (setq gnus-newsgroup-auto-expire
4217 (gnus-group-auto-expirable-p group))
4218 ;; Set up the article buffer now, if necessary.
4219 (unless gnus-single-article-buffer
4220 (gnus-article-setup-buffer))
4221 ;; First and last article in this newsgroup.
4222 (when gnus-newsgroup-headers
4223 (setq gnus-newsgroup-begin
4224 (mail-header-number (car gnus-newsgroup-headers))
4227 (gnus-last-element gnus-newsgroup-headers))))
4228 ;; GROUP is successfully selected.
4229 (or gnus-newsgroup-headers t)))))
4231 (defun gnus-articles-to-read (group &optional read-all)
4232 ;; Find out what articles the user wants to read.
4234 ;; Select all articles if `read-all' is non-nil, or if there
4235 ;; are no unread articles.
4237 (and (zerop (length gnus-newsgroup-marked))
4238 (zerop (length gnus-newsgroup-unreads)))
4239 (eq (gnus-group-find-parameter group 'display)
4242 (gnus-uncompress-range (gnus-active group))
4243 (gnus-cache-articles-in-group group))
4244 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4245 (copy-sequence gnus-newsgroup-unreads))
4247 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4248 (scored (length scored-list))
4249 (number (length articles))
4250 (marked (+ (length gnus-newsgroup-marked)
4251 (length gnus-newsgroup-dormant)))
4259 ((and (or (<= scored marked) (= scored number))
4260 (natnump gnus-large-newsgroup)
4261 (> number gnus-large-newsgroup))
4262 (let* ((cursor-in-echo-area nil)
4263 (input (read-from-minibuffer
4265 "How many articles from %s (max %d): "
4266 (gnus-limit-string gnus-newsgroup-name 35)
4268 (cons (number-to-string gnus-large-newsgroup)
4270 (if (string-match "^[ \t]*$" input)
4273 ((and (> scored marked) (< scored number)
4274 (> (- scored number) 20))
4277 (format "%s %s (%d scored, %d total): "
4278 "How many articles from"
4279 group scored number))))
4280 (if (string-match "^[ \t]*$" input)
4284 (setq select (if (stringp select) (string-to-number select) select))
4285 (if (or (null select) (zerop select))
4287 (if (and (not (zerop scored)) (<= (abs select) scored))
4289 (setq articles (sort scored-list '<))
4290 (setq number (length articles)))
4291 (setq articles (copy-sequence articles)))
4293 (when (< (abs select) number)
4295 ;; Select the N oldest articles.
4296 (setcdr (nthcdr (1- (abs select)) articles) nil)
4297 ;; Select the N most recent articles.
4298 (setq articles (nthcdr (- number select) articles))))
4299 (setq gnus-newsgroup-unselected
4300 (gnus-sorted-intersection
4301 gnus-newsgroup-unreads
4302 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4305 (defun gnus-killed-articles (killed articles)
4308 (when (inline (gnus-member-of-range (car articles) killed))
4309 (push (car articles) out))
4310 (setq articles (cdr articles)))
4313 (defun gnus-uncompress-marks (marks)
4314 "Uncompress the mark ranges in MARKS."
4315 (let ((uncompressed '(score bookmark))
4318 (if (memq (caar marks) uncompressed)
4319 (push (car marks) out)
4320 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4321 (setq marks (cdr marks)))
4324 (defun gnus-adjust-marked-articles (info)
4325 "Set all article lists and remove all marks that are no longer valid."
4326 (let* ((marked-lists (gnus-info-marks info))
4327 (active (gnus-active (gnus-info-group info)))
4330 (types gnus-article-mark-lists)
4331 (uncompressed '(score bookmark killed))
4332 marks var articles article mark)
4335 (setq marks (pop marked-lists))
4336 (set (setq var (intern (format "gnus-newsgroup-%s"
4337 (car (rassq (setq mark (car marks))
4339 (if (memq (car marks) uncompressed) (cdr marks)
4340 (gnus-uncompress-range (cdr marks))))
4342 (setq articles (symbol-value var))
4344 ;; All articles have to be subsets of the active articles.
4346 ;; Adjust "simple" lists.
4347 ((memq mark '(tick dormant expire reply save))
4349 (when (or (< (setq article (pop articles)) min) (> article max))
4350 (set var (delq article (symbol-value var))))))
4352 ((memq mark uncompressed)
4353 (when (not (listp (cdr (symbol-value var))))
4354 (set var (list (symbol-value var))))
4355 (when (not (listp (cdr articles)))
4356 (setq articles (list articles)))
4358 (when (or (not (consp (setq article (pop articles))))
4359 (< (car article) min)
4360 (> (car article) max))
4361 (set var (delq article (symbol-value var))))))))))
4363 (defun gnus-update-missing-marks (missing)
4364 "Go through the list of MISSING articles and remove them from the mark lists."
4366 (let ((types gnus-article-mark-lists)
4368 ;; Go through all types.
4370 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4371 (when (symbol-value var)
4372 ;; This list has articles. So we delete all missing articles
4376 (set var (delq (pop m) (symbol-value var)))))))))
4378 (defun gnus-update-marks ()
4379 "Enter the various lists of marked articles into the newsgroup info list."
4380 (let ((types gnus-article-mark-lists)
4381 (info (gnus-get-info gnus-newsgroup-name))
4382 (uncompressed '(score bookmark killed))
4383 type list newmarked symbol delta-marks)
4385 ;; Add all marks lists to the list of marks lists.
4386 (while (setq type (pop types))
4387 (setq list (symbol-value
4389 (intern (format "gnus-newsgroup-%s"
4393 ;; Get rid of the entries of the articles that have the
4395 (when (and (eq (cdr type) 'score)
4399 (prev (cons nil list))
4402 (if (or (not (consp (car arts)))
4403 (= (cdar arts) gnus-summary-default-score))
4404 (setcdr prev (cdr arts))
4406 (setq arts (cdr arts)))
4407 (setq list (cdr all)))))
4409 (unless (memq (cdr type) uncompressed)
4410 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4412 (when (gnus-check-backend-function
4413 'request-set-mark gnus-newsgroup-name)
4414 ;; uncompressed:s are not proper flags (they are cons cells)
4415 ;; cache is a internal gnus flag
4416 (unless (memq (cdr type) (cons 'cache uncompressed))
4417 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4418 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4419 (add (gnus-remove-from-range
4420 (gnus-copy-sequence list) old)))
4422 (push (list add 'add (list (cdr type))) delta-marks))
4424 (push (list del 'del (list (cdr type))) delta-marks)))))
4427 (push (cons (cdr type) list) newmarked)))
4430 (unless (gnus-check-group gnus-newsgroup-name)
4431 (error "Can't open server for %s" gnus-newsgroup-name))
4432 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4434 ;; Enter these new marks into the info of the group.
4436 (setcar (nthcdr 3 info) newmarked)
4437 ;; Add the marks lists to the end of the info.
4439 (setcdr (nthcdr 2 info) (list newmarked))))
4441 ;; Cut off the end of the info if there's nothing else there.
4445 (when (nthcdr (decf i) info)
4446 (setcdr (nthcdr i info) nil)))))))
4448 (defun gnus-set-mode-line (where)
4449 "This function sets the mode line of the article or summary buffers.
4450 If WHERE is `summary', the summary mode line format will be used."
4451 ;; Is this mode line one we keep updated?
4452 (when (and (memq where gnus-updated-mode-lines)
4454 (intern (format "gnus-%s-mode-line-format-spec" where))))
4457 ;; We evaluate this in the summary buffer since these
4458 ;; variables are buffer-local to that buffer.
4459 (set-buffer gnus-summary-buffer)
4460 ;; We bind all these variables that are used in the `eval' form
4462 (let* ((mformat (symbol-value
4464 (format "gnus-%s-mode-line-format-spec" where))))
4465 (gnus-tmp-group-name gnus-newsgroup-name)
4466 (gnus-tmp-article-number (or gnus-current-article 0))
4467 (gnus-tmp-unread gnus-newsgroup-unreads)
4468 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4469 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4470 (gnus-tmp-unread-and-unselected
4471 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4472 (zerop gnus-tmp-unselected))
4474 ((zerop gnus-tmp-unselected)
4475 (format "{%d more}" gnus-tmp-unread-and-unticked))
4476 (t (format "{%d(+%d) more}"
4477 gnus-tmp-unread-and-unticked
4478 gnus-tmp-unselected))))
4480 (if (and gnus-current-headers
4481 (vectorp gnus-current-headers))
4482 (gnus-mode-string-quote
4483 (mail-header-subject gnus-current-headers))
4485 bufname-length max-len
4486 gnus-tmp-header);; passed as argument to any user-format-funcs
4487 (setq mode-string (eval mformat))
4488 (setq bufname-length (if (string-match "%b" mode-string)
4491 (if (eq where 'summary)
4493 (get-buffer gnus-article-buffer))))
4496 (setq max-len (max 4 (if gnus-mode-non-string-length
4498 gnus-mode-non-string-length
4500 (length mode-string))))
4501 ;; We might have to chop a bit of the string off...
4502 (when (> (length mode-string) max-len)
4504 (concat (gnus-truncate-string mode-string (- max-len 3))
4506 ;; Pad the mode string a bit.
4507 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4508 ;; Update the mode line.
4509 (setq mode-line-buffer-identification
4510 (gnus-mode-line-buffer-identification (list mode-string)))
4511 (set-buffer-modified-p t))))
4513 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4514 "Go through the HEADERS list and add all Xrefs to a hash table.
4515 The resulting hash table is returned, or nil if no Xrefs were found."
4516 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4517 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4518 (xref-hashtb (gnus-make-hashtable))
4519 start group entry number xrefs header)
4521 (setq header (pop headers))
4522 (when (and (setq xrefs (mail-header-xref header))
4523 (not (memq (setq number (mail-header-number header))
4526 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4527 (setq start (match-end 0))
4528 (setq group (if prefix
4529 (concat prefix (substring xrefs (match-beginning 1)
4531 (substring xrefs (match-beginning 1) (match-end 1))))
4533 (string-to-int (substring xrefs (match-beginning 2)
4535 (if (setq entry (gnus-gethash group xref-hashtb))
4536 (setcdr entry (cons number (cdr entry)))
4537 (gnus-sethash group (cons number nil) xref-hashtb)))))
4538 (and start xref-hashtb)))
4540 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4541 "Look through all the headers and mark the Xrefs as read."
4542 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4543 name entry info xref-hashtb idlist method nth4)
4545 (set-buffer gnus-group-buffer)
4546 (when (setq xref-hashtb
4547 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4550 (unless (string= from-newsgroup (setq name (symbol-name group)))
4551 (setq idlist (symbol-value group))
4552 ;; Dead groups are not updated.
4554 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4556 (when (stringp (setq nth4 (gnus-info-method info)))
4557 (setq nth4 (gnus-server-to-method nth4))))
4558 ;; Only do the xrefs if the group has the same
4559 ;; select method as the group we have just read.
4560 (or (gnus-methods-equal-p
4561 nth4 (gnus-find-method-for-group from-newsgroup))
4563 (equal nth4 (setq method (gnus-find-method-for-group
4565 (and (equal (car nth4) (car method))
4566 (equal (nth 1 nth4) (nth 1 method))))
4567 gnus-use-cross-reference
4568 (or (not (eq gnus-use-cross-reference t))
4570 ;; Only do cross-references on subscribed
4571 ;; groups, if that is what is wanted.
4572 (<= (gnus-info-level info) gnus-level-subscribed))
4573 (gnus-group-make-articles-read name idlist))))
4576 (defun gnus-compute-read-articles (group articles)
4577 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4578 (info (nth 2 entry))
4579 (active (gnus-active group))
4582 ;; First peel off all invalid article numbers.
4584 (let ((ids articles)
4586 (while (setq id (pop ids))
4587 (when (and first (> id (cdr active)))
4588 ;; We'll end up in this situation in one particular
4589 ;; obscure situation. If you re-scan a group and get
4590 ;; a new article that is cross-posted to a different
4591 ;; group that has not been re-scanned, you might get
4592 ;; crossposted article that has a higher number than
4593 ;; Gnus believes possible. So we re-activate this
4594 ;; group as well. This might mean doing the
4595 ;; crossposting thingy will *increase* the number
4596 ;; of articles in some groups. Tsk, tsk.
4597 (setq active (or (gnus-activate-group group) active)))
4598 (when (or (> id (cdr active))
4599 (< id (car active)))
4600 (setq articles (delq id articles))))))
4601 ;; If the read list is nil, we init it.
4603 (null (gnus-info-read info))
4605 (setq ninfo (cons 1 (1- (car active))))
4606 (setq ninfo (gnus-info-read info)))
4607 ;; Then we add the read articles to the range.
4609 ninfo (setq articles (sort articles '<))))))
4611 (defun gnus-group-make-articles-read (group articles)
4612 "Update the info of GROUP to say that ARTICLES are read."
4614 (entry (gnus-gethash group gnus-newsrc-hashtb))
4615 (info (nth 2 entry))
4616 (active (gnus-active group))
4619 (setq range (gnus-compute-read-articles group articles))
4621 (set-buffer gnus-group-buffer)
4624 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4625 (gnus-info-set-read ',info ',(gnus-info-read info))
4626 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4627 (gnus-group-update-group ,group t))))
4628 ;; Add the read articles to the range.
4629 (gnus-info-set-read info range)
4630 ;; Then we have to re-compute how many unread
4631 ;; articles there are in this group.
4635 (setq num (- (1+ (cdr active)) (car active))))
4636 ((not (listp (cdr range)))
4637 (setq num (- (cdr active) (- (1+ (cdr range))
4641 (if (numberp (car range))
4643 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4644 (setq range (cdr range)))
4645 (setq num (- (cdr active) num))))
4646 ;; Update the number of unread articles.
4648 ;; Update the group buffer.
4649 (gnus-group-update-group group t)))))
4651 (defvar gnus-newsgroup-none-id 0)
4653 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4654 (let ((cur nntp-server-buffer)
4657 (save-excursion (set-buffer gnus-summary-buffer)
4658 gnus-newsgroup-dependencies)))
4660 (mail-parse-charset gnus-newsgroup-charset)
4661 (mail-parse-ignored-charsets
4662 (save-excursion (condition-case nil
4663 (set-buffer gnus-summary-buffer)
4665 gnus-newsgroup-ignored-charsets)))
4667 (set-buffer nntp-server-buffer)
4668 ;; Translate all TAB characters into SPACE characters.
4669 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4670 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4671 (gnus-run-hooks 'gnus-parse-headers-hook)
4672 (let ((case-fold-search t)
4673 in-reply-to header p lines chars ctype)
4674 (goto-char (point-min))
4675 ;; Search to the beginning of the next header. Error messages
4676 ;; do not begin with 2 or 3.
4677 (while (re-search-forward "^[23][0-9]+ " nil t)
4680 ;; This implementation of this function, with nine
4681 ;; search-forwards instead of the one re-search-forward and
4682 ;; a case (which basically was the old function) is actually
4683 ;; about twice as fast, even though it looks messier. You
4684 ;; can't have everything, I guess. Speed and elegance
4685 ;; doesn't always go hand in hand.
4688 (make-full-mail-header
4694 (narrow-to-region (point)
4695 (or (and (search-forward "\n.\n" nil t)
4701 (if (search-forward "\nsubject: " nil t)
4702 (buffer-substring (match-end 0) (std11-field-end))
4707 (if (search-forward "\nfrom: " nil t)
4708 (buffer-substring (match-end 0) (std11-field-end))
4713 (if (search-forward "\ndate: " nil t)
4714 (buffer-substring (match-end 0) (std11-field-end))
4719 (setq id (if (re-search-forward
4720 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4721 ;; We do it this way to make sure the Message-ID
4722 ;; is (somewhat) syntactically valid.
4723 (buffer-substring (match-beginning 1)
4725 ;; If there was no message-id, we just fake one
4726 ;; to make subsequent routines simpler.
4727 (nnheader-generate-fake-message-id))))
4731 (if (search-forward "\nreferences: " nil t)
4735 (buffer-substring (match-end 0) (std11-field-end))
4740 (search-backward ">" end t)
4743 (search-backward "<" end t)
4745 ;; Get the references from the in-reply-to header if there
4746 ;; were no references and the in-reply-to header looks
4748 (if (and (search-forward "\nin-reply-to: " nil t)
4750 (buffer-substring (match-end 0)
4752 (string-match "<[^>]+>" in-reply-to))
4754 (setq ref (substring in-reply-to (match-beginning 0)
4756 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4757 (setq ref2 (substring in-reply-to (match-beginning 0)
4759 (when (> (length ref2) (length ref))
4766 (if (search-forward "\nchars: " nil t)
4767 (if (numberp (setq chars (ignore-errors (read cur))))
4773 (if (search-forward "\nlines: " nil t)
4774 (if (numberp (setq lines (ignore-errors (read cur))))
4780 (and (search-forward "\nxref: " nil t)
4781 (buffer-substring (match-end 0) (std11-field-end))))
4783 (when gnus-extra-headers
4784 (let ((extra gnus-extra-headers)
4788 (when (search-forward
4789 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4790 (push (cons (car extra)
4791 (buffer-substring (match-end 0)
4797 (if (and (search-forward "\ncontent-type: " nil t)
4799 (buffer-substring (match-end 0) (std11-field-end))))
4800 (mime-entity-set-content-type-internal
4801 header (mime-parse-Content-Type ctype)))
4802 (when (equal id ref)
4805 (when gnus-alter-header-function
4806 (funcall gnus-alter-header-function header)
4807 (setq id (mail-header-id header)
4808 ref (gnus-parent-id (mail-header-references header))))
4811 (gnus-dependencies-add-header
4812 header dependencies force-new))
4813 (push header headers))
4814 (goto-char (point-max))
4816 (nreverse headers)))))
4818 ;; Goes through the xover lines and returns a list of vectors
4819 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4820 force-new dependencies
4821 group also-fetch-heads)
4822 "Parse the news overview data in the server buffer, and return a
4823 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4824 ;; Get the Xref when the users reads the articles since most/some
4825 ;; NNTP servers do not include Xrefs when using XOVER.
4826 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4827 (let ((mail-parse-charset gnus-newsgroup-charset)
4828 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4829 (cur nntp-server-buffer)
4830 (dependencies (or dependencies gnus-newsgroup-dependencies))
4831 number headers header)
4833 (set-buffer nntp-server-buffer)
4834 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4835 ;; Allow the user to mangle the headers before parsing them.
4836 (gnus-run-hooks 'gnus-parse-headers-hook)
4837 (goto-char (point-min))
4840 (while (and sequence (not (eobp)))
4841 (setq number (read cur))
4842 (while (and sequence
4843 (< (car sequence) number))
4844 (setq sequence (cdr sequence)))
4846 (eq number (car sequence))
4848 (setq sequence (cdr sequence))
4849 (setq header (inline
4850 (gnus-nov-parse-line
4851 number dependencies force-new))))
4852 (push header headers))
4855 (gnus-error 4 "Strange nov line (%d)"
4856 (count-lines (point-min) (point)))))
4858 ;; A common bug in inn is that if you have posted an article and
4859 ;; then retrieves the active file, it will answer correctly --
4860 ;; the new article is included. However, a NOV entry for the
4861 ;; article may not have been generated yet, so this may fail.
4862 ;; We work around this problem by retrieving the last few
4863 ;; headers using HEAD.
4864 (if (or (not also-fetch-heads)
4866 ;; We (probably) got all the headers.
4868 (let ((gnus-nov-is-evil t))
4871 (gnus-retrieve-parsed-headers sequence group)
4874 (defun gnus-article-get-xrefs ()
4875 "Fill in the Xref value in `gnus-current-headers', if necessary.
4876 This is meant to be called in `gnus-article-internal-prepare-hook'."
4877 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4878 gnus-current-headers)))
4879 (or (not gnus-use-cross-reference)
4881 (and (mail-header-xref headers)
4882 (not (string= (mail-header-xref headers) "")))
4883 (let ((case-fold-search t)
4886 (nnheader-narrow-to-headers)
4887 (goto-char (point-min))
4888 (when (or (and (not (eobp))
4889 (eq (downcase (char-after)) ?x)
4890 (looking-at "Xref:"))
4891 (search-forward "\nXref:" nil t))
4892 (goto-char (1+ (match-end 0)))
4893 (setq xref (buffer-substring (point)
4894 (progn (end-of-line) (point))))
4895 (mail-header-set-xref headers xref)))))))
4897 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4898 "Find article ID and insert the summary line for that article.
4899 OLD-HEADER can either be a header or a line number to insert
4900 the subject line on."
4901 (let* ((line (and (numberp old-header) old-header))
4902 (old-header (and (vectorp old-header) old-header))
4903 (header (cond ((and old-header use-old-header)
4906 (gnus-number-to-header id))
4907 (gnus-number-to-header id))
4909 (gnus-read-header id))))
4910 (number (and (numberp id) id))
4913 ;; Rebuild the thread that this article is part of and go to the
4914 ;; article we have fetched.
4915 (when (and (not gnus-show-threads)
4918 (setq d (gnus-data-find (mail-header-number old-header))))
4919 (goto-char (gnus-data-pos d))
4922 (- (gnus-point-at-bol)
4924 (1+ (gnus-point-at-eol))
4925 (gnus-delete-line))))))
4927 (mail-header-set-number header (mail-header-number old-header)))
4928 (setq gnus-newsgroup-sparse
4929 (delq (setq number (mail-header-number header))
4930 gnus-newsgroup-sparse))
4931 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4932 (push number gnus-newsgroup-limit)
4933 (gnus-rebuild-thread (mail-header-id header) line)
4934 (gnus-summary-goto-subject number nil t))
4935 (when (and (numberp number)
4937 ;; We have to update the boundaries even if we can't fetch the
4938 ;; article if ID is a number -- so that the next `P' or `N'
4939 ;; command will fetch the previous (or next) article even
4940 ;; if the one we tried to fetch this time has been canceled.
4941 (when (> number gnus-newsgroup-end)
4942 (setq gnus-newsgroup-end number))
4943 (when (< number gnus-newsgroup-begin)
4944 (setq gnus-newsgroup-begin number))
4945 (setq gnus-newsgroup-unselected
4946 (delq number gnus-newsgroup-unselected)))
4947 ;; Report back a success?
4948 (and header (mail-header-number header))))
4950 ;;; Process/prefix in the summary buffer
4952 (defun gnus-summary-work-articles (n)
4953 "Return a list of articles to be worked upon.
4954 The prefix argument, the list of process marked articles, and the
4955 current article will be taken into consideration."
4957 (set-buffer gnus-summary-buffer)
4960 ;; A numerical prefix has been given.
4961 (setq n (prefix-numeric-value n))
4962 (let ((backward (< n 0))
4963 (n (abs (prefix-numeric-value n)))
4968 (push (setq article (gnus-summary-article-number))
4971 (gnus-summary-find-prev nil article)
4972 (gnus-summary-find-next nil article)))
4974 (nreverse articles)))
4975 ((and (gnus-region-active-p) (mark))
4976 (message "region active")
4977 ;; Work on the region between point and mark.
4978 (let ((max (max (point) (mark)))
4981 (goto-char (min (point) (mark)))
4984 (push (setq article (gnus-summary-article-number)) articles)
4985 (gnus-summary-find-next nil article)
4987 (nreverse articles))))
4988 (gnus-newsgroup-processable
4989 ;; There are process-marked articles present.
4990 ;; Save current state.
4991 (gnus-summary-save-process-mark)
4993 (reverse gnus-newsgroup-processable))
4995 ;; Just return the current article.
4996 (list (gnus-summary-article-number))))))
4998 (defmacro gnus-summary-iterate (arg &rest forms)
4999 "Iterate over the process/prefixed articles and do FORMS.
5000 ARG is the interactive prefix given to the command. FORMS will be
5001 executed with point over the summary line of the articles."
5002 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5003 `(let ((,articles (gnus-summary-work-articles ,arg)))
5005 (gnus-summary-goto-subject (car ,articles))
5009 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5010 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5012 (defun gnus-summary-save-process-mark ()
5013 "Push the current set of process marked articles on the stack."
5015 (push (copy-sequence gnus-newsgroup-processable)
5016 gnus-newsgroup-process-stack))
5018 (defun gnus-summary-kill-process-mark ()
5019 "Push the current set of process marked articles on the stack and unmark."
5021 (gnus-summary-save-process-mark)
5022 (gnus-summary-unmark-all-processable))
5024 (defun gnus-summary-yank-process-mark ()
5025 "Pop the last process mark state off the stack and restore it."
5027 (unless gnus-newsgroup-process-stack
5028 (error "Empty mark stack"))
5029 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5031 (defun gnus-summary-process-mark-set (set)
5032 "Make SET into the current process marked articles."
5033 (gnus-summary-unmark-all-processable)
5035 (gnus-summary-set-process-mark (pop set))))
5037 ;;; Searching and stuff
5039 (defun gnus-summary-search-group (&optional backward use-level)
5040 "Search for next unread newsgroup.
5041 If optional argument BACKWARD is non-nil, search backward instead."
5043 (set-buffer gnus-group-buffer)
5044 (when (gnus-group-search-forward
5045 backward nil (if use-level (gnus-group-group-level) nil))
5046 (gnus-group-group-name))))
5048 (defun gnus-summary-best-group (&optional exclude-group)
5049 "Find the name of the best unread group.
5050 If EXCLUDE-GROUP, do not go to this group."
5052 (set-buffer gnus-group-buffer)
5054 (gnus-group-best-unread-group exclude-group))))
5056 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5057 (if backward (gnus-summary-find-prev)
5058 (let* ((dummy (gnus-summary-article-intangible-p))
5059 (article (or article (gnus-summary-article-number)))
5060 (arts (gnus-data-find-list article))
5062 (when (and (not dummy)
5063 (or (not gnus-summary-check-current)
5065 (not (gnus-data-unread-p (car arts)))))
5066 (setq arts (cdr arts)))
5071 (when (or (and undownloaded
5072 (eq gnus-undownloaded-mark
5073 (gnus-data-mark (car arts))))
5074 (gnus-data-unread-p (car arts)))
5075 (setq result (car arts)
5077 (setq arts (cdr arts)))
5080 (goto-char (gnus-data-pos result))
5081 (gnus-data-number result)))))
5083 (defun gnus-summary-find-prev (&optional unread article)
5084 (let* ((eobp (eobp))
5085 (article (or article (gnus-summary-article-number)))
5086 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5088 (when (and (not eobp)
5089 (or (not gnus-summary-check-current)
5091 (not (gnus-data-unread-p (car arts)))))
5092 (setq arts (cdr arts)))
5097 (when (gnus-data-unread-p (car arts))
5098 (setq result (car arts)
5100 (setq arts (cdr arts)))
5103 (goto-char (gnus-data-pos result))
5104 (gnus-data-number result))))
5106 (defun gnus-summary-find-subject (subject &optional unread backward article)
5107 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5108 (article (or article (gnus-summary-article-number)))
5109 (articles (gnus-data-list backward))
5110 (arts (gnus-data-find-list article articles))
5112 (when (or (not gnus-summary-check-current)
5114 (not (gnus-data-unread-p (car arts))))
5115 (setq arts (cdr arts)))
5117 (and (or (not unread)
5118 (gnus-data-unread-p (car arts)))
5119 (vectorp (gnus-data-header (car arts)))
5121 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5122 (setq result (car arts)
5124 (setq arts (cdr arts)))
5126 (goto-char (gnus-data-pos result))
5127 (gnus-data-number result))))
5129 (defun gnus-summary-search-forward (&optional unread subject backward)
5130 "Search forward for an article.
5131 If UNREAD, look for unread articles. If SUBJECT, look for
5132 articles with that subject. If BACKWARD, search backward instead."
5133 (cond (subject (gnus-summary-find-subject subject unread backward))
5134 (backward (gnus-summary-find-prev unread))
5135 (t (gnus-summary-find-next unread))))
5137 (defun gnus-recenter (&optional n)
5138 "Center point in window and redisplay frame.
5139 Also do horizontal recentering."
5141 (when (and gnus-auto-center-summary
5142 (not (eq gnus-auto-center-summary 'vertical)))
5143 (gnus-horizontal-recenter))
5146 (defun gnus-summary-recenter ()
5147 "Center point in the summary window.
5148 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5149 displayed, no centering will be performed."
5150 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5151 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5152 (let* ((top (cond ((< (window-height) 4) 0)
5153 ((< (window-height) 7) 1)
5154 (t (if (numberp gnus-auto-center-summary)
5155 gnus-auto-center-summary
5157 (height (1- (window-height)))
5158 (bottom (save-excursion (goto-char (point-max))
5159 (forward-line (- height))
5161 (window (get-buffer-window (current-buffer))))
5162 ;; The user has to want it.
5163 (when gnus-auto-center-summary
5164 (when (get-buffer-window gnus-article-buffer)
5165 ;; Only do recentering when the article buffer is displayed,
5166 ;; Set the window start to either `bottom', which is the biggest
5167 ;; possible valid number, or the second line from the top,
5168 ;; whichever is the least.
5170 window (min bottom (save-excursion
5171 (forward-line (- top)) (point)))
5173 ;; Do horizontal recentering while we're at it.
5174 (when (and (get-buffer-window (current-buffer) t)
5175 (not (eq gnus-auto-center-summary 'vertical)))
5176 (let ((selected (selected-window)))
5177 (select-window (get-buffer-window (current-buffer) t))
5178 (gnus-summary-position-point)
5179 (gnus-horizontal-recenter)
5180 (select-window selected))))))
5182 (defun gnus-summary-jump-to-group (newsgroup)
5183 "Move point to NEWSGROUP in group mode buffer."
5184 ;; Keep update point of group mode buffer if visible.
5185 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5186 (save-window-excursion
5187 ;; Take care of tree window mode.
5188 (when (get-buffer-window gnus-group-buffer)
5189 (pop-to-buffer gnus-group-buffer))
5190 (gnus-group-jump-to-group newsgroup))
5192 ;; Take care of tree window mode.
5193 (if (get-buffer-window gnus-group-buffer)
5194 (pop-to-buffer gnus-group-buffer)
5195 (set-buffer gnus-group-buffer))
5196 (gnus-group-jump-to-group newsgroup))))
5198 ;; This function returns a list of article numbers based on the
5199 ;; difference between the ranges of read articles in this group and
5200 ;; the range of active articles.
5201 (defun gnus-list-of-unread-articles (group)
5202 (let* ((read (gnus-info-read (gnus-get-info group)))
5203 (active (or (gnus-active group) (gnus-activate-group group)))
5206 ;; If none are read, then all are unread.
5208 (setq first (car active))
5209 ;; If the range of read articles is a single range, then the
5210 ;; first unread article is the article after the last read
5211 ;; article. Sounds logical, doesn't it?
5212 (if (and (not (listp (cdr read)))
5213 (or (< (car read) (car active))
5214 (progn (setq read (list read))
5216 (setq first (max (car active) (1+ (cdr read))))
5217 ;; `read' is a list of ranges.
5218 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5221 (setq first (car active)))
5224 (while (< first nlast)
5226 (setq first (1+ first))))
5227 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5228 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5229 (setq read (cdr read)))))
5230 ;; And add the last unread articles.
5231 (while (<= first last)
5233 (setq first (1+ first)))
5234 ;; Return the list of unread articles.
5235 (delq 0 (nreverse unread))))
5237 (defun gnus-list-of-read-articles (group)
5238 "Return a list of unread, unticked and non-dormant articles."
5239 (let* ((info (gnus-get-info group))
5240 (marked (gnus-info-marks info))
5241 (active (gnus-active group)))
5243 (gnus-set-difference
5244 (gnus-sorted-complement
5245 (gnus-uncompress-range active)
5246 (gnus-list-of-unread-articles group))
5248 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5249 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5251 ;; Various summary commands
5253 (defun gnus-summary-select-article-buffer ()
5254 "Reconfigure windows to show article buffer."
5256 (if (not (gnus-buffer-live-p gnus-article-buffer))
5257 (error "There is no article buffer for this summary buffer")
5258 (gnus-configure-windows 'article)
5259 (select-window (get-buffer-window gnus-article-buffer))))
5261 (defun gnus-summary-universal-argument (arg)
5262 "Perform any operation on all articles that are process/prefixed."
5264 (let ((articles (gnus-summary-work-articles arg))
5271 (substitute-command-keys
5272 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5274 (gnus-error 1 "Undefined key")
5277 (gnus-summary-goto-subject (setq article (pop articles)))
5278 (let (gnus-newsgroup-processable)
5279 (command-execute func))
5280 (gnus-summary-remove-process-mark article)))))
5281 (gnus-summary-position-point))
5283 (defun gnus-summary-toggle-truncation (&optional arg)
5284 "Toggle truncation of summary lines.
5285 With arg, turn line truncation on iff arg is positive."
5287 (setq truncate-lines
5288 (if (null arg) (not truncate-lines)
5289 (> (prefix-numeric-value arg) 0)))
5292 (defun gnus-summary-reselect-current-group (&optional all rescan)
5293 "Exit and then reselect the current newsgroup.
5294 The prefix argument ALL means to select all articles."
5296 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5297 (error "Ephemeral groups can't be reselected"))
5298 (let ((current-subject (gnus-summary-article-number))
5299 (group gnus-newsgroup-name))
5300 (setq gnus-newsgroup-begin nil)
5302 ;; We have to adjust the point of group mode buffer because
5303 ;; point was moved to the next unread newsgroup by exiting.
5304 (gnus-summary-jump-to-group group)
5307 (save-window-excursion
5308 ;; Don't show group contents.
5309 (set-window-start (selected-window) (point-max))
5310 (gnus-group-get-new-news-this-group 1))))
5311 (gnus-group-read-group all t)
5312 (gnus-summary-goto-subject current-subject nil t)))
5314 (defun gnus-summary-rescan-group (&optional all)
5315 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5317 (gnus-summary-reselect-current-group all t))
5319 (defun gnus-summary-update-info (&optional non-destructive)
5321 (let ((group gnus-newsgroup-name))
5323 (when gnus-newsgroup-kill-headers
5324 (setq gnus-newsgroup-killed
5325 (gnus-compress-sequence
5327 (gnus-set-sorted-intersection
5328 (gnus-uncompress-range gnus-newsgroup-killed)
5329 (setq gnus-newsgroup-unselected
5330 (sort gnus-newsgroup-unselected '<)))
5331 (setq gnus-newsgroup-unreads
5332 (sort gnus-newsgroup-unreads '<)))
5334 (unless (listp (cdr gnus-newsgroup-killed))
5335 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5336 (let ((headers gnus-newsgroup-headers))
5337 ;; Set the new ranges of read articles.
5339 (set-buffer gnus-group-buffer)
5340 (gnus-undo-force-boundary))
5341 (gnus-update-read-articles
5342 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5343 ;; Set the current article marks.
5344 (let ((gnus-newsgroup-scored
5345 (if (and (not gnus-save-score)
5346 (not non-destructive))
5348 gnus-newsgroup-scored)))
5350 (gnus-update-marks)))
5351 ;; Do the cross-ref thing.
5352 (when gnus-use-cross-reference
5353 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5354 ;; Do not switch windows but change the buffer to work.
5355 (set-buffer gnus-group-buffer)
5356 (unless (gnus-ephemeral-group-p group)
5357 (gnus-group-update-group group)))))))
5359 (defun gnus-summary-save-newsrc (&optional force)
5360 "Save the current number of read/marked articles in the dribble buffer.
5361 The dribble buffer will then be saved.
5362 If FORCE (the prefix), also save the .newsrc file(s)."
5364 (gnus-summary-update-info t)
5366 (gnus-save-newsrc-file)
5367 (gnus-dribble-save)))
5369 (defun gnus-summary-exit (&optional temporary)
5370 "Exit reading current newsgroup, and then return to group selection mode.
5371 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5373 (gnus-set-global-variables)
5374 (gnus-kill-save-kill-buffer)
5375 (gnus-async-halt-prefetch)
5376 (let* ((group gnus-newsgroup-name)
5377 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5380 (buf (current-buffer)))
5382 ;; Do adaptive scoring, and possibly save score files.
5383 (when gnus-newsgroup-adaptive
5384 (gnus-score-adaptive))
5385 (when gnus-use-scoring
5387 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5388 ;; If we have several article buffers, we kill them at exit.
5389 (unless gnus-single-article-buffer
5390 (gnus-kill-buffer gnus-original-article-buffer)
5391 (setq gnus-article-current nil))
5392 (when gnus-use-cache
5393 (gnus-cache-possibly-remove-articles)
5394 (gnus-cache-save-buffers))
5395 (gnus-async-prefetch-remove-group group)
5396 (when gnus-suppress-duplicates
5397 (gnus-dup-enter-articles))
5398 (when gnus-use-trees
5399 (gnus-tree-close group))
5400 (when gnus-use-cache
5401 (gnus-cache-write-active))
5402 ;; Remove entries for this group.
5403 (nnmail-purge-split-history (gnus-group-real-name group))
5404 ;; Make all changes in this group permanent.
5406 (gnus-run-hooks 'gnus-exit-group-hook)
5407 (gnus-summary-update-info))
5408 (gnus-close-group group)
5409 ;; Make sure where we were, and go to next newsgroup.
5410 (set-buffer gnus-group-buffer)
5412 (gnus-group-jump-to-group group))
5413 (gnus-run-hooks 'gnus-summary-exit-hook)
5414 (unless (or quit-config
5415 ;; If this group has disappeared from the summary
5416 ;; buffer, don't skip forwards.
5417 (not (string= group (gnus-group-group-name))))
5418 (gnus-group-next-unread-group 1))
5419 (setq group-point (point))
5422 ;; If we have several article buffers, we kill them at exit.
5423 (unless gnus-single-article-buffer
5424 (gnus-kill-buffer gnus-article-buffer)
5425 (gnus-kill-buffer gnus-original-article-buffer)
5426 (setq gnus-article-current nil))
5428 (if (not gnus-kill-summary-on-exit)
5429 (gnus-deaden-summary)
5430 ;; We set all buffer-local variables to nil. It is unclear why
5431 ;; this is needed, but if we don't, buffer-local variables are
5432 ;; not garbage-collected, it seems. This would the lead to en
5433 ;; ever-growing Emacs.
5434 (gnus-summary-clear-local-variables)
5435 (when (get-buffer gnus-article-buffer)
5436 (bury-buffer gnus-article-buffer))
5437 ;; We clear the global counterparts of the buffer-local
5438 ;; variables as well, just to be on the safe side.
5439 (set-buffer gnus-group-buffer)
5440 (gnus-summary-clear-local-variables)
5441 ;; Return to group mode buffer.
5442 (when (eq mode 'gnus-summary-mode)
5443 (gnus-kill-buffer buf)))
5444 (setq gnus-current-select-method gnus-select-method)
5445 (pop-to-buffer gnus-group-buffer)
5446 (if (not quit-config)
5448 (goto-char group-point)
5449 (gnus-configure-windows 'group 'force)
5450 (unless (pos-visible-in-window-p)
5451 (forward-line (/ (static-if (featurep 'xemacs)
5452 (window-displayed-height)
5453 (1- (window-height)))
5455 (set-window-start (selected-window) (point))
5456 (goto-char group-point)))
5457 (gnus-handle-ephemeral-exit quit-config))
5458 ;; Clear the current group name.
5460 (setq gnus-newsgroup-name nil)))))
5462 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5463 (defun gnus-summary-exit-no-update (&optional no-questions)
5464 "Quit reading current newsgroup without updating read article info."
5466 (let* ((group gnus-newsgroup-name)
5467 (quit-config (gnus-group-quit-config group)))
5468 (when (or no-questions
5470 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5471 (gnus-async-halt-prefetch)
5473 (delq 'gnus-summary-expire-articles
5474 (copy-sequence gnus-summary-prepare-exit-hook)))
5475 ;; If we have several article buffers, we kill them at exit.
5476 (unless gnus-single-article-buffer
5477 (gnus-kill-buffer gnus-article-buffer)
5478 (gnus-kill-buffer gnus-original-article-buffer)
5479 (setq gnus-article-current nil))
5480 (if (not gnus-kill-summary-on-exit)
5481 (gnus-deaden-summary)
5482 (gnus-close-group group)
5483 (gnus-summary-clear-local-variables)
5484 (set-buffer gnus-group-buffer)
5485 (gnus-summary-clear-local-variables)
5486 (when (get-buffer gnus-summary-buffer)
5487 (kill-buffer gnus-summary-buffer)))
5488 (unless gnus-single-article-buffer
5489 (setq gnus-article-current nil))
5490 (when gnus-use-trees
5491 (gnus-tree-close group))
5492 (gnus-async-prefetch-remove-group group)
5493 (when (get-buffer gnus-article-buffer)
5494 (bury-buffer gnus-article-buffer))
5495 ;; Return to the group buffer.
5496 (gnus-configure-windows 'group 'force)
5497 ;; Clear the current group name.
5498 (setq gnus-newsgroup-name nil)
5499 (when (equal (gnus-group-group-name) group)
5500 (gnus-group-next-unread-group 1))
5502 (gnus-handle-ephemeral-exit quit-config)))))
5504 (defun gnus-handle-ephemeral-exit (quit-config)
5505 "Handle movement when leaving an ephemeral group.
5506 The state which existed when entering the ephemeral is reset."
5507 (if (not (buffer-name (car quit-config)))
5508 (gnus-configure-windows 'group 'force)
5509 (set-buffer (car quit-config))
5510 (cond ((eq major-mode 'gnus-summary-mode)
5511 (gnus-set-global-variables))
5512 ((eq major-mode 'gnus-article-mode)
5514 ;; The `gnus-summary-buffer' variable may point
5515 ;; to the old summary buffer when using a single
5517 (unless (gnus-buffer-live-p gnus-summary-buffer)
5518 (set-buffer gnus-group-buffer))
5519 (set-buffer gnus-summary-buffer)
5520 (gnus-set-global-variables))))
5521 (if (or (eq (cdr quit-config) 'article)
5522 (eq (cdr quit-config) 'pick))
5524 ;; The current article may be from the ephemeral group
5525 ;; thus it is best that we reload this article
5526 (gnus-summary-show-article)
5527 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5528 (gnus-configure-windows 'pick 'force)
5529 (gnus-configure-windows (cdr quit-config) 'force)))
5530 (gnus-configure-windows (cdr quit-config) 'force))
5531 (when (eq major-mode 'gnus-summary-mode)
5532 (gnus-summary-next-subject 1 nil t)
5533 (gnus-summary-recenter)
5534 (gnus-summary-position-point))))
5536 (defun gnus-summary-preview-mime-message ()
5537 "MIME decode and play this message."
5539 (let ((gnus-break-pages nil)
5541 (gnus-summary-select-article gnus-show-all-headers t))
5542 (select-window (get-buffer-window gnus-article-buffer)))
5546 (defvar gnus-dead-summary-mode-map nil)
5548 (unless gnus-dead-summary-mode-map
5549 (setq gnus-dead-summary-mode-map (make-keymap))
5550 (suppress-keymap gnus-dead-summary-mode-map)
5551 (substitute-key-definition
5552 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5553 (let ((keys '("\C-d" "\r" "\177" [delete])))
5555 (define-key gnus-dead-summary-mode-map
5556 (pop keys) 'gnus-summary-wake-up-the-dead))))
5558 (defvar gnus-dead-summary-mode nil
5559 "Minor mode for Gnus summary buffers.")
5561 (defun gnus-dead-summary-mode (&optional arg)
5562 "Minor mode for Gnus summary buffers."
5564 (when (eq major-mode 'gnus-summary-mode)
5565 (make-local-variable 'gnus-dead-summary-mode)
5566 (setq gnus-dead-summary-mode
5567 (if (null arg) (not gnus-dead-summary-mode)
5568 (> (prefix-numeric-value arg) 0)))
5569 (when gnus-dead-summary-mode
5570 (gnus-add-minor-mode
5571 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5573 (defun gnus-deaden-summary ()
5574 "Make the current summary buffer into a dead summary buffer."
5575 ;; Kill any previous dead summary buffer.
5576 (when (and gnus-dead-summary
5577 (buffer-name gnus-dead-summary))
5579 (set-buffer gnus-dead-summary)
5580 (when gnus-dead-summary-mode
5581 (kill-buffer (current-buffer)))))
5582 ;; Make this the current dead summary.
5583 (setq gnus-dead-summary (current-buffer))
5584 (gnus-dead-summary-mode 1)
5585 (let ((name (buffer-name)))
5586 (when (string-match "Summary" name)
5588 (concat (substring name 0 (match-beginning 0)) "Dead "
5589 (substring name (match-beginning 0)))
5593 (defun gnus-kill-or-deaden-summary (buffer)
5594 "Kill or deaden the summary BUFFER."
5596 (when (and (buffer-name buffer)
5597 (not gnus-single-article-buffer))
5600 (gnus-kill-buffer gnus-article-buffer)
5601 (gnus-kill-buffer gnus-original-article-buffer)))
5602 (cond (gnus-kill-summary-on-exit
5603 (when (and gnus-use-trees
5604 (gnus-buffer-exists-p buffer))
5607 (gnus-tree-close gnus-newsgroup-name)))
5608 (gnus-kill-buffer buffer))
5609 ((gnus-buffer-exists-p buffer)
5612 (gnus-deaden-summary))))))
5614 (defun gnus-summary-wake-up-the-dead (&rest args)
5615 "Wake up the dead summary buffer."
5617 (gnus-dead-summary-mode -1)
5618 (let ((name (buffer-name)))
5619 (when (string-match "Dead " name)
5621 (concat (substring name 0 (match-beginning 0))
5622 (substring name (match-end 0)))
5624 (gnus-message 3 "This dead summary is now alive again"))
5626 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5627 (defun gnus-summary-fetch-faq (&optional faq-dir)
5628 "Fetch the FAQ for the current group.
5629 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5633 (when current-prefix-arg
5635 "Faq dir: " (and (listp gnus-group-faq-directory)
5636 (mapcar (lambda (file) (list file))
5637 gnus-group-faq-directory))))))
5638 (let (gnus-faq-buffer)
5639 (when (setq gnus-faq-buffer
5640 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5641 (gnus-configure-windows 'summary-faq))))
5643 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5644 (defun gnus-summary-describe-group (&optional force)
5645 "Describe the current newsgroup."
5647 (gnus-group-describe-group force gnus-newsgroup-name))
5649 (defun gnus-summary-describe-briefly ()
5650 "Describe summary mode commands briefly."
5652 (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")))
5654 ;; Walking around group mode buffer from summary mode.
5656 (defun gnus-summary-next-group (&optional no-article target-group backward)
5657 "Exit current newsgroup and then select next unread newsgroup.
5658 If prefix argument NO-ARTICLE is non-nil, no article is selected
5659 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5660 previous group instead."
5662 ;; Stop pre-fetching.
5663 (gnus-async-halt-prefetch)
5664 (let ((current-group gnus-newsgroup-name)
5665 (current-buffer (current-buffer))
5667 ;; First we semi-exit this group to update Xrefs and all variables.
5668 ;; We can't do a real exit, because the window conf must remain
5669 ;; the same in case the user is prompted for info, and we don't
5670 ;; want the window conf to change before that...
5671 (gnus-summary-exit t)
5672 (while (not entered)
5673 ;; Then we find what group we are supposed to enter.
5674 (set-buffer gnus-group-buffer)
5675 (gnus-group-jump-to-group current-group)
5678 (if (eq gnus-keep-same-level 'best)
5679 (gnus-summary-best-group gnus-newsgroup-name)
5680 (gnus-summary-search-group backward gnus-keep-same-level))))
5681 (if (not target-group)
5682 ;; There are no further groups, so we return to the group
5685 (gnus-message 5 "Returning to the group buffer")
5687 (when (gnus-buffer-live-p current-buffer)
5688 (set-buffer current-buffer)
5689 (gnus-summary-exit))
5690 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5691 ;; We try to enter the target group.
5692 (gnus-group-jump-to-group target-group)
5693 (let ((unreads (gnus-group-group-unread)))
5694 (if (and (or (eq t unreads)
5695 (and unreads (not (zerop unreads))))
5696 (gnus-summary-read-group
5697 target-group nil no-article
5698 (and (buffer-name current-buffer) current-buffer)
5701 (setq current-group target-group
5702 target-group nil)))))))
5704 (defun gnus-summary-prev-group (&optional no-article)
5705 "Exit current newsgroup and then select previous unread newsgroup.
5706 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5708 (gnus-summary-next-group no-article nil t))
5710 ;; Walking around summary lines.
5712 (defun gnus-summary-first-subject (&optional unread undownloaded)
5713 "Go to the first unread subject.
5714 If UNREAD is non-nil, go to the first unread article.
5715 Returns the article selected or nil if there are no unread articles."
5720 ((null gnus-newsgroup-data)
5721 (gnus-message 3 "No articles in the group")
5723 ;; Pick the first article.
5725 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5726 (gnus-data-number (car gnus-newsgroup-data)))
5727 ;; No unread articles.
5728 ((null gnus-newsgroup-unreads)
5729 (gnus-message 3 "No more unread articles")
5731 ;; Find the first unread article.
5733 (let ((data gnus-newsgroup-data))
5735 (and (not (and undownloaded
5736 (eq gnus-undownloaded-mark
5737 (gnus-data-mark (car data)))))
5738 (not (gnus-data-unread-p (car data)))))
5739 (setq data (cdr data)))
5741 (goto-char (gnus-data-pos (car data)))
5742 (gnus-data-number (car data))))))
5743 (gnus-summary-position-point)))
5745 (defun gnus-summary-next-subject (n &optional unread dont-display)
5746 "Go to next N'th summary line.
5747 If N is negative, go to the previous N'th subject line.
5748 If UNREAD is non-nil, only unread articles are selected.
5749 The difference between N and the actual number of steps taken is
5752 (let ((backward (< n 0))
5756 (gnus-summary-find-prev unread)
5757 (gnus-summary-find-next unread)))
5758 (unless (zerop (setq n (1- n)))
5759 (gnus-summary-show-thread)))
5761 (gnus-message 7 "No more%s articles"
5762 (if unread " unread" "")))
5763 (unless dont-display
5764 (gnus-summary-recenter)
5765 (gnus-summary-position-point))
5768 (defun gnus-summary-next-unread-subject (n)
5769 "Go to next N'th unread summary line."
5771 (gnus-summary-next-subject n t))
5773 (defun gnus-summary-prev-subject (n &optional unread)
5774 "Go to previous N'th summary line.
5775 If optional argument UNREAD is non-nil, only unread article is selected."
5777 (gnus-summary-next-subject (- n) unread))
5779 (defun gnus-summary-prev-unread-subject (n)
5780 "Go to previous N'th unread summary line."
5782 (gnus-summary-next-subject (- n) t))
5784 (defun gnus-summary-goto-subject (article &optional force silent)
5785 "Go the subject line of ARTICLE.
5786 If FORCE, also allow jumping to articles not currently shown."
5787 (interactive "nArticle number: ")
5789 (data (gnus-data-find article)))
5790 ;; We read in the article if we have to.
5793 (gnus-summary-insert-subject
5795 (if (or (numberp force) (vectorp force)) force)
5797 (setq data (gnus-data-find article)))
5802 (gnus-message 3 "Can't find article %d" article))
5804 (goto-char (gnus-data-pos data))
5805 (gnus-summary-position-point)
5808 ;; Walking around summary lines with displaying articles.
5810 (defun gnus-summary-expand-window (&optional arg)
5811 "Make the summary buffer take up the entire Emacs frame.
5812 Given a prefix, will force an `article' buffer configuration."
5815 (gnus-configure-windows 'article 'force)
5816 (gnus-configure-windows 'summary 'force)))
5818 (defun gnus-summary-display-article (article &optional all-header)
5819 "Display ARTICLE in article buffer."
5820 (gnus-set-global-variables)
5824 (if gnus-summary-display-article-function
5825 (funcall gnus-summary-display-article-function article all-header)
5826 (gnus-article-prepare article all-header))
5827 (with-current-buffer gnus-article-buffer
5828 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5830 (gnus-run-hooks 'gnus-select-article-hook)
5831 (when (and gnus-current-article
5832 (not (zerop gnus-current-article)))
5833 (gnus-summary-goto-subject gnus-current-article))
5834 (gnus-summary-recenter)
5835 (when (and gnus-use-trees gnus-show-threads)
5836 (gnus-possibly-generate-tree article)
5837 (gnus-highlight-selected-tree article))
5838 ;; Successfully display article.
5839 (gnus-article-set-window-start
5840 (cdr (assq article gnus-newsgroup-bookmarks))))))
5842 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5843 "Select the current article.
5844 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5845 non-nil, the article will be re-fetched even if it already present in
5846 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5848 ;; Make sure we are in the summary buffer to work around bbdb bug.
5849 (unless (eq major-mode 'gnus-summary-mode)
5850 (set-buffer gnus-summary-buffer))
5851 (let ((article (or article (gnus-summary-article-number)))
5852 (all-headers (not (not all-headers))) ;Must be T or NIL.
5853 gnus-summary-display-article-function)
5855 (gnus-summary-article-pseudo-p article)
5856 (error "This is a pseudo-article"))
5858 (set-buffer gnus-summary-buffer)
5859 (if (or (and gnus-single-article-buffer
5860 (or (null gnus-current-article)
5861 (null gnus-article-current)
5862 (null (get-buffer gnus-article-buffer))
5863 (not (eq article (cdr gnus-article-current)))
5864 (not (equal (car gnus-article-current)
5865 gnus-newsgroup-name))))
5866 (and (not gnus-single-article-buffer)
5867 (or (null gnus-current-article)
5868 (not (eq gnus-current-article article))))
5870 ;; The requested article is different from the current article.
5872 (gnus-summary-display-article article all-headers)
5873 (when (or all-headers gnus-show-all-headers)
5874 (gnus-article-show-all-headers))
5875 (gnus-article-set-window-start
5876 (cdr (assq article gnus-newsgroup-bookmarks)))
5878 (when (or all-headers gnus-show-all-headers)
5879 (gnus-article-show-all-headers))
5882 (defun gnus-summary-set-current-mark (&optional current-mark)
5883 "Obsolete function."
5886 (defun gnus-summary-next-article (&optional unread subject backward push)
5887 "Select the next article.
5888 If UNREAD, only unread articles are selected.
5889 If SUBJECT, only articles with SUBJECT are selected.
5890 If BACKWARD, the previous article is selected instead of the next."
5893 ;; Is there such an article?
5894 ((and (gnus-summary-search-forward unread subject backward)
5895 (or (gnus-summary-display-article (gnus-summary-article-number))
5896 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5897 (gnus-summary-position-point))
5898 ;; If not, we try the first unread, if that is wanted.
5900 gnus-auto-select-same
5901 (gnus-summary-first-unread-article))
5902 (gnus-summary-position-point)
5903 (gnus-message 6 "Wrapped"))
5904 ;; Try to get next/previous article not displayed in this group.
5905 ((and gnus-auto-extend-newsgroup
5906 (not unread) (not subject))
5907 (gnus-summary-goto-article
5908 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5909 nil (count-lines (point-min) (point))))
5910 ;; Go to next/previous group.
5912 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5913 (gnus-summary-jump-to-group gnus-newsgroup-name))
5914 (let ((cmd last-command-char)
5917 (set-buffer gnus-group-buffer)
5920 (if (eq gnus-keep-same-level 'best)
5921 (gnus-summary-best-group gnus-newsgroup-name)
5922 (gnus-summary-search-group backward gnus-keep-same-level))))
5923 ;; For some reason, the group window gets selected. We change
5925 (select-window (get-buffer-window (current-buffer)))
5926 ;; Select next unread newsgroup automagically.
5928 ((or (not gnus-auto-select-next)
5930 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5931 ((or (eq gnus-auto-select-next 'quietly)
5932 (and (eq gnus-auto-select-next 'slightly-quietly)
5934 (and (eq gnus-auto-select-next 'almost-quietly)
5935 (gnus-summary-last-article-p)))
5937 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5939 (gnus-message 7 "No more%s articles (%s)..."
5940 (if unread " unread" "")
5941 (if group (concat "selecting " group)
5943 (gnus-summary-next-group nil group backward)))
5945 (when (gnus-key-press-event-p last-input-event)
5946 (gnus-summary-walk-group-buffer
5947 gnus-newsgroup-name cmd unread backward point))))))))
5949 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5950 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5951 (?\C-p (gnus-group-prev-unread-group 1))))
5952 (cursor-in-echo-area t)
5953 keve key group ended)
5955 (set-buffer gnus-group-buffer)
5958 (if (eq gnus-keep-same-level 'best)
5959 (gnus-summary-best-group gnus-newsgroup-name)
5960 (gnus-summary-search-group backward gnus-keep-same-level))))
5963 5 "No more%s articles%s" (if unread " unread" "")
5965 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5966 (format " (Type %s for %s [%s])"
5967 (single-key-description cmd) group
5968 (car (gnus-gethash group gnus-newsrc-hashtb)))
5969 (format " (Type %s to exit %s)"
5970 (single-key-description cmd)
5971 gnus-newsgroup-name)))
5972 ;; Confirm auto selection.
5973 (setq key (car (setq keve (gnus-read-event-char))))
5976 ((assq key keystrokes)
5977 (let ((obuf (current-buffer)))
5978 (switch-to-buffer gnus-group-buffer)
5980 (gnus-group-jump-to-group group))
5981 (eval (cadr (assq key keystrokes)))
5982 (setq group (gnus-group-group-name))
5983 (switch-to-buffer obuf))
5987 (gnus-ephemeral-group-p gnus-newsgroup-name))
5989 (gnus-summary-next-group nil group backward)))
5991 (push (cdr keve) unread-command-events))))))
5993 (defun gnus-summary-next-unread-article ()
5994 "Select unread article after current one."
5996 (gnus-summary-next-article
5997 (or (not (eq gnus-summary-goto-unread 'never))
5998 (gnus-summary-last-article-p (gnus-summary-article-number)))
5999 (and gnus-auto-select-same
6000 (gnus-summary-article-subject))))
6002 (defun gnus-summary-prev-article (&optional unread subject)
6003 "Select the article after the current one.
6004 If UNREAD is non-nil, only unread articles are selected."
6006 (gnus-summary-next-article unread subject t))
6008 (defun gnus-summary-prev-unread-article ()
6009 "Select unread article before current one."
6011 (gnus-summary-prev-article
6012 (or (not (eq gnus-summary-goto-unread 'never))
6013 (gnus-summary-first-article-p (gnus-summary-article-number)))
6014 (and gnus-auto-select-same
6015 (gnus-summary-article-subject))))
6017 (defun gnus-summary-next-page (&optional lines circular)
6018 "Show next page of the selected article.
6019 If at the end of the current article, select the next article.
6020 LINES says how many lines should be scrolled up.
6022 If CIRCULAR is non-nil, go to the start of the article instead of
6023 selecting the next article when reaching the end of the current
6026 (setq gnus-summary-buffer (current-buffer))
6027 (gnus-set-global-variables)
6028 (let ((article (gnus-summary-article-number))
6029 (article-window (get-buffer-window gnus-article-buffer t))
6031 ;; If the buffer is empty, we have no article.
6033 (error "No article to select"))
6034 (gnus-configure-windows 'article)
6035 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6036 (if (and (eq gnus-summary-goto-unread 'never)
6037 (not (gnus-summary-last-article-p article)))
6038 (gnus-summary-next-article)
6039 (gnus-summary-next-unread-article))
6040 (if (or (null gnus-current-article)
6041 (null gnus-article-current)
6042 (/= article (cdr gnus-article-current))
6043 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6044 ;; Selected subject is different from current article's.
6045 (gnus-summary-display-article article)
6046 (when article-window
6047 (gnus-eval-in-buffer-window gnus-article-buffer
6048 (setq endp (gnus-article-next-page lines)))
6051 (gnus-summary-beginning-of-article))
6053 (gnus-message 3 "End of message"))
6055 (if (and (eq gnus-summary-goto-unread 'never)
6056 (not (gnus-summary-last-article-p article)))
6057 (gnus-summary-next-article)
6058 (gnus-summary-next-unread-article))))))))
6059 (gnus-summary-recenter)
6060 (gnus-summary-position-point)))
6062 (defun gnus-summary-prev-page (&optional lines move)
6063 "Show previous page of selected article.
6064 Argument LINES specifies lines to be scrolled down.
6065 If MOVE, move to the previous unread article if point is at
6066 the beginning of the buffer."
6068 (let ((article (gnus-summary-article-number))
6069 (article-window (get-buffer-window gnus-article-buffer t))
6071 (gnus-configure-windows 'article)
6072 (if (or (null gnus-current-article)
6073 (null gnus-article-current)
6074 (/= article (cdr gnus-article-current))
6075 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6076 ;; Selected subject is different from current article's.
6077 (gnus-summary-display-article article)
6078 (gnus-summary-recenter)
6079 (when article-window
6080 (gnus-eval-in-buffer-window gnus-article-buffer
6081 (setq endp (gnus-article-prev-page lines)))
6082 (when (and move endp)
6084 (gnus-message 3 "Beginning of message"))
6086 (if (and (eq gnus-summary-goto-unread 'never)
6087 (not (gnus-summary-first-article-p article)))
6088 (gnus-summary-prev-article)
6089 (gnus-summary-prev-unread-article))))))))
6090 (gnus-summary-position-point))
6092 (defun gnus-summary-prev-page-or-article (&optional lines)
6093 "Show previous page of selected article.
6094 Argument LINES specifies lines to be scrolled down.
6095 If at the beginning of the article, go to the next article."
6097 (gnus-summary-prev-page lines t))
6099 (defun gnus-summary-scroll-up (lines)
6100 "Scroll up (or down) one line current article.
6101 Argument LINES specifies lines to be scrolled up (or down if negative)."
6103 (gnus-configure-windows 'article)
6104 (gnus-summary-show-thread)
6105 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6106 (gnus-eval-in-buffer-window gnus-article-buffer
6108 (when (gnus-article-next-page lines)
6109 (gnus-message 3 "End of message")))
6111 (gnus-article-prev-page (- lines))))))
6112 (gnus-summary-recenter)
6113 (gnus-summary-position-point))
6115 (defun gnus-summary-scroll-down (lines)
6116 "Scroll down (or up) one line current article.
6117 Argument LINES specifies lines to be scrolled down (or up if negative)."
6119 (gnus-summary-scroll-up (- lines)))
6121 (defun gnus-summary-next-same-subject ()
6122 "Select next article which has the same subject as current one."
6124 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6126 (defun gnus-summary-prev-same-subject ()
6127 "Select previous article which has the same subject as current one."
6129 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6131 (defun gnus-summary-next-unread-same-subject ()
6132 "Select next unread article which has the same subject as current one."
6134 (gnus-summary-next-article t (gnus-summary-article-subject)))
6136 (defun gnus-summary-prev-unread-same-subject ()
6137 "Select previous unread article which has the same subject as current one."
6139 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6141 (defun gnus-summary-first-unread-article ()
6142 "Select the first unread article.
6143 Return nil if there are no unread articles."
6146 (when (gnus-summary-first-subject t)
6147 (gnus-summary-show-thread)
6148 (gnus-summary-first-subject t)
6149 (gnus-summary-display-article (gnus-summary-article-number)))
6150 (gnus-summary-position-point)))
6152 (defun gnus-summary-first-unread-subject ()
6153 "Place the point on the subject line of the first unread article.
6154 Return nil if there are no unread articles."
6157 (when (gnus-summary-first-subject t)
6158 (gnus-summary-show-thread)
6159 (gnus-summary-first-subject t))
6160 (gnus-summary-position-point)))
6162 (defun gnus-summary-first-article ()
6163 "Select the first article.
6164 Return nil if there are no articles."
6167 (when (gnus-summary-first-subject)
6168 (gnus-summary-show-thread)
6169 (gnus-summary-first-subject)
6170 (gnus-summary-display-article (gnus-summary-article-number)))
6171 (gnus-summary-position-point)))
6173 (defun gnus-summary-best-unread-article ()
6174 "Select the unread article with the highest score."
6176 (let ((best -1000000)
6177 (data gnus-newsgroup-data)
6180 (and (gnus-data-unread-p (car data))
6182 (gnus-summary-article-score (gnus-data-number (car data))))
6185 article (gnus-data-number (car data))))
6186 (setq data (cdr data)))
6189 (gnus-summary-goto-article article)
6190 (error "No unread articles"))
6191 (gnus-summary-position-point))))
6193 (defun gnus-summary-last-subject ()
6194 "Go to the last displayed subject line in the group."
6195 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6197 (gnus-summary-goto-subject article))))
6199 (defun gnus-summary-goto-article (article &optional all-headers force)
6200 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6201 If ALL-HEADERS is non-nil, no header lines are hidden.
6202 If FORCE, go to the article even if it isn't displayed. If FORCE
6203 is a number, it is the line the article is to be displayed on."
6207 "Article number or Message-ID: "
6208 (mapcar (lambda (number) (list (int-to-string number)))
6209 gnus-newsgroup-limit))
6213 (if (and (stringp article)
6214 (string-match "@" article))
6215 (gnus-summary-refer-article article)
6216 (when (stringp article)
6217 (setq article (string-to-number article)))
6218 (if (gnus-summary-goto-subject article force)
6219 (gnus-summary-display-article article all-headers)
6220 (gnus-message 4 "Couldn't go to article %s" article) nil))
6221 (gnus-summary-position-point)))
6223 (defun gnus-summary-goto-last-article ()
6224 "Go to the previously read article."
6227 (when gnus-last-article
6228 (gnus-summary-goto-article gnus-last-article nil t))
6229 (gnus-summary-position-point)))
6231 (defun gnus-summary-pop-article (number)
6232 "Pop one article off the history and go to the previous.
6233 NUMBER articles will be popped off."
6236 (setq gnus-newsgroup-history
6237 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6239 (gnus-summary-goto-article (car to) nil t)
6240 (error "Article history empty")))
6241 (gnus-summary-position-point))
6243 ;; Summary commands and functions for limiting the summary buffer.
6245 (defun gnus-summary-limit-to-articles (n)
6246 "Limit the summary buffer to the next N articles.
6247 If not given a prefix, use the process marked articles instead."
6250 (let ((articles (gnus-summary-work-articles n)))
6251 (setq gnus-newsgroup-processable nil)
6252 (gnus-summary-limit articles))
6253 (gnus-summary-position-point)))
6255 (defun gnus-summary-pop-limit (&optional total)
6256 "Restore the previous limit.
6257 If given a prefix, remove all limits."
6260 (setq gnus-newsgroup-limits
6261 (list (mapcar (lambda (h) (mail-header-number h))
6262 gnus-newsgroup-headers))))
6263 (unless gnus-newsgroup-limits
6264 (error "No limit to pop"))
6266 (gnus-summary-limit nil 'pop)
6267 (gnus-summary-position-point)))
6269 (defun gnus-summary-limit-to-subject (subject &optional header)
6270 "Limit the summary buffer to articles that have subjects that match a regexp."
6271 (interactive "sLimit to subject (regexp): ")
6273 (setq header "subject"))
6274 (when (not (equal "" subject))
6276 (let ((articles (gnus-summary-find-matching
6277 (or header "subject") subject 'all)))
6279 (error "Found no matches for \"%s\"" subject))
6280 (gnus-summary-limit articles))
6281 (gnus-summary-position-point))))
6283 (defun gnus-summary-limit-to-author (from)
6284 "Limit the summary buffer to articles that have authors that match a regexp."
6285 (interactive "sLimit to author (regexp): ")
6286 (gnus-summary-limit-to-subject from "from"))
6288 (defun gnus-summary-limit-to-age (age &optional younger-p)
6289 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6290 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6291 articles that are younger than AGE days."
6293 (let ((younger current-prefix-arg)
6296 (while (not days-got)
6297 (setq days (if younger
6298 (read-string "Limit to articles within (in days): ")
6299 (read-string "Limit to articles old than (in days): ")))
6300 (when (> (length days) 0)
6301 (setq days (read days)))
6304 (message "Please enter a number.")
6306 (list days younger)))
6308 (let ((data gnus-newsgroup-data)
6309 (cutoff (days-to-time age))
6310 articles d date is-younger)
6311 (while (setq d (pop data))
6312 (when (and (vectorp (gnus-data-header d))
6313 (setq date (mail-header-date (gnus-data-header d))))
6314 (setq is-younger (time-less-p
6315 (time-since (condition-case ()
6322 (push (gnus-data-number d) articles))))
6323 (gnus-summary-limit (nreverse articles)))
6324 (gnus-summary-position-point)))
6326 (defun gnus-summary-limit-to-extra (header regexp)
6327 "Limit the summary buffer to articles that match an 'extra' header."
6331 (gnus-completing-read
6332 (symbol-name (car gnus-extra-headers))
6333 "Limit extra header:"
6335 (cons (symbol-name x) x))
6340 (read-string (format "Limit to header %s (regexp): " header)))))
6341 (when (not (equal "" regexp))
6343 (let ((articles (gnus-summary-find-matching
6344 (cons 'extra header) regexp 'all)))
6346 (error "Found no matches for \"%s\"" regexp))
6347 (gnus-summary-limit articles))
6348 (gnus-summary-position-point))))
6350 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6352 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6354 (defun gnus-summary-limit-to-unread (&optional all)
6355 "Limit the summary buffer to articles that are not marked as read.
6356 If ALL is non-nil, limit strictly to unread articles."
6359 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6360 (gnus-summary-limit-to-marks
6361 ;; Concat all the marks that say that an article is read and have
6363 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6364 gnus-killed-mark gnus-kill-file-mark
6365 gnus-low-score-mark gnus-expirable-mark
6366 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6367 gnus-duplicate-mark gnus-souped-mark)
6370 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6371 (make-obsolete 'gnus-summary-delete-marked-with
6372 'gnus-summary-limit-exlude-marks)
6374 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6375 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6376 If REVERSE, limit the summary buffer to articles that are marked
6377 with MARKS. MARKS can either be a string of marks or a list of marks.
6378 Returns how many articles were removed."
6379 (interactive "sMarks: ")
6380 (gnus-summary-limit-to-marks marks t))
6382 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6383 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6384 If REVERSE (the prefix), limit the summary buffer to articles that are
6385 not marked with MARKS. MARKS can either be a string of marks or a
6387 Returns how many articles were removed."
6388 (interactive "sMarks: \nP")
6390 (let ((data gnus-newsgroup-data)
6391 (marks (if (listp marks) marks
6392 (append marks nil))) ; Transform to list.
6395 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6396 (memq (gnus-data-mark (car data)) marks))
6397 (push (gnus-data-number (car data)) articles))
6398 (setq data (cdr data)))
6399 (gnus-summary-limit articles))
6400 (gnus-summary-position-point)))
6402 (defun gnus-summary-limit-to-score (&optional score)
6403 "Limit to articles with score at or above SCORE."
6405 (setq score (if score
6406 (prefix-numeric-value score)
6407 (or gnus-summary-default-score 0)))
6408 (let ((data gnus-newsgroup-data)
6411 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6413 (push (gnus-data-number (car data)) articles))
6414 (setq data (cdr data)))
6416 (gnus-summary-limit articles)
6417 (gnus-summary-position-point))))
6419 (defun gnus-summary-limit-include-thread (id)
6420 "Display all the hidden articles that in the current thread."
6421 (interactive (list (mail-header-id (gnus-summary-article-header))))
6422 (let ((articles (gnus-articles-in-thread
6423 (gnus-id-to-thread (gnus-root-id id)))))
6425 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6426 (gnus-summary-position-point))))
6428 (defun gnus-summary-limit-include-dormant ()
6429 "Display all the hidden articles that are marked as dormant.
6430 Note that this command only works on a subset of the articles currently
6431 fetched for this group."
6433 (unless gnus-newsgroup-dormant
6434 (error "There are no dormant articles in this group"))
6436 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6437 (gnus-summary-position-point)))
6439 (defun gnus-summary-limit-exclude-dormant ()
6440 "Hide all dormant articles."
6443 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6444 (gnus-summary-position-point)))
6446 (defun gnus-summary-limit-exclude-childless-dormant ()
6447 "Hide all dormant articles that have no children."
6449 (let ((data (gnus-data-list t))
6450 articles d children)
6451 ;; Find all articles that are either not dormant or have
6453 (while (setq d (pop data))
6454 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6456 (gnus-article-children (gnus-data-number d)))
6459 (when (memq (car children) articles)
6464 (push (gnus-data-number d) articles)))
6467 (gnus-summary-limit articles)
6468 (gnus-summary-position-point))))
6470 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6471 "Mark all unread excluded articles as read.
6472 If ALL, mark even excluded ticked and dormants as read."
6474 (let ((articles (gnus-sorted-complement
6476 (mapcar (lambda (h) (mail-header-number h))
6477 gnus-newsgroup-headers)
6479 (sort gnus-newsgroup-limit '<)))
6481 (setq gnus-newsgroup-unreads
6482 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6484 (setq gnus-newsgroup-dormant nil
6485 gnus-newsgroup-marked nil
6486 gnus-newsgroup-reads
6488 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6489 gnus-newsgroup-reads))
6490 (while (setq article (pop articles))
6491 (unless (or (memq article gnus-newsgroup-dormant)
6492 (memq article gnus-newsgroup-marked))
6493 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6495 (defun gnus-summary-limit (articles &optional pop)
6497 ;; We pop the previous limit off the stack and use that.
6498 (setq articles (car gnus-newsgroup-limits)
6499 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6500 ;; We use the new limit, so we push the old limit on the stack.
6501 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6503 (setq gnus-newsgroup-limit articles)
6504 (let ((total (length gnus-newsgroup-data))
6505 (data (gnus-data-find-list (gnus-summary-article-number)))
6506 (gnus-summary-mark-below nil) ; Inhibit this.
6508 ;; This will do all the work of generating the new summary buffer
6509 ;; according to the new limit.
6510 (gnus-summary-prepare)
6511 ;; Hide any threads, possibly.
6512 (and gnus-show-threads
6513 gnus-thread-hide-subtree
6514 (gnus-summary-hide-all-threads))
6515 ;; Try to return to the article you were at, or one in the
6518 ;; We try to find some article after the current one.
6520 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6523 (setq data (cdr data))))
6525 ;; If there is no data, that means that we were after the last
6526 ;; article. The same goes when we can't find any articles
6527 ;; after the current one.
6528 (goto-char (point-max))
6529 (gnus-summary-find-prev))
6530 (gnus-set-mode-line 'summary)
6531 ;; We return how many articles were removed from the summary
6532 ;; buffer as a result of the new limit.
6533 (- total (length gnus-newsgroup-data))))
6535 (defsubst gnus-invisible-cut-children (threads)
6538 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6543 (defsubst gnus-cut-thread (thread)
6544 "Go forwards in the thread until we find an article that we want to display."
6545 (when (or (eq gnus-fetch-old-headers 'some)
6546 (eq gnus-fetch-old-headers 'invisible)
6547 (numberp gnus-fetch-old-headers)
6548 (eq gnus-build-sparse-threads 'some)
6549 (eq gnus-build-sparse-threads 'more))
6550 ;; Deal with old-fetched headers and sparse threads.
6554 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6555 (gnus-summary-article-ancient-p
6556 (mail-header-number (car thread))))
6557 (if (or (<= (length (cdr thread)) 1)
6558 (eq gnus-fetch-old-headers 'invisible))
6559 (setq gnus-newsgroup-limit
6560 (delq (mail-header-number (car thread))
6561 gnus-newsgroup-limit)
6562 thread (cadr thread))
6563 (when (gnus-invisible-cut-children (cdr thread))
6564 (let ((th (cdr thread)))
6566 (if (memq (mail-header-number (caar th))
6567 gnus-newsgroup-limit)
6568 (setq thread (car th)
6570 (setq th (cdr th))))))))))
6573 (defun gnus-cut-threads (threads)
6574 "Cut off all uninteresting articles from the beginning of threads."
6575 (when (or (eq gnus-fetch-old-headers 'some)
6576 (eq gnus-fetch-old-headers 'invisible)
6577 (numberp gnus-fetch-old-headers)
6578 (eq gnus-build-sparse-threads 'some)
6579 (eq gnus-build-sparse-threads 'more))
6582 (setcar th (gnus-cut-thread (car th)))
6583 (setq th (cdr th)))))
6584 ;; Remove nixed out threads.
6587 (defun gnus-summary-initial-limit (&optional show-if-empty)
6588 "Figure out what the initial limit is supposed to be on group entry.
6589 This entails weeding out unwanted dormants, low-scored articles,
6590 fetch-old-headers verbiage, and so on."
6591 ;; Most groups have nothing to remove.
6592 (if (or gnus-inhibit-limiting
6593 (and (null gnus-newsgroup-dormant)
6594 (not (eq gnus-fetch-old-headers 'some))
6595 (not (numberp gnus-fetch-old-headers))
6596 (not (eq gnus-fetch-old-headers 'invisible))
6597 (null gnus-summary-expunge-below)
6598 (not (eq gnus-build-sparse-threads 'some))
6599 (not (eq gnus-build-sparse-threads 'more))
6600 (null gnus-thread-expunge-below)
6601 (not gnus-use-nocem)))
6603 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6604 (setq gnus-newsgroup-limit nil)
6607 (unless (car (symbol-value node))
6608 ;; These threads have no parents -- they are roots.
6609 (let ((nodes (cdr (symbol-value node)))
6612 (if (and gnus-thread-expunge-below
6613 (< (gnus-thread-total-score (car nodes))
6614 gnus-thread-expunge-below))
6615 (gnus-expunge-thread (pop nodes))
6616 (setq thread (pop nodes))
6617 (gnus-summary-limit-children thread))))))
6618 gnus-newsgroup-dependencies)
6619 ;; If this limitation resulted in an empty group, we might
6620 ;; pop the previous limit and use it instead.
6621 (when (and (not gnus-newsgroup-limit)
6623 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6624 gnus-newsgroup-limit))
6626 (defun gnus-summary-limit-children (thread)
6627 "Return 1 if this subthread is visible and 0 if it is not."
6628 ;; First we get the number of visible children to this thread. This
6629 ;; is done by recursing down the thread using this function, so this
6630 ;; will really go down to a leaf article first, before slowly
6631 ;; working its way up towards the root.
6635 (apply '+ (mapcar 'gnus-summary-limit-children
6638 (number (mail-header-number (car thread)))
6641 (not (memq number gnus-newsgroup-marked))
6643 ;; If this article is dormant and has absolutely no visible
6644 ;; children, then this article isn't visible.
6645 (and (memq number gnus-newsgroup-dormant)
6647 ;; If this is "fetch-old-headered" and there is no
6648 ;; visible children, then we don't want this article.
6649 (and (or (eq gnus-fetch-old-headers 'some)
6650 (numberp gnus-fetch-old-headers))
6651 (gnus-summary-article-ancient-p number)
6653 ;; If this is "fetch-old-headered" and `invisible', then
6654 ;; we don't want this article.
6655 (and (eq gnus-fetch-old-headers 'invisible)
6656 (gnus-summary-article-ancient-p number))
6657 ;; If this is a sparsely inserted article with no children,
6658 ;; we don't want it.
6659 (and (eq gnus-build-sparse-threads 'some)
6660 (gnus-summary-article-sparse-p number)
6662 ;; If we use expunging, and this article is really
6663 ;; low-scored, then we don't want this article.
6664 (when (and gnus-summary-expunge-below
6666 (or (cdr (assq number gnus-newsgroup-scored))
6667 gnus-summary-default-score))
6668 gnus-summary-expunge-below))
6669 ;; We increase the expunge-tally here, but that has
6670 ;; nothing to do with the limits, really.
6671 (incf gnus-newsgroup-expunged-tally)
6672 ;; We also mark as read here, if that's wanted.
6673 (when (and gnus-summary-mark-below
6674 (< score gnus-summary-mark-below))
6675 (setq gnus-newsgroup-unreads
6676 (delq number gnus-newsgroup-unreads))
6677 (if gnus-newsgroup-auto-expire
6678 (push number gnus-newsgroup-expirable)
6679 (push (cons number gnus-low-score-mark)
6680 gnus-newsgroup-reads)))
6682 ;; Check NoCeM things.
6683 (if (and gnus-use-nocem
6684 (gnus-nocem-unwanted-article-p
6685 (mail-header-id (car thread))))
6687 (setq gnus-newsgroup-unreads
6688 (delq number gnus-newsgroup-unreads))
6690 ;; Nope, invisible article.
6692 ;; Ok, this article is to be visible, so we add it to the limit
6694 (push number gnus-newsgroup-limit)
6697 (defun gnus-expunge-thread (thread)
6698 "Mark all articles in THREAD as read."
6699 (let* ((number (mail-header-number (car thread))))
6700 (incf gnus-newsgroup-expunged-tally)
6701 ;; We also mark as read here, if that's wanted.
6702 (setq gnus-newsgroup-unreads
6703 (delq number gnus-newsgroup-unreads))
6704 (if gnus-newsgroup-auto-expire
6705 (push number gnus-newsgroup-expirable)
6706 (push (cons number gnus-low-score-mark)
6707 gnus-newsgroup-reads)))
6708 ;; Go recursively through all subthreads.
6709 (mapcar 'gnus-expunge-thread (cdr thread)))
6711 ;; Summary article oriented commands
6713 (defun gnus-summary-refer-parent-article (n)
6714 "Refer parent article N times.
6715 If N is negative, go to ancestor -N instead.
6716 The difference between N and the number of articles fetched is returned."
6720 (when (not (natnump n))
6725 (setq header (gnus-summary-article-header))
6726 (if (and (eq (mail-header-number header)
6727 (cdr gnus-article-current))
6728 (equal gnus-newsgroup-name
6729 (car gnus-article-current)))
6730 ;; If we try to find the parent of the currently
6731 ;; displayed article, then we take a look at the actual
6732 ;; References header, since this is slightly more
6733 ;; reliable than the References field we got from the
6736 (set-buffer gnus-original-article-buffer)
6737 (nnheader-narrow-to-headers)
6738 (unless (setq ref (message-fetch-field "references"))
6739 (setq ref (message-fetch-field "in-reply-to")))
6742 ;; It's not the current article, so we take a bet on
6743 ;; the value we got from the server.
6744 (mail-header-references header)))
6746 (not (equal ref "")))
6747 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6748 (gnus-message 1 "Couldn't find parent"))
6749 (gnus-message 1 "No references in article %d"
6750 (gnus-summary-article-number))
6753 (gnus-summary-position-point)
6756 (defun gnus-summary-refer-references ()
6757 "Fetch all articles mentioned in the References header.
6758 Return the number of articles fetched."
6760 (let ((ref (mail-header-references (gnus-summary-article-header)))
6761 (current (gnus-summary-article-number))
6765 (error "No References in the current article")
6766 ;; For each Message-ID in the References header...
6767 (while (string-match "<[^>]*>" ref)
6769 ;; ... fetch that article.
6770 (gnus-summary-refer-article
6771 (prog1 (match-string 0 ref)
6772 (setq ref (substring ref (match-end 0))))))
6773 (gnus-summary-goto-subject current)
6774 (gnus-summary-position-point)
6777 (defun gnus-summary-refer-thread (&optional limit)
6778 "Fetch all articles in the current thread.
6779 If LIMIT (the numerical prefix), fetch that many old headers instead
6780 of what's specified by the `gnus-refer-thread-limit' variable."
6782 (let ((id (mail-header-id (gnus-summary-article-header)))
6783 (limit (if limit (prefix-numeric-value limit)
6784 gnus-refer-thread-limit)))
6785 ;; We want to fetch LIMIT *old* headers, but we also have to
6786 ;; re-fetch all the headers in the current buffer, because many of
6787 ;; them may be undisplayed. So we adjust LIMIT.
6788 (when (numberp limit)
6789 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6790 (unless (eq gnus-fetch-old-headers 'invisible)
6791 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6792 ;; Retrieve the headers and read them in.
6793 (if (eq (gnus-retrieve-headers
6794 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6796 (gnus-build-all-threads)
6797 (error "Can't fetch thread from backends that don't support NOV"))
6798 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6799 (gnus-summary-limit-include-thread id)))
6801 (defun gnus-summary-refer-article (message-id)
6802 "Fetch an article specified by MESSAGE-ID."
6803 (interactive "sMessage-ID: ")
6804 (when (and (stringp message-id)
6805 (not (zerop (length message-id))))
6806 ;; Construct the correct Message-ID if necessary.
6807 ;; Suggested by tale@pawl.rpi.edu.
6808 (unless (string-match "^<" message-id)
6809 (setq message-id (concat "<" message-id)))
6810 (unless (string-match ">$" message-id)
6811 (setq message-id (concat message-id ">")))
6812 (let* ((header (gnus-id-to-header message-id))
6814 (gnus-summary-article-sparse-p
6815 (mail-header-number header))
6816 (memq (mail-header-number header)
6817 gnus-newsgroup-limit)))
6820 ;; If the article is present in the buffer we just go to it.
6822 (or (not (gnus-summary-article-sparse-p
6823 (mail-header-number header)))
6826 (gnus-summary-goto-article
6827 (mail-header-number header) nil t)
6829 (gnus-summary-update-article (mail-header-number header)))))
6831 ;; We fetch the article.
6833 (dolist (gnus-override-method (gnus-refer-article-methods))
6834 (gnus-check-server gnus-override-method)
6835 ;; Fetch the header, and display the article.
6836 (when (setq number (gnus-summary-insert-subject message-id))
6837 (gnus-summary-select-article nil nil nil number)
6839 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6841 (defun gnus-refer-article-methods ()
6842 "Return a list of referrable methods."
6844 ;; No method, so we default to current and native.
6845 ((null gnus-refer-article-method)
6846 (list gnus-current-select-method gnus-select-method))
6848 ((eq 'current gnus-refer-article-method)
6849 (list gnus-current-select-method))
6850 ;; List of select methods.
6851 ((not (stringp (cadr gnus-refer-article-method)))
6853 (dolist (method gnus-refer-article-method)
6854 (push (if (eq 'current method)
6855 gnus-current-select-method
6859 ;; One single select method.
6861 (list gnus-refer-article-method))))
6863 (defun gnus-summary-edit-parameters ()
6864 "Edit the group parameters of the current group."
6866 (gnus-group-edit-group gnus-newsgroup-name 'params))
6868 (defun gnus-summary-customize-parameters ()
6869 "Customize the group parameters of the current group."
6871 (gnus-group-customize gnus-newsgroup-name))
6873 (defun gnus-summary-enter-digest-group (&optional force)
6874 "Enter an nndoc group based on the current article.
6875 If FORCE, force a digest interpretation. If not, try
6876 to guess what the document format is."
6878 (let ((conf gnus-current-window-configuration))
6880 (gnus-summary-select-article))
6881 (setq gnus-current-window-configuration conf)
6882 (let* ((name (format "%s-%d"
6883 (gnus-group-prefixed-name
6884 gnus-newsgroup-name (list 'nndoc ""))
6886 (set-buffer gnus-summary-buffer)
6887 gnus-current-article)))
6888 (ogroup gnus-newsgroup-name)
6889 (params (append (gnus-info-params (gnus-get-info ogroup))
6890 (list (cons 'to-group ogroup))
6891 (list (cons 'save-article-group ogroup))))
6892 (case-fold-search t)
6893 (buf (current-buffer))
6896 (set-buffer gnus-original-article-buffer)
6897 ;; Have the digest group inherit the main mail address of
6898 ;; the parent article.
6899 (when (setq to-address (or (message-fetch-field "reply-to")
6900 (message-fetch-field "from")))
6901 (setq params (append (list (cons 'to-address to-address)))))
6902 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6903 (insert-buffer-substring gnus-original-article-buffer)
6904 ;; Remove lines that may lead nndoc to misinterpret the
6907 (goto-char (point-min))
6908 (or (search-forward "\n\n" nil t) (point)))
6909 (goto-char (point-min))
6910 (delete-matching-lines "^Path:\\|^From ")
6913 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6914 (gnus-newsgroup-ephemeral-ignored-charsets
6915 gnus-newsgroup-ignored-charsets))
6916 (gnus-group-read-ephemeral-group
6917 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6919 ,(if force 'mbox 'guess))) t))
6920 ;; Make all postings to this group go to the parent group.
6921 (nconc (gnus-info-params (gnus-get-info name))
6923 ;; Couldn't select this doc group.
6924 (switch-to-buffer buf)
6925 (gnus-set-global-variables)
6926 (gnus-configure-windows 'summary)
6927 (gnus-message 3 "Article couldn't be entered?"))
6928 (kill-buffer dig)))))
6930 (defun gnus-summary-read-document (n)
6931 "Open a new group based on the current article(s).
6932 This will allow you to read digests and other similar
6933 documents as newsgroups.
6934 Obeys the standard process/prefix convention."
6936 (let* ((articles (gnus-summary-work-articles n))
6937 (ogroup gnus-newsgroup-name)
6938 (params (append (gnus-info-params (gnus-get-info ogroup))
6939 (list (cons 'to-group ogroup))))
6940 article group egroup groups vgroup)
6941 (while (setq article (pop articles))
6942 (setq group (format "%s-%d" gnus-newsgroup-name article))
6943 (gnus-summary-remove-process-mark article)
6944 (when (gnus-summary-display-article article)
6947 (insert-buffer-substring gnus-original-article-buffer)
6948 ;; Remove some headers that may lead nndoc to make
6950 (message-narrow-to-head)
6951 (goto-char (point-min))
6952 (delete-matching-lines "^\\(Path\\):\\|^From ")
6955 (gnus-group-read-ephemeral-group
6956 group `(nndoc ,group (nndoc-address ,(current-buffer))
6957 (nndoc-article-type guess))
6960 ;; Make all postings to this group go to the parent group.
6961 (nconc (gnus-info-params (gnus-get-info egroup))
6963 (push egroup groups))
6964 ;; Couldn't select this doc group.
6965 (gnus-error 3 "Article couldn't be entered"))))))
6966 ;; Now we have selected all the documents.
6969 (error "None of the articles could be interpreted as documents"))
6970 ((gnus-group-read-ephemeral-group
6971 (setq vgroup (format
6972 "nnvirtual:%s-%s" gnus-newsgroup-name
6973 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6974 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6976 (cons (current-buffer) 'summary)))
6978 (error "Couldn't select virtual nndoc group")))))
6980 (defun gnus-summary-isearch-article (&optional regexp-p)
6981 "Do incremental search forward on the current article.
6982 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6984 (let* ((gnus-inhibit-treatment t)
6985 (old (gnus-summary-select-article)))
6986 (gnus-configure-windows 'article)
6987 (gnus-eval-in-buffer-window gnus-article-buffer
6991 (gnus-article-show-all-headers))
6992 (goto-char (point-min))
6993 (isearch-forward regexp-p)))))
6995 (defun gnus-summary-search-article-forward (regexp &optional backward)
6996 "Search for an article containing REGEXP forward.
6997 If BACKWARD, search backward instead."
7000 (format "Search article %s (regexp%s): "
7001 (if current-prefix-arg "backward" "forward")
7002 (if gnus-last-search-regexp
7003 (concat ", default " gnus-last-search-regexp)
7005 current-prefix-arg))
7006 (if (string-equal regexp "")
7007 (setq regexp (or gnus-last-search-regexp ""))
7008 (setq gnus-last-search-regexp regexp))
7009 (if (gnus-summary-search-article regexp backward)
7010 (gnus-summary-show-thread)
7011 (error "Search failed: \"%s\"" regexp)))
7013 (defun gnus-summary-search-article-backward (regexp)
7014 "Search for an article containing REGEXP backward."
7017 (format "Search article backward (regexp%s): "
7018 (if gnus-last-search-regexp
7019 (concat ", default " gnus-last-search-regexp)
7021 (gnus-summary-search-article-forward regexp 'backward))
7024 (defmacro gnus-summary-search-article-position-point (regexp backward)
7025 "Dehighlight the last matched text and goto the beginning position."
7026 (` (if (and gnus-summary-search-article-matched-data
7027 (let ((text (caddr gnus-summary-search-article-matched-data))
7028 (inhibit-read-only t)
7031 (goto-char (car gnus-summary-search-article-matched-data))
7032 (cadr gnus-summary-search-article-matched-data))
7034 (string-match (, regexp) text)))
7035 (if (, backward) (beginning-of-line) (end-of-line))
7036 (goto-char (if (, backward) (point-max) (point-min))))))
7038 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7039 "Place point where X-Face image is displayed."
7040 (if (featurep 'xemacs)
7041 (` (let ((end (if (search-forward "\n\n" nil t)
7042 (goto-char (1- (point)))
7045 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7046 (unless (and (re-search-forward "^From:" end t)
7047 (setq extent (extent-at (point)))
7048 (extent-begin-glyph extent))
7049 (goto-char (, opoint)))))
7050 (` (let ((end (if (search-forward "\n\n" nil t)
7051 (goto-char (1- (point)))
7054 (or (text-property-any (or (search-backward "\n\n" nil t)
7056 end 'x-face-mule-bitmap-image t)
7059 (defmacro gnus-summary-search-article-highlight-matched-text
7060 (backward treated x-face)
7061 "Highlight matched text in the function `gnus-summary-search-article'."
7062 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7063 (end (set-marker (make-marker) (match-end 0)))
7064 (inhibit-read-only t)
7068 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7070 (lambda (item) (setq items (delq item items)))
7071 '(gnus-treat-buttonize
7072 gnus-treat-fill-article
7073 gnus-treat-fill-long-lines
7074 gnus-treat-emphasize
7075 gnus-treat-highlight-headers
7076 gnus-treat-highlight-citation
7077 gnus-treat-highlight-signature
7078 gnus-treat-overstrike
7079 gnus-treat-display-xface
7080 gnus-treat-buttonize-head
7081 gnus-treat-decode-article-as-default-mime-charset))
7082 (static-if (featurep 'xemacs)
7084 (cons '(x-face-mule-delete-x-face-field
7087 (gnus-treat-display-xface
7088 (when (, x-face) gnus-treat-display-xface)))
7089 (gnus-article-prepare-mime-display)))
7090 (goto-char (if (, backward) start end))
7092 (gnus-summary-search-article-highlight-goto-x-face (point)))
7093 (setq gnus-summary-search-article-matched-data
7094 (list start end (buffer-substring start end)))
7095 (unless (eq start end);; matched text has been deleted. :-<
7096 (put-text-property start end 'face
7097 (or (find-face 'isearch)
7098 'secondary-selection))))))
7101 (defun gnus-summary-search-article (regexp &optional backward)
7102 "Search for an article containing REGEXP.
7103 Optional argument BACKWARD means do search for backward.
7104 `gnus-select-article-hook' is not called during the search."
7105 ;; We have to require this here to make sure that the following
7106 ;; dynamic binding isn't shadowed by autoloading.
7107 (require 'gnus-async)
7109 (let ((gnus-select-article-hook nil) ;Disable hook.
7110 (gnus-article-display-hook nil)
7111 (gnus-article-prepare-hook nil)
7112 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7113 (gnus-use-article-prefetch nil)
7114 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7115 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7116 (sum (current-buffer))
7119 (gnus-save-hidden-threads
7120 (static-if (featurep 'xemacs)
7121 (let ((gnus-inhibit-treatment t))
7122 (setq treated (eq 'old (gnus-summary-select-article)))
7124 (not (and (gnus-buffer-live-p gnus-article-buffer)
7125 (window-live-p (get-buffer-window
7126 gnus-article-buffer t)))))
7127 (gnus-summary-select-article nil t)
7128 (setq treated nil)))
7129 (let ((gnus-inhibit-treatment t)
7130 (x-face-mule-delete-x-face-field 'never))
7131 (setq treated (eq 'old (gnus-summary-select-article)))
7134 (and (gnus-buffer-live-p gnus-article-buffer)
7135 (window-live-p (get-buffer-window
7136 gnus-article-buffer t))
7137 (or (not (string-match "^\\^X-Face:" regexp))
7138 (with-current-buffer gnus-article-buffer
7139 gnus-summary-search-article-matched-data)))))
7140 (gnus-summary-select-article nil t)
7141 (setq treated nil))))
7142 (set-buffer gnus-article-buffer)
7146 (gnus-article-show-all-headers)
7147 (gnus-summary-search-article-position-point regexp backward))
7148 (goto-char (if backward (point-max) (point-min))))
7150 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7152 (re-search-backward regexp nil t)
7153 (re-search-forward regexp nil t))
7154 ;; We found the regexp.
7156 (gnus-summary-search-article-highlight-matched-text
7157 backward treated (string-match "^\\^X-Face:" regexp))
7160 (/ (- 2 (window-height
7161 (get-buffer-window gnus-article-buffer t)))
7164 (get-buffer-window (current-buffer))
7167 (setq point (point)))
7168 ;; We didn't find it, so we go to the next article.
7171 (while (eq found 'not)
7172 (if (not (if backward (gnus-summary-find-prev)
7173 (gnus-summary-find-next)))
7174 ;; No more articles.
7176 ;; Select the next article and adjust point.
7177 (unless (gnus-summary-article-sparse-p
7178 (gnus-summary-article-number))
7180 (let ((gnus-inhibit-treatment t))
7181 (gnus-summary-select-article))
7183 (set-buffer gnus-article-buffer)
7185 (goto-char (if backward (point-max) (point-min))))))))
7186 (gnus-message 7 ""))
7187 ;; Return whether we found the regexp.
7188 (when (eq found 'found)
7190 (gnus-summary-show-thread)
7191 (gnus-summary-goto-subject gnus-current-article)
7192 (gnus-summary-position-point)
7195 (defun gnus-summary-find-matching (header regexp &optional backward unread
7197 "Return a list of all articles that match REGEXP on HEADER.
7198 The search stars on the current article and goes forwards unless
7199 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7200 If UNREAD is non-nil, only unread articles will
7201 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7202 in the comparisons."
7203 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7204 (gnus-data-find-list
7205 (gnus-summary-article-number) (gnus-data-list backward))))
7206 (case-fold-search (not not-case-fold))
7209 (if (eq (car header) 'extra)
7212 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7214 (error "%s is an invalid header" header))
7215 (unless (fboundp (intern (concat "mail-header-" header)))
7216 (error "%s is not a valid header" header))
7217 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7220 (and (or (not unread) ; We want all articles...
7221 (gnus-data-unread-p d)) ; Or just unreads.
7222 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7223 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7224 (push (gnus-data-number d) articles)) ; Success!
7225 (setq data (cdr data)))
7226 (nreverse articles)))
7228 (defun gnus-summary-execute-command (header regexp command &optional backward)
7229 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7230 If HEADER is an empty string (or nil), the match is done on the entire
7231 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7233 (list (let ((completion-ignore-case t))
7236 (mapcar (lambda (string) (list string))
7237 '("Number" "Subject" "From" "Lines" "Date"
7238 "Message-ID" "Xref" "References" "Body"))
7239 nil 'require-match))
7240 (read-string "Regexp: ")
7241 (read-key-sequence "Command: ")
7242 current-prefix-arg))
7243 (when (equal header "Body")
7245 ;; Hidden thread subtrees must be searched as well.
7246 (gnus-summary-show-all-threads)
7247 ;; We don't want to change current point nor window configuration.
7249 (save-window-excursion
7250 (gnus-message 6 "Executing %s..." (key-description command))
7251 ;; We'd like to execute COMMAND interactively so as to give arguments.
7252 (gnus-execute header regexp
7253 `(call-interactively ',(key-binding command))
7255 (gnus-message 6 "Executing %s...done" (key-description command)))))
7257 (defun gnus-summary-beginning-of-article ()
7258 "Scroll the article back to the beginning."
7260 (gnus-summary-select-article)
7261 (gnus-configure-windows 'article)
7262 (gnus-eval-in-buffer-window gnus-article-buffer
7264 (goto-char (point-min))
7265 (when gnus-page-broken
7266 (gnus-narrow-to-page))))
7268 (defun gnus-summary-end-of-article ()
7269 "Scroll to the end of the article."
7271 (gnus-summary-select-article)
7272 (gnus-configure-windows 'article)
7273 (gnus-eval-in-buffer-window gnus-article-buffer
7275 (goto-char (point-max))
7277 (when gnus-page-broken
7278 (gnus-narrow-to-page))))
7280 (defun gnus-summary-print-article (&optional filename n)
7281 "Generate and print a PostScript image of the N next (mail) articles.
7283 If N is negative, print the N previous articles. If N is nil and articles
7284 have been marked with the process mark, print these instead.
7286 If the optional first argument FILENAME is nil, send the image to the
7287 printer. If FILENAME is a string, save the PostScript image in a file with
7288 that name. If FILENAME is a number, prompt the user for the name of the file
7290 (interactive (list (ps-print-preprint current-prefix-arg)
7291 current-prefix-arg))
7292 (dolist (article (gnus-summary-work-articles n))
7293 (gnus-summary-select-article nil nil 'pseudo article)
7294 (gnus-eval-in-buffer-window gnus-article-buffer
7295 (let ((buffer (generate-new-buffer " *print*")))
7298 (copy-to-buffer buffer (point-min) (point-max))
7300 (gnus-article-delete-invisible-text)
7301 (let ((ps-left-header
7304 (mail-header-subject gnus-current-headers) ")")
7306 (mail-header-from gnus-current-headers) ")")))
7309 "/pagenumberstring load"
7311 (mail-header-date gnus-current-headers) ")"))))
7312 (gnus-run-hooks 'gnus-ps-print-hook)
7314 (ps-print-buffer-with-faces filename))))
7315 (kill-buffer buffer))))))
7317 (defun gnus-summary-show-article (&optional arg)
7318 "Force re-fetching of the current article.
7319 If ARG (the prefix) is a number, show the article with the charset
7320 defined in `gnus-summary-show-article-charset-alist', or the charset
7322 If ARG (the prefix) is non-nil and not a number, show the raw article
7323 without any article massaging functions being run."
7327 (let ((gnus-newsgroup-charset
7328 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7329 (read-coding-system "Charset: ")))
7330 (gnus-newsgroup-ignored-charsets 'gnus-all))
7331 (gnus-summary-select-article nil 'force)))
7333 ;; Select the article the normal way.
7334 (gnus-summary-select-article nil 'force))
7336 ;; We have to require this here to make sure that the following
7337 ;; dynamic binding isn't shadowed by autoloading.
7338 (require 'gnus-async)
7340 ;; Bind the article treatment functions to nil.
7341 (let ((gnus-have-all-headers t)
7342 gnus-article-display-hook
7343 gnus-article-prepare-hook
7344 gnus-article-decode-hook
7347 (gnus-summary-select-article nil 'force))))
7348 (gnus-summary-goto-subject gnus-current-article)
7349 (gnus-summary-position-point))
7351 (defun gnus-summary-verbose-headers (&optional arg)
7352 "Toggle permanent full header display.
7353 If ARG is a positive number, turn header display on.
7354 If ARG is a negative number, turn header display off."
7356 (setq gnus-show-all-headers
7357 (cond ((or (not (numberp arg))
7359 (not gnus-show-all-headers))
7362 (gnus-summary-show-article))
7364 (defun gnus-summary-toggle-header (&optional arg)
7365 "Show the headers if they are hidden, or hide them if they are shown.
7366 If ARG is a positive number, show the entire header.
7367 If ARG is a negative number, hide the unwanted header lines."
7370 (set-buffer gnus-article-buffer)
7372 (let* ((buffer-read-only nil)
7373 (inhibit-point-motion-hooks t)
7379 (article-narrow-to-head)
7380 (gnus-article-hidden-text-p 'headers))))
7381 (goto-char (point-min))
7382 (when (search-forward "\n\n" nil t)
7383 (delete-region (point-min) (1- (point))))
7384 (goto-char (point-min))
7386 (set-buffer gnus-original-article-buffer)
7387 (goto-char (point-min))
7388 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7389 (insert-buffer-substring gnus-original-article-buffer 1 e)
7391 (narrow-to-region (point-min) (point))
7392 (article-decode-encoded-words)
7394 (let ((gnus-treat-hide-headers nil)
7395 (gnus-treat-hide-boring-headers nil))
7396 (setq gnus-article-wash-types
7397 (delq 'headers gnus-article-wash-types))
7398 (gnus-treat-article 'head))
7399 (gnus-treat-article 'head)))
7400 (gnus-set-mode-line 'article)))))
7402 (defun gnus-summary-show-all-headers ()
7403 "Make all header lines visible."
7405 (gnus-article-show-all-headers))
7407 (defun gnus-summary-toggle-mime (&optional arg)
7408 "Toggle MIME processing.
7409 If ARG is a positive number, turn MIME processing on."
7411 (setq gnus-show-mime
7413 (not gnus-show-mime)
7414 (> (prefix-numeric-value arg) 0)))
7415 (gnus-summary-select-article t 'force))
7417 (defun gnus-summary-caesar-message (&optional arg)
7418 "Caesar rotate the current article by 13.
7419 The numerical prefix specifies how many places to rotate each letter
7422 (gnus-summary-select-article)
7423 (let ((mail-header-separator ""))
7424 (gnus-eval-in-buffer-window gnus-article-buffer
7427 (let ((start (window-start))
7429 (message-caesar-buffer-body arg)
7430 (set-window-start (get-buffer-window (current-buffer)) start))))))
7432 (defun gnus-summary-stop-page-breaking ()
7433 "Stop page breaking in the current article."
7435 (gnus-summary-select-article)
7436 (gnus-eval-in-buffer-window gnus-article-buffer
7438 (when (gnus-visual-p 'page-marker)
7439 (let ((buffer-read-only nil))
7440 (gnus-remove-text-with-property 'gnus-prev)
7441 (gnus-remove-text-with-property 'gnus-next))
7442 (setq gnus-page-broken nil))))
7444 (defun gnus-summary-move-article (&optional n to-newsgroup
7445 select-method action)
7446 "Move the current article to a different newsgroup.
7447 If N is a positive number, move the N next articles.
7448 If N is a negative number, move the N previous articles.
7449 If N is nil and any articles have been marked with the process mark,
7450 move those articles instead.
7451 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7452 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7453 re-spool using this method.
7455 For this function to work, both the current newsgroup and the
7456 newsgroup that you want to move to have to support the `request-move'
7457 and `request-accept' functions.
7459 ACTION can be either `move' (the default), `crosspost' or `copy'."
7462 (setq action 'move))
7463 ;; Disable marking as read.
7464 (let (gnus-mark-article-hook)
7465 (save-window-excursion
7466 (gnus-summary-select-article)))
7467 ;; Check whether the source group supports the required functions.
7468 (cond ((and (eq action 'move)
7469 (not (gnus-check-backend-function
7470 'request-move-article gnus-newsgroup-name)))
7471 (error "The current group does not support article moving"))
7472 ((and (eq action 'crosspost)
7473 (not (gnus-check-backend-function
7474 'request-replace-article gnus-newsgroup-name)))
7475 (error "The current group does not support article editing")))
7476 (let ((articles (gnus-summary-work-articles n))
7477 (prefix (if (gnus-check-backend-function
7478 'request-move-article gnus-newsgroup-name)
7479 (gnus-group-real-prefix gnus-newsgroup-name)
7481 (names '((move "Move" "Moving")
7482 (copy "Copy" "Copying")
7483 (crosspost "Crosspost" "Crossposting")))
7484 (copy-buf (save-excursion
7485 (nnheader-set-temp-buffer " *copy article*")))
7486 (default-marks gnus-article-mark-lists)
7487 (no-expire-marks (delete '(expirable . expire)
7488 (copy-sequence gnus-article-mark-lists)))
7489 art-group to-method new-xref article to-groups)
7490 (unless (assq action names)
7491 (error "Unknown action %s" action))
7492 ;; Read the newsgroup name.
7493 (when (and (not to-newsgroup)
7494 (not select-method))
7496 (gnus-read-move-group-name
7497 (cadr (assq action names))
7498 (symbol-value (intern (format "gnus-current-%s-group" action)))
7500 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7501 (setq to-method (or select-method
7502 (gnus-group-name-to-method to-newsgroup)))
7503 ;; Check the method we are to move this article to...
7504 (unless (gnus-check-backend-function
7505 'request-accept-article (car to-method))
7506 (error "%s does not support article copying" (car to-method)))
7507 (unless (gnus-check-server to-method)
7508 (error "Can't open server %s" (car to-method)))
7509 (gnus-message 6 "%s to %s: %s..."
7510 (caddr (assq action names))
7511 (or (car select-method) to-newsgroup) articles)
7513 (setq article (pop articles))
7517 ;; Move the article.
7519 ;; Remove this article from future suppression.
7520 (gnus-dup-unsuppress-article article)
7521 (gnus-request-move-article
7522 article ; Article to move
7523 gnus-newsgroup-name ; From newsgroup
7524 (nth 1 (gnus-find-method-for-group
7525 gnus-newsgroup-name)) ; Server
7526 (list 'gnus-request-accept-article
7527 to-newsgroup (list 'quote select-method)
7528 (not articles) t) ; Accept form
7529 (not articles))) ; Only save nov last time
7530 ;; Copy the article.
7533 (set-buffer copy-buf)
7534 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7535 (gnus-request-accept-article
7536 to-newsgroup select-method (not articles) t))))
7537 ;; Crosspost the article.
7538 ((eq action 'crosspost)
7539 (let ((xref (message-tokenize-header
7540 (mail-header-xref (gnus-summary-article-header article))
7542 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7545 (setq xref (list (system-name))))
7548 (mapconcat 'identity
7549 (delete "Xref:" (delete new-xref xref))
7553 (set-buffer copy-buf)
7554 ;; First put the article in the destination group.
7555 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7556 (when (consp (setq art-group
7557 (gnus-request-accept-article
7558 to-newsgroup select-method (not articles))))
7559 (setq new-xref (concat new-xref " " (car art-group)
7560 ":" (cdr art-group)))
7561 ;; Now we have the new Xrefs header, so we insert
7562 ;; it and replace the new article.
7563 (nnheader-replace-header "Xref" new-xref)
7564 (gnus-request-replace-article
7565 (cdr art-group) to-newsgroup (current-buffer))
7569 (gnus-message 1 "Couldn't %s article %s: %s"
7570 (cadr (assq action names)) article
7571 (nnheader-get-report (car to-method))))
7572 ((eq art-group 'junk)
7573 (when (eq action 'move)
7574 (gnus-summary-mark-article article gnus-canceled-mark)
7575 (gnus-message 4 "Deleted article %s" article)))
7577 (let* ((pto-group (gnus-group-prefixed-name
7578 (car art-group) to-method))
7580 (gnus-gethash pto-group gnus-newsrc-hashtb))
7581 (info (nth 2 entry))
7582 (to-group (gnus-info-group info))
7584 ;; Update the group that has been moved to.
7586 (memq action '(move copy)))
7587 (unless (member to-group to-groups)
7588 (push to-group to-groups))
7590 (unless (memq article gnus-newsgroup-unreads)
7591 (push 'read to-marks)
7593 info (gnus-add-to-range (gnus-info-read info)
7594 (list (cdr art-group)))))
7596 ;; See whether the article is to be put in the cache.
7597 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7600 (to-article (cdr art-group)))
7602 ;; Enter the article into the cache in the new group,
7603 ;; if that is required.
7604 (when gnus-use-cache
7605 (gnus-cache-possibly-enter-article
7607 (let ((header (copy-sequence
7608 (gnus-summary-article-header article))))
7609 (mail-header-set-number header to-article)
7611 (memq article gnus-newsgroup-marked)
7612 (memq article gnus-newsgroup-dormant)
7613 (memq article gnus-newsgroup-unreads)))
7615 (when gnus-preserve-marks
7616 ;; Copy any marks over to the new group.
7617 (when (and (equal to-group gnus-newsgroup-name)
7618 (not (memq article gnus-newsgroup-unreads)))
7619 ;; Mark this article as read in this group.
7620 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7621 (setcdr (gnus-active to-group) to-article)
7622 (setcdr gnus-newsgroup-active to-article))
7625 (when (memq article (symbol-value
7626 (intern (format "gnus-newsgroup-%s"
7628 (push (cdar marks) to-marks)
7629 ;; If the other group is the same as this group,
7630 ;; then we have to add the mark to the list.
7631 (when (equal to-group gnus-newsgroup-name)
7632 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7635 (intern (format "gnus-newsgroup-%s"
7637 ;; Copy the marks to other group.
7638 (gnus-add-marked-articles
7639 to-group (cdar marks) (list to-article) info))
7640 (setq marks (cdr marks)))
7642 (gnus-request-set-mark to-group (list (list (list to-article)
7647 (concat "(gnus-group-set-info '"
7648 (gnus-prin1-to-string (gnus-get-info to-group))
7651 ;; Update the Xref header in this article to point to
7652 ;; the new crossposted article we have just created.
7653 (when (eq action 'crosspost)
7655 (set-buffer copy-buf)
7656 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7657 (nnheader-replace-header "Xref" new-xref)
7658 (gnus-request-replace-article
7659 article gnus-newsgroup-name (current-buffer)))))
7661 ;;;!!!Why is this necessary?
7662 (set-buffer gnus-summary-buffer)
7664 (gnus-summary-goto-subject article)
7665 (when (eq action 'move)
7666 (gnus-summary-mark-article article gnus-canceled-mark))))
7667 (gnus-summary-remove-process-mark article))
7668 ;; Re-activate all groups that have been moved to.
7671 (set-buffer gnus-group-buffer)
7672 (when (gnus-group-goto-group (car to-groups) t)
7673 (gnus-group-get-new-news-this-group 1 t))
7676 (gnus-kill-buffer copy-buf)
7677 (gnus-summary-position-point)
7678 (gnus-set-mode-line 'summary)))
7680 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7681 "Move the current article to a different newsgroup.
7682 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7683 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7684 re-spool using this method."
7686 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7688 (defun gnus-summary-crosspost-article (&optional n)
7689 "Crosspost the current article to some other group."
7691 (gnus-summary-move-article n nil nil 'crosspost))
7693 (defcustom gnus-summary-respool-default-method nil
7694 "Default method for respooling an article.
7695 If nil, use to the current newsgroup method."
7696 :type '(choice (gnus-select-method :value (nnml ""))
7698 :group 'gnus-summary-mail)
7700 (defun gnus-summary-respool-article (&optional n method)
7701 "Respool the current article.
7702 The article will be squeezed through the mail spooling process again,
7703 which means that it will be put in some mail newsgroup or other
7704 depending on `nnmail-split-methods'.
7705 If N is a positive number, respool the N next articles.
7706 If N is a negative number, respool the N previous articles.
7707 If N is nil and any articles have been marked with the process mark,
7708 respool those articles instead.
7710 Respooling can be done both from mail groups and \"real\" newsgroups.
7711 In the former case, the articles in question will be moved from the
7712 current group into whatever groups they are destined to. In the
7713 latter case, they will be copied into the relevant groups."
7715 (list current-prefix-arg
7716 (let* ((methods (gnus-methods-using 'respool))
7718 (symbol-name (or gnus-summary-respool-default-method
7719 (car (gnus-find-method-for-group
7720 gnus-newsgroup-name)))))
7722 (gnus-completing-read
7723 methname "What backend do you want to use when respooling?"
7724 methods nil t nil 'gnus-mail-method-history))
7727 ((zerop (length (setq ms (gnus-servers-using-backend
7729 (list (intern method) ""))
7733 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7734 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7737 (error "No method given for respooling"))
7738 (if (assoc (symbol-name
7739 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7740 (gnus-methods-using 'respool))
7741 (gnus-summary-move-article n nil method)
7742 (gnus-summary-copy-article n nil method)))
7744 (defun gnus-summary-import-article (file)
7745 "Import an arbitrary file into a mail newsgroup."
7746 (interactive "fImport file: ")
7747 (let ((group gnus-newsgroup-name)
7748 (now (current-time))
7750 (unless (gnus-check-backend-function 'request-accept-article group)
7751 (error "%s does not support article importing" group))
7752 (or (file-readable-p file)
7753 (not (file-regular-p file))
7754 (error "Can't read %s" file))
7756 (set-buffer (gnus-get-buffer-create " *import file*"))
7758 (nnheader-insert-file-contents file)
7759 (goto-char (point-min))
7760 (unless (nnheader-article-p)
7761 ;; This doesn't look like an article, so we fudge some headers.
7762 (setq atts (file-attributes file)
7763 lines (count-lines (point-min) (point-max)))
7764 (insert "From: " (read-string "From: ") "\n"
7765 "Subject: " (read-string "Subject: ") "\n"
7766 "Date: " (message-make-date (nth 5 atts))
7768 "Message-ID: " (message-make-message-id) "\n"
7769 "Lines: " (int-to-string lines) "\n"
7770 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7771 (gnus-request-accept-article group nil t)
7772 (kill-buffer (current-buffer)))))
7774 (defun gnus-summary-article-posted-p ()
7775 "Say whether the current (mail) article is available from news as well.
7776 This will be the case if the article has both been mailed and posted."
7778 (let ((id (mail-header-references (gnus-summary-article-header)))
7779 (gnus-override-method (car (gnus-refer-article-methods))))
7780 (if (gnus-request-head id "")
7781 (gnus-message 2 "The current message was found on %s"
7782 gnus-override-method)
7783 (gnus-message 2 "The current message couldn't be found on %s"
7784 gnus-override-method)
7787 (defun gnus-summary-expire-articles (&optional now)
7788 "Expire all articles that are marked as expirable in the current group."
7790 (when (gnus-check-backend-function
7791 'request-expire-articles gnus-newsgroup-name)
7792 ;; This backend supports expiry.
7793 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7794 (expirable (if total
7796 ;; We need to update the info for
7797 ;; this group for `gnus-list-of-read-articles'
7798 ;; to give us the right answer.
7799 (gnus-run-hooks 'gnus-exit-group-hook)
7800 (gnus-summary-update-info)
7801 (gnus-list-of-read-articles gnus-newsgroup-name))
7802 (setq gnus-newsgroup-expirable
7803 (sort gnus-newsgroup-expirable '<))))
7804 (expiry-wait (if now 'immediate
7805 (gnus-group-find-parameter
7806 gnus-newsgroup-name 'expiry-wait)))
7809 ;; There are expirable articles in this group, so we run them
7810 ;; through the expiry process.
7811 (gnus-message 6 "Expiring articles...")
7812 (unless (gnus-check-group gnus-newsgroup-name)
7813 (error "Can't open server for %s" gnus-newsgroup-name))
7814 ;; The list of articles that weren't expired is returned.
7817 (let ((nnmail-expiry-wait-function nil)
7818 (nnmail-expiry-wait expiry-wait))
7819 (setq es (gnus-request-expire-articles
7820 expirable gnus-newsgroup-name)))
7821 (setq es (gnus-request-expire-articles
7822 expirable gnus-newsgroup-name))))
7824 (setq gnus-newsgroup-expirable es))
7825 ;; We go through the old list of expirable, and mark all
7826 ;; really expired articles as nonexistent.
7827 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7828 (let ((gnus-use-cache nil))
7830 (unless (memq (car expirable) es)
7831 (when (gnus-data-find (car expirable))
7832 (gnus-summary-mark-article
7833 (car expirable) gnus-canceled-mark)))
7834 (setq expirable (cdr expirable)))))
7835 (gnus-message 6 "Expiring articles...done")))))
7837 (defun gnus-summary-expire-articles-now ()
7838 "Expunge all expirable articles in the current group.
7839 This means that *all* articles that are marked as expirable will be
7840 deleted forever, right now."
7842 (or gnus-expert-user
7844 "Are you really, really, really sure you want to delete all these messages? ")
7846 (gnus-summary-expire-articles t))
7848 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7849 (defun gnus-summary-delete-article (&optional n)
7850 "Delete the N next (mail) articles.
7851 This command actually deletes articles. This is not a marking
7852 command. The article will disappear forever from your life, never to
7854 If N is negative, delete backwards.
7855 If N is nil and articles have been marked with the process mark,
7856 delete these instead."
7858 (unless (gnus-check-backend-function 'request-expire-articles
7859 gnus-newsgroup-name)
7860 (error "The current newsgroup does not support article deletion"))
7861 ;; Compute the list of articles to delete.
7862 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7864 (if (and gnus-novice-user
7865 (not (gnus-yes-or-no-p
7866 (format "Do you really want to delete %s forever? "
7867 (if (> (length articles) 1)
7868 (format "these %s articles" (length articles))
7871 ;; Delete the articles.
7872 (setq not-deleted (gnus-request-expire-articles
7873 articles gnus-newsgroup-name 'force))
7875 (gnus-summary-remove-process-mark (car articles))
7876 ;; The backend might not have been able to delete the article
7878 (unless (memq (car articles) not-deleted)
7879 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7880 (setq articles (cdr articles)))
7882 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7883 (gnus-summary-position-point)
7884 (gnus-set-mode-line 'summary)
7887 (defun gnus-summary-edit-article (&optional force)
7888 "Edit the current article.
7889 This will have permanent effect only in mail groups.
7890 If FORCE is non-nil, allow editing of articles even in read-only
7894 (set-buffer gnus-summary-buffer)
7895 (let ((mail-parse-charset gnus-newsgroup-charset)
7896 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7897 (gnus-set-global-variables)
7898 (when (and (not force)
7899 (gnus-group-read-only-p))
7900 (error "The current newsgroup does not support article editing"))
7901 (gnus-summary-show-article t)
7902 (gnus-article-edit-article
7904 `(lambda (no-highlight)
7905 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7906 (mail-parse-ignored-charsets
7907 ',gnus-newsgroup-ignored-charsets))
7908 (gnus-summary-edit-article-done
7909 ,(or (mail-header-references gnus-current-headers) "")
7910 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7912 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7914 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7916 "Make edits to the current article permanent."
7918 ;; Replace the article.
7919 (let ((buf (current-buffer)))
7921 (insert-buffer-substring buf)
7922 (if (and (not read-only)
7923 (not (gnus-request-replace-article
7924 (cdr gnus-article-current) (car gnus-article-current)
7925 (current-buffer) t)))
7926 (error "Couldn't replace article")
7927 ;; Update the summary buffer.
7929 (equal (message-tokenize-header references " ")
7930 (message-tokenize-header
7931 (or (message-fetch-field "references") "") " ")))
7932 ;; We only have to update this line.
7935 (message-narrow-to-head)
7936 (let ((head (buffer-string))
7939 (insert (format "211 %d Article retrieved.\n"
7940 (cdr gnus-article-current)))
7943 (let ((nntp-server-buffer (current-buffer)))
7944 (setq header (car (gnus-get-newsgroup-headers
7946 (set-buffer gnus-summary-buffer)
7947 gnus-newsgroup-dependencies)
7950 (set-buffer gnus-summary-buffer)
7951 (gnus-data-set-header
7952 (gnus-data-find (cdr gnus-article-current))
7954 (gnus-summary-update-article-line
7955 (cdr gnus-article-current) header))))))
7957 (set-buffer (or buffer gnus-summary-buffer))
7958 (gnus-summary-update-article (cdr gnus-article-current)))
7959 ;; Prettify the article buffer again.
7960 (unless no-highlight
7962 (set-buffer gnus-article-buffer)
7963 ;;;!!! Fix this -- article should be rehighlighted.
7964 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7965 (set-buffer gnus-original-article-buffer)
7966 (gnus-request-article
7967 (cdr gnus-article-current)
7968 (car gnus-article-current) (current-buffer))))
7969 ;; Prettify the summary buffer line.
7970 (when (gnus-visual-p 'summary-highlight 'highlight)
7971 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7973 (defun gnus-summary-edit-wash (key)
7974 "Perform editing command KEY in the article buffer."
7978 (message "%s" (concat (this-command-keys) "- "))
7981 (gnus-summary-edit-article)
7982 (execute-kbd-macro (concat (this-command-keys) key))
7983 (gnus-article-edit-done))
7987 (defun gnus-summary-respool-query (&optional silent trace)
7988 "Query where the respool algorithm would put this article."
7990 (let (gnus-mark-article-hook)
7991 (gnus-summary-select-article)
7993 (set-buffer gnus-original-article-buffer)
7995 (message-narrow-to-head)
7996 (let ((groups (nnmail-article-group 'identity trace)))
7999 (message "This message would go to %s"
8000 (mapconcat 'car groups ", "))
8001 (message "This message would go to no groups"))
8004 (defun gnus-summary-respool-trace ()
8005 "Trace where the respool algorithm would put this article.
8006 Display a buffer showing all fancy splitting patterns which matched."
8008 (gnus-summary-respool-query nil t))
8010 ;; Summary marking commands.
8012 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8013 "Mark articles which has the same subject as read, and then select the next.
8014 If UNMARK is positive, remove any kind of mark.
8015 If UNMARK is negative, tick articles."
8018 (setq unmark (prefix-numeric-value unmark)))
8020 (gnus-summary-mark-same-subject
8021 (gnus-summary-article-subject) unmark)))
8022 ;; Select next unread article. If auto-select-same mode, should
8023 ;; select the first unread article.
8024 (gnus-summary-next-article t (and gnus-auto-select-same
8025 (gnus-summary-article-subject)))
8026 (gnus-message 7 "%d article%s marked as %s"
8027 count (if (= count 1) " is" "s are")
8028 (if unmark "unread" "read"))))
8030 (defun gnus-summary-kill-same-subject (&optional unmark)
8031 "Mark articles which has the same subject as read.
8032 If UNMARK is positive, remove any kind of mark.
8033 If UNMARK is negative, tick articles."
8036 (setq unmark (prefix-numeric-value unmark)))
8038 (gnus-summary-mark-same-subject
8039 (gnus-summary-article-subject) unmark)))
8040 ;; If marked as read, go to next unread subject.
8042 ;; Go to next unread subject.
8043 (gnus-summary-next-subject 1 t))
8044 (gnus-message 7 "%d articles are marked as %s"
8045 count (if unmark "unread" "read"))))
8047 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8048 "Mark articles with same SUBJECT as read, and return marked number.
8049 If optional argument UNMARK is positive, remove any kinds of marks.
8050 If optional argument UNMARK is negative, mark articles as unread instead."
8054 ((null unmark) ; Mark as read.
8057 (gnus-summary-mark-article-as-read gnus-killed-mark)
8058 (gnus-summary-show-thread) t)
8059 (gnus-summary-find-subject subject))
8060 (setq count (1+ count))))
8061 ((> unmark 0) ; Tick.
8064 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8065 (gnus-summary-show-thread) t)
8066 (gnus-summary-find-subject subject))
8067 (setq count (1+ count))))
8068 (t ; Mark as unread.
8071 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8072 (gnus-summary-show-thread) t)
8073 (gnus-summary-find-subject subject))
8074 (setq count (1+ count)))))
8075 (gnus-set-mode-line 'summary)
8076 ;; Return the number of marked articles.
8079 (defun gnus-summary-mark-as-processable (n &optional unmark)
8080 "Set the process mark on the next N articles.
8081 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8082 the process mark instead. The difference between N and the actual
8083 number of articles marked is returned."
8085 (let ((backward (< n 0))
8090 (gnus-summary-remove-process-mark
8091 (gnus-summary-article-number))
8092 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8093 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8096 (gnus-message 7 "No more articles"))
8097 (gnus-summary-recenter)
8098 (gnus-summary-position-point)
8101 (defun gnus-summary-unmark-as-processable (n)
8102 "Remove the process mark from the next N articles.
8103 If N is negative, unmark backward instead. The difference between N and
8104 the actual number of articles unmarked is returned."
8106 (gnus-summary-mark-as-processable n t))
8108 (defun gnus-summary-unmark-all-processable ()
8109 "Remove the process mark from all articles."
8112 (while gnus-newsgroup-processable
8113 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8114 (gnus-summary-position-point))
8116 (defun gnus-summary-mark-as-expirable (n)
8117 "Mark N articles forward as expirable.
8118 If N is negative, mark backward instead. The difference between N and
8119 the actual number of articles marked is returned."
8121 (gnus-summary-mark-forward n gnus-expirable-mark))
8123 (defun gnus-summary-mark-article-as-replied (article)
8124 "Mark ARTICLE replied and update the summary line."
8125 (push article gnus-newsgroup-replied)
8126 (let ((buffer-read-only nil))
8127 (when (gnus-summary-goto-subject article nil t)
8128 (gnus-summary-update-secondary-mark article))))
8130 (defun gnus-summary-set-bookmark (article)
8131 "Set a bookmark in current article."
8132 (interactive (list (gnus-summary-article-number)))
8133 (when (or (not (get-buffer gnus-article-buffer))
8134 (not gnus-current-article)
8135 (not gnus-article-current)
8136 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8137 (error "No current article selected"))
8138 ;; Remove old bookmark, if one exists.
8139 (let ((old (assq article gnus-newsgroup-bookmarks)))
8141 (setq gnus-newsgroup-bookmarks
8142 (delq old gnus-newsgroup-bookmarks))))
8143 ;; Set the new bookmark, which is on the form
8144 ;; (article-number . line-number-in-body).
8148 (set-buffer gnus-article-buffer)
8152 (goto-char (point-min))
8153 (search-forward "\n\n" nil t)
8156 gnus-newsgroup-bookmarks)
8157 (gnus-message 6 "A bookmark has been added to the current article."))
8159 (defun gnus-summary-remove-bookmark (article)
8160 "Remove the bookmark from the current article."
8161 (interactive (list (gnus-summary-article-number)))
8162 ;; Remove old bookmark, if one exists.
8163 (let ((old (assq article gnus-newsgroup-bookmarks)))
8166 (setq gnus-newsgroup-bookmarks
8167 (delq old gnus-newsgroup-bookmarks))
8168 (gnus-message 6 "Removed bookmark."))
8169 (gnus-message 6 "No bookmark in current article."))))
8171 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8172 (defun gnus-summary-mark-as-dormant (n)
8173 "Mark N articles forward as dormant.
8174 If N is negative, mark backward instead. The difference between N and
8175 the actual number of articles marked is returned."
8177 (gnus-summary-mark-forward n gnus-dormant-mark))
8179 (defun gnus-summary-set-process-mark (article)
8180 "Set the process mark on ARTICLE and update the summary line."
8181 (setq gnus-newsgroup-processable
8183 (delq article gnus-newsgroup-processable)))
8184 (when (gnus-summary-goto-subject article)
8185 (gnus-summary-show-thread)
8186 (gnus-summary-goto-subject article)
8187 (gnus-summary-update-secondary-mark article)))
8189 (defun gnus-summary-remove-process-mark (article)
8190 "Remove the process mark from ARTICLE and update the summary line."
8191 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8192 (when (gnus-summary-goto-subject article)
8193 (gnus-summary-show-thread)
8194 (gnus-summary-goto-subject article)
8195 (gnus-summary-update-secondary-mark article)))
8197 (defun gnus-summary-set-saved-mark (article)
8198 "Set the process mark on ARTICLE and update the summary line."
8199 (push article gnus-newsgroup-saved)
8200 (when (gnus-summary-goto-subject article)
8201 (gnus-summary-update-secondary-mark article)))
8203 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8204 "Mark N articles as read forwards.
8205 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8206 The difference between N and the actual number of articles marked is
8208 Iff NO-EXPIRE, auto-expiry will be inhibited."
8210 (gnus-summary-show-thread)
8211 (let ((backward (< n 0))
8212 (gnus-summary-goto-unread
8213 (and gnus-summary-goto-unread
8214 (not (eq gnus-summary-goto-unread 'never))
8215 (not (memq mark (list gnus-unread-mark
8216 gnus-ticked-mark gnus-dormant-mark)))))
8218 (mark (or mark gnus-del-mark)))
8220 (gnus-summary-mark-article nil mark no-expire)
8221 (zerop (gnus-summary-next-subject
8223 (and gnus-summary-goto-unread
8224 (not (eq gnus-summary-goto-unread 'never)))
8228 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8229 (gnus-summary-recenter)
8230 (gnus-summary-position-point)
8231 (gnus-set-mode-line 'summary)
8234 (defun gnus-summary-mark-article-as-read (mark)
8235 "Mark the current article quickly as read with MARK."
8236 (let ((article (gnus-summary-article-number)))
8237 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8238 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8239 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8240 (push (cons article mark) gnus-newsgroup-reads)
8241 ;; Possibly remove from cache, if that is used.
8242 (when gnus-use-cache
8243 (gnus-cache-enter-remove-article article))
8244 ;; Allow the backend to change the mark.
8245 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8246 ;; Check for auto-expiry.
8247 (when (and gnus-newsgroup-auto-expire
8248 (memq mark gnus-auto-expirable-marks))
8249 (setq mark gnus-expirable-mark)
8250 ;; Let the backend know about the mark change.
8251 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8252 (push article gnus-newsgroup-expirable))
8253 ;; Set the mark in the buffer.
8254 (gnus-summary-update-mark mark 'unread)
8257 (defun gnus-summary-mark-article-as-unread (mark)
8258 "Mark the current article quickly as unread with MARK."
8259 (let* ((article (gnus-summary-article-number))
8260 (old-mark (gnus-summary-article-mark article)))
8261 ;; Allow the backend to change the mark.
8262 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8263 (if (eq mark old-mark)
8267 (gnus-error 1 "Can't mark negative article numbers")
8269 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8270 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8271 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8272 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8273 (cond ((= mark gnus-ticked-mark)
8274 (push article gnus-newsgroup-marked))
8275 ((= mark gnus-dormant-mark)
8276 (push article gnus-newsgroup-dormant))
8278 (push article gnus-newsgroup-unreads)))
8279 (gnus-pull article gnus-newsgroup-reads)
8281 ;; See whether the article is to be put in the cache.
8283 (vectorp (gnus-summary-article-header article))
8285 (gnus-cache-possibly-enter-article
8286 gnus-newsgroup-name article
8287 (gnus-summary-article-header article)
8288 (= mark gnus-ticked-mark)
8289 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8292 (gnus-summary-update-mark mark 'unread)
8295 (defun gnus-summary-mark-article (&optional article mark no-expire)
8296 "Mark ARTICLE with MARK. MARK can be any character.
8297 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8298 `??' (dormant) and `?E' (expirable).
8299 If MARK is nil, then the default character `?r' is used.
8300 If ARTICLE is nil, then the article on the current line will be
8302 Iff NO-EXPIRE, auto-expiry will be inhibited."
8303 ;; The mark might be a string.
8304 (when (stringp mark)
8305 (setq mark (aref mark 0)))
8306 ;; If no mark is given, then we check auto-expiring.
8308 (setq mark gnus-del-mark))
8309 (when (and (not no-expire)
8310 gnus-newsgroup-auto-expire
8311 (memq mark gnus-auto-expirable-marks))
8312 (setq mark gnus-expirable-mark))
8313 (let ((article (or article (gnus-summary-article-number)))
8314 (old-mark (gnus-summary-article-mark article)))
8315 ;; Allow the backend to change the mark.
8316 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8317 (if (eq mark old-mark)
8320 (error "No article on current line"))
8321 (if (not (if (or (= mark gnus-unread-mark)
8322 (= mark gnus-ticked-mark)
8323 (= mark gnus-dormant-mark))
8324 (gnus-mark-article-as-unread article mark)
8325 (gnus-mark-article-as-read article mark)))
8327 ;; See whether the article is to be put in the cache.
8329 (not (= mark gnus-canceled-mark))
8330 (vectorp (gnus-summary-article-header article))
8332 (gnus-cache-possibly-enter-article
8333 gnus-newsgroup-name article
8334 (gnus-summary-article-header article)
8335 (= mark gnus-ticked-mark)
8336 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8338 (when (gnus-summary-goto-subject article nil t)
8339 (let ((buffer-read-only nil))
8340 (gnus-summary-show-thread)
8342 (gnus-summary-update-mark mark 'unread)
8345 (defun gnus-summary-update-secondary-mark (article)
8346 "Update the secondary (read, process, cache) mark."
8347 (gnus-summary-update-mark
8348 (cond ((memq article gnus-newsgroup-processable)
8350 ((memq article gnus-newsgroup-cached)
8352 ((memq article gnus-newsgroup-replied)
8354 ((memq article gnus-newsgroup-saved)
8356 (t gnus-unread-mark))
8358 (when (gnus-visual-p 'summary-highlight 'highlight)
8359 (gnus-run-hooks 'gnus-summary-update-hook))
8362 (defun gnus-summary-update-mark (mark type)
8363 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8364 (buffer-read-only nil))
8365 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8367 (when (looking-at "\r")
8369 (when (<= (+ forward (point)) (point-max))
8370 ;; Go to the right position on the line.
8371 (goto-char (+ forward (point)))
8372 ;; Replace the old mark with the new mark.
8373 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8374 ;; Optionally update the marks by some user rule.
8375 (when (eq type 'unread)
8377 (gnus-data-find (gnus-summary-article-number)) mark)
8378 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8380 (defun gnus-mark-article-as-read (article &optional mark)
8381 "Enter ARTICLE in the pertinent lists and remove it from others."
8382 ;; Make the article expirable.
8383 (let ((mark (or mark gnus-del-mark)))
8384 (if (= mark gnus-expirable-mark)
8385 (push article gnus-newsgroup-expirable)
8386 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8387 ;; Remove from unread and marked lists.
8388 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8389 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8390 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8391 (push (cons article mark) gnus-newsgroup-reads)
8392 ;; Possibly remove from cache, if that is used.
8393 (when gnus-use-cache
8394 (gnus-cache-enter-remove-article article))
8397 (defun gnus-mark-article-as-unread (article &optional mark)
8398 "Enter ARTICLE in the pertinent lists and remove it from others."
8399 (let ((mark (or mark gnus-ticked-mark)))
8402 (gnus-error 1 "Can't mark negative article numbers")
8404 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8405 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8406 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8407 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8409 ;; Unsuppress duplicates?
8410 (when gnus-suppress-duplicates
8411 (gnus-dup-unsuppress-article article))
8413 (cond ((= mark gnus-ticked-mark)
8414 (push article gnus-newsgroup-marked))
8415 ((= mark gnus-dormant-mark)
8416 (push article gnus-newsgroup-dormant))
8418 (push article gnus-newsgroup-unreads)))
8419 (gnus-pull article gnus-newsgroup-reads)
8422 (defalias 'gnus-summary-mark-as-unread-forward
8423 'gnus-summary-tick-article-forward)
8424 (make-obsolete 'gnus-summary-mark-as-unread-forward
8425 'gnus-summary-tick-article-forward)
8426 (defun gnus-summary-tick-article-forward (n)
8427 "Tick N articles forwards.
8428 If N is negative, tick backwards instead.
8429 The difference between N and the number of articles ticked is returned."
8431 (gnus-summary-mark-forward n gnus-ticked-mark))
8433 (defalias 'gnus-summary-mark-as-unread-backward
8434 'gnus-summary-tick-article-backward)
8435 (make-obsolete 'gnus-summary-mark-as-unread-backward
8436 'gnus-summary-tick-article-backward)
8437 (defun gnus-summary-tick-article-backward (n)
8438 "Tick N articles backwards.
8439 The difference between N and the number of articles ticked is returned."
8441 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8443 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8444 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8445 (defun gnus-summary-tick-article (&optional article clear-mark)
8446 "Mark current article as unread.
8447 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8448 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8450 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8453 (defun gnus-summary-mark-as-read-forward (n)
8454 "Mark N articles as read forwards.
8455 If N is negative, mark backwards instead.
8456 The difference between N and the actual number of articles marked is
8459 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8461 (defun gnus-summary-mark-as-read-backward (n)
8462 "Mark the N articles as read backwards.
8463 The difference between N and the actual number of articles marked is
8466 (gnus-summary-mark-forward
8467 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8469 (defun gnus-summary-mark-as-read (&optional article mark)
8470 "Mark current article as read.
8471 ARTICLE specifies the article to be marked as read.
8472 MARK specifies a string to be inserted at the beginning of the line."
8473 (gnus-summary-mark-article article mark))
8475 (defun gnus-summary-clear-mark-forward (n)
8476 "Clear marks from N articles forward.
8477 If N is negative, clear backward instead.
8478 The difference between N and the number of marks cleared is returned."
8480 (gnus-summary-mark-forward n gnus-unread-mark))
8482 (defun gnus-summary-clear-mark-backward (n)
8483 "Clear marks from N articles backward.
8484 The difference between N and the number of marks cleared is returned."
8486 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8488 (defun gnus-summary-mark-unread-as-read ()
8489 "Intended to be used by `gnus-summary-mark-article-hook'."
8490 (when (memq gnus-current-article gnus-newsgroup-unreads)
8491 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8493 (defun gnus-summary-mark-read-and-unread-as-read ()
8494 "Intended to be used by `gnus-summary-mark-article-hook'."
8495 (let ((mark (gnus-summary-article-mark)))
8496 (when (or (gnus-unread-mark-p mark)
8497 (gnus-read-mark-p mark))
8498 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8500 (defun gnus-summary-mark-region-as-read (point mark all)
8501 "Mark all unread articles between point and mark as read.
8502 If given a prefix, mark all articles between point and mark as read,
8503 even ticked and dormant ones."
8504 (interactive "r\nP")
8513 (memq (setq article (gnus-summary-article-number))
8514 gnus-newsgroup-unreads))
8515 (gnus-summary-mark-article article gnus-del-mark))
8517 (gnus-summary-find-next))))))
8519 (defun gnus-summary-mark-below (score mark)
8520 "Mark articles with score less than SCORE with MARK."
8521 (interactive "P\ncMark: ")
8522 (setq score (if score
8523 (prefix-numeric-value score)
8524 (or gnus-summary-default-score 0)))
8526 (set-buffer gnus-summary-buffer)
8527 (goto-char (point-min))
8530 (and (< (gnus-summary-article-score) score)
8531 (gnus-summary-mark-article nil mark))
8532 (gnus-summary-find-next)))))
8534 (defun gnus-summary-kill-below (&optional score)
8535 "Mark articles with score below SCORE as read."
8537 (gnus-summary-mark-below score gnus-killed-mark))
8539 (defun gnus-summary-clear-above (&optional score)
8540 "Clear all marks from articles with score above SCORE."
8542 (gnus-summary-mark-above score gnus-unread-mark))
8544 (defun gnus-summary-tick-above (&optional score)
8545 "Tick all articles with score above SCORE."
8547 (gnus-summary-mark-above score gnus-ticked-mark))
8549 (defun gnus-summary-mark-above (score mark)
8550 "Mark articles with score over SCORE with MARK."
8551 (interactive "P\ncMark: ")
8552 (setq score (if score
8553 (prefix-numeric-value score)
8554 (or gnus-summary-default-score 0)))
8556 (set-buffer gnus-summary-buffer)
8557 (goto-char (point-min))
8559 (when (> (gnus-summary-article-score) score)
8560 (gnus-summary-mark-article nil mark))
8562 (gnus-summary-find-next)))))
8564 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8565 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8566 (defun gnus-summary-limit-include-expunged (&optional no-error)
8567 "Display all the hidden articles that were expunged for low scores."
8569 (let ((buffer-read-only nil))
8570 (let ((scored gnus-newsgroup-scored)
8573 (unless (gnus-summary-goto-subject (caar scored))
8574 (and (setq h (gnus-summary-article-header (caar scored)))
8575 (< (cdar scored) gnus-summary-expunge-below)
8577 (setq scored (cdr scored)))
8579 (when (not no-error)
8580 (error "No expunged articles hidden"))
8581 (goto-char (point-min))
8582 (gnus-summary-prepare-unthreaded (nreverse headers))
8583 (goto-char (point-min))
8584 (gnus-summary-position-point)
8587 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8588 "Mark all unread articles in this newsgroup as read.
8589 If prefix argument ALL is non-nil, ticked and dormant articles will
8590 also be marked as read.
8591 If QUIETLY is non-nil, no questions will be asked.
8592 If TO-HERE is non-nil, it should be a point in the buffer. All
8593 articles before this point will be marked as read.
8594 Note that this function will only catch up the unread article
8595 in the current summary buffer limitation.
8596 The number of articles marked as read is returned."
8601 (not gnus-interactive-catchup) ;Without confirmation?
8605 "Mark absolutely all articles as read? "
8606 "Mark all unread articles as read? ")))
8608 (not gnus-newsgroup-adaptive)
8609 (not gnus-newsgroup-auto-expire)
8610 (not gnus-suppress-duplicates)
8611 (or (not gnus-use-cache)
8612 (eq gnus-use-cache 'passive)))
8615 (setq gnus-newsgroup-marked nil
8616 gnus-newsgroup-dormant nil))
8617 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8618 ;; We actually mark all articles as canceled, which we
8619 ;; have to do when using auto-expiry or adaptive scoring.
8620 (gnus-summary-show-all-threads)
8621 (when (gnus-summary-first-subject (not all) t)
8623 (if to-here (< (point) to-here) t)
8624 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8625 (gnus-summary-find-next (not all) nil nil t))))
8626 (gnus-set-mode-line 'summary))
8628 (gnus-summary-position-point)))
8630 (defun gnus-summary-catchup-to-here (&optional all)
8631 "Mark all unticked articles before the current one as read.
8632 If ALL is non-nil, also mark ticked and dormant articles as read."
8635 (gnus-save-hidden-threads
8636 (let ((beg (point)))
8637 ;; We check that there are unread articles.
8638 (when (or all (gnus-summary-find-prev))
8639 (gnus-summary-catchup all t beg)))))
8640 (gnus-summary-position-point))
8642 (defun gnus-summary-catchup-all (&optional quietly)
8643 "Mark all articles in this newsgroup as read."
8645 (gnus-summary-catchup t quietly))
8647 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8648 "Mark all unread articles in this group as read, then exit.
8649 If prefix argument ALL is non-nil, all articles are marked as read."
8651 (when (gnus-summary-catchup all quietly nil 'fast)
8652 ;; Select next newsgroup or exit.
8653 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8654 (eq gnus-auto-select-next 'quietly))
8655 (gnus-summary-next-group nil)
8656 (gnus-summary-exit))))
8658 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8659 "Mark all articles in this newsgroup as read, and then exit."
8661 (gnus-summary-catchup-and-exit t quietly))
8663 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8664 "Mark all articles in this group as read and select the next group.
8665 If given a prefix, mark all articles, unread as well as ticked, as
8669 (gnus-summary-catchup all))
8670 (gnus-summary-next-group))
8672 ;; Thread-based commands.
8674 (defun gnus-summary-articles-in-thread (&optional article)
8675 "Return a list of all articles in the current thread.
8676 If ARTICLE is non-nil, return all articles in the thread that starts
8678 (let* ((article (or article (gnus-summary-article-number)))
8679 (data (gnus-data-find-list article))
8680 (top-level (gnus-data-level (car data)))
8682 (cond ((null gnus-thread-operation-ignore-subject)
8683 (gnus-simplify-subject-re
8684 (mail-header-subject (gnus-data-header (car data)))))
8685 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8686 (gnus-simplify-subject-fuzzy
8687 (mail-header-subject (gnus-data-header (car data)))))
8689 (end-point (save-excursion
8690 (if (gnus-summary-go-to-next-thread)
8691 (point) (point-max))))
8694 (< (gnus-data-pos (car data)) end-point))
8695 (when (or (not top-subject)
8696 (string= top-subject
8697 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8698 (gnus-simplify-subject-fuzzy
8699 (mail-header-subject
8700 (gnus-data-header (car data))))
8701 (gnus-simplify-subject-re
8702 (mail-header-subject
8703 (gnus-data-header (car data)))))))
8704 (push (gnus-data-number (car data)) articles))
8705 (unless (and (setq data (cdr data))
8706 (> (gnus-data-level (car data)) top-level))
8708 ;; Return the list of articles.
8709 (nreverse articles)))
8711 (defun gnus-summary-rethread-current ()
8712 "Rethread the thread the current article is part of."
8714 (let* ((gnus-show-threads t)
8715 (article (gnus-summary-article-number))
8716 (id (mail-header-id (gnus-summary-article-header)))
8717 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8719 (error "No article on the current line"))
8720 (gnus-rebuild-thread id)
8721 (gnus-summary-goto-subject article)))
8723 (defun gnus-summary-reparent-thread ()
8724 "Make the current article child of the marked (or previous) article.
8726 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8727 is non-nil or the Subject: of both articles are the same."
8729 (unless (not (gnus-group-read-only-p))
8730 (error "The current newsgroup does not support article editing"))
8731 (unless (<= (length gnus-newsgroup-processable) 1)
8732 (error "No more than one article may be marked"))
8733 (save-window-excursion
8734 (let ((gnus-article-buffer " *reparent*")
8735 (current-article (gnus-summary-article-number))
8736 ;; First grab the marked article, otherwise one line up.
8737 (parent-article (if (not (null gnus-newsgroup-processable))
8738 (car gnus-newsgroup-processable)
8740 (if (eq (forward-line -1) 0)
8741 (gnus-summary-article-number)
8742 (error "Beginning of summary buffer"))))))
8743 (unless (not (eq current-article parent-article))
8744 (error "An article may not be self-referential"))
8745 (let ((message-id (mail-header-id
8746 (gnus-summary-article-header parent-article))))
8747 (unless (and message-id (not (equal message-id "")))
8748 (error "No message-id in desired parent"))
8749 (gnus-with-article current-article
8750 (goto-char (point-min))
8751 (if (re-search-forward "^References: " nil t)
8753 (re-search-forward "^[^ \t]" nil t)
8756 (insert " " message-id))
8757 (insert "References: " message-id "\n")))
8758 (set-buffer gnus-summary-buffer)
8759 (gnus-summary-unmark-all-processable)
8760 (gnus-summary-update-article current-article)
8761 (gnus-summary-rethread-current)
8762 (gnus-message 3 "Article %d is now the child of article %d"
8763 current-article parent-article)))))
8765 (defun gnus-summary-toggle-threads (&optional arg)
8766 "Toggle showing conversation threads.
8767 If ARG is positive number, turn showing conversation threads on."
8769 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8770 (setq gnus-show-threads
8771 (if (null arg) (not gnus-show-threads)
8772 (> (prefix-numeric-value arg) 0)))
8773 (gnus-summary-prepare)
8774 (gnus-summary-goto-subject current)
8775 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8776 (gnus-summary-position-point)))
8778 (defun gnus-summary-show-all-threads ()
8782 (let ((buffer-read-only nil))
8783 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8784 (gnus-summary-position-point))
8786 (defun gnus-summary-show-thread ()
8787 "Show thread subtrees.
8788 Returns nil if no thread was there to be shown."
8790 (let ((buffer-read-only nil)
8792 ;; first goto end then to beg, to have point at beg after let
8793 (end (progn (end-of-line) (point)))
8794 (beg (progn (beginning-of-line) (point))))
8796 ;; Any hidden lines here?
8797 (search-forward "\r" end t)
8798 (subst-char-in-region beg end ?\^M ?\n t)
8800 (gnus-summary-position-point))))
8802 (defun gnus-summary-hide-all-threads ()
8803 "Hide all thread subtrees."
8806 (goto-char (point-min))
8807 (gnus-summary-hide-thread)
8808 (while (zerop (gnus-summary-next-thread 1 t))
8809 (gnus-summary-hide-thread)))
8810 (gnus-summary-position-point))
8812 (defun gnus-summary-hide-thread ()
8813 "Hide thread subtrees.
8814 Returns nil if no threads were there to be hidden."
8816 (let ((buffer-read-only nil)
8818 (article (gnus-summary-article-number)))
8820 ;; Go forward until either the buffer ends or the subthread
8822 (when (and (not (eobp))
8823 (or (zerop (gnus-summary-next-thread 1 t))
8824 (goto-char (point-max))))
8826 (if (and (> (point) start)
8827 (search-backward "\n" start t))
8829 (subst-char-in-region start (point) ?\n ?\^M)
8830 (gnus-summary-goto-subject article))
8834 (defun gnus-summary-go-to-next-thread (&optional previous)
8835 "Go to the same level (or less) next thread.
8836 If PREVIOUS is non-nil, go to previous thread instead.
8837 Return the article number moved to, or nil if moving was impossible."
8838 (let ((level (gnus-summary-thread-level))
8839 (way (if previous -1 1))
8842 (while (and (not (eobp))
8843 (< level (gnus-summary-thread-level)))
8851 (gnus-summary-article-number)
8854 (defun gnus-summary-next-thread (n &optional silent)
8855 "Go to the same level next N'th thread.
8856 If N is negative, search backward instead.
8857 Returns the difference between N and the number of skips actually
8860 If SILENT, don't output messages."
8862 (let ((backward (< n 0))
8865 (gnus-summary-go-to-next-thread backward))
8868 (gnus-summary-position-point))
8869 (when (and (not silent) (/= 0 n))
8870 (gnus-message 7 "No more threads"))
8873 (defun gnus-summary-prev-thread (n)
8874 "Go to the same level previous N'th thread.
8875 Returns the difference between N and the number of skips actually
8878 (gnus-summary-next-thread (- n)))
8880 (defun gnus-summary-go-down-thread ()
8881 "Go down one level in the current thread."
8882 (let ((children (gnus-summary-article-children)))
8884 (gnus-summary-goto-subject (car children)))))
8886 (defun gnus-summary-go-up-thread ()
8887 "Go up one level in the current thread."
8888 (let ((parent (gnus-summary-article-parent)))
8890 (gnus-summary-goto-subject parent))))
8892 (defun gnus-summary-down-thread (n)
8893 "Go down thread N steps.
8894 If N is negative, go up instead.
8895 Returns the difference between N and how many steps down that were
8901 (if up (gnus-summary-go-up-thread)
8902 (gnus-summary-go-down-thread)))
8904 (gnus-summary-position-point)
8906 (gnus-message 7 "Can't go further"))
8909 (defun gnus-summary-up-thread (n)
8910 "Go up thread N steps.
8911 If N is negative, go up instead.
8912 Returns the difference between N and how many steps down that were
8915 (gnus-summary-down-thread (- n)))
8917 (defun gnus-summary-top-thread ()
8918 "Go to the top of the thread."
8920 (while (gnus-summary-go-up-thread))
8921 (gnus-summary-article-number))
8923 (defun gnus-summary-kill-thread (&optional unmark)
8924 "Mark articles under current thread as read.
8925 If the prefix argument is positive, remove any kinds of marks.
8926 If the prefix argument is negative, tick articles instead."
8929 (setq unmark (prefix-numeric-value unmark)))
8930 (let ((articles (gnus-summary-articles-in-thread)))
8932 ;; Expand the thread.
8933 (gnus-summary-show-thread)
8934 ;; Mark all the articles.
8936 (gnus-summary-goto-subject (car articles))
8937 (cond ((null unmark)
8938 (gnus-summary-mark-article-as-read gnus-killed-mark))
8940 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8942 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8943 (setq articles (cdr articles))))
8944 ;; Hide killed subtrees.
8946 gnus-thread-hide-killed
8947 (gnus-summary-hide-thread))
8948 ;; If marked as read, go to next unread subject.
8950 ;; Go to next unread subject.
8951 (gnus-summary-next-subject 1 t)))
8952 (gnus-set-mode-line 'summary))
8954 ;; Summary sorting commands
8956 (defun gnus-summary-sort-by-number (&optional reverse)
8957 "Sort the summary buffer by article number.
8958 Argument REVERSE means reverse order."
8960 (gnus-summary-sort 'number reverse))
8962 (defun gnus-summary-sort-by-author (&optional reverse)
8963 "Sort the summary buffer by author name alphabetically.
8964 If case-fold-search is non-nil, case of letters is ignored.
8965 Argument REVERSE means reverse order."
8967 (gnus-summary-sort 'author reverse))
8969 (defun gnus-summary-sort-by-subject (&optional reverse)
8970 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8971 If case-fold-search is non-nil, case of letters is ignored.
8972 Argument REVERSE means reverse order."
8974 (gnus-summary-sort 'subject reverse))
8976 (defun gnus-summary-sort-by-date (&optional reverse)
8977 "Sort the summary buffer by date.
8978 Argument REVERSE means reverse order."
8980 (gnus-summary-sort 'date reverse))
8982 (defun gnus-summary-sort-by-score (&optional reverse)
8983 "Sort the summary buffer by score.
8984 Argument REVERSE means reverse order."
8986 (gnus-summary-sort 'score reverse))
8988 (defun gnus-summary-sort-by-lines (&optional reverse)
8989 "Sort the summary buffer by the number of lines.
8990 Argument REVERSE means reverse order."
8992 (gnus-summary-sort 'lines reverse))
8994 (defun gnus-summary-sort-by-chars (&optional reverse)
8995 "Sort the summary buffer by article length.
8996 Argument REVERSE means reverse order."
8998 (gnus-summary-sort 'chars reverse))
9000 (defun gnus-summary-sort (predicate reverse)
9001 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9002 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9003 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9004 (gnus-thread-sort-functions
9009 (gnus-article-sort-functions
9015 (gnus-summary-prepare-hook nil))
9016 ;; We do the sorting by regenerating the threads.
9017 (gnus-summary-prepare)
9018 ;; Hide subthreads if needed.
9019 (when (and gnus-show-threads gnus-thread-hide-subtree)
9020 (gnus-summary-hide-all-threads))))
9022 ;; Summary saving commands.
9024 (defun gnus-summary-save-article (&optional n not-saved)
9025 "Save the current article using the default saver function.
9026 If N is a positive number, save the N next articles.
9027 If N is a negative number, save the N previous articles.
9028 If N is nil and any articles have been marked with the process mark,
9029 save those articles instead.
9030 The variable `gnus-default-article-saver' specifies the saver function."
9032 (let* ((articles (gnus-summary-work-articles n))
9033 (save-buffer (save-excursion
9034 (nnheader-set-temp-buffer " *Gnus Save*")))
9035 (num (length articles))
9037 (dolist (article articles)
9038 (setq header (gnus-summary-article-header article))
9039 (if (not (vectorp header))
9040 ;; This is a pseudo-article.
9041 (if (assq 'name header)
9042 (gnus-copy-file (cdr (assq 'name header)))
9043 (gnus-message 1 "Article %d is unsaveable" article))
9044 ;; This is a real article.
9045 (save-window-excursion
9046 (gnus-summary-select-article t nil nil article))
9048 (set-buffer save-buffer)
9050 (insert-buffer-substring gnus-original-article-buffer))
9051 (setq file (gnus-article-save save-buffer file num))
9052 (gnus-summary-remove-process-mark article)
9054 (gnus-summary-set-saved-mark article))))
9055 (gnus-kill-buffer save-buffer)
9056 (gnus-summary-position-point)
9057 (gnus-set-mode-line 'summary)
9060 (defun gnus-summary-pipe-output (&optional arg)
9061 "Pipe the current article to a subprocess.
9062 If N is a positive number, pipe the N next articles.
9063 If N is a negative number, pipe the N previous articles.
9064 If N is nil and any articles have been marked with the process mark,
9065 pipe those articles instead."
9067 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9068 (gnus-summary-save-article arg t))
9069 (gnus-configure-windows 'pipe))
9071 (defun gnus-summary-save-article-mail (&optional arg)
9072 "Append the current article to an mail file.
9073 If N is a positive number, save the N next articles.
9074 If N is a negative number, save the N previous articles.
9075 If N is nil and any articles have been marked with the process mark,
9076 save those articles instead."
9078 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9079 (gnus-summary-save-article arg)))
9081 (defun gnus-summary-save-article-rmail (&optional arg)
9082 "Append the current article to an rmail file.
9083 If N is a positive number, save the N next articles.
9084 If N is a negative number, save the N previous articles.
9085 If N is nil and any articles have been marked with the process mark,
9086 save those articles instead."
9088 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9089 (gnus-summary-save-article arg)))
9091 (defun gnus-summary-save-article-file (&optional arg)
9092 "Append the current article to a file.
9093 If N is a positive number, save the N next articles.
9094 If N is a negative number, save the N previous articles.
9095 If N is nil and any articles have been marked with the process mark,
9096 save those articles instead."
9098 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9099 (gnus-summary-save-article arg)))
9101 (defun gnus-summary-write-article-file (&optional arg)
9102 "Write the current article to a file, deleting the previous file.
9103 If N is a positive number, save the N next articles.
9104 If N is a negative number, save the N previous articles.
9105 If N is nil and any articles have been marked with the process mark,
9106 save those articles instead."
9108 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9109 (gnus-summary-save-article arg)))
9111 (defun gnus-summary-save-article-body-file (&optional arg)
9112 "Append the current article body to a file.
9113 If N is a positive number, save the N next articles.
9114 If N is a negative number, save the N previous articles.
9115 If N is nil and any articles have been marked with the process mark,
9116 save those articles instead."
9118 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9119 (gnus-summary-save-article arg)))
9121 (defun gnus-summary-pipe-message (program)
9122 "Pipe the current article through PROGRAM."
9123 (interactive "sProgram: ")
9124 (gnus-summary-select-article)
9125 (let ((mail-header-separator ""))
9126 (gnus-eval-in-buffer-window gnus-article-buffer
9129 (let ((start (window-start))
9131 (message-pipe-buffer-body program)
9132 (set-window-start (get-buffer-window (current-buffer)) start))))))
9134 (defun gnus-get-split-value (methods)
9135 "Return a value based on the split METHODS."
9136 (let (split-name method result match)
9139 (set-buffer gnus-original-article-buffer)
9141 (nnheader-narrow-to-headers)
9143 (goto-char (point-min))
9144 (setq method (pop methods))
9145 (setq match (car method))
9148 ;; Regular expression.
9150 (re-search-forward match nil t)))
9151 ((gnus-functionp match)
9155 (setq result (funcall match gnus-newsgroup-name))))
9160 (setq result (eval match)))))
9161 (setq split-name (append (cdr method) split-name))
9162 (cond ((stringp result)
9163 (push (expand-file-name
9164 result gnus-article-save-directory)
9167 (setq split-name (append result split-name)))))))))
9168 (nreverse split-name)))
9170 (defun gnus-valid-move-group-p (group)
9173 (symbol-value group)
9174 (gnus-get-function (gnus-find-method-for-group
9175 (symbol-name group)) 'request-accept-article t)))
9177 (defun gnus-read-move-group-name (prompt default articles prefix)
9178 "Read a group name."
9179 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9180 (minibuffer-confirm-incomplete nil) ; XEmacs
9184 (if (> (length articles) 1)
9185 (format "these %d articles" (length articles))
9190 (gnus-completing-read default prom
9192 'gnus-valid-move-group-p
9194 'gnus-group-history))
9195 ((= 1 (length split-name))
9196 (gnus-completing-read (car split-name) prom
9198 'gnus-valid-move-group-p
9200 'gnus-group-history))
9202 (gnus-completing-read nil prom
9203 (mapcar (lambda (el) (list el))
9204 (nreverse split-name))
9206 'gnus-group-history)))))
9208 (if (or (string= to-newsgroup "")
9209 (string= to-newsgroup prefix))
9210 (setq to-newsgroup default))
9211 (unless to-newsgroup
9212 (error "No group name entered"))
9213 (or (gnus-active to-newsgroup)
9214 (gnus-activate-group to-newsgroup)
9215 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9217 (or (and (gnus-request-create-group
9218 to-newsgroup (gnus-group-name-to-method to-newsgroup))
9219 (gnus-activate-group
9220 to-newsgroup nil nil
9221 (gnus-group-name-to-method to-newsgroup))
9222 (gnus-subscribe-group to-newsgroup))
9223 (error "Couldn't create group %s" to-newsgroup)))
9224 (error "No such group: %s" to-newsgroup)))
9227 (defun gnus-summary-save-parts (type dir n &optional reverse)
9228 "Save parts matching TYPE to DIR.
9229 If REVERSE, save parts that do not match TYPE."
9231 (list (read-string "Save parts of type: " "image/.*")
9232 (read-file-name "Save to directory: " nil nil t)
9233 current-prefix-arg))
9234 (gnus-summary-iterate n
9235 (let ((gnus-display-mime-function nil)
9236 (gnus-inhibit-treatment t))
9237 (gnus-summary-select-article))
9239 (set-buffer gnus-article-buffer)
9240 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9242 (gnus-summary-save-parts-1 type dir handles reverse)
9243 (mm-destroy-parts handles))))))
9245 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9246 (if (stringp (car handle))
9247 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9250 (not (string-match type (mm-handle-media-type handle)))
9251 (string-match type (mm-handle-media-type handle)))
9252 (let ((file (expand-file-name
9253 (file-name-nondirectory
9255 (mail-content-type-get
9256 (mm-handle-disposition handle) 'filename)
9257 (concat gnus-newsgroup-name "." gnus-current-article)))
9259 (unless (file-exists-p file)
9260 (mm-save-part-to-file handle file))))))
9262 ;; Summary extract commands
9264 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9265 (let ((buffer-read-only nil)
9266 (article (gnus-summary-article-number))
9268 (unless (gnus-summary-goto-subject article)
9269 (error "No such article: %d" article))
9270 (gnus-summary-position-point)
9271 ;; If all commands are to be bunched up on one line, we collect
9273 (unless gnus-view-pseudos-separately
9274 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9277 (setq action (cdr (assq 'action (car ps))))
9278 (setq files (list (cdr (assq 'name (car ps)))))
9279 (while (and ps (cdr ps)
9280 (string= (or action "1")
9281 (or (cdr (assq 'action (cadr ps))) "2")))
9282 (push (cdr (assq 'name (cadr ps))) files)
9283 (setcdr ps (cddr ps)))
9285 (when (not (string-match "%s" action))
9288 (when (assq 'execute (car ps))
9289 (setcdr (assq 'execute (car ps))
9290 (funcall (if (string-match "%s" action)
9297 (gnus-quote-arg-for-sh-or-csh f)))
9299 (setq ps (cdr ps)))))
9300 (if (and gnus-view-pseudos (not not-view))
9302 (when (assq 'execute (car pslist))
9303 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9304 (eq gnus-view-pseudos 'not-confirm)))
9305 (setq pslist (cdr pslist)))
9308 (setq after-article (or (cdr (assq 'article (car pslist)))
9309 (gnus-summary-article-number)))
9310 (gnus-summary-goto-subject after-article)
9313 (insert " " (file-name-nondirectory
9314 (cdr (assq 'name (car pslist))))
9315 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9317 (forward-line -1) ; back to `b'
9318 (gnus-add-text-properties
9319 b (1- e) (list 'gnus-number gnus-reffed-article-number
9320 gnus-mouse-face-prop gnus-mouse-face))
9322 after-article gnus-reffed-article-number
9323 gnus-unread-mark b (car pslist) 0 (- e b))
9324 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9325 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9326 (setq pslist (cdr pslist)))))))
9328 (defun gnus-pseudos< (p1 p2)
9329 (let ((c1 (cdr (assq 'action p1)))
9330 (c2 (cdr (assq 'action p2))))
9331 (and c1 c2 (string< c1 c2))))
9333 (defun gnus-request-pseudo-article (props)
9334 (cond ((assq 'execute props)
9335 (gnus-execute-command (cdr (assq 'execute props)))))
9336 (let ((gnus-current-article (gnus-summary-article-number)))
9337 (gnus-run-hooks 'gnus-mark-article-hook)))
9339 (defun gnus-execute-command (command &optional automatic)
9341 (gnus-article-setup-buffer)
9342 (set-buffer gnus-article-buffer)
9343 (setq buffer-read-only nil)
9344 (let ((command (if automatic command
9345 (read-string "Command: " (cons command 0)))))
9347 (insert "$ " command "\n\n")
9348 (if gnus-view-pseudo-asynchronously
9349 (start-process "gnus-execute" (current-buffer) shell-file-name
9350 shell-command-switch command)
9351 (call-process shell-file-name nil t nil
9352 shell-command-switch command)))))
9354 ;; Summary kill commands.
9356 (defun gnus-summary-edit-global-kill (article)
9357 "Edit the \"global\" kill file."
9358 (interactive (list (gnus-summary-article-number)))
9359 (gnus-group-edit-global-kill article))
9361 (defun gnus-summary-edit-local-kill ()
9362 "Edit a local kill file applied to the current newsgroup."
9364 (setq gnus-current-headers (gnus-summary-article-header))
9365 (gnus-group-edit-local-kill
9366 (gnus-summary-article-number) gnus-newsgroup-name))
9370 (defun gnus-read-header (id &optional header)
9371 "Read the headers of article ID and enter them into the Gnus system."
9372 (let ((group gnus-newsgroup-name)
9373 (gnus-override-method
9375 gnus-override-method
9376 (and (gnus-news-group-p gnus-newsgroup-name)
9377 (car (gnus-refer-article-methods)))))
9379 ;; First we check to see whether the header in question is already
9382 ;; This is a Message-ID.
9383 (setq header (or header (gnus-id-to-header id)))
9384 ;; This is an article number.
9385 (setq header (or header (gnus-summary-article-header id))))
9387 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9388 ;; We have found the header.
9390 ;; If this is a sparse article, we have to nix out its
9391 ;; previous entry in the thread hashtb.
9393 (gnus-summary-article-sparse-p (mail-header-number header)))
9394 (let* ((parent (gnus-parent-id (mail-header-references header)))
9395 (thread (and parent (gnus-id-to-thread parent))))
9397 (delq (assq header thread) thread))))
9398 ;; We have to really fetch the header to this article.
9400 (set-buffer nntp-server-buffer)
9401 (when (setq where (gnus-request-head id group))
9402 (nnheader-fold-continuation-lines)
9403 (goto-char (point-max))
9405 (goto-char (point-min))
9409 ((cdr where) (cdr where))
9410 (header (mail-header-number header))
9411 (t gnus-reffed-article-number))
9413 (insert " Article retrieved.\n"))
9415 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9416 () ; Malformed head.
9417 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9418 (when (and (stringp id)
9419 (not (string= (gnus-group-real-name group)
9421 ;; If we fetched by Message-ID and the article came
9422 ;; from a different group, we fudge some bogus article
9423 ;; numbers for this article.
9424 (mail-header-set-number header gnus-reffed-article-number))
9426 (set-buffer gnus-summary-buffer)
9427 (decf gnus-reffed-article-number)
9428 (gnus-remove-header (mail-header-number header))
9429 (push header gnus-newsgroup-headers)
9430 (setq gnus-current-headers header)
9431 (push (mail-header-number header) gnus-newsgroup-limit)))
9434 (defun gnus-remove-header (number)
9435 "Remove header NUMBER from `gnus-newsgroup-headers'."
9436 (if (and gnus-newsgroup-headers
9437 (= number (mail-header-number (car gnus-newsgroup-headers))))
9438 (pop gnus-newsgroup-headers)
9439 (let ((headers gnus-newsgroup-headers))
9440 (while (and (cdr headers)
9441 (not (= number (mail-header-number (cadr headers)))))
9444 (setcdr headers (cddr headers))))))
9447 ;;; summary highlights
9450 (defun gnus-highlight-selected-summary ()
9451 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9452 ;; Highlight selected article in summary buffer
9453 (when gnus-summary-selected-face
9455 (let* ((beg (progn (beginning-of-line) (point)))
9456 (end (progn (end-of-line) (point)))
9457 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9458 (from (if (get-text-property beg gnus-mouse-face-prop)
9460 (or (next-single-property-change
9461 beg gnus-mouse-face-prop nil end)
9466 (or (next-single-property-change
9467 from gnus-mouse-face-prop nil end)
9469 ;; If no mouse-face prop on line we will have to = from = end,
9470 ;; so we highlight the entire line instead.
9471 (when (= (+ to 2) from)
9474 (if gnus-newsgroup-selected-overlay
9475 ;; Move old overlay.
9477 gnus-newsgroup-selected-overlay from to (current-buffer))
9478 ;; Create new overlay.
9480 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9481 'face gnus-summary-selected-face))))))
9483 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9484 (defun gnus-summary-highlight-line ()
9485 "Highlight current line according to `gnus-summary-highlight'."
9486 (let* ((list gnus-summary-highlight)
9488 (end (progn (end-of-line) (point)))
9489 ;; now find out where the line starts and leave point there.
9490 (beg (progn (beginning-of-line) (point)))
9491 (article (gnus-summary-article-number))
9492 (score (or (cdr (assq (or article gnus-current-article)
9493 gnus-newsgroup-scored))
9494 gnus-summary-default-score 0))
9495 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9496 (inhibit-read-only t))
9497 ;; Eval the cars of the lists until we find a match.
9498 (let ((default gnus-summary-default-score))
9500 (not (eval (caar list))))
9501 (setq list (cdr list))))
9502 (let ((face (cdar list)))
9503 (unless (eq face (get-text-property beg 'face))
9504 (gnus-put-text-property-excluding-characters-with-faces
9506 (setq face (if (boundp face) (symbol-value face) face)))
9507 (when gnus-summary-highlight-line-function
9508 (funcall gnus-summary-highlight-line-function article face))))
9511 (defun gnus-update-read-articles (group unread &optional compute)
9512 "Update the list of read articles in GROUP."
9513 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9514 (entry (gnus-gethash group gnus-newsrc-hashtb))
9515 (info (nth 2 entry))
9517 (unread (sort (copy-sequence unread) '<))
9519 (if (or (not info) (not active))
9520 ;; There is no info on this group if it was, in fact,
9521 ;; killed. Gnus stores no information on killed groups, so
9522 ;; there's nothing to be done.
9523 ;; One could store the information somewhere temporarily,
9524 ;; perhaps... Hmmm...
9526 ;; Remove any negative articles numbers.
9527 (while (and unread (< (car unread) 0))
9528 (setq unread (cdr unread)))
9529 ;; Remove any expired article numbers
9530 (while (and unread (< (car unread) (car active)))
9531 (setq unread (cdr unread)))
9532 ;; Compute the ranges of read articles by looking at the list of
9535 (when (/= (car unread) prev)
9536 (push (if (= prev (1- (car unread))) prev
9537 (cons prev (1- (car unread))))
9539 (setq prev (1+ (car unread)))
9540 (setq unread (cdr unread)))
9541 (when (<= prev (cdr active))
9542 (push (cons prev (cdr active)) read))
9543 (setq read (if (> (length read) 1) (nreverse read) read))
9547 (set-buffer gnus-group-buffer)
9550 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9551 (gnus-info-set-read ',info ',(gnus-info-read info))
9552 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9553 (gnus-group-update-group ,group t))))
9554 ;; Propagate the read marks to the backend.
9555 (if (gnus-check-backend-function 'request-set-mark group)
9556 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9557 (add (gnus-remove-from-range read (gnus-info-read info))))
9559 (unless (gnus-check-group group)
9560 (error "Can't open server for %s" group))
9561 (gnus-request-set-mark
9562 group (delq nil (list (if add (list add 'add '(read)))
9563 (if del (list del 'del '(read)))))))))
9564 ;; Enter this list into the group info.
9565 (gnus-info-set-read info read)
9566 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9567 (gnus-get-unread-articles-in-group info (gnus-active group))
9570 (defun gnus-offer-save-summaries ()
9571 "Offer to save all active summary buffers."
9573 (let ((buflist (buffer-list))
9575 ;; Go through all buffers and find all summaries.
9577 (and (setq bufname (buffer-name (car buflist)))
9578 (string-match "Summary" bufname)
9580 (set-buffer bufname)
9581 ;; We check that this is, indeed, a summary buffer.
9582 (and (eq major-mode 'gnus-summary-mode)
9583 ;; Also make sure this isn't bogus.
9584 gnus-newsgroup-prepared
9585 ;; Also make sure that this isn't a dead summary buffer.
9586 (not gnus-dead-summary-mode)))
9587 (push bufname buffers))
9588 (setq buflist (cdr buflist)))
9589 ;; Go through all these summary buffers and offer to save them.
9592 "Update summary buffer %s? "
9594 (switch-to-buffer buf)
9595 (gnus-summary-exit))
9599 ;;; @ for mime-partial
9602 (defun gnus-request-partial-message ()
9604 (let ((number (gnus-summary-article-number))
9605 (group gnus-newsgroup-name)
9606 (mother gnus-article-buffer))
9607 (set-buffer (get-buffer-create " *Partial Article*"))
9609 (setq mime-preview-buffer mother)
9610 (gnus-request-article-this-buffer number group)
9614 (autoload 'mime-combine-message/partial-pieces-automatically
9616 "Internal method to combine message/partial messages automatically.")
9619 'action '((type . message)(subtype . partial)
9620 (major-mode . gnus-original-article-mode)
9621 (method . mime-combine-message/partial-pieces-automatically)
9622 (summary-buffer-exp . gnus-summary-buffer)
9623 (request-partial-message-method . gnus-request-partial-message)
9627 ;;; @ for message/rfc822
9630 (defun gnus-mime-extract-message/rfc822 (entity situation)
9631 (let (group article num cwin swin cur)
9632 (with-current-buffer (mime-entity-buffer entity)
9634 (narrow-to-region (mime-entity-body-start entity)
9635 (mime-entity-body-end entity))
9636 (setq group (or (cdr (assq 'group situation))
9637 (completing-read "Group: "
9640 (gnus-read-active-file-p)
9641 gnus-newsgroup-name))
9642 article (gnus-request-accept-article group)
9645 (when (and (consp article)
9646 (numberp (setq article (cdr article))))
9647 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9648 cwin (get-buffer-window (current-buffer) t)
9650 (save-window-excursion
9651 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9652 (select-window swin)
9653 (set-buffer gnus-summary-buffer)
9655 (setq cur gnus-current-article)
9657 (let (gnus-show-threads)
9658 (gnus-summary-goto-subject article t)
9660 (gnus-summary-clear-mark-forward 1)
9661 (gnus-summary-goto-subject cur)
9663 (when (and cwin (window-frame cwin))
9664 (select-frame (window-frame cwin))
9666 (when (boundp 'mime-acting-situation-to-override)
9667 (set-alist 'mime-acting-situation-to-override
9670 (set-alist 'mime-acting-situation-to-override
9673 (save-current-buffer
9674 (set-buffer gnus-group-buffer)
9675 (gnus-activate-group ,group)
9677 (gnus-summary-goto-article ,cur
9678 gnus-show-all-headers)
9680 (set-alist 'mime-acting-situation-to-override
9686 'action '((type . message)(subtype . rfc822)
9687 (major-mode . gnus-original-article-mode)
9688 (method . gnus-mime-extract-message/rfc822)
9693 'action '((type . message)(subtype . news)
9694 (major-mode . gnus-original-article-mode)
9695 (method . gnus-mime-extract-message/rfc822)
9699 (defun gnus-mime-extract-multipart (entity situation)
9700 (let ((children (mime-entity-children entity))
9701 mime-acting-situation-to-override
9704 (mime-play-entity (car children)
9705 (cons (assq 'mode situation)
9706 mime-acting-situation-to-override))
9707 (setq children (cdr children)))
9708 (if (setq f (cdr (assq 'after-method
9709 mime-acting-situation-to-override)))
9714 'action '((type . multipart)
9715 (method . gnus-mime-extract-multipart)
9724 (defun gnus-summary-setup-default-charset ()
9725 "Setup newsgroup default charset."
9726 (if (equal gnus-newsgroup-name "nndraft:drafts")
9727 (setq gnus-newsgroup-charset nil)
9728 (let* ((name (and gnus-newsgroup-name
9729 (gnus-group-real-name gnus-newsgroup-name)))
9731 (or gnus-newsgroup-ephemeral-ignored-charsets
9733 (and gnus-newsgroup-name
9734 (or (gnus-group-find-parameter gnus-newsgroup-name
9735 'ignored-charsets t)
9736 (let ((alist gnus-group-ignored-charsets-alist)
9737 elem (charsets nil))
9738 (while (setq elem (pop alist))
9740 (string-match (car elem) name))
9742 charsets (cdr elem))))
9744 gnus-newsgroup-ignored-charsets))))
9745 (setq gnus-newsgroup-charset
9746 (or gnus-newsgroup-ephemeral-charset
9747 (and gnus-newsgroup-name
9748 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9749 (let ((alist gnus-group-charset-alist)
9751 (while (setq elem (pop alist))
9753 (string-match (car elem) name))
9755 charset (cadr elem))))
9757 gnus-default-charset))
9758 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9759 ignored-charsets))))
9765 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9766 "Display the current article buffer fully MIME-buttonized.
9767 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9768 treated as multipart/mixed."
9771 (let ((gnus-unbuttonized-mime-types nil)
9772 (gnus-mime-display-multipart-as-mixed show-all-parts))
9773 (gnus-summary-show-article)))
9775 (defun gnus-summary-repair-multipart (article)
9776 "Add a Content-Type header to a multipart article without one."
9777 (interactive (list (gnus-summary-article-number)))
9778 (gnus-with-article article
9779 (message-narrow-to-head)
9780 (goto-char (point-max))
9782 (when (search-forward "\n--" nil t)
9783 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9784 (message-narrow-to-head)
9785 (message-remove-header "Mime-Version")
9786 (message-remove-header "Content-Type")
9787 (goto-char (point-max))
9788 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9790 (insert "Mime-Version: 1.0\n")
9792 (let (gnus-mark-article-hook)
9793 (gnus-summary-select-article t t nil article)))
9795 (defun gnus-summary-toggle-display-buttonized ()
9796 "Toggle the buttonizing of the article buffer."
9799 (if (setq gnus-inhibit-mime-unbuttonizing
9800 (not gnus-inhibit-mime-unbuttonizing))
9801 (let ((gnus-unbuttonized-mime-types nil))
9802 (gnus-summary-show-article))
9803 (gnus-summary-show-article)))
9806 ;;; Intelli-mouse commmands
9809 (defun gnus-wheel-summary-scroll (event)
9811 (let ((amount (if (memq 'shift (event-modifiers event))
9812 (car gnus-wheel-scroll-amount)
9813 (cdr gnus-wheel-scroll-amount)))
9814 (direction (- (* (static-if (featurep 'xemacs)
9815 (event-button event)
9816 (cond ((eq 'mouse-4 (event-basic-type event))
9818 ((eq 'mouse-5 (event-basic-type event))
9822 (gnus-summary-scroll-up (* amount direction))
9823 (when (gnus-eval-in-buffer-window gnus-article-buffer
9826 (and (if (< 0 direction)
9827 (gnus-article-next-page 0)
9828 (gnus-article-prev-page 0)
9830 (if (setq edge (get-text-property
9831 (point-min) 'gnus-wheel-edge))
9832 (setq edge (* edge direction))
9835 (let ((buffer-read-only nil)
9836 (inhibit-read-only t))
9837 (put-text-property (point-min) (point-max)
9838 'gnus-wheel-edge direction)
9840 (or (> edge gnus-wheel-edge-resistance)
9841 (let ((buffer-read-only nil)
9842 (inhibit-read-only t))
9843 (put-text-property (point-min) (point-max)
9845 (* (1+ edge) direction))
9847 (eq last-command 'gnus-wheel-summary-scroll))))
9848 (gnus-summary-next-article nil nil (minusp direction)))))
9850 (defun gnus-wheel-install ()
9851 "Enable mouse wheel support on summary window."
9852 (when gnus-use-wheel
9854 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
9856 (define-key gnus-summary-mode-map key
9857 'gnus-wheel-summary-scroll)))))
9859 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
9862 ;;; Traditional PGP commmands
9865 (defun gnus-summary-decrypt-article (&optional force)
9866 "Decrypt the current article in traditional PGP way.
9867 This will have permanent effect only in mail groups.
9868 If FORCE is non-nil, allow editing of articles even in read-only
9871 (gnus-summary-select-article t)
9872 (gnus-eval-in-buffer-window gnus-article-buffer
9876 (goto-char (point-min))
9877 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
9878 (error "Not a traditional PGP message!"))
9879 (let ((armor-start (match-beginning 0)))
9880 (if (and (pgg-decrypt-region armor-start (point-max))
9881 (or force (not (gnus-group-read-only-p))))
9882 (let ((inhibit-read-only t)
9884 (delete-region armor-start
9886 (re-search-forward "^-+END PGP" nil t)
9887 (beginning-of-line 2)
9889 (insert-buffer-substring pgg-output-buffer))))))))
9891 (defun gnus-summary-verify-article ()
9892 "Verify the current article in traditional PGP way."
9895 (set-buffer gnus-original-article-buffer)
9896 (goto-char (point-min))
9897 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
9898 (error "Not a traditional PGP message!"))
9899 (re-search-forward "^-+END PGP" nil t)
9900 (beginning-of-line 2)
9901 (call-interactively (function pgg-verify-region))))
9907 (defmacro gnus-with-article (article &rest forms)
9908 "Select ARTICLE and perform FORMS in the original article buffer.
9909 Then replace the article with the result."
9911 ;; We don't want the article to be marked as read.
9912 (let (gnus-mark-article-hook)
9913 (gnus-summary-select-article t t nil ,article))
9914 (set-buffer gnus-original-article-buffer)
9916 (if (not (gnus-check-backend-function
9917 'request-replace-article (car gnus-article-current)))
9918 (gnus-message 5 "Read-only group; not replacing")
9919 (unless (gnus-request-replace-article
9920 ,article (car gnus-article-current)
9922 (error "Couldn't replace article")))
9923 ;; The cache and backlog have to be flushed somewhat.
9924 (when gnus-keep-backlog
9925 (gnus-backlog-remove-article
9926 (car gnus-article-current) (cdr gnus-article-current)))
9927 (when gnus-use-cache
9928 (gnus-cache-update-article
9929 (car gnus-article-current) (cdr gnus-article-current)))))
9931 (put 'gnus-with-article 'lisp-indent-function 1)
9932 (put 'gnus-with-article 'edebug-form-spec '(form body))
9935 ;;; Generic summary marking commands
9938 (defvar gnus-summary-marking-alist
9939 '((read gnus-del-mark "d")
9940 (unread gnus-unread-mark "u")
9941 (ticked gnus-ticked-mark "!")
9942 (dormant gnus-dormant-mark "?")
9943 (expirable gnus-expirable-mark "e"))
9944 "An alist of names/marks/keystrokes.")
9946 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9947 (defvar gnus-summary-mark-map)
9949 (defun gnus-summary-make-all-marking-commands ()
9950 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9951 (dolist (elem gnus-summary-marking-alist)
9952 (apply 'gnus-summary-make-marking-command elem)))
9954 (defun gnus-summary-make-marking-command (name mark keystroke)
9955 (let ((map (make-sparse-keymap)))
9956 (define-key gnus-summary-generic-mark-map keystroke map)
9957 (dolist (lway `((next "next" next nil "n")
9958 (next-unread "next unread" next t "N")
9959 (prev "previous" prev nil "p")
9960 (prev-unread "previous unread" prev t "P")
9961 (nomove "" nil nil ,keystroke)))
9962 (let ((func (gnus-summary-make-marking-command-1
9963 mark (car lway) lway name)))
9964 (setq func (eval func))
9965 (define-key map (nth 4 lway) func)))))
9967 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9969 (format "gnus-summary-put-mark-as-%s%s"
9970 name (if (eq way 'nomove)
9972 (concat "-" (symbol-name way)))))
9975 "Mark the current article as %s%s.
9976 If N, the prefix, then repeat N times.
9977 If N is negative, move in reverse order.
9978 The difference between N and the actual number of articles marked is
9980 name (car (cdr lway)))
9982 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9984 (defun gnus-summary-generic-mark (n mark move unread)
9985 "Mark N articles with MARK."
9986 (unless (eq major-mode 'gnus-summary-mode)
9987 (error "This command can only be used in the summary buffer"))
9988 (gnus-summary-show-thread)
9992 ((eq move 'prev) -1)
9998 nummove (* -1 nummove))))
10000 (gnus-summary-mark-article nil mark)
10001 (zerop (gnus-summary-next-subject nummove unread t)))
10004 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10005 (gnus-summary-recenter)
10006 (gnus-summary-position-point)
10007 (gnus-set-mode-line 'summary)
10010 (gnus-summary-make-all-marking-commands)
10012 (gnus-ems-redefine)
10014 (provide 'gnus-sum)
10016 (run-hooks 'gnus-sum-load-hook)
10018 ;;; gnus-sum.el ends here