1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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 3 of the License, or
14 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
28 ;; For Emacs <22.2 and XEmacs.
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34 (when (featurep 'xemacs)
35 (require 'easy-mmode))) ; for `define-minor-mode'
37 (defvar tool-bar-mode)
38 (defvar gnus-tmp-header)
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-cache-write-active "gnus-cache")
53 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
54 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
55 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
60 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
64 (defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66 If nil, the summary will become a \"*Dead Summary*\" buffer, and
67 it will be killed sometime later."
68 :group 'gnus-summary-exit
71 (defcustom gnus-summary-next-group-on-exit t
72 "If non-nil, go to the next unread newsgroup on summary exit.
73 See `gnus-group-goto-unread'."
74 :link '(custom-manual "(gnus)Group Maneuvering")
75 :group 'gnus-summary-exit
76 :version "23.1" ;; No Gnus
79 (defcustom gnus-summary-stop-at-end-of-message nil
80 "If non-nil, don't select the next message when using `SPC'."
81 :link '(custom-manual "(gnus)Group Maneuvering")
82 :group 'gnus-summary-maneuvering
86 (defcustom gnus-fetch-old-headers nil
87 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
88 If an unread article in the group refers to an older, already
89 read (or just marked as read) article, the old article will not
90 normally be displayed in the Summary buffer. If this variable is
91 t, Gnus will attempt to grab the headers to the old articles, and
92 thereby build complete threads. If it has the value `some', all
93 old headers will be fetched but only enough headers to connect
94 otherwise loose threads will be displayed. This variable can
95 also be a number. In that case, no more than that number of old
96 headers will be fetched. If it has the value `invisible', all
97 old headers will be fetched, but none will be displayed.
99 The server has to support NOV for any of this to work.
101 This feature can seriously impact performance it ignores all
102 locally cached header entries. Setting it to t for groups for a
103 server that doesn't expire articles (such as news.gmane.org),
104 leads to very slow summary generation."
106 :type '(choice (const :tag "off" nil)
111 (sexp :menu-tag "other" t)))
113 (defcustom gnus-refer-thread-limit 500
114 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
115 If t, fetch all the available old headers."
117 :type '(choice number
118 (sexp :menu-tag "other" t)))
120 (defcustom gnus-summary-make-false-root 'adopt
121 "*nil means that Gnus won't gather loose threads.
122 If the root of a thread has expired or been read in a previous
123 session, the information necessary to build a complete thread has been
124 lost. Instead of having many small sub-threads from this original thread
125 scattered all over the summary buffer, Gnus can gather them.
127 If non-nil, Gnus will try to gather all loose sub-threads from an
128 original thread into one large thread.
130 If this variable is non-nil, it should be one of `none', `adopt',
133 If this variable is `none', Gnus will not make a false root, but just
134 present the sub-threads after another.
135 If this variable is `dummy', Gnus will create a dummy root that will
136 have all the sub-threads as children.
137 If this variable is `adopt', Gnus will make one of the \"children\"
138 the parent and mark all the step-children as such.
139 If this variable is `empty', the \"children\" are printed with empty
140 subject fields. (Or rather, they will be printed with a string
141 given by the `gnus-summary-same-subject' variable.)"
143 :type '(choice (const :tag "off" nil)
149 (defcustom gnus-summary-make-false-root-always nil
150 "Always make a false dummy root."
155 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
156 "*A regexp to match subjects to be excluded from loose thread gathering.
157 As loose thread gathering is done on subjects only, that means that
158 there can be many false gatherings performed. By rooting out certain
159 common subjects, gathering might become saner."
163 (defcustom gnus-summary-gather-subject-limit nil
164 "*Maximum length of subject comparisons when gathering loose threads.
165 Use nil to compare full subjects. Setting this variable to a low
166 number will help gather threads that have been corrupted by
167 newsreaders chopping off subject lines, but it might also mean that
168 unrelated articles that have subject that happen to begin with the
169 same few characters will be incorrectly gathered.
171 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
174 :type '(choice (const :tag "off" nil)
176 (sexp :menu-tag "on" t)))
178 (defcustom gnus-simplify-subject-functions nil
179 "List of functions taking a string argument that simplify subjects.
180 The functions are applied recursively.
182 Useful functions to put in this list include:
183 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
184 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
186 :type '(repeat function))
188 (defcustom gnus-simplify-ignored-prefixes nil
189 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
191 :type '(choice (const :tag "off" nil)
194 (defcustom gnus-build-sparse-threads nil
195 "*If non-nil, fill in the gaps in threads.
196 If `some', only fill in the gaps that are needed to tie loose threads
197 together. If `more', fill in all leaf nodes that Gnus can find. If
198 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
200 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "all" t)))
205 (defcustom gnus-summary-thread-gathering-function
206 'gnus-gather-threads-by-subject
207 "*Function used for gathering loose threads.
208 There are two pre-defined functions: `gnus-gather-threads-by-subject',
209 which only takes Subjects into consideration; and
210 `gnus-gather-threads-by-references', which compared the References
211 headers of the articles to find matches."
213 :type '(radio (function-item gnus-gather-threads-by-subject)
214 (function-item gnus-gather-threads-by-references)
215 (function :tag "other")))
217 (defcustom gnus-summary-same-subject ""
218 "*String indicating that the current article has the same subject as the previous.
219 This variable will only be used if the value of
220 `gnus-summary-make-false-root' is `empty'."
221 :group 'gnus-summary-format
224 (defcustom gnus-summary-goto-unread nil
225 "*If t, many commands will go to the next unread article.
226 This applies to marking commands as well as other commands that
227 \"naturally\" select the next article, like, for instance, `SPC' at
228 the end of an article.
230 If nil, the marking commands do NOT go to the next unread article
231 \(they go to the next article instead). If `never', commands that
232 usually go to the next unread article, will go to the next article,
233 whether it is read or not."
235 :group 'gnus-summary-marks
236 :link '(custom-manual "(gnus)Setting Marks")
237 :type '(choice (const :tag "off" nil)
239 (sexp :menu-tag "on" t)))
241 (defcustom gnus-summary-default-score 0
242 "*Default article score level.
243 All scores generated by the score files will be added to this score.
244 If this variable is nil, scoring will be disabled."
245 :group 'gnus-score-default
246 :type '(choice (const :tag "disable")
249 (defcustom gnus-summary-default-high-score 0
250 "*Default threshold for a high scored article.
251 An article will be highlighted as high scored if its score is greater
254 :group 'gnus-score-default
257 (defcustom gnus-summary-default-low-score 0
258 "*Default threshold for a low scored article.
259 An article will be highlighted as low scored if its score is smaller
262 :group 'gnus-score-default
265 (defcustom gnus-summary-zcore-fuzz 0
266 "*Fuzziness factor for the zcore in the summary buffer.
267 Articles with scores closer than this to `gnus-summary-default-score'
269 :group 'gnus-summary-format
272 (defcustom gnus-simplify-subject-fuzzy-regexp nil
273 "*Strings to be removed when doing fuzzy matches.
274 This can either be a regular expression or list of regular expressions
275 that will be removed from subject strings if fuzzy subject
276 simplification is selected."
278 :type '(repeat regexp))
280 (defcustom gnus-show-threads t
281 "*If non-nil, display threads in summary mode."
285 (defcustom gnus-thread-hide-subtree nil
286 "*If non-nil, hide all threads initially.
287 This can be a predicate specifier which says which threads to hide.
288 If threads are hidden, you have to run the command
289 `gnus-summary-show-thread' by hand or select an article."
291 :type '(radio (sexp :format "Non-nil\n"
292 :match (lambda (widget value)
293 (not (or (consp value) (functionp value))))
296 (sexp :tag "Predicate specifier")))
298 (defcustom gnus-thread-hide-killed t
299 "*If non-nil, hide killed threads automatically."
303 (defcustom gnus-thread-ignore-subject t
304 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
305 If nil, articles that have different subjects from their parents will
306 start separate threads."
310 (defcustom gnus-thread-operation-ignore-subject t
311 "*If non-nil, subjects will be ignored when doing thread commands.
312 This affects commands like `gnus-summary-kill-thread' and
313 `gnus-summary-lower-thread'.
315 If this variable is nil, articles in the same thread with different
316 subjects will not be included in the operation in question. If this
317 variable is `fuzzy', only articles that have subjects that are fuzzily
318 equal will be included."
320 :type '(choice (const :tag "off" nil)
324 (defcustom gnus-thread-indent-level 4
325 "*Number that says how much each sub-thread should be indented."
329 (defcustom gnus-auto-extend-newsgroup t
330 "*If non-nil, extend newsgroup forward and backward when requested."
331 :group 'gnus-summary-choose
334 (defcustom gnus-auto-select-first t
335 "If non-nil, select an article on group entry.
336 An article is selected automatically when entering a group
337 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
338 `gnus-summary-catchup-and-goto-next-group'.
340 Which article is selected is controlled by the variable
341 `gnus-auto-select-subject'.
343 If you want to prevent automatic selection of articles in some
344 newsgroups, set the variable to nil in `gnus-select-group-hook'."
345 ;; Commands include...
346 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
347 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
349 :group 'gnus-group-select
350 :type '(choice (const :tag "none" nil)
351 (sexp :menu-tag "first" t)))
353 (defcustom gnus-auto-select-subject 'unseen-or-unread
354 "*Says what subject to place under point when entering a group.
356 This variable can either be the symbols `first' (place point on the
357 first subject), `unread' (place point on the subject line of the first
358 unread article), `best' (place point on the subject line of the
359 higest-scored article), `unseen' (place point on the subject line of
360 the first unseen article), `unseen-or-unread' (place point on the subject
361 line of the first unseen article or, if all article have been seen, on the
362 subject line of the first unread article), or a function to be called to
363 place point on some subject line."
365 :group 'gnus-group-select
366 :type '(choice (const best)
370 (const unseen-or-unread)))
372 (defcustom gnus-auto-select-next t
373 "*If non-nil, offer to go to the next group from the end of the previous.
374 If the value is t and the next newsgroup is empty, Gnus will exit
375 summary mode and go back to group mode. If the value is neither nil
376 nor t, Gnus will select the following unread newsgroup. In
377 particular, if the value is the symbol `quietly', the next unread
378 newsgroup will be selected without any confirmation, and if it is
379 `almost-quietly', the next group will be selected without any
380 confirmation if you are located on the last article in the group.
381 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
382 will go to the next group without confirmation."
383 :group 'gnus-summary-maneuvering
384 :type '(choice (const :tag "off" nil)
386 (const almost-quietly)
387 (const slightly-quietly)
388 (sexp :menu-tag "on" t)))
390 (defcustom gnus-auto-select-same nil
391 "*If non-nil, select the next article with the same subject.
392 If there are no more articles with the same subject, go to
393 the first unread article."
394 :group 'gnus-summary-maneuvering
397 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
398 "What article should be selected after exiting an ephemeral group.
399 Valid values include:
402 Select the next article.
404 Select the next unread article.
406 Move the cursor to the next article. This is the default.
407 `next-unread-noselect'
408 Move the cursor to the next unread article.
410 If it has any other value or there is no next (unread) article, the
411 article selected before entering to the ephemeral group will appear."
412 :version "23.1" ;; No Gnus
413 :group 'gnus-summary-maneuvering
414 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
415 (const next) (const next-unread)
416 (const next-noselect) (const next-unread-noselect)
417 (sexp :tag "other" :value nil)))
419 (defcustom gnus-auto-goto-ignores 'unfetched
420 "*Says how to handle unfetched articles when maneuvering.
422 This variable can either be the symbols nil (maneuver to any
423 article), `undownloaded' (maneuvering while unplugged ignores articles
424 that have not been fetched), `always-undownloaded' (maneuvering always
425 ignores articles that have not been fetched), `unfetched' (maneuvering
426 ignores articles whose headers have not been fetched).
428 NOTE: The list of unfetched articles will always be nil when plugged
429 and, when unplugged, a subset of the undownloaded article list."
431 :group 'gnus-summary-maneuvering
432 :type '(choice (const :tag "None" nil)
433 (const :tag "Undownloaded when unplugged" undownloaded)
434 (const :tag "Undownloaded" always-undownloaded)
435 (const :tag "Unfetched" unfetched)))
437 (defcustom gnus-summary-check-current nil
438 "*If non-nil, consider the current article when moving.
439 The \"unread\" movement commands will stay on the same line if the
440 current article is unread."
441 :group 'gnus-summary-maneuvering
444 (defcustom gnus-auto-center-summary 2
445 "*If non-nil, always center the current summary buffer.
446 In particular, if `vertical' do only vertical recentering. If non-nil
447 and non-`vertical', do both horizontal and vertical recentering."
448 :group 'gnus-summary-maneuvering
449 :type '(choice (const :tag "none" nil)
451 (integer :tag "height")
452 (sexp :menu-tag "both" t)))
454 (defcustom gnus-auto-center-group t
455 "If non-nil, always center the group buffer."
456 :group 'gnus-summary-maneuvering
459 (defcustom gnus-show-all-headers nil
460 "*If non-nil, don't hide any headers."
461 :group 'gnus-article-hiding
462 :group 'gnus-article-headers
465 (defcustom gnus-summary-ignore-duplicates nil
466 "*If non-nil, ignore articles with identical Message-ID headers."
470 (defcustom gnus-single-article-buffer nil
471 "*If non-nil, display all articles in the same buffer.
472 If nil, each group will get its own article buffer."
474 :group 'gnus-article-various
477 (defcustom gnus-widen-article-window nil
478 "If non-nil, selecting the article buffer will display only the article buffer."
480 :group 'gnus-article-various
483 (defcustom gnus-break-pages t
484 "*If non-nil, do page breaking on articles.
485 The page delimiter is specified by the `gnus-page-delimiter'
487 :group 'gnus-article-various
490 (defcustom gnus-move-split-methods nil
491 "*Variable used to suggest where articles are to be moved to.
492 It uses the same syntax as the `gnus-split-methods' variable.
493 However, whereas `gnus-split-methods' specifies file names as targets,
494 this variable specifies group names."
495 :group 'gnus-summary-mail
496 :type '(repeat (choice (list :value (fun) function)
497 (cons :value ("" "") regexp (repeat string))
500 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
501 "Function used to compute default prefix for article move/copy/etc prompts.
502 The function should take one argument, a group name, and return a
503 string with the suggested prefix."
504 :group 'gnus-summary-mail
507 ;; FIXME: Although the custom type is `character' for the following variables,
508 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
510 (defcustom gnus-unread-mark ? ;Whitespace
511 "*Mark used for unread articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-ticked-mark ?!
516 "*Mark used for ticked articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-dormant-mark ??
521 "*Mark used for dormant articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-del-mark ?r
526 "*Mark used for del'd articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-read-mark ?R
531 "*Mark used for read articles."
532 :group 'gnus-summary-marks
535 (defcustom gnus-expirable-mark ?E
536 "*Mark used for expirable articles."
537 :group 'gnus-summary-marks
540 (defcustom gnus-killed-mark ?K
541 "*Mark used for killed articles."
542 :group 'gnus-summary-marks
545 (defcustom gnus-spam-mark ?$
546 "*Mark used for spam articles."
548 :group 'gnus-summary-marks
551 (defcustom gnus-kill-file-mark ?X
552 "*Mark used for articles killed by kill files."
553 :group 'gnus-summary-marks
556 (defcustom gnus-low-score-mark ?Y
557 "*Mark used for articles with a low score."
558 :group 'gnus-summary-marks
561 (defcustom gnus-catchup-mark ?C
562 "*Mark used for articles that are caught up."
563 :group 'gnus-summary-marks
566 (defcustom gnus-replied-mark ?A
567 "*Mark used for articles that have been replied to."
568 :group 'gnus-summary-marks
571 (defcustom gnus-forwarded-mark ?F
572 "*Mark used for articles that have been forwarded."
574 :group 'gnus-summary-marks
577 (defcustom gnus-recent-mark ?N
578 "*Mark used for articles that are recent."
580 :group 'gnus-summary-marks
583 (defcustom gnus-cached-mark ?*
584 "*Mark used for articles that are in the cache."
585 :group 'gnus-summary-marks
588 (defcustom gnus-saved-mark ?S
589 "*Mark used for articles that have been saved."
590 :group 'gnus-summary-marks
593 (defcustom gnus-unseen-mark ?.
594 "*Mark used for articles that haven't been seen."
596 :group 'gnus-summary-marks
599 (defcustom gnus-no-mark ? ;Whitespace
600 "*Mark used for articles that have no other secondary mark."
602 :group 'gnus-summary-marks
605 (defcustom gnus-ancient-mark ?O
606 "*Mark used for ancient articles."
607 :group 'gnus-summary-marks
610 (defcustom gnus-sparse-mark ?Q
611 "*Mark used for sparsely reffed articles."
612 :group 'gnus-summary-marks
615 (defcustom gnus-canceled-mark ?G
616 "*Mark used for canceled articles."
617 :group 'gnus-summary-marks
620 (defcustom gnus-duplicate-mark ?M
621 "*Mark used for duplicate articles."
622 :group 'gnus-summary-marks
625 (defcustom gnus-undownloaded-mark ?-
626 "*Mark used for articles that weren't downloaded."
628 :group 'gnus-summary-marks
631 (defcustom gnus-downloaded-mark ?+
632 "*Mark used for articles that were downloaded."
633 :group 'gnus-summary-marks
636 (defcustom gnus-downloadable-mark ?%
637 "*Mark used for articles that are to be downloaded."
638 :group 'gnus-summary-marks
641 (defcustom gnus-unsendable-mark ?=
642 "*Mark used for articles that won't be sent."
643 :group 'gnus-summary-marks
646 (defcustom gnus-score-over-mark ?+
647 "*Score mark used for articles with high scores."
648 :group 'gnus-summary-marks
651 (defcustom gnus-score-below-mark ?-
652 "*Score mark used for articles with low scores."
653 :group 'gnus-summary-marks
656 (defcustom gnus-empty-thread-mark ? ;Whitespace
657 "*There is no thread under the article."
658 :group 'gnus-summary-marks
661 (defcustom gnus-not-empty-thread-mark ?=
662 "*There is a thread under the article."
663 :group 'gnus-summary-marks
666 (defcustom gnus-view-pseudo-asynchronously nil
667 "*If non-nil, Gnus will view pseudo-articles asynchronously."
668 :group 'gnus-extract-view
671 (defcustom gnus-auto-expirable-marks
672 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
673 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
675 "*The list of marks converted into expiration if a group is auto-expirable."
678 :type '(repeat character))
680 (defcustom gnus-inhibit-user-auto-expire t
681 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
686 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
687 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
688 If nil, the expirable marks will be unchanged except that the marks
689 will be removed when copying or moving articles to a group that has
690 not turned auto-expire on. If non-nil, articles that have been read
691 will be marked as expirable when being copied or moved to a group in
692 which auto-expire is turned on."
695 :group 'gnus-summary-marks)
697 (defcustom gnus-view-pseudos nil
698 "*If `automatic', pseudo-articles will be viewed automatically.
699 If `not-confirm', pseudos will be viewed automatically, and the user
700 will not be asked to confirm the command."
701 :group 'gnus-extract-view
702 :type '(choice (const :tag "off" nil)
704 (const not-confirm)))
706 (defcustom gnus-view-pseudos-separately t
707 "*If non-nil, one pseudo-article will be created for each file to be viewed.
708 If nil, all files that use the same viewing command will be given as a
709 list of parameters to that command."
710 :group 'gnus-extract-view
713 (defcustom gnus-insert-pseudo-articles t
714 "*If non-nil, insert pseudo-articles when decoding articles."
715 :group 'gnus-extract-view
718 (defcustom gnus-summary-dummy-line-format
720 "*The format specification for the dummy roots in the summary buffer.
721 It works along the same lines as a normal formatting string,
722 with some simple extensions.
726 General format specifiers can also be used.
727 See `(gnus)Formatting Variables'."
728 :link '(custom-manual "(gnus)Formatting Variables")
729 :group 'gnus-threading
732 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
733 "*The format specification for the summary mode line.
734 It works along the same lines as a normal formatting string,
735 with some simple extensions:
738 %p Unprefixed group name
739 %A Current article number
740 %z Current article score
742 %U Number of unread articles in the group
743 %e Number of unselected articles in the group
744 %Z A string with unread/unselected article counts
745 %g Shortish group name
746 %S Subject of the current article
748 %s Current score file name
749 %d Number of dormant articles
750 %r Number of articles that have been marked as read in this session
751 %E Number of articles expunged by the score files"
752 :group 'gnus-summary-format
755 (defcustom gnus-list-identifiers nil
756 "Regexp that matches list identifiers to be removed from subject.
757 This can also be a list of regexps."
759 :group 'gnus-summary-format
760 :group 'gnus-article-hiding
761 :type '(choice (const :tag "none" nil)
763 (repeat :value (".*") regexp)))
765 (defcustom gnus-summary-mark-below 0
766 "*Mark all articles with a score below this variable as read.
767 This variable is local to each summary buffer and usually set by the
769 :group 'gnus-score-default
772 (defun gnus-widget-reversible-match (widget value)
773 "Ignoring WIDGET, convert VALUE to internal form.
774 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
778 (eq (length value) 2)
779 (eq (nth 0 value) 'not)
780 (symbolp (nth 1 value)))))
782 (defun gnus-widget-reversible-to-internal (widget value)
783 "Ignoring WIDGET, convert VALUE to internal form.
784 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
785 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
789 (list (nth 1 value) t)))
791 (defun gnus-widget-reversible-to-external (widget value)
792 "Ignoring WIDGET, convert VALUE to external form.
793 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
794 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
797 (list 'not (nth 0 value))
800 (define-widget 'gnus-widget-reversible 'group
801 "A `group' that convert values."
802 :match 'gnus-widget-reversible-match
803 :value-to-internal 'gnus-widget-reversible-to-internal
804 :value-to-external 'gnus-widget-reversible-to-external)
806 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
807 "*List of functions used for sorting articles in the summary buffer.
809 Each function takes two articles and returns non-nil if the first
810 article should be sorted before the other. If you use more than one
811 function, the primary sort function should be the last. You should
812 probably always include `gnus-article-sort-by-number' in the list of
813 sorting functions -- preferably first. Also note that sorting by date
814 is often much slower than sorting by number, and the sorting order is
815 very similar. (Sorting by date means sorting by the time the message
816 was sent, sorting by number means sorting by arrival time.)
818 Each item can also be a list `(not F)' where F is a function;
819 this reverses the sort order.
821 Ready-made functions include `gnus-article-sort-by-number',
822 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
823 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
824 and `gnus-article-sort-by-score'.
826 When threading is turned on, the variable `gnus-thread-sort-functions'
827 controls how articles are sorted."
828 :group 'gnus-summary-sort
829 :type '(repeat (gnus-widget-reversible
830 (choice (function-item gnus-article-sort-by-number)
831 (function-item gnus-article-sort-by-author)
832 (function-item gnus-article-sort-by-subject)
833 (function-item gnus-article-sort-by-date)
834 (function-item gnus-article-sort-by-score)
835 (function-item gnus-article-sort-by-random)
836 (function :tag "other"))
837 (boolean :tag "Reverse order"))))
840 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
841 "*List of functions used for sorting threads in the summary buffer.
842 By default, threads are sorted by article number.
844 Each function takes two threads and returns non-nil if the first
845 thread should be sorted before the other. If you use more than one
846 function, the primary sort function should be the last. You should
847 probably always include `gnus-thread-sort-by-number' in the list of
848 sorting functions -- preferably first. Also note that sorting by date
849 is often much slower than sorting by number, and the sorting order is
850 very similar. (Sorting by date means sorting by the time the message
851 was sent, sorting by number means sorting by arrival time.)
853 Each list item can also be a list `(not F)' where F is a
854 function; this specifies reversed sort order.
856 Ready-made functions include `gnus-thread-sort-by-number',
857 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
858 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
859 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
860 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
861 and `gnus-thread-sort-by-total-score' (see
862 `gnus-thread-score-function').
864 When threading is turned off, the variable
865 `gnus-article-sort-functions' controls how articles are sorted."
866 :group 'gnus-summary-sort
868 (gnus-widget-reversible
869 (choice (function-item gnus-thread-sort-by-number)
870 (function-item gnus-thread-sort-by-author)
871 (function-item gnus-thread-sort-by-recipient)
872 (function-item gnus-thread-sort-by-subject)
873 (function-item gnus-thread-sort-by-date)
874 (function-item gnus-thread-sort-by-score)
875 (function-item gnus-thread-sort-by-most-recent-number)
876 (function-item gnus-thread-sort-by-most-recent-date)
877 (function-item gnus-thread-sort-by-random)
878 (function-item gnus-thread-sort-by-total-score)
879 (function :tag "other"))
880 (boolean :tag "Reverse order"))))
882 (defcustom gnus-thread-score-function '+
883 "*Function used for calculating the total score of a thread.
885 The function is called with the scores of the article and each
886 subthread and should then return the score of the thread.
888 Some functions you can use are `+', `max', or `min'."
889 :group 'gnus-summary-sort
892 (defcustom gnus-summary-expunge-below nil
893 "All articles that have a score less than this variable will be expunged.
894 This variable is local to the summary buffers."
895 :group 'gnus-score-default
896 :type '(choice (const :tag "off" nil)
899 (defcustom gnus-thread-expunge-below nil
900 "All threads that have a total score less than this variable will be expunged.
901 See `gnus-thread-score-function' for en explanation of what a
904 This variable is local to the summary buffers."
905 :group 'gnus-threading
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
910 (defcustom gnus-summary-mode-hook nil
911 "*A hook for Gnus summary mode.
912 This hook is run before any variables are set in the summary buffer."
913 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
914 :group 'gnus-summary-various
917 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
918 (when (featurep 'xemacs)
919 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
920 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
921 (add-hook 'gnus-summary-mode-hook
922 'gnus-xmas-switch-horizontal-scrollbar-off))
924 (defcustom gnus-summary-menu-hook nil
925 "*Hook run after the creation of the summary mode menu."
926 :group 'gnus-summary-visual
929 (defcustom gnus-summary-exit-hook nil
930 "*A hook called on exit from the summary buffer.
931 It will be called with point in the group buffer."
932 :group 'gnus-summary-exit
935 (defcustom gnus-summary-prepare-hook nil
936 "*A hook called after the summary buffer has been generated.
937 If you want to modify the summary buffer, you can use this hook."
938 :group 'gnus-summary-various
941 (defcustom gnus-summary-prepared-hook nil
942 "*A hook called as the last thing after the summary buffer has been generated."
943 :group 'gnus-summary-various
946 (defcustom gnus-summary-generate-hook nil
947 "*A hook run just before generating the summary buffer.
948 This hook is commonly used to customize threading variables and the
950 :group 'gnus-summary-various
953 (defcustom gnus-select-group-hook nil
954 "*A hook called when a newsgroup is selected.
956 If you'd like to simplify subjects like the
957 `gnus-summary-next-same-subject' command does, you can use the
960 (add-hook gnus-select-group-hook
962 (mapcar (lambda (header)
963 (mail-header-set-subject
965 (gnus-simplify-subject
966 (mail-header-subject header) 're-only)))
967 gnus-newsgroup-headers)))"
968 :group 'gnus-group-select
971 (defcustom gnus-select-article-hook nil
972 "*A hook called when an article is selected."
973 :group 'gnus-summary-choose
974 :options '(gnus-agent-fetch-selected-article)
977 (defcustom gnus-visual-mark-article-hook
978 (list 'gnus-highlight-selected-summary)
979 "*Hook run after selecting an article in the summary buffer.
980 It is meant to be used for highlighting the article in some way. It
981 is not run if `gnus-visual' is nil."
982 :group 'gnus-summary-visual
985 (defcustom gnus-parse-headers-hook nil
986 "*A hook called before parsing the headers."
990 (defcustom gnus-exit-group-hook nil
991 "*A hook called when exiting summary mode.
992 This hook is not called from the non-updating exit commands like `Q'."
996 (defcustom gnus-summary-update-hook nil
997 "*A hook called when a summary line is changed.
998 The hook will not be called if `gnus-visual' is nil.
1000 The default function `gnus-summary-highlight-line' will
1001 highlight the line according to the `gnus-summary-highlight'
1003 :group 'gnus-summary-visual
1006 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1007 "*A hook called when an article is selected for the first time.
1008 The hook is intended to mark an article as read (or unread)
1009 automatically when it is selected."
1010 :group 'gnus-summary-choose
1013 (defcustom gnus-group-no-more-groups-hook nil
1014 "*A hook run when returning to group mode having no more (unread) groups."
1015 :group 'gnus-group-select
1018 (defcustom gnus-ps-print-hook nil
1019 "*A hook run before ps-printing something from Gnus."
1020 :group 'gnus-summary
1023 (defcustom gnus-summary-article-move-hook nil
1024 "*A hook called after an article is moved, copied, respooled, or crossposted."
1026 :group 'gnus-summary
1029 (defcustom gnus-summary-article-delete-hook nil
1030 "*A hook called after an article is deleted."
1032 :group 'gnus-summary
1035 (defcustom gnus-summary-article-expire-hook nil
1036 "*A hook called after an article is expired."
1038 :group 'gnus-summary
1041 (defcustom gnus-summary-display-arrow
1042 (and (fboundp 'display-graphic-p)
1043 (display-graphic-p))
1044 "*If non-nil, display an arrow highlighting the current article."
1046 :group 'gnus-summary
1049 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1050 "Face used for highlighting the current article in the summary buffer."
1051 :group 'gnus-summary-visual
1054 (defvar gnus-tmp-downloaded nil)
1056 (defcustom gnus-summary-highlight
1057 '(((eq mark gnus-canceled-mark)
1058 . gnus-summary-cancelled)
1059 ((and uncached (> score default-high))
1060 . gnus-summary-high-undownloaded)
1061 ((and uncached (< score default-low))
1062 . gnus-summary-low-undownloaded)
1064 . gnus-summary-normal-undownloaded)
1065 ((and (> score default-high)
1066 (or (eq mark gnus-dormant-mark)
1067 (eq mark gnus-ticked-mark)))
1068 . gnus-summary-high-ticked)
1069 ((and (< score default-low)
1070 (or (eq mark gnus-dormant-mark)
1071 (eq mark gnus-ticked-mark)))
1072 . gnus-summary-low-ticked)
1073 ((or (eq mark gnus-dormant-mark)
1074 (eq mark gnus-ticked-mark))
1075 . gnus-summary-normal-ticked)
1076 ((and (> score default-high) (eq mark gnus-ancient-mark))
1077 . gnus-summary-high-ancient)
1078 ((and (< score default-low) (eq mark gnus-ancient-mark))
1079 . gnus-summary-low-ancient)
1080 ((eq mark gnus-ancient-mark)
1081 . gnus-summary-normal-ancient)
1082 ((and (> score default-high) (eq mark gnus-unread-mark))
1083 . gnus-summary-high-unread)
1084 ((and (< score default-low) (eq mark gnus-unread-mark))
1085 . gnus-summary-low-unread)
1086 ((eq mark gnus-unread-mark)
1087 . gnus-summary-normal-unread)
1088 ((> score default-high)
1089 . gnus-summary-high-read)
1090 ((< score default-low)
1091 . gnus-summary-low-read)
1093 . gnus-summary-normal-read))
1094 "*Controls the highlighting of summary buffer lines.
1096 A list of (FORM . FACE) pairs. When deciding how a particular
1097 summary line should be displayed, each form is evaluated. The content
1098 of the face field after the first true form is used. You can change
1099 how those summary lines are displayed, by editing the face field.
1101 You can use the following variables in the FORM field.
1103 score: The article's score.
1104 default: The default article score.
1105 default-high: The default score for high scored articles.
1106 default-low: The default score for low scored articles.
1107 below: The score below which articles are automatically marked as read.
1108 mark: The article's mark.
1109 uncached: Non-nil if the article is uncached."
1110 :group 'gnus-summary-visual
1111 :type '(repeat (cons (sexp :tag "Form" nil)
1113 (put 'gnus-summary-highlight 'risky-local-variable t)
1115 (defcustom gnus-alter-header-function nil
1116 "Function called to allow alteration of article header structures.
1117 The function is called with one parameter, the article header vector,
1118 which it may alter in any way."
1119 :type '(choice (const :tag "None" nil)
1121 :group 'gnus-summary)
1123 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1124 "Function used to decode a string with encoded words.")
1126 (defvar gnus-decode-encoded-address-function
1127 'mail-decode-encoded-address-string
1128 "Function used to decode addresses with encoded words.")
1130 (defcustom gnus-extra-headers '(To Newsgroups)
1131 "*Extra headers to parse."
1133 :group 'gnus-summary
1134 :type '(repeat symbol))
1136 (defcustom gnus-ignored-from-addresses
1137 (and user-mail-address
1138 (not (string= user-mail-address ""))
1139 (regexp-quote user-mail-address))
1140 "*From headers that may be suppressed in favor of To headers.
1141 This can be a regexp or a list of regexps."
1143 :group 'gnus-summary
1144 :type '(choice regexp
1145 (repeat :tag "Regexp List" regexp)))
1147 (defsubst gnus-ignored-from-addresses ()
1148 (gmm-regexp-concat gnus-ignored-from-addresses))
1150 (defcustom gnus-summary-to-prefix "-> "
1151 "*String prefixed to the To field in the summary line when
1152 using `gnus-ignored-from-addresses'."
1154 :group 'gnus-summary
1157 (defcustom gnus-summary-newsgroup-prefix "=> "
1158 "*String prefixed to the Newsgroup field in the summary
1159 line when using `gnus-ignored-from-addresses'."
1161 :group 'gnus-summary
1164 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1165 "List of charsets that should be ignored.
1166 When these charsets are used in the \"charset\" parameter, the
1167 default charset will be used instead."
1169 :type '(repeat symbol)
1170 :group 'gnus-charset)
1172 (defcustom gnus-newsgroup-maximum-articles nil
1173 "The maximum number of articles a newsgroup.
1174 If this is a number, old articles in a newsgroup exceeding this number
1175 are silently ignored. If it is nil, no article is ignored. Note that
1176 setting this variable to a number might prevent you from reading very
1178 :group 'gnus-group-select
1180 :type '(choice (const :tag "No limit" nil)
1183 (gnus-define-group-parameter
1187 "Return the ignored charsets of GROUP."
1188 :variable gnus-group-ignored-charsets-alist
1190 '(("alt\\.chinese\\.text" iso-8859-1))
1192 "Alist of regexps (to match group names) and charsets that should be ignored.
1193 When these charsets are used in the \"charset\" parameter, the
1194 default charset will be used instead."
1195 :variable-group gnus-charset
1196 :variable-type '(repeat (cons (regexp :tag "Group")
1198 :parameter-type '(choice :tag "Ignored charsets"
1201 :parameter-document "\
1202 List of charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead.")
1207 (defcustom gnus-group-highlight-words-alist nil
1208 "Alist of group regexps and highlight regexps.
1209 This variable uses the same syntax as `gnus-emphasis-alist'."
1211 :type '(repeat (cons (regexp :tag "Group")
1212 (repeat (list (regexp :tag "Highlight regexp")
1213 (number :tag "Group for entire word" 0)
1214 (number :tag "Group for displayed part" 0)
1216 gnus-emphasis-highlight-words)))))
1217 :group 'gnus-summary-visual)
1219 (defcustom gnus-summary-show-article-charset-alist
1221 "Alist of number and charset.
1222 The article will be shown with the charset corresponding to the
1224 For example: ((1 . cn-gb-2312) (2 . big5))."
1226 :type '(repeat (cons (number :tag "Argument" 1)
1227 (symbol :tag "Charset")))
1228 :group 'gnus-charset)
1230 (defcustom gnus-preserve-marks t
1231 "Whether marks are preserved when moving, copying and respooling messages."
1234 :group 'gnus-summary-marks)
1236 (defcustom gnus-propagate-marks t
1237 "If non-nil, do not propagate marks to the backends."
1238 :version "23.1" ;; No Gnus
1240 :group 'gnus-summary-marks)
1242 (defcustom gnus-alter-articles-to-read-function nil
1243 "Function to be called to alter the list of articles to be selected."
1244 :type '(choice (const nil) function)
1245 :group 'gnus-summary)
1247 (defcustom gnus-orphan-score nil
1248 "*All orphans get this score added. Set in the score file."
1249 :group 'gnus-score-default
1250 :type '(choice (const nil)
1253 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1254 "*A regexp to match MIME parts when saving multiple parts of a
1255 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1256 This regexp will be used by default when prompting the user for which
1257 type of files to save."
1258 :group 'gnus-summary
1261 (defcustom gnus-read-all-available-headers nil
1262 "Whether Gnus should parse all headers made available to it.
1263 This is mostly relevant for slow back ends where the user may
1264 wish to widen the summary buffer to include all headers
1267 :group 'gnus-summary
1268 :type '(choice boolean regexp))
1270 (defcustom gnus-summary-pipe-output-default-command nil
1271 "Command (and optional arguments) used to pipe article to subprocess.
1272 This will be used as the default command if it is non-nil. The value
1273 will be updated if you modify it when executing the command
1274 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1275 :version "23.1" ;; No Gnus
1276 :group 'gnus-summary
1277 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1279 (defcustom gnus-summary-muttprint-program "muttprint"
1280 "Command (and optional arguments) used to run Muttprint.
1281 The value will be updated if you modify it when executing the command
1282 `gnus-summary-muttprint'."
1284 :group 'gnus-summary
1287 (defcustom gnus-article-loose-mime t
1288 "If non-nil, don't require MIME-Version header.
1289 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1290 supply the MIME-Version header or deliberately strip it from the mail.
1291 If non-nil (the default), Gnus will treat some articles as MIME
1292 even if the MIME-Version header is missing."
1295 :group 'gnus-article-mime)
1297 (defcustom gnus-article-emulate-mime t
1298 "If non-nil, use MIME emulation for uuencode and the like.
1299 This means that Gnus will search message bodies for text that look
1300 like uuencoded bits, yEncoded bits, and so on, and present that using
1301 the normal Gnus MIME machinery."
1304 :group 'gnus-article-mime)
1306 ;;; Internal variables
1308 (defvar gnus-summary-display-cache nil)
1309 (defvar gnus-article-mime-handles nil)
1310 (defvar gnus-article-decoded-p nil)
1311 (defvar gnus-article-charset nil)
1312 (defvar gnus-article-ignored-charsets nil)
1313 (defvar gnus-scores-exclude-files nil)
1314 (defvar gnus-page-broken nil)
1316 (defvar gnus-original-article nil)
1317 (defvar gnus-article-internal-prepare-hook nil)
1318 (defvar gnus-newsgroup-process-stack nil)
1320 (defvar gnus-thread-indent-array nil)
1321 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1322 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1323 "Function called to sort the articles within a thread after it has been gathered together.")
1325 (defvar gnus-summary-save-parts-type-history nil)
1326 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1328 ;; Avoid highlighting in kill files.
1329 (defvar gnus-summary-inhibit-highlight nil)
1330 (defvar gnus-newsgroup-selected-overlay nil)
1331 (defvar gnus-inhibit-limiting nil)
1332 (defvar gnus-newsgroup-adaptive-score-file nil)
1333 (defvar gnus-current-score-file nil)
1334 (defvar gnus-current-move-group nil)
1335 (defvar gnus-current-copy-group nil)
1336 (defvar gnus-current-crosspost-group nil)
1337 (defvar gnus-newsgroup-display nil)
1339 (defvar gnus-newsgroup-dependencies nil)
1340 (defvar gnus-newsgroup-adaptive nil)
1341 (defvar gnus-summary-display-article-function nil)
1342 (defvar gnus-summary-highlight-line-function nil
1343 "Function called after highlighting a summary line.")
1345 (defvar gnus-summary-line-format-alist
1346 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1347 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1348 (?s gnus-tmp-subject-or-nil ?s)
1349 (?n gnus-tmp-name ?s)
1350 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1352 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1354 (?F gnus-tmp-from ?s)
1355 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1356 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1357 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1358 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1359 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1360 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1361 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1362 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1363 (?L gnus-tmp-lines ?s)
1364 (?O gnus-tmp-downloaded ?c)
1365 (?I gnus-tmp-indentation ?s)
1366 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1367 (?R gnus-tmp-replied ?c)
1368 (?\[ gnus-tmp-opening-bracket ?c)
1369 (?\] gnus-tmp-closing-bracket ?c)
1370 (?\> (make-string gnus-tmp-level ? ) ?s)
1371 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1372 (?i gnus-tmp-score ?d)
1373 (?z gnus-tmp-score-char ?c)
1374 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1375 (?U gnus-tmp-unread ?c)
1376 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1378 (?t (gnus-summary-number-of-articles-in-thread
1379 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1381 (?e (gnus-summary-number-of-articles-in-thread
1382 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1384 (?u gnus-tmp-user-defined ?s)
1385 (?P (gnus-pick-line-number) ?d)
1386 (?B gnus-tmp-thread-tree-header-string ?s)
1387 (user-date (gnus-user-date
1388 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1389 "An alist of format specifications that can appear in summary lines.
1390 These are paired with what variables they correspond with, along with
1391 the type of the variable (string, integer, character, etc).")
1393 (defvar gnus-summary-dummy-line-format-alist
1394 `((?S gnus-tmp-subject ?s)
1395 (?N gnus-tmp-number ?d)
1396 (?u gnus-tmp-user-defined ?s)))
1398 (defvar gnus-summary-mode-line-format-alist
1399 `((?G gnus-tmp-group-name ?s)
1400 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1401 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1402 (?A gnus-tmp-article-number ?d)
1403 (?Z gnus-tmp-unread-and-unselected ?s)
1404 (?V gnus-version ?s)
1405 (?U gnus-tmp-unread-and-unticked ?d)
1406 (?S gnus-tmp-subject ?s)
1407 (?e gnus-tmp-unselected ?d)
1408 (?u gnus-tmp-user-defined ?s)
1409 (?d (length gnus-newsgroup-dormant) ?d)
1410 (?t (length gnus-newsgroup-marked) ?d)
1411 (?h (length gnus-newsgroup-spam-marked) ?d)
1412 (?r (length gnus-newsgroup-reads) ?d)
1413 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1414 (?E gnus-newsgroup-expunged-tally ?d)
1415 (?s (gnus-current-score-file-nondirectory) ?s)))
1417 ;; This is here rather than in gnus-art for compilation reasons.
1418 (defvar gnus-article-mode-line-format-alist
1419 (nconc '((?w (gnus-article-wash-status) ?s)
1420 (?m (gnus-article-mime-part-status) ?s))
1421 gnus-summary-mode-line-format-alist))
1423 (defvar gnus-last-search-regexp nil
1424 "Default regexp for article search command.")
1426 (defvar gnus-last-shell-command nil
1427 "Default shell command on article.")
1429 (defvar gnus-newsgroup-agentized nil
1430 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1431 (defvar gnus-newsgroup-begin nil)
1432 (defvar gnus-newsgroup-end nil)
1433 (defvar gnus-newsgroup-last-rmail nil)
1434 (defvar gnus-newsgroup-last-mail nil)
1435 (defvar gnus-newsgroup-last-folder nil)
1436 (defvar gnus-newsgroup-last-file nil)
1437 (defvar gnus-newsgroup-last-directory nil)
1438 (defvar gnus-newsgroup-auto-expire nil)
1439 (defvar gnus-newsgroup-active nil)
1440 (defvar gnus-newsgroup-highest nil)
1442 (defvar gnus-newsgroup-data nil)
1443 (defvar gnus-newsgroup-data-reverse nil)
1444 (defvar gnus-newsgroup-limit nil)
1445 (defvar gnus-newsgroup-limits nil)
1446 (defvar gnus-summary-use-undownloaded-faces nil)
1448 (defvar gnus-newsgroup-unreads nil
1449 "Sorted list of unread articles in the current newsgroup.")
1451 (defvar gnus-newsgroup-unselected nil
1452 "Sorted list of unselected unread articles in the current newsgroup.")
1454 (defvar gnus-newsgroup-reads nil
1455 "Alist of read articles and article marks in the current newsgroup.")
1457 (defvar gnus-newsgroup-expunged-tally nil)
1459 (defvar gnus-newsgroup-marked nil
1460 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1462 (defvar gnus-newsgroup-spam-marked nil
1463 "List of ranges of articles that have been marked as spam.")
1465 (defvar gnus-newsgroup-killed nil
1466 "List of ranges of articles that have been through the scoring process.")
1468 (defvar gnus-newsgroup-cached nil
1469 "Sorted list of articles that come from the article cache.")
1471 (defvar gnus-newsgroup-saved nil
1472 "List of articles that have been saved.")
1474 (defvar gnus-newsgroup-kill-headers nil)
1476 (defvar gnus-newsgroup-replied nil
1477 "List of articles that have been replied to in the current newsgroup.")
1479 (defvar gnus-newsgroup-forwarded nil
1480 "List of articles that have been forwarded in the current newsgroup.")
1482 (defvar gnus-newsgroup-recent nil
1483 "List of articles that have are recent in the current newsgroup.")
1485 (defvar gnus-newsgroup-expirable nil
1486 "Sorted list of articles in the current newsgroup that can be expired.")
1488 (defvar gnus-newsgroup-processable nil
1489 "List of articles in the current newsgroup that can be processed.")
1491 (defvar gnus-newsgroup-downloadable nil
1492 "Sorted list of articles in the current newsgroup that can be processed.")
1494 (defvar gnus-newsgroup-unfetched nil
1495 "Sorted list of articles in the current newsgroup whose headers have
1496 not been fetched into the agent.
1498 This list will always be a subset of gnus-newsgroup-undownloaded.")
1500 (defvar gnus-newsgroup-undownloaded nil
1501 "List of articles in the current newsgroup that haven't been downloaded.")
1503 (defvar gnus-newsgroup-unsendable nil
1504 "List of articles in the current newsgroup that won't be sent.")
1506 (defvar gnus-newsgroup-bookmarks nil
1507 "List of articles in the current newsgroup that have bookmarks.")
1509 (defvar gnus-newsgroup-dormant nil
1510 "Sorted list of dormant articles in the current newsgroup.")
1512 (defvar gnus-newsgroup-unseen nil
1513 "List of unseen articles in the current newsgroup.")
1515 (defvar gnus-newsgroup-seen nil
1516 "Range of seen articles in the current newsgroup.")
1518 (defvar gnus-newsgroup-articles nil
1519 "List of articles in the current newsgroup.")
1521 (defvar gnus-newsgroup-scored nil
1522 "List of scored articles in the current newsgroup.")
1524 (defvar gnus-newsgroup-headers nil
1525 "List of article headers in the current newsgroup.")
1527 (defvar gnus-newsgroup-threads nil)
1529 (defvar gnus-newsgroup-prepared nil
1530 "Whether the current group has been prepared properly.")
1532 (defvar gnus-newsgroup-ancient nil
1533 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-sparse nil)
1537 (defvar gnus-current-article nil)
1538 (defvar gnus-article-current nil)
1539 (defvar gnus-current-headers nil)
1540 (defvar gnus-have-all-headers nil)
1541 (defvar gnus-last-article nil)
1542 (defvar gnus-newsgroup-history nil)
1543 (defvar gnus-newsgroup-charset nil)
1544 (defvar gnus-newsgroup-ephemeral-charset nil)
1545 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1547 (defvar gnus-article-before-search nil)
1549 (defvar gnus-summary-local-variables
1550 '(gnus-newsgroup-name
1553 gnus-newsgroup-unreads
1554 gnus-newsgroup-unselected
1555 gnus-newsgroup-marked
1556 gnus-newsgroup-spam-marked
1557 gnus-newsgroup-reads
1558 gnus-newsgroup-saved
1559 gnus-newsgroup-replied
1560 gnus-newsgroup-forwarded
1561 gnus-newsgroup-recent
1562 gnus-newsgroup-expirable
1563 gnus-newsgroup-killed
1564 gnus-newsgroup-unseen
1566 gnus-newsgroup-cached
1567 gnus-newsgroup-downloadable
1568 gnus-newsgroup-undownloaded
1569 gnus-newsgroup-unsendable
1571 gnus-newsgroup-begin gnus-newsgroup-end
1572 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1573 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1574 gnus-newsgroup-last-directory
1575 gnus-newsgroup-auto-expire
1576 gnus-newsgroup-processable
1577 gnus-newsgroup-unfetched
1578 gnus-newsgroup-articles
1579 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1580 gnus-newsgroup-headers gnus-newsgroup-threads
1581 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1582 gnus-current-article gnus-current-headers gnus-have-all-headers
1583 gnus-last-article gnus-article-internal-prepare-hook
1584 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1585 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1586 gnus-thread-expunge-below
1587 gnus-score-alist gnus-current-score-file
1588 (gnus-summary-expunge-below . global)
1589 (gnus-summary-mark-below . global)
1590 (gnus-orphan-score . global)
1591 gnus-newsgroup-active gnus-scores-exclude-files
1592 gnus-newsgroup-highest
1593 gnus-newsgroup-history gnus-newsgroup-ancient
1594 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1595 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1596 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1597 (gnus-newsgroup-expunged-tally . 0)
1598 gnus-cache-removable-articles
1599 gnus-newsgroup-data gnus-newsgroup-data-reverse
1600 gnus-newsgroup-limit gnus-newsgroup-limits
1601 gnus-newsgroup-charset gnus-newsgroup-display
1602 gnus-summary-use-undownloaded-faces)
1603 "Variables that are buffer-local to the summary buffers.")
1605 (defvar gnus-newsgroup-variables nil
1606 "A list of variables that have separate values in different newsgroups.
1607 A list of newsgroup (summary buffer) local variables, or cons of
1608 variables and their default expressions to be evalled (when the default
1609 values are not nil), that should be made global while the summary buffer
1612 Note: The default expressions will be evaluated (using function `eval')
1613 before assignment to the local variable rather than just assigned to it.
1614 If the default expression is the symbol `global', that symbol will not
1615 be evaluated but the global value of the local variable will be used
1618 These variables can be used to set variables in the group parameters
1619 while still allowing them to affect operations done in other buffers.
1622 \(setq gnus-newsgroup-variables
1623 '(message-use-followup-to
1624 (gnus-visible-headers .
1625 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1629 ;; Bind features so that require will believe that gnus-sum has
1630 ;; already been loaded (avoids infinite recursion)
1631 (let ((features (cons 'gnus-sum features)))
1632 (require 'gnus-art)))
1636 (defvar gnus-decode-encoded-word-methods
1637 '(mail-decode-encoded-word-string)
1638 "List of methods used to decode encoded words.
1640 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1641 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1642 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1643 whose names match REGEXP.
1646 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1647 mail-decode-encoded-word-string
1648 (\"chinese\" . rfc1843-decode-string))")
1650 (defvar gnus-decode-encoded-word-methods-cache nil)
1652 (defun gnus-multi-decode-encoded-word-string (string)
1653 "Apply the functions from `gnus-encoded-word-methods' that match."
1654 (unless (and gnus-decode-encoded-word-methods-cache
1655 (eq gnus-newsgroup-name
1656 (car gnus-decode-encoded-word-methods-cache)))
1657 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1658 (dolist (method gnus-decode-encoded-word-methods)
1659 (if (symbolp method)
1660 (nconc gnus-decode-encoded-word-methods-cache (list method))
1661 (if (and gnus-newsgroup-name
1662 (string-match (car method) gnus-newsgroup-name))
1663 (nconc gnus-decode-encoded-word-methods-cache
1664 (list (cdr method)))))))
1665 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1666 (setq string (funcall method string))))
1668 ;; Subject simplification.
1670 (defun gnus-simplify-whitespace (str)
1671 "Remove excessive whitespace from STR."
1673 (while (string-match "[ \t][ \t]+" str)
1674 (setq str (concat (substring str 0 (match-beginning 0))
1676 (substring str (match-end 0)))))
1678 (when (string-match "^[ \t]+" str)
1679 (setq str (substring str (match-end 0))))
1681 (when (string-match "[ \t]+$" str)
1682 (setq str (substring str 0 (match-beginning 0))))
1685 (defun gnus-simplify-all-whitespace (str)
1686 "Remove all whitespace from STR."
1687 (while (string-match "[ \t\n]+" str)
1688 (setq str (replace-match "" nil nil str)))
1691 (defsubst gnus-simplify-subject-re (subject)
1692 "Remove \"Re:\" from subject lines."
1693 (if (string-match message-subject-re-regexp subject)
1694 (substring subject (match-end 0))
1697 (defun gnus-simplify-subject (subject &optional re-only)
1698 "Remove `Re:' and words in parentheses.
1699 If RE-ONLY is non-nil, strip leading `Re:'s only."
1700 (let ((case-fold-search t)) ;Ignore case.
1701 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1702 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1703 (setq subject (substring subject (match-end 0))))
1704 ;; Remove uninteresting prefixes.
1705 (when (and (not re-only)
1706 gnus-simplify-ignored-prefixes
1707 (string-match gnus-simplify-ignored-prefixes subject))
1708 (setq subject (substring subject (match-end 0))))
1709 ;; Remove words in parentheses from end.
1711 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1712 (setq subject (substring subject 0 (match-beginning 0)))))
1713 ;; Return subject string.
1716 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1718 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1719 (goto-char (point-min))
1720 (while (re-search-forward regexp nil t)
1721 (replace-match (or newtext ""))))
1723 (defun gnus-simplify-buffer-fuzzy ()
1724 "Simplify string in the buffer fuzzily.
1725 The string in the accessible portion of the current buffer is simplified.
1726 It is assumed to be a single-line subject.
1727 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1728 matter is removed. Additional things can be deleted by setting
1729 `gnus-simplify-subject-fuzzy-regexp'."
1730 (let ((case-fold-search t)
1732 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1734 (while (not (eq modified-tick (buffer-modified-tick)))
1735 (setq modified-tick (buffer-modified-tick))
1737 ((listp gnus-simplify-subject-fuzzy-regexp)
1738 (mapc 'gnus-simplify-buffer-fuzzy-step
1739 gnus-simplify-subject-fuzzy-regexp))
1740 (gnus-simplify-subject-fuzzy-regexp
1741 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1742 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1743 (gnus-simplify-buffer-fuzzy-step
1744 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1745 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1747 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1748 (gnus-simplify-buffer-fuzzy-step " +" " ")
1749 (gnus-simplify-buffer-fuzzy-step " $")
1750 (gnus-simplify-buffer-fuzzy-step "^ +")))
1752 (defun gnus-simplify-subject-fuzzy (subject)
1753 "Simplify a subject string fuzzily.
1754 See `gnus-simplify-buffer-fuzzy' for details."
1756 (gnus-set-work-buffer)
1757 (let ((case-fold-search t))
1758 ;; Remove uninteresting prefixes.
1759 (when (and gnus-simplify-ignored-prefixes
1760 (string-match gnus-simplify-ignored-prefixes subject))
1761 (setq subject (substring subject (match-end 0))))
1763 (inline (gnus-simplify-buffer-fuzzy))
1766 (defsubst gnus-simplify-subject-fully (subject)
1767 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1769 (gnus-simplify-subject-functions
1770 (gnus-map-function gnus-simplify-subject-functions subject))
1771 ((null gnus-summary-gather-subject-limit)
1772 (gnus-simplify-subject-re subject))
1773 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1774 (gnus-simplify-subject-fuzzy subject))
1775 ((numberp gnus-summary-gather-subject-limit)
1776 (truncate-string-to-width (gnus-simplify-subject-re subject)
1777 gnus-summary-gather-subject-limit))
1781 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1782 "Check whether two subjects are equal.
1783 If optional argument SIMPLE-FIRST is t, first argument is already
1786 ((null simple-first)
1787 (equal (gnus-simplify-subject-fully s1)
1788 (gnus-simplify-subject-fully s2)))
1791 (gnus-simplify-subject-fully s2)))))
1793 (defun gnus-summary-bubble-group ()
1794 "Increase the score of the current group.
1795 This is a handy function to add to `gnus-summary-exit-hook' to
1796 increase the score of each group you read."
1797 (gnus-group-add-score gnus-newsgroup-name))
1801 ;;; Gnus summary mode
1804 (put 'gnus-summary-mode 'mode-class 'special)
1806 (defvar gnus-article-commands-menu)
1808 ;; Non-orthogonal keys
1810 (gnus-define-keys gnus-summary-mode-map
1811 " " gnus-summary-next-page
1812 "\177" gnus-summary-prev-page
1813 [delete] gnus-summary-prev-page
1814 [backspace] gnus-summary-prev-page
1815 "\r" gnus-summary-scroll-up
1816 "\M-\r" gnus-summary-scroll-down
1817 "n" gnus-summary-next-unread-article
1818 "p" gnus-summary-prev-unread-article
1819 "N" gnus-summary-next-article
1820 "P" gnus-summary-prev-article
1821 "\M-\C-n" gnus-summary-next-same-subject
1822 "\M-\C-p" gnus-summary-prev-same-subject
1823 "\M-n" gnus-summary-next-unread-subject
1824 "\M-p" gnus-summary-prev-unread-subject
1825 "." gnus-summary-first-unread-article
1826 "," gnus-summary-best-unread-article
1827 "\M-s" gnus-summary-search-article-forward
1828 "\M-r" gnus-summary-search-article-backward
1829 "\M-S" gnus-summary-repeat-search-article-forward
1830 "\M-R" gnus-summary-repeat-search-article-backward
1831 "<" gnus-summary-beginning-of-article
1832 ">" gnus-summary-end-of-article
1833 "j" gnus-summary-goto-article
1834 "^" gnus-summary-refer-parent-article
1835 "\M-^" gnus-summary-refer-article
1836 "u" gnus-summary-tick-article-forward
1837 "!" gnus-summary-tick-article-forward
1838 "U" gnus-summary-tick-article-backward
1839 "d" gnus-summary-mark-as-read-forward
1840 "D" gnus-summary-mark-as-read-backward
1841 "E" gnus-summary-mark-as-expirable
1842 "\M-u" gnus-summary-clear-mark-forward
1843 "\M-U" gnus-summary-clear-mark-backward
1844 "k" gnus-summary-kill-same-subject-and-select
1845 "\C-k" gnus-summary-kill-same-subject
1846 "\M-\C-k" gnus-summary-kill-thread
1847 "\M-\C-l" gnus-summary-lower-thread
1848 "e" gnus-summary-edit-article
1849 "#" gnus-summary-mark-as-processable
1850 "\M-#" gnus-summary-unmark-as-processable
1851 "\M-\C-t" gnus-summary-toggle-threads
1852 "\M-\C-s" gnus-summary-show-thread
1853 "\M-\C-h" gnus-summary-hide-thread
1854 "\M-\C-f" gnus-summary-next-thread
1855 "\M-\C-b" gnus-summary-prev-thread
1856 [(meta down)] gnus-summary-next-thread
1857 [(meta up)] gnus-summary-prev-thread
1858 "\M-\C-u" gnus-summary-up-thread
1859 "\M-\C-d" gnus-summary-down-thread
1860 "&" gnus-summary-execute-command
1861 "c" gnus-summary-catchup-and-exit
1862 "\C-w" gnus-summary-mark-region-as-read
1863 "\C-t" gnus-summary-toggle-truncation
1864 "?" gnus-summary-mark-as-dormant
1865 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1866 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1867 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1868 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1869 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1870 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1871 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1872 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1873 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1874 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1875 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1876 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1877 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1878 "=" gnus-summary-expand-window
1879 "\C-x\C-s" gnus-summary-reselect-current-group
1880 "\M-g" gnus-summary-rescan-group
1881 "\C-c\C-r" gnus-summary-caesar-message
1882 "f" gnus-summary-followup
1883 "F" gnus-summary-followup-with-original
1884 "C" gnus-summary-cancel-article
1885 "r" gnus-summary-reply
1886 "R" gnus-summary-reply-with-original
1887 "\C-c\C-f" gnus-summary-mail-forward
1888 "o" gnus-summary-save-article
1889 "\C-o" gnus-summary-save-article-mail
1890 "|" gnus-summary-pipe-output
1891 "\M-k" gnus-summary-edit-local-kill
1892 "\M-K" gnus-summary-edit-global-kill
1894 "\C-c\C-d" gnus-summary-describe-group
1895 "q" gnus-summary-exit
1896 "Q" gnus-summary-exit-no-update
1897 "\C-c\C-i" gnus-info-find-node
1898 gnus-mouse-2 gnus-mouse-pick-article
1899 [follow-link] mouse-face
1900 "m" gnus-summary-mail-other-window
1901 "a" gnus-summary-post-news
1902 "x" gnus-summary-limit-to-unread
1903 "s" gnus-summary-isearch-article
1904 "t" gnus-summary-toggle-header
1905 "g" gnus-summary-show-article
1906 "l" gnus-summary-goto-last-article
1907 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1908 "\C-d" gnus-summary-enter-digest-group
1909 "\M-\C-d" gnus-summary-read-document
1910 "\M-\C-e" gnus-summary-edit-parameters
1911 "\M-\C-a" gnus-summary-customize-parameters
1913 "*" gnus-cache-enter-article
1914 "\M-*" gnus-cache-remove-article
1915 "\M-&" gnus-summary-universal-argument
1916 "\C-l" gnus-recenter
1917 "I" gnus-summary-increase-score
1918 "L" gnus-summary-lower-score
1919 "\M-i" gnus-symbolic-argument
1920 "h" gnus-summary-select-article-buffer
1922 "b" gnus-article-view-part
1923 "\M-t" gnus-summary-toggle-display-buttonized
1925 "V" gnus-summary-score-map
1926 "X" gnus-uu-extract-map
1927 "S" gnus-summary-send-map)
1929 ;; Sort of orthogonal keymap
1930 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1931 "t" gnus-summary-tick-article-forward
1932 "!" gnus-summary-tick-article-forward
1933 "d" gnus-summary-mark-as-read-forward
1934 "r" gnus-summary-mark-as-read-forward
1935 "c" gnus-summary-clear-mark-forward
1936 " " gnus-summary-clear-mark-forward
1937 "e" gnus-summary-mark-as-expirable
1938 "x" gnus-summary-mark-as-expirable
1939 "?" gnus-summary-mark-as-dormant
1940 "b" gnus-summary-set-bookmark
1941 "B" gnus-summary-remove-bookmark
1942 "#" gnus-summary-mark-as-processable
1943 "\M-#" gnus-summary-unmark-as-processable
1944 "S" gnus-summary-limit-include-expunged
1945 "C" gnus-summary-catchup
1946 "H" gnus-summary-catchup-to-here
1947 "h" gnus-summary-catchup-from-here
1948 "\C-c" gnus-summary-catchup-all
1949 "k" gnus-summary-kill-same-subject-and-select
1950 "K" gnus-summary-kill-same-subject
1951 "P" gnus-uu-mark-map)
1953 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1954 "c" gnus-summary-clear-above
1955 "u" gnus-summary-tick-above
1956 "m" gnus-summary-mark-above
1957 "k" gnus-summary-kill-below)
1959 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1960 "/" gnus-summary-limit-to-subject
1961 "n" gnus-summary-limit-to-articles
1962 "b" gnus-summary-limit-to-bodies
1963 "h" gnus-summary-limit-to-headers
1964 "w" gnus-summary-pop-limit
1965 "s" gnus-summary-limit-to-subject
1966 "a" gnus-summary-limit-to-author
1967 "u" gnus-summary-limit-to-unread
1968 "m" gnus-summary-limit-to-marks
1969 "M" gnus-summary-limit-exclude-marks
1970 "v" gnus-summary-limit-to-score
1971 "*" gnus-summary-limit-include-cached
1972 "D" gnus-summary-limit-include-dormant
1973 "T" gnus-summary-limit-include-thread
1974 "d" gnus-summary-limit-exclude-dormant
1975 "t" gnus-summary-limit-to-age
1976 "." gnus-summary-limit-to-unseen
1977 "x" gnus-summary-limit-to-extra
1978 "p" gnus-summary-limit-to-display-predicate
1979 "E" gnus-summary-limit-include-expunged
1980 "c" gnus-summary-limit-exclude-childless-dormant
1981 "C" gnus-summary-limit-mark-excluded-as-read
1982 "o" gnus-summary-insert-old-articles
1983 "N" gnus-summary-insert-new-articles
1984 "S" gnus-summary-limit-to-singletons
1985 "r" gnus-summary-limit-to-replied
1986 "R" gnus-summary-limit-to-recipient
1987 "A" gnus-summary-limit-to-address)
1989 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1990 "n" gnus-summary-next-unread-article
1991 "p" gnus-summary-prev-unread-article
1992 "N" gnus-summary-next-article
1993 "P" gnus-summary-prev-article
1994 "\C-n" gnus-summary-next-same-subject
1995 "\C-p" gnus-summary-prev-same-subject
1996 "\M-n" gnus-summary-next-unread-subject
1997 "\M-p" gnus-summary-prev-unread-subject
1998 "f" gnus-summary-first-unread-article
1999 "b" gnus-summary-best-unread-article
2000 "j" gnus-summary-goto-article
2001 "g" gnus-summary-goto-subject
2002 "l" gnus-summary-goto-last-article
2003 "o" gnus-summary-pop-article)
2005 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2006 "k" gnus-summary-kill-thread
2007 "E" gnus-summary-expire-thread
2008 "l" gnus-summary-lower-thread
2009 "i" gnus-summary-raise-thread
2010 "T" gnus-summary-toggle-threads
2011 "t" gnus-summary-rethread-current
2012 "^" gnus-summary-reparent-thread
2013 "\M-^" gnus-summary-reparent-children
2014 "s" gnus-summary-show-thread
2015 "S" gnus-summary-show-all-threads
2016 "h" gnus-summary-hide-thread
2017 "H" gnus-summary-hide-all-threads
2018 "n" gnus-summary-next-thread
2019 "p" gnus-summary-prev-thread
2020 "u" gnus-summary-up-thread
2021 "o" gnus-summary-top-thread
2022 "d" gnus-summary-down-thread
2023 "#" gnus-uu-mark-thread
2024 "\M-#" gnus-uu-unmark-thread)
2026 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2027 "g" gnus-summary-prepare
2028 "c" gnus-summary-insert-cached-articles
2029 "d" gnus-summary-insert-dormant-articles
2030 "t" gnus-summary-insert-ticked-articles)
2032 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2033 "c" gnus-summary-catchup-and-exit
2034 "C" gnus-summary-catchup-all-and-exit
2035 "E" gnus-summary-exit-no-update
2036 "Q" gnus-summary-exit
2037 "Z" gnus-summary-exit
2038 "n" gnus-summary-catchup-and-goto-next-group
2039 "p" gnus-summary-catchup-and-goto-prev-group
2040 "R" gnus-summary-reselect-current-group
2041 "G" gnus-summary-rescan-group
2042 "N" gnus-summary-next-group
2043 "s" gnus-summary-save-newsrc
2044 "P" gnus-summary-prev-group)
2046 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2047 " " gnus-summary-next-page
2048 "n" gnus-summary-next-page
2049 "\177" gnus-summary-prev-page
2050 [delete] gnus-summary-prev-page
2051 "p" gnus-summary-prev-page
2052 "\r" gnus-summary-scroll-up
2053 "\M-\r" gnus-summary-scroll-down
2054 "<" gnus-summary-beginning-of-article
2055 ">" gnus-summary-end-of-article
2056 "b" gnus-summary-beginning-of-article
2057 "e" gnus-summary-end-of-article
2058 "^" gnus-summary-refer-parent-article
2059 "r" gnus-summary-refer-parent-article
2060 "C" gnus-summary-show-complete-article
2061 "D" gnus-summary-enter-digest-group
2062 "R" gnus-summary-refer-references
2063 "T" gnus-summary-refer-thread
2064 "g" gnus-summary-show-article
2065 "s" gnus-summary-isearch-article
2066 "P" gnus-summary-print-article
2067 "S" gnus-sticky-article
2068 "M" gnus-mailing-list-insinuate
2069 "t" gnus-article-babel)
2071 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2072 "b" gnus-article-add-buttons
2073 "B" gnus-article-add-buttons-to-head
2074 "o" gnus-article-treat-overstrike
2075 "e" gnus-article-emphasize
2076 "w" gnus-article-fill-cited-article
2077 "Q" gnus-article-fill-long-lines
2078 "L" gnus-article-toggle-truncate-lines
2079 "C" gnus-article-capitalize-sentences
2080 "c" gnus-article-remove-cr
2081 "q" gnus-article-de-quoted-unreadable
2082 "6" gnus-article-de-base64-unreadable
2083 "Z" gnus-article-decode-HZ
2084 "A" gnus-article-treat-ansi-sequences
2085 "h" gnus-article-wash-html
2086 "u" gnus-article-unsplit-urls
2087 "s" gnus-summary-force-verify-and-decrypt
2088 "f" gnus-article-display-x-face
2089 "l" gnus-summary-stop-page-breaking
2090 "r" gnus-summary-caesar-message
2091 "m" gnus-summary-morse-message
2092 "t" gnus-summary-toggle-header
2093 "g" gnus-treat-smiley
2094 "v" gnus-summary-verbose-headers
2095 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2096 "p" gnus-article-verify-x-pgp-sig
2097 "d" gnus-article-treat-dumbquotes
2098 "i" gnus-summary-idna-message)
2100 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2101 ;; mnemonic: deuglif*Y*
2102 "u" gnus-article-outlook-unwrap-lines
2103 "a" gnus-article-outlook-repair-attribution
2104 "c" gnus-article-outlook-rearrange-citation
2105 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2107 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2108 "a" gnus-article-hide
2109 "h" gnus-article-hide-headers
2110 "b" gnus-article-hide-boring-headers
2111 "s" gnus-article-hide-signature
2112 "c" gnus-article-hide-citation
2113 "C" gnus-article-hide-citation-in-followups
2114 "l" gnus-article-hide-list-identifiers
2115 "B" gnus-article-strip-banner
2116 "P" gnus-article-hide-pem
2117 "\C-c" gnus-article-hide-citation-maybe)
2119 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2120 "a" gnus-article-highlight
2121 "h" gnus-article-highlight-headers
2122 "c" gnus-article-highlight-citation
2123 "s" gnus-article-highlight-signature)
2125 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2126 "f" gnus-article-treat-fold-headers
2127 "u" gnus-article-treat-unfold-headers
2128 "n" gnus-article-treat-fold-newsgroups)
2130 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2131 "x" gnus-article-display-x-face
2132 "d" gnus-article-display-face
2133 "s" gnus-treat-smiley
2134 "D" gnus-article-remove-images
2135 "W" gnus-html-show-images
2136 "f" gnus-treat-from-picon
2137 "m" gnus-treat-mail-picon
2138 "n" gnus-treat-newsgroups-picon
2139 "g" gnus-treat-from-gravatar
2140 "h" gnus-treat-mail-gravatar)
2142 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2143 "w" gnus-article-decode-mime-words
2144 "c" gnus-article-decode-charset
2145 "v" gnus-mime-view-all-parts
2146 "b" gnus-article-view-part)
2148 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2149 "z" gnus-article-date-ut
2150 "u" gnus-article-date-ut
2151 "l" gnus-article-date-local
2152 "p" gnus-article-date-english
2153 "e" gnus-article-date-lapsed
2154 "o" gnus-article-date-original
2155 "i" gnus-article-date-iso8601
2156 "s" gnus-article-date-user)
2158 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2159 "t" gnus-article-remove-trailing-blank-lines
2160 "l" gnus-article-strip-leading-blank-lines
2161 "m" gnus-article-strip-multiple-blank-lines
2162 "a" gnus-article-strip-blank-lines
2163 "A" gnus-article-strip-all-blank-lines
2164 "s" gnus-article-strip-leading-space
2165 "e" gnus-article-strip-trailing-space
2166 "w" gnus-article-remove-leading-whitespace)
2168 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2170 "d" gnus-summary-describe-group
2171 "h" gnus-summary-describe-briefly
2172 "i" gnus-info-find-node)
2174 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2175 "e" gnus-summary-expire-articles
2176 "\M-\C-e" gnus-summary-expire-articles-now
2177 "\177" gnus-summary-delete-article
2178 [delete] gnus-summary-delete-article
2179 [backspace] gnus-summary-delete-article
2180 "m" gnus-summary-move-article
2181 "r" gnus-summary-respool-article
2182 "w" gnus-summary-edit-article
2183 "c" gnus-summary-copy-article
2184 "B" gnus-summary-crosspost-article
2185 "q" gnus-summary-respool-query
2186 "t" gnus-summary-respool-trace
2187 "i" gnus-summary-import-article
2188 "I" gnus-summary-create-article
2189 "p" gnus-summary-article-posted-p)
2191 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2192 "o" gnus-summary-save-article
2193 "m" gnus-summary-save-article-mail
2194 "F" gnus-summary-write-article-file
2195 "r" gnus-summary-save-article-rmail
2196 "f" gnus-summary-save-article-file
2197 "b" gnus-summary-save-article-body-file
2198 "B" gnus-summary-write-article-body-file
2199 "h" gnus-summary-save-article-folder
2200 "v" gnus-summary-save-article-vm
2201 "p" gnus-summary-pipe-output
2202 "P" gnus-summary-muttprint)
2204 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2205 "b" gnus-summary-display-buttonized
2206 "m" gnus-summary-repair-multipart
2207 "v" gnus-article-view-part
2208 "o" gnus-article-save-part
2209 "O" gnus-article-save-part-and-strip
2210 "r" gnus-article-replace-part
2211 "d" gnus-article-delete-part
2212 "t" gnus-article-view-part-as-type
2213 "j" gnus-article-jump-to-part
2214 "c" gnus-article-copy-part
2215 "C" gnus-article-view-part-as-charset
2216 "e" gnus-article-view-part-externally
2217 "H" gnus-article-browse-html-article
2218 "E" gnus-article-encrypt-body
2219 "i" gnus-article-inline-part
2220 "|" gnus-article-pipe-part)
2222 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2223 "p" gnus-summary-mark-as-processable
2224 "u" gnus-summary-unmark-as-processable
2225 "U" gnus-summary-unmark-all-processable
2226 "v" gnus-uu-mark-over
2227 "s" gnus-uu-mark-series
2228 "r" gnus-uu-mark-region
2229 "g" gnus-uu-unmark-region
2230 "R" gnus-uu-mark-by-regexp
2231 "G" gnus-uu-unmark-by-regexp
2232 "t" gnus-uu-mark-thread
2233 "T" gnus-uu-unmark-thread
2234 "a" gnus-uu-mark-all
2235 "b" gnus-uu-mark-buffer
2236 "S" gnus-uu-mark-sparse
2237 "k" gnus-summary-kill-process-mark
2238 "y" gnus-summary-yank-process-mark
2239 "w" gnus-summary-save-process-mark
2240 "i" gnus-uu-invert-processable)
2242 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2243 ;;"x" gnus-uu-extract-any
2244 "m" gnus-summary-save-parts
2245 "u" gnus-uu-decode-uu
2246 "U" gnus-uu-decode-uu-and-save
2247 "s" gnus-uu-decode-unshar
2248 "S" gnus-uu-decode-unshar-and-save
2249 "o" gnus-uu-decode-save
2250 "O" gnus-uu-decode-save
2251 "b" gnus-uu-decode-binhex
2252 "B" gnus-uu-decode-binhex
2253 "Y" gnus-uu-decode-yenc
2254 "p" gnus-uu-decode-postscript
2255 "P" gnus-uu-decode-postscript-and-save)
2258 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2259 "u" gnus-uu-decode-uu-view
2260 "U" gnus-uu-decode-uu-and-save-view
2261 "s" gnus-uu-decode-unshar-view
2262 "S" gnus-uu-decode-unshar-and-save-view
2263 "o" gnus-uu-decode-save-view
2264 "O" gnus-uu-decode-save-view
2265 "b" gnus-uu-decode-binhex-view
2266 "B" gnus-uu-decode-binhex-view
2267 "p" gnus-uu-decode-postscript-view
2268 "P" gnus-uu-decode-postscript-and-save-view)
2270 (defvar gnus-article-post-menu nil)
2272 (defconst gnus-summary-menu-maxlen 20)
2274 (defun gnus-summary-menu-split (menu)
2275 ;; If we have lots of elements, divide them into groups of 20
2276 ;; and make a pane (or submenu) for each one.
2277 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2278 (let ((menu menu) sublists next
2281 ;; Pull off the next gnus-summary-menu-maxlen elements
2282 ;; and make them the next element of sublist.
2283 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2285 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2287 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2288 (aref (car (last menu)) 0)) menu)
2292 (nreverse sublists))
2293 ;; Few elements--put them all in one pane.
2296 (defun gnus-summary-make-menu-bar ()
2297 (gnus-turn-off-edit-menu 'summary)
2299 (unless (boundp 'gnus-summary-misc-menu)
2302 gnus-summary-kill-menu gnus-summary-mode-map ""
2307 ["Customize" gnus-score-customize t])
2308 (gnus-make-score-map 'increase)
2309 (gnus-make-score-map 'lower)
2311 ["Kill below" gnus-summary-kill-below t]
2312 ["Mark above" gnus-summary-mark-above t]
2313 ["Tick above" gnus-summary-tick-above t]
2314 ["Clear above" gnus-summary-clear-above t])
2315 ["Current score" gnus-summary-current-score t]
2316 ["Set score" gnus-summary-set-score t]
2317 ["Switch current score file..." gnus-score-change-score-file t]
2318 ["Set mark below..." gnus-score-set-mark-below t]
2319 ["Set expunge below..." gnus-score-set-expunge-below t]
2320 ["Edit current score file" gnus-score-edit-current-scores t]
2321 ["Edit score file..." gnus-score-edit-file t]
2322 ["Trace score" gnus-score-find-trace t]
2323 ["Find words" gnus-score-find-favourite-words t]
2324 ["Rescore buffer" gnus-summary-rescore t]
2325 ["Increase score..." gnus-summary-increase-score t]
2326 ["Lower score..." gnus-summary-lower-score t]))))
2328 ;; Define both the Article menu in the summary buffer and the
2329 ;; equivalent Commands menu in the article buffer here for
2333 ["All" gnus-article-hide t]
2334 ["Headers" gnus-article-hide-headers t]
2335 ["Signature" gnus-article-hide-signature t]
2336 ["Citation" gnus-article-hide-citation t]
2337 ["List identifiers" gnus-article-hide-list-identifiers t]
2338 ["Banner" gnus-article-strip-banner t]
2339 ["Boring headers" gnus-article-hide-boring-headers t])
2341 ["All" gnus-article-highlight t]
2342 ["Headers" gnus-article-highlight-headers t]
2343 ["Signature" gnus-article-highlight-signature t]
2344 ["Citation" gnus-article-highlight-citation t])
2346 ["Words" gnus-article-decode-mime-words t]
2347 ["Charset" gnus-article-decode-charset t]
2348 ["QP" gnus-article-de-quoted-unreadable t]
2349 ["Base64" gnus-article-de-base64-unreadable t]
2350 ["View MIME buttons" gnus-summary-display-buttonized t]
2351 ["View all" gnus-mime-view-all-parts t]
2352 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2353 ["Encrypt body" gnus-article-encrypt-body
2354 :active (not (gnus-group-read-only-p))
2355 ,@(if (featurep 'xemacs) nil
2356 '(:help "Encrypt the message body on disk"))]
2357 ["Extract all parts..." gnus-summary-save-parts t]
2359 ["Repair multipart" gnus-summary-repair-multipart t]
2360 ["Pipe part..." gnus-article-pipe-part t]
2361 ["Inline part" gnus-article-inline-part t]
2362 ["View part as type..." gnus-article-view-part-as-type t]
2363 ["Encrypt body" gnus-article-encrypt-body
2364 :active (not (gnus-group-read-only-p))
2365 ,@(if (featurep 'xemacs) nil
2366 '(:help "Encrypt the message body on disk"))]
2367 ["View part externally" gnus-article-view-part-externally t]
2368 ["View HTML parts in browser" gnus-article-browse-html-article t]
2369 ["View part with charset..." gnus-article-view-part-as-charset t]
2370 ["Copy part" gnus-article-copy-part t]
2371 ["Save part..." gnus-article-save-part t]
2372 ["View part" gnus-article-view-part t]))
2374 ["Local" gnus-article-date-local t]
2375 ["ISO8601" gnus-article-date-iso8601 t]
2376 ["UT" gnus-article-date-ut t]
2377 ["Original" gnus-article-date-original t]
2378 ["Lapsed" gnus-article-date-lapsed t]
2379 ["User-defined" gnus-article-date-user t])
2381 ["Remove images" gnus-article-remove-images t]
2382 ["Toggle smiley" gnus-treat-smiley t]
2383 ["Show X-Face" gnus-article-display-x-face t]
2384 ["Show picons in From" gnus-treat-from-picon t]
2385 ["Show picons in mail headers" gnus-treat-mail-picon t]
2386 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2387 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2388 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2389 ("View as different encoding"
2390 ,@(gnus-summary-menu-split
2393 ;; Since easymenu under Emacs doesn't allow
2394 ;; lambda forms for menu commands, we should
2395 ;; provide intern'ed function symbols.
2396 (let ((command (intern (format "\
2397 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2401 (let ((gnus-summary-show-article-charset-alist
2403 (gnus-summary-show-article 1))))
2404 `[,(symbol-name cs) ,command t]))
2405 (sort (if (fboundp 'coding-system-list)
2406 (coding-system-list)
2407 (mapcar 'car mm-mime-mule-charset-alist))
2411 ["Leading" gnus-article-strip-leading-blank-lines t]
2412 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2413 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2414 ["All of the above" gnus-article-strip-blank-lines t]
2415 ["All" gnus-article-strip-all-blank-lines t]
2416 ["Leading space" gnus-article-strip-leading-space t]
2417 ["Trailing space" gnus-article-strip-trailing-space t]
2418 ["Leading space in headers"
2419 gnus-article-remove-leading-whitespace t])
2420 ["Overstrike" gnus-article-treat-overstrike t]
2421 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2422 ["Emphasis" gnus-article-emphasize t]
2423 ["Word wrap" gnus-article-fill-cited-article t]
2424 ["Fill long lines" gnus-article-fill-long-lines t]
2425 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2426 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2427 ["Remove CR" gnus-article-remove-cr t]
2428 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2429 ["Base64" gnus-article-de-base64-unreadable t]
2430 ["Rot 13" gnus-summary-caesar-message
2431 ,@(if (featurep 'xemacs) '(t)
2432 '(:help "\"Caesar rotate\" article by 13"))]
2433 ["De-IDNA" gnus-summary-idna-message t]
2434 ["Morse decode" gnus-summary-morse-message t]
2435 ["Unix pipe..." gnus-summary-pipe-message t]
2436 ["Add buttons" gnus-article-add-buttons t]
2437 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2438 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2439 ["Verbose header" gnus-summary-verbose-headers t]
2440 ["Toggle header" gnus-summary-toggle-header t]
2441 ["Unfold headers" gnus-article-treat-unfold-headers t]
2442 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2443 ["Html" gnus-article-wash-html t]
2444 ["Unsplit URLs" gnus-article-unsplit-urls t]
2445 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2446 ["Decode HZ" gnus-article-decode-HZ t]
2447 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2448 ("(Outlook) Deuglify"
2449 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2450 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2451 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2452 ["Full (Outlook) deuglify"
2453 gnus-article-outlook-deuglify-article t])
2456 ["Save in default format..." gnus-summary-save-article
2457 ,@(if (featurep 'xemacs) '(t)
2458 '(:help "Save article using default method"))]
2459 ["Save in file..." gnus-summary-save-article-file
2460 ,@(if (featurep 'xemacs) '(t)
2461 '(:help "Save article in file"))]
2462 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2463 ["Save in MH folder..." gnus-summary-save-article-folder t]
2464 ["Save in VM folder..." gnus-summary-save-article-vm t]
2465 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2466 ["Save body in file..." gnus-summary-save-article-body-file t]
2467 ["Pipe through a filter..." gnus-summary-pipe-output t]
2468 ["Print with Muttprint..." gnus-summary-muttprint t]
2469 ["Print" gnus-summary-print-article
2470 ,@(if (featurep 'xemacs) '(t)
2471 '(:help "Generate and print a PostScript image"))])
2472 ("Copy, move,... (Backend)"
2473 ,@(if (featurep 'xemacs) nil
2474 '(:help "Copying, moving, expiring articles..."))
2475 ["Respool article..." gnus-summary-respool-article t]
2476 ["Move article..." gnus-summary-move-article
2477 (gnus-check-backend-function
2478 'request-move-article gnus-newsgroup-name)]
2479 ["Copy article..." gnus-summary-copy-article t]
2480 ["Crosspost article..." gnus-summary-crosspost-article
2481 (gnus-check-backend-function
2482 'request-replace-article gnus-newsgroup-name)]
2483 ["Import file..." gnus-summary-import-article
2484 (gnus-check-backend-function
2485 'request-accept-article gnus-newsgroup-name)]
2486 ["Create article..." gnus-summary-create-article
2487 (gnus-check-backend-function
2488 'request-accept-article gnus-newsgroup-name)]
2489 ["Check if posted" gnus-summary-article-posted-p t]
2490 ["Edit article" gnus-summary-edit-article
2491 (not (gnus-group-read-only-p))]
2492 ["Delete article" gnus-summary-delete-article
2493 (gnus-check-backend-function
2494 'request-expire-articles gnus-newsgroup-name)]
2495 ["Query respool" gnus-summary-respool-query t]
2496 ["Trace respool" gnus-summary-respool-trace t]
2497 ["Delete expirable articles" gnus-summary-expire-articles-now
2498 (gnus-check-backend-function
2499 'request-expire-articles gnus-newsgroup-name)])
2501 ["Uudecode" gnus-uu-decode-uu
2502 ,@(if (featurep 'xemacs) '(t)
2503 '(:help "Decode uuencoded article(s)"))]
2504 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2505 ["Unshar" gnus-uu-decode-unshar t]
2506 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2507 ["Save" gnus-uu-decode-save t]
2508 ["Binhex" gnus-uu-decode-binhex t]
2509 ["Postscript" gnus-uu-decode-postscript t]
2510 ["All MIME parts" gnus-summary-save-parts t])
2512 ["Enter article" gnus-cache-enter-article t]
2513 ["Remove article" gnus-cache-remove-article t])
2514 ["Translate" gnus-article-babel t]
2515 ["Select article buffer" gnus-summary-select-article-buffer t]
2516 ["Make article buffer sticky" gnus-sticky-article t]
2517 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2518 ["Isearch article..." gnus-summary-isearch-article t]
2519 ["Beginning of the article" gnus-summary-beginning-of-article t]
2520 ["End of the article" gnus-summary-end-of-article t]
2521 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2522 ["Fetch referenced articles" gnus-summary-refer-references t]
2523 ["Fetch current thread" gnus-summary-refer-thread t]
2524 ["Fetch article with id..." gnus-summary-refer-article t]
2525 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2526 ["Redisplay" gnus-summary-show-article t]
2527 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2529 gnus-summary-article-menu gnus-summary-mode-map ""
2530 (cons "Article" innards))
2532 (if (not (keymapp gnus-summary-article-menu))
2534 gnus-article-commands-menu gnus-article-mode-map ""
2535 (cons "Commands" innards))
2536 ;; in Emacs, don't share menu.
2537 (setq gnus-article-commands-menu
2538 (copy-keymap gnus-summary-article-menu))
2539 (define-key gnus-article-mode-map [menu-bar commands]
2540 (cons "Commands" gnus-article-commands-menu))))
2543 gnus-summary-thread-menu gnus-summary-mode-map ""
2545 ["Find all messages in thread" gnus-summary-refer-thread t]
2546 ["Toggle threading" gnus-summary-toggle-threads t]
2547 ["Hide threads" gnus-summary-hide-all-threads t]
2548 ["Show threads" gnus-summary-show-all-threads t]
2549 ["Hide thread" gnus-summary-hide-thread t]
2550 ["Show thread" gnus-summary-show-thread t]
2551 ["Go to next thread" gnus-summary-next-thread t]
2552 ["Go to previous thread" gnus-summary-prev-thread t]
2553 ["Go down thread" gnus-summary-down-thread t]
2554 ["Go up thread" gnus-summary-up-thread t]
2555 ["Top of thread" gnus-summary-top-thread t]
2556 ["Mark thread as read" gnus-summary-kill-thread t]
2557 ["Mark thread as expired" gnus-summary-expire-thread t]
2558 ["Lower thread score" gnus-summary-lower-thread t]
2559 ["Raise thread score" gnus-summary-raise-thread t]
2560 ["Rethread current" gnus-summary-rethread-current t]))
2563 gnus-summary-post-menu gnus-summary-mode-map ""
2565 ["Send a message (mail or news)" gnus-summary-post-news
2566 ,@(if (featurep 'xemacs) '(t)
2567 '(:help "Compose a new message (mail or news)"))]
2568 ["Followup" gnus-summary-followup
2569 ,@(if (featurep 'xemacs) '(t)
2570 '(:help "Post followup to this article"))]
2571 ["Followup and yank" gnus-summary-followup-with-original
2572 ,@(if (featurep 'xemacs) '(t)
2573 '(:help "Post followup to this article, quoting its contents"))]
2574 ["Supersede article" gnus-summary-supersede-article t]
2575 ["Cancel article" gnus-summary-cancel-article
2576 ,@(if (featurep 'xemacs) '(t)
2577 '(:help "Cancel an article you posted"))]
2578 ["Reply" gnus-summary-reply t]
2579 ["Reply and yank" gnus-summary-reply-with-original t]
2580 ["Wide reply" gnus-summary-wide-reply t]
2581 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2582 ,@(if (featurep 'xemacs) '(t)
2583 '(:help "Mail a reply, quoting this article"))]
2584 ["Very wide reply" gnus-summary-very-wide-reply t]
2585 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Mail a very wide reply, quoting this article"))]
2588 ["Mail forward" gnus-summary-mail-forward t]
2589 ["Post forward" gnus-summary-post-forward t]
2590 ["Digest and mail" gnus-uu-digest-mail-forward t]
2591 ["Digest and post" gnus-uu-digest-post-forward t]
2592 ["Resend message" gnus-summary-resend-message t]
2593 ["Resend message edit" gnus-summary-resend-message-edit t]
2594 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2595 ["Send a mail" gnus-summary-mail-other-window t]
2596 ["Create a local message" gnus-summary-news-other-window t]
2597 ["Uuencode and post" gnus-uu-post-news
2598 ,@(if (featurep 'xemacs) '(t)
2599 '(:help "Post a uuencoded article"))]
2600 ["Followup via news" gnus-summary-followup-to-mail t]
2601 ["Followup via news and yank"
2602 gnus-summary-followup-to-mail-with-original t]
2603 ["Strip signature on reply"
2606 (if (not (memq message-cite-function
2607 '(message-cite-original-without-signature
2608 message-cite-original)))
2609 ;; Stupid workaround for XEmacs not honoring :visible.
2610 (message "Can't toggle this value of `message-cite-function'")
2611 (setq message-cite-function
2612 (if (eq message-cite-function
2613 'message-cite-original-without-signature)
2614 'message-cite-original
2615 'message-cite-original-without-signature))))
2616 ;; XEmacs barfs on :visible.
2617 ,@(if (featurep 'xemacs) nil
2618 '(:visible (memq message-cite-function
2619 '(message-cite-original-without-signature
2620 message-cite-original))))
2622 :selected (eq message-cite-function
2623 'message-cite-original-without-signature)
2624 ,@(if (featurep 'xemacs) nil
2625 '(:help "Strip signature from cited article when replying."))]
2627 ;;["Send" gnus-summary-send-draft t]
2628 ;;["Send bounced" gnus-resend-bounced-mail t])
2632 ((not (keymapp gnus-summary-post-menu))
2633 (setq gnus-article-post-menu gnus-summary-post-menu))
2634 ((not gnus-article-post-menu)
2635 ;; Don't share post menu.
2636 (setq gnus-article-post-menu
2637 (copy-keymap gnus-summary-post-menu))))
2638 (define-key gnus-article-mode-map [menu-bar post]
2639 (cons "Post" gnus-article-post-menu))
2642 gnus-summary-misc-menu gnus-summary-mode-map ""
2645 ["Mark as read" gnus-summary-mark-as-read-forward t]
2646 ["Mark same subject and select"
2647 gnus-summary-kill-same-subject-and-select t]
2648 ["Mark same subject" gnus-summary-kill-same-subject t]
2649 ["Catchup" gnus-summary-catchup
2650 ,@(if (featurep 'xemacs) '(t)
2651 '(:help "Mark unread articles in this group as read"))]
2652 ["Catchup all" gnus-summary-catchup-all t]
2653 ["Catchup to here" gnus-summary-catchup-to-here t]
2654 ["Catchup from here" gnus-summary-catchup-from-here t]
2655 ["Catchup region" gnus-summary-mark-region-as-read
2656 (gnus-mark-active-p)]
2657 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2659 ["Tick" gnus-summary-tick-article-forward t]
2660 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2661 ["Remove marks" gnus-summary-clear-mark-forward t]
2662 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2663 ["Set bookmark" gnus-summary-set-bookmark t]
2664 ["Remove bookmark" gnus-summary-remove-bookmark t])
2666 ["Marks..." gnus-summary-limit-to-marks t]
2667 ["Subject..." gnus-summary-limit-to-subject t]
2668 ["Author..." gnus-summary-limit-to-author t]
2669 ["Recipient..." gnus-summary-limit-to-recipient t]
2670 ["Address..." gnus-summary-limit-to-address t]
2671 ["Age..." gnus-summary-limit-to-age t]
2672 ["Extra..." gnus-summary-limit-to-extra t]
2673 ["Score..." gnus-summary-limit-to-score t]
2674 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2675 ["Unread" gnus-summary-limit-to-unread t]
2676 ["Unseen" gnus-summary-limit-to-unseen t]
2677 ["Singletons" gnus-summary-limit-to-singletons t]
2678 ["Replied" gnus-summary-limit-to-replied t]
2679 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2680 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2681 ["Pop limit" gnus-summary-pop-limit t]
2682 ["Show dormant" gnus-summary-limit-include-dormant t]
2683 ["Hide childless dormant"
2684 gnus-summary-limit-exclude-childless-dormant t]
2685 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2686 ["Hide marked" gnus-summary-limit-exclude-marks t]
2687 ["Show expunged" gnus-summary-limit-include-expunged t])
2689 ["Set mark" gnus-summary-mark-as-processable t]
2690 ["Remove mark" gnus-summary-unmark-as-processable t]
2691 ["Remove all marks" gnus-summary-unmark-all-processable t]
2692 ["Invert marks" gnus-uu-invert-processable t]
2693 ["Mark above" gnus-uu-mark-over t]
2694 ["Mark series" gnus-uu-mark-series t]
2695 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2696 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2697 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2698 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2699 ["Mark all" gnus-uu-mark-all t]
2700 ["Mark buffer" gnus-uu-mark-buffer t]
2701 ["Mark sparse" gnus-uu-mark-sparse t]
2702 ["Mark thread" gnus-uu-mark-thread t]
2703 ["Unmark thread" gnus-uu-unmark-thread t]
2704 ("Process Mark Sets"
2705 ["Kill" gnus-summary-kill-process-mark t]
2706 ["Yank" gnus-summary-yank-process-mark
2707 gnus-newsgroup-process-stack]
2708 ["Save" gnus-summary-save-process-mark t]
2709 ["Run command on marked..." gnus-summary-universal-argument t]))
2712 ["Page forward" gnus-summary-next-page
2713 ,@(if (featurep 'xemacs) '(t)
2714 '(:help "Show next page of article"))]
2715 ["Page backward" gnus-summary-prev-page
2716 ,@(if (featurep 'xemacs) '(t)
2717 '(:help "Show previous page of article"))]
2718 ["Line forward" gnus-summary-scroll-up t])
2720 ["Next unread article" gnus-summary-next-unread-article t]
2721 ["Previous unread article" gnus-summary-prev-unread-article t]
2722 ["Next article" gnus-summary-next-article t]
2723 ["Previous article" gnus-summary-prev-article t]
2724 ["Next unread subject" gnus-summary-next-unread-subject t]
2725 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2726 ["Next article same subject" gnus-summary-next-same-subject t]
2727 ["Previous article same subject" gnus-summary-prev-same-subject t]
2728 ["First unread article" gnus-summary-first-unread-article t]
2729 ["Best unread article" gnus-summary-best-unread-article t]
2730 ["Go to subject number..." gnus-summary-goto-subject t]
2731 ["Go to article number..." gnus-summary-goto-article t]
2732 ["Go to the last article" gnus-summary-goto-last-article t]
2733 ["Pop article off history" gnus-summary-pop-article t])
2735 ["Sort by number" gnus-summary-sort-by-number t]
2736 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2737 ["Sort by author" gnus-summary-sort-by-author t]
2738 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2739 ["Sort by subject" gnus-summary-sort-by-subject t]
2740 ["Sort by date" gnus-summary-sort-by-date t]
2741 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2742 ["Sort by score" gnus-summary-sort-by-score t]
2743 ["Sort by lines" gnus-summary-sort-by-lines t]
2744 ["Sort by characters" gnus-summary-sort-by-chars t]
2745 ["Randomize" gnus-summary-sort-by-random t]
2746 ["Original sort" gnus-summary-sort-by-original t])
2748 ["Describe group" gnus-summary-describe-group t]
2749 ["Read manual" gnus-info-find-node t])
2751 ["Pick and read" gnus-pick-mode t]
2752 ["Binary" gnus-binary-mode t])
2754 ["Regenerate" gnus-summary-prepare t]
2755 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2756 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2757 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2758 ["Toggle threading" gnus-summary-toggle-threads t])
2759 ["See old articles" gnus-summary-insert-old-articles t]
2760 ["See new articles" gnus-summary-insert-new-articles t]
2761 ["Filter articles..." gnus-summary-execute-command t]
2762 ["Run command on articles..." gnus-summary-universal-argument t]
2763 ["Search articles forward..." gnus-summary-search-article-forward t]
2764 ["Search articles backward..." gnus-summary-search-article-backward t]
2765 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2766 ["Expand window" gnus-summary-expand-window t]
2767 ["Expire expirable articles" gnus-summary-expire-articles
2768 (gnus-check-backend-function
2769 'request-expire-articles gnus-newsgroup-name)]
2770 ["Edit local kill file" gnus-summary-edit-local-kill t]
2771 ["Edit main kill file" gnus-summary-edit-global-kill t]
2772 ["Edit group parameters" gnus-summary-edit-parameters t]
2773 ["Customize group parameters" gnus-summary-customize-parameters t]
2774 ["Send a bug report" gnus-bug t]
2776 ["Catchup and exit" gnus-summary-catchup-and-exit
2777 ,@(if (featurep 'xemacs) '(t)
2778 '(:help "Mark unread articles in this group as read, then exit"))]
2779 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2780 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2781 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2782 ["Exit group" gnus-summary-exit
2783 ,@(if (featurep 'xemacs) '(t)
2784 '(:help "Exit current group, return to group selection mode"))]
2785 ["Exit group without updating" gnus-summary-exit-no-update t]
2786 ["Exit and goto next group" gnus-summary-next-group t]
2787 ["Exit and goto prev group" gnus-summary-prev-group t]
2788 ["Reselect group" gnus-summary-reselect-current-group t]
2789 ["Rescan group" gnus-summary-rescan-group t]
2790 ["Update dribble" gnus-summary-save-newsrc t])))
2792 (gnus-run-hooks 'gnus-summary-menu-hook)))
2794 (defvar gnus-summary-tool-bar-map nil)
2796 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2797 ;; affect _new_ message buffers. We might add a function that walks thru all
2798 ;; summary-mode buffers and force the update.
2799 (defun gnus-summary-tool-bar-update (&optional symbol value)
2800 "Update summary mode toolbar.
2801 Setter function for custom variables."
2802 (setq-default gnus-summary-tool-bar-map nil)
2804 ;; When used as ":set" function:
2805 (set-default symbol value))
2806 (when (gnus-buffer-live-p gnus-summary-buffer)
2807 (with-current-buffer gnus-summary-buffer
2808 (gnus-summary-make-tool-bar))))
2810 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2811 'gnus-summary-tool-bar-gnome
2812 'gnus-summary-tool-bar-retro)
2813 "Specifies the Gnus summary tool bar.
2815 It can be either a list or a symbol refering to a list. See
2816 `gmm-tool-bar-from-list' for the format of the list. The
2817 default key map is `gnus-summary-mode-map'.
2819 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2820 `gnus-summary-tool-bar-retro'."
2821 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2822 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2823 (repeat :tag "User defined list" gmm-tool-bar-item)
2825 :version "23.1" ;; No Gnus
2826 :initialize 'custom-initialize-default
2827 :set 'gnus-summary-tool-bar-update
2828 :group 'gnus-summary)
2830 (defcustom gnus-summary-tool-bar-gnome
2831 '((gnus-summary-post-news "mail/compose" nil)
2832 (gnus-summary-insert-new-articles "mail/inbox" nil
2833 :visible (or (not gnus-agent)
2835 (gnus-summary-reply-with-original "mail/reply")
2836 (gnus-summary-reply "mail/reply" nil :visible nil)
2837 (gnus-summary-followup-with-original "mail/reply-all")
2838 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2839 (gnus-summary-mail-forward "mail/forward")
2840 (gnus-summary-save-article "mail/save")
2841 (gnus-summary-search-article-forward "search" nil :visible nil)
2842 (gnus-summary-print-article "print")
2843 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2844 ;; Some new commands that may need more suitable icons:
2845 (gnus-summary-save-newsrc "save" nil :visible nil)
2846 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2847 (gnus-summary-prev-article "left-arrow")
2848 (gnus-summary-next-article "right-arrow")
2849 (gnus-summary-next-page "next-page")
2850 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2852 ;; Maybe some sort-by-... could be added:
2853 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2854 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2855 (gnus-summary-mark-as-expirable
2857 :visible (gnus-check-backend-function 'request-expire-articles
2858 gnus-newsgroup-name))
2859 (gnus-summary-mark-as-spam
2861 :visible (and (fboundp 'spam-group-ham-contents-p)
2862 (spam-group-ham-contents-p gnus-newsgroup-name))
2863 :help "Mark as spam")
2864 (gnus-summary-mark-as-read-forward
2866 :visible (and (fboundp 'spam-group-spam-contents-p)
2867 (spam-group-spam-contents-p gnus-newsgroup-name)))
2869 (gnus-summary-exit "exit")
2870 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2871 (gnus-info-find-node "help"))
2872 "List of functions for the summary tool bar (GNOME style).
2874 See `gmm-tool-bar-from-list' for the format of the list."
2875 :type '(repeat gmm-tool-bar-item)
2876 :version "23.1" ;; No Gnus
2877 :initialize 'custom-initialize-default
2878 :set 'gnus-summary-tool-bar-update
2879 :group 'gnus-summary)
2881 (defcustom gnus-summary-tool-bar-retro
2882 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2883 (gnus-summary-next-unread-article "gnus/next-ur")
2884 (gnus-summary-post-news "gnus/post")
2885 (gnus-summary-followup-with-original "gnus/fuwo")
2886 (gnus-summary-followup "gnus/followup")
2887 (gnus-summary-reply-with-original "gnus/reply-wo")
2888 (gnus-summary-reply "gnus/reply")
2889 (gnus-summary-caesar-message "gnus/rot13")
2890 (gnus-uu-decode-uu "gnus/uu-decode")
2891 (gnus-summary-save-article-file "gnus/save-aif")
2892 (gnus-summary-save-article "gnus/save-art")
2893 (gnus-uu-post-news "gnus/uu-post")
2894 (gnus-summary-catchup "gnus/catchup")
2895 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2896 (gnus-summary-exit "gnus/exit-summ")
2897 ;; Some new command that may need more suitable icons:
2898 (gnus-summary-print-article "gnus/print" nil :visible nil)
2899 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2900 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2901 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2902 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2903 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2904 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2906 (gnus-info-find-node "gnus/help" nil :visible nil))
2907 "List of functions for the summary tool bar (retro look).
2909 See `gmm-tool-bar-from-list' for the format of the list."
2910 :type '(repeat gmm-tool-bar-item)
2911 :version "23.1" ;; No Gnus
2912 :initialize 'custom-initialize-default
2913 :set 'gnus-summary-tool-bar-update
2914 :group 'gnus-summary)
2916 (defcustom gnus-summary-tool-bar-zap-list t
2917 "List of icon items from the global tool bar.
2918 These items are not displayed in the Gnus summary mode tool bar.
2920 See `gmm-tool-bar-from-list' for the format of the list."
2921 :type 'gmm-tool-bar-zap-list
2922 :version "23.1" ;; No Gnus
2923 :initialize 'custom-initialize-default
2924 :set 'gnus-summary-tool-bar-update
2925 :group 'gnus-summary)
2927 (defvar image-load-path)
2928 (defvar tool-bar-map)
2930 (defun gnus-summary-make-tool-bar (&optional force)
2931 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2932 When FORCE, rebuild the tool bar."
2933 (when (and (not (featurep 'xemacs))
2934 (boundp 'tool-bar-mode)
2936 (or (not gnus-summary-tool-bar-map) force))
2938 (gmm-image-load-path-for-library "gnus"
2941 (image-load-path (cons (car load-path)
2942 (when (boundp 'image-load-path)
2944 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2945 gnus-summary-tool-bar-zap-list
2946 'gnus-summary-mode-map)))
2948 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2950 (setq gnus-summary-tool-bar-map map))))
2951 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2953 (defun gnus-score-set-default (var value)
2954 "A version of set that updates the GNU Emacs menu-bar."
2956 ;; It is the message that forces the active status to be updated.
2959 (defun gnus-make-score-map (type)
2960 "Make a summary score map of type TYPE."
2963 (let ((headers '(("author" "from" string)
2964 ("subject" "subject" string)
2965 ("article body" "body" string)
2966 ("article head" "head" string)
2967 ("xref" "xref" string)
2968 ("extra header" "extra" string)
2969 ("lines" "lines" number)
2970 ("followups to author" "followup" string)))
2971 (types '((number ("less than" <)
2974 (string ("substring" s)
2978 (perms '(("temporary" (current-time-string))
2986 (if (eq type 'lower)
2991 (setq header (car headers))
2997 (let ((ts (cdr (assoc (nth 2 header) types)))
3013 'gnus-summary-score-entry
3015 (if (or (string= (nth 1 header)
3017 (string= (nth 1 header)
3020 (list 'gnus-summary-header
3022 (list 'quote (nth 1 (car ts)))
3023 (list 'gnus-score-delta-default
3030 (list (nreverse outp))))
3033 (list (nreverse outt))))
3035 (setq headers (cdr headers)))
3036 (list (nreverse outh))))))))
3039 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3040 (defvar bookmark-make-record-function)
3043 (defun gnus-summary-mode (&optional group)
3044 "Major mode for reading articles.
3046 All normal editing commands are switched off.
3047 \\<gnus-summary-mode-map>
3048 Each line in this buffer represents one article. To read an
3049 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3050 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3053 You can also post articles and send mail from this buffer. To
3054 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3055 of an article, type `\\[gnus-summary-reply]'.
3057 There are approx. one gazillion commands you can execute in this
3058 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3060 The following commands are available:
3062 \\{gnus-summary-mode-map}"
3064 (kill-all-local-variables)
3065 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3066 (gnus-summary-make-local-variables))
3067 (gnus-summary-make-local-variables)
3068 (setq gnus-newsgroup-name group)
3069 (when (gnus-visual-p 'summary-menu 'menu)
3070 (gnus-summary-make-menu-bar)
3071 (gnus-summary-make-tool-bar))
3072 (gnus-make-thread-indent-array)
3073 (gnus-simplify-mode-line)
3074 (setq major-mode 'gnus-summary-mode)
3075 (setq mode-name "Summary")
3076 (use-local-map gnus-summary-mode-map)
3077 (buffer-disable-undo)
3078 (setq buffer-read-only t ;Disable modification
3079 show-trailing-whitespace nil)
3080 (setq truncate-lines t)
3081 (add-to-invisibility-spec '(gnus-sum . t))
3082 (gnus-summary-set-display-table)
3083 (gnus-set-default-directory)
3084 (make-local-variable 'gnus-summary-line-format)
3085 (make-local-variable 'gnus-summary-line-format-spec)
3086 (make-local-variable 'gnus-summary-dummy-line-format)
3087 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3088 (make-local-variable 'gnus-summary-mark-positions)
3089 (gnus-make-local-hook 'pre-command-hook)
3090 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3091 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3092 (turn-on-gnus-mailing-list-mode)
3093 (mm-enable-multibyte)
3094 (set (make-local-variable 'bookmark-make-record-function)
3095 'gnus-summary-bookmark-make-record)
3096 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3097 (gnus-update-summary-mark-positions))
3099 (defun gnus-summary-make-local-variables ()
3100 "Make all the local summary buffer variables."
3102 (dolist (local gnus-summary-local-variables)
3105 (if (eq (cdr local) 'global)
3106 ;; Copy the global value of the variable.
3107 (setq global (symbol-value (car local)))
3108 ;; Use the value from the list.
3109 (setq global (eval (cdr local))))
3110 (set (make-local-variable (car local)) global))
3111 ;; Simple nil-valued local variable.
3112 (set (make-local-variable local) nil)))))
3114 ;; Summary data functions.
3116 (defmacro gnus-data-number (data)
3119 (defmacro gnus-data-set-number (data number)
3120 `(setcar ,data ,number))
3122 (defmacro gnus-data-mark (data)
3125 (defmacro gnus-data-set-mark (data mark)
3126 `(setcar (nthcdr 1 ,data) ,mark))
3128 (defmacro gnus-data-pos (data)
3131 (defmacro gnus-data-set-pos (data pos)
3132 `(setcar (nthcdr 2 ,data) ,pos))
3134 (defmacro gnus-data-header (data)
3137 (defmacro gnus-data-set-header (data header)
3138 `(setf (nth 3 ,data) ,header))
3140 (defmacro gnus-data-level (data)
3143 (defmacro gnus-data-unread-p (data)
3144 `(= (nth 1 ,data) gnus-unread-mark))
3146 (defmacro gnus-data-read-p (data)
3147 `(/= (nth 1 ,data) gnus-unread-mark))
3149 (defmacro gnus-data-pseudo-p (data)
3150 `(consp (nth 3 ,data)))
3152 (defmacro gnus-data-find (number)
3153 `(assq ,number gnus-newsgroup-data))
3155 (defmacro gnus-data-find-list (number &optional data)
3156 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3157 (memq (assq ,number bdata)
3160 (defmacro gnus-data-make (number mark pos header level)
3161 `(list ,number ,mark ,pos ,header ,level))
3163 (defun gnus-data-enter (after-article number mark pos header level offset)
3164 (let ((data (gnus-data-find-list after-article)))
3166 (error "No such article: %d" after-article))
3167 (setcdr data (cons (gnus-data-make number mark pos header level)
3169 (setq gnus-newsgroup-data-reverse nil)
3170 (gnus-data-update-list (cddr data) offset)))
3172 (defun gnus-data-enter-list (after-article list &optional offset)
3174 (let ((data (and after-article (gnus-data-find-list after-article)))
3178 (let ((odata gnus-newsgroup-data))
3179 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3181 (gnus-data-update-list odata offset)))
3182 ;; Find the last element in the list to be spliced into the main
3184 (setq list (last list))
3187 (setcdr list gnus-newsgroup-data)
3188 (setq gnus-newsgroup-data ilist)
3190 (gnus-data-update-list (cdr list) offset)))
3191 (setcdr list (cdr data))
3194 (gnus-data-update-list (cdr list) offset))))
3195 (setq gnus-newsgroup-data-reverse nil))))
3197 (defun gnus-data-remove (article &optional offset)
3198 (let ((data gnus-newsgroup-data))
3199 (if (= (gnus-data-number (car data)) article)
3201 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3202 gnus-newsgroup-data-reverse nil)
3204 (gnus-data-update-list gnus-newsgroup-data offset)))
3206 (when (= (gnus-data-number (cadr data)) article)
3207 (setcdr data (cddr data))
3209 (gnus-data-update-list (cdr data) offset))
3211 gnus-newsgroup-data-reverse nil))
3212 (setq data (cdr data))))))
3214 (defmacro gnus-data-list (backward)
3216 (or gnus-newsgroup-data-reverse
3217 (setq gnus-newsgroup-data-reverse
3218 (reverse gnus-newsgroup-data)))
3219 gnus-newsgroup-data))
3221 (defun gnus-data-update-list (data offset)
3222 "Add OFFSET to the POS of all data entries in DATA."
3223 (setq gnus-newsgroup-data-reverse nil)
3225 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3226 (setq data (cdr data))))
3228 (defun gnus-summary-article-pseudo-p (article)
3229 "Say whether this article is a pseudo article or not."
3230 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3232 (defmacro gnus-summary-article-sparse-p (article)
3233 "Say whether this article is a sparse article or not."
3234 `(memq ,article gnus-newsgroup-sparse))
3236 (defmacro gnus-summary-article-ancient-p (article)
3237 "Say whether this article is a sparse article or not."
3238 `(memq ,article gnus-newsgroup-ancient))
3240 (defun gnus-article-parent-p (number)
3241 "Say whether this article is a parent or not."
3242 (let ((data (gnus-data-find-list number)))
3243 (and (cdr data) ; There has to be an article after...
3244 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3245 (gnus-data-level (nth 1 data))))))
3247 (defun gnus-article-children (number)
3248 "Return a list of all children to NUMBER."
3249 (let* ((data (gnus-data-find-list number))
3250 (level (gnus-data-level (car data)))
3252 (setq data (cdr data))
3254 (= (gnus-data-level (car data)) (1+ level)))
3255 (push (gnus-data-number (car data)) children)
3256 (setq data (cdr data)))
3259 (defmacro gnus-summary-skip-intangible ()
3260 "If the current article is intangible, then jump to a different article."
3261 '(let ((to (get-text-property (point) 'gnus-intangible)))
3262 (and to (gnus-summary-goto-subject to))))
3264 (defmacro gnus-summary-article-intangible-p ()
3265 "Say whether this article is intangible or not."
3266 '(get-text-property (point) 'gnus-intangible))
3268 (defun gnus-article-read-p (article)
3269 "Say whether ARTICLE is read or not."
3270 (not (or (memq article gnus-newsgroup-marked)
3271 (memq article gnus-newsgroup-spam-marked)
3272 (memq article gnus-newsgroup-unreads)
3273 (memq article gnus-newsgroup-unselected)
3274 (memq article gnus-newsgroup-dormant))))
3276 ;; Some summary mode macros.
3278 (defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
3280 If there isn't an article number here, then we return the current
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3287 (defmacro gnus-summary-article-header (&optional number)
3288 "Return the header of article NUMBER."
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3292 (defmacro gnus-summary-thread-level (&optional number)
3293 "Return the level of thread that starts with article NUMBER."
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3300 (defmacro gnus-summary-article-mark (&optional number)
3301 "Return the mark of article NUMBER."
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3305 (defmacro gnus-summary-article-pos (&optional number)
3306 "Return the position of the line of article NUMBER."
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3310 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311 (defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3320 (mail-header-subject headers))))
3322 (defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3328 (defun gnus-summary-article-children (&optional number)
3329 "Return a list of article numbers that are children of article NUMBER."
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3338 (nreverse children)))
3340 (defun gnus-summary-article-parent (&optional number)
3341 "Return the article number of the parent of article NUMBER."
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3353 (defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3357 (defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359 This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
3362 (= mark gnus-spam-mark)
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3366 (defmacro gnus-article-mark (number)
3367 "Return the MARK of article NUMBER.
3368 This macro should only be used when computing the mark the \"first\"
3369 time; i.e., when generating the summary lines. After that,
3370 `gnus-summary-article-mark' should be used to examine the
3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3383 ;; Saving hidden threads.
3385 (defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3392 (gnus-restore-hidden-threads-configuration ,config)))))
3393 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3396 (defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3405 (while (get-text-property (point) 'gnus-intangible)
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3411 (defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3415 (goto-char (point-min))
3417 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3418 (push (save-excursion (forward-line 0) (point)) config))
3422 (defun gnus-restore-hidden-threads-configuration (config)
3423 "Restore hidden threads configuration from CONFIG."
3425 (let (point (inhibit-read-only t))
3426 (while (setq point (pop config))
3428 (gnus-summary-hide-thread)))))
3430 ;; Various summary mode internalish functions.
3432 (defun gnus-mouse-pick-article (e)
3435 (gnus-summary-next-page nil t))
3437 (defun gnus-summary-set-display-table ()
3438 "Change the display table.
3439 Odd characters have a tendency to mess
3440 up nicely formatted displays - we make all possible glyphs
3441 display only a single character."
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
3449 (gnus-put-display-table i [??] table))
3450 ;; ... but not newline and cr, of course. (cr is necessary for the
3451 ;; selective display).
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
3454 ;; We keep TAB as well.
3455 (gnus-put-display-table ?\t nil table)
3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3457 ;; Emacs 23 (unicode), that are not set already.
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
3465 (setq buffer-display-table table)))
3467 (defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3480 (current-buffer))))))
3482 (defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer."
3484 (let ((buffer (gnus-summary-buffer-name group))
3485 (dead-name (concat "*Dead Summary "
3486 (gnus-group-decoded-name group) "*")))
3487 ;; If a dead summary buffer exists, we kill it.
3488 (when (gnus-buffer-live-p dead-name)
3489 (gnus-kill-buffer dead-name))
3490 (if (get-buffer buffer)
3493 (setq gnus-summary-buffer (current-buffer))
3494 (not gnus-newsgroup-prepared))
3495 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3496 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3497 (gnus-summary-mode group)
3498 (when (gnus-group-quit-config group)
3499 (set (make-local-variable 'gnus-single-article-buffer) nil))
3500 (make-local-variable 'gnus-article-buffer)
3501 (make-local-variable 'gnus-article-current)
3502 (make-local-variable 'gnus-original-article-buffer)
3503 (setq gnus-newsgroup-name group)
3504 ;; Set any local variables in the group parameters.
3505 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3508 (defun gnus-set-global-variables ()
3509 "Set the global equivalents of the buffer-local variables.
3510 They are set to the latest values they had. These reflect the summary
3511 buffer that was in action when the last article was fetched."
3512 (when (eq major-mode 'gnus-summary-mode)
3513 (setq gnus-summary-buffer (current-buffer))
3514 (let ((name gnus-newsgroup-name)
3515 (marked gnus-newsgroup-marked)
3516 (spam gnus-newsgroup-spam-marked)
3517 (unread gnus-newsgroup-unreads)
3518 (headers gnus-current-headers)
3519 (data gnus-newsgroup-data)
3520 (summary gnus-summary-buffer)
3521 (article-buffer gnus-article-buffer)
3522 (original gnus-original-article-buffer)
3523 (gac gnus-article-current)
3524 (reffed gnus-reffed-article-number)
3525 (score-file gnus-current-score-file)
3526 (default-charset gnus-newsgroup-charset)
3528 (let ((locals gnus-newsgroup-variables))
3530 (if (consp (car locals))
3531 (push (eval (caar locals)) vlist)
3532 (push (eval (car locals)) vlist))
3533 (setq locals (cdr locals)))
3534 (setq vlist (nreverse vlist)))
3535 (with-current-buffer gnus-group-buffer
3536 (setq gnus-newsgroup-name name
3537 gnus-newsgroup-marked marked
3538 gnus-newsgroup-spam-marked spam
3539 gnus-newsgroup-unreads unread
3540 gnus-current-headers headers
3541 gnus-newsgroup-data data
3542 gnus-article-current gac
3543 gnus-summary-buffer summary
3544 gnus-article-buffer article-buffer
3545 gnus-original-article-buffer original
3546 gnus-reffed-article-number reffed
3547 gnus-current-score-file score-file
3548 gnus-newsgroup-charset default-charset)
3549 (let ((locals gnus-newsgroup-variables))
3551 (if (consp (car locals))
3552 (set (caar locals) (pop vlist))
3553 (set (car locals) (pop vlist)))
3554 (setq locals (cdr locals))))
3555 ;; The article buffer also has local variables.
3556 (when (gnus-buffer-live-p gnus-article-buffer)
3557 (set-buffer gnus-article-buffer)
3558 (setq gnus-summary-buffer summary))))))
3560 (defun gnus-summary-article-unread-p (article)
3561 "Say whether ARTICLE is unread or not."
3562 (memq article gnus-newsgroup-unreads))
3564 (defun gnus-summary-first-article-p (&optional article)
3565 "Return whether ARTICLE is the first article in the buffer."
3566 (if (not (setq article (or article (gnus-summary-article-number))))
3568 (eq article (caar gnus-newsgroup-data))))
3570 (defun gnus-summary-last-article-p (&optional article)
3571 "Return whether ARTICLE is the last article in the buffer."
3572 (if (not (setq article (or article (gnus-summary-article-number))))
3573 ;; All non-existent numbers are the last article. :-)
3575 (not (cdr (gnus-data-find-list article)))))
3577 (defun gnus-make-thread-indent-array (&optional n)
3579 (progn (setq n 200) nil)
3580 (null gnus-thread-indent-array)
3581 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3582 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3583 gnus-thread-indent-array-level gnus-thread-indent-level)
3585 (aset gnus-thread-indent-array n
3586 (make-string (* n gnus-thread-indent-level) ? ))
3589 (defun gnus-update-summary-mark-positions ()
3590 "Compute where the summary marks are to go."
3592 (when (gnus-buffer-exists-p gnus-summary-buffer)
3593 (set-buffer gnus-summary-buffer))
3594 (let ((spec gnus-summary-line-format-spec)
3597 (gnus-set-work-buffer)
3598 (let ((gnus-tmp-unread ?Z)
3599 (gnus-replied-mark ?Z)
3600 (gnus-score-below-mark ?Z)
3601 (gnus-score-over-mark ?Z)
3602 (gnus-undownloaded-mark ?Z)
3603 (gnus-summary-line-format-spec spec)
3604 (gnus-newsgroup-downloadable '(0))
3605 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3606 case-fold-search ignores)
3607 ;; Here, all marks are bound to Z.
3608 (gnus-summary-insert-line header
3609 0 nil t gnus-tmp-unread t nil "" nil 1)
3610 (goto-char (point-min))
3611 ;; Memorize the positions of the same characters as dummy marks.
3612 (while (re-search-forward "[A-D]" nil t)
3613 (push (point) ignores))
3615 ;; We use A-D as dummy marks in order to know column positions
3616 ;; where marks should be inserted.
3617 (setq gnus-tmp-unread ?A
3618 gnus-replied-mark ?B
3619 gnus-score-below-mark ?C
3620 gnus-score-over-mark ?C
3621 gnus-undownloaded-mark ?D)
3622 (gnus-summary-insert-line header
3623 0 nil t gnus-tmp-unread t nil "" nil 1)
3624 ;; Ignore characters which aren't dummy marks.
3626 (delete-region (goto-char (1- p)) p)
3628 (goto-char (point-min))
3629 (setq pos (list (cons 'unread
3630 (and (search-forward "A" nil t)
3631 (- (point) (point-min) 1)))))
3632 (goto-char (point-min))
3633 (push (cons 'replied (and (search-forward "B" nil t)
3634 (- (point) (point-min) 1)))
3636 (goto-char (point-min))
3637 (push (cons 'score (and (search-forward "C" nil t)
3638 (- (point) (point-min) 1)))
3640 (goto-char (point-min))
3641 (push (cons 'download (and (search-forward "D" nil t)
3642 (- (point) (point-min) 1)))
3644 (setq gnus-summary-mark-positions pos))))
3646 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3647 "Insert a dummy root in the summary buffer."
3649 (gnus-add-text-properties
3650 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3651 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3653 (defun gnus-summary-extract-address-component (from)
3654 (or (car (funcall gnus-extract-address-components from))
3657 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3658 (let ((mail-parse-charset gnus-newsgroup-charset)
3659 (ignored-from-addresses (gnus-ignored-from-addresses))
3660 ; Is it really necessary to do this next part for each summary line?
3661 ; Luckily, doesn't seem to slow things down much.
3662 (mail-parse-ignored-charsets
3663 (with-current-buffer gnus-summary-buffer
3664 gnus-newsgroup-ignored-charsets)))
3666 (and ignored-from-addresses
3667 (string-match ignored-from-addresses gnus-tmp-from)
3668 (let ((extra-headers (mail-header-extra header))
3672 ((setq to (cdr (assq 'To extra-headers)))
3673 (concat gnus-summary-to-prefix
3675 (gnus-summary-extract-address-component
3676 (funcall gnus-decode-encoded-address-function to)))))
3679 (cdr (assq 'Newsgroups extra-headers))
3681 (memq 'Newsgroups gnus-extra-headers)
3682 (eq (car (gnus-find-method-for-group
3683 gnus-newsgroup-name)) 'nntp)
3684 (gnus-group-real-name gnus-newsgroup-name))))
3685 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3686 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3688 (defun gnus-summary-insert-line (gnus-tmp-header
3689 gnus-tmp-level gnus-tmp-current
3690 undownloaded gnus-tmp-unread gnus-tmp-replied
3691 gnus-tmp-expirable gnus-tmp-subject-or-nil
3692 &optional gnus-tmp-dummy gnus-tmp-score
3694 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3695 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3697 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3698 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3699 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3700 (gnus-tmp-score-char
3701 (if (or (null gnus-summary-default-score)
3702 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3703 gnus-summary-zcore-fuzz))
3705 (if (< gnus-tmp-score gnus-summary-default-score)
3706 gnus-score-below-mark gnus-score-over-mark)))
3707 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3709 (cond (gnus-tmp-process gnus-process-mark)
3710 ((memq gnus-tmp-current gnus-newsgroup-cached)
3712 (gnus-tmp-replied gnus-replied-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3714 gnus-forwarded-mark)
3715 ((memq gnus-tmp-current gnus-newsgroup-saved)
3717 ((memq gnus-tmp-number gnus-newsgroup-recent)
3719 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3722 (gnus-tmp-downloaded
3724 gnus-undownloaded-mark)
3725 (gnus-newsgroup-agentized
3726 gnus-downloaded-mark)
3729 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3732 ((string-match "<[^>]+> *$" gnus-tmp-from)
3733 (let ((beg (match-beginning 0)))
3734 (or (and (string-match "^\".+\"" gnus-tmp-from)
3735 (substring gnus-tmp-from 1 (1- (match-end 0))))
3736 (substring gnus-tmp-from 0 beg))))
3737 ((string-match "(.+)" gnus-tmp-from)
3738 (substring gnus-tmp-from
3739 (1+ (match-beginning 0)) (1- (match-end 0))))
3741 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3742 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3743 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3744 (inhibit-read-only t))
3745 (when (string= gnus-tmp-name "")
3746 (setq gnus-tmp-name gnus-tmp-from))
3747 (unless (numberp gnus-tmp-lines)
3748 (setq gnus-tmp-lines -1))
3749 (if (= gnus-tmp-lines -1)
3750 (setq gnus-tmp-lines "?")
3751 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3753 (gnus-put-text-property
3755 (progn (eval gnus-summary-line-format-spec) (point))
3756 'gnus-number gnus-tmp-number)
3757 (error (gnus-message 5 "Error updating the summary line")))
3758 (when (gnus-visual-p 'summary-highlight 'highlight)
3760 (gnus-summary-highlight-line)
3761 (gnus-run-hooks 'gnus-summary-update-hook)
3764 (defun gnus-summary-update-line (&optional dont-update)
3765 "Update summary line after change."
3766 (when (and gnus-summary-default-score
3767 (not gnus-summary-inhibit-highlight))
3768 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3769 (article (gnus-summary-article-number))
3770 (score (gnus-summary-article-score article)))
3772 (if (and gnus-summary-mark-below
3773 (< (gnus-summary-article-score)
3774 gnus-summary-mark-below))
3775 ;; This article has a low score, so we mark it as read.
3776 (when (memq article gnus-newsgroup-unreads)
3777 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3778 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3779 ;; This article was previously marked as read on account
3780 ;; of a low score, but now it has risen, so we mark it as
3782 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3783 (gnus-summary-update-mark
3784 (if (or (null gnus-summary-default-score)
3785 (<= (abs (- score gnus-summary-default-score))
3786 gnus-summary-zcore-fuzz))
3788 (if (< score gnus-summary-default-score)
3789 gnus-score-below-mark gnus-score-over-mark))
3791 ;; Do visual highlighting.
3792 (when (gnus-visual-p 'summary-highlight 'highlight)
3793 (gnus-summary-highlight-line)
3794 (gnus-run-hooks 'gnus-summary-update-hook)))))
3796 (defvar gnus-tmp-new-adopts nil)
3798 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3799 "Return the number of articles in THREAD.
3800 This may be 0 in some cases -- if none of the articles in
3801 the thread are to be displayed."
3803 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3805 ((not (listp thread))
3807 ((and (consp thread) (cdr thread))
3810 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3813 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3816 (when (and level (zerop level) gnus-tmp-new-adopts)
3819 'gnus-summary-number-of-articles-in-thread
3820 gnus-tmp-new-adopts))))
3822 (if (> number 1) gnus-not-empty-thread-mark
3823 gnus-empty-thread-mark)
3826 (defsubst gnus-summary-line-message-size (head)
3827 "Return pretty-printed version of message size.
3828 This function is intended to be used in
3829 `gnus-summary-line-format-alist'."
3830 (let ((c (or (mail-header-chars head) -1)))
3831 (cond ((< c 0) "n/a") ; chars not available
3832 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3833 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3834 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3835 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3838 (defun gnus-summary-set-local-parameters (group)
3839 "Go through the local params of GROUP and set all variable specs in that list."
3840 (let ((vars '(quit-config active))) ; Ignore things that aren't
3842 (dolist (elem (gnus-group-find-parameter group))
3843 (and (consp elem) ; Has to be a cons.
3844 (consp (cdr elem)) ; The cdr has to be a list.
3845 (symbolp (car elem)) ; Has to be a symbol in there.
3846 (not (memq (car elem) vars))
3848 (push (car elem) vars)
3849 ;; Variables like `gnus-show-threads' that are globally
3850 ;; bound, if used as group parameters, need to get to be
3851 ;; buffer-local, whereas just parameters like `gcc-self',
3852 ;; `timestamp', etc. should not be bound as variables.
3853 (if (boundp (car elem))
3854 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3855 (eval (nth 1 elem))))))))
3857 (defun gnus-summary-read-group (group &optional show-all no-article
3858 kill-buffer no-display backward
3860 "Start reading news in newsgroup GROUP.
3861 If SHOW-ALL is non-nil, already read articles are also listed.
3862 If NO-ARTICLE is non-nil, no article is selected initially.
3863 If NO-DISPLAY, don't generate a summary buffer."
3867 (let ((gnus-auto-select-next nil))
3868 (or (gnus-summary-read-group-1
3869 group show-all no-article
3870 kill-buffer no-display
3873 select-articles nil)))))
3874 (eq gnus-auto-select-next 'quietly))
3875 (set-buffer gnus-group-buffer)
3876 ;; The entry function called above goes to the next
3877 ;; group automatically, so we go two groups back
3878 ;; if we are searching for the previous group.
3880 (gnus-group-prev-unread-group 2))
3881 (if (not (equal group (gnus-group-group-name)))
3882 (setq group (gnus-group-group-name))
3886 (defun gnus-summary-read-group-1 (group show-all no-article
3887 kill-buffer no-display
3888 &optional select-articles)
3889 ;; Killed foreign groups can't be entered.
3890 ;; (when (and (not (gnus-group-native-p group))
3891 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3892 ;; (error "Dead non-native groups can't be entered"))
3893 (gnus-message 5 "Retrieving newsgroup: %s..."
3894 (gnus-group-decoded-name group))
3895 (let* ((new-group (gnus-summary-setup-buffer group))
3896 (quit-config (gnus-group-quit-config group))
3897 (did-select (and new-group (gnus-select-newsgroup
3898 group show-all select-articles))))
3900 ;; This summary buffer exists already, so we just select it.
3902 (gnus-set-global-variables)
3904 (gnus-kill-or-deaden-summary kill-buffer))
3905 (gnus-configure-windows 'summary 'force)
3906 (gnus-set-mode-line 'summary)
3907 (gnus-summary-position-point)
3910 ;; We couldn't select this group.
3912 (when (and (eq major-mode 'gnus-summary-mode)
3913 (not (equal (current-buffer) kill-buffer)))
3914 (kill-buffer (current-buffer))
3915 (if (not quit-config)
3917 ;; Update the info -- marks might need to be removed,
3919 (gnus-summary-update-info)
3920 (set-buffer gnus-group-buffer)
3921 (gnus-group-jump-to-group group)
3922 (gnus-group-next-unread-group 1))
3923 (gnus-handle-ephemeral-exit quit-config)))
3924 (let ((grpinfo (gnus-get-info group)))
3925 (if (null (gnus-info-read grpinfo))
3926 (gnus-message 3 "Group %s contains no messages"
3927 (gnus-group-decoded-name group))
3928 (gnus-message 3 "Can't select group")))
3930 ;; The user did a `C-g' while prompting for number of articles,
3931 ;; so we exit this group.
3932 ((eq did-select 'quit)
3933 (and (eq major-mode 'gnus-summary-mode)
3934 (not (equal (current-buffer) kill-buffer))
3935 (kill-buffer (current-buffer)))
3937 (gnus-kill-or-deaden-summary kill-buffer))
3938 (if (not quit-config)
3940 (set-buffer gnus-group-buffer)
3941 (gnus-group-jump-to-group group)
3942 (gnus-configure-windows 'group 'force))
3943 (gnus-handle-ephemeral-exit quit-config))
3944 ;; Finally signal the quit.
3946 ;; The group was successfully selected.
3948 (gnus-set-global-variables)
3949 ;; Save the active value in effect when the group was entered.
3950 (setq gnus-newsgroup-active
3952 (gnus-active gnus-newsgroup-name)))
3953 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3954 ;; You can change the summary buffer in some way with this hook.
3955 (gnus-run-hooks 'gnus-select-group-hook)
3956 (when (memq 'summary (gnus-update-format-specifications
3957 nil 'summary 'summary-mode 'summary-dummy))
3958 ;; The format specification for the summary line was updated,
3959 ;; so we need to update the mark positions as well.
3960 (gnus-update-summary-mark-positions))
3961 ;; Do score processing.
3962 (when gnus-use-scoring
3963 (gnus-possibly-score-headers))
3964 ;; Check whether to fill in the gaps in the threads.
3965 (when gnus-build-sparse-threads
3966 (gnus-build-sparse-threads))
3967 ;; Find the initial limit.
3969 (let ((gnus-newsgroup-dormant nil))
3970 (gnus-summary-initial-limit show-all))
3971 (gnus-summary-initial-limit show-all))
3972 ;; Generate the summary buffer.
3974 (gnus-summary-prepare))
3975 (when gnus-use-trees
3976 (gnus-tree-open group)
3977 (setq gnus-summary-highlight-line-function
3978 'gnus-tree-highlight-article))
3979 ;; If the summary buffer is empty, but there are some low-scored
3980 ;; articles or some excluded dormants, we include these in the
3982 (when (and (zerop (buffer-size))
3984 (cond (gnus-newsgroup-dormant
3985 (gnus-summary-limit-include-dormant))
3986 ((and gnus-newsgroup-scored show-all)
3987 (gnus-summary-limit-include-expunged t))))
3988 ;; Function `gnus-apply-kill-file' must be called in this hook.
3989 (gnus-run-hooks 'gnus-apply-kill-hook)
3990 (if (and (zerop (buffer-size))
3993 ;; This newsgroup is empty.
3994 (gnus-summary-catchup-and-exit nil t)
3995 (gnus-message 6 "No unread news")
3997 (gnus-kill-or-deaden-summary kill-buffer))
3998 ;; Return nil from this function.
4000 ;; Hide conversation thread subtrees. We cannot do this in
4001 ;; gnus-summary-prepare-hook since kill processing may not
4002 ;; work with hidden articles.
4003 (gnus-summary-maybe-hide-threads)
4005 (gnus-kill-or-deaden-summary kill-buffer))
4006 (gnus-summary-auto-select-subject)
4007 ;; Show first unread article if requested.
4008 (if (and (not no-article)
4010 gnus-newsgroup-unreads
4011 gnus-auto-select-first)
4013 (gnus-configure-windows 'summary)
4014 (let ((art (gnus-summary-article-number)))
4015 (unless (and (not gnus-plugged)
4016 (or (memq art gnus-newsgroup-undownloaded)
4017 (memq art gnus-newsgroup-downloadable)))
4018 (gnus-summary-goto-article art))))
4019 ;; Don't select any articles.
4020 (gnus-summary-position-point)
4021 (gnus-configure-windows 'summary 'force)
4022 (gnus-set-mode-line 'summary))
4023 (when (and gnus-auto-center-group
4024 (get-buffer-window gnus-group-buffer t))
4025 ;; Gotta use windows, because recenter does weird stuff if
4026 ;; the current buffer ain't the displayed window.
4027 (let ((owin (selected-window)))
4028 (select-window (get-buffer-window gnus-group-buffer t))
4029 (when (gnus-group-goto-group group)
4031 (select-window owin)))
4032 ;; Mark this buffer as "prepared".
4033 (setq gnus-newsgroup-prepared t)
4034 (gnus-run-hooks 'gnus-summary-prepared-hook)
4035 (unless (gnus-ephemeral-group-p group)
4036 (gnus-group-update-group group))
4039 (defun gnus-summary-auto-select-subject ()
4040 "Select the subject line on initial group entry."
4041 (goto-char (point-min))
4043 ((eq gnus-auto-select-subject 'best)
4044 (gnus-summary-best-unread-subject))
4045 ((eq gnus-auto-select-subject 'unread)
4046 (gnus-summary-first-unread-subject))
4047 ((eq gnus-auto-select-subject 'unseen)
4048 (gnus-summary-first-unseen-subject))
4049 ((eq gnus-auto-select-subject 'unseen-or-unread)
4050 (gnus-summary-first-unseen-or-unread-subject))
4051 ((eq gnus-auto-select-subject 'first)
4054 ((functionp gnus-auto-select-subject)
4055 (funcall gnus-auto-select-subject))))
4057 (defun gnus-summary-prepare ()
4058 "Generate the summary buffer."
4060 (let ((inhibit-read-only t))
4062 (setq gnus-newsgroup-data nil
4063 gnus-newsgroup-data-reverse nil)
4064 (gnus-run-hooks 'gnus-summary-generate-hook)
4065 ;; Generate the buffer, either with threads or without.
4066 (when gnus-newsgroup-headers
4067 (gnus-summary-prepare-threads
4068 (if gnus-show-threads
4069 (gnus-sort-gathered-threads
4070 (funcall gnus-summary-thread-gathering-function
4072 (gnus-cut-threads (gnus-make-threads)))))
4073 ;; Unthreaded display.
4074 (gnus-sort-articles gnus-newsgroup-headers))))
4075 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4076 ;; Call hooks for modifying summary buffer.
4077 (goto-char (point-min))
4078 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4080 (defsubst gnus-general-simplify-subject (subject)
4081 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4084 ;; Truncate the subject.
4085 (gnus-simplify-subject-functions
4086 (gnus-map-function gnus-simplify-subject-functions subject))
4087 ((numberp gnus-summary-gather-subject-limit)
4088 (setq subject (gnus-simplify-subject-re subject))
4089 (if (> (length subject) gnus-summary-gather-subject-limit)
4090 (substring subject 0 gnus-summary-gather-subject-limit)
4092 ;; Fuzzily simplify it.
4093 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4094 (gnus-simplify-subject-fuzzy subject))
4095 ;; Just remove the leading "Re:".
4097 (gnus-simplify-subject-re subject))))
4099 (if (and gnus-summary-gather-exclude-subject
4100 (string-match gnus-summary-gather-exclude-subject subject))
4101 nil ; This article shouldn't be gathered
4104 (defun gnus-summary-simplify-subject-query ()
4105 "Query where the respool algorithm would put this article."
4107 (gnus-summary-select-article)
4108 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4110 (defun gnus-gather-threads-by-subject (threads)
4111 "Gather threads by looking at Subject headers."
4112 (if (not gnus-summary-make-false-root)
4114 (let ((hashtb (gnus-make-hashtable 1024))
4117 subject hthread whole-subject)
4119 (setq subject (gnus-general-simplify-subject
4120 (setq whole-subject (mail-header-subject
4123 (if (setq hthread (gnus-gethash subject hashtb))
4125 ;; We enter a dummy root into the thread, if we
4126 ;; haven't done that already.
4127 (unless (stringp (caar hthread))
4128 (setcar hthread (list whole-subject (car hthread))))
4129 ;; We add this new gathered thread to this gathered
4131 (setcdr (car hthread)
4132 (nconc (cdar hthread) (list (car threads))))
4133 ;; Remove it from the list of threads.
4134 (setcdr prev (cdr threads))
4135 (setq threads prev))
4136 ;; Enter this thread into the hash table.
4137 (gnus-sethash subject
4138 (if gnus-summary-make-false-root-always
4140 ;; If you want a dummy root above all
4142 (setcar threads (list whole-subject
4148 (setq threads (cdr threads)))
4151 (defun gnus-gather-threads-by-references (threads)
4152 "Gather threads by looking at References headers."
4153 (let ((idhashtb (gnus-make-hashtable 1024))
4154 (thhashtb (gnus-make-hashtable 1024))
4157 ids references id gthread gid entered ref)
4159 (when (setq references (mail-header-references (caar threads)))
4160 (setq id (mail-header-id (caar threads))
4161 ids (inline (gnus-split-references references))
4163 (while (setq ref (pop ids))
4164 (setq ids (delete ref ids))
4165 (if (not (setq gid (gnus-gethash ref idhashtb)))
4167 (gnus-sethash ref id idhashtb)
4168 (gnus-sethash id threads thhashtb))
4169 (setq gthread (gnus-gethash gid thhashtb))
4171 ;; We enter a dummy root into the thread, if we
4172 ;; haven't done that already.
4173 (unless (stringp (caar gthread))
4174 (setcar gthread (list (mail-header-subject (caar gthread))
4176 ;; We add this new gathered thread to this gathered
4178 (setcdr (car gthread)
4179 (nconc (cdar gthread) (list (car threads)))))
4180 ;; Add it into the thread hash table.
4181 (gnus-sethash id gthread thhashtb)
4183 ;; Remove it from the list of threads.
4184 (setcdr prev (cdr threads))
4185 (setq threads prev))))
4187 (setq threads (cdr threads)))
4190 (defun gnus-sort-gathered-threads (threads)
4191 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4192 (let ((result threads))
4194 (when (stringp (caar threads))
4195 (setcdr (car threads)
4196 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4197 (setq threads (cdr threads)))
4200 (defun gnus-thread-loop-p (root thread)
4201 "Say whether ROOT is in THREAD."
4202 (let ((stack (list thread))
4205 (while (setq thread (pop stack))
4206 (setq th (cdr thread))
4208 (not (eq (caar th) root)))
4211 ;; We have found a loop.
4213 (setcdr thread (delq (car th) (cdr thread)))
4214 (if (boundp (setq ref-dep (intern "none"
4215 gnus-newsgroup-dependencies)))
4216 (setcdr (symbol-value ref-dep)
4217 (nconc (cdr (symbol-value ref-dep))
4219 (set ref-dep (list nil (car th))))
4222 ;; Push all the subthreads onto the stack.
4223 (push (cdr thread) stack)))
4226 (defun gnus-make-threads ()
4227 "Go through the dependency hashtb and find the roots. Return all threads."
4229 (while (catch 'infloop
4232 ;; Deal with self-referencing References loops.
4233 (when (and (car (symbol-value refs))
4240 (car (symbol-value refs)) thread))
4241 (cdr (symbol-value refs)))))))
4244 (unless (car (symbol-value refs))
4245 ;; These threads do not refer back to any other
4246 ;; articles, so they're roots.
4247 (setq threads (append (cdr (symbol-value refs)) threads))))
4248 gnus-newsgroup-dependencies)))
4251 ;; Build the thread tree.
4252 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4253 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4255 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4256 if it was already present.
4258 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4259 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4260 Message-IDs will be renamed to a unique Message-ID before being
4263 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4264 (let* ((id (mail-header-id header))
4265 (id-dep (and id (intern id dependencies)))
4266 parent-id ref ref-dep ref-header replaced)
4267 ;; Enter this `header' in the `dependencies' table.
4271 ;; The first two cases do the normal part: enter a new `header'
4272 ;; in the `dependencies' table.
4273 ((not (boundp id-dep))
4274 (set id-dep (list header)))
4275 ((null (car (symbol-value id-dep)))
4276 (setcar (symbol-value id-dep) header))
4278 ;; From here the `header' was already present in the
4279 ;; `dependencies' table.
4281 ;; Overrides an existing entry;
4282 ;; just set the header part of the entry.
4283 (setcar (symbol-value id-dep) header)
4286 ;; Renames the existing `header' to a unique Message-ID.
4287 ((not gnus-summary-ignore-duplicates)
4288 ;; An article with this Message-ID has already been seen.
4289 ;; We rename the Message-ID.
4290 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4292 (mail-header-set-id header id))
4294 ;; The last case ignores an existing entry, except it adds any
4295 ;; additional Xrefs (in case the two articles came from different
4297 ;; Also sets `header' to `nil' meaning that the `dependencies'
4298 ;; table was *not* modified.
4300 (mail-header-set-xref
4301 (car (symbol-value id-dep))
4302 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4304 (or (mail-header-xref header) "")))
4307 (when (and header (not replaced))
4308 ;; First check that we are not creating a References loop.
4309 (setq parent-id (gnus-parent-id (mail-header-references header)))
4310 (setq ref parent-id)
4312 (setq ref-dep (intern-soft ref dependencies))
4314 (setq ref-header (car (symbol-value ref-dep))))
4315 (if (string= id ref)
4316 ;; Yuk! This is a reference loop. Make the article be a
4319 (mail-header-set-references (car (symbol-value id-dep)) "none")
4321 (setq parent-id nil))
4322 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4323 (setq ref-dep (intern (or parent-id "none") dependencies))
4324 (if (boundp ref-dep)
4325 (setcdr (symbol-value ref-dep)
4326 (nconc (cdr (symbol-value ref-dep))
4327 (list (symbol-value id-dep))))
4328 (set ref-dep (list nil (symbol-value id-dep)))))
4331 (defun gnus-extract-message-id-from-in-reply-to (string)
4332 (if (string-match "<[^>]+>" string)
4333 (substring string (match-beginning 0) (match-end 0))
4336 (defun gnus-build-sparse-threads ()
4337 (let ((headers gnus-newsgroup-headers)
4338 (mail-parse-charset gnus-newsgroup-charset)
4339 (gnus-summary-ignore-duplicates t)
4340 header references generation relations
4341 subject child end new-child date)
4342 ;; First we create an alist of generations/relations, where
4343 ;; generations is how much we trust the relation, and the relation
4345 (gnus-message 7 "Making sparse threads...")
4347 (nnheader-set-temp-buffer " *gnus sparse threads*")
4348 (while (setq header (pop headers))
4349 (when (and (setq references (mail-header-references header))
4350 (not (string= references "")))
4352 (setq child (mail-header-id header)
4353 subject (mail-header-subject header)
4354 date (mail-header-date header)
4356 (while (search-backward ">" nil t)
4357 (setq end (1+ (point)))
4358 (when (search-backward "<" nil t)
4359 (setq new-child (buffer-substring (point) end))
4360 (push (list (incf generation)
4361 child (setq child new-child)
4365 (push (list (1+ generation) child nil subject) relations))
4367 (kill-buffer (current-buffer)))
4368 ;; Sort over trustworthiness.
4369 (dolist (relation (sort relations 'car-less-than-car))
4370 (when (gnus-dependencies-add-header
4371 (make-full-mail-header
4372 gnus-reffed-article-number
4373 (nth 3 relation) "" (or (nth 4 relation) "")
4375 (or (nth 2 relation) "") 0 0 "")
4376 gnus-newsgroup-dependencies nil)
4377 (push gnus-reffed-article-number gnus-newsgroup-limit)
4378 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4379 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4380 gnus-newsgroup-reads)
4381 (decf gnus-reffed-article-number)))
4382 (gnus-message 7 "Making sparse threads...done")))
4384 (defun gnus-build-old-threads ()
4385 ;; Look at all the articles that refer back to old articles, and
4386 ;; fetch the headers for the articles that aren't there. This will
4387 ;; build complete threads - if the roots haven't been expired by the
4389 (let ((mail-parse-charset gnus-newsgroup-charset)
4393 (when (not (car (symbol-value refs)))
4394 (setq heads (cdr (symbol-value refs)))
4396 (if (memq (mail-header-number (caar heads))
4397 gnus-newsgroup-dormant)
4398 (setq heads (cdr heads))
4399 (setq id (symbol-name refs))
4400 (while (and (setq id (gnus-build-get-header id))
4401 (not (car (gnus-id-to-thread id)))))
4402 (setq heads nil)))))
4403 gnus-newsgroup-dependencies)))
4405 (defsubst gnus-remove-odd-characters (string)
4406 "Translate STRING into something that doesn't contain weird characters."
4407 (mm-subst-char-in-string
4409 (mm-subst-char-in-string ?\n ?\- string t) t))
4411 ;; This function has to be called with point after the article number
4412 ;; on the beginning of the line.
4413 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4414 (let ((eol (point-at-eol))
4415 (buffer (current-buffer))
4416 header references in-reply-to)
4418 ;; overview: [num subject from date id refs chars lines misc]
4421 (narrow-to-region (point) eol)
4426 (make-full-mail-header
4428 (condition-case () ; subject
4429 (gnus-remove-odd-characters
4430 (funcall gnus-decode-encoded-word-function
4431 (setq x (nnheader-nov-field))))
4433 (condition-case () ; from
4434 (gnus-remove-odd-characters
4435 (funcall gnus-decode-encoded-address-function
4436 (setq x (nnheader-nov-field))))
4438 (nnheader-nov-field) ; date
4439 (nnheader-nov-read-message-id number) ; id
4440 (setq references (nnheader-nov-field)) ; refs
4441 (nnheader-nov-read-integer) ; chars
4442 (nnheader-nov-read-integer) ; lines
4444 (if (looking-at "Xref: ")
4445 (goto-char (match-end 0)))
4446 (nnheader-nov-field)) ; Xref
4447 (nnheader-nov-parse-extra)))) ; extra
4451 (when (and (string= references "")
4452 (setq in-reply-to (mail-header-extra header))
4453 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4454 (mail-header-set-references
4455 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4457 (when gnus-alter-header-function
4458 (funcall gnus-alter-header-function header))
4459 (gnus-dependencies-add-header header dependencies force-new)))
4461 (defun gnus-build-get-header (id)
4462 "Look through the buffer of NOV lines and find the header to ID.
4463 Enter this line into the dependencies hash table, and return
4464 the id of the parent article (if any)."
4465 (let ((deps gnus-newsgroup-dependencies)
4468 (with-current-buffer nntp-server-buffer
4469 (let ((case-fold-search nil))
4470 (goto-char (point-min))
4471 (while (and (not found)
4472 (search-forward id nil t))
4474 (setq found (looking-at
4475 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4476 (regexp-quote id))))
4477 (or found (beginning-of-line 2)))
4481 (setq header (gnus-nov-parse-line
4482 (read (current-buffer)) deps))
4483 (gnus-parent-id (mail-header-references header))))))
4485 (let ((number (mail-header-number header)))
4486 (push number gnus-newsgroup-limit)
4487 (push header gnus-newsgroup-headers)
4488 (if (memq number gnus-newsgroup-unselected)
4490 (setq gnus-newsgroup-unreads
4491 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4493 (setq gnus-newsgroup-unselected
4494 (delq number gnus-newsgroup-unselected)))
4495 (push number gnus-newsgroup-ancient)))))))
4497 (defun gnus-build-all-threads ()
4498 "Read all the headers."
4499 (let ((gnus-summary-ignore-duplicates t)
4500 (mail-parse-charset gnus-newsgroup-charset)
4501 (dependencies gnus-newsgroup-dependencies)
4503 (with-current-buffer nntp-server-buffer
4504 (let ((case-fold-search nil))
4505 (goto-char (point-min))
4508 (setq article (read (current-buffer))
4509 header (gnus-nov-parse-line article dependencies)))
4511 (with-current-buffer gnus-summary-buffer
4512 (push header gnus-newsgroup-headers)
4513 (if (memq (setq article (mail-header-number header))
4514 gnus-newsgroup-unselected)
4516 (setq gnus-newsgroup-unreads
4517 (gnus-add-to-sorted-list
4518 gnus-newsgroup-unreads article))
4519 (setq gnus-newsgroup-unselected
4520 (delq article gnus-newsgroup-unselected)))
4521 (push article gnus-newsgroup-ancient)))
4522 (forward-line 1)))))))
4524 (defun gnus-summary-update-article-line (article header)
4525 "Update the line for ARTICLE using HEADER."
4526 (let* ((id (mail-header-id header))
4527 (thread (gnus-id-to-thread id)))
4529 (error "Article in no thread"))
4530 ;; Update the thread.
4531 (setcar thread header)
4532 (gnus-summary-goto-subject article)
4533 (let* ((datal (gnus-data-find-list article))
4535 (inhibit-read-only t)
4536 (level (gnus-summary-thread-level)))
4538 (let ((inserted (- (point)
4540 (gnus-summary-insert-line
4542 (memq article gnus-newsgroup-undownloaded)
4543 (gnus-article-mark article)
4544 (memq article gnus-newsgroup-replied)
4545 (memq article gnus-newsgroup-expirable)
4546 ;; Only insert the Subject string when it's different
4547 ;; from the previous Subject string.
4552 (mail-header-subject
4555 (gnus-data-find-list
4557 (gnus-data-list t)))))
4558 ;; Error on the side of excessive subjects.
4560 (mail-header-subject header)))
4562 (mail-header-subject header))
4563 nil (cdr (assq article gnus-newsgroup-scored))
4564 (memq article gnus-newsgroup-processable))
4567 (gnus-data-update-list
4569 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4571 (defun gnus-summary-update-article (article &optional iheader)
4572 "Update ARTICLE in the summary buffer."
4573 (set-buffer gnus-summary-buffer)
4574 (let* ((header (gnus-summary-article-header article))
4575 (id (mail-header-id header))
4576 (data (gnus-data-find article))
4577 (thread (gnus-id-to-thread id))
4578 (references (mail-header-references header))
4582 (when (and references
4583 (not (equal "" references)))
4586 (inhibit-read-only t)
4592 (delq thread parent)))
4593 (if (gnus-summary-insert-subject id header)
4594 ;; Set the (possibly) new article number in the data structure.
4595 (gnus-data-set-number data (gnus-id-to-article id))
4599 (defun gnus-rebuild-thread (id &optional line)
4600 "Rebuild the thread containing ID.
4601 If LINE, insert the rebuilt thread starting on line LINE."
4602 (let ((inhibit-read-only t)
4603 old-pos current thread data)
4604 (if (not gnus-show-threads)
4605 (setq thread (list (car (gnus-id-to-thread id))))
4606 ;; Get the thread this article is part of.
4607 (setq thread (gnus-remove-thread id)))
4608 (setq old-pos (point-at-bol))
4609 (setq current (save-excursion
4610 (and (re-search-backward "[\r\n]" nil t)
4611 (gnus-summary-article-number))))
4612 ;; If this is a gathered thread, we have to go some re-gathering.
4613 (when (stringp (car thread))
4614 (let ((subject (car thread))
4616 (setq thread (cdr thread))
4618 (unless (memq (setq thr (gnus-id-to-thread
4620 (mail-header-id (caar thread)))))
4623 (setq thread (cdr thread)))
4624 ;; We now have all (unique) roots.
4625 (if (= (length roots) 1)
4626 ;; All the loose roots are now one solid root.
4627 (setq thread (car roots))
4628 (setq thread (cons subject (gnus-sort-threads roots))))))
4630 ;; We then insert this thread into the summary buffer.
4632 (goto-char (point-min))
4633 (forward-line (1- line)))
4634 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4635 (if gnus-show-threads
4636 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4637 (gnus-summary-prepare-unthreaded thread))
4638 (setq data (nreverse gnus-newsgroup-data))
4639 (setq threads gnus-newsgroup-threads))
4640 ;; We splice the new data into the data structure.
4641 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4642 ;;!!! then we want to insert at the beginning of the buffer.
4643 ;;!!! That happens to be true with Gnus now, but that may
4644 ;;!!! change in the future. Perhaps.
4645 (gnus-data-enter-list
4646 (if line nil current) data (- (point) old-pos))
4647 (setq gnus-newsgroup-threads
4648 (nconc threads gnus-newsgroup-threads))
4649 (gnus-data-compute-positions))))
4651 (defun gnus-number-to-header (number)
4652 "Return the header for article NUMBER."
4653 (let ((headers gnus-newsgroup-headers))
4655 (not (= number (mail-header-number (car headers)))))
4660 (defun gnus-parent-headers (in-headers &optional generation)
4661 "Return the headers of the GENERATIONeth parent of HEADERS."
4663 (setq generation 1))
4665 (headers in-headers)
4668 (not (zerop generation))
4669 (setq references (mail-header-references headers)))
4670 (setq headers (if (and references
4671 (setq parent (gnus-parent-id references)))
4672 (car (gnus-id-to-thread parent))
4675 (and (not (eq headers in-headers))
4678 (defun gnus-id-to-thread (id)
4679 "Return the (sub-)thread where ID appears."
4680 (gnus-gethash id gnus-newsgroup-dependencies))
4682 (defun gnus-id-to-article (id)
4683 "Return the article number of ID."
4684 (let ((thread (gnus-id-to-thread id)))
4687 (mail-header-number (car thread)))))
4689 (defun gnus-id-to-header (id)
4690 "Return the article headers of ID."
4691 (car (gnus-id-to-thread id)))
4693 (defun gnus-article-displayed-root-p (article)
4694 "Say whether ARTICLE is a root(ish) article."
4695 (let ((level (gnus-summary-thread-level article))
4696 (refs (mail-header-references (gnus-summary-article-header article)))
4702 ((null (gnus-parent-id refs)) t)
4704 (null (setq particle (gnus-id-to-article
4705 (gnus-parent-id refs))))
4706 (null (gnus-summary-thread-level particle)))))))
4708 (defun gnus-root-id (id)
4709 "Return the id of the root of the thread where ID appears."
4711 (while (and id (setq prev (car (gnus-id-to-thread id))))
4713 id (gnus-parent-id (mail-header-references prev))))
4716 (defun gnus-articles-in-thread (thread)
4717 "Return the list of articles in THREAD."
4718 (cons (mail-header-number (car thread))
4719 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4721 (defun gnus-remove-thread (id &optional dont-remove)
4722 "Remove the thread that has ID in it."
4723 (let (headers thread last-id)
4724 ;; First go up in this thread until we find the root.
4725 (setq last-id (gnus-root-id id)
4726 headers (message-flatten-list (gnus-id-to-thread last-id)))
4727 ;; We have now found the real root of this thread. It might have
4728 ;; been gathered into some loose thread, so we have to search
4729 ;; through the threads to find the thread we wanted.
4730 (let ((threads gnus-newsgroup-threads)
4733 (setq sub (car threads))
4734 (if (stringp (car sub))
4735 ;; This is a gathered thread, so we look at the roots
4736 ;; below it to find whether this article is in this
4739 (setq sub (cdr sub))
4741 (when (member (caar sub) headers)
4742 (setq thread (car threads)
4745 (setq sub (cdr sub))))
4746 ;; It's an ordinary thread, so we check it.
4747 (when (eq (car sub) (car headers))
4750 (setq threads (cdr threads)))
4751 ;; If this article is in no thread, then it's a root.
4754 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4755 (setq thread (gnus-id-to-thread last-id)))
4758 thread ; We return this thread.
4760 (if (stringp (car thread))
4762 ;; If we use dummy roots, then we have to remove the
4763 ;; dummy root as well.
4764 (when (eq gnus-summary-make-false-root 'dummy)
4765 ;; We go to the dummy root by going to
4766 ;; the first sub-"thread", and then one line up.
4767 (gnus-summary-goto-article
4768 (mail-header-number (caadr thread)))
4771 (gnus-data-compute-positions))
4772 (setq thread (cdr thread))
4774 (gnus-remove-thread-1 (car thread))
4775 (setq thread (cdr thread))))
4776 (gnus-remove-thread-1 thread))))))))
4778 (defun gnus-remove-thread-1 (thread)
4779 "Remove the thread THREAD recursively."
4780 (let ((number (mail-header-number (pop thread)))
4782 (setq thread (reverse thread))
4784 (gnus-remove-thread-1 (pop thread)))
4785 (when (setq d (gnus-data-find number))
4786 (goto-char (gnus-data-pos d))
4787 (gnus-summary-show-thread)
4793 (gnus-delete-line)))))))
4795 (defun gnus-sort-threads-recursive (threads func)
4796 (sort (mapcar (lambda (thread)
4799 (gnus-sort-threads-recursive (cdr thread) func))))
4802 (defun gnus-sort-threads-loop (threads func)
4803 (let* ((superthread (cons nil threads))
4804 (stack (list (cons superthread threads)))
4805 remaining-threads thread)
4807 (setq remaining-threads (cdr (car stack)))
4808 (if remaining-threads
4809 (progn (setq thread (car remaining-threads))
4810 (setcdr (car stack) (cdr remaining-threads))
4812 (push (cons thread (cdr thread)) stack)))
4813 (setq thread (caar stack))
4814 (setcdr thread (sort (cdr thread) func))
4818 (defun gnus-sort-threads (threads)
4820 (if (not gnus-thread-sort-functions)
4822 (gnus-message 8 "Sorting threads...")
4825 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4826 (gnus-sort-threads-recursive
4827 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4828 ;; Even after binding max-lisp-eval-depth, the recursive
4829 ;; sorter might fail for very long threads. In that case,
4830 ;; try using a (less well-tested) non-recursive sorter.
4831 (error (gnus-message 9 "Sorting threads with loop...")
4832 (gnus-sort-threads-loop
4833 threads (gnus-make-sort-function
4834 gnus-thread-sort-functions))))
4835 (gnus-message 8 "Sorting threads...done"))))
4837 (defun gnus-sort-articles (articles)
4839 (when gnus-article-sort-functions
4840 (gnus-message 7 "Sorting articles...")
4842 (setq gnus-newsgroup-headers
4843 (sort articles (gnus-make-sort-function
4844 gnus-article-sort-functions)))
4845 (gnus-message 7 "Sorting articles...done"))))
4847 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4848 (defmacro gnus-thread-header (thread)
4849 "Return header of first article in THREAD.
4850 Note that THREAD must never, ever be anything else than a variable -
4851 using some other form will lead to serious barfage."
4852 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4853 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4854 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4857 (defsubst gnus-article-sort-by-number (h1 h2)
4858 "Sort articles by article number."
4859 (< (mail-header-number h1)
4860 (mail-header-number h2)))
4862 (defun gnus-thread-sort-by-number (h1 h2)
4863 "Sort threads by root article number."
4864 (gnus-article-sort-by-number
4865 (gnus-thread-header h1) (gnus-thread-header h2)))
4867 (defsubst gnus-article-sort-by-random (h1 h2)
4868 "Sort articles randomly."
4871 (defun gnus-thread-sort-by-random (h1 h2)
4872 "Sort threads randomly."
4873 (gnus-article-sort-by-random
4874 (gnus-thread-header h1) (gnus-thread-header h2)))
4876 (defsubst gnus-article-sort-by-lines (h1 h2)
4877 "Sort articles by article Lines header."
4878 (< (mail-header-lines h1)
4879 (mail-header-lines h2)))
4881 (defun gnus-thread-sort-by-lines (h1 h2)
4882 "Sort threads by root article Lines header."
4883 (gnus-article-sort-by-lines
4884 (gnus-thread-header h1) (gnus-thread-header h2)))
4886 (defsubst gnus-article-sort-by-chars (h1 h2)
4887 "Sort articles by octet length."
4888 (< (mail-header-chars h1)
4889 (mail-header-chars h2)))
4891 (defun gnus-thread-sort-by-chars (h1 h2)
4892 "Sort threads by root article octet length."
4893 (gnus-article-sort-by-chars
4894 (gnus-thread-header h1) (gnus-thread-header h2)))
4896 (defsubst gnus-article-sort-by-author (h1 h2)
4897 "Sort articles by root author."
4899 (let ((extract (funcall
4900 gnus-extract-address-components
4901 (mail-header-from h1))))
4902 (or (car extract) (cadr extract) ""))
4903 (let ((extract (funcall
4904 gnus-extract-address-components
4905 (mail-header-from h2))))
4906 (or (car extract) (cadr extract) ""))))
4908 (defun gnus-thread-sort-by-author (h1 h2)
4909 "Sort threads by root author."
4910 (gnus-article-sort-by-author
4911 (gnus-thread-header h1) (gnus-thread-header h2)))
4913 (defsubst gnus-article-sort-by-recipient (h1 h2)
4914 "Sort articles by recipient."
4916 (let ((extract (funcall
4917 gnus-extract-address-components
4918 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4919 (or (car extract) (cadr extract)))
4920 (let ((extract (funcall
4921 gnus-extract-address-components
4922 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4923 (or (car extract) (cadr extract)))))
4925 (defun gnus-thread-sort-by-recipient (h1 h2)
4926 "Sort threads by root recipient."
4927 (gnus-article-sort-by-recipient
4928 (gnus-thread-header h1) (gnus-thread-header h2)))
4930 (defsubst gnus-article-sort-by-subject (h1 h2)
4931 "Sort articles by root subject."
4933 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4934 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4936 (defun gnus-thread-sort-by-subject (h1 h2)
4937 "Sort threads by root subject."
4938 (gnus-article-sort-by-subject
4939 (gnus-thread-header h1) (gnus-thread-header h2)))
4941 (defsubst gnus-article-sort-by-date (h1 h2)
4942 "Sort articles by root article date."
4944 (gnus-date-get-time (mail-header-date h1))
4945 (gnus-date-get-time (mail-header-date h2))))
4947 (defun gnus-thread-sort-by-date (h1 h2)
4948 "Sort threads by root article date."
4949 (gnus-article-sort-by-date
4950 (gnus-thread-header h1) (gnus-thread-header h2)))
4952 (defsubst gnus-article-sort-by-score (h1 h2)
4953 "Sort articles by root article score.
4954 Unscored articles will be counted as having a score of zero."
4955 (> (or (cdr (assq (mail-header-number h1)
4956 gnus-newsgroup-scored))
4957 gnus-summary-default-score 0)
4958 (or (cdr (assq (mail-header-number h2)
4959 gnus-newsgroup-scored))
4960 gnus-summary-default-score 0)))
4962 (defun gnus-thread-sort-by-score (h1 h2)
4963 "Sort threads by root article score."
4964 (gnus-article-sort-by-score
4965 (gnus-thread-header h1) (gnus-thread-header h2)))
4967 (defun gnus-thread-sort-by-total-score (h1 h2)
4968 "Sort threads by the sum of all scores in the thread.
4969 Unscored articles will be counted as having a score of zero."
4970 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4972 (defun gnus-thread-total-score (thread)
4973 ;; This function find the total score of THREAD.
4978 (if (stringp (car thread))
4979 (apply gnus-thread-score-function 0
4980 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4981 (gnus-thread-total-score-1 thread)))
4983 (gnus-thread-total-score-1 (list thread)))))
4985 (defun gnus-article-sort-by-most-recent-number (h1 h2)
4986 "Sort articles by number."
4987 (gnus-article-sort-by-number h1 h2))
4989 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4990 "Sort threads such that the thread with the most recently arrived article comes first."
4991 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4993 (defun gnus-thread-highest-number (thread)
4994 "Return the highest article number in THREAD."
4995 (apply 'max (mapcar (lambda (header)
4996 (mail-header-number header))
4997 (message-flatten-list thread))))
4999 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5000 "Sort articles by number."
5001 (gnus-article-sort-by-date h1 h2))
5003 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5004 "Sort threads such that the thread with the most recently dated article comes first."
5005 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5007 ; Since this is called not only to sort the top-level threads, but
5008 ; also in recursive sorts to order the articles within a thread, each
5009 ; article will be processed many times. Thus it speeds things up
5010 ; quite a bit to use gnus-date-get-time, which caches the time value.
5011 (defun gnus-thread-latest-date (thread)
5012 "Return the highest article date in THREAD."
5014 (mapcar (lambda (header) (gnus-float-time
5016 (mail-header-date header))))
5017 (message-flatten-list thread))))
5019 (defun gnus-thread-total-score-1 (root)
5020 ;; This function find the total score of the thread below ROOT.
5021 (setq root (car root))
5022 (apply gnus-thread-score-function
5024 (mapcar 'gnus-thread-total-score
5025 (cdr (gnus-id-to-thread (mail-header-id root))))
5026 (when (> (mail-header-number root) 0)
5027 (list (or (cdr (assq (mail-header-number root)
5028 gnus-newsgroup-scored))
5029 gnus-summary-default-score 0))))
5030 (list gnus-summary-default-score)
5033 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5034 (defvar gnus-tmp-prev-subject nil)
5035 (defvar gnus-tmp-false-parent nil)
5036 (defvar gnus-tmp-root-expunged nil)
5037 (defvar gnus-tmp-dummy-line nil)
5039 (defun gnus-extra-header (type &optional header)
5040 "Return the extra header of TYPE."
5041 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5044 (defvar gnus-tmp-thread-tree-header-string "")
5046 (defcustom gnus-sum-thread-tree-root "> "
5047 "With %B spec, used for the root of a thread.
5048 If nil, use subject instead."
5050 :type '(radio (const :format "%v " nil) string)
5051 :group 'gnus-thread)
5053 (defcustom gnus-sum-thread-tree-false-root "> "
5054 "With %B spec, used for a false root of a thread.
5055 If nil, use subject instead."
5057 :type '(radio (const :format "%v " nil) string)
5058 :group 'gnus-thread)
5060 (defcustom gnus-sum-thread-tree-single-indent ""
5061 "With %B spec, used for a thread with just one message.
5062 If nil, use subject instead."
5064 :type '(radio (const :format "%v " nil) string)
5065 :group 'gnus-thread)
5067 (defcustom gnus-sum-thread-tree-vertical "| "
5068 "With %B spec, used for drawing a vertical line."
5071 :group 'gnus-thread)
5073 (defcustom gnus-sum-thread-tree-indent " "
5074 "With %B spec, used for indenting."
5077 :group 'gnus-thread)
5079 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5080 "With %B spec, used for a leaf with brothers."
5083 :group 'gnus-thread)
5085 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5086 "With %B spec, used for a leaf without brothers."
5089 :group 'gnus-thread)
5091 (defcustom gnus-summary-display-while-building nil
5092 "If non-nil, show and update the summary buffer as it's being built.
5093 If the value is t, update the buffer after every line is inserted. If
5094 the value is an integer (N), update the display every N lines."
5097 :type '(choice (const :tag "off" nil)
5099 (const :tag "frequently" t)))
5101 (defun gnus-summary-prepare-threads (threads)
5102 "Prepare summary buffer from THREADS and indentation LEVEL.
5103 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5104 or a straight list of headers."
5105 (gnus-message 7 "Generating summary...")
5107 (setq gnus-newsgroup-threads threads)
5110 (let ((gnus-tmp-level 0)
5111 (default-score (or gnus-summary-default-score 0))
5112 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5113 (building-line-count gnus-summary-display-while-building)
5114 (building-count (integerp gnus-summary-display-while-building))
5115 thread number subject stack state gnus-tmp-gathered beg-match
5116 new-roots gnus-tmp-new-adopts thread-end simp-subject
5117 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5118 gnus-tmp-replied gnus-tmp-subject-or-nil
5119 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5120 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5121 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5124 (setq gnus-tmp-prev-subject nil
5125 gnus-tmp-thread-tree-header-string "")
5127 (if (vectorp (car threads))
5128 ;; If this is a straight (sic) list of headers, then a
5129 ;; threaded summary display isn't required, so we just create
5130 ;; an unthreaded one.
5131 (gnus-summary-prepare-unthreaded threads)
5133 ;; Do the threaded display.
5135 (if gnus-summary-display-while-building
5136 (switch-to-buffer (buffer-name)))
5137 (while (or threads stack gnus-tmp-new-adopts new-roots)
5139 (if (and (= gnus-tmp-level 0)
5142 (not gnus-tmp-false-parent)
5143 (or gnus-tmp-new-adopts new-roots))
5144 (if gnus-tmp-new-adopts
5145 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5146 thread (list (car gnus-tmp-new-adopts))
5147 gnus-tmp-header (caar thread)
5148 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5150 (setq thread (list (car new-roots))
5151 gnus-tmp-header (caar thread)
5152 new-roots (cdr new-roots))))
5155 ;; If there are some threads, we do them before the
5156 ;; threads on the stack.
5157 (setq thread threads
5158 gnus-tmp-header (caar thread))
5159 ;; There were no current threads, so we pop something off
5161 (setq state (car stack)
5162 gnus-tmp-level (car state)
5163 tree-stack (cadr state)
5164 thread (caddr state)
5166 gnus-tmp-header (caar thread))))
5168 (setq gnus-tmp-false-parent nil)
5169 (setq gnus-tmp-root-expunged nil)
5170 (setq thread-end nil)
5172 (if (stringp gnus-tmp-header)
5173 ;; The header is a dummy root.
5175 ((eq gnus-summary-make-false-root 'adopt)
5176 ;; We let the first article adopt the rest.
5177 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5179 (setq gnus-tmp-gathered
5181 (lambda (h) (mail-header-number (car h)))
5184 (setq thread (cons (list (caar thread)
5187 (setq gnus-tmp-level -1
5188 gnus-tmp-false-parent t))
5189 ((eq gnus-summary-make-false-root 'empty)
5190 ;; We print adopted articles with empty subject fields.
5191 (setq gnus-tmp-gathered
5193 (lambda (h) (mail-header-number (car h)))
5196 (setq gnus-tmp-level -1))
5197 ((eq gnus-summary-make-false-root 'dummy)
5198 ;; We remember that we probably want to output a dummy
5200 (setq gnus-tmp-dummy-line gnus-tmp-header)
5201 (setq gnus-tmp-prev-subject gnus-tmp-header))
5203 ;; We do not make a root for the gathered
5204 ;; sub-threads at all.
5205 (setq gnus-tmp-level -1)))
5207 (setq number (mail-header-number gnus-tmp-header)
5208 subject (mail-header-subject gnus-tmp-header)
5209 simp-subject (gnus-simplify-subject-fully subject))
5212 ;; If the thread has changed subject, we might want to make
5213 ;; this subthread into a root.
5214 ((and (null gnus-thread-ignore-subject)
5215 (not (zerop gnus-tmp-level))
5216 gnus-tmp-prev-subject
5217 (not (string= gnus-tmp-prev-subject simp-subject)))
5218 (setq new-roots (nconc new-roots (list (car thread)))
5220 gnus-tmp-header nil))
5221 ;; If the article lies outside the current limit,
5222 ;; then we do not display it.
5223 ((not (memq number gnus-newsgroup-limit))
5224 (setq gnus-tmp-gathered
5226 (lambda (h) (mail-header-number (car h)))
5229 (setq gnus-tmp-new-adopts (if (cdar thread)
5230 (append gnus-tmp-new-adopts
5232 gnus-tmp-new-adopts)
5234 gnus-tmp-header nil)
5235 (when (zerop gnus-tmp-level)
5236 (setq gnus-tmp-root-expunged t)))
5237 ;; Perhaps this article is to be marked as read?
5238 ((and gnus-summary-mark-below
5239 (< (or (cdr (assq number gnus-newsgroup-scored))
5241 gnus-summary-mark-below)
5242 ;; Don't touch sparse articles.
5243 (not (gnus-summary-article-sparse-p number))
5244 (not (gnus-summary-article-ancient-p number)))
5245 (setq gnus-newsgroup-unreads
5246 (delq number gnus-newsgroup-unreads))
5247 (if gnus-newsgroup-auto-expire
5248 (setq gnus-newsgroup-expirable
5249 (gnus-add-to-sorted-list
5250 gnus-newsgroup-expirable number))
5251 (push (cons number gnus-low-score-mark)
5252 gnus-newsgroup-reads))))
5254 (when gnus-tmp-header
5255 ;; We may have an old dummy line to output before this
5257 (when (and gnus-tmp-dummy-line
5260 (mail-header-subject gnus-tmp-header)))
5261 (gnus-summary-insert-dummy-line
5262 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5263 (setq gnus-tmp-dummy-line nil))
5265 ;; Compute the mark.
5266 (setq gnus-tmp-unread (gnus-article-mark number))
5268 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5269 gnus-tmp-header gnus-tmp-level)
5270 gnus-newsgroup-data)
5272 ;; Actually insert the line.
5274 gnus-tmp-subject-or-nil
5276 ((and gnus-thread-ignore-subject
5277 gnus-tmp-prev-subject
5278 (not (string= gnus-tmp-prev-subject simp-subject)))
5280 ((zerop gnus-tmp-level)
5281 (if (and (eq gnus-summary-make-false-root 'empty)
5282 (memq number gnus-tmp-gathered)
5283 gnus-tmp-prev-subject
5284 (string= gnus-tmp-prev-subject simp-subject))
5285 gnus-summary-same-subject
5287 (t gnus-summary-same-subject)))
5288 (if (and (eq gnus-summary-make-false-root 'adopt)
5289 (= gnus-tmp-level 1)
5290 (memq number gnus-tmp-gathered))
5291 (setq gnus-tmp-opening-bracket ?\<
5292 gnus-tmp-closing-bracket ?\>)
5293 (setq gnus-tmp-opening-bracket ?\[
5294 gnus-tmp-closing-bracket ?\]))
5295 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5296 (gnus-make-thread-indent-array
5297 (max (* 2 (length gnus-thread-indent-array))
5300 gnus-tmp-indentation
5301 (aref gnus-thread-indent-array gnus-tmp-level)
5302 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5303 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5304 gnus-summary-default-score 0)
5306 (if (or (null gnus-summary-default-score)
5307 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5308 gnus-summary-zcore-fuzz))
5310 (if (< gnus-tmp-score gnus-summary-default-score)
5311 gnus-score-below-mark gnus-score-over-mark))
5313 (cond ((memq number gnus-newsgroup-processable)
5315 ((memq number gnus-newsgroup-cached)
5317 ((memq number gnus-newsgroup-replied)
5319 ((memq number gnus-newsgroup-forwarded)
5320 gnus-forwarded-mark)
5321 ((memq number gnus-newsgroup-saved)
5323 ((memq number gnus-newsgroup-recent)
5325 ((memq number gnus-newsgroup-unseen)
5329 (cond ((memq number gnus-newsgroup-undownloaded)
5330 gnus-undownloaded-mark)
5331 (gnus-newsgroup-agentized
5332 gnus-downloaded-mark)
5335 gnus-tmp-from (mail-header-from gnus-tmp-header)
5338 ((string-match "<[^>]+> *$" gnus-tmp-from)
5339 (setq beg-match (match-beginning 0))
5340 (or (and (string-match "^\".+\"" gnus-tmp-from)
5341 (substring gnus-tmp-from 1 (1- (match-end 0))))
5342 (substring gnus-tmp-from 0 beg-match)))
5343 ((string-match "(.+)" gnus-tmp-from)
5344 (substring gnus-tmp-from
5345 (1+ (match-beginning 0)) (1- (match-end 0))))
5349 gnus-tmp-thread-tree-header-string
5351 ((not gnus-show-threads) "")
5352 ((zerop gnus-tmp-level)
5353 (cond ((cdar thread)
5354 (or gnus-sum-thread-tree-root subject))
5355 (gnus-tmp-new-adopts
5356 (or gnus-sum-thread-tree-false-root subject))
5358 (or gnus-sum-thread-tree-single-indent subject))))
5360 (concat (apply 'concat
5361 (mapcar (lambda (item)
5363 gnus-sum-thread-tree-vertical
5364 gnus-sum-thread-tree-indent))
5365 (cdr (reverse tree-stack))))
5367 gnus-sum-thread-tree-leaf-with-other
5368 gnus-sum-thread-tree-single-leaf)))))
5369 (when (string= gnus-tmp-name "")
5370 (setq gnus-tmp-name gnus-tmp-from))
5371 (unless (numberp gnus-tmp-lines)
5372 (setq gnus-tmp-lines -1))
5373 (if (= gnus-tmp-lines -1)
5374 (setq gnus-tmp-lines "?")
5375 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5376 (gnus-put-text-property
5378 (progn (eval gnus-summary-line-format-spec) (point))
5379 'gnus-number number)
5382 (gnus-summary-highlight-line)
5383 (when gnus-summary-update-hook
5384 (gnus-run-hooks 'gnus-summary-update-hook))
5387 (setq gnus-tmp-prev-subject simp-subject)))
5389 (when (nth 1 thread)
5390 (push (list (max 0 gnus-tmp-level)
5391 (copy-sequence tree-stack)
5394 (push (if (nth 1 thread) 1 0) tree-stack)
5395 (incf gnus-tmp-level)
5396 (setq threads (if thread-end nil (cdar thread)))
5397 (if gnus-summary-display-while-building
5400 ;; use a set frequency
5401 (setq building-line-count (1- building-line-count))
5402 (when (= building-line-count 0)
5404 (setq building-line-count
5405 gnus-summary-display-while-building)))
5409 (setq gnus-tmp-level 0)))))
5410 (gnus-message 7 "Generating summary...done"))
5412 (defun gnus-summary-prepare-unthreaded (headers)
5413 "Generate an unthreaded summary buffer based on HEADERS."
5414 (let (header number mark)
5419 ;; We may have to root out some bad articles...
5420 (when (memq (setq number (mail-header-number
5421 (setq header (pop headers))))
5422 gnus-newsgroup-limit)
5423 ;; Mark article as read when it has a low score.
5424 (when (and gnus-summary-mark-below
5425 (< (or (cdr (assq number gnus-newsgroup-scored))
5426 gnus-summary-default-score 0)
5427 gnus-summary-mark-below)
5428 (not (gnus-summary-article-ancient-p number)))
5429 (setq gnus-newsgroup-unreads
5430 (delq number gnus-newsgroup-unreads))
5431 (if gnus-newsgroup-auto-expire
5432 (push number gnus-newsgroup-expirable)
5433 (push (cons number gnus-low-score-mark)
5434 gnus-newsgroup-reads)))
5436 (setq mark (gnus-article-mark number))
5437 (push (gnus-data-make number mark (1+ (point)) header 0)
5438 gnus-newsgroup-data)
5439 (gnus-summary-insert-line
5441 (memq number gnus-newsgroup-undownloaded)
5442 mark (memq number gnus-newsgroup-replied)
5443 (memq number gnus-newsgroup-expirable)
5444 (mail-header-subject header) nil
5445 (cdr (assq number gnus-newsgroup-scored))
5446 (memq number gnus-newsgroup-processable))))))
5448 (defun gnus-summary-remove-list-identifiers ()
5449 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5450 (let ((regexp (if (consp gnus-list-identifiers)
5451 (mapconcat 'identity gnus-list-identifiers " *\\|")
5452 gnus-list-identifiers))
5455 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5456 (dolist (header gnus-newsgroup-headers)
5457 (setq subject (mail-header-subject header)
5459 (while (string-match regexp subject)
5461 (concat (substring subject 0 (match-beginning 1))
5462 (substring subject (match-end 0)))
5465 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5467 (concat (substring subject 0 (match-beginning 1))
5468 (substring subject (match-end 1)))))
5469 (mail-header-set-subject header subject))))))
5471 (defun gnus-fetch-headers (articles)
5472 "Fetch headers of ARTICLES."
5473 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5474 (gnus-message 5 "Fetching headers for %s..." name)
5477 (setq gnus-headers-retrieved-by
5478 (gnus-retrieve-headers
5479 articles gnus-newsgroup-name
5480 ;; We might want to fetch old headers, but
5481 ;; not if there is only 1 article.
5483 (not (eq gnus-fetch-old-headers 'some))
5484 (not (numberp gnus-fetch-old-headers)))
5485 (> (length articles) 1))
5486 gnus-fetch-old-headers))))
5487 (gnus-get-newsgroup-headers-xover
5488 articles nil nil gnus-newsgroup-name t)
5489 (gnus-get-newsgroup-headers))
5490 (gnus-message 5 "Fetching headers for %s...done" name))))
5492 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5493 "Select newsgroup GROUP.
5494 If READ-ALL is non-nil, all articles in the group are selected.
5495 If SELECT-ARTICLES, only select those articles from GROUP."
5496 (let* ((entry (gnus-group-entry group))
5497 ;;!!! Dirty hack; should be removed.
5498 (gnus-summary-ignore-duplicates
5499 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5501 gnus-summary-ignore-duplicates))
5502 (info (nth 2 entry))
5503 charset articles fetched-articles cached)
5505 (unless (gnus-check-server
5506 (set (make-local-variable 'gnus-current-select-method)
5507 (gnus-find-method-for-group group)))
5508 (error "Couldn't open server"))
5509 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5511 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5512 (gnus-activate-group group) ; Or we can activate it...
5513 (progn ; Or we bug out.
5514 (when (equal major-mode 'gnus-summary-mode)
5515 (gnus-kill-buffer (current-buffer)))
5517 "Couldn't activate group %s: %s"
5518 (mm-decode-coding-string group charset)
5519 (mm-decode-coding-string (gnus-status-message group) charset))))
5521 (unless (gnus-request-group group t)
5522 (when (equal major-mode 'gnus-summary-mode)
5523 (gnus-kill-buffer (current-buffer)))
5524 (error "Couldn't request group %s: %s"
5525 (mm-decode-coding-string group charset)
5526 (mm-decode-coding-string (gnus-status-message group) charset)))
5529 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5531 (setq gnus-summary-use-undownloaded-faces
5532 (gnus-agent-find-parameter
5534 'agent-enable-undownloaded-faces)))
5536 (setq gnus-newsgroup-name group
5537 gnus-newsgroup-unselected nil
5538 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5540 (let ((display (gnus-group-find-parameter group 'display)))
5541 (setq gnus-newsgroup-display
5543 ((not (zerop (or (car-safe read-all) 0)))
5544 ;; The user entered the group with C-u SPC/RET, let's show
5550 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5552 ;; The following is probably the "correct" solution, but
5553 ;; it makes Gnus fetch all headers and then limit the
5554 ;; articles (which is slow), so instead we hack the
5555 ;; select-articles parameter instead. -- Simon Josefsson
5558 ;; (gnus-byte-compile
5559 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5561 (setq select-articles
5562 (gnus-uncompress-range
5563 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5567 (cdr (gnus-active group)))))
5572 (gnus-summary-setup-default-charset)
5574 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5575 (when (gnus-virtual-group-p group)
5576 (setq cached gnus-newsgroup-cached))
5578 (setq gnus-newsgroup-unreads
5579 (gnus-sorted-ndifference
5580 (gnus-sorted-ndifference gnus-newsgroup-unreads
5581 gnus-newsgroup-marked)
5582 gnus-newsgroup-dormant))
5584 (setq gnus-newsgroup-processable nil)
5586 (gnus-update-read-articles group gnus-newsgroup-unreads)
5588 ;; Adjust and set lists of article marks.
5590 (gnus-adjust-marked-articles info))
5591 (if (setq articles select-articles)
5592 (setq gnus-newsgroup-unselected
5593 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5594 (setq articles (gnus-articles-to-read group read-all)))
5598 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5600 ((eq articles 0) nil)
5602 ;; Init the dependencies hash table.
5603 (setq gnus-newsgroup-dependencies
5604 (gnus-make-hashtable (length articles)))
5605 (gnus-set-global-variables)
5606 ;; Retrieve the headers and read them in.
5608 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5610 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5612 (setq gnus-newsgroup-cached cached))
5614 ;; Suppress duplicates?
5615 (when gnus-suppress-duplicates
5616 (gnus-dup-suppress-articles))
5618 ;; Set the initial limit.
5619 (setq gnus-newsgroup-limit (copy-sequence articles))
5620 ;; Remove canceled articles from the list of unread articles.
5621 (setq fetched-articles
5622 (mapcar (lambda (headers) (mail-header-number headers))
5623 gnus-newsgroup-headers))
5624 (setq gnus-newsgroup-articles fetched-articles)
5625 (setq gnus-newsgroup-unreads
5626 (gnus-sorted-nintersection
5627 gnus-newsgroup-unreads fetched-articles))
5628 (gnus-compute-unseen-list)
5630 ;; Removed marked articles that do not exist.
5631 (gnus-update-missing-marks
5632 (gnus-sorted-difference articles fetched-articles))
5633 ;; We might want to build some more threads first.
5634 (when (and gnus-fetch-old-headers
5635 (eq gnus-headers-retrieved-by 'nov))
5636 (if (eq gnus-fetch-old-headers 'invisible)
5637 (gnus-build-all-threads)
5638 (gnus-build-old-threads)))
5639 ;; Let the Gnus agent mark articles as read.
5641 (gnus-agent-get-undownloaded-list))
5642 ;; Remove list identifiers from subject
5643 (when gnus-list-identifiers
5644 (gnus-summary-remove-list-identifiers))
5645 ;; Check whether auto-expire is to be done in this group.
5646 (setq gnus-newsgroup-auto-expire
5647 (gnus-group-auto-expirable-p group))
5648 ;; Set up the article buffer now, if necessary.
5649 (unless (and gnus-single-article-buffer
5650 (equal gnus-article-buffer "*Article*"))
5651 (gnus-article-setup-buffer))
5652 ;; First and last article in this newsgroup.
5653 (when gnus-newsgroup-headers
5654 (setq gnus-newsgroup-begin
5655 (mail-header-number (car gnus-newsgroup-headers))
5658 (gnus-last-element gnus-newsgroup-headers))))
5659 ;; GROUP is successfully selected.
5660 (or gnus-newsgroup-headers t)))))
5662 (defun gnus-compute-unseen-list ()
5663 ;; The `seen' marks are treated specially.
5664 (if (not gnus-newsgroup-seen)
5665 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5666 (setq gnus-newsgroup-unseen
5667 (gnus-inverse-list-range-intersection
5668 gnus-newsgroup-articles gnus-newsgroup-seen))))
5670 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5672 (defun gnus-summary-display-make-predicate (display)
5673 (require 'gnus-agent)
5674 (when (= (length display) 1)
5675 (setq display (car display)))
5676 (unless gnus-summary-display-cache
5677 (dolist (elem (append '((unread . unread)
5680 gnus-article-mark-lists))
5681 (push (cons (cdr elem)
5682 (gnus-byte-compile ;Why bother?
5683 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5684 gnus-summary-display-cache)))
5685 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5686 (gnus-category-predicate-cache gnus-summary-display-cache))
5687 (gnus-get-predicate display)))
5689 ;; Uses the dynamically bound `gnus-number' variable.
5690 (defvar gnus-number)
5691 (defun gnus-article-marked-p (type &optional article)
5692 (let ((article (or article gnus-number)))
5695 (memq article gnus-newsgroup-marked))
5697 (memq article gnus-newsgroup-spam-marked))
5699 (memq article gnus-newsgroup-unsendable))
5700 ((eq type 'undownload)
5701 (memq article gnus-newsgroup-undownloaded))
5702 ((eq type 'download)
5703 (memq article gnus-newsgroup-downloadable))
5705 (memq article gnus-newsgroup-unreads))
5707 (memq article gnus-newsgroup-reads))
5709 (memq article gnus-newsgroup-dormant) )
5711 (memq article gnus-newsgroup-expirable))
5713 (memq article gnus-newsgroup-replied))
5715 (memq article gnus-newsgroup-killed))
5716 ((eq type 'bookmark)
5717 (assq article gnus-newsgroup-bookmarks))
5719 (assq article gnus-newsgroup-scored))
5721 (memq article gnus-newsgroup-saved))
5723 (memq article gnus-newsgroup-cached))
5725 (memq article gnus-newsgroup-forwarded))
5727 (not (memq article gnus-newsgroup-unseen)))
5729 (memq article gnus-newsgroup-recent))
5732 (defun gnus-articles-to-read (group &optional read-all)
5733 "Find out what articles the user wants to read."
5735 ;; Select all articles if `read-all' is non-nil, or if there
5736 ;; are no unread articles.
5738 (and (zerop (length gnus-newsgroup-marked))
5739 (zerop (length gnus-newsgroup-unreads)))
5740 ;; Fetch all if the predicate is non-nil.
5741 gnus-newsgroup-display)
5742 ;; We want to select the headers for all the articles in
5743 ;; the group, so we select either all the active
5744 ;; articles in the group, or (if that's nil), the
5745 ;; articles in the cache.
5747 (if gnus-newsgroup-maximum-articles
5748 (let ((active (gnus-active group)))
5749 (gnus-uncompress-range
5750 (cons (max (car active)
5752 gnus-newsgroup-maximum-articles
5755 (gnus-uncompress-range (gnus-active group)))
5756 (gnus-cache-articles-in-group group))
5757 ;; Select only the "normal" subset of articles.
5759 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5760 gnus-newsgroup-unreads)))
5761 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5762 (scored (length scored-list))
5763 (number (length articles))
5764 (marked (+ (length gnus-newsgroup-marked)
5765 (length gnus-newsgroup-dormant)))
5770 ((numberp gnus-newsgroup-display)
5771 gnus-newsgroup-display)
5775 ((and (or (<= scored marked) (= scored number))
5776 (numberp gnus-large-newsgroup)
5777 (> number gnus-large-newsgroup))
5778 (let* ((cursor-in-echo-area nil)
5779 (initial (gnus-parameter-large-newsgroup-initial
5780 gnus-newsgroup-name))
5784 "How many articles from %s (%s %d): "
5785 (gnus-group-decoded-name gnus-newsgroup-name)
5786 (if initial "max" "default")
5789 (cons (number-to-string initial)
5791 (if (string-match "^[ \t]*$" input) number input)))
5792 ((and (> scored marked) (< scored number)
5793 (> (- scored number) 20))
5796 (format "%s %s (%d scored, %d total): "
5797 "How many articles from"
5798 (gnus-group-decoded-name group)
5800 (if (string-match "^[ \t]*$" input)
5804 (message "Quit getting the articles to read")
5806 (setq select (if (stringp select) (string-to-number select) select))
5807 (if (or (null select) (zerop select))
5809 (if (and (not (zerop scored)) (<= (abs select) scored))
5811 (setq articles (sort scored-list '<))
5812 (setq number (length articles)))
5813 (setq articles (copy-sequence articles)))
5815 (when (< (abs select) number)
5817 ;; Select the N oldest articles.
5818 (setcdr (nthcdr (1- (abs select)) articles) nil)
5819 ;; Select the N most recent articles.
5820 (setq articles (nthcdr (- number select) articles))))
5821 (setq gnus-newsgroup-unselected
5822 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5823 (when gnus-alter-articles-to-read-function
5826 (funcall gnus-alter-articles-to-read-function
5827 gnus-newsgroup-name articles)
5831 (defun gnus-killed-articles (killed articles)
5834 (when (inline (gnus-member-of-range (car articles) killed))
5835 (push (car articles) out))
5836 (setq articles (cdr articles)))
5839 (defun gnus-uncompress-marks (marks)
5840 "Uncompress the mark ranges in MARKS."
5841 (let ((uncompressed '(score bookmark))
5844 (if (memq (caar marks) uncompressed)
5845 (push (car marks) out)
5846 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5847 (setq marks (cdr marks)))
5850 (defun gnus-article-mark-to-type (mark)
5851 "Return the type of MARK."
5852 (or (cadr (assq mark gnus-article-special-mark-lists))
5855 (defun gnus-article-unpropagatable-p (mark)
5856 "Return whether MARK should be propagated to back end."
5857 (memq mark gnus-article-unpropagated-mark-lists))
5859 (defun gnus-adjust-marked-articles (info)
5860 "Set all article lists and remove all marks that are no longer valid."
5861 (let* ((marked-lists (gnus-info-marks info))
5862 (active (gnus-active (gnus-info-group info)))
5865 (types gnus-article-mark-lists)
5866 marks var articles article mark mark-type
5868 ;; Hack to avoid adjusting marks for imap.
5869 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5873 (dolist (marks marked-lists)
5874 (setq mark (car marks)
5875 mark-type (gnus-article-mark-to-type mark)
5876 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5878 ;; We set the variable according to the type of the marks list,
5879 ;; and then adjust the marks to a subset of the active articles.
5881 ;; Adjust "simple" lists - compressed yet unsorted
5882 ((eq mark-type 'list)
5883 ;; Simultaneously uncompress and clip to active range
5884 ;; See gnus-uncompress-range for a description of possible marks
5886 (if (not (cadr marks))
5888 (setq articles (if (numberp (cddr marks))
5894 (while (setq article (pop articles))
5895 (cond ((consp article)
5896 (setq bgn (max (car article) min)
5897 end (min (cdr article) max))
5899 (setq l (setcdr l (cons bgn nil))
5901 ((and (<= min article)
5903 (setq l (setcdr l (cons article nil))))))
5904 (set var (cdr lh)))))
5906 ((eq mark-type 'tuple)
5907 (set var (setq articles (cdr marks)))
5908 (when (not (listp (cdr (symbol-value var))))
5909 (set var (list (symbol-value var))))
5910 (when (not (listp (cdr articles)))
5911 (setq articles (list articles)))
5913 (when (or (not (consp (setq article (pop articles))))
5914 (< (car article) min)
5915 (> (car article) max))
5916 (set var (delq article (symbol-value var))))))
5917 ;; Adjust ranges (sloppily).
5918 ((eq mark-type 'range)
5921 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5922 ;; It should be (seen (NUM1 . NUM2)).
5923 (when (numberp (cddr marks))
5924 (setcdr marks (list (cdr marks))))
5925 (setq articles (cdr marks))
5926 (while (and articles
5927 (or (and (consp (car articles))
5928 (> min (cdar articles)))
5929 (and (numberp (car articles))
5930 (> min (car articles)))))
5932 (set var articles))))))))
5934 (defun gnus-update-missing-marks (missing)
5935 "Go through the list of MISSING articles and remove them from the mark lists."
5938 ;; Go through all types.
5939 (dolist (elem gnus-article-mark-lists)
5940 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5941 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5942 (when (symbol-value var)
5943 ;; This list has articles. So we delete all missing
5944 ;; articles from it.
5947 (set var (delq (pop m) (symbol-value var))))))))))
5949 (defun gnus-update-marks ()
5950 "Enter the various lists of marked articles into the newsgroup info list."
5951 (let ((types gnus-article-mark-lists)
5952 (info (gnus-get-info gnus-newsgroup-name))
5953 type list newmarked symbol delta-marks)
5955 ;; Add all marks lists to the list of marks lists.
5956 (while (setq type (pop types))
5957 (setq list (symbol-value
5959 (intern (format "gnus-newsgroup-%s" (car type))))))
5962 ;; Get rid of the entries of the articles that have the
5964 (when (and (eq (cdr type) 'score)
5968 (prev (cons nil list))
5971 (if (or (not (consp (car arts)))
5972 (= (cdar arts) gnus-summary-default-score))
5973 (setcdr prev (cdr arts))
5975 (setq arts (cdr arts)))
5976 (setq list (cdr all)))))
5978 (when (eq (cdr type) 'seen)
5979 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5981 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5982 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5984 (when (and (gnus-check-backend-function
5985 'request-set-mark gnus-newsgroup-name)
5986 (not (gnus-article-unpropagatable-p (cdr type))))
5987 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5988 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5989 (add (gnus-remove-from-range
5990 (gnus-copy-sequence list) old)))
5992 (push (list add 'add (list (cdr type))) delta-marks))
5994 ;; Don't delete marks from outside the active range. This
5995 ;; shouldn't happen, but is a sanity check.
5996 (setq del (gnus-sorted-range-intersection
5997 (gnus-active gnus-newsgroup-name) del))
5998 (push (list del 'del (list (cdr type))) delta-marks))))
6001 (push (cons (cdr type) list) newmarked)))
6004 (unless (gnus-check-group gnus-newsgroup-name)
6005 (error "Can't open server for %s" gnus-newsgroup-name))
6006 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6008 ;; Enter these new marks into the info of the group.
6010 (setcar (nthcdr 3 info) newmarked)
6011 ;; Add the marks lists to the end of the info.
6013 (setcdr (nthcdr 2 info) (list newmarked))))
6015 ;; Cut off the end of the info if there's nothing else there.
6019 (when (nthcdr (decf i) info)
6020 (setcdr (nthcdr i info) nil)))))))
6022 (defun gnus-set-mode-line (where)
6023 "Set the mode line of the article or summary buffers.
6024 If WHERE is `summary', the summary mode line format will be used."
6025 ;; Is this mode line one we keep updated?
6026 (when (and (memq where gnus-updated-mode-lines)
6028 (intern (format "gnus-%s-mode-line-format-spec" where))))
6030 ;; We evaluate this in the summary buffer since these
6031 ;; variables are buffer-local to that buffer.
6032 (with-current-buffer gnus-summary-buffer
6033 ;; We bind all these variables that are used in the `eval' form
6035 (let* ((mformat (symbol-value
6037 (format "gnus-%s-mode-line-format-spec" where))))
6038 (gnus-tmp-group-name (gnus-mode-string-quote
6039 (gnus-group-decoded-name
6040 gnus-newsgroup-name)))
6041 (gnus-tmp-article-number (or gnus-current-article 0))
6042 (gnus-tmp-unread gnus-newsgroup-unreads)
6043 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6044 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6045 (gnus-tmp-unread-and-unselected
6046 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6047 (zerop gnus-tmp-unselected))
6049 ((zerop gnus-tmp-unselected)
6050 (format "{%d more}" gnus-tmp-unread-and-unticked))
6051 (t (format "{%d(+%d) more}"
6052 gnus-tmp-unread-and-unticked
6053 gnus-tmp-unselected))))
6055 (if (and gnus-current-headers
6056 (vectorp gnus-current-headers))
6057 (gnus-mode-string-quote
6058 (mail-header-subject gnus-current-headers))
6060 bufname-length max-len
6061 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6062 (setq mode-string (eval mformat))
6063 (setq bufname-length (if (string-match "%b" mode-string)
6066 (if (eq where 'summary)
6068 (get-buffer gnus-article-buffer))))
6071 (setq max-len (max 4 (if gnus-mode-non-string-length
6073 gnus-mode-non-string-length
6075 (length mode-string))))
6076 ;; We might have to chop a bit of the string off...
6077 (when (> (length mode-string) max-len)
6079 (concat (truncate-string-to-width mode-string (- max-len 3))
6081 ;; Update the mode line.
6082 (setq mode-line-buffer-identification
6083 (gnus-mode-line-buffer-identification (list mode-string)))
6084 (set-buffer-modified-p t))))
6086 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6087 "Go through the HEADERS list and add all Xrefs to a hash table.
6088 The resulting hash table is returned, or nil if no Xrefs were found."
6089 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6090 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6091 (xref-hashtb (gnus-make-hashtable))
6092 start group entry number xrefs header)
6094 (setq header (pop headers))
6095 (when (and (setq xrefs (mail-header-xref header))
6096 (not (memq (setq number (mail-header-number header))
6099 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6100 (setq start (match-end 0))
6101 (setq group (if prefix
6102 (concat prefix (substring xrefs (match-beginning 1)
6104 (substring xrefs (match-beginning 1) (match-end 1))))
6106 (string-to-number (substring xrefs (match-beginning 2)
6108 (if (setq entry (gnus-gethash group xref-hashtb))
6109 (setcdr entry (cons number (cdr entry)))
6110 (gnus-sethash group (cons number nil) xref-hashtb)))))
6111 (and start xref-hashtb)))
6113 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6114 "Look through all the headers and mark the Xrefs as read."
6115 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6116 name info xref-hashtb idlist method nth4)
6117 (with-current-buffer gnus-group-buffer
6118 (when (setq xref-hashtb
6119 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6122 (unless (string= from-newsgroup (setq name (symbol-name group)))
6123 (setq idlist (symbol-value group))
6124 ;; Dead groups are not updated.
6126 (setq info (gnus-get-info name))
6127 (when (stringp (setq nth4 (gnus-info-method info)))
6128 (setq nth4 (gnus-server-to-method nth4))))
6129 ;; Only do the xrefs if the group has the same
6130 ;; select method as the group we have just read.
6131 (or (gnus-methods-equal-p
6132 nth4 (gnus-find-method-for-group from-newsgroup))
6134 (equal nth4 (setq method (gnus-find-method-for-group
6136 (and (equal (car nth4) (car method))
6137 (equal (nth 1 nth4) (nth 1 method))))
6138 gnus-use-cross-reference
6139 (or (not (eq gnus-use-cross-reference t))
6141 ;; Only do cross-references on subscribed
6142 ;; groups, if that is what is wanted.
6143 (<= (gnus-info-level info) gnus-level-subscribed))
6144 (gnus-group-make-articles-read name idlist))))
6147 (defun gnus-compute-read-articles (group articles)
6148 (let* ((entry (gnus-group-entry group))
6149 (info (nth 2 entry))
6150 (active (gnus-active group))
6153 ;; First peel off all invalid article numbers.
6155 (let ((ids articles)
6157 (while (setq id (pop ids))
6158 (when (and first (> id (cdr active)))
6159 ;; We'll end up in this situation in one particular
6160 ;; obscure situation. If you re-scan a group and get
6161 ;; a new article that is cross-posted to a different
6162 ;; group that has not been re-scanned, you might get
6163 ;; crossposted article that has a higher number than
6164 ;; Gnus believes possible. So we re-activate this
6165 ;; group as well. This might mean doing the
6166 ;; crossposting thingy will *increase* the number
6167 ;; of articles in some groups. Tsk, tsk.
6168 (setq active (or (gnus-activate-group group) active)))
6169 (when (or (> id (cdr active))
6170 (< id (car active)))
6171 (setq articles (delq id articles))))))
6172 ;; If the read list is nil, we init it.
6174 (null (gnus-info-read info))
6176 (setq ninfo (cons 1 (1- (car active))))
6177 (setq ninfo (gnus-info-read info)))
6178 ;; Then we add the read articles to the range.
6180 ninfo (setq articles (sort articles '<))))))
6182 (defun gnus-group-make-articles-read (group articles)
6183 "Update the info of GROUP to say that ARTICLES are read."
6185 (entry (gnus-group-entry group))
6186 (info (nth 2 entry))
6187 (active (gnus-active group))
6190 ;; Group that Gnus doesn't know exists, but still allow the
6191 ;; backend to set marks.
6192 (gnus-request-set-mark
6193 group (list (list (gnus-compress-sequence (sort articles #'<))
6195 ;; Normal, subscribed groups.
6196 (setq range (gnus-compute-read-articles group articles))
6197 (with-current-buffer gnus-group-buffer
6200 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6201 (gnus-info-set-read ',info ',(gnus-info-read info))
6202 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6203 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6204 (gnus-group-update-group ,group t))))
6205 ;; Add the read articles to the range.
6206 (gnus-info-set-read info range)
6207 (gnus-request-set-mark group (list (list range 'add '(read))))
6208 ;; Then we have to re-compute how many unread
6209 ;; articles there are in this group.
6213 (setq num (- (1+ (cdr active)) (car active))))
6214 ((not (listp (cdr range)))
6215 (setq num (- (cdr active) (- (1+ (cdr range))
6219 (if (numberp (car range))
6221 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6222 (setq range (cdr range)))
6223 (setq num (- (cdr active) num))))
6224 ;; Update the number of unread articles.
6226 ;; Update the group buffer.
6227 (unless (gnus-ephemeral-group-p group)
6228 (gnus-group-update-group group t))))))
6230 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6231 (let ((cur nntp-server-buffer)
6234 (with-current-buffer gnus-summary-buffer
6235 gnus-newsgroup-dependencies)))
6236 headers id end ref number
6237 (mail-parse-charset gnus-newsgroup-charset)
6238 (mail-parse-ignored-charsets
6239 (save-current-buffer (condition-case nil
6240 (set-buffer gnus-summary-buffer)
6242 gnus-newsgroup-ignored-charsets)))
6243 (with-current-buffer nntp-server-buffer
6244 ;; Translate all TAB characters into SPACE characters.
6245 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6246 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6247 (ietf-drums-unfold-fws)
6248 (gnus-run-hooks 'gnus-parse-headers-hook)
6249 (let ((case-fold-search t)
6250 in-reply-to header p lines chars)
6251 (goto-char (point-min))
6252 ;; Search to the beginning of the next header. Error messages
6253 ;; do not begin with 2 or 3.
6254 (while (re-search-forward "^[23][0-9]+ " nil t)
6257 ;; This implementation of this function, with nine
6258 ;; search-forwards instead of the one re-search-forward and
6259 ;; a case (which basically was the old function) is actually
6260 ;; about twice as fast, even though it looks messier. You
6261 ;; can't have everything, I guess. Speed and elegance
6262 ;; doesn't always go hand in hand.
6268 (setq number (read cur))
6271 (narrow-to-region (point)
6272 (or (and (search-forward "\n.\n" nil t)
6278 (if (search-forward "\nsubject:" nil t)
6279 (funcall gnus-decode-encoded-word-function
6280 (nnheader-header-value))
6285 (if (search-forward "\nfrom:" nil t)
6286 (funcall gnus-decode-encoded-address-function
6287 (nnheader-header-value))
6292 (if (search-forward "\ndate:" nil t)
6293 (nnheader-header-value) ""))
6297 (setq id (if (re-search-forward
6298 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6299 ;; We do it this way to make sure the Message-ID
6300 ;; is (somewhat) syntactically valid.
6301 (buffer-substring (match-beginning 1)
6303 ;; If there was no message-id, we just fake one
6304 ;; to make subsequent routines simpler.
6305 (nnheader-generate-fake-message-id number))))
6309 (if (search-forward "\nreferences:" nil t)
6313 (nnheader-header-value)
6318 (search-backward ">" end t)
6321 (search-backward "<" end t)
6323 ;; Get the references from the in-reply-to header if there
6324 ;; were no references and the in-reply-to header looks
6326 (if (and (search-forward "\nin-reply-to:" nil t)
6327 (setq in-reply-to (nnheader-header-value))
6328 (string-match "<[^>]+>" in-reply-to))
6330 (setq ref (substring in-reply-to (match-beginning 0)
6332 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6333 (setq ref2 (substring in-reply-to (match-beginning 0)
6335 (when (> (length ref2) (length ref))
6342 (if (search-forward "\nchars: " nil t)
6343 (if (numberp (setq chars (ignore-errors (read cur))))
6349 (if (search-forward "\nlines: " nil t)
6350 (if (numberp (setq lines (ignore-errors (read cur))))
6356 (and (search-forward "\nxref:" nil t)
6357 (nnheader-header-value)))
6359 (when gnus-extra-headers
6360 (let ((extra gnus-extra-headers)
6364 (when (search-forward
6365 (concat "\n" (symbol-name (car extra)) ":") nil t)
6366 (push (cons (car extra) (nnheader-header-value))
6370 (when (equal id ref)
6373 (when gnus-alter-header-function
6374 (funcall gnus-alter-header-function header)
6375 (setq id (mail-header-id header)
6376 ref (gnus-parent-id (mail-header-references header))))
6379 (gnus-dependencies-add-header
6380 header dependencies force-new))
6381 (push header headers))
6382 (goto-char (point-max))
6384 (nreverse headers)))))
6386 ;; Goes through the xover lines and returns a list of vectors
6387 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6388 force-new dependencies
6389 group also-fetch-heads)
6390 "Parse the news overview data in the server buffer.
6391 Return a list of headers that match SEQUENCE (see
6392 `nntp-retrieve-headers')."
6393 ;; Get the Xref when the users reads the articles since most/some
6394 ;; NNTP servers do not include Xrefs when using XOVER.
6395 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6396 (let ((mail-parse-charset gnus-newsgroup-charset)
6397 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6398 (cur nntp-server-buffer)
6399 (dependencies (or dependencies gnus-newsgroup-dependencies))
6401 ((eq gnus-read-all-available-headers t)
6403 ((and (stringp gnus-read-all-available-headers)
6405 (string-match gnus-read-all-available-headers group))
6408 number headers header)
6409 (with-current-buffer nntp-server-buffer
6410 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6411 ;; Allow the user to mangle the headers before parsing them.
6412 (gnus-run-hooks 'gnus-parse-headers-hook)
6413 (goto-char (point-min))
6414 (gnus-parse-without-error
6415 (while (and (or sequence allp)
6417 (setq number (read cur))
6419 (while (and sequence
6420 (< (car sequence) number))
6421 (setq sequence (cdr sequence))))
6424 (eq number (car sequence))))
6426 (setq sequence (cdr sequence))
6427 (setq header (inline
6428 (gnus-nov-parse-line
6429 number dependencies force-new)))))
6430 (push header headers))
6432 ;; A common bug in inn is that if you have posted an article and
6433 ;; then retrieves the active file, it will answer correctly --
6434 ;; the new article is included. However, a NOV entry for the
6435 ;; article may not have been generated yet, so this may fail.
6436 ;; We work around this problem by retrieving the last few
6437 ;; headers using HEAD.
6438 (if (or (not also-fetch-heads)
6440 ;; We (probably) got all the headers.
6442 (let ((gnus-nov-is-evil t))
6445 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6446 (gnus-get-newsgroup-headers))))))))
6448 (defun gnus-article-get-xrefs ()
6449 "Fill in the Xref value in `gnus-current-headers', if necessary.
6450 This is meant to be called in `gnus-article-internal-prepare-hook'."
6451 (let ((headers (with-current-buffer gnus-summary-buffer
6452 gnus-current-headers)))
6453 (or (not gnus-use-cross-reference)
6455 (and (mail-header-xref headers)
6456 (not (string= (mail-header-xref headers) "")))
6457 (let ((case-fold-search t)
6460 (nnheader-narrow-to-headers)
6461 (goto-char (point-min))
6462 (when (or (and (not (eobp))
6463 (eq (downcase (char-after)) ?x)
6464 (looking-at "Xref:"))
6465 (search-forward "\nXref:" nil t))
6466 (goto-char (1+ (match-end 0)))
6467 (setq xref (buffer-substring (point) (point-at-eol)))
6468 (mail-header-set-xref headers xref)))))))
6470 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6471 "Find article ID and insert the summary line for that article.
6472 OLD-HEADER can either be a header or a line number to insert
6473 the subject line on."
6474 (let* ((line (and (numberp old-header) old-header))
6475 (old-header (and (vectorp old-header) old-header))
6476 (header (cond ((and old-header use-old-header)
6479 (gnus-number-to-header id))
6480 (gnus-number-to-header id))
6482 (gnus-read-header id))))
6483 (number (and (numberp id) id))
6486 ;; Rebuild the thread that this article is part of and go to the
6487 ;; article we have fetched.
6488 (when (and (not gnus-show-threads)
6491 (setq d (gnus-data-find (mail-header-number old-header))))
6492 (goto-char (gnus-data-pos d))
6498 (gnus-delete-line))))))
6499 ;; Remove list identifiers from subject.
6500 (when gnus-list-identifiers
6501 (let ((gnus-newsgroup-headers (list header)))
6502 (gnus-summary-remove-list-identifiers)))
6504 (mail-header-set-number header (mail-header-number old-header)))
6505 (setq gnus-newsgroup-sparse
6506 (delq (setq number (mail-header-number header))
6507 gnus-newsgroup-sparse))
6508 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6509 (push number gnus-newsgroup-limit)
6510 (gnus-rebuild-thread (mail-header-id header) line)
6511 (gnus-summary-goto-subject number nil t))
6512 (when (and (numberp number)
6514 ;; We have to update the boundaries even if we can't fetch the
6515 ;; article if ID is a number -- so that the next `P' or `N'
6516 ;; command will fetch the previous (or next) article even
6517 ;; if the one we tried to fetch this time has been canceled.
6518 (when (> number gnus-newsgroup-end)
6519 (setq gnus-newsgroup-end number))
6520 (when (< number gnus-newsgroup-begin)
6521 (setq gnus-newsgroup-begin number))
6522 (setq gnus-newsgroup-unselected
6523 (delq number gnus-newsgroup-unselected)))
6524 ;; Report back a success?
6525 (and header (mail-header-number header))))
6527 ;;; Process/prefix in the summary buffer
6529 (defun gnus-summary-work-articles (n)
6530 "Return a list of articles to be worked upon.
6531 The prefix argument, the list of process marked articles, and the
6532 current article will be taken into consideration."
6533 (with-current-buffer gnus-summary-buffer
6536 ;; A numerical prefix has been given.
6537 (setq n (prefix-numeric-value n))
6538 (let ((backward (< n 0))
6539 (n (abs (prefix-numeric-value n)))
6544 (push (setq article (gnus-summary-article-number))
6547 (gnus-summary-find-prev nil article)
6548 (gnus-summary-find-next nil article)))
6550 (nreverse articles)))
6551 ((and (gnus-region-active-p) (mark))
6552 (message "region active")
6553 ;; Work on the region between point and mark.
6554 (let ((max (max (point) (mark)))
6557 (goto-char (min (point) (mark)))
6560 (push (setq article (gnus-summary-article-number)) articles)
6561 (gnus-summary-find-next nil article)
6563 (nreverse articles))))
6564 (gnus-newsgroup-processable
6565 ;; There are process-marked articles present.
6566 ;; Save current state.
6567 (gnus-summary-save-process-mark)
6569 (reverse gnus-newsgroup-processable))
6571 ;; Just return the current article.
6572 (list (gnus-summary-article-number))))))
6574 (defmacro gnus-summary-iterate (arg &rest forms)
6575 "Iterate over the process/prefixed articles and do FORMS.
6576 ARG is the interactive prefix given to the command. FORMS will be
6577 executed with point over the summary line of the articles."
6578 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6579 `(let ((,articles (gnus-summary-work-articles ,arg)))
6581 (gnus-summary-goto-subject (car ,articles))
6585 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6586 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6588 (defun gnus-summary-save-process-mark ()
6589 "Push the current set of process marked articles on the stack."
6591 (push (copy-sequence gnus-newsgroup-processable)
6592 gnus-newsgroup-process-stack))
6594 (defun gnus-summary-kill-process-mark ()
6595 "Push the current set of process marked articles on the stack and unmark."
6597 (gnus-summary-save-process-mark)
6598 (gnus-summary-unmark-all-processable))
6600 (defun gnus-summary-yank-process-mark ()
6601 "Pop the last process mark state off the stack and restore it."
6603 (unless gnus-newsgroup-process-stack
6604 (error "Empty mark stack"))
6605 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6607 (defun gnus-summary-process-mark-set (set)
6608 "Make SET into the current process marked articles."
6609 (gnus-summary-unmark-all-processable)
6610 (mapc 'gnus-summary-set-process-mark set))
6612 ;;; Searching and stuff
6614 (defun gnus-summary-search-group (&optional backward use-level)
6615 "Search for next unread newsgroup.
6616 If optional argument BACKWARD is non-nil, search backward instead."
6617 (with-current-buffer gnus-group-buffer
6618 (when (gnus-group-search-forward
6619 backward nil (if use-level (gnus-group-group-level) nil))
6620 (gnus-group-group-name))))
6622 (defun gnus-summary-best-group (&optional exclude-group)
6623 "Find the name of the best unread group.
6624 If EXCLUDE-GROUP, do not go to this group."
6625 (with-current-buffer gnus-group-buffer
6627 (gnus-group-best-unread-group exclude-group))))
6629 (defun gnus-summary-find-next (&optional unread article backward)
6631 (gnus-summary-find-prev unread article)
6632 (let* ((dummy (gnus-summary-article-intangible-p))
6633 (article (or article (gnus-summary-article-number)))
6634 (data (gnus-data-find-list article))
6636 (when (and (not dummy)
6637 (or (not gnus-summary-check-current)
6639 (not (gnus-data-unread-p (car data)))))
6640 (setq data (cdr data)))
6645 (unless (memq (gnus-data-number (car data))
6647 ((eq gnus-auto-goto-ignores
6648 'always-undownloaded)
6649 gnus-newsgroup-undownloaded)
6652 ((eq gnus-auto-goto-ignores
6654 gnus-newsgroup-unfetched)
6655 ((eq gnus-auto-goto-ignores
6657 gnus-newsgroup-undownloaded)))
6658 (when (gnus-data-unread-p (car data))
6659 (setq result (car data)
6661 (setq data (cdr data)))
6664 (goto-char (gnus-data-pos result))
6665 (gnus-data-number result)))))
6667 (defun gnus-summary-find-prev (&optional unread article)
6668 (let* ((eobp (eobp))
6669 (article (or article (gnus-summary-article-number)))
6670 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6672 (when (and (not eobp)
6673 (or (not gnus-summary-check-current)
6675 (not (gnus-data-unread-p (car data)))))
6676 (setq data (cdr data)))
6681 (unless (memq (gnus-data-number (car data))
6683 ((eq gnus-auto-goto-ignores
6684 'always-undownloaded)
6685 gnus-newsgroup-undownloaded)
6688 ((eq gnus-auto-goto-ignores
6690 gnus-newsgroup-unfetched)
6691 ((eq gnus-auto-goto-ignores
6693 gnus-newsgroup-undownloaded)))
6694 (when (gnus-data-unread-p (car data))
6695 (setq result (car data)
6697 (setq data (cdr data)))
6700 (goto-char (gnus-data-pos result))
6701 (gnus-data-number result))))
6703 (defun gnus-summary-find-subject (subject &optional unread backward article)
6704 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6705 (article (or article (gnus-summary-article-number)))
6706 (articles (gnus-data-list backward))
6707 (arts (gnus-data-find-list article articles))
6709 (when (or (not gnus-summary-check-current)
6711 (not (gnus-data-unread-p (car arts))))
6712 (setq arts (cdr arts)))
6714 (and (or (not unread)
6715 (gnus-data-unread-p (car arts)))
6716 (vectorp (gnus-data-header (car arts)))
6718 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6719 (setq result (car arts)
6721 (setq arts (cdr arts)))
6723 (goto-char (gnus-data-pos result))
6724 (gnus-data-number result))))
6726 (defun gnus-summary-search-forward (&optional unread subject backward)
6727 "Search forward for an article.
6728 If UNREAD, look for unread articles. If SUBJECT, look for
6729 articles with that subject. If BACKWARD, search backward instead."
6730 (cond (subject (gnus-summary-find-subject subject unread backward))
6731 (backward (gnus-summary-find-prev unread))
6732 (t (gnus-summary-find-next unread))))
6734 (defun gnus-recenter (&optional n)
6735 "Center point in window and redisplay frame.
6736 Also do horizontal recentering."
6738 (when (and gnus-auto-center-summary
6739 (not (eq gnus-auto-center-summary 'vertical)))
6740 (gnus-horizontal-recenter))
6741 (if (fboundp 'recenter-top-bottom)
6742 (recenter-top-bottom n)
6745 (put 'gnus-recenter 'isearch-scroll t)
6747 (defun gnus-forward-line-ignore-invisible (n)
6748 "Move N lines forward (backward if N is negative).
6749 Like forward-line, but skip over (and don't count) invisible lines."
6751 (while (and (> n 0) (not done))
6752 ;; If the following character is currently invisible,
6753 ;; skip all characters with that same `invisible' property value.
6754 (while (gnus-invisible-p (point))
6755 (goto-char (gnus-next-char-property-change (point))))
6760 (while (and (< n 0) (not done))
6762 (if (bobp) (setq done t)
6764 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6765 (goto-char (gnus-previous-char-property-change (point))))))))
6767 (defun gnus-summary-recenter ()
6768 "Center point in the summary window.
6769 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6770 displayed, no centering will be performed."
6771 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6772 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6774 ;; The user has to want it.
6775 (when gnus-auto-center-summary
6776 (let* ((top (cond ((< (window-height) 4) 0)
6777 ((< (window-height) 7) 1)
6778 (t (if (numberp gnus-auto-center-summary)
6779 gnus-auto-center-summary
6780 (/ (1- (window-height)) 2)))))
6781 (height (1- (window-height)))
6782 (bottom (save-excursion
6783 (goto-char (point-max))
6784 (gnus-forward-line-ignore-invisible (- height))
6786 (window (get-buffer-window (current-buffer))))
6787 (when (get-buffer-window gnus-article-buffer)
6788 ;; Only do recentering when the article buffer is displayed,
6789 ;; Set the window start to either `bottom', which is the biggest
6790 ;; possible valid number, or the second line from the top,
6791 ;; whichever is the least.
6792 (let ((top-pos (save-excursion
6793 (gnus-forward-line-ignore-invisible (- top))
6795 (if (> bottom top-pos)
6796 ;; Keep the second line from the top visible
6797 (set-window-start window top-pos)
6798 ;; Try to keep the bottom line visible; if it's partially
6799 ;; obscured, either scroll one more line to make it fully
6800 ;; visible, or revert to using TOP-POS.
6802 (goto-char (point-max))
6803 (gnus-forward-line-ignore-invisible -1)
6804 (let ((last-line-start (point)))
6806 (set-window-start window (point) t)
6807 (when (not (pos-visible-in-window-p last-line-start window))
6808 (gnus-forward-line-ignore-invisible 1)
6809 (set-window-start window (min (point) top-pos) t)))))))
6810 ;; Do horizontal recentering while we're at it.
6811 (when (and (get-buffer-window (current-buffer) t)
6812 (not (eq gnus-auto-center-summary 'vertical)))
6813 (let ((selected (selected-window)))
6814 (select-window (get-buffer-window (current-buffer) t))
6815 (gnus-summary-position-point)
6816 (gnus-horizontal-recenter)
6817 (select-window selected))))))
6819 (defun gnus-summary-jump-to-group (newsgroup)
6820 "Move point to NEWSGROUP in group mode buffer."
6821 ;; Keep update point of group mode buffer if visible.
6822 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6823 (save-window-excursion
6824 ;; Take care of tree window mode.
6825 (when (get-buffer-window gnus-group-buffer)
6826 (pop-to-buffer gnus-group-buffer))
6827 (gnus-group-jump-to-group newsgroup))
6829 ;; Take care of tree window mode.
6830 (if (get-buffer-window gnus-group-buffer 0)
6831 (pop-to-buffer gnus-group-buffer)
6832 (set-buffer gnus-group-buffer))
6833 (gnus-group-jump-to-group newsgroup))))
6835 ;; This function returns a list of article numbers based on the
6836 ;; difference between the ranges of read articles in this group and
6837 ;; the range of active articles.
6838 (defun gnus-list-of-unread-articles (group)
6839 (let* ((read (gnus-info-read (gnus-get-info group)))
6840 (active (or (gnus-active group) (gnus-activate-group group)))
6841 (last (or (cdr active)
6842 (error "Group %s couldn't be activated " group)))
6843 (bottom (if gnus-newsgroup-maximum-articles
6845 (- last gnus-newsgroup-maximum-articles -1))
6848 ;; If none are read, then all are unread.
6851 ;; If the range of read articles is a single range, then the
6852 ;; first unread article is the article after the last read
6853 ;; article. Sounds logical, doesn't it?
6854 (if (and (not (listp (cdr read)))
6855 (or (< (car read) bottom)
6856 (progn (setq read (list read))
6858 (setq first (max bottom (1+ (cdr read))))
6859 ;; `read' is a list of ranges.
6860 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6863 (setq first bottom))
6866 (while (< first nlast)
6867 (setq unread (cons first unread)
6869 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6870 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6871 (setq read (cdr read)))))
6872 ;; And add the last unread articles.
6873 (while (<= first last)
6874 (setq unread (cons first unread)
6876 ;; Return the list of unread articles.
6877 (delq 0 (nreverse unread))))
6879 (defun gnus-list-of-read-articles (group)
6880 "Return a list of unread, unticked and non-dormant articles."
6881 (let* ((info (gnus-get-info group))
6882 (marked (gnus-info-marks info))
6883 (active (gnus-active group)))
6885 (gnus-list-range-difference
6886 (gnus-list-range-difference
6887 (gnus-sorted-complement
6888 (gnus-uncompress-range
6889 (if gnus-newsgroup-maximum-articles
6890 (cons (max (car active)
6892 gnus-newsgroup-maximum-articles
6896 (gnus-list-of-unread-articles group))
6897 (cdr (assq 'dormant marked)))
6898 (cdr (assq 'tick marked))))))
6900 ;; This function returns a sequence of article numbers based on the
6901 ;; difference between the ranges of read articles in this group and
6902 ;; the range of active articles.
6903 (defun gnus-sequence-of-unread-articles (group)
6904 (let* ((read (gnus-info-read (gnus-get-info group)))
6905 (active (or (gnus-active group) (gnus-activate-group group)))
6907 (bottom (if gnus-newsgroup-maximum-articles
6909 (- last gnus-newsgroup-maximum-articles -1))
6912 ;; If none are read, then all are unread.
6915 ;; If the range of read articles is a single range, then the
6916 ;; first unread article is the article after the last read
6917 ;; article. Sounds logical, doesn't it?
6918 (if (and (not (listp (cdr read)))
6919 (or (< (car read) bottom)
6920 (progn (setq read (list read))
6922 (setq first (max bottom (1+ (cdr read))))
6923 ;; `read' is a list of ranges.
6924 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6927 (setq first bottom))
6930 (push (cons first nlast) unread))
6931 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6932 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6933 (setq read (cdr read)))))
6934 ;; And add the last unread articles.
6935 (cond ((not (and first last))
6938 (push (cons first last) unread))
6940 (push first unread)))
6941 ;; Return the sequence of unread articles.
6942 (delq 0 (nreverse unread))))
6944 ;; Various summary commands
6946 (defun gnus-summary-select-article-buffer ()
6947 "Reconfigure windows to show the article buffer.
6948 If `gnus-widen-article-buffer' is set, show only the article
6951 (if (not (gnus-buffer-live-p gnus-article-buffer))
6952 (error "There is no article buffer for this summary buffer")
6953 (unless (get-buffer-window gnus-article-buffer)
6954 (gnus-summary-show-article))
6955 (gnus-configure-windows
6956 (if gnus-widen-article-window
6960 (select-window (get-buffer-window gnus-article-buffer))))
6962 (defun gnus-summary-universal-argument (arg)
6963 "Perform any operation on all articles that are process/prefixed."
6965 (let ((articles (gnus-summary-work-articles arg))
6972 (substitute-command-keys
6973 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6975 (gnus-error 1 "Undefined key")
6978 (gnus-summary-goto-subject (setq article (pop articles)))
6979 (let (gnus-newsgroup-processable)
6980 (command-execute func))
6981 (gnus-summary-remove-process-mark article)))))
6982 (gnus-summary-position-point))
6984 (defun gnus-summary-toggle-truncation (&optional arg)
6985 "Toggle truncation of summary lines.
6986 With ARG, turn line truncation on if ARG is positive."
6988 (setq truncate-lines
6989 (if (null arg) (not truncate-lines)
6990 (> (prefix-numeric-value arg) 0)))
6993 (defun gnus-summary-find-for-reselect ()
6994 "Return the number of an article to stay on across a reselect.
6995 The current article is considered, then following articles, then previous
6996 articles. An article is sought which is not cancelled and isn't a temporary
6997 insertion from another group. If there's no such then return a dummy 0."
6999 (dolist (rev '(nil t))
7000 (unless found ; don't demand the reverse list if we don't need it
7001 (let ((data (gnus-data-find-list
7002 (gnus-summary-article-number) (gnus-data-list rev))))
7003 (while (and data (not found))
7004 (if (and (< 0 (gnus-data-number (car data)))
7005 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7006 (setq found (gnus-data-number (car data))))
7007 (setq data (cdr data))))))
7010 (defun gnus-summary-reselect-current-group (&optional all rescan)
7011 "Exit and then reselect the current newsgroup.
7012 The prefix argument ALL means to select all articles."
7014 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7015 (error "Ephemeral groups can't be reselected"))
7016 (let ((current-subject (gnus-summary-find-for-reselect))
7017 (group gnus-newsgroup-name))
7018 (setq gnus-newsgroup-begin nil)
7019 (gnus-summary-exit nil 'leave-hidden)
7020 ;; We have to adjust the point of group mode buffer because
7021 ;; point was moved to the next unread newsgroup by exiting.
7022 (gnus-summary-jump-to-group group)
7025 (gnus-group-get-new-news-this-group 1)))
7026 (gnus-group-read-group all t)
7027 (gnus-summary-goto-subject current-subject nil t)))
7029 (defun gnus-summary-rescan-group (&optional all)
7030 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7032 (let ((config gnus-current-window-configuration))
7033 (gnus-summary-reselect-current-group all t)
7034 (gnus-configure-windows config)
7035 (when (eq config 'article)
7036 (gnus-summary-select-article))))
7038 (defun gnus-summary-update-info (&optional non-destructive)
7040 (let ((group gnus-newsgroup-name))
7042 (when gnus-newsgroup-kill-headers
7043 (setq gnus-newsgroup-killed
7044 (gnus-compress-sequence
7046 (gnus-list-range-intersection
7047 gnus-newsgroup-unselected gnus-newsgroup-killed)
7048 gnus-newsgroup-unreads)
7050 (unless (listp (cdr gnus-newsgroup-killed))
7051 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7052 (let ((headers gnus-newsgroup-headers))
7053 ;; Set the new ranges of read articles.
7054 (with-current-buffer gnus-group-buffer
7055 (gnus-undo-force-boundary))
7056 (gnus-update-read-articles
7057 group (gnus-sorted-union
7058 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7059 ;; Set the current article marks.
7060 (let ((gnus-newsgroup-scored
7061 (if (and (not gnus-save-score)
7062 (not non-destructive))
7064 gnus-newsgroup-scored)))
7066 (gnus-update-marks)))
7067 ;; Do the cross-ref thing.
7068 (when gnus-use-cross-reference
7069 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7070 ;; Do not switch windows but change the buffer to work.
7071 (set-buffer gnus-group-buffer)
7072 (unless (gnus-ephemeral-group-p group)
7073 (gnus-group-update-group group)))))))
7075 (defun gnus-summary-save-newsrc (&optional force)
7076 "Save the current number of read/marked articles in the dribble buffer.
7077 The dribble buffer will then be saved.
7078 If FORCE (the prefix), also save the .newsrc file(s)."
7080 (gnus-summary-update-info t)
7082 (gnus-save-newsrc-file)
7083 (gnus-dribble-save)))
7085 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7087 (defun gnus-summary-exit (&optional temporary leave-hidden)
7088 "Exit reading current newsgroup, and then return to group selection mode.
7089 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7091 (gnus-set-global-variables)
7092 (when (gnus-buffer-live-p gnus-article-buffer)
7093 (with-current-buffer gnus-article-buffer
7094 (mm-destroy-parts gnus-article-mime-handles)
7095 ;; Set it to nil for safety reason.
7096 (setq gnus-article-mime-handle-alist nil)
7097 (setq gnus-article-mime-handles nil)))
7098 (gnus-kill-save-kill-buffer)
7099 (gnus-async-halt-prefetch)
7100 (let* ((group gnus-newsgroup-name)
7101 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7102 (gnus-group-is-exiting-p t)
7105 (buf (current-buffer)))
7107 ;; Do adaptive scoring, and possibly save score files.
7108 (when gnus-newsgroup-adaptive
7109 (gnus-score-adaptive))
7110 (when gnus-use-scoring
7112 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7113 (when gnus-use-cache
7114 (gnus-cache-possibly-remove-articles)
7115 (gnus-cache-save-buffers))
7116 (gnus-async-prefetch-remove-group group)
7117 (when gnus-suppress-duplicates
7118 (gnus-dup-enter-articles))
7119 (when gnus-use-trees
7120 (gnus-tree-close group))
7121 (when gnus-use-cache
7122 (gnus-cache-write-active))
7123 ;; Remove entries for this group.
7124 (nnmail-purge-split-history (gnus-group-real-name group))
7125 ;; Make all changes in this group permanent.
7127 (gnus-run-hooks 'gnus-exit-group-hook)
7128 (gnus-summary-update-info))
7129 (gnus-close-group group)
7130 ;; Make sure where we were, and go to next newsgroup.
7131 (set-buffer gnus-group-buffer)
7133 (gnus-group-jump-to-group group))
7134 (gnus-run-hooks 'gnus-summary-exit-hook)
7135 (unless (or quit-config
7136 (not gnus-summary-next-group-on-exit)
7137 ;; If this group has disappeared from the summary
7138 ;; buffer, don't skip forwards.
7139 (not (string= group (gnus-group-group-name))))
7140 (gnus-group-next-unread-group 1))
7141 (setq group-point (point))
7145 (if (not gnus-kill-summary-on-exit)
7147 (gnus-deaden-summary)
7149 (when (get-buffer gnus-article-buffer)
7150 (bury-buffer gnus-article-buffer))
7151 ;; Return to group mode buffer.
7152 (when (eq mode 'gnus-summary-mode)
7153 (gnus-kill-buffer buf)))
7155 ;; If we have several article buffers, we kill them at exit.
7156 (unless gnus-single-article-buffer
7157 (when (gnus-buffer-live-p gnus-article-buffer)
7158 (with-current-buffer gnus-article-buffer
7159 ;; Don't kill sticky article buffers
7160 (unless (eq major-mode 'gnus-sticky-article-mode)
7161 (gnus-kill-buffer gnus-article-buffer)
7162 (setq gnus-article-current nil))))
7163 (gnus-kill-buffer gnus-original-article-buffer))
7165 (setq gnus-current-select-method gnus-select-method)
7166 (set-buffer gnus-group-buffer)
7168 (gnus-handle-ephemeral-exit quit-config)
7169 (goto-char group-point)
7170 ;; If gnus-group-buffer is already displayed, make sure we also move
7171 ;; the cursor in the window that displays it.
7172 (let ((win (get-buffer-window (current-buffer) 0)))
7173 (if win (set-window-point win (point))))
7174 (unless leave-hidden
7175 (gnus-configure-windows 'group 'force)))
7176 ;; Clear the current group name.
7178 (setq gnus-newsgroup-name nil)))))
7180 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7181 (defun gnus-summary-exit-no-update (&optional no-questions)
7182 "Quit reading current newsgroup without updating read article info."
7184 (let* ((group gnus-newsgroup-name)
7185 (gnus-group-is-exiting-p t)
7186 (gnus-group-is-exiting-without-update-p t)
7187 (quit-config (gnus-group-quit-config group)))
7188 (when (or no-questions
7190 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7191 (gnus-async-halt-prefetch)
7192 (run-hooks 'gnus-summary-prepare-exit-hook)
7193 (when (gnus-buffer-live-p gnus-article-buffer)
7194 (with-current-buffer gnus-article-buffer
7195 (mm-destroy-parts gnus-article-mime-handles)
7196 ;; Set it to nil for safety reason.
7197 (setq gnus-article-mime-handle-alist nil)
7198 (setq gnus-article-mime-handles nil)))
7199 ;; If we have several article buffers, we kill them at exit.
7200 (unless gnus-single-article-buffer
7201 (gnus-kill-buffer gnus-article-buffer)
7202 (gnus-kill-buffer gnus-original-article-buffer)
7203 (setq gnus-article-current nil))
7204 (if (not gnus-kill-summary-on-exit)
7205 (gnus-deaden-summary)
7206 (gnus-close-group group)
7207 (gnus-kill-buffer gnus-summary-buffer))
7208 (unless gnus-single-article-buffer
7209 (setq gnus-article-current nil))
7210 (when gnus-use-trees
7211 (gnus-tree-close group))
7212 (gnus-async-prefetch-remove-group group)
7213 (when (get-buffer gnus-article-buffer)
7214 (bury-buffer gnus-article-buffer))
7215 ;; Return to the group buffer.
7216 (gnus-configure-windows 'group 'force)
7217 ;; Clear the current group name.
7218 (setq gnus-newsgroup-name nil)
7219 (unless (gnus-ephemeral-group-p group)
7220 (gnus-group-update-group group))
7221 (when (equal (gnus-group-group-name) group)
7222 (gnus-group-next-unread-group 1))
7224 (gnus-handle-ephemeral-exit quit-config)))))
7226 (defun gnus-handle-ephemeral-exit (quit-config)
7227 "Handle movement when leaving an ephemeral group.
7228 The state which existed when entering the ephemeral is reset."
7229 (if (not (buffer-name (car quit-config)))
7230 (gnus-configure-windows 'group 'force)
7231 (set-buffer (car quit-config))
7232 (cond ((eq major-mode 'gnus-summary-mode)
7233 (gnus-set-global-variables))
7234 ((eq major-mode 'gnus-article-mode)
7235 (save-current-buffer
7236 ;; The `gnus-summary-buffer' variable may point
7237 ;; to the old summary buffer when using a single
7239 (unless (gnus-buffer-live-p gnus-summary-buffer)
7240 (set-buffer gnus-group-buffer))
7241 (set-buffer gnus-summary-buffer)
7242 (gnus-set-global-variables))))
7243 (if (or (eq (cdr quit-config) 'article)
7244 (eq (cdr quit-config) 'pick))
7245 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7246 (gnus-configure-windows 'pick 'force)
7247 (gnus-configure-windows (cdr quit-config) 'force))
7248 (gnus-configure-windows (cdr quit-config) 'force))
7249 (when (eq major-mode 'gnus-summary-mode)
7250 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7251 next-unread-noselect))
7252 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7254 (gnus-summary-next-subject 1 nil t))
7255 ((eq gnus-auto-select-on-ephemeral-exit
7256 'next-unread-noselect)
7257 (gnus-summary-next-subject 1 t t))))
7258 ;; Hide the article buffer which displays the article different
7259 ;; from the one that the cursor points to in the summary buffer.
7260 (gnus-configure-windows 'summary 'force))
7261 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7262 (gnus-summary-next-subject 1))
7263 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7264 (gnus-summary-next-subject 1 t))))
7265 (gnus-summary-recenter)
7266 (gnus-summary-position-point))))
7270 (defvar gnus-dead-summary-mode-map
7271 (let ((map (make-keymap)))
7272 (suppress-keymap map)
7273 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7274 (dolist (key '("\C-d" "\r" "\177" [delete]))
7275 (define-key map key 'gnus-summary-wake-up-the-dead))
7276 (dolist (key '("q" "Q"))
7277 (define-key map key 'bury-buffer))
7280 (define-minor-mode gnus-dead-summary-mode
7281 "Minor mode for Gnus summary buffers."
7282 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7283 (unless (derived-mode-p 'gnus-summary-mode)
7284 (setq gnus-dead-summary-mode nil)))
7286 (defun gnus-deaden-summary ()
7287 "Make the current summary buffer into a dead summary buffer."
7288 ;; Kill any previous dead summary buffer.
7289 (when (and gnus-dead-summary
7290 (buffer-name gnus-dead-summary))
7291 (with-current-buffer gnus-dead-summary
7292 (when gnus-dead-summary-mode
7293 (kill-buffer (current-buffer)))))
7294 ;; Make this the current dead summary.
7295 (setq gnus-dead-summary (current-buffer))
7296 (gnus-dead-summary-mode 1)
7297 (let ((name (buffer-name)))
7298 (when (string-match "Summary" name)
7300 (concat (substring name 0 (match-beginning 0)) "Dead "
7301 (substring name (match-beginning 0)))
7305 (defun gnus-kill-or-deaden-summary (buffer)
7306 "Kill or deaden the summary BUFFER."
7308 (when (and (buffer-name buffer)
7309 (not gnus-single-article-buffer))
7310 (with-current-buffer buffer
7311 (gnus-kill-buffer gnus-article-buffer)
7312 (gnus-kill-buffer gnus-original-article-buffer)))
7315 (gnus-kill-summary-on-exit
7316 (when (and gnus-use-trees
7317 (gnus-buffer-exists-p buffer))
7318 (with-current-buffer buffer
7319 (gnus-tree-close gnus-newsgroup-name)))
7320 (gnus-kill-buffer buffer))
7321 ;; Deaden the buffer.
7322 ((gnus-buffer-exists-p buffer)
7323 (with-current-buffer buffer
7324 (gnus-deaden-summary))))))
7326 (defun gnus-summary-wake-up-the-dead (&rest args)
7327 "Wake up the dead summary buffer."
7329 (gnus-dead-summary-mode -1)
7330 (let ((name (buffer-name)))
7331 (when (string-match "Dead " name)
7333 (concat (substring name 0 (match-beginning 0))
7334 (substring name (match-end 0)))
7336 (gnus-message 3 "This dead summary is now alive again"))
7338 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7339 (defun gnus-summary-describe-group (&optional force)
7340 "Describe the current newsgroup."
7342 (gnus-group-describe-group force gnus-newsgroup-name))
7344 (defun gnus-summary-describe-briefly ()
7345 "Describe summary mode commands briefly."
7347 (gnus-message 6 "%s" (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")))
7349 ;; Walking around group mode buffer from summary mode.
7351 (defun gnus-summary-next-group (&optional no-article target-group backward)
7352 "Exit current newsgroup and then select next unread newsgroup.
7353 If prefix argument NO-ARTICLE is non-nil, no article is selected
7354 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7355 previous group instead."
7357 ;; Stop pre-fetching.
7358 (gnus-async-halt-prefetch)
7359 (let ((current-group gnus-newsgroup-name)
7360 (current-buffer (current-buffer))
7362 ;; First we semi-exit this group to update Xrefs and all variables.
7363 ;; We can't do a real exit, because the window conf must remain
7364 ;; the same in case the user is prompted for info, and we don't
7365 ;; want the window conf to change before that...
7366 (gnus-summary-exit t)
7367 (while (not entered)
7368 ;; Then we find what group we are supposed to enter.
7369 (set-buffer gnus-group-buffer)
7370 (gnus-group-jump-to-group current-group)
7373 (if (eq gnus-keep-same-level 'best)
7374 (gnus-summary-best-group gnus-newsgroup-name)
7375 (gnus-summary-search-group backward gnus-keep-same-level))))
7376 (if (not target-group)
7377 ;; There are no further groups, so we return to the group
7380 (gnus-message 5 "Returning to the group buffer")
7382 (when (gnus-buffer-live-p current-buffer)
7383 (set-buffer current-buffer)
7384 (gnus-summary-exit))
7385 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7386 ;; We try to enter the target group.
7387 (gnus-group-jump-to-group target-group)
7388 (let ((unreads (gnus-group-group-unread)))
7389 (if (and (or (eq t unreads)
7390 (and unreads (not (zerop unreads))))
7391 (gnus-summary-read-group
7392 target-group nil no-article
7393 (and (buffer-name current-buffer) current-buffer)
7396 (setq current-group target-group
7397 target-group nil)))))))
7399 (defun gnus-summary-prev-group (&optional no-article)
7400 "Exit current newsgroup and then select previous unread newsgroup.
7401 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7403 (gnus-summary-next-group no-article nil t))
7405 ;; Walking around summary lines.
7407 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7408 "Go to the first subject satisfying any non-nil constraint.
7409 If UNREAD is non-nil, the article should be unread.
7410 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7411 If UNSEEN is non-nil, the article should be unseen as well as unread.
7412 Returns the article selected or nil if there are no matching articles."
7416 ((null gnus-newsgroup-data)
7417 (gnus-message 3 "No articles in the group")
7419 ;; Pick the first article.
7420 ((not (or unread undownloaded unseen))
7421 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7422 (gnus-data-number (car gnus-newsgroup-data)))
7423 ;; Find the first unread article.
7425 (let ((data gnus-newsgroup-data))
7427 (let ((num (gnus-data-number (car data))))
7428 (or (memq num gnus-newsgroup-unfetched)
7429 (not (or (and unread
7430 (memq num gnus-newsgroup-unreads))
7432 (memq num gnus-newsgroup-undownloaded))
7434 (memq num gnus-newsgroup-unseen)
7435 (memq num gnus-newsgroup-unreads)))))))
7436 (setq data (cdr data)))
7440 (goto-char (gnus-data-pos (car data)))
7441 (gnus-data-number (car data)))
7442 (gnus-message 3 "No more%s articles"
7443 (let* ((r (when unread " unread"))
7444 (d (when undownloaded " undownloaded"))
7445 (s (when unseen " unseen"))
7446 (l (delq nil (list r d s))))
7447 (cond ((= 3 (length l))
7448 (concat r "," d ", or" s))
7450 (concat (car l) ", or" (cadr l)))
7457 (gnus-summary-position-point))))))
7459 (defun gnus-summary-next-subject (n &optional unread dont-display)
7460 "Go to next N'th summary line.
7461 If N is negative, go to the previous N'th subject line.
7462 If UNREAD is non-nil, only unread articles are selected.
7463 The difference between N and the actual number of steps taken is
7466 (let ((backward (< n 0))
7470 (gnus-summary-find-prev unread)
7471 (gnus-summary-find-next unread)))
7472 (unless (zerop (setq n (1- n)))
7473 (gnus-summary-show-thread)))
7475 (gnus-message 7 "No more%s articles"
7476 (if unread " unread" "")))
7477 (unless dont-display
7478 (gnus-summary-recenter)
7479 (gnus-summary-position-point))
7482 (defun gnus-summary-next-unread-subject (n)
7483 "Go to next N'th unread summary line."
7485 (gnus-summary-next-subject n t))
7487 (defun gnus-summary-prev-subject (n &optional unread)
7488 "Go to previous N'th summary line.
7489 If optional argument UNREAD is non-nil, only unread article is selected."
7491 (gnus-summary-next-subject (- n) unread))
7493 (defun gnus-summary-prev-unread-subject (n)
7494 "Go to previous N'th unread summary line."
7496 (gnus-summary-next-subject (- n) t))
7498 (defun gnus-summary-goto-subjects (articles)
7499 "Insert the subject header for ARTICLES in the current buffer."
7501 (dolist (article articles)
7502 (gnus-summary-goto-subject article t)))
7503 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7504 (gnus-summary-position-point))
7506 (defun gnus-summary-goto-subject (article &optional force silent)
7507 "Go to the subject line of ARTICLE.
7508 If FORCE, also allow jumping to articles not currently shown."
7509 (interactive "nArticle number: ")
7510 (unless (numberp article)
7511 (error "Article %s is not a number" article))
7513 (data (gnus-data-find article)))
7514 ;; We read in the article if we have to.
7517 (gnus-summary-insert-subject
7519 (if (or (numberp force) (vectorp force)) force)
7521 (setq data (gnus-data-find article)))
7526 (gnus-message 3 "Can't find article %d" article))
7528 (let ((pt (gnus-data-pos data)))
7530 (gnus-summary-set-article-display-arrow pt))
7531 (gnus-summary-position-point)
7534 ;; Walking around summary lines with displaying articles.
7536 (defun gnus-summary-expand-window (&optional arg)
7537 "Make the summary buffer take up the entire Emacs frame.
7538 Given a prefix, will force an `article' buffer configuration."
7541 (gnus-configure-windows 'article 'force)
7542 (gnus-configure-windows 'summary 'force)))
7544 (defun gnus-summary-display-article (article &optional all-header)
7545 "Display ARTICLE in article buffer."
7546 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7547 (with-current-buffer gnus-article-buffer
7548 (eq major-mode 'gnus-article-mode)))
7549 (gnus-article-setup-buffer))
7550 (gnus-set-global-variables)
7551 (with-current-buffer gnus-article-buffer
7552 (setq gnus-article-charset gnus-newsgroup-charset)
7553 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7554 (mm-enable-multibyte))
7558 (if gnus-summary-display-article-function
7559 (funcall gnus-summary-display-article-function article all-header)
7560 (gnus-article-prepare article all-header))
7561 (gnus-run-hooks 'gnus-select-article-hook)
7562 (when (and gnus-current-article
7563 (not (zerop gnus-current-article)))
7564 (gnus-summary-goto-subject gnus-current-article))
7565 (gnus-summary-recenter)
7566 (when (and gnus-use-trees gnus-show-threads)
7567 (gnus-possibly-generate-tree article)
7568 (gnus-highlight-selected-tree article))
7569 ;; Successfully display article.
7570 (gnus-article-set-window-start
7571 (cdr (assq article gnus-newsgroup-bookmarks))))))
7573 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7574 "Select the current article.
7575 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7576 non-nil, the article will be re-fetched even if it already present in
7577 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7579 ;; Make sure we are in the summary buffer to work around bbdb bug.
7580 (unless (eq major-mode 'gnus-summary-mode)
7581 (set-buffer gnus-summary-buffer))
7582 (let ((article (or article (gnus-summary-article-number)))
7583 (all-headers (not (not all-headers))) ;Must be t or nil.
7584 gnus-summary-display-article-function)
7586 (gnus-summary-article-pseudo-p article)
7587 (error "This is a pseudo-article"))
7588 (with-current-buffer gnus-summary-buffer
7589 (if (or (and gnus-single-article-buffer
7590 (or (null gnus-current-article)
7591 (null gnus-article-current)
7592 (null (get-buffer gnus-article-buffer))
7593 (not (eq article (cdr gnus-article-current)))
7594 (not (equal (car gnus-article-current)
7595 gnus-newsgroup-name))
7596 (not (get-buffer gnus-original-article-buffer))))
7597 (and (not gnus-single-article-buffer)
7598 (or (null gnus-current-article)
7599 (not (get-buffer gnus-original-article-buffer))
7600 (not (eq gnus-current-article article))))
7602 ;; The requested article is different from the current article.
7604 (gnus-summary-display-article article all-headers)
7605 (when (gnus-buffer-live-p gnus-article-buffer)
7606 (with-current-buffer gnus-article-buffer
7607 (if (not gnus-article-decoded-p) ;; a local variable
7608 (mm-disable-multibyte))))
7609 (gnus-article-set-window-start
7610 (cdr (assq article gnus-newsgroup-bookmarks)))
7614 (defun gnus-summary-force-verify-and-decrypt ()
7615 "Display buttons for signed/encrypted parts and verify/decrypt them."
7617 (let ((mm-verify-option 'known)
7618 (mm-decrypt-option 'known)
7619 (gnus-article-emulate-mime t)
7620 (gnus-buttonized-mime-types (append (list "multipart/signed"
7621 "multipart/encrypted")
7622 gnus-buttonized-mime-types)))
7623 (gnus-summary-select-article nil 'force)))
7625 (defun gnus-summary-set-current-mark (&optional current-mark)
7626 "Obsolete function."
7629 (defun gnus-summary-next-article (&optional unread subject backward push)
7630 "Select the next article.
7631 If UNREAD, only unread articles are selected.
7632 If SUBJECT, only articles with SUBJECT are selected.
7633 If BACKWARD, the previous article is selected instead of the next."
7635 ;; Make sure we are in the summary buffer.
7636 (unless (eq major-mode 'gnus-summary-mode)
7637 (set-buffer gnus-summary-buffer))
7639 ;; Is there such an article?
7640 ((and (gnus-summary-search-forward unread subject backward)
7641 (or (gnus-summary-display-article (gnus-summary-article-number))
7642 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7643 (gnus-summary-position-point))
7644 ;; If not, we try the first unread, if that is wanted.
7646 gnus-auto-select-same
7647 (gnus-summary-first-unread-article))
7648 (gnus-summary-position-point)
7649 (gnus-message 6 "Wrapped"))
7650 ;; Try to get next/previous article not displayed in this group.
7651 ((and gnus-auto-extend-newsgroup
7652 (not unread) (not subject))
7653 (gnus-summary-goto-article
7654 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7655 nil (count-lines (point-min) (point))))
7656 ;; Go to next/previous group.
7658 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7659 (gnus-summary-jump-to-group gnus-newsgroup-name))
7660 (let ((cmd (if (featurep 'xemacs)
7662 last-command-event))
7664 (with-current-buffer gnus-group-buffer
7667 (if (eq gnus-keep-same-level 'best)
7668 (gnus-summary-best-group gnus-newsgroup-name)
7669 (gnus-summary-search-group backward gnus-keep-same-level))))
7670 ;; For some reason, the group window gets selected. We change
7672 (select-window (get-buffer-window (current-buffer)))
7673 ;; Select next unread newsgroup automagically.
7675 ((or (not gnus-auto-select-next)
7677 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7678 ((or (eq gnus-auto-select-next 'quietly)
7679 (and (eq gnus-auto-select-next 'slightly-quietly)
7681 (and (eq gnus-auto-select-next 'almost-quietly)
7682 (gnus-summary-last-article-p)))
7684 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7686 (gnus-message 7 "No more%s articles (%s)..."
7687 (if unread " unread" "")
7688 (if group (concat "selecting " group)
7690 (gnus-summary-next-group nil group backward)))
7692 (when (gnus-key-press-event-p last-input-event)
7693 (gnus-summary-walk-group-buffer
7694 gnus-newsgroup-name cmd unread backward point))))))))
7696 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7697 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7698 (?\C-p (gnus-group-prev-unread-group 1))))
7699 (cursor-in-echo-area t)
7700 keve key group ended prompt)
7701 (with-current-buffer gnus-group-buffer
7704 (if (eq gnus-keep-same-level 'best)
7705 (gnus-summary-best-group gnus-newsgroup-name)
7706 (gnus-summary-search-group backward gnus-keep-same-level))))
7710 "No more%s articles%s " (if unread " unread" "")
7712 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7713 (format " (Type %s for %s [%s])"
7714 (single-key-description cmd)
7715 (gnus-group-decoded-name group)
7716 (gnus-group-unread group))
7717 (format " (Type %s to exit %s)"
7718 (single-key-description cmd)
7719 (gnus-group-decoded-name gnus-newsgroup-name)))))
7720 ;; Confirm auto selection.
7721 (setq key (car (setq keve (gnus-read-event-char prompt)))
7724 ((assq key keystrokes)
7725 (let ((obuf (current-buffer)))
7726 (switch-to-buffer gnus-group-buffer)
7728 (gnus-group-jump-to-group group))
7729 (eval (cadr (assq key keystrokes)))
7730 (setq group (gnus-group-group-name))
7731 (switch-to-buffer obuf))
7735 (gnus-ephemeral-group-p gnus-newsgroup-name))
7737 (gnus-summary-next-group nil group backward)))
7739 (push (cdr keve) unread-command-events))))))
7741 (defun gnus-summary-next-unread-article ()
7742 "Select unread article after current one."
7744 (gnus-summary-next-article
7745 (or (not (eq gnus-summary-goto-unread 'never))
7746 (gnus-summary-last-article-p (gnus-summary-article-number)))
7747 (and gnus-auto-select-same
7748 (gnus-summary-article-subject))))
7750 (defun gnus-summary-prev-article (&optional unread subject)
7751 "Select the article before the current one.
7752 If UNREAD is non-nil, only unread articles are selected."
7754 (gnus-summary-next-article unread subject t))
7756 (defun gnus-summary-prev-unread-article ()
7757 "Select unread article before current one."
7759 (gnus-summary-prev-article
7760 (or (not (eq gnus-summary-goto-unread 'never))
7761 (gnus-summary-first-article-p (gnus-summary-article-number)))
7762 (and gnus-auto-select-same
7763 (gnus-summary-article-subject))))
7765 (defun gnus-summary-next-page (&optional lines circular stop)
7766 "Show next page of the selected article.
7767 If at the end of the current article, select the next article.
7768 LINES says how many lines should be scrolled up.
7770 If CIRCULAR is non-nil, go to the start of the article instead of
7771 selecting the next article when reaching the end of the current
7774 If STOP is non-nil, just stop when reaching the end of the message.
7776 Also see the variable `gnus-article-skip-boring'."
7778 (setq gnus-summary-buffer (current-buffer))
7779 (gnus-set-global-variables)
7780 (let ((article (gnus-summary-article-number))
7781 (article-window (get-buffer-window gnus-article-buffer t))
7783 ;; If the buffer is empty, we have no article.
7785 (error "No article to select"))
7786 (gnus-configure-windows 'article)
7787 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7788 (if (and (eq gnus-summary-goto-unread 'never)
7789 (not (gnus-summary-last-article-p article)))
7790 (gnus-summary-next-article)
7791 (gnus-summary-next-unread-article))
7792 (if (or (null gnus-current-article)
7793 (null gnus-article-current)
7794 (/= article (cdr gnus-article-current))
7795 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7796 ;; Selected subject is different from current article's.
7797 (gnus-summary-display-article article)
7798 (when article-window
7799 (gnus-eval-in-buffer-window gnus-article-buffer
7800 (setq endp (or (gnus-article-next-page lines)
7801 (gnus-article-only-boring-p))))
7803 (cond ((or stop gnus-summary-stop-at-end-of-message)
7804 (gnus-message 3 "End of message"))
7806 (gnus-summary-beginning-of-article))
7808 (gnus-message 3 "End of message"))
7810 (if (and (eq gnus-summary-goto-unread 'never)
7811 (not (gnus-summary-last-article-p article)))
7812 (gnus-summary-next-article)
7813 (gnus-summary-next-unread-article))))))))
7814 (gnus-summary-recenter)
7815 (gnus-summary-position-point)))
7817 (defun gnus-summary-prev-page (&optional lines move)
7818 "Show previous page of selected article.
7819 Argument LINES specifies lines to be scrolled down.
7820 If MOVE, move to the previous unread article if point is at
7821 the beginning of the buffer."
7823 (let ((article (gnus-summary-article-number))
7824 (article-window (get-buffer-window gnus-article-buffer t))
7826 (gnus-configure-windows 'article)
7827 (if (or (null gnus-current-article)
7828 (null gnus-article-current)
7829 (/= article (cdr gnus-article-current))
7830 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7831 ;; Selected subject is different from current article's.
7832 (gnus-summary-display-article article)
7833 (gnus-summary-recenter)
7834 (when article-window
7835 (gnus-eval-in-buffer-window gnus-article-buffer
7836 (setq endp (gnus-article-prev-page lines)))
7837 (when (and move endp)
7839 (gnus-message 3 "Beginning of message"))
7841 (if (and (eq gnus-summary-goto-unread 'never)
7842 (not (gnus-summary-first-article-p article)))
7843 (gnus-summary-prev-article)
7844 (gnus-summary-prev-unread-article))))))))
7845 (gnus-summary-position-point))
7847 (defun gnus-summary-prev-page-or-article (&optional lines)
7848 "Show previous page of selected article.
7849 Argument LINES specifies lines to be scrolled down.
7850 If at the beginning of the article, go to the next article."
7852 (gnus-summary-prev-page lines t))
7854 (defun gnus-summary-scroll-up (lines)
7855 "Scroll up (or down) one line current article.
7856 Argument LINES specifies lines to be scrolled up (or down if negative).
7857 If no article is selected, then the current article will be selected first."
7859 (gnus-configure-windows 'article)
7860 (gnus-summary-show-thread)
7861 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7862 (gnus-eval-in-buffer-window gnus-article-buffer
7864 (when (gnus-article-next-page lines)
7865 (gnus-message 3 "End of message")))
7867 (gnus-article-prev-page (- lines))))))
7868 (gnus-summary-recenter)
7869 (gnus-summary-position-point))
7871 (defun gnus-summary-scroll-down (lines)
7872 "Scroll down (or up) one line current article.
7873 Argument LINES specifies lines to be scrolled down (or up if negative).
7874 If no article is selected, then the current article will be selected first."
7876 (gnus-summary-scroll-up (- lines)))
7878 (defun gnus-summary-next-same-subject ()
7879 "Select next article which has the same subject as current one."
7881 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7883 (defun gnus-summary-prev-same-subject ()
7884 "Select previous article which has the same subject as current one."
7886 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7888 (defun gnus-summary-next-unread-same-subject ()
7889 "Select next unread article which has the same subject as current one."
7891 (gnus-summary-next-article t (gnus-summary-article-subject)))
7893 (defun gnus-summary-prev-unread-same-subject ()
7894 "Select previous unread article which has the same subject as current one."
7896 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7898 (defun gnus-summary-first-unread-article ()
7899 "Select the first unread article.
7900 Return nil if there are no unread articles."
7903 (when (gnus-summary-first-subject t)
7904 (gnus-summary-show-thread)
7905 (gnus-summary-first-subject t)
7906 (gnus-summary-display-article (gnus-summary-article-number)))
7907 (gnus-summary-position-point)))
7909 (defun gnus-summary-first-unread-subject ()
7910 "Place the point on the subject line of the first unread article.
7911 Return nil if there are no unread articles."
7914 (when (gnus-summary-first-subject t)
7915 (gnus-summary-show-thread)
7916 (gnus-summary-first-subject t))
7917 (gnus-summary-position-point)))
7919 (defun gnus-summary-first-unseen-subject ()
7920 "Place the point on the subject line of the first unseen article.
7921 Return nil if there are no unseen articles."
7924 (when (gnus-summary-first-subject nil nil t)
7925 (gnus-summary-show-thread)
7926 (gnus-summary-first-subject nil nil t))
7927 (gnus-summary-position-point)))
7929 (defun gnus-summary-first-unseen-or-unread-subject ()
7930 "Place the point on the subject line of the first unseen and unread article.
7931 If all article have been seen, on the subject line of the first unread
7935 (unless (when (gnus-summary-first-subject nil nil t)
7936 (gnus-summary-show-thread)
7937 (gnus-summary-first-subject nil nil t))
7938 (when (gnus-summary-first-subject t)
7939 (gnus-summary-show-thread)
7940 (gnus-summary-first-subject t)))
7941 (gnus-summary-position-point)))
7943 (defun gnus-summary-first-article ()
7944 "Select the first article.
7945 Return nil if there are no articles."
7948 (when (gnus-summary-first-subject)
7949 (gnus-summary-show-thread)
7950 (gnus-summary-first-subject)
7951 (gnus-summary-display-article (gnus-summary-article-number)))
7952 (gnus-summary-position-point)))
7954 (defun gnus-summary-best-unread-article (&optional arg)
7955 "Select the unread article with the highest score.
7956 If given a prefix argument, select the next unread article that has a
7957 score higher than the default score."
7959 (let ((article (if arg
7960 (gnus-summary-better-unread-subject)
7961 (gnus-summary-best-unread-subject))))
7963 (gnus-summary-goto-article article)
7964 (error "No unread articles"))))
7966 (defun gnus-summary-best-unread-subject ()
7967 "Select the unread subject with the highest score."
7969 (let ((best -1000000)
7970 (data gnus-newsgroup-data)
7973 (and (gnus-data-unread-p (car data))
7975 (gnus-summary-article-score (gnus-data-number (car data))))
7978 article (gnus-data-number (car data))))
7979 (setq data (cdr data)))
7981 (gnus-summary-goto-subject article))
7982 (gnus-summary-position-point)
7985 (defun gnus-summary-better-unread-subject ()
7986 "Select the first unread subject that has a score over the default score."
7988 (let ((data gnus-newsgroup-data)
7990 (while (and (setq article (gnus-data-number (car data)))
7991 (or (gnus-data-read-p (car data))
7992 (not (> (gnus-summary-article-score article)
7993 gnus-summary-default-score))))
7994 (setq data (cdr data)))
7996 (gnus-summary-goto-subject article))
7997 (gnus-summary-position-point)
8000 (defun gnus-summary-last-subject ()
8001 "Go to the last displayed subject line in the group."
8002 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8004 (gnus-summary-goto-subject article))))
8006 (defun gnus-summary-goto-article (article &optional all-headers force)
8007 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8008 If ALL-HEADERS is non-nil, no header lines are hidden.
8009 If FORCE, go to the article even if it isn't displayed. If FORCE
8010 is a number, it is the line the article is to be displayed on."
8013 (gnus-completing-read
8014 "Article number or Message-ID"
8015 (mapcar 'int-to-string gnus-newsgroup-limit))
8019 (if (and (stringp article)
8020 (string-match "@\\|%40" article))
8021 (gnus-summary-refer-article article)
8022 (when (stringp article)
8023 (setq article (string-to-number article)))
8024 (if (gnus-summary-goto-subject article force)
8025 (gnus-summary-display-article article all-headers)
8026 (gnus-message 4 "Couldn't go to article %s" article) nil))
8027 (gnus-summary-position-point)))
8029 (defun gnus-summary-goto-last-article ()
8030 "Go to the previously read article."
8033 (when gnus-last-article
8034 (gnus-summary-goto-article gnus-last-article nil t))
8035 (gnus-summary-position-point)))
8037 (defun gnus-summary-pop-article (number)
8038 "Pop one article off the history and go to the previous.
8039 NUMBER articles will be popped off."
8042 (setq gnus-newsgroup-history
8043 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8045 (gnus-summary-goto-article (car to) nil t)
8046 (error "Article history empty")))
8047 (gnus-summary-position-point))
8049 ;; Summary commands and functions for limiting the summary buffer.
8051 (defun gnus-summary-limit-to-articles (n)
8052 "Limit the summary buffer to the next N articles.
8053 If not given a prefix, use the process marked articles instead."
8056 (let ((articles (gnus-summary-work-articles n)))
8057 (setq gnus-newsgroup-processable nil)
8058 (gnus-summary-limit articles))
8059 (gnus-summary-position-point)))
8061 (defun gnus-summary-pop-limit (&optional total)
8062 "Restore the previous limit.
8063 If given a prefix, remove all limits."
8066 (setq gnus-newsgroup-limits
8067 (list (mapcar (lambda (h) (mail-header-number h))
8068 gnus-newsgroup-headers))))
8069 (unless gnus-newsgroup-limits
8070 (error "No limit to pop"))
8072 (gnus-summary-limit nil 'pop)
8073 (gnus-summary-position-point)))
8075 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8076 "Limit the summary buffer to articles that have subjects that match a regexp.
8077 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8079 (list (read-string (if current-prefix-arg
8080 "Exclude subject (regexp): "
8081 "Limit to subject (regexp): "))
8082 nil current-prefix-arg))
8084 (setq header "subject"))
8085 (when (not (equal "" subject))
8087 (let ((articles (gnus-summary-find-matching
8088 (or header "subject") subject 'all nil nil
8091 (error "Found no matches for \"%s\"" subject))
8092 (gnus-summary-limit articles))
8093 (gnus-summary-position-point))))
8095 (defun gnus-summary-limit-to-author (from &optional not-matching)
8096 "Limit the summary buffer to articles that have authors that match a regexp.
8097 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8099 (list (read-string (if current-prefix-arg
8100 "Exclude author (regexp): "
8101 "Limit to author (regexp): "))
8102 current-prefix-arg))
8103 (gnus-summary-limit-to-subject from "from" not-matching))
8105 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8106 "Limit the summary buffer to articles with the given RECIPIENT.
8108 If NOT-MATCHING, exclude RECIPIENT.
8110 To and Cc headers are checked. You need to include them in
8111 `nnmail-extra-headers'."
8112 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8114 (list (read-string (format "%s recipient (regexp): "
8115 (if current-prefix-arg "Exclude" "Limit to")))
8116 current-prefix-arg))
8117 (when (not (equal "" recipient))
8119 (if (memq 'To nnmail-extra-headers)
8120 (gnus-summary-find-matching
8121 (cons 'extra 'To) recipient 'all nil nil
8124 1 "`To' isn't present in `nnmail-extra-headers'")
8128 (if (memq 'Cc nnmail-extra-headers)
8129 (gnus-summary-find-matching
8130 (cons 'extra 'Cc) recipient 'all nil nil
8133 1 "`Cc' isn't present in `nnmail-extra-headers'")
8138 ;; We need the numbers that are in both lists:
8140 (and (memq a to) a))
8144 (error "Found no matches for \"%s\"" recipient))
8145 (gnus-summary-limit articles))
8146 (gnus-summary-position-point))))
8148 (defun gnus-summary-limit-to-address (address &optional not-matching)
8149 "Limit the summary buffer to articles with the given ADDRESS.
8151 If NOT-MATCHING, exclude ADDRESS.
8153 To, Cc and From headers are checked. You need to include `To' and `Cc'
8154 in `nnmail-extra-headers'."
8156 (list (read-string (format "%s address (regexp): "
8157 (if current-prefix-arg "Exclude" "Limit to")))
8158 current-prefix-arg))
8159 (when (not (equal "" address))
8161 (if (memq 'To nnmail-extra-headers)
8162 (gnus-summary-find-matching
8163 (cons 'extra 'To) address 'all nil nil
8166 1 "`To' isn't present in `nnmail-extra-headers'")
8170 (if (memq 'Cc nnmail-extra-headers)
8171 (gnus-summary-find-matching
8172 (cons 'extra 'Cc) address 'all nil nil
8175 1 "`Cc' isn't present in `nnmail-extra-headers'")
8179 (gnus-summary-find-matching "from" address
8180 'all nil nil not-matching))
8183 ;; We need the numbers that are in all lists:
8187 (mapcar (lambda (a) (car (memq a from))) to))
8189 (mapcar (lambda (a) (car (memq a from))) cc)
8190 (mapcar (lambda (a) (car (memq a from)))
8191 (mapcar (lambda (a) (car (memq a to)))
8193 (nconc (if (eq to t) nil to)
8194 (if (eq cc t) nil cc)
8197 (error "Found no matches for \"%s\"" address))
8198 (gnus-summary-limit articles))
8199 (gnus-summary-position-point))))
8201 (defun gnus-summary-limit-strange-charsets-predicate (header)
8202 (when (fboundp 'char-charset)
8203 (let ((string (concat (mail-header-subject header)
8204 (mail-header-from header)))
8206 (dotimes (i (1- (length string)))
8207 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8208 (when (string-match "unicode\\|big\\|japanese" charset)
8212 (defun gnus-summary-limit-to-predicate (predicate)
8213 "Limit to articles where PREDICATE returns non-nil.
8214 PREDICATE will be called with the header structures of the
8216 (let ((articles nil)
8217 (case-fold-search t))
8218 (dolist (header gnus-newsgroup-headers)
8219 (when (funcall predicate header)
8220 (push (mail-header-number header) articles)))
8221 (gnus-summary-limit (nreverse articles))))
8223 (defun gnus-summary-limit-to-age (age &optional younger-p)
8224 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8225 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8226 articles that are younger than AGE days."
8228 (let ((younger current-prefix-arg)
8231 (while (not days-got)
8232 (setq days (if younger
8233 (read-string "Limit to articles younger than (in days, older when negative): ")
8235 "Limit to articles older than (in days, younger when negative): ")))
8236 (when (> (length days) 0)
8237 (setq days (read days)))
8242 (setq younger (not younger))
8243 (setq days (* days -1))))
8244 (message "Please enter a number.")
8246 (list days younger)))
8248 (let ((data gnus-newsgroup-data)
8249 (cutoff (days-to-time age))
8250 articles d date is-younger)
8251 (while (setq d (pop data))
8252 (when (and (vectorp (gnus-data-header d))
8253 (setq date (mail-header-date (gnus-data-header d))))
8254 (setq is-younger (time-less-p
8255 (time-since (gnus-date-get-time date))
8260 (push (gnus-data-number d) articles))))
8261 (gnus-summary-limit (nreverse articles)))
8262 (gnus-summary-position-point)))
8264 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8265 "Limit the summary buffer to articles that match an 'extra' header."
8269 (gnus-completing-read
8270 (if current-prefix-arg
8271 "Exclude extra header"
8272 "Limit extra header")
8273 (mapcar 'symbol-name gnus-extra-headers)
8275 (symbol-name (car gnus-extra-headers))))))
8277 (read-string (format "%s header %s (regexp): "
8278 (if current-prefix-arg "Exclude" "Limit to")
8280 current-prefix-arg)))
8281 (when (not (equal "" regexp))
8283 (let ((articles (gnus-summary-find-matching
8284 (cons 'extra header) regexp 'all nil nil
8287 (error "Found no matches for \"%s\"" regexp))
8288 (gnus-summary-limit articles))
8289 (gnus-summary-position-point))))
8291 (defun gnus-summary-limit-to-display-predicate ()
8292 "Limit the summary buffer to the predicated in the `display' group parameter."
8294 (unless gnus-newsgroup-display
8295 (error "There is no `display' group parameter"))
8297 (dolist (gnus-number gnus-newsgroup-articles)
8298 (when (funcall gnus-newsgroup-display)
8299 (push gnus-number articles)))
8300 (gnus-summary-limit articles))
8301 (gnus-summary-position-point))
8303 (defun gnus-summary-limit-to-unread (&optional all)
8304 "Limit the summary buffer to articles that are not marked as read.
8305 If ALL is non-nil, limit strictly to unread articles."
8308 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8309 (gnus-summary-limit-to-marks
8310 ;; Concat all the marks that say that an article is read and have
8312 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8313 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8314 gnus-low-score-mark gnus-expirable-mark
8315 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8316 gnus-duplicate-mark)
8319 (defun gnus-summary-limit-to-headers (match &optional reverse)
8320 "Limit the summary buffer to articles that have headers that match MATCH.
8321 If REVERSE (the prefix), limit to articles that don't match."
8322 (interactive "sMatch headers (regexp): \nP")
8323 (gnus-summary-limit-to-bodies match reverse t))
8325 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8326 "Limit the summary buffer to articles that have bodies that match MATCH.
8327 If REVERSE (the prefix), limit to articles that don't match."
8328 (interactive "sMatch body (regexp): \nP")
8329 (let ((articles nil)
8330 (gnus-select-article-hook nil) ;Disable hook.
8331 (gnus-article-prepare-hook nil)
8332 (gnus-use-article-prefetch nil)
8333 (gnus-keep-backlog nil)
8334 (gnus-break-pages nil)
8335 (gnus-summary-display-arrow nil)
8336 (gnus-updated-mode-lines nil)
8337 (gnus-auto-center-summary nil)
8338 (gnus-display-mime-function nil))
8339 (dolist (data gnus-newsgroup-data)
8340 (let (gnus-mark-article-hook)
8341 (gnus-summary-select-article t t nil (gnus-data-number data)))
8342 (with-current-buffer gnus-article-buffer
8344 (let* ((case-fold-search t)
8346 (re-search-backward match nil t)
8347 (re-search-forward match nil t))))
8348 (when (or (and found
8352 (push (gnus-data-number data) articles)))))
8354 (message "No messages matched")
8355 (gnus-summary-limit articles)))
8356 (gnus-summary-position-point))
8358 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8359 "Limit the summary buffer to articles that aren't part on any thread.
8360 If THREADSP (the prefix), limit to articles that are in threads."
8362 (let ((articles nil)
8365 (dolist (thread gnus-newsgroup-threads)
8366 (if (stringp (car thread))
8367 (dolist (thread (cdr thread))
8368 (push thread threads))
8369 (push thread threads)))
8370 (dolist (thread threads)
8371 (setq thread-articles (gnus-articles-in-thread thread))
8372 (when (or (and threadsp
8373 (> (length thread-articles) 1))
8375 (= (length thread-articles) 1)))
8376 (setq articles (nconc thread-articles articles))))
8378 (message "No messages matched")
8379 (gnus-summary-limit articles))
8380 (gnus-summary-position-point)))
8382 (defun gnus-summary-limit-to-replied (&optional unreplied)
8383 "Limit the summary buffer to replied articles.
8384 If UNREPLIED (the prefix), limit to unreplied articles."
8388 (gnus-set-difference gnus-newsgroup-articles
8389 gnus-newsgroup-replied))
8390 (gnus-summary-limit gnus-newsgroup-replied))
8391 (gnus-summary-position-point))
8393 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8394 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8395 If REVERSE, limit the summary buffer to articles that are marked
8396 with MARKS. MARKS can either be a string of marks or a list of marks.
8397 Returns how many articles were removed."
8398 (interactive "sMarks: ")
8399 (gnus-summary-limit-to-marks marks t))
8401 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8402 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8403 If REVERSE (the prefix), limit the summary buffer to articles that are
8404 not marked with MARKS. MARKS can either be a string of marks or a
8406 Returns how many articles were removed."
8407 (interactive "sMarks: \nP")
8409 (let ((data gnus-newsgroup-data)
8410 (marks (if (listp marks) marks
8411 (append marks nil))) ; Transform to list.
8414 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8415 (memq (gnus-data-mark (car data)) marks))
8416 (push (gnus-data-number (car data)) articles))
8417 (setq data (cdr data)))
8418 (gnus-summary-limit articles))
8419 (gnus-summary-position-point)))
8421 (defun gnus-summary-limit-to-score (score)
8422 "Limit to articles with score at or above SCORE."
8423 (interactive "NLimit to articles with score of at least: ")
8424 (let ((data gnus-newsgroup-data)
8427 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8429 (push (gnus-data-number (car data)) articles))
8430 (setq data (cdr data)))
8432 (gnus-summary-limit articles)
8433 (gnus-summary-position-point))))
8435 (defun gnus-summary-limit-to-unseen ()
8436 "Limit to unseen articles."
8439 (gnus-summary-limit gnus-newsgroup-unseen)
8440 (gnus-summary-position-point)))
8442 (defun gnus-summary-limit-include-thread (id)
8443 "Display all the hidden articles that is in the thread with ID in it.
8444 When called interactively, ID is the Message-ID of the current
8446 (interactive (list (mail-header-id (gnus-summary-article-header))))
8447 (let ((articles (gnus-articles-in-thread
8448 (gnus-id-to-thread (gnus-root-id id)))))
8450 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8451 (gnus-summary-limit-include-matching-articles
8453 (regexp-quote (gnus-simplify-subject-re
8454 (mail-header-subject (gnus-id-to-header id)))))
8455 (gnus-summary-position-point))))
8457 (defun gnus-summary-limit-include-matching-articles (header regexp)
8458 "Display all the hidden articles that have HEADERs that match REGEXP."
8459 (interactive (list (read-string "Match on header: ")
8460 (read-string "Regexp: ")))
8461 (let ((articles (gnus-find-matching-articles header regexp)))
8463 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8464 (gnus-summary-position-point))))
8466 (defun gnus-summary-insert-dormant-articles ()
8467 "Insert all the dormant articles for this group into the current buffer."
8469 (let ((gnus-verbose (max 6 gnus-verbose)))
8470 (if (not gnus-newsgroup-dormant)
8471 (gnus-message 3 "No dormant articles for this group")
8472 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8474 (defun gnus-summary-insert-ticked-articles ()
8475 "Insert ticked articles for this group into the current buffer."
8477 (let ((gnus-verbose (max 6 gnus-verbose)))
8478 (if (not gnus-newsgroup-marked)
8479 (gnus-message 3 "No ticked articles for this group")
8480 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8482 (defun gnus-summary-limit-include-dormant ()
8483 "Display all the hidden articles that are marked as dormant.
8484 Note that this command only works on a subset of the articles currently
8485 fetched for this group."
8487 (unless gnus-newsgroup-dormant
8488 (error "There are no dormant articles in this group"))
8490 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8491 (gnus-summary-position-point)))
8493 (defun gnus-summary-limit-exclude-dormant ()
8494 "Hide all dormant articles."
8497 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8498 (gnus-summary-position-point)))
8500 (defun gnus-summary-limit-exclude-childless-dormant ()
8501 "Hide all dormant articles that have no children."
8503 (let ((data (gnus-data-list t))
8504 articles d children)
8505 ;; Find all articles that are either not dormant or have
8507 (while (setq d (pop data))
8508 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8510 (gnus-article-children (gnus-data-number d)))
8513 (when (memq (car children) articles)
8518 (push (gnus-data-number d) articles)))
8521 (gnus-summary-limit articles)
8522 (gnus-summary-position-point))))
8524 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8525 "Mark all unread excluded articles as read.
8526 If ALL, mark even excluded ticked and dormants as read."
8528 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8529 (let ((articles (gnus-sorted-ndifference
8531 (mapcar (lambda (h) (mail-header-number h))
8532 gnus-newsgroup-headers)
8534 gnus-newsgroup-limit))
8536 (setq gnus-newsgroup-unreads
8537 (gnus-sorted-intersection gnus-newsgroup-unreads
8538 gnus-newsgroup-limit))
8540 (setq gnus-newsgroup-dormant nil
8541 gnus-newsgroup-marked nil
8542 gnus-newsgroup-reads
8544 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8545 gnus-newsgroup-reads))
8546 (while (setq article (pop articles))
8547 (unless (or (memq article gnus-newsgroup-dormant)
8548 (memq article gnus-newsgroup-marked))
8549 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8551 (defun gnus-summary-limit (articles &optional pop)
8553 ;; We pop the previous limit off the stack and use that.
8554 (setq articles (car gnus-newsgroup-limits)
8555 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8556 ;; We use the new limit, so we push the old limit on the stack.
8557 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8559 (setq gnus-newsgroup-limit articles)
8560 (let ((total (length gnus-newsgroup-data))
8561 (data (gnus-data-find-list (gnus-summary-article-number)))
8562 (gnus-summary-mark-below nil) ; Inhibit this.
8564 ;; This will do all the work of generating the new summary buffer
8565 ;; according to the new limit.
8566 (gnus-summary-prepare)
8567 ;; Hide any threads, possibly.
8568 (gnus-summary-maybe-hide-threads)
8569 ;; Try to return to the article you were at, or one in the
8572 ;; We try to find some article after the current one.
8574 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8577 (setq data (cdr data))))
8579 ;; If there is no data, that means that we were after the last
8580 ;; article. The same goes when we can't find any articles
8581 ;; after the current one.
8582 (goto-char (point-max))
8583 (gnus-summary-find-prev))
8584 (gnus-set-mode-line 'summary)
8585 ;; We return how many articles were removed from the summary
8586 ;; buffer as a result of the new limit.
8587 (- total (length gnus-newsgroup-data))))
8589 (defsubst gnus-invisible-cut-children (threads)
8592 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8597 (defsubst gnus-cut-thread (thread)
8598 "Go forwards in the thread until we find an article that we want to display."
8599 (when (or (eq gnus-fetch-old-headers 'some)
8600 (eq gnus-fetch-old-headers 'invisible)
8601 (numberp gnus-fetch-old-headers)
8602 (eq gnus-build-sparse-threads 'some)
8603 (eq gnus-build-sparse-threads 'more))
8604 ;; Deal with old-fetched headers and sparse threads.
8608 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8609 (gnus-summary-article-ancient-p
8610 (mail-header-number (car thread))))
8611 (if (or (<= (length (cdr thread)) 1)
8612 (eq gnus-fetch-old-headers 'invisible))
8613 (setq gnus-newsgroup-limit
8614 (delq (mail-header-number (car thread))
8615 gnus-newsgroup-limit)
8616 thread (cadr thread))
8617 (when (gnus-invisible-cut-children (cdr thread))
8618 (let ((th (cdr thread)))
8620 (if (memq (mail-header-number (caar th))
8621 gnus-newsgroup-limit)
8622 (setq thread (car th)
8624 (setq th (cdr th))))))))))
8627 (defun gnus-cut-threads (threads)
8628 "Cut off all uninteresting articles from the beginning of THREADS."
8629 (when (or (eq gnus-fetch-old-headers 'some)
8630 (eq gnus-fetch-old-headers 'invisible)
8631 (numberp gnus-fetch-old-headers)
8632 (eq gnus-build-sparse-threads 'some)
8633 (eq gnus-build-sparse-threads 'more))
8636 (setcar th (gnus-cut-thread (car th)))
8637 (setq th (cdr th)))))
8638 ;; Remove nixed out threads.
8641 (defun gnus-summary-initial-limit (&optional show-if-empty)
8642 "Figure out what the initial limit is supposed to be on group entry.
8643 This entails weeding out unwanted dormants, low-scored articles,
8644 fetch-old-headers verbiage, and so on."
8645 ;; Most groups have nothing to remove.
8646 (unless (or gnus-inhibit-limiting
8647 (and (null gnus-newsgroup-dormant)
8648 (eq gnus-newsgroup-display 'gnus-not-ignore)
8649 (not (eq gnus-fetch-old-headers 'some))
8650 (not (numberp gnus-fetch-old-headers))
8651 (not (eq gnus-fetch-old-headers 'invisible))
8652 (null gnus-summary-expunge-below)
8653 (not (eq gnus-build-sparse-threads 'some))
8654 (not (eq gnus-build-sparse-threads 'more))
8655 (null gnus-thread-expunge-below)))
8656 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8657 (setq gnus-newsgroup-limit nil)
8660 (unless (car (symbol-value node))
8661 ;; These threads have no parents -- they are roots.
8662 (let ((nodes (cdr (symbol-value node)))
8665 (if (and gnus-thread-expunge-below
8666 (< (gnus-thread-total-score (car nodes))
8667 gnus-thread-expunge-below))
8668 (gnus-expunge-thread (pop nodes))
8669 (setq thread (pop nodes))
8670 (gnus-summary-limit-children thread))))))
8671 gnus-newsgroup-dependencies)
8672 ;; If this limitation resulted in an empty group, we might
8673 ;; pop the previous limit and use it instead.
8674 (when (and (not gnus-newsgroup-limit)
8676 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8677 gnus-newsgroup-limit))
8679 (defun gnus-summary-limit-children (thread)
8680 "Return 1 if this subthread is visible and 0 if it is not."
8681 ;; First we get the number of visible children to this thread. This
8682 ;; is done by recursing down the thread using this function, so this
8683 ;; will really go down to a leaf article first, before slowly
8684 ;; working its way up towards the root.
8686 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8689 (apply '+ (mapcar 'gnus-summary-limit-children
8692 (number (mail-header-number (car thread)))
8695 (not (memq number gnus-newsgroup-marked))
8697 ;; If this article is dormant and has absolutely no visible
8698 ;; children, then this article isn't visible.
8699 (and (memq number gnus-newsgroup-dormant)
8701 ;; If this is "fetch-old-headered" and there is no
8702 ;; visible children, then we don't want this article.
8703 (and (or (eq gnus-fetch-old-headers 'some)
8704 (numberp gnus-fetch-old-headers))
8705 (gnus-summary-article-ancient-p number)
8707 ;; If this is "fetch-old-headered" and `invisible', then
8708 ;; we don't want this article.
8709 (and (eq gnus-fetch-old-headers 'invisible)
8710 (gnus-summary-article-ancient-p number))
8711 ;; If this is a sparsely inserted article with no children,
8712 ;; we don't want it.
8713 (and (eq gnus-build-sparse-threads 'some)
8714 (gnus-summary-article-sparse-p number)
8716 ;; If we use expunging, and this article is really
8717 ;; low-scored, then we don't want this article.
8718 (when (and gnus-summary-expunge-below
8720 (or (cdr (assq number gnus-newsgroup-scored))
8721 gnus-summary-default-score))
8722 gnus-summary-expunge-below))
8723 ;; We increase the expunge-tally here, but that has
8724 ;; nothing to do with the limits, really.
8725 (incf gnus-newsgroup-expunged-tally)
8726 ;; We also mark as read here, if that's wanted.
8727 (when (and gnus-summary-mark-below
8728 (< score gnus-summary-mark-below))
8729 (setq gnus-newsgroup-unreads
8730 (delq number gnus-newsgroup-unreads))
8731 (if gnus-newsgroup-auto-expire
8732 (push number gnus-newsgroup-expirable)
8733 (push (cons number gnus-low-score-mark)
8734 gnus-newsgroup-reads)))
8736 ;; Do the `display' group parameter.
8737 (and gnus-newsgroup-display
8738 (let ((gnus-number number))
8739 (not (funcall gnus-newsgroup-display))))))
8740 ;; Nope, invisible article.
8742 ;; Ok, this article is to be visible, so we add it to the limit
8744 (push number gnus-newsgroup-limit)
8747 (defun gnus-expunge-thread (thread)
8748 "Mark all articles in THREAD as read."
8749 (let* ((number (mail-header-number (car thread))))
8750 (incf gnus-newsgroup-expunged-tally)
8751 ;; We also mark as read here, if that's wanted.
8752 (setq gnus-newsgroup-unreads
8753 (delq number gnus-newsgroup-unreads))
8754 (if gnus-newsgroup-auto-expire
8755 (push number gnus-newsgroup-expirable)
8756 (push (cons number gnus-low-score-mark)
8757 gnus-newsgroup-reads)))
8758 ;; Go recursively through all subthreads.
8759 (mapcar 'gnus-expunge-thread (cdr thread)))
8761 ;; Summary article oriented commands
8763 (defun gnus-summary-refer-parent-article (n)
8764 "Refer parent article N times.
8765 If N is negative, go to ancestor -N instead.
8766 The difference between N and the number of articles fetched is returned."
8770 (when (not (natnump n))
8775 (setq header (gnus-summary-article-header))
8776 (if (and (eq (mail-header-number header)
8777 (cdr gnus-article-current))
8778 (equal gnus-newsgroup-name
8779 (car gnus-article-current)))
8780 ;; If we try to find the parent of the currently
8781 ;; displayed article, then we take a look at the actual
8782 ;; References header, since this is slightly more
8783 ;; reliable than the References field we got from the
8785 (with-current-buffer gnus-original-article-buffer
8786 (nnheader-narrow-to-headers)
8787 (unless (setq ref (message-fetch-field "references"))
8788 (when (setq ref (message-fetch-field "in-reply-to"))
8789 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8792 ;; It's not the current article, so we take a bet on
8793 ;; the value we got from the server.
8794 (mail-header-references header)))
8796 (not (equal ref "")))
8797 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8798 (gnus-message 1 "Couldn't find parent"))
8799 (gnus-message 1 "No references in article %d"
8800 (gnus-summary-article-number))
8803 (gnus-summary-position-point)
8806 (defun gnus-summary-refer-references ()
8807 "Fetch all articles mentioned in the References header.
8808 Return the number of articles fetched."
8810 (let ((ref (mail-header-references (gnus-summary-article-header)))
8811 (current (gnus-summary-article-number))
8815 (error "No References in the current article")
8816 ;; For each Message-ID in the References header...
8817 (while (string-match "<[^>]*>" ref)
8819 ;; ... fetch that article.
8820 (gnus-summary-refer-article
8821 (prog1 (match-string 0 ref)
8822 (setq ref (substring ref (match-end 0))))))
8823 (gnus-summary-goto-subject current)
8824 (gnus-summary-position-point)
8827 (defun gnus-summary-refer-thread (&optional limit)
8828 "Fetch all articles in the current thread.
8829 If no backend-specific 'request-thread function is available
8830 fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
8831 fetch what's specified by the `gnus-refer-thread-limit'
8834 (let ((id (mail-header-id (gnus-summary-article-header)))
8835 (gnus-summary-ignore-duplicates t)
8836 (limit (if limit (prefix-numeric-value limit)
8837 gnus-refer-thread-limit)))
8838 (if (gnus-check-backend-function 'request-thread gnus-newsgroup-name)
8839 (setq gnus-newsgroup-headers
8841 gnus-newsgroup-headers
8842 (gnus-request-thread id)
8843 'gnus-article-sort-by-number))
8844 (unless (eq gnus-fetch-old-headers 'invisible)
8845 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8846 ;; Retrieve the headers and read them in.
8848 (gnus-retrieve-headers
8850 (+ (mail-header-number
8851 (gnus-summary-article-header))
8853 gnus-newsgroup-end))
8854 gnus-newsgroup-name (* limit 2))
8855 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8857 (gnus-retrieve-headers (list gnus-newsgroup-end)
8858 gnus-newsgroup-name limit)
8859 (gnus-message 5 "Fetching headers for %s...done"
8860 gnus-newsgroup-name))))
8861 (when (eq gnus-headers-retrieved-by 'nov)
8862 (gnus-build-all-threads))
8863 (gnus-summary-limit-include-thread id)))
8865 (defun gnus-summary-refer-article (message-id)
8866 "Fetch an article specified by MESSAGE-ID."
8867 (interactive "sMessage-ID: ")
8868 (when (and (stringp message-id)
8869 (not (zerop (length message-id))))
8870 (setq message-id (gnus-replace-in-string message-id " " ""))
8871 ;; Construct the correct Message-ID if necessary.
8872 ;; Suggested by tale@pawl.rpi.edu.
8873 (unless (string-match "^<" message-id)
8874 (setq message-id (concat "<" message-id)))
8875 (unless (string-match ">$" message-id)
8876 (setq message-id (concat message-id ">")))
8877 ;; People often post MIDs from URLs, so unhex it:
8878 (unless (string-match "@" message-id)
8879 (setq message-id (gnus-url-unhex-string message-id)))
8880 (let* ((header (gnus-id-to-header message-id))
8882 (gnus-summary-article-sparse-p
8883 (mail-header-number header))
8884 (memq (mail-header-number header)
8885 gnus-newsgroup-limit)))
8888 ;; If the article is present in the buffer we just go to it.
8890 (or (not (gnus-summary-article-sparse-p
8891 (mail-header-number header)))
8894 (gnus-summary-goto-article
8895 (mail-header-number header) nil t)
8897 (gnus-summary-update-article (mail-header-number header)))))
8899 ;; We fetch the article.
8901 (dolist (gnus-override-method (gnus-refer-article-methods))
8902 (when (and (gnus-check-server gnus-override-method)
8903 ;; Fetch the header,
8904 (setq number (gnus-summary-insert-subject message-id)))
8905 ;; and display the article.
8906 (gnus-summary-select-article nil nil nil number)
8908 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8910 (defun gnus-refer-article-methods ()
8911 "Return a list of referable methods."
8913 ;; No method, so we default to current and native.
8914 ((null gnus-refer-article-method)
8915 (list gnus-current-select-method gnus-select-method))
8917 ((eq 'current gnus-refer-article-method)
8918 (list gnus-current-select-method))
8919 ;; List of select methods.
8920 ((not (and (symbolp (car gnus-refer-article-method))
8921 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8923 (dolist (method gnus-refer-article-method)
8924 (push (if (eq 'current method)
8925 gnus-current-select-method
8929 ;; One single select method.
8931 (list gnus-refer-article-method))))
8933 (defun gnus-summary-edit-parameters ()
8934 "Edit the group parameters of the current group."
8936 (gnus-group-edit-group gnus-newsgroup-name 'params))
8938 (defun gnus-summary-customize-parameters ()
8939 "Customize the group parameters of the current group."
8941 (gnus-group-customize gnus-newsgroup-name))
8943 (defun gnus-summary-enter-digest-group (&optional force)
8944 "Enter an nndoc group based on the current article.
8945 If FORCE, force a digest interpretation. If not, try
8946 to guess what the document format is."
8948 (let ((conf gnus-current-window-configuration))
8949 (save-window-excursion
8951 (let (gnus-article-prepare-hook
8952 gnus-display-mime-function
8954 (gnus-summary-select-article))))
8955 (setq gnus-current-window-configuration conf)
8956 (let* ((name (format "%s-%d"
8957 (gnus-group-prefixed-name
8958 gnus-newsgroup-name (list 'nndoc ""))
8959 (with-current-buffer gnus-summary-buffer
8960 gnus-current-article)))
8961 (ogroup gnus-newsgroup-name)
8962 (params (append (gnus-info-params (gnus-get-info ogroup))
8963 (list (cons 'to-group ogroup))
8964 (list (cons 'parent-group ogroup))
8965 (list (cons 'save-article-group ogroup))))
8966 (case-fold-search t)
8967 (buf (current-buffer))
8969 (with-current-buffer gnus-original-article-buffer
8970 ;; Have the digest group inherit the main mail address of
8971 ;; the parent article.
8972 (when (setq to-address (or (gnus-fetch-field "reply-to")
8973 (gnus-fetch-field "from")))
8976 (list (cons 'to-address
8977 (funcall gnus-decode-encoded-address-function
8979 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8980 (insert-buffer-substring gnus-original-article-buffer)
8981 ;; Remove lines that may lead nndoc to misinterpret the
8984 (goto-char (point-min))
8985 (or (search-forward "\n\n" nil t) (point)))
8986 (goto-char (point-min))
8987 (delete-matching-lines "^Path:\\|^From ")
8990 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8991 (gnus-newsgroup-ephemeral-ignored-charsets
8992 gnus-newsgroup-ignored-charsets))
8993 (gnus-group-read-ephemeral-group
8994 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8996 ,(if force 'mbox 'guess)))
8998 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9000 ;; Make all postings to this group go to the parent group.
9001 (nconc (gnus-info-params (gnus-get-info name))
9003 ;; Couldn't select this doc group.
9004 (switch-to-buffer buf)
9005 (gnus-set-global-variables)
9006 (gnus-configure-windows 'summary)
9007 (gnus-message 3 "Article couldn't be entered?"))
9008 (kill-buffer dig)))))
9010 (defun gnus-summary-read-document (n)
9011 "Open a new group based on the current article(s).
9012 This will allow you to read digests and other similar
9013 documents as newsgroups.
9014 Obeys the standard process/prefix convention."
9016 (let* ((ogroup gnus-newsgroup-name)
9017 (params (append (gnus-info-params (gnus-get-info ogroup))
9018 (list (cons 'to-group ogroup))))
9019 group egroup groups vgroup)
9020 (dolist (article (gnus-summary-work-articles n))
9021 (setq group (format "%s-%d" gnus-newsgroup-name article))
9022 (gnus-summary-remove-process-mark article)
9023 (when (gnus-summary-display-article article)
9024 (save-excursion ;;What for?
9026 (insert-buffer-substring gnus-original-article-buffer)
9027 ;; Remove some headers that may lead nndoc to make
9029 (message-narrow-to-head)
9030 (goto-char (point-min))
9031 (delete-matching-lines "^Path:\\|^From ")
9034 (gnus-group-read-ephemeral-group
9035 group `(nndoc ,group (nndoc-address ,(current-buffer))
9036 (nndoc-article-type guess))
9039 ;; Make all postings to this group go to the parent group.
9040 (nconc (gnus-info-params (gnus-get-info egroup))
9042 (push egroup groups))
9043 ;; Couldn't select this doc group.
9044 (gnus-error 3 "Article couldn't be entered"))))))
9045 ;; Now we have selected all the documents.
9048 (error "None of the articles could be interpreted as documents"))
9049 ((gnus-group-read-ephemeral-group
9050 (setq vgroup (format
9051 "nnvirtual:%s-%s" gnus-newsgroup-name
9052 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9053 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9055 (cons (current-buffer) 'summary)))
9057 (error "Couldn't select virtual nndoc group")))))
9059 (defun gnus-summary-isearch-article (&optional regexp-p)
9060 "Do incremental search forward on the current article.
9061 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9063 (gnus-summary-select-article)
9064 (gnus-configure-windows 'article)
9065 (gnus-eval-in-buffer-window gnus-article-buffer
9068 (isearch-forward regexp-p))))
9070 (defun gnus-summary-repeat-search-article-forward ()
9071 "Repeat the previous search forwards."
9073 (unless gnus-last-search-regexp
9074 (error "No previous search"))
9075 (gnus-summary-search-article-forward gnus-last-search-regexp))
9077 (defun gnus-summary-repeat-search-article-backward ()
9078 "Repeat the previous search backwards."
9080 (unless gnus-last-search-regexp
9081 (error "No previous search"))
9082 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9084 (defun gnus-summary-search-article-forward (regexp &optional backward)
9085 "Search for an article containing REGEXP forward.
9086 If BACKWARD, search backward instead."
9089 (format "Search article %s (regexp%s): "
9090 (if current-prefix-arg "backward" "forward")
9091 (if gnus-last-search-regexp
9092 (concat ", default " gnus-last-search-regexp)
9094 current-prefix-arg))
9095 (if (string-equal regexp "")
9096 (setq regexp (or gnus-last-search-regexp ""))
9097 (setq gnus-last-search-regexp regexp)
9098 (setq gnus-article-before-search gnus-current-article))
9099 ;; Intentionally set gnus-last-article.
9100 (setq gnus-last-article gnus-article-before-search)
9101 (let ((gnus-last-article gnus-last-article))
9102 (if (gnus-summary-search-article regexp backward)
9103 (gnus-summary-show-thread)
9104 (signal 'search-failed (list regexp)))))
9106 (defun gnus-summary-search-article-backward (regexp)
9107 "Search for an article containing REGEXP backward."
9110 (format "Search article backward (regexp%s): "
9111 (if gnus-last-search-regexp
9112 (concat ", default " gnus-last-search-regexp)
9114 (gnus-summary-search-article-forward regexp 'backward))
9116 (defun gnus-summary-search-article (regexp &optional backward)
9117 "Search for an article containing REGEXP.
9118 Optional argument BACKWARD means do search for backward.
9119 `gnus-select-article-hook' is not called during the search."
9120 ;; We have to require this here to make sure that the following
9121 ;; dynamic binding isn't shadowed by autoloading.
9122 (require 'gnus-async)
9124 (let ((gnus-select-article-hook nil) ;Disable hook.
9125 (gnus-article-prepare-hook nil)
9126 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9127 (gnus-use-article-prefetch nil)
9128 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9129 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9131 (gnus-keep-backlog nil)
9132 (gnus-break-pages nil)
9133 (gnus-summary-display-arrow nil)
9134 (gnus-updated-mode-lines nil)
9135 (gnus-auto-center-summary nil)
9136 (sum (current-buffer))
9137 (gnus-display-mime-function nil)
9140 (gnus-save-hidden-threads
9141 (gnus-summary-select-article)
9142 (set-buffer gnus-article-buffer)
9143 (goto-char (window-point (get-buffer-window (current-buffer))))
9147 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9149 (re-search-backward regexp nil t)
9150 (re-search-forward regexp nil t))
9151 ;; We found the regexp.
9156 (get-buffer-window (current-buffer))
9160 (get-buffer-window (current-buffer))
9163 (setq point (point)))
9164 ;; We didn't find it, so we go to the next article.
9167 (while (eq found 'not)
9168 (if (not (if backward (gnus-summary-find-prev)
9169 (gnus-summary-find-next)))
9170 ;; No more articles.
9172 ;; Select the next article and adjust point.
9173 (unless (gnus-summary-article-sparse-p
9174 (gnus-summary-article-number))
9176 (gnus-summary-select-article)
9177 (set-buffer gnus-article-buffer)
9179 (goto-char (if backward (point-max) (point-min))))))))
9180 (gnus-message 7 ""))
9181 ;; Return whether we found the regexp.
9182 (when (eq found 'found)
9184 (gnus-summary-show-thread)
9185 (gnus-summary-goto-subject gnus-current-article)
9186 (gnus-summary-position-point)
9189 (defun gnus-find-matching-articles (header regexp)
9190 "Return a list of all articles that match REGEXP on HEADER.
9191 This search includes all articles in the current group that Gnus has
9192 fetched headers for, whether they are displayed or not."
9193 (let ((articles nil)
9194 ;; Can't eta-reduce because it's a macro.
9195 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9196 (case-fold-search t))
9197 (dolist (header gnus-newsgroup-headers)
9198 (when (string-match regexp (funcall func header))
9199 (push (mail-header-number header) articles)))
9200 (nreverse articles)))
9202 (defun gnus-summary-find-matching (header regexp &optional backward unread
9203 not-case-fold not-matching)
9204 "Return a list of all articles that match REGEXP on HEADER.
9205 The search stars on the current article and goes forwards unless
9206 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9207 If UNREAD is non-nil, only unread articles will
9208 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9209 in the comparisons. If NOT-MATCHING, return a list of all articles that
9210 not match REGEXP on HEADER."
9211 (let ((case-fold-search (not not-case-fold))
9214 (if (eq (car header) 'extra)
9217 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9219 (error "%s is an invalid header" header))
9220 (unless (fboundp (intern (concat "mail-header-" header)))
9221 (error "%s is not a valid header" header))
9222 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9223 (dolist (d (if (eq backward 'all)
9225 (gnus-data-find-list
9226 (gnus-summary-article-number)
9227 (gnus-data-list backward))))
9228 (when (and (or (not unread) ; We want all articles...
9229 (gnus-data-unread-p d)) ; Or just unreads.
9230 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9234 (funcall func (gnus-data-header d))))
9235 (string-match regexp
9236 (funcall func (gnus-data-header d)))))
9237 (push (gnus-data-number d) articles))) ; Success!
9238 (nreverse articles)))
9240 (defun gnus-summary-execute-command (header regexp command &optional backward)
9241 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9242 If HEADER is an empty string (or nil), the match is done on the entire
9243 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9245 (list (let ((completion-ignore-case t))
9246 (gnus-completing-read
9248 (mapcar 'symbol-name
9250 '(Number Subject From Lines Date
9251 Message-ID Xref References Body)
9252 gnus-extra-headers))
9254 (read-string "Regexp: ")
9255 (read-key-sequence "Command: ")
9256 current-prefix-arg))
9257 (when (equal header "Body")
9259 ;; Hidden thread subtrees must be searched as well.
9260 (gnus-summary-show-all-threads)
9261 ;; We don't want to change current point nor window configuration.
9263 (save-window-excursion
9265 gnus-treat-strip-trailing-blank-lines
9266 gnus-treat-strip-leading-blank-lines
9267 gnus-treat-strip-multiple-blank-lines
9268 gnus-treat-hide-boring-headers
9269 gnus-treat-fold-newsgroups
9270 gnus-article-prepare-hook)
9271 (gnus-message 6 "Executing %s..." (key-description command))
9272 ;; We'd like to execute COMMAND interactively so as to give arguments.
9273 (gnus-execute header regexp
9274 `(call-interactively ',(key-binding command))
9276 (gnus-message 6 "Executing %s...done" (key-description command))))))
9278 (defun gnus-summary-beginning-of-article ()
9279 "Scroll the article back to the beginning."
9281 (gnus-summary-select-article)
9282 (gnus-configure-windows 'article)
9283 (gnus-eval-in-buffer-window gnus-article-buffer
9285 (goto-char (point-min))
9286 (when gnus-break-pages
9287 (gnus-narrow-to-page))))
9289 (defun gnus-summary-end-of-article ()
9290 "Scroll to the end of the article."
9292 (gnus-summary-select-article)
9293 (gnus-configure-windows 'article)
9294 (gnus-eval-in-buffer-window gnus-article-buffer
9296 (goto-char (point-max))
9298 (when gnus-break-pages
9299 (gnus-narrow-to-page))))
9301 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9302 "Truncate to LEN and quote all \"(\"'s in STRING."
9303 (gnus-replace-in-string (if (and len (> (length string) len))
9304 (substring string 0 len)
9308 (defun gnus-summary-print-article (&optional filename n)
9309 "Generate and print a PostScript image of the process-marked (mail) articles.
9311 If used interactively, print the current article if none are
9312 process-marked. With prefix arg, prompt the user for the name of the
9315 When used from Lisp, accept two optional args FILENAME and N. N means
9316 to print the next N articles. If N is negative, print the N previous
9317 articles. If N is nil and articles have been marked with the process
9318 mark, print these instead.
9320 If the optional first argument FILENAME is nil, send the image to the
9321 printer. If FILENAME is a string, save the PostScript image in a file with
9322 that name. If FILENAME is a number, prompt the user for the name of the file
9324 (interactive (list (ps-print-preprint current-prefix-arg)))
9325 (dolist (article (gnus-summary-work-articles n))
9326 (gnus-summary-select-article nil nil 'pseudo article)
9327 (gnus-eval-in-buffer-window gnus-article-buffer
9328 (gnus-print-buffer))
9329 (gnus-summary-remove-process-mark article))
9330 (ps-despool filename))
9332 (defun gnus-print-buffer ()
9333 (let ((buffer (generate-new-buffer " *print*")))
9336 (copy-to-buffer buffer (point-min) (point-max))
9338 (gnus-remove-text-with-property 'gnus-decoration)
9339 (when (gnus-visual-p 'article-highlight 'highlight)
9340 ;; Copy-to-buffer doesn't copy overlays. So redo the
9342 (let ((gnus-article-buffer buffer))
9343 (gnus-article-highlight-citation t)
9344 (gnus-article-highlight-signature)
9345 (gnus-article-emphasize)
9346 (gnus-article-delete-invisible-text)))
9347 (let ((ps-left-header
9350 (gnus-summary-print-truncate-and-quote
9351 (mail-header-subject gnus-current-headers)
9354 (gnus-summary-print-truncate-and-quote
9355 (mail-header-from gnus-current-headers)
9359 "/pagenumberstring load"
9361 (mail-header-date gnus-current-headers) ")"))))
9362 (gnus-run-hooks 'gnus-ps-print-hook)
9364 (if ps-print-color-p
9365 (ps-spool-buffer-with-faces)
9366 (ps-spool-buffer)))))
9367 (kill-buffer buffer))))
9369 (defun gnus-summary-show-complete-article ()
9370 "Show a complete version of the current article.
9371 This is only useful if you're looking at a partial version of the
9374 (let ((gnus-keep-backlog nil)
9375 (gnus-use-cache nil)
9378 (format "%s-fetch-partial-articles"
9379 (car (gnus-find-method-for-group
9380 gnus-newsgroup-name)))
9385 (setq old-val (symbol-value variable))
9387 (gnus-flush-original-article-buffer)
9388 (gnus-summary-show-article))
9389 (set variable old-val))))
9391 (defun gnus-summary-show-article (&optional arg)
9392 "Force redisplaying of the current article.
9393 If ARG (the prefix) is a number, show the article with the charset
9394 defined in `gnus-summary-show-article-charset-alist', or the charset
9396 If ARG (the prefix) is non-nil and not a number, show the article,
9397 but without running any of the article treatment functions
9398 article. Normally, the keystroke is `C-u g'. When using `C-u
9399 C-u g', show the raw article."
9403 (gnus-summary-show-article t)
9404 (let ((gnus-newsgroup-charset
9405 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9406 (mm-read-coding-system
9407 "View as charset: " ;; actually it is coding system.
9408 (with-current-buffer gnus-article-buffer
9409 (mm-detect-coding-region (point) (point-max))))))
9410 (gnus-newsgroup-ignored-charsets 'gnus-all))
9411 (gnus-summary-select-article nil 'force)
9412 (let ((deps gnus-newsgroup-dependencies)
9414 (with-current-buffer gnus-original-article-buffer
9416 (message-narrow-to-head)
9417 (setq head (buffer-string))
9418 (goto-char (point-min))
9419 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9420 (goto-char (point-max))
9422 (setq lines (1- (count-lines (point) (point-max))))))
9424 (insert (format "211 %d Article retrieved.\n"
9425 (cdr gnus-article-current)))
9427 (if lines (insert (format "Lines: %d\n" lines)))
9429 (let ((nntp-server-buffer (current-buffer)))
9430 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9431 (gnus-data-set-header
9432 (gnus-data-find (cdr gnus-article-current))
9434 (gnus-summary-update-article-line
9435 (cdr gnus-article-current) header)
9436 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9437 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9439 ;; Select the article the normal way.
9440 (gnus-summary-select-article nil 'force))
9443 ;; We have to require this here to make sure that the following
9444 ;; dynamic binding isn't shadowed by autoloading.
9445 (require 'gnus-async)
9447 ;; Bind the article treatment functions to nil.
9448 (let ((gnus-have-all-headers t)
9449 gnus-article-prepare-hook
9450 gnus-article-decode-hook
9451 gnus-display-mime-function
9453 ;; Destroy any MIME parts.
9454 (when (gnus-buffer-live-p gnus-article-buffer)
9455 (with-current-buffer gnus-article-buffer
9456 (mm-destroy-parts gnus-article-mime-handles)
9457 ;; Set it to nil for safety reason.
9458 (setq gnus-article-mime-handle-alist nil)
9459 (setq gnus-article-mime-handles nil)))
9460 (gnus-summary-select-article nil 'force)))
9462 (let ((gnus-inhibit-article-treatments t))
9463 (gnus-summary-select-article nil 'force))))
9464 (gnus-summary-goto-subject gnus-current-article)
9465 (gnus-summary-position-point))
9467 (defun gnus-summary-show-raw-article ()
9468 "Show the raw article without any article massaging functions being run."
9470 (gnus-summary-show-article t))
9472 (defun gnus-summary-verbose-headers (&optional arg)
9473 "Toggle permanent full header display.
9474 If ARG is a positive number, turn header display on.
9475 If ARG is a negative number, turn header display off."
9477 (setq gnus-show-all-headers
9478 (cond ((or (not (numberp arg))
9480 (not gnus-show-all-headers))
9483 (gnus-summary-show-article))
9485 (defun gnus-summary-toggle-header (&optional arg)
9486 "Show the headers if they are hidden, or hide them if they are shown.
9487 If ARG is a positive number, show the entire header.
9488 If ARG is a negative number, hide the unwanted header lines."
9490 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9491 (get-buffer-window gnus-article-buffer t))))
9492 (with-current-buffer gnus-article-buffer
9494 (article-narrow-to-head)
9495 (let* ((inhibit-read-only t)
9496 (inhibit-point-motion-hooks t)
9497 (hidden (if (numberp arg)
9499 (or (not (looking-at "[^ \t\n]+:"))
9500 (gnus-article-hidden-text-p 'headers))))
9502 (delete-region (point-min) (point-max))
9503 (with-current-buffer gnus-original-article-buffer
9504 (goto-char (setq s (point-min)))
9505 (setq e (if (search-forward "\n\n" nil t)
9508 (insert-buffer-substring gnus-original-article-buffer s e)
9509 (run-hooks 'gnus-article-decode-hook)
9511 (let ((gnus-treat-hide-headers nil)
9512 (gnus-treat-hide-boring-headers nil))
9513 (gnus-delete-wash-type 'headers)
9514 (gnus-treat-article 'head))
9515 (gnus-treat-article 'head))
9518 (set-window-start window (goto-char (point-min))))
9519 (if gnus-break-pages
9520 (gnus-narrow-to-page)
9521 (when (gnus-visual-p 'page-marker)
9522 (let ((inhibit-read-only t))
9523 (gnus-remove-text-with-property 'gnus-prev)
9524 (gnus-remove-text-with-property 'gnus-next))))
9525 (gnus-set-mode-line 'article)))))
9527 (defun gnus-summary-show-all-headers ()
9528 "Make all header lines visible."
9530 (gnus-summary-toggle-header 1))
9532 (defun gnus-summary-caesar-message (&optional arg)
9533 "Caesar rotate the current article by 13.
9534 With a non-numerical prefix, also rotate headers. A numerical
9535 prefix specifies how many places to rotate each letter forward."
9537 (gnus-summary-select-article)
9538 (let ((mail-header-separator ""))
9539 (gnus-eval-in-buffer-window gnus-article-buffer
9542 (let ((start (window-start))
9543 (inhibit-read-only t))
9544 (if (equal arg '(4))
9545 (message-caesar-buffer-body nil t)
9546 (message-caesar-buffer-body arg))
9547 (set-window-start (get-buffer-window (current-buffer)) start)))))
9548 ;; Create buttons and stuff...
9549 (gnus-treat-article nil))
9551 (declare-function idna-to-unicode "ext:idna" (str))
9553 (defun gnus-summary-idna-message (&optional arg)
9554 "Decode IDNA encoded domain names in the current articles.
9555 IDNA encoded domain names looks like `xn--bar'. If a string
9556 remain unencoded after running this function, it is likely an
9557 invalid IDNA string (`xn--bar' is invalid).
9559 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9560 installed for this command to work."
9562 (if (not (and (condition-case nil (require 'idna)
9564 (mm-coding-system-p 'utf-8)
9565 (executable-find (symbol-value 'idna-program))))
9567 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9568 (gnus-summary-select-article)
9569 (let ((mail-header-separator ""))
9570 (gnus-eval-in-buffer-window gnus-article-buffer
9573 (let ((start (window-start))
9575 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9576 (replace-match (idna-to-unicode (match-string 1))))
9577 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9579 (defun gnus-summary-morse-message (&optional arg)
9580 "Morse decode the current article."
9582 (gnus-summary-select-article)
9583 (let ((mail-header-separator ""))
9584 (gnus-eval-in-buffer-window gnus-article-buffer
9588 (let ((pos (window-start))
9589 (inhibit-read-only t))
9590 (goto-char (point-min))
9591 (when (message-goto-body)
9592 (gnus-narrow-to-body))
9593 (goto-char (point-min))
9594 (while (search-forward "·" (point-max) t)
9595 (replace-match "."))
9596 (unmorse-region (point-min) (point-max))
9598 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9600 (defun gnus-summary-stop-page-breaking ()
9601 "Stop page breaking in the current article."
9603 (gnus-summary-select-article)
9604 (gnus-eval-in-buffer-window gnus-article-buffer
9606 (when (gnus-visual-p 'page-marker)
9607 (let ((inhibit-read-only t))
9608 (gnus-remove-text-with-property 'gnus-prev)
9609 (gnus-remove-text-with-property 'gnus-next))
9610 (setq gnus-page-broken nil))))
9612 (defun gnus-summary-move-article (&optional n to-newsgroup
9613 select-method action)
9614 "Move the current article to a different newsgroup.
9615 If N is a positive number, move the N next articles.
9616 If N is a negative number, move the N previous articles.
9617 If N is nil and any articles have been marked with the process mark,
9618 move those articles instead.
9619 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9620 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9621 re-spool using this method.
9623 When called interactively with TO-NEWSGROUP being nil, the value of
9624 the variable `gnus-move-split-methods' is used for finding a default
9625 for the target newsgroup.
9627 For this function to work, both the current newsgroup and the
9628 newsgroup that you want to move to have to support the `request-move'
9629 and `request-accept' functions.
9631 ACTION can be either `move' (the default), `crosspost' or `copy'."
9634 (setq action 'move))
9635 ;; Check whether the source group supports the required functions.
9636 (cond ((and (eq action 'move)
9637 (not (gnus-check-backend-function
9638 'request-move-article gnus-newsgroup-name)))
9639 (error "The current group does not support article moving"))
9640 ((and (eq action 'crosspost)
9641 (not (gnus-check-backend-function
9642 'request-replace-article gnus-newsgroup-name)))
9643 (error "The current group does not support article editing")))
9644 (let ((articles (gnus-summary-work-articles n))
9645 (prefix (if (gnus-check-backend-function
9646 'request-move-article gnus-newsgroup-name)
9647 (funcall gnus-move-group-prefix-function
9648 gnus-newsgroup-name)
9650 (names '((move "Move" "Moving")
9651 (copy "Copy" "Copying")
9652 (crosspost "Crosspost" "Crossposting")))
9653 (copy-buf (save-excursion
9654 (nnheader-set-temp-buffer " *copy article*")))
9655 art-group to-method new-xref article to-groups
9656 articles-to-update-marks encoded)
9657 (unless (assq action names)
9658 (error "Unknown action %s" action))
9659 ;; Read the newsgroup name.
9660 (when (and (not to-newsgroup)
9661 (not select-method))
9662 (if (and gnus-move-split-methods
9664 (and (memq gnus-current-article articles)
9665 (gnus-buffer-live-p gnus-original-article-buffer))))
9666 ;; When `gnus-move-split-methods' is non-nil, we have to
9667 ;; select an article to give `gnus-read-move-group-name' an
9668 ;; opportunity to suggest an appropriate default. However,
9669 ;; we needn't render or mark the article.
9670 (let ((gnus-display-mime-function nil)
9671 (gnus-article-prepare-hook nil)
9672 (gnus-mark-article-hook nil))
9673 (gnus-summary-select-article nil nil nil (car articles))))
9674 (setq to-newsgroup (gnus-read-move-group-name
9675 (cadr (assq action names))
9677 (intern (format "gnus-current-%s-group" action)))
9679 encoded to-newsgroup
9680 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9681 (set (intern (format "gnus-current-%s-group" action))
9682 (mm-decode-coding-string
9684 (gnus-group-name-charset to-method to-newsgroup))))
9686 (setq to-method (or select-method
9687 (gnus-server-to-method
9688 (gnus-group-method to-newsgroup)))))
9692 (mm-encode-coding-string
9694 (gnus-group-name-charset to-method to-newsgroup)))))
9695 ;; Check the method we are to move this article to...
9696 (unless (gnus-check-backend-function
9697 'request-accept-article (car to-method))
9698 (error "%s does not support article copying" (car to-method)))
9699 (unless (gnus-check-server to-method)
9700 (error "Can't open server %s" (car to-method)))
9701 (gnus-message 6 "%s to %s: %s..."
9702 (caddr (assq action names))
9703 (or (car select-method)
9704 (gnus-group-decoded-name to-newsgroup))
9707 (setq article (pop articles))
9711 ;; Move the article.
9713 ;; Remove this article from future suppression.
9714 (gnus-dup-unsuppress-article article)
9715 (let* ((from-method (gnus-find-method-for-group
9716 gnus-newsgroup-name))
9717 (to-method (or select-method
9718 (gnus-find-method-for-group to-newsgroup)))
9719 (move-is-internal (gnus-server-equal from-method to-method)))
9720 (gnus-request-move-article
9721 article ; Article to move
9722 gnus-newsgroup-name ; From newsgroup
9723 (nth 1 (gnus-find-method-for-group
9724 gnus-newsgroup-name)) ; Server
9725 (list 'gnus-request-accept-article
9726 to-newsgroup (list 'quote select-method)
9727 (not articles) t) ; Accept form
9728 (not articles) ; Only save nov last time
9729 (and move-is-internal
9730 to-newsgroup ; Not respooling
9731 (gnus-group-real-name to-newsgroup))))) ; Is this move internal?
9732 ;; Copy the article.
9734 (with-current-buffer copy-buf
9735 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9737 (nnheader-narrow-to-headers)
9738 (dolist (hdr gnus-copy-article-ignored-headers)
9739 (message-remove-header hdr t)))
9740 (gnus-request-accept-article
9741 to-newsgroup select-method (not articles) t))))
9742 ;; Crosspost the article.
9743 ((eq action 'crosspost)
9744 (let ((xref (message-tokenize-header
9745 (mail-header-xref (gnus-summary-article-header article))
9747 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9748 ":" (number-to-string article)))
9750 (setq xref (list (system-name))))
9753 (mapconcat 'identity
9754 (delete "Xref:" (delete new-xref xref))
9757 (with-current-buffer copy-buf
9758 ;; First put the article in the destination group.
9759 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9760 (when (consp (setq art-group
9761 (gnus-request-accept-article
9762 to-newsgroup select-method (not articles) t)))
9763 (setq new-xref (concat new-xref " " (car art-group)
9765 (number-to-string (cdr art-group))))
9766 ;; Now we have the new Xrefs header, so we insert
9767 ;; it and replace the new article.
9768 (nnheader-replace-header "Xref" new-xref)
9769 (gnus-request-replace-article
9770 (cdr art-group) to-newsgroup (current-buffer) t)
9774 (gnus-message 1 "Couldn't %s article %s: %s"
9775 (cadr (assq action names)) article
9776 (nnheader-get-report (car to-method))))
9777 ((eq art-group 'junk)
9778 (when (eq action 'move)
9779 (gnus-summary-mark-article article gnus-canceled-mark)
9780 (gnus-message 4 "Deleted article %s" article)
9781 ;; run the delete hook
9782 (run-hook-with-args 'gnus-summary-article-delete-hook
9785 (assoc article (gnus-data-list nil)))
9786 gnus-newsgroup-name nil
9789 (let* ((pto-group (gnus-group-prefixed-name
9790 (car art-group) to-method))
9791 (info (gnus-get-info pto-group))
9792 (to-group (gnus-info-group info))
9794 ;; Update the group that has been moved to.
9796 (memq action '(move copy)))
9797 (unless (member to-group to-groups)
9798 (push to-group to-groups))
9800 (unless (memq article gnus-newsgroup-unreads)
9801 (push 'read to-marks)
9803 info (gnus-add-to-range (gnus-info-read info)
9804 (list (cdr art-group)))))
9806 ;; See whether the article is to be put in the cache.
9807 (let* ((expirable (gnus-group-auto-expirable-p to-group))
9808 (marks (if expirable
9809 gnus-article-mark-lists
9810 (delete '(expirable . expire)
9811 (copy-sequence gnus-article-mark-lists))))
9812 (to-article (cdr art-group)))
9814 ;; Enter the article into the cache in the new group,
9815 ;; if that is required.
9816 (when gnus-use-cache
9817 (gnus-cache-possibly-enter-article
9819 (memq article gnus-newsgroup-marked)
9820 (memq article gnus-newsgroup-dormant)
9821 (memq article gnus-newsgroup-unreads)))
9823 (when gnus-preserve-marks
9824 ;; Copy any marks over to the new group.
9825 (when (and (equal to-group gnus-newsgroup-name)
9826 (not (memq article gnus-newsgroup-unreads)))
9827 ;; Mark this article as read in this group.
9828 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9829 ;; Increase the active status of this group.
9830 (setcdr (gnus-active to-group) to-article)
9831 (setcdr gnus-newsgroup-active to-article))
9834 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9835 (when (memq article (symbol-value
9836 (intern (format "gnus-newsgroup-%s"
9838 (push (cdar marks) to-marks)
9839 ;; If the other group is the same as this group,
9840 ;; then we have to add the mark to the list.
9841 (when (equal to-group gnus-newsgroup-name)
9842 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9845 (intern (format "gnus-newsgroup-%s"
9847 ;; Copy the marks to other group.
9848 (gnus-add-marked-articles
9849 to-group (cdar marks) (list to-article) info)))
9850 (setq marks (cdr marks)))
9852 (when (and expirable
9853 gnus-mark-copied-or-moved-articles-as-expirable
9854 (not (memq 'expire to-marks)))
9855 ;; Mark this article as expirable.
9856 (push 'expire to-marks)
9857 (when (equal to-group gnus-newsgroup-name)
9858 (push to-article gnus-newsgroup-expirable))
9859 ;; Copy the expirable mark to other group.
9860 (gnus-add-marked-articles
9861 to-group 'expire (list to-article) info))
9864 (gnus-request-set-mark
9865 to-group (list (list (list to-article) 'add to-marks)))))
9868 (concat "(gnus-group-set-info '"
9869 (gnus-prin1-to-string (gnus-get-info to-group))
9872 ;; Update the Xref header in this article to point to
9873 ;; the new crossposted article we have just created.
9874 (when (eq action 'crosspost)
9875 (with-current-buffer copy-buf
9876 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9877 (nnheader-replace-header "Xref" new-xref)
9878 (gnus-request-replace-article
9879 article gnus-newsgroup-name (current-buffer) t)))
9881 ;; run the move/copy/crosspost/respool hook
9882 (run-hook-with-args 'gnus-summary-article-move-hook
9885 (assoc article (gnus-data-list nil)))
9890 ;;;!!!Why is this necessary?
9891 (set-buffer gnus-summary-buffer)
9893 (when (eq action 'move)
9895 (gnus-summary-goto-subject article)
9896 (gnus-summary-mark-article article gnus-canceled-mark)))))
9897 (push article articles-to-update-marks))
9900 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
9901 ;; Re-activate all groups that have been moved to.
9902 (with-current-buffer gnus-group-buffer
9903 (let ((gnus-group-marked to-groups))
9904 (gnus-group-get-new-news-this-group nil t)))
9906 (gnus-kill-buffer copy-buf)
9907 (gnus-summary-position-point)
9908 (gnus-set-mode-line 'summary)))
9910 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9911 "Copy the current article to some other group.
9912 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9913 When called interactively, if TO-NEWSGROUP is nil, use the value of
9914 the variable `gnus-move-split-methods' for finding a default target
9916 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9917 re-spool using this method."
9919 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9921 (defun gnus-summary-crosspost-article (&optional n)
9922 "Crosspost the current article to some other group."
9924 (gnus-summary-move-article n nil nil 'crosspost))
9926 (defcustom gnus-summary-respool-default-method nil
9927 "Default method type for respooling an article.
9928 If nil, use to the current newsgroup method."
9930 :group 'gnus-summary-mail)
9932 (defun gnus-summary-respool-article (&optional n method)
9933 "Respool the current article.
9934 The article will be squeezed through the mail spooling process again,
9935 which means that it will be put in some mail newsgroup or other
9936 depending on `nnmail-split-methods'.
9937 If N is a positive number, respool the N next articles.
9938 If N is a negative number, respool the N previous articles.
9939 If N is nil and any articles have been marked with the process mark,
9940 respool those articles instead.
9942 Respooling can be done both from mail groups and \"real\" newsgroups.
9943 In the former case, the articles in question will be moved from the
9944 current group into whatever groups they are destined to. In the
9945 latter case, they will be copied into the relevant groups."
9947 (list current-prefix-arg
9948 (let* ((methods (gnus-methods-using 'respool))
9950 (symbol-name (or gnus-summary-respool-default-method
9951 (car (gnus-find-method-for-group
9952 gnus-newsgroup-name)))))
9954 (gnus-completing-read
9955 "Backend to use when respooling"
9956 methods t nil 'gnus-mail-method-history methname))
9959 ((zerop (length (setq ms (gnus-servers-using-backend
9961 (list (intern method) ""))
9965 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9966 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
9969 (error "No method given for respooling"))
9970 (if (assoc (symbol-name
9971 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9972 (gnus-methods-using 'respool))
9973 (gnus-summary-move-article n nil method)
9974 (gnus-summary-copy-article n nil method)))
9976 (defun gnus-summary-import-article (file &optional edit)
9977 "Import an arbitrary file into a mail newsgroup."
9978 (interactive "fImport file: \nP")
9979 (let ((group gnus-newsgroup-name)
9980 (now (current-time))
9981 atts lines group-art)
9982 (unless (gnus-check-backend-function 'request-accept-article group)
9983 (error "%s does not support article importing" group))
9984 (or (file-readable-p file)
9985 (not (file-regular-p file))
9986 (error "Can't read %s" file))
9987 (with-current-buffer (gnus-get-buffer-create " *import file*")
9989 (nnheader-insert-file-contents file)
9990 (goto-char (point-min))
9991 (if (nnheader-article-p)
9993 (goto-char (point-min))
9994 (search-forward "\n\n" nil t)
9995 (narrow-to-region (point-min) (1- (point)))
9996 (goto-char (point-min))
9997 (unless (re-search-forward "^date:" nil t)
9998 (goto-char (point-max))
9999 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10000 ;; This doesn't look like an article, so we fudge some headers.
10001 (setq atts (file-attributes file)
10002 lines (count-lines (point-min) (point-max)))
10003 (insert "From: " (read-string "From: ") "\n"
10004 "Subject: " (read-string "Subject: ") "\n"
10005 "Date: " (message-make-date (nth 5 atts)) "\n"
10006 "Message-ID: " (message-make-message-id) "\n"
10007 "Lines: " (int-to-string lines) "\n"
10008 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10009 (setq group-art (gnus-request-accept-article group nil t))
10010 (kill-buffer (current-buffer)))
10011 (setq gnus-newsgroup-active (gnus-activate-group group))
10013 (gnus-summary-goto-article (cdr group-art) nil t)
10015 (gnus-summary-edit-article))))
10017 (defun gnus-summary-create-article ()
10018 "Create an article in a mail newsgroup."
10020 (let ((group gnus-newsgroup-name)
10021 (now (current-time))
10023 (unless (gnus-check-backend-function 'request-accept-article group)
10024 (error "%s does not support article importing" group))
10025 (with-current-buffer (gnus-get-buffer-create " *import file*")
10027 (goto-char (point-min))
10028 ;; This doesn't look like an article, so we fudge some headers.
10029 (insert "From: " (read-string "From: ") "\n"
10030 "Subject: " (read-string "Subject: ") "\n"
10031 "Date: " (message-make-date now) "\n"
10032 "Message-ID: " (message-make-message-id) "\n")
10033 (setq group-art (gnus-request-accept-article group nil t))
10034 (kill-buffer (current-buffer)))
10035 (setq gnus-newsgroup-active (gnus-activate-group group))
10037 (gnus-summary-goto-article (cdr group-art) nil t)
10038 (gnus-summary-edit-article)))
10040 (defun gnus-summary-article-posted-p ()
10041 "Say whether the current (mail) article is available from news as well.
10042 This will be the case if the article has both been mailed and posted."
10044 (let ((id (mail-header-references (gnus-summary-article-header)))
10045 (gnus-override-method (car (gnus-refer-article-methods))))
10046 (if (gnus-request-head id "")
10047 (gnus-message 2 "The current message was found on %s"
10048 gnus-override-method)
10049 (gnus-message 2 "The current message couldn't be found on %s"
10050 gnus-override-method)
10053 (defun gnus-summary-expire-articles (&optional now)
10054 "Expire all articles that are marked as expirable in the current group."
10056 (when (and (not gnus-group-is-exiting-without-update-p)
10057 (gnus-check-backend-function
10058 'request-expire-articles gnus-newsgroup-name))
10059 ;; This backend supports expiry.
10060 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10061 (expirable (if total
10063 ;; We need to update the info for
10064 ;; this group for `gnus-list-of-read-articles'
10065 ;; to give us the right answer.
10066 (gnus-run-hooks 'gnus-exit-group-hook)
10067 (gnus-summary-update-info)
10068 (gnus-list-of-read-articles gnus-newsgroup-name))
10069 (setq gnus-newsgroup-expirable
10070 (sort gnus-newsgroup-expirable '<))))
10071 (expiry-wait (if now 'immediate
10072 (gnus-group-find-parameter
10073 gnus-newsgroup-name 'expiry-wait)))
10074 (nnmail-expiry-target
10075 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10076 nnmail-expiry-target))
10079 ;; There are expirable articles in this group, so we run them
10080 ;; through the expiry process.
10081 (gnus-message 6 "Expiring articles...")
10082 (unless (gnus-check-group gnus-newsgroup-name)
10083 (error "Can't open server for %s" gnus-newsgroup-name))
10084 ;; The list of articles that weren't expired is returned.
10087 (let ((nnmail-expiry-wait-function nil)
10088 (nnmail-expiry-wait expiry-wait))
10089 (setq es (gnus-request-expire-articles
10090 expirable gnus-newsgroup-name)))
10091 (setq es (gnus-request-expire-articles
10092 expirable gnus-newsgroup-name)))
10094 (setq gnus-newsgroup-expirable es))
10095 ;; We go through the old list of expirable, and mark all
10096 ;; really expired articles as nonexistent.
10097 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10098 (let ((gnus-use-cache nil))
10099 (dolist (article expirable)
10100 (when (and (not (memq article es))
10101 (gnus-data-find article))
10102 (gnus-summary-mark-article article gnus-canceled-mark)
10103 (run-hook-with-args 'gnus-summary-article-expire-hook
10106 (assoc article (gnus-data-list nil)))
10107 gnus-newsgroup-name
10110 (gnus-message 6 "Expiring articles...done")))))
10112 (defun gnus-summary-expire-articles-now ()
10113 "Expunge all expirable articles in the current group.
10114 This means that *all* articles that are marked as expirable will be
10115 deleted forever, right now."
10117 (or gnus-expert-user
10119 "Are you really, really sure you want to delete all expirable messages? ")
10121 (gnus-summary-expire-articles t))
10123 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10124 (defun gnus-summary-delete-article (&optional n)
10125 "Delete the N next (mail) articles.
10126 This command actually deletes articles. This is not a marking
10127 command. The article will disappear forever from your life, never to
10130 If N is negative, delete backwards.
10131 If N is nil and articles have been marked with the process mark,
10132 delete these instead.
10134 If `gnus-novice-user' is non-nil you will be asked for
10135 confirmation before the articles are deleted."
10137 (unless (gnus-check-backend-function 'request-expire-articles
10138 gnus-newsgroup-name)
10139 (error "The current newsgroup does not support article deletion"))
10140 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10141 (error "Couldn't open server"))
10142 ;; Compute the list of articles to delete.
10143 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10144 (nnmail-expiry-target 'delete)
10146 (if (and gnus-novice-user
10147 (not (gnus-yes-or-no-p
10148 (format "Do you really want to delete %s forever? "
10149 (if (> (length articles) 1)
10150 (format "these %s articles" (length articles))
10151 "this article")))))
10153 ;; Delete the articles.
10154 (setq not-deleted (gnus-request-expire-articles
10155 articles gnus-newsgroup-name 'force))
10158 (gnus-summary-remove-process-mark (car articles))
10159 ;; The backend might not have been able to delete the article
10161 (unless (memq (car articles) not-deleted)
10162 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
10163 (let* ((article (car articles))
10164 (ghead (gnus-data-header
10165 (assoc article (gnus-data-list nil)))))
10166 (run-hook-with-args 'gnus-summary-article-delete-hook
10167 'delete ghead gnus-newsgroup-name nil
10169 (setq articles (cdr articles))))
10171 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10172 (gnus-summary-position-point)
10173 (gnus-set-mode-line 'summary)
10176 (defun gnus-summary-edit-article (&optional arg)
10177 "Edit the current article.
10178 This will have permanent effect only in mail groups.
10179 If ARG is nil, edit the decoded articles.
10180 If ARG is 1, edit the raw articles.
10181 If ARG is 2, edit the raw articles even in read-only groups.
10182 If ARG is 3, edit the articles with the current handles.
10183 Otherwise, allow editing of articles even in read-only
10186 (let (force raw current-handles)
10195 (setq current-handles
10196 (and (gnus-buffer-live-p gnus-article-buffer)
10197 (with-current-buffer gnus-article-buffer
10199 gnus-article-mime-handles
10200 (setq gnus-article-mime-handles nil))))))
10203 (when (and raw (not force)
10204 (member gnus-newsgroup-name '("nndraft:delayed"
10207 (error "Can't edit the raw article in group %s"
10208 gnus-newsgroup-name))
10209 (with-current-buffer gnus-summary-buffer
10210 (let ((mail-parse-charset gnus-newsgroup-charset)
10211 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10212 (gnus-set-global-variables)
10213 (when (and (not force)
10214 (gnus-group-read-only-p))
10215 (error "The current newsgroup does not support article editing"))
10216 (gnus-summary-show-article t)
10217 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10218 (with-current-buffer gnus-article-buffer
10219 (mm-enable-multibyte)))
10220 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10222 (gnus-article-edit-article
10225 (let ((mbl mml-buffer-list))
10226 (setq mml-buffer-list nil)
10227 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10228 (mime-to-mml ,'current-handles))
10229 (let ((mbl1 mml-buffer-list))
10230 (setq mml-buffer-list mbl)
10231 (set (make-local-variable 'mml-buffer-list) mbl1))
10232 (gnus-make-local-hook 'kill-buffer-hook)
10233 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10234 `(lambda (no-highlight)
10235 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10236 (message-options message-options)
10237 (message-options-set-recipient)
10238 (mail-parse-ignored-charsets
10239 ',gnus-newsgroup-ignored-charsets)
10240 (rfc2047-header-encoding-alist
10241 ',(let ((charset (gnus-group-name-charset
10242 (gnus-find-method-for-group
10243 gnus-newsgroup-name)
10244 gnus-newsgroup-name)))
10245 (append (list (cons "Newsgroups" charset)
10246 (cons "Followup-To" charset)
10247 (cons "Xref" charset))
10248 rfc2047-header-encoding-alist))))
10249 ,(if (not raw) '(progn
10251 (mml-destroy-buffers)
10252 (remove-hook 'kill-buffer-hook
10253 'mml-destroy-buffers t)
10254 (kill-local-variable 'mml-buffer-list)))
10255 (gnus-summary-edit-article-done
10256 ,(or (mail-header-references gnus-current-headers) "")
10257 ,(gnus-group-read-only-p)
10258 ,gnus-summary-buffer no-highlight))))))))
10260 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10262 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10264 "Make edits to the current article permanent."
10267 ;; The buffer restriction contains the entire article if it exists.
10268 (when (article-goto-body)
10269 (let ((lines (count-lines (point) (point-max)))
10270 (length (- (point-max) (point)))
10271 (case-fold-search t)
10272 (body (copy-marker (point))))
10273 (goto-char (point-min))
10274 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10275 (delete-region (match-beginning 1) (match-end 1))
10276 (insert (number-to-string length)))
10277 (goto-char (point-min))
10278 (when (re-search-forward
10279 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10280 (delete-region (match-beginning 1) (match-end 1))
10281 (insert (number-to-string length)))
10282 (goto-char (point-min))
10283 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10284 (delete-region (match-beginning 1) (match-end 1))
10285 (insert (number-to-string lines))))))
10286 ;; Replace the article.
10287 (let ((buf (current-buffer))
10288 (article (cdr gnus-article-current))
10291 (insert-buffer-substring buf)
10292 (if (and (not read-only)
10293 (not (setq replace-result
10294 (gnus-request-replace-article
10295 article (car gnus-article-current)
10296 (current-buffer) t))))
10297 (error "Couldn't replace article")
10298 ;; If we got a number back, then that's the new article number
10299 ;; for this article. Otherwise, the article number didn't change.
10300 (when (numberp replace-result)
10301 (with-current-buffer gnus-summary-buffer
10302 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10303 (gnus-summary-limit gnus-newsgroup-limit)
10304 (setq article replace-result)
10305 (gnus-summary-goto-subject article t)))
10306 ;; Update the summary buffer.
10307 (if (and references
10308 (equal (message-tokenize-header references " ")
10309 (message-tokenize-header
10310 (or (message-fetch-field "references") "") " ")))
10311 ;; We only have to update this line.
10314 (message-narrow-to-head)
10315 (let ((head (buffer-substring-no-properties
10316 (point-min) (point-max)))
10319 (insert (format "211 %d Article retrieved.\n" article))
10322 (let ((nntp-server-buffer (current-buffer)))
10323 (setq header (car (gnus-get-newsgroup-headers nil t))))
10324 (with-current-buffer gnus-summary-buffer
10325 (gnus-data-set-header (gnus-data-find article) header)
10326 (gnus-summary-update-article-line article header)
10327 (if (gnus-summary-goto-subject article nil t)
10328 (gnus-summary-update-secondary-mark article)))))))
10330 (set-buffer (or buffer gnus-summary-buffer))
10331 (gnus-summary-update-article article)
10332 (if (gnus-summary-goto-subject article nil t)
10333 (gnus-summary-update-secondary-mark article)))
10334 ;; Prettify the article buffer again.
10335 (unless no-highlight
10336 (with-current-buffer gnus-article-buffer
10337 ;;!!! Fix this -- article should be rehighlighted.
10338 ;;(gnus-run-hooks 'gnus-article-display-hook)
10339 (set-buffer gnus-original-article-buffer)
10340 (gnus-request-article
10341 article (car gnus-article-current) (current-buffer))))
10342 ;; Prettify the summary buffer line.
10343 (when (gnus-visual-p 'summary-highlight 'highlight)
10344 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10346 (defun gnus-summary-edit-wash (key)
10347 "Perform editing command KEY in the article buffer."
10351 (message "%s" (concat (this-command-keys) "- "))
10354 (gnus-summary-edit-article)
10355 (execute-kbd-macro (concat (this-command-keys) key))
10356 (gnus-article-edit-done))
10360 (defun gnus-summary-respool-query (&optional silent trace)
10361 "Query where the respool algorithm would put this article."
10363 (let (gnus-mark-article-hook)
10364 (gnus-summary-select-article)
10365 (with-current-buffer gnus-original-article-buffer
10366 (let ((groups (nnmail-article-group 'identity trace)))
10369 (message "This message would go to %s"
10370 (mapconcat 'car groups ", "))
10371 (message "This message would go to no groups"))
10374 (defun gnus-summary-respool-trace ()
10375 "Trace where the respool algorithm would put this article.
10376 Display a buffer showing all fancy splitting patterns which matched."
10378 (gnus-summary-respool-query nil t))
10380 ;; Summary marking commands.
10382 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10383 "Mark articles which has the same subject as read, and then select the next.
10384 If UNMARK is positive, remove any kind of mark.
10385 If UNMARK is negative, tick articles."
10388 (setq unmark (prefix-numeric-value unmark)))
10390 (gnus-summary-mark-same-subject
10391 (gnus-summary-article-subject) unmark)))
10392 ;; Select next unread article. If auto-select-same mode, should
10393 ;; select the first unread article.
10394 (gnus-summary-next-article t (and gnus-auto-select-same
10395 (gnus-summary-article-subject)))
10396 (gnus-message 7 "%d article%s marked as %s"
10397 count (if (= count 1) " is" "s are")
10398 (if unmark "unread" "read"))))
10400 (defun gnus-summary-kill-same-subject (&optional unmark)
10401 "Mark articles which has the same subject as read.
10402 If UNMARK is positive, remove any kind of mark.
10403 If UNMARK is negative, tick articles."
10406 (setq unmark (prefix-numeric-value unmark)))
10408 (gnus-summary-mark-same-subject
10409 (gnus-summary-article-subject) unmark)))
10410 ;; If marked as read, go to next unread subject.
10411 (when (null unmark)
10412 ;; Go to next unread subject.
10413 (gnus-summary-next-subject 1 t))
10414 (gnus-message 7 "%d articles are marked as %s"
10415 count (if unmark "unread" "read"))))
10417 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10418 "Mark articles with same SUBJECT as read, and return marked number.
10419 If optional argument UNMARK is positive, remove any kinds of marks.
10420 If optional argument UNMARK is negative, mark articles as unread instead."
10424 ((null unmark) ; Mark as read.
10427 (gnus-summary-mark-article-as-read gnus-killed-mark)
10428 (gnus-summary-show-thread) t)
10429 (gnus-summary-find-subject subject))
10430 (setq count (1+ count))))
10431 ((> unmark 0) ; Tick.
10434 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10435 (gnus-summary-show-thread) t)
10436 (gnus-summary-find-subject subject))
10437 (setq count (1+ count))))
10438 (t ; Mark as unread.
10441 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10442 (gnus-summary-show-thread) t)
10443 (gnus-summary-find-subject subject))
10444 (setq count (1+ count)))))
10445 (gnus-set-mode-line 'summary)
10446 ;; Return the number of marked articles.
10449 (defun gnus-summary-mark-as-processable (n &optional unmark)
10450 "Set the process mark on the next N articles.
10451 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10452 the process mark instead. The difference between N and the actual
10453 number of articles marked is returned."
10455 (if (and (null n) (gnus-region-active-p))
10456 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10457 (setq n (prefix-numeric-value n))
10458 (let ((backward (< n 0))
10463 (gnus-summary-remove-process-mark
10464 (gnus-summary-article-number))
10465 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10466 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10469 (gnus-message 7 "No more articles"))
10470 (gnus-summary-recenter)
10471 (gnus-summary-position-point)
10474 (defun gnus-summary-unmark-as-processable (n)
10475 "Remove the process mark from the next N articles.
10476 If N is negative, unmark backward instead. The difference between N and
10477 the actual number of articles unmarked is returned."
10479 (gnus-summary-mark-as-processable n t))
10481 (defun gnus-summary-unmark-all-processable ()
10482 "Remove the process mark from all articles."
10485 (while gnus-newsgroup-processable
10486 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10487 (gnus-summary-position-point))
10489 (defun gnus-summary-add-mark (article type)
10490 "Mark ARTICLE with a mark of TYPE."
10491 (let ((vtype (car (assq type gnus-article-mark-lists)))
10494 (error "No such mark type: %s" type)
10495 (setq var (intern (format "gnus-newsgroup-%s" type)))
10496 (set var (cons article (symbol-value var)))
10497 (if (memq type '(processable cached replied forwarded recent saved))
10498 (gnus-summary-update-secondary-mark article)
10499 ;;; !!! This is bogus. We should find out what primary
10500 ;;; !!! mark we want to set.
10501 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10503 (defun gnus-summary-mark-as-expirable (n)
10504 "Mark N articles forward as expirable.
10505 If N is negative, mark backward instead. The difference between N and
10506 the actual number of articles marked is returned."
10508 (gnus-summary-mark-forward n gnus-expirable-mark))
10510 (defun gnus-summary-mark-as-spam (n)
10511 "Mark N articles forward as spam.
10512 If N is negative, mark backward instead. The difference between N and
10513 the actual number of articles marked is returned."
10515 (gnus-summary-mark-forward n gnus-spam-mark))
10517 (defun gnus-summary-mark-article-as-replied (article)
10518 "Mark ARTICLE as replied to and update the summary line.
10519 ARTICLE can also be a list of articles."
10520 (interactive (list (gnus-summary-article-number)))
10521 (let ((articles (if (listp article) article (list article))))
10522 (dolist (article articles)
10523 (unless (numberp article)
10524 (error "%s is not a number" article))
10525 (push article gnus-newsgroup-replied)
10526 (let ((inhibit-read-only t))
10527 (when (gnus-summary-goto-subject article nil t)
10528 (gnus-summary-update-secondary-mark article))))))
10530 (defun gnus-summary-mark-article-as-forwarded (article)
10531 "Mark ARTICLE as forwarded and update the summary line.
10532 ARTICLE can also be a list of articles."
10533 (let ((articles (if (listp article) article (list article))))
10534 (dolist (article articles)
10535 (push article gnus-newsgroup-forwarded)
10536 (let ((inhibit-read-only t))
10537 (when (gnus-summary-goto-subject article nil t)
10538 (gnus-summary-update-secondary-mark article))))))
10540 (defun gnus-summary-set-bookmark (article)
10541 "Set a bookmark in current article."
10542 (interactive (list (gnus-summary-article-number)))
10543 (when (or (not (get-buffer gnus-article-buffer))
10544 (not gnus-current-article)
10545 (not gnus-article-current)
10546 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10547 (error "No current article selected"))
10548 ;; Remove old bookmark, if one exists.
10549 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10550 ;; Set the new bookmark, which is on the form
10551 ;; (article-number . line-number-in-body).
10554 (with-current-buffer gnus-article-buffer
10558 (article-goto-body)
10561 gnus-newsgroup-bookmarks)
10562 (gnus-message 6 "A bookmark has been added to the current article."))
10564 (defun gnus-summary-remove-bookmark (article)
10565 "Remove the bookmark from the current article."
10566 (interactive (list (gnus-summary-article-number)))
10567 ;; Remove old bookmark, if one exists.
10568 (if (not (assq article gnus-newsgroup-bookmarks))
10569 (gnus-message 6 "No bookmark in current article.")
10570 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10571 (gnus-message 6 "Removed bookmark.")))
10573 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10574 (defun gnus-summary-mark-as-dormant (n)
10575 "Mark N articles forward as dormant.
10576 If N is negative, mark backward instead. The difference between N and
10577 the actual number of articles marked is returned."
10579 (gnus-summary-mark-forward n gnus-dormant-mark))
10581 (defun gnus-summary-set-process-mark (article)
10582 "Set the process mark on ARTICLE and update the summary line."
10583 (setq gnus-newsgroup-processable
10585 (delq article gnus-newsgroup-processable)))
10586 (when (gnus-summary-goto-subject article)
10587 (gnus-summary-show-thread)
10588 (gnus-summary-goto-subject article)
10589 (gnus-summary-update-secondary-mark article)))
10591 (defun gnus-summary-remove-process-mark (&rest articles)
10592 "Remove the process mark from ARTICLES and update the summary line."
10593 (dolist (article articles)
10594 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10595 (when (gnus-summary-goto-subject article)
10596 (gnus-summary-show-thread)
10597 (gnus-summary-goto-subject article)
10598 (gnus-summary-update-secondary-mark article)))
10601 (defun gnus-summary-set-saved-mark (article)
10602 "Set the process mark on ARTICLE and update the summary line."
10603 (push article gnus-newsgroup-saved)
10604 (when (gnus-summary-goto-subject article)
10605 (gnus-summary-update-secondary-mark article)))
10607 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10608 "Mark N articles as read forwards.
10609 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10610 The difference between N and the actual number of articles marked is
10612 If NO-EXPIRE, auto-expiry will be inhibited."
10614 (gnus-summary-show-thread)
10615 (let ((backward (< n 0))
10616 (gnus-summary-goto-unread
10617 (and gnus-summary-goto-unread
10618 (not (eq gnus-summary-goto-unread 'never))
10619 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10620 gnus-ticked-mark gnus-dormant-mark)))))
10622 (mark (or mark gnus-del-mark)))
10623 (while (and (> n 0)
10624 (gnus-summary-mark-article nil mark no-expire)
10625 (zerop (gnus-summary-next-subject
10627 (and gnus-summary-goto-unread
10628 (not (eq gnus-summary-goto-unread 'never)))
10632 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10633 (gnus-summary-recenter)
10634 (gnus-summary-position-point)
10635 (gnus-set-mode-line 'summary)
10638 (defun gnus-summary-mark-article-as-read (mark)
10639 "Mark the current article quickly as read with MARK."
10640 (let ((article (gnus-summary-article-number)))
10641 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10642 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10643 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10644 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10645 (push (cons article mark) gnus-newsgroup-reads)
10646 ;; Possibly remove from cache, if that is used.
10647 (when gnus-use-cache
10648 (gnus-cache-enter-remove-article article))
10649 ;; Allow the backend to change the mark.
10650 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10651 ;; Check for auto-expiry.
10652 (when (and gnus-newsgroup-auto-expire
10653 (memq mark gnus-auto-expirable-marks))
10654 (setq mark gnus-expirable-mark)
10655 ;; Let the backend know about the mark change.
10656 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10657 (push article gnus-newsgroup-expirable))
10658 ;; Set the mark in the buffer.
10659 (gnus-summary-update-mark mark 'unread)
10662 (defun gnus-summary-mark-article-as-unread (mark)
10663 "Mark the current article quickly as unread with MARK."
10664 (let* ((article (gnus-summary-article-number))
10665 (old-mark (gnus-summary-article-mark article)))
10666 ;; Allow the backend to change the mark.
10667 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10668 (if (eq mark old-mark)
10672 (gnus-error 1 "Can't mark negative article numbers")
10674 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10675 (setq gnus-newsgroup-spam-marked
10676 (delq article gnus-newsgroup-spam-marked))
10677 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10678 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10679 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10680 (cond ((= mark gnus-ticked-mark)
10681 (setq gnus-newsgroup-marked
10682 (gnus-add-to-sorted-list gnus-newsgroup-marked
10684 ((= mark gnus-spam-mark)
10685 (setq gnus-newsgroup-spam-marked
10686 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10688 ((= mark gnus-dormant-mark)
10689 (setq gnus-newsgroup-dormant
10690 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10693 (setq gnus-newsgroup-unreads
10694 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10696 (gnus-alist-pull article gnus-newsgroup-reads)
10698 ;; See whether the article is to be put in the cache.
10699 (and gnus-use-cache
10700 (vectorp (gnus-summary-article-header article))
10702 (gnus-cache-possibly-enter-article
10703 gnus-newsgroup-name article
10704 (= mark gnus-ticked-mark)
10705 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10708 (gnus-summary-update-mark mark 'unread)
10711 (defun gnus-summary-mark-article (&optional article mark no-expire)
10712 "Mark ARTICLE with MARK. MARK can be any character.
10713 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10714 `??' (dormant) and `?E' (expirable).
10715 If MARK is nil, then the default character `?r' is used.
10716 If ARTICLE is nil, then the article on the current line will be
10718 If NO-EXPIRE, auto-expiry will be inhibited."
10719 ;; The mark might be a string.
10720 (when (stringp mark)
10721 (setq mark (aref mark 0)))
10722 ;; If no mark is given, then we check auto-expiring.
10724 (setq mark gnus-del-mark))
10725 (when (and (not no-expire)
10726 gnus-newsgroup-auto-expire
10727 (memq mark gnus-auto-expirable-marks))
10728 (setq mark gnus-expirable-mark))
10729 (let ((article (or article (gnus-summary-article-number)))
10730 (old-mark (gnus-summary-article-mark article)))
10731 ;; Allow the backend to change the mark.
10732 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10733 (if (eq mark old-mark)
10736 (error "No article on current line"))
10737 (if (not (if (or (= mark gnus-unread-mark)
10738 (= mark gnus-ticked-mark)
10739 (= mark gnus-spam-mark)
10740 (= mark gnus-dormant-mark))
10741 (gnus-mark-article-as-unread article mark)
10742 (gnus-mark-article-as-read article mark)))
10744 ;; See whether the article is to be put in the cache.
10745 (and gnus-use-cache
10746 (not (= mark gnus-canceled-mark))
10747 (vectorp (gnus-summary-article-header article))
10749 (gnus-cache-possibly-enter-article
10750 gnus-newsgroup-name article
10751 (= mark gnus-ticked-mark)
10752 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10754 (when (gnus-summary-goto-subject article nil t)
10755 (let ((inhibit-read-only t))
10756 (gnus-summary-show-thread)
10758 (gnus-summary-update-mark mark 'unread)
10761 (defun gnus-summary-update-secondary-mark (article)
10762 "Update the secondary (read, process, cache) mark."
10763 (gnus-summary-update-mark
10764 (cond ((memq article gnus-newsgroup-processable)
10766 ((memq article gnus-newsgroup-cached)
10768 ((memq article gnus-newsgroup-replied)
10770 ((memq article gnus-newsgroup-forwarded)
10771 gnus-forwarded-mark)
10772 ((memq article gnus-newsgroup-saved)
10774 ((memq article gnus-newsgroup-recent)
10776 ((memq article gnus-newsgroup-unseen)
10780 (when (gnus-visual-p 'summary-highlight 'highlight)
10781 (gnus-summary-highlight-line)
10782 (gnus-run-hooks 'gnus-summary-update-hook))
10785 (defun gnus-summary-update-download-mark (article)
10786 "Update the download mark."
10787 (gnus-summary-update-mark
10788 (cond ((memq article gnus-newsgroup-undownloaded)
10789 gnus-undownloaded-mark)
10790 (gnus-newsgroup-agentized
10791 gnus-downloaded-mark)
10795 (gnus-summary-update-line t)
10798 (defun gnus-summary-update-mark (mark type)
10799 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10800 (inhibit-read-only t))
10801 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10803 (when (looking-at "\r")
10805 (when (<= (+ forward (point)) (point-max))
10806 ;; Go to the right position on the line.
10807 (goto-char (+ forward (point)))
10808 ;; Replace the old mark with the new mark.
10810 (mm-subst-char-in-string
10812 (buffer-substring (point) (1+ (point))))))
10813 (delete-region (point) (1+ (point)))
10814 (insert to-insert))
10815 ;; Optionally update the marks by some user rule.
10816 (when (eq type 'unread)
10817 (gnus-data-set-mark
10818 (gnus-data-find (gnus-summary-article-number)) mark)
10819 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10821 (defun gnus-mark-article-as-read (article &optional mark)
10822 "Enter ARTICLE in the pertinent lists and remove it from others."
10823 ;; Make the article expirable.
10824 (let ((mark (or mark gnus-del-mark)))
10825 (setq gnus-newsgroup-expirable
10826 (if (= mark gnus-expirable-mark)
10827 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10828 (delq article gnus-newsgroup-expirable)))
10829 ;; Remove from unread and marked lists.
10830 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10831 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10832 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10833 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10834 (push (cons article mark) gnus-newsgroup-reads)
10835 ;; Possibly remove from cache, if that is used.
10836 (when gnus-use-cache
10837 (gnus-cache-enter-remove-article article))
10840 (defun gnus-mark-article-as-unread (article &optional mark)
10841 "Enter ARTICLE in the pertinent lists and remove it from others."
10842 (let ((mark (or mark gnus-ticked-mark)))
10845 (gnus-error 1 "Can't mark negative article numbers")
10847 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10848 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10849 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10850 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10851 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10853 ;; Unsuppress duplicates?
10854 (when gnus-suppress-duplicates
10855 (gnus-dup-unsuppress-article article))
10857 (cond ((= mark gnus-ticked-mark)
10858 (setq gnus-newsgroup-marked
10859 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10860 ((= mark gnus-spam-mark)
10861 (setq gnus-newsgroup-spam-marked
10862 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10864 ((= mark gnus-dormant-mark)
10865 (setq gnus-newsgroup-dormant
10866 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10868 (setq gnus-newsgroup-unreads
10869 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10870 (gnus-alist-pull article gnus-newsgroup-reads)
10873 (defun gnus-summary-tick-article-forward (n)
10874 "Tick N articles forwards.
10875 If N is negative, tick backwards instead.
10876 The difference between N and the number of articles ticked is returned."
10878 (gnus-summary-mark-forward n gnus-ticked-mark))
10880 (defun gnus-summary-tick-article-backward (n)
10881 "Tick N articles backwards.
10882 The difference between N and the number of articles ticked is returned."
10884 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10886 (defun gnus-summary-tick-article (&optional article clear-mark)
10887 "Mark current article as unread.
10888 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10889 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10891 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10892 gnus-ticked-mark)))
10894 (defun gnus-summary-mark-as-read-forward (n)
10895 "Mark N articles as read forwards.
10896 If N is negative, mark backwards instead.
10897 The difference between N and the actual number of articles marked is
10900 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10902 (defun gnus-summary-mark-as-read-backward (n)
10903 "Mark the N articles as read backwards.
10904 The difference between N and the actual number of articles marked is
10907 (gnus-summary-mark-forward
10908 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10910 (defun gnus-summary-mark-as-read (&optional article mark)
10911 "Mark current article as read.
10912 ARTICLE specifies the article to be marked as read.
10913 MARK specifies a string to be inserted at the beginning of the line."
10914 (gnus-summary-mark-article article mark))
10916 (defun gnus-summary-clear-mark-forward (n)
10917 "Clear marks from N articles forward.
10918 If N is negative, clear backward instead.
10919 The difference between N and the number of marks cleared is returned."
10921 (gnus-summary-mark-forward n gnus-unread-mark))
10923 (defun gnus-summary-clear-mark-backward (n)
10924 "Clear marks from N articles backward.
10925 The difference between N and the number of marks cleared is returned."
10927 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10929 (defun gnus-summary-mark-unread-as-read ()
10930 "Intended to be used by `gnus-mark-article-hook'."
10931 (when (memq gnus-current-article gnus-newsgroup-unreads)
10932 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10934 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10935 "Intended to be used by `gnus-mark-article-hook'."
10936 (let ((mark (gnus-summary-article-mark)))
10937 (when (or (gnus-unread-mark-p mark)
10938 (gnus-read-mark-p mark))
10939 (gnus-summary-mark-article gnus-current-article
10940 (or new-mark gnus-read-mark)))))
10942 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10943 "Intended to be used by `gnus-mark-article-hook'."
10944 (let ((mark (gnus-summary-article-mark)))
10945 (when (or (gnus-unread-mark-p mark)
10946 (gnus-read-mark-p mark))
10947 (gnus-summary-mark-article (gnus-summary-article-number)
10948 (or new-mark gnus-read-mark)))))
10950 (defun gnus-summary-mark-unread-as-ticked ()
10951 "Intended to be used by `gnus-mark-article-hook'."
10952 (when (memq gnus-current-article gnus-newsgroup-unreads)
10953 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10955 (defun gnus-summary-mark-region-as-read (point mark all)
10956 "Mark all unread articles between point and mark as read.
10957 If given a prefix, mark all articles between point and mark as read,
10958 even ticked and dormant ones."
10959 (interactive "r\nP")
10963 (beginning-of-line)
10968 (memq (setq article (gnus-summary-article-number))
10969 gnus-newsgroup-unreads))
10970 (gnus-summary-mark-article article gnus-del-mark))
10972 (gnus-summary-find-next))))))
10974 (defun gnus-summary-mark-below (score mark)
10975 "Mark articles with score less than SCORE with MARK."
10976 (interactive "P\ncMark: ")
10977 (setq score (if score
10978 (prefix-numeric-value score)
10979 (or gnus-summary-default-score 0)))
10980 (with-current-buffer gnus-summary-buffer
10981 (goto-char (point-min))
10984 (and (< (gnus-summary-article-score) score)
10985 (gnus-summary-mark-article nil mark))
10986 (gnus-summary-find-next)))))
10988 (defun gnus-summary-kill-below (&optional score)
10989 "Mark articles with score below SCORE as read."
10991 (gnus-summary-mark-below score gnus-killed-mark))
10993 (defun gnus-summary-clear-above (&optional score)
10994 "Clear all marks from articles with score above SCORE."
10996 (gnus-summary-mark-above score gnus-unread-mark))
10998 (defun gnus-summary-tick-above (&optional score)
10999 "Tick all articles with score above SCORE."
11001 (gnus-summary-mark-above score gnus-ticked-mark))
11003 (defun gnus-summary-mark-above (score mark)
11004 "Mark articles with score over SCORE with MARK."
11005 (interactive "P\ncMark: ")
11006 (setq score (if score
11007 (prefix-numeric-value score)
11008 (or gnus-summary-default-score 0)))
11009 (with-current-buffer gnus-summary-buffer
11010 (goto-char (point-min))
11012 (when (> (gnus-summary-article-score) score)
11013 (gnus-summary-mark-article nil mark))
11015 (gnus-summary-find-next)))))
11017 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11018 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11019 (defun gnus-summary-limit-include-expunged (&optional no-error)
11020 "Display all the hidden articles that were expunged for low scores."
11022 (let ((inhibit-read-only t))
11023 (let ((scored gnus-newsgroup-scored)
11026 (unless (gnus-summary-article-header (caar scored))
11027 (and (setq h (gnus-number-to-header (caar scored)))
11028 (< (cdar scored) gnus-summary-expunge-below)
11030 (setq scored (cdr scored)))
11032 (when (not no-error)
11033 (error "No expunged articles hidden"))
11034 (goto-char (point-min))
11035 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11036 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11037 (dolist (x headers)
11038 (push (mail-header-number x) gnus-newsgroup-limit))
11039 (gnus-summary-prepare-unthreaded (nreverse headers))
11040 (goto-char (point-min))
11041 (gnus-summary-position-point)
11044 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11045 "Mark all unread articles in this newsgroup as read.
11046 If prefix argument ALL is non-nil, ticked and dormant articles will
11047 also be marked as read.
11048 If QUIETLY is non-nil, no questions will be asked.
11050 If TO-HERE is non-nil, it should be a point in the buffer. All
11051 articles before (after, if REVERSE is set) this point will be marked
11054 Note that this function will only catch up the unread article
11055 in the current summary buffer limitation.
11057 The number of articles marked as read is returned."
11062 (not gnus-interactive-catchup) ;Without confirmation?
11066 "Mark absolutely all articles as read? "
11067 "Mark all unread articles as read? ")))
11069 (not gnus-newsgroup-adaptive)
11070 (not gnus-newsgroup-auto-expire)
11071 (not gnus-suppress-duplicates)
11072 (or (not gnus-use-cache)
11073 (eq gnus-use-cache 'passive)))
11076 (setq gnus-newsgroup-marked nil
11077 gnus-newsgroup-spam-marked nil
11078 gnus-newsgroup-dormant nil))
11079 (setq gnus-newsgroup-unreads
11080 (gnus-sorted-nunion
11081 (gnus-sorted-intersection gnus-newsgroup-unreads
11082 gnus-newsgroup-downloadable)
11083 (gnus-sorted-difference gnus-newsgroup-unfetched
11084 gnus-newsgroup-cached))))
11085 ;; We actually mark all articles as canceled, which we
11086 ;; have to do when using auto-expiry or adaptive scoring.
11087 (gnus-summary-show-all-threads)
11088 (if (and to-here reverse)
11090 (goto-char to-here)
11091 (gnus-summary-mark-current-read-and-unread-as-read
11093 (while (gnus-summary-find-next (not all))
11094 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11095 (when (gnus-summary-first-subject (not all))
11097 (if to-here (< (point) to-here) t)
11098 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11099 (gnus-summary-find-next (not all))))))
11100 (gnus-set-mode-line 'summary))
11102 (gnus-summary-position-point)))
11104 (defun gnus-summary-catchup-to-here (&optional all)
11105 "Mark all unticked articles before the current one as read.
11106 If ALL is non-nil, also mark ticked and dormant articles as read."
11109 (gnus-save-hidden-threads
11110 (let ((beg (point)))
11111 ;; We check that there are unread articles.
11112 (when (or all (gnus-summary-find-prev))
11113 (gnus-summary-catchup all t beg)))))
11114 (gnus-summary-position-point))
11116 (defun gnus-summary-catchup-from-here (&optional all)
11117 "Mark all unticked articles after (and including) the current one as read.
11118 If ALL is non-nil, also mark ticked and dormant articles as read."
11121 (gnus-save-hidden-threads
11122 (let ((beg (point)))
11123 ;; We check that there are unread articles.
11124 (when (or all (gnus-summary-find-next))
11125 (gnus-summary-catchup all t beg nil t)))))
11126 (gnus-summary-position-point))
11128 (defun gnus-summary-catchup-all (&optional quietly)
11129 "Mark all articles in this newsgroup as read.
11130 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11131 instead, which marks only unread articles as read."
11133 (gnus-summary-catchup t quietly))
11135 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11136 "Mark all unread articles in this group as read, then exit.
11137 If prefix argument ALL is non-nil, all articles are marked as read.
11138 If QUIETLY is non-nil, no questions will be asked."
11140 (when (gnus-summary-catchup all quietly nil 'fast)
11141 ;; Select next newsgroup or exit.
11142 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11143 (eq gnus-auto-select-next 'quietly))
11144 (gnus-summary-next-group nil)
11145 (gnus-summary-exit))))
11147 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11148 "Mark all articles in this newsgroup as read, and then exit.
11149 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11150 instead, which marks only unread articles as read."
11152 (gnus-summary-catchup-and-exit t quietly))
11154 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11155 "Mark all articles in this group as read and select the next group.
11156 If given a prefix, mark all articles, unread as well as ticked, as
11160 (gnus-summary-catchup all))
11161 (gnus-summary-next-group))
11163 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11164 "Mark all articles in this group as read and select the previous group.
11165 If given a prefix, mark all articles, unread as well as ticked, as
11169 (gnus-summary-catchup all))
11170 (gnus-summary-next-group nil nil t))
11176 (defmacro gnus-with-article (article &rest forms)
11177 "Select ARTICLE and perform FORMS in the original article buffer.
11178 Then replace the article with the result."
11180 ;; We don't want the article to be marked as read.
11181 (let (gnus-mark-article-hook)
11182 (gnus-summary-select-article t t nil ,article))
11183 (set-buffer gnus-original-article-buffer)
11185 (if (not (gnus-check-backend-function
11186 'request-replace-article (car gnus-article-current)))
11187 (gnus-message 5 "Read-only group; not replacing")
11188 (unless (gnus-request-replace-article
11189 ,article (car gnus-article-current)
11190 (current-buffer) t)
11191 (error "Couldn't replace article")))
11192 ;; The cache and backlog have to be flushed somewhat.
11193 (when gnus-keep-backlog
11194 (gnus-backlog-remove-article
11195 (car gnus-article-current) (cdr gnus-article-current)))
11196 (when gnus-use-cache
11197 (gnus-cache-update-article
11198 (car gnus-article-current) (cdr gnus-article-current)))))
11200 (put 'gnus-with-article 'lisp-indent-function 1)
11201 (put 'gnus-with-article 'edebug-form-spec '(form body))
11203 ;; Thread-based commands.
11205 (defun gnus-summary-articles-in-thread (&optional article)
11206 "Return a list of all articles in the current thread.
11207 If ARTICLE is non-nil, return all articles in the thread that starts
11208 with that article."
11209 (let* ((article (or article (gnus-summary-article-number)))
11210 (data (gnus-data-find-list article))
11211 (top-level (gnus-data-level (car data)))
11213 (cond ((null gnus-thread-operation-ignore-subject)
11214 (gnus-simplify-subject-re
11215 (mail-header-subject (gnus-data-header (car data)))))
11216 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11217 (gnus-simplify-subject-fuzzy
11218 (mail-header-subject (gnus-data-header (car data)))))
11220 (end-point (save-excursion
11221 (if (gnus-summary-go-to-next-thread)
11222 (point) (point-max))))
11225 (< (gnus-data-pos (car data)) end-point))
11226 (when (or (not top-subject)
11227 (string= top-subject
11228 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11229 (gnus-simplify-subject-fuzzy
11230 (mail-header-subject
11231 (gnus-data-header (car data))))
11232 (gnus-simplify-subject-re
11233 (mail-header-subject
11234 (gnus-data-header (car data)))))))
11235 (push (gnus-data-number (car data)) articles))
11236 (unless (and (setq data (cdr data))
11237 (> (gnus-data-level (car data)) top-level))
11239 ;; Return the list of articles.
11240 (nreverse articles)))
11242 (defun gnus-summary-rethread-current ()
11243 "Rethread the thread the current article is part of."
11245 (let* ((gnus-show-threads t)
11246 (article (gnus-summary-article-number))
11247 (id (mail-header-id (gnus-summary-article-header)))
11248 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11250 (error "No article on the current line"))
11251 (gnus-rebuild-thread id)
11252 (gnus-summary-goto-subject article)))
11254 (defun gnus-summary-reparent-thread ()
11255 "Make the current article child of the marked (or previous) article.
11257 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11258 is non-nil or the Subject: of both articles are the same."
11260 (unless (not (gnus-group-read-only-p))
11261 (error "The current newsgroup does not support article editing"))
11262 (unless (<= (length gnus-newsgroup-processable) 1)
11263 (error "No more than one article may be marked"))
11264 (let ((child (gnus-summary-article-number))
11265 ;; First grab the marked article, otherwise one line up.
11266 (parent (if (not (null gnus-newsgroup-processable))
11267 (car gnus-newsgroup-processable)
11269 (if (eq (forward-line -1) 0)
11270 (gnus-summary-article-number)
11271 (error "Beginning of summary buffer"))))))
11272 (gnus-summary-reparent-children parent (list child))))
11274 (defun gnus-summary-reparent-children (parent children)
11275 "Make PARENT the parent of CHILDREN.
11276 When called interactively, PARENT is the current article and CHILDREN
11277 are the process-marked articles."
11279 (list (gnus-summary-article-number)
11280 (gnus-summary-work-articles nil)))
11281 (dolist (child children)
11282 (save-window-excursion
11283 (let ((gnus-article-buffer " *reparent*"))
11284 (unless (not (eq parent child))
11285 (error "An article may not be self-referential"))
11286 (let ((message-id (mail-header-id
11287 (gnus-summary-article-header parent))))
11288 (unless (and message-id (not (equal message-id "")))
11289 (error "No message-id in desired parent"))
11290 (gnus-with-article child
11292 (goto-char (point-min))
11293 (message-narrow-to-head)
11294 (if (re-search-forward "^References: " nil t)
11296 (re-search-forward "^[^ \t]" nil t)
11299 (insert " " message-id))
11300 (insert "References: " message-id "\n"))))
11301 (set-buffer gnus-summary-buffer)
11302 (gnus-summary-unmark-all-processable)
11303 (gnus-summary-update-article child)
11304 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11305 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11306 (gnus-summary-rethread-current)
11307 (gnus-message 3 "Article %d is now the child of article %d"
11310 (defun gnus-summary-toggle-threads (&optional arg)
11311 "Toggle showing conversation threads.
11312 If ARG is positive number, turn showing conversation threads on."
11314 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11315 (setq gnus-show-threads
11316 (if (null arg) (not gnus-show-threads)
11317 (> (prefix-numeric-value arg) 0)))
11318 (gnus-summary-prepare)
11319 (gnus-summary-goto-subject current)
11320 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11321 (gnus-summary-position-point)))
11324 (if (fboundp 'remove-overlays)
11325 (defalias 'gnus-remove-overlays 'remove-overlays)
11326 (defun gnus-remove-overlays (beg end name val)
11327 "Clear BEG and END of overlays whose property NAME has value VAL.
11328 For compatibility with XEmacs."
11329 (dolist (ov (gnus-overlays-in beg end))
11330 (when (eq (gnus-overlay-get ov name) val)
11331 (gnus-delete-overlay ov))))))
11333 (defun gnus-summary-show-all-threads ()
11334 "Show all threads."
11336 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11337 (gnus-summary-position-point))
11339 (defsubst gnus-summary--inv (p)
11340 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11342 (defun gnus-summary-show-thread ()
11343 "Show thread subtrees.
11344 Returns nil if no thread was there to be shown."
11346 (let* ((orig (point))
11347 (end (point-at-eol))
11348 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11349 ;; Leave point at bol
11350 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11352 (if (fboundp 'next-single-char-property-change)
11353 (or (next-single-char-property-change end 'invisible)
11358 (eq (get-char-property (point) 'invisible)
11362 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11364 (gnus-summary-position-point)
11367 (defun gnus-summary-maybe-hide-threads ()
11368 "If requested, hide the threads that should be hidden."
11369 (when (and gnus-show-threads
11370 gnus-thread-hide-subtree)
11371 (gnus-summary-hide-all-threads
11372 (if (or (consp gnus-thread-hide-subtree)
11373 (functionp gnus-thread-hide-subtree))
11374 (gnus-make-predicate gnus-thread-hide-subtree)
11377 ;;; Hiding predicates.
11379 (defun gnus-article-unread-p (header)
11380 (memq (mail-header-number header) gnus-newsgroup-unreads))
11382 (defun gnus-article-unseen-p (header)
11383 (memq (mail-header-number header) gnus-newsgroup-unseen))
11385 (defun gnus-map-articles (predicate articles)
11386 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11387 (apply 'gnus-or (mapcar predicate
11388 (mapcar (lambda (number)
11389 (gnus-summary-article-header number))
11392 (defun gnus-summary-hide-all-threads (&optional predicate)
11393 "Hide all thread subtrees.
11394 If PREDICATE is supplied, threads that satisfy this predicate
11395 will not be hidden."
11398 (goto-char (point-min))
11401 (when (or (not predicate)
11403 predicate (gnus-summary-article-children)))
11404 (gnus-summary-hide-thread))
11405 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11406 (gnus-summary-position-point))
11408 (defun gnus-summary-hide-thread ()
11409 "Hide thread subtrees.
11410 If PREDICATE is supplied, threads that satisfy this predicate
11411 will not be hidden.
11412 Returns nil if no threads were there to be hidden."
11414 (let ((start (point))
11415 (starteol (line-end-position))
11416 (article (gnus-summary-article-number)))
11418 ;; Go forward until either the buffer ends or the subthread ends.
11419 (when (and (not (eobp))
11420 (or (zerop (gnus-summary-next-thread 1 t))
11421 (goto-char (point-max))))
11422 (if (and (> (point) start)
11423 ;; FIXME: this should actually search for a non-invisible \n.
11424 (search-backward "\n" start t))
11426 (when (> (point) starteol)
11427 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11428 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11429 (gnus-overlay-put ol 'invisible 'gnus-sum)
11430 (gnus-overlay-put ol 'evaporate t)))
11431 (gnus-summary-goto-subject article))
11435 (defun gnus-summary-go-to-next-thread (&optional previous)
11436 "Go to the same level (or less) next thread.
11437 If PREVIOUS is non-nil, go to previous thread instead.
11438 Return the article number moved to, or nil if moving was impossible."
11439 (let ((level (gnus-summary-thread-level))
11440 (way (if previous -1 1))
11443 (while (and (not (eobp))
11444 (< level (gnus-summary-thread-level)))
11445 (forward-line way))
11452 (gnus-summary-article-number)
11453 (goto-char beg)))))
11455 (defun gnus-summary-next-thread (n &optional silent)
11456 "Go to the same level next N'th thread.
11457 If N is negative, search backward instead.
11458 Returns the difference between N and the number of skips actually
11461 If SILENT, don't output messages."
11463 (let ((backward (< n 0))
11465 (while (and (> n 0)
11466 (gnus-summary-go-to-next-thread backward))
11469 (gnus-summary-position-point))
11470 (when (and (not silent) (/= 0 n))
11471 (gnus-message 7 "No more threads"))
11474 (defun gnus-summary-prev-thread (n)
11475 "Go to the same level previous N'th thread.
11476 Returns the difference between N and the number of skips actually
11479 (gnus-summary-next-thread (- n)))
11481 (defun gnus-summary-go-down-thread ()
11482 "Go down one level in the current thread."
11483 (let ((children (gnus-summary-article-children)))
11485 (gnus-summary-goto-subject (car children)))))
11487 (defun gnus-summary-go-up-thread ()
11488 "Go up one level in the current thread."
11489 (let ((parent (gnus-summary-article-parent)))
11491 (gnus-summary-goto-subject parent))))
11493 (defun gnus-summary-down-thread (n)
11494 "Go down thread N steps.
11495 If N is negative, go up instead.
11496 Returns the difference between N and how many steps down that were
11501 (while (and (> n 0)
11502 (if up (gnus-summary-go-up-thread)
11503 (gnus-summary-go-down-thread)))
11505 (gnus-summary-position-point)
11507 (gnus-message 7 "Can't go further"))
11510 (defun gnus-summary-up-thread (n)
11511 "Go up thread N steps.
11512 If N is negative, go down instead.
11513 Returns the difference between N and how many steps down that were
11516 (gnus-summary-down-thread (- n)))
11518 (defun gnus-summary-top-thread ()
11519 "Go to the top of the thread."
11521 (while (gnus-summary-go-up-thread))
11522 (gnus-summary-article-number))
11524 (defun gnus-summary-expire-thread ()
11525 "Mark articles under current thread as expired."
11527 (gnus-summary-kill-thread 0))
11529 (defun gnus-summary-kill-thread (&optional unmark)
11530 "Mark articles under current thread as read.
11531 If the prefix argument is positive, remove any kinds of marks.
11532 If the prefix argument is zero, mark thread as expired.
11533 If the prefix argument is negative, tick articles instead."
11536 (setq unmark (prefix-numeric-value unmark)))
11537 (let ((articles (gnus-summary-articles-in-thread))
11538 (hide (or (null unmark) (= unmark 0))))
11540 ;; Expand the thread.
11541 (gnus-summary-show-thread)
11542 ;; Mark all the articles.
11544 (gnus-summary-goto-subject (car articles))
11545 (cond ((null unmark)
11546 (gnus-summary-mark-article-as-read gnus-killed-mark))
11548 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11550 (gnus-summary-mark-article nil gnus-expirable-mark))
11552 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11553 (setq articles (cdr articles))))
11554 ;; Hide killed subtrees when hide is true.
11556 gnus-thread-hide-killed
11557 (gnus-summary-hide-thread))
11558 ;; If hide is t, go to next unread subject.
11560 ;; Go to next unread subject.
11561 (gnus-summary-next-subject 1 t)))
11562 (gnus-set-mode-line 'summary))
11564 ;; Summary sorting commands
11566 (defun gnus-summary-sort-by-number (&optional reverse)
11567 "Sort the summary buffer by article number.
11568 Argument REVERSE means reverse order."
11570 (gnus-summary-sort 'number reverse))
11572 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11573 "Sort the summary buffer by most recent article number.
11574 Argument REVERSE means reverse order."
11576 (gnus-summary-sort 'most-recent-number reverse))
11578 (defun gnus-summary-sort-by-random (&optional reverse)
11579 "Randomize the order in the summary buffer.
11580 Argument REVERSE means to randomize in reverse order."
11582 (gnus-summary-sort 'random reverse))
11584 (defun gnus-summary-sort-by-author (&optional reverse)
11585 "Sort the summary buffer by author name alphabetically.
11586 If `case-fold-search' is non-nil, case of letters is ignored.
11587 Argument REVERSE means reverse order."
11589 (gnus-summary-sort 'author reverse))
11591 (defun gnus-summary-sort-by-recipient (&optional reverse)
11592 "Sort the summary buffer by recipient name alphabetically.
11593 If `case-fold-search' is non-nil, case of letters is ignored.
11594 Argument REVERSE means reverse order."
11596 (gnus-summary-sort 'recipient reverse))
11598 (defun gnus-summary-sort-by-subject (&optional reverse)
11599 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11600 If `case-fold-search' is non-nil, case of letters is ignored.
11601 Argument REVERSE means reverse order."
11603 (gnus-summary-sort 'subject reverse))
11605 (defun gnus-summary-sort-by-date (&optional reverse)
11606 "Sort the summary buffer by date.
11607 Argument REVERSE means reverse order."
11609 (gnus-summary-sort 'date reverse))
11611 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11612 "Sort the summary buffer by most recent date.
11613 Argument REVERSE means reverse order."
11615 (gnus-summary-sort 'most-recent-date reverse))
11617 (defun gnus-summary-sort-by-score (&optional reverse)
11618 "Sort the summary buffer by score.
11619 Argument REVERSE means reverse order."
11621 (gnus-summary-sort 'score reverse))
11623 (defun gnus-summary-sort-by-lines (&optional reverse)
11624 "Sort the summary buffer by the number of lines.
11625 Argument REVERSE means reverse order."
11627 (gnus-summary-sort 'lines reverse))
11629 (defun gnus-summary-sort-by-chars (&optional reverse)
11630 "Sort the summary buffer by article length.
11631 Argument REVERSE means reverse order."
11633 (gnus-summary-sort 'chars reverse))
11635 (defun gnus-summary-sort-by-original (&optional reverse)
11636 "Sort the summary buffer using the default sorting method.
11637 Argument REVERSE means reverse order."
11639 (let* ((inhibit-read-only t)
11640 (gnus-summary-prepare-hook nil))
11641 ;; We do the sorting by regenerating the threads.
11642 (gnus-summary-prepare)
11643 ;; Hide subthreads if needed.
11644 (gnus-summary-maybe-hide-threads)))
11646 (defun gnus-summary-sort (predicate reverse)
11647 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11648 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11649 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11650 (gnus-thread-sort-functions
11655 (gnus-sort-gathered-threads-function
11656 gnus-thread-sort-functions)
11657 (gnus-article-sort-functions
11661 (,article t2 t1))))
11662 (inhibit-read-only t)
11663 (gnus-summary-prepare-hook nil))
11664 ;; We do the sorting by regenerating the threads.
11665 (gnus-summary-prepare)
11666 ;; Hide subthreads if needed.
11667 (gnus-summary-maybe-hide-threads)))
11669 ;; Summary saving commands.
11671 (defun gnus-summary-save-article (&optional n not-saved)
11672 "Save the current article using the default saver function.
11673 If N is a positive number, save the N next articles.
11674 If N is a negative number, save the N previous articles.
11675 If N is nil and any articles have been marked with the process mark,
11676 save those articles instead.
11677 The variable `gnus-default-article-saver' specifies the saver function.
11679 If the optional second argument NOT-SAVED is non-nil, articles saved
11680 will not be marked as saved."
11682 (require 'gnus-art)
11683 (let* ((articles (gnus-summary-work-articles n))
11684 (save-buffer (save-excursion
11685 (nnheader-set-temp-buffer " *Gnus Save*")))
11686 (num (length articles))
11687 ;; Whether to save decoded articles or raw articles.
11688 (decode (when gnus-article-save-coding-system
11689 (get gnus-default-article-saver :decode)))
11690 ;; When saving many articles in a single file, use the other
11691 ;; function to save articles other than the first one.
11692 (saver2 (get gnus-default-article-saver :function))
11693 (gnus-prompt-before-saving (if saver2
11695 gnus-prompt-before-saving))
11696 (gnus-default-article-saver gnus-default-article-saver)
11698 (dolist (article articles)
11699 (setq header (gnus-summary-article-header article))
11700 (if (not (vectorp header))
11701 ;; This is a pseudo-article.
11702 (if (assq 'name header)
11703 (gnus-copy-file (cdr (assq 'name header)))
11704 (gnus-message 1 "Article %d is unsaveable" article))
11705 ;; This is a real article.
11706 (save-window-excursion
11707 (gnus-summary-select-article decode decode nil article)
11708 (gnus-summary-goto-subject article))
11709 (with-current-buffer save-buffer
11711 (insert-buffer-substring (if decode
11712 gnus-article-buffer
11713 gnus-original-article-buffer)))
11714 (setq file (gnus-article-save save-buffer file num))
11715 (gnus-summary-remove-process-mark article)
11717 (gnus-summary-set-saved-mark article)))
11719 (setq gnus-default-article-saver saver2
11721 (gnus-kill-buffer save-buffer)
11722 (gnus-summary-position-point)
11723 (gnus-set-mode-line 'summary)
11726 (defun gnus-summary-pipe-output (&optional n sym)
11727 "Pipe the current article to a subprocess.
11728 If N is a positive number, pipe the N next articles.
11729 If N is a negative number, pipe the N previous articles.
11730 If N is nil and any articles have been marked with the process mark,
11731 pipe those articles instead.
11732 The default command to which articles are piped is specified by the
11733 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11734 will be prompted for the command.
11736 The properties `:decode' and `:headers' that are put to the function
11737 symbol `gnus-summary-save-in-pipe' control whether this function
11738 decodes articles and what headers to keep (see the doc string for the
11739 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11740 is neither omitted nor the symbol `r', force including all headers
11741 regardless of the `:headers' property. If it is the symbol `r',
11742 articles that are not decoded and include all headers will be piped
11743 no matter what the properties `:decode' and `:headers' are."
11744 (interactive (gnus-interactive "P\ny"))
11745 (require 'gnus-art)
11746 (let* ((articles (gnus-summary-work-articles n))
11747 (result-buffer "*Shell Command Output*")
11748 (all-headers (not (memq sym '(nil r))))
11749 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11751 (headers (get 'gnus-summary-save-in-pipe :headers))
11753 (unless (numberp (car articles))
11754 (error "No article to pipe"))
11755 (setq command (gnus-read-shell-command
11756 (concat "Shell command on "
11758 (format "these %d articles" (length articles))
11761 gnus-summary-pipe-output-default-command))
11762 (when (string-equal command "")
11763 (error "A command is required"))
11765 (put 'gnus-summary-save-in-pipe :headers nil))
11768 (gnus-summary-goto-subject (pop articles))
11769 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11770 (when (and (get-buffer result-buffer)
11771 (not (zerop (buffer-size (get-buffer result-buffer)))))
11772 (setq result (concat result (with-current-buffer result-buffer
11773 (buffer-string))))))
11774 (put 'gnus-summary-save-in-pipe :headers headers))
11775 (unless (zerop (length result))
11776 (if (with-current-buffer (get-buffer-create result-buffer)
11780 (and (= (count-lines (point-min) (point)) 1)
11783 (<= (current-column)
11784 (window-width (minibuffer-window)))))
11785 (goto-char (point-min))))
11786 (message "%s" (substring result 0 -1))
11788 (gnus-configure-windows 'pipe)))))
11790 (defun gnus-summary-save-article-mail (&optional arg)
11791 "Append the current article to a Unix mail box file.
11792 If N is a positive number, save the N next articles.
11793 If N is a negative number, save the N previous articles.
11794 If N is nil and any articles have been marked with the process mark,
11795 save those articles instead."
11797 (require 'gnus-art)
11798 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11799 (gnus-summary-save-article arg)))
11801 (defun gnus-summary-save-article-rmail (&optional arg)
11802 "Append the current article to an rmail file.
11803 If N is a positive number, save the N next articles.
11804 If N is a negative number, save the N previous articles.
11805 If N is nil and any articles have been marked with the process mark,
11806 save those articles instead."
11808 (require 'gnus-art)
11809 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11810 (gnus-summary-save-article arg)))
11812 (defun gnus-summary-save-article-file (&optional arg)
11813 "Append the current article to a file.
11814 If N is a positive number, save the N next articles.
11815 If N is a negative number, save the N previous articles.
11816 If N is nil and any articles have been marked with the process mark,
11817 save those articles instead."
11819 (require 'gnus-art)
11820 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11821 (gnus-summary-save-article arg)))
11823 (defun gnus-summary-write-article-file (&optional arg)
11824 "Write the current article to a file, deleting the previous file.
11825 If N is a positive number, save the N next articles.
11826 If N is a negative number, save the N previous articles.
11827 If N is nil and any articles have been marked with the process mark,
11828 save those articles instead."
11830 (require 'gnus-art)
11831 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11832 (gnus-summary-save-article arg)))
11834 (defun gnus-summary-save-article-body-file (&optional arg)
11835 "Append the current article body to a file.
11836 If N is a positive number, save the N next articles.
11837 If N is a negative number, save the N previous articles.
11838 If N is nil and any articles have been marked with the process mark,
11839 save those articles instead."
11841 (require 'gnus-art)
11842 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11843 (gnus-summary-save-article arg)))
11845 (defun gnus-summary-write-article-body-file (&optional arg)
11846 "Write the current article body to a file, deleting the previous file.
11847 If N is a positive number, save the N next articles.
11848 If N is a negative number, save the N previous articles.
11849 If N is nil and any articles have been marked with the process mark,
11850 save those articles instead."
11852 (require 'gnus-art)
11853 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11854 (gnus-summary-save-article arg)))
11856 (defun gnus-summary-muttprint (&optional arg)
11857 "Print the current article using Muttprint.
11858 If N is a positive number, save the N next articles.
11859 If N is a negative number, save the N previous articles.
11860 If N is nil and any articles have been marked with the process mark,
11861 save those articles instead."
11863 (require 'gnus-art)
11864 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11865 (gnus-summary-save-article arg t)))
11867 (defun gnus-summary-pipe-message (program)
11868 "Pipe the current article through PROGRAM."
11869 (interactive "sProgram: ")
11870 (gnus-summary-select-article)
11871 (let ((mail-header-separator ""))
11872 (gnus-eval-in-buffer-window gnus-article-buffer
11875 (let ((start (window-start))
11876 (inhibit-read-only t))
11877 (message-pipe-buffer-body program)
11878 (set-window-start (get-buffer-window (current-buffer)) start))))))
11880 (defun gnus-get-split-value (methods)
11881 "Return a value based on the split METHODS."
11882 (let (split-name method result match)
11884 (with-current-buffer gnus-original-article-buffer
11886 (nnheader-narrow-to-headers)
11887 (while (and methods (not split-name))
11888 (goto-char (point-min))
11889 (setq method (pop methods))
11890 (setq match (car method))
11893 ;; Regular expression.
11895 (re-search-forward match nil t)))
11900 (setq result (funcall match gnus-newsgroup-name))))
11905 (setq result (eval match)))))
11906 (setq split-name (cdr method))
11907 (cond ((stringp result)
11908 (push (expand-file-name
11909 result gnus-article-save-directory)
11912 (setq split-name (append result split-name)))))))))
11913 (nreverse split-name)))
11915 (defun gnus-valid-move-group-p (group)
11916 (and (symbolp group)
11918 (symbol-name group)
11919 (symbol-value group)
11920 (gnus-get-function (gnus-find-method-for-group
11921 (symbol-name group)) 'request-accept-article t)))
11923 (defun gnus-read-move-group-name (prompt default articles prefix)
11924 "Read a group name."
11925 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11926 (minibuffer-confirm-incomplete nil) ; XEmacs
11930 (if (> (length articles) 1)
11931 (format "these %d articles" (length articles))
11936 (gnus-group-completing-read
11938 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
11939 nil prefix nil default))
11940 ((= 1 (length split-name))
11941 (gnus-group-completing-read
11943 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
11944 nil prefix 'gnus-group-history (car split-name)))
11946 (gnus-completing-read
11947 prom (nreverse split-name) nil nil 'gnus-group-history))))
11948 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
11951 (if (or (string= to-newsgroup "")
11952 (string= to-newsgroup prefix))
11953 (setq to-newsgroup default))
11954 (unless to-newsgroup
11955 (error "No group name entered"))
11956 (setq encoded (mm-encode-coding-string
11958 (gnus-group-name-charset to-method to-newsgroup)))
11959 (or (gnus-active encoded)
11960 (gnus-activate-group encoded nil nil to-method)
11961 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11963 (or (and (gnus-request-create-group encoded to-method)
11964 (gnus-activate-group encoded nil nil to-method)
11965 (gnus-subscribe-group encoded))
11966 (error "Couldn't create group %s" to-newsgroup)))
11967 (error "No such group: %s" to-newsgroup))
11970 (defvar gnus-summary-save-parts-counter)
11971 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
11973 (defun gnus-summary-save-parts (type dir n &optional reverse)
11974 "Save parts matching TYPE to DIR.
11975 If REVERSE, save parts that do not match TYPE."
11977 (list (read-string "Save parts of type: "
11978 (or (car gnus-summary-save-parts-type-history)
11979 gnus-summary-save-parts-default-mime)
11980 'gnus-summary-save-parts-type-history)
11981 (setq gnus-summary-save-parts-last-directory
11982 (read-file-name "Save to directory: "
11983 gnus-summary-save-parts-last-directory
11985 current-prefix-arg))
11986 (gnus-summary-iterate n
11987 (let ((gnus-display-mime-function nil)
11988 gnus-article-prepare-hook
11989 gnus-article-decode-hook
11990 gnus-display-mime-function
11992 (gnus-inhibit-treatment t))
11993 (gnus-summary-select-article))
11994 (with-current-buffer gnus-article-buffer
11995 (let ((handles (or gnus-article-mime-handles
11996 (mm-dissect-buffer nil gnus-article-loose-mime)
11997 (and gnus-article-emulate-mime
11999 (gnus-summary-save-parts-counter 1))
12001 (gnus-summary-save-parts-1 type dir handles reverse)
12002 (unless gnus-article-mime-handles ;; Don't destroy this case.
12003 (mm-destroy-parts handles)))))))
12005 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12006 (if (stringp (car handle))
12007 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12010 (not (string-match type (mm-handle-media-type handle)))
12011 (string-match type (mm-handle-media-type handle)))
12012 (let ((file (expand-file-name
12014 mm-file-name-rewrite-functions
12015 (file-name-nondirectory
12017 (mail-content-type-get
12018 (mm-handle-disposition handle) 'filename)
12019 (mail-content-type-get
12020 (mm-handle-type handle) 'name)
12021 (format "%s.%d.%d" gnus-newsgroup-name
12022 (cdr gnus-article-current)
12023 gnus-summary-save-parts-counter))))
12025 (incf gnus-summary-save-parts-counter)
12026 (unless (file-exists-p file)
12027 (mm-save-part-to-file handle file))))))
12029 ;; Summary extract commands
12031 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12032 (let ((inhibit-read-only t)
12033 (article (gnus-summary-article-number))
12035 (unless (gnus-summary-goto-subject article)
12036 (error "No such article: %d" article))
12037 (gnus-summary-position-point)
12038 ;; If all commands are to be bunched up on one line, we collect
12040 (unless gnus-view-pseudos-separately
12041 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12044 (setq action (cdr (assq 'action (car ps))))
12045 (setq files (list (cdr (assq 'name (car ps)))))
12046 (while (and ps (cdr ps)
12047 (string= (or action "1")
12048 (or (cdr (assq 'action (cadr ps))) "2")))
12049 (push (cdr (assq 'name (cadr ps))) files)
12050 (setcdr ps (cddr ps)))
12052 (when (not (string-match "%s" action))
12055 (when (assq 'execute (car ps))
12056 (setcdr (assq 'execute (car ps))
12057 (funcall (if (string-match "%s" action)
12064 (shell-quote-argument f)))
12066 (setq ps (cdr ps)))))
12067 (if (and gnus-view-pseudos (not not-view))
12069 (when (assq 'execute (car pslist))
12070 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12071 (eq gnus-view-pseudos 'not-confirm)))
12072 (setq pslist (cdr pslist)))
12075 (setq after-article (or (cdr (assq 'article (car pslist)))
12076 (gnus-summary-article-number)))
12077 (gnus-summary-goto-subject after-article)
12080 (insert " " (file-name-nondirectory
12081 (cdr (assq 'name (car pslist))))
12082 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12084 (forward-line -1) ; back to `b'
12085 (gnus-add-text-properties
12086 b (1- e) (list 'gnus-number gnus-reffed-article-number
12087 gnus-mouse-face-prop gnus-mouse-face))
12089 after-article gnus-reffed-article-number
12090 gnus-unread-mark b (car pslist) 0 (- e b))
12091 (setq gnus-newsgroup-unreads
12092 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12093 gnus-reffed-article-number))
12094 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12095 (setq pslist (cdr pslist)))))))
12097 (defun gnus-pseudos< (p1 p2)
12098 (let ((c1 (cdr (assq 'action p1)))
12099 (c2 (cdr (assq 'action p2))))
12100 (and c1 c2 (string< c1 c2))))
12102 (defun gnus-request-pseudo-article (props)
12103 (cond ((assq 'execute props)
12104 (gnus-execute-command (cdr (assq 'execute props)))))
12105 (let ((gnus-current-article (gnus-summary-article-number)))
12106 (gnus-run-hooks 'gnus-mark-article-hook)))
12108 (defun gnus-execute-command (command &optional automatic)
12110 (gnus-article-setup-buffer)
12111 (set-buffer gnus-article-buffer)
12112 (setq buffer-read-only nil)
12113 (let ((command (if automatic command
12114 (read-string "Command: " (cons command 0)))))
12116 (insert "$ " command "\n\n")
12117 (if gnus-view-pseudo-asynchronously
12118 (start-process "gnus-execute" (current-buffer) shell-file-name
12119 shell-command-switch command)
12120 (call-process shell-file-name nil t nil
12121 shell-command-switch command)))))
12123 ;; Summary kill commands.
12125 (defun gnus-summary-edit-global-kill (article)
12126 "Edit the \"global\" kill file."
12127 (interactive (list (gnus-summary-article-number)))
12128 (gnus-group-edit-global-kill article))
12130 (defun gnus-summary-edit-local-kill ()
12131 "Edit a local kill file applied to the current newsgroup."
12133 (setq gnus-current-headers (gnus-summary-article-header))
12134 (gnus-group-edit-local-kill
12135 (gnus-summary-article-number) gnus-newsgroup-name))
12137 ;;; Header reading.
12139 (defun gnus-read-header (id &optional header)
12140 "Read the headers of article ID and enter them into the Gnus system."
12141 (let ((group gnus-newsgroup-name)
12142 (gnus-override-method
12144 gnus-override-method
12145 (and (gnus-news-group-p gnus-newsgroup-name)
12146 (car (gnus-refer-article-methods)))))
12148 ;; First we check to see whether the header in question is already
12151 ;; This is a Message-ID.
12152 (setq header (or header (gnus-id-to-header id)))
12153 ;; This is an article number.
12154 (setq header (or header (gnus-summary-article-header id))))
12156 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12157 ;; We have found the header.
12159 ;; We have to really fetch the header to this article.
12160 (with-current-buffer nntp-server-buffer
12161 (when (setq where (gnus-request-head id group))
12162 (nnheader-fold-continuation-lines)
12163 (goto-char (point-max))
12165 (goto-char (point-min))
12169 ((cdr where) (cdr where))
12170 (header (mail-header-number header))
12171 (t gnus-reffed-article-number))
12173 (insert " Article retrieved.\n"))
12174 (if (or (not where)
12175 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12176 () ; Malformed head.
12177 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12178 (when (and (stringp id)
12180 (not (string= (gnus-group-real-name group)
12182 (not (gnus-server-equal gnus-override-method
12183 (gnus-group-method group)))))
12184 ;; If we fetched by Message-ID and the article came from
12185 ;; a different group (or server), we fudge some bogus
12186 ;; article numbers for this article.
12187 (mail-header-set-number header gnus-reffed-article-number))
12188 (with-current-buffer gnus-summary-buffer
12189 (decf gnus-reffed-article-number)
12190 (gnus-remove-header (mail-header-number header))
12191 (push header gnus-newsgroup-headers)
12192 (setq gnus-current-headers header)
12193 (push (mail-header-number header) gnus-newsgroup-limit)))
12196 (defun gnus-remove-header (number)
12197 "Remove header NUMBER from `gnus-newsgroup-headers'."
12198 (if (and gnus-newsgroup-headers
12199 (= number (mail-header-number (car gnus-newsgroup-headers))))
12200 (pop gnus-newsgroup-headers)
12201 (let ((headers gnus-newsgroup-headers))
12202 (while (and (cdr headers)
12203 (not (= number (mail-header-number (cadr headers)))))
12205 (when (cdr headers)
12206 (setcdr headers (cddr headers))))))
12209 ;;; summary highlights
12212 (defun gnus-highlight-selected-summary ()
12213 "Highlight selected article in summary buffer."
12214 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12215 (when gnus-summary-selected-face
12217 (let* ((beg (point-at-bol))
12218 (end (point-at-eol))
12219 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12220 (from (if (get-text-property beg gnus-mouse-face-prop)
12222 (or (next-single-property-change
12223 beg gnus-mouse-face-prop nil end)
12228 (or (next-single-property-change
12229 from gnus-mouse-face-prop nil end)
12231 ;; If no mouse-face prop on line we will have to = from = end,
12232 ;; so we highlight the entire line instead.
12233 (when (= (+ to 2) from)
12236 (if gnus-newsgroup-selected-overlay
12237 ;; Move old overlay.
12239 gnus-newsgroup-selected-overlay from to (current-buffer))
12240 ;; Create new overlay.
12242 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12243 'face gnus-summary-selected-face))))))
12245 (defvar gnus-summary-highlight-line-cached nil)
12246 (defvar gnus-summary-highlight-line-trigger nil)
12248 (defun gnus-summary-highlight-line-0 ()
12249 (if (and (eq gnus-summary-highlight-line-trigger
12250 gnus-summary-highlight)
12251 gnus-summary-highlight-line-cached)
12252 gnus-summary-highlight-line-cached
12253 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12254 gnus-summary-highlight-line-cached
12255 (let* ((cond (list 'cond))
12257 (list gnus-summary-highlight))
12259 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12263 (gnus-byte-compile (list 'lambda nil cond))))))
12265 (defun gnus-summary-highlight-line ()
12266 "Highlight current line according to `gnus-summary-highlight'."
12267 (let* ((beg (point-at-bol))
12268 (article (or (gnus-summary-article-number) gnus-current-article))
12269 (score (or (cdr (assq article
12270 gnus-newsgroup-scored))
12271 gnus-summary-default-score 0))
12272 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12273 (inhibit-read-only t)
12274 (default gnus-summary-default-score)
12275 (default-high gnus-summary-default-high-score)
12276 (default-low gnus-summary-default-low-score)
12277 (uncached (and gnus-summary-use-undownloaded-faces
12278 (memq article gnus-newsgroup-undownloaded)
12279 (not (memq article gnus-newsgroup-cached)))))
12280 (let ((face (funcall (gnus-summary-highlight-line-0))))
12281 (unless (eq face (get-text-property beg 'face))
12282 (gnus-put-text-property-excluding-characters-with-faces
12283 beg (point-at-eol) 'face
12284 (setq face (if (boundp face) (symbol-value face) face)))
12285 (when gnus-summary-highlight-line-function
12286 (funcall gnus-summary-highlight-line-function article face))))))
12288 (defun gnus-update-read-articles (group unread &optional compute)
12289 "Update the list of read articles in GROUP.
12290 UNREAD is a sorted list."
12291 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12292 (info (gnus-get-info group))
12295 (if (or (not info) (not active))
12296 ;; There is no info on this group if it was, in fact,
12297 ;; killed. Gnus stores no information on killed groups, so
12298 ;; there's nothing to be done.
12299 ;; One could store the information somewhere temporarily,
12300 ;; perhaps... Hmmm...
12302 ;; Remove any negative articles numbers.
12303 (while (and unread (< (car unread) 0))
12304 (setq unread (cdr unread)))
12305 ;; Remove any expired article numbers
12306 (while (and unread (< (car unread) (car active)))
12307 (setq unread (cdr unread)))
12308 ;; Compute the ranges of read articles by looking at the list of
12309 ;; unread articles.
12311 (when (/= (car unread) prev)
12312 (push (if (= prev (1- (car unread))) prev
12313 (cons prev (1- (car unread))))
12315 (setq prev (1+ (car unread)))
12316 (setq unread (cdr unread)))
12317 (when (<= prev (cdr active))
12318 (push (cons prev (cdr active)) read))
12319 (setq read (if (> (length read) 1) (nreverse read) read))
12324 ;; Propagate the read marks to the backend.
12325 (when (and gnus-propagate-marks
12326 (gnus-check-backend-function 'request-set-mark group))
12327 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12328 (add (gnus-remove-from-range read (gnus-info-read info))))
12330 (unless (gnus-check-group group)
12331 (error "Can't open server for %s" group))
12332 (gnus-request-set-mark
12333 group (delq nil (list (if add (list add 'add '(read)))
12334 (if del (list del 'del '(read))))))
12336 `(gnus-request-set-mark
12339 (if del (list del 'add '(read)))
12340 (if add (list add 'del '(read))))))))))
12341 (set-buffer gnus-group-buffer)
12342 (gnus-undo-register
12344 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12345 (gnus-info-set-read ',info ',(gnus-info-read info))
12346 (gnus-get-unread-articles-in-group ',info
12347 (gnus-active ,group))
12348 (gnus-group-update-group ,group t)
12350 ;; Enter this list into the group info.
12351 (gnus-info-set-read info read)
12352 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12353 (gnus-get-unread-articles-in-group info (gnus-active group))
12356 (defun gnus-offer-save-summaries ()
12357 "Offer to save all active summary buffers."
12359 ;; Go through all buffers and find all summaries.
12360 (dolist (buffer (buffer-list))
12361 (when (and (setq buffer (buffer-name buffer))
12362 (string-match "Summary" buffer)
12363 (with-current-buffer buffer
12364 ;; We check that this is, indeed, a summary buffer.
12365 (and (eq major-mode 'gnus-summary-mode)
12366 ;; Also make sure this isn't bogus.
12367 gnus-newsgroup-prepared
12368 ;; Also make sure that this isn't a
12369 ;; dead summary buffer.
12370 (not gnus-dead-summary-mode))))
12371 (push buffer buffers)))
12372 ;; Go through all these summary buffers and offer to save them.
12376 "Update summary buffer %s? "
12378 (switch-to-buffer buf)
12379 (gnus-summary-exit))
12382 (defun gnus-summary-setup-default-charset ()
12383 "Setup newsgroup default charset."
12384 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12385 (setq gnus-newsgroup-charset nil)
12386 (let* ((ignored-charsets
12387 (or gnus-newsgroup-ephemeral-ignored-charsets
12389 (and gnus-newsgroup-name
12390 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12391 gnus-newsgroup-ignored-charsets))))
12392 (setq gnus-newsgroup-charset
12393 (or gnus-newsgroup-ephemeral-charset
12394 (and gnus-newsgroup-name
12395 (gnus-parameter-charset gnus-newsgroup-name))
12396 gnus-default-charset))
12397 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12398 ignored-charsets))))
12404 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12405 "Display the current article buffer fully MIME-buttonized.
12406 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12407 treated as multipart/mixed."
12409 (require 'gnus-art)
12410 (let ((gnus-unbuttonized-mime-types nil)
12411 (gnus-mime-display-multipart-as-mixed show-all-parts))
12412 (gnus-summary-show-article)))
12414 (defun gnus-summary-repair-multipart (article)
12415 "Add a Content-Type header to a multipart article without one."
12416 (interactive (list (gnus-summary-article-number)))
12417 (gnus-with-article article
12418 (message-narrow-to-head)
12419 (message-remove-header "Mime-Version")
12420 (goto-char (point-max))
12421 (insert "Mime-Version: 1.0\n")
12423 (when (search-forward "\n--" nil t)
12424 (let ((separator (buffer-substring (point) (point-at-eol))))
12425 (message-narrow-to-head)
12426 (message-remove-header "Content-Type")
12427 (goto-char (point-max))
12428 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12431 (let (gnus-mark-article-hook)
12432 (gnus-summary-select-article t t nil article)))
12434 (defun gnus-summary-toggle-display-buttonized ()
12435 "Toggle the buttonizing of the article buffer."
12437 (require 'gnus-art)
12438 (if (setq gnus-inhibit-mime-unbuttonizing
12439 (not gnus-inhibit-mime-unbuttonizing))
12440 (let ((gnus-unbuttonized-mime-types nil))
12441 (gnus-summary-show-article))
12442 (gnus-summary-show-article)))
12445 ;;; Generic summary marking commands
12448 (defvar gnus-summary-marking-alist
12449 '((read gnus-del-mark "d")
12450 (unread gnus-unread-mark "u")
12451 (ticked gnus-ticked-mark "!")
12452 (dormant gnus-dormant-mark "?")
12453 (expirable gnus-expirable-mark "e"))
12454 "An alist of names/marks/keystrokes.")
12456 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12457 (defvar gnus-summary-mark-map)
12459 (defun gnus-summary-make-all-marking-commands ()
12460 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12461 (dolist (elem gnus-summary-marking-alist)
12462 (apply 'gnus-summary-make-marking-command elem)))
12464 (defun gnus-summary-make-marking-command (name mark keystroke)
12465 (let ((map (make-sparse-keymap)))
12466 (define-key gnus-summary-generic-mark-map keystroke map)
12467 (dolist (lway `((next "next" next nil "n")
12468 (next-unread "next unread" next t "N")
12469 (prev "previous" prev nil "p")
12470 (prev-unread "previous unread" prev t "P")
12471 (nomove "" nil nil ,keystroke)))
12472 (let ((func (gnus-summary-make-marking-command-1
12473 mark (car lway) lway name)))
12474 (setq func (eval func))
12475 (define-key map (nth 4 lway) func)))))
12477 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12479 (format "gnus-summary-put-mark-as-%s%s"
12480 name (if (eq way 'nomove)
12482 (concat "-" (symbol-name way)))))
12485 "Mark the current article as %s%s.
12486 If N, the prefix, then repeat N times.
12487 If N is negative, move in reverse order.
12488 The difference between N and the actual number of articles marked is
12492 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12494 (defun gnus-summary-generic-mark (n mark move unread)
12495 "Mark N articles with MARK."
12496 (unless (eq major-mode 'gnus-summary-mode)
12497 (error "This command can only be used in the summary buffer"))
12498 (gnus-summary-show-thread)
12501 ((eq move 'next) 1)
12502 ((eq move 'prev) -1)
12504 (if (zerop nummove)
12508 nummove (* -1 nummove))))
12509 (while (and (> n 0)
12510 (gnus-summary-mark-article nil mark)
12511 (zerop (gnus-summary-next-subject nummove unread t)))
12514 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12515 (gnus-summary-recenter)
12516 (gnus-summary-position-point)
12517 (gnus-set-mode-line 'summary)
12520 (defun gnus-summary-insert-articles (articles)
12521 (when (setq articles
12522 (gnus-sorted-difference articles
12523 (mapcar (lambda (h)
12524 (mail-header-number h))
12525 gnus-newsgroup-headers)))
12526 (setq gnus-newsgroup-headers
12528 gnus-newsgroup-headers
12529 (gnus-fetch-headers articles)
12530 'gnus-article-sort-by-number))
12531 ;; Suppress duplicates?
12532 (when gnus-suppress-duplicates
12533 (gnus-dup-suppress-articles))
12535 (if (and gnus-fetch-old-headers
12536 (eq gnus-headers-retrieved-by 'nov))
12537 ;; We might want to build some more threads first.
12538 (if (eq gnus-fetch-old-headers 'invisible)
12539 (gnus-build-all-threads)
12540 (gnus-build-old-threads))
12541 ;; Mark the inserted articles that are unread as unread.
12542 (setq gnus-newsgroup-unreads
12543 (gnus-sorted-nunion
12544 gnus-newsgroup-unreads
12545 (gnus-sorted-nintersection
12546 (gnus-list-of-unread-articles gnus-newsgroup-name)
12548 ;; Mark the inserted articles as selected so that the information
12549 ;; of the marks having been changed by a user may be updated when
12550 ;; exiting this group. See `gnus-summary-update-info'.
12551 (dolist (art articles)
12552 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12553 ;; Let the Gnus agent mark articles as read.
12555 (gnus-agent-get-undownloaded-list))
12556 ;; Remove list identifiers from subject
12557 (when gnus-list-identifiers
12558 (gnus-summary-remove-list-identifiers))
12559 ;; First and last article in this newsgroup.
12560 (when gnus-newsgroup-headers
12561 (setq gnus-newsgroup-begin
12562 (mail-header-number (car gnus-newsgroup-headers))
12564 (mail-header-number
12565 (gnus-last-element gnus-newsgroup-headers))))
12566 (when gnus-use-scoring
12567 (gnus-possibly-score-headers))))
12569 (defun gnus-summary-insert-old-articles (&optional all)
12570 "Insert all old articles in this group.
12571 If ALL is non-nil, already read articles become readable.
12572 If ALL is a number, fetch this number of articles."
12575 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12578 ;; Some nntp servers lie about their active range. When
12579 ;; this happens, the active range can be in the millions.
12580 ;; Use a compressed range to avoid creating a huge list.
12581 (gnus-range-difference (list gnus-newsgroup-active) old))
12582 (setq len (gnus-range-length older))
12587 (let ((older-range (nreverse older)))
12591 (let* ((r (pop older-range))
12592 (min (if (numberp r) r (car r)))
12593 (max (if (numberp r) r (cdr r))))
12594 (while (and (<= min max)
12599 (setq older (gnus-uncompress-range older))))
12601 (setq older (gnus-uncompress-range older)))
12603 (when (and (numberp gnus-large-newsgroup)
12604 (> len gnus-large-newsgroup))
12605 (let* ((cursor-in-echo-area nil)
12606 (initial (gnus-parameter-large-newsgroup-initial
12607 gnus-newsgroup-name))
12611 "How many articles from %s (%s %d): "
12612 (gnus-group-decoded-name gnus-newsgroup-name)
12613 (if initial "max" "default")
12616 (cons (number-to-string initial)
12618 (unless (string-match "^[ \t]*$" input)
12619 (setq all (string-to-number input))
12621 (let ((older-range (nreverse older)))
12625 (let* ((r (pop older-range))
12626 (min (if (numberp r) r (car r)))
12627 (max (if (numberp r) r (cdr r))))
12628 (while (and (<= min max)
12632 max (1- max))))))))))
12633 (setq older (gnus-uncompress-range older))))
12635 (message "No old news.")
12636 (gnus-summary-insert-articles older)
12637 (gnus-summary-limit (gnus-sorted-nunion old older))))
12638 (gnus-summary-position-point)))
12640 (defun gnus-summary-insert-new-articles ()
12641 "Insert all new articles in this group."
12644 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12645 (old-high gnus-newsgroup-highest)
12646 (nnmail-fetched-sources (list t))
12648 (setq gnus-newsgroup-active
12649 (gnus-copy-sequence
12650 (gnus-activate-group gnus-newsgroup-name 'scan)))
12651 (setq i (cdr gnus-newsgroup-active)
12652 gnus-newsgroup-highest i)
12653 (while (> i old-high)
12657 (message "No gnus is bad news")
12658 (gnus-summary-insert-articles new)
12659 (setq gnus-newsgroup-unreads
12660 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12661 (gnus-summary-limit (gnus-sorted-nunion old new))))
12662 (gnus-summary-position-point)))
12664 ;;; Bookmark support for Gnus.
12665 (declare-function bookmark-make-record-default
12666 "bookmark" (&optional no-file no-context posn))
12667 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12668 (declare-function bookmark-default-handler "bookmark" (bmk))
12669 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12670 (defvar bookmark-yank-point)
12671 (defvar bookmark-current-buffer)
12673 (defun gnus-summary-bookmark-make-record ()
12674 "Make a bookmark entry for a Gnus summary buffer."
12676 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12677 (save-restriction ; FIXME is it necessary to widen?
12678 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12679 (setq buf "art") ; We are recording bookmark from article buffer.
12680 (setq bookmark-yank-point (point))
12681 (setq bookmark-current-buffer (current-buffer))
12682 (gnus-article-show-summary)) ; Go back in summary buffer.
12683 ;; We are now recording bookmark from summary buffer.
12684 (unless buf (setq buf "sum"))
12685 (let* ((subject (elt (gnus-summary-article-header) 1))
12686 (grp (car gnus-article-current))
12687 (art (cdr gnus-article-current))
12688 (head (gnus-summary-article-header art))
12689 (id (mail-header-id head)))
12691 ,@(condition-case nil
12692 (bookmark-make-record-default 'no-file 'no-context pos)
12693 (wrong-number-of-arguments
12694 (bookmark-make-record-default 'point-only)))
12695 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12696 (group . ,grp) (article . ,art)
12697 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12700 (defun gnus-summary-bookmark-jump (bookmark)
12701 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12702 BOOKMARK is a bookmark name or a bookmark record."
12703 (let ((group (bookmark-prop-get bookmark 'group))
12704 (article (bookmark-prop-get bookmark 'article))
12705 (id (bookmark-prop-get bookmark 'message-id))
12706 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12707 (gnus-fetch-group group (list article))
12708 (gnus-summary-insert-cached-articles)
12709 (gnus-summary-goto-article id nil 'force)
12710 ;; FIXME we have to wait article buffer is ready (only large buffer)
12711 ;; Is there a better solution to know that?
12712 ;; If we don't wait `bookmark-default-handler' will have no chance
12713 ;; to set position. However there is no error, just wrong pos.
12715 (when (string= buf "Gnus-art")
12717 (bookmark-default-handler
12719 (buffer . ,(current-buffer))
12720 . ,(bookmark-get-bookmark-record bookmark)))))
12722 (gnus-summary-make-all-marking-commands)
12724 (gnus-ems-redefine)
12726 (provide 'gnus-sum)
12728 (run-hooks 'gnus-sum-load-hook)
12730 ;; Local Variables:
12731 ;; coding: iso-8859-1
12734 ;;; gnus-sum.el ends here