1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
107 :type '(choice (const :tag "off" nil)
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
152 :type '(choice (const :tag "off" nil)
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
183 :type '(choice (const :tag "off" nil)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
195 :type '(repeat function))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
200 :type '(choice (const :tag "off" nil)
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
209 :type '(choice (const :tag "off" nil)
212 (sexp :menu-tag "all" t)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
248 (sexp :menu-tag "on" t)))
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
263 :group 'gnus-score-default
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
271 :group 'gnus-score-default
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
278 :group 'gnus-summary-format
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
287 :type '(repeat regexp))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
305 (sexp :tag "Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
329 :type '(choice (const :tag "off" nil)
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
374 :group 'gnus-group-select
375 :type '(choice (const best)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
412 Select the next article.
414 Select the next unread article.
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
454 (defcustom gnus-auto-center-summary
455 (max (or (bound-and-true-p scroll-margin) 0) 2)
456 "*If non-nil, always center the current summary buffer.
457 In particular, if `vertical' do only vertical recentering. If non-nil
458 and non-`vertical', do both horizontal and vertical recentering."
459 :group 'gnus-summary-maneuvering
460 :type '(choice (const :tag "none" nil)
462 (integer :tag "height")
463 (sexp :menu-tag "both" t)))
465 (defcustom gnus-auto-center-group t
466 "If non-nil, always center the group buffer."
467 :group 'gnus-summary-maneuvering
470 (defcustom gnus-show-all-headers nil
471 "*If non-nil, don't hide any headers."
472 :group 'gnus-article-hiding
473 :group 'gnus-article-headers
476 (defcustom gnus-summary-ignore-duplicates nil
477 "*If non-nil, ignore articles with identical Message-ID headers."
481 (defcustom gnus-single-article-buffer nil
482 "*If non-nil, display all articles in the same buffer.
483 If nil, each group will get its own article buffer."
485 :group 'gnus-article-various
488 (defcustom gnus-widen-article-window nil
489 "If non-nil, selecting the article buffer will display only the article buffer."
491 :group 'gnus-article-various
494 (defcustom gnus-break-pages t
495 "*If non-nil, do page breaking on articles.
496 The page delimiter is specified by the `gnus-page-delimiter'
498 :group 'gnus-article-various
501 (defcustom gnus-move-split-methods nil
502 "*Variable used to suggest where articles are to be moved to.
503 It uses the same syntax as the `gnus-split-methods' variable.
504 However, whereas `gnus-split-methods' specifies file names as targets,
505 this variable specifies group names."
506 :group 'gnus-summary-mail
507 :type '(repeat (choice (list :value (fun) function)
508 (cons :value ("" "") regexp (repeat string))
511 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
512 "Function used to compute default prefix for article move/copy/etc prompts.
513 The function should take one argument, a group name, and return a
514 string with the suggested prefix."
515 :group 'gnus-summary-mail
518 ;; FIXME: Although the custom type is `character' for the following variables,
519 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
521 (defcustom gnus-unread-mark ? ;Whitespace
522 "*Mark used for unread articles."
523 :group 'gnus-summary-marks
526 (defcustom gnus-ticked-mark ?!
527 "*Mark used for ticked articles."
528 :group 'gnus-summary-marks
531 (defcustom gnus-dormant-mark ??
532 "*Mark used for dormant articles."
533 :group 'gnus-summary-marks
536 (defcustom gnus-del-mark ?r
537 "*Mark used for del'd articles."
538 :group 'gnus-summary-marks
541 (defcustom gnus-read-mark ?R
542 "*Mark used for read articles."
543 :group 'gnus-summary-marks
546 (defcustom gnus-expirable-mark ?E
547 "*Mark used for expirable articles."
548 :group 'gnus-summary-marks
551 (defcustom gnus-killed-mark ?K
552 "*Mark used for killed articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-spam-mark ?$
557 "*Mark used for spam articles."
559 :group 'gnus-summary-marks
562 (defcustom gnus-kill-file-mark ?X
563 "*Mark used for articles killed by kill files."
564 :group 'gnus-summary-marks
567 (defcustom gnus-low-score-mark ?Y
568 "*Mark used for articles with a low score."
569 :group 'gnus-summary-marks
572 (defcustom gnus-catchup-mark ?C
573 "*Mark used for articles that are caught up."
574 :group 'gnus-summary-marks
577 (defcustom gnus-replied-mark ?A
578 "*Mark used for articles that have been replied to."
579 :group 'gnus-summary-marks
582 (defcustom gnus-forwarded-mark ?F
583 "*Mark used for articles that have been forwarded."
585 :group 'gnus-summary-marks
588 (defcustom gnus-recent-mark ?N
589 "*Mark used for articles that are recent."
591 :group 'gnus-summary-marks
594 (defcustom gnus-cached-mark ?*
595 "*Mark used for articles that are in the cache."
596 :group 'gnus-summary-marks
599 (defcustom gnus-saved-mark ?S
600 "*Mark used for articles that have been saved."
601 :group 'gnus-summary-marks
604 (defcustom gnus-unseen-mark ?.
605 "*Mark used for articles that haven't been seen."
607 :group 'gnus-summary-marks
610 (defcustom gnus-no-mark ? ;Whitespace
611 "*Mark used for articles that have no other secondary mark."
613 :group 'gnus-summary-marks
616 (defcustom gnus-ancient-mark ?O
617 "*Mark used for ancient articles."
618 :group 'gnus-summary-marks
621 (defcustom gnus-sparse-mark ?Q
622 "*Mark used for sparsely reffed articles."
623 :group 'gnus-summary-marks
626 (defcustom gnus-canceled-mark ?G
627 "*Mark used for canceled articles."
628 :group 'gnus-summary-marks
631 (defcustom gnus-duplicate-mark ?M
632 "*Mark used for duplicate articles."
633 :group 'gnus-summary-marks
636 (defcustom gnus-undownloaded-mark ?-
637 "*Mark used for articles that weren't downloaded."
639 :group 'gnus-summary-marks
642 (defcustom gnus-downloaded-mark ?+
643 "*Mark used for articles that were downloaded."
644 :group 'gnus-summary-marks
647 (defcustom gnus-downloadable-mark ?%
648 "*Mark used for articles that are to be downloaded."
649 :group 'gnus-summary-marks
652 (defcustom gnus-unsendable-mark ?=
653 "*Mark used for articles that won't be sent."
654 :group 'gnus-summary-marks
657 (defcustom gnus-score-over-mark ?+
658 "*Score mark used for articles with high scores."
659 :group 'gnus-summary-marks
662 (defcustom gnus-score-below-mark ?-
663 "*Score mark used for articles with low scores."
664 :group 'gnus-summary-marks
667 (defcustom gnus-empty-thread-mark ? ;Whitespace
668 "*There is no thread under the article."
669 :group 'gnus-summary-marks
672 (defcustom gnus-not-empty-thread-mark ?=
673 "*There is a thread under the article."
674 :group 'gnus-summary-marks
677 (defcustom gnus-view-pseudo-asynchronously nil
678 "*If non-nil, Gnus will view pseudo-articles asynchronously."
679 :group 'gnus-extract-view
682 (defcustom gnus-auto-expirable-marks
683 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
684 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
686 "*The list of marks converted into expiration if a group is auto-expirable."
689 :type '(repeat character))
691 (defcustom gnus-inhibit-user-auto-expire t
692 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
697 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
698 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
699 If nil, the expirable marks will be unchanged except that the marks
700 will be removed when copying or moving articles to a group that has
701 not turned auto-expire on. If non-nil, articles that have been read
702 will be marked as expirable when being copied or moved to a group in
703 which auto-expire is turned on."
706 :group 'gnus-summary-marks)
708 (defcustom gnus-view-pseudos nil
709 "*If `automatic', pseudo-articles will be viewed automatically.
710 If `not-confirm', pseudos will be viewed automatically, and the user
711 will not be asked to confirm the command."
712 :group 'gnus-extract-view
713 :type '(choice (const :tag "off" nil)
715 (const not-confirm)))
717 (defcustom gnus-view-pseudos-separately t
718 "*If non-nil, one pseudo-article will be created for each file to be viewed.
719 If nil, all files that use the same viewing command will be given as a
720 list of parameters to that command."
721 :group 'gnus-extract-view
724 (defcustom gnus-insert-pseudo-articles t
725 "*If non-nil, insert pseudo-articles when decoding articles."
726 :group 'gnus-extract-view
729 (defcustom gnus-summary-dummy-line-format
731 "*The format specification for the dummy roots in the summary buffer.
732 It works along the same lines as a normal formatting string,
733 with some simple extensions.
737 General format specifiers can also be used.
738 See `(gnus)Formatting Variables'."
739 :link '(custom-manual "(gnus)Formatting Variables")
740 :group 'gnus-threading
743 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
744 "*The format specification for the summary mode line.
745 It works along the same lines as a normal formatting string,
746 with some simple extensions:
749 %p Unprefixed group name
750 %A Current article number
751 %z Current article score
753 %U Number of unread articles in the group
754 %e Number of unselected articles in the group
755 %Z A string with unread/unselected article counts
756 %g Shortish group name
757 %S Subject of the current article
759 %s Current score file name
760 %d Number of dormant articles
761 %r Number of articles that have been marked as read in this session
762 %E Number of articles expunged by the score files"
763 :group 'gnus-summary-format
766 (defcustom gnus-list-identifiers nil
767 "Regexp that matches list identifiers to be removed from subject.
768 This can also be a list of regexps."
770 :group 'gnus-summary-format
771 :group 'gnus-article-hiding
772 :type '(choice (const :tag "none" nil)
774 (repeat :value (".*") regexp)))
776 (defcustom gnus-summary-mark-below 0
777 "*Mark all articles with a score below this variable as read.
778 This variable is local to each summary buffer and usually set by the
780 :group 'gnus-score-default
783 (defun gnus-widget-reversible-match (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
789 (eq (length value) 2)
790 (eq (nth 0 value) 'not)
791 (symbolp (nth 1 value)))))
793 (defun gnus-widget-reversible-to-internal (widget value)
794 "Ignoring WIDGET, convert VALUE to internal form.
795 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
796 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
800 (list (nth 1 value) t)))
802 (defun gnus-widget-reversible-to-external (widget value)
803 "Ignoring WIDGET, convert VALUE to external form.
804 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
805 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
808 (list 'not (nth 0 value))
811 (define-widget 'gnus-widget-reversible 'group
812 "A `group' that convert values."
813 :match 'gnus-widget-reversible-match
814 :value-to-internal 'gnus-widget-reversible-to-internal
815 :value-to-external 'gnus-widget-reversible-to-external)
817 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
818 "*List of functions used for sorting articles in the summary buffer.
820 Each function takes two articles and returns non-nil if the first
821 article should be sorted before the other. If you use more than one
822 function, the primary sort function should be the last. You should
823 probably always include `gnus-article-sort-by-number' in the list of
824 sorting functions -- preferably first. Also note that sorting by date
825 is often much slower than sorting by number, and the sorting order is
826 very similar. (Sorting by date means sorting by the time the message
827 was sent, sorting by number means sorting by arrival time.)
829 Each item can also be a list `(not F)' where F is a function;
830 this reverses the sort order.
832 Ready-made functions include `gnus-article-sort-by-number',
833 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
834 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
835 and `gnus-article-sort-by-score'.
837 When threading is turned on, the variable `gnus-thread-sort-functions'
838 controls how articles are sorted."
839 :group 'gnus-summary-sort
840 :type '(repeat (gnus-widget-reversible
841 (choice (function-item gnus-article-sort-by-number)
842 (function-item gnus-article-sort-by-author)
843 (function-item gnus-article-sort-by-subject)
844 (function-item gnus-article-sort-by-date)
845 (function-item gnus-article-sort-by-score)
846 (function-item gnus-article-sort-by-random)
847 (function :tag "other"))
848 (boolean :tag "Reverse order"))))
851 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "*List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted."
877 :group 'gnus-summary-sort
879 (gnus-widget-reversible
880 (choice (function-item gnus-thread-sort-by-number)
881 (function-item gnus-thread-sort-by-author)
882 (function-item gnus-thread-sort-by-recipient)
883 (function-item gnus-thread-sort-by-subject)
884 (function-item gnus-thread-sort-by-date)
885 (function-item gnus-thread-sort-by-score)
886 (function-item gnus-thread-sort-by-most-recent-number)
887 (function-item gnus-thread-sort-by-most-recent-date)
888 (function-item gnus-thread-sort-by-random)
889 (function-item gnus-thread-sort-by-total-score)
890 (function :tag "other"))
891 (boolean :tag "Reverse order"))))
893 (defcustom gnus-thread-score-function '+
894 "*Function used for calculating the total score of a thread.
896 The function is called with the scores of the article and each
897 subthread and should then return the score of the thread.
899 Some functions you can use are `+', `max', or `min'."
900 :group 'gnus-summary-sort
903 (defcustom gnus-summary-expunge-below nil
904 "All articles that have a score less than this variable will be expunged.
905 This variable is local to the summary buffers."
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
910 (defcustom gnus-thread-expunge-below nil
911 "All threads that have a total score less than this variable will be expunged.
912 See `gnus-thread-score-function' for en explanation of what a
915 This variable is local to the summary buffers."
916 :group 'gnus-threading
917 :group 'gnus-score-default
918 :type '(choice (const :tag "off" nil)
921 (defcustom gnus-summary-mode-hook nil
922 "*A hook for Gnus summary mode.
923 This hook is run before any variables are set in the summary buffer."
924 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
925 :group 'gnus-summary-various
928 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
929 (when (featurep 'xemacs)
930 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
931 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
932 (add-hook 'gnus-summary-mode-hook
933 'gnus-xmas-switch-horizontal-scrollbar-off))
935 (defcustom gnus-summary-menu-hook nil
936 "*Hook run after the creation of the summary mode menu."
937 :group 'gnus-summary-visual
940 (defcustom gnus-summary-exit-hook nil
941 "*A hook called on exit from the summary buffer.
942 It will be called with point in the group buffer."
943 :group 'gnus-summary-exit
946 (defcustom gnus-summary-prepare-hook nil
947 "*A hook called after the summary buffer has been generated.
948 If you want to modify the summary buffer, you can use this hook."
949 :group 'gnus-summary-various
952 (defcustom gnus-summary-prepared-hook nil
953 "*A hook called as the last thing after the summary buffer has been generated."
954 :group 'gnus-summary-various
957 (defcustom gnus-summary-generate-hook nil
958 "*A hook run just before generating the summary buffer.
959 This hook is commonly used to customize threading variables and the
961 :group 'gnus-summary-various
964 (defcustom gnus-select-group-hook nil
965 "*A hook called when a newsgroup is selected.
967 If you'd like to simplify subjects like the
968 `gnus-summary-next-same-subject' command does, you can use the
971 (add-hook gnus-select-group-hook
973 (mapcar (lambda (header)
974 (mail-header-set-subject
976 (gnus-simplify-subject
977 (mail-header-subject header) 're-only)))
978 gnus-newsgroup-headers)))"
979 :group 'gnus-group-select
982 (defcustom gnus-select-article-hook nil
983 "*A hook called when an article is selected."
984 :group 'gnus-summary-choose
985 :options '(gnus-agent-fetch-selected-article)
988 (defcustom gnus-visual-mark-article-hook
989 (list 'gnus-highlight-selected-summary)
990 "*Hook run after selecting an article in the summary buffer.
991 It is meant to be used for highlighting the article in some way. It
992 is not run if `gnus-visual' is nil."
993 :group 'gnus-summary-visual
996 (defcustom gnus-parse-headers-hook nil
997 "*A hook called before parsing the headers."
1001 (defcustom gnus-exit-group-hook nil
1002 "*A hook called when exiting summary mode.
1003 This hook is not called from the non-updating exit commands like `Q'."
1004 :group 'gnus-various
1007 (defcustom gnus-summary-update-hook nil
1008 "*A hook called when a summary line is changed.
1009 The hook will not be called if `gnus-visual' is nil.
1011 The default function `gnus-summary-highlight-line' will
1012 highlight the line according to the `gnus-summary-highlight'
1014 :group 'gnus-summary-visual
1017 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1018 "*A hook called when an article is selected for the first time.
1019 The hook is intended to mark an article as read (or unread)
1020 automatically when it is selected."
1021 :group 'gnus-summary-choose
1024 (defcustom gnus-group-no-more-groups-hook nil
1025 "*A hook run when returning to group mode having no more (unread) groups."
1026 :group 'gnus-group-select
1029 (defcustom gnus-ps-print-hook nil
1030 "*A hook run before ps-printing something from Gnus."
1031 :group 'gnus-summary
1034 (defcustom gnus-summary-article-move-hook nil
1035 "*A hook called after an article is moved, copied, respooled, or crossposted."
1037 :group 'gnus-summary
1040 (defcustom gnus-summary-article-delete-hook nil
1041 "*A hook called after an article is deleted."
1043 :group 'gnus-summary
1046 (defcustom gnus-summary-article-expire-hook nil
1047 "*A hook called after an article is expired."
1049 :group 'gnus-summary
1052 (defcustom gnus-summary-display-arrow
1053 (and (fboundp 'display-graphic-p)
1054 (display-graphic-p))
1055 "*If non-nil, display an arrow highlighting the current article."
1057 :group 'gnus-summary
1060 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1061 "Face used for highlighting the current article in the summary buffer."
1062 :group 'gnus-summary-visual
1065 (defvar gnus-tmp-downloaded nil)
1067 (defcustom gnus-summary-highlight
1068 '(((eq mark gnus-canceled-mark)
1069 . gnus-summary-cancelled)
1070 ((and uncached (> score default-high))
1071 . gnus-summary-high-undownloaded)
1072 ((and uncached (< score default-low))
1073 . gnus-summary-low-undownloaded)
1075 . gnus-summary-normal-undownloaded)
1076 ((and (> score default-high)
1077 (or (eq mark gnus-dormant-mark)
1078 (eq mark gnus-ticked-mark)))
1079 . gnus-summary-high-ticked)
1080 ((and (< score default-low)
1081 (or (eq mark gnus-dormant-mark)
1082 (eq mark gnus-ticked-mark)))
1083 . gnus-summary-low-ticked)
1084 ((or (eq mark gnus-dormant-mark)
1085 (eq mark gnus-ticked-mark))
1086 . gnus-summary-normal-ticked)
1087 ((and (> score default-high) (eq mark gnus-ancient-mark))
1088 . gnus-summary-high-ancient)
1089 ((and (< score default-low) (eq mark gnus-ancient-mark))
1090 . gnus-summary-low-ancient)
1091 ((eq mark gnus-ancient-mark)
1092 . gnus-summary-normal-ancient)
1093 ((and (> score default-high) (eq mark gnus-unread-mark))
1094 . gnus-summary-high-unread)
1095 ((and (< score default-low) (eq mark gnus-unread-mark))
1096 . gnus-summary-low-unread)
1097 ((eq mark gnus-unread-mark)
1098 . gnus-summary-normal-unread)
1099 ((> score default-high)
1100 . gnus-summary-high-read)
1101 ((< score default-low)
1102 . gnus-summary-low-read)
1104 . gnus-summary-normal-read))
1105 "*Controls the highlighting of summary buffer lines.
1107 A list of (FORM . FACE) pairs. When deciding how a particular
1108 summary line should be displayed, each form is evaluated. The content
1109 of the face field after the first true form is used. You can change
1110 how those summary lines are displayed, by editing the face field.
1112 You can use the following variables in the FORM field.
1114 score: The article's score.
1115 default: The default article score.
1116 default-high: The default score for high scored articles.
1117 default-low: The default score for low scored articles.
1118 below: The score below which articles are automatically marked as read.
1119 mark: The article's mark.
1120 uncached: Non-nil if the article is uncached."
1121 :group 'gnus-summary-visual
1122 :type '(repeat (cons (sexp :tag "Form" nil)
1124 (put 'gnus-summary-highlight 'risky-local-variable t)
1126 (defcustom gnus-alter-header-function nil
1127 "Function called to allow alteration of article header structures.
1128 The function is called with one parameter, the article header vector,
1129 which it may alter in any way."
1130 :type '(choice (const :tag "None" nil)
1132 :group 'gnus-summary)
1134 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1135 "Function used to decode a string with encoded words.")
1137 (defvar gnus-decode-encoded-address-function
1138 'mail-decode-encoded-address-string
1139 "Function used to decode addresses with encoded words.")
1141 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1142 "*Extra headers to parse."
1143 :version "24.1" ; added Cc Keywords Gcc
1144 :group 'gnus-summary
1145 :type '(repeat symbol))
1147 (defcustom gnus-ignored-from-addresses
1148 (and user-mail-address
1149 (not (string= user-mail-address ""))
1150 (regexp-quote user-mail-address))
1151 "*From headers that may be suppressed in favor of To headers.
1152 This can be a regexp or a list of regexps."
1154 :group 'gnus-summary
1155 :type '(choice regexp
1156 (repeat :tag "Regexp List" regexp)))
1158 (defsubst gnus-ignored-from-addresses ()
1159 (gmm-regexp-concat gnus-ignored-from-addresses))
1161 (defcustom gnus-summary-to-prefix "-> "
1162 "*String prefixed to the To field in the summary line when
1163 using `gnus-ignored-from-addresses'."
1165 :group 'gnus-summary
1168 (defcustom gnus-summary-newsgroup-prefix "=> "
1169 "*String prefixed to the Newsgroup field in the summary
1170 line when using `gnus-ignored-from-addresses'."
1172 :group 'gnus-summary
1175 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1176 "List of charsets that should be ignored.
1177 When these charsets are used in the \"charset\" parameter, the
1178 default charset will be used instead."
1180 :type '(repeat symbol)
1181 :group 'gnus-charset)
1183 (defcustom gnus-newsgroup-maximum-articles nil
1184 "The maximum number of articles a newsgroup.
1185 If this is a number, old articles in a newsgroup exceeding this number
1186 are silently ignored. If it is nil, no article is ignored. Note that
1187 setting this variable to a number might prevent you from reading very
1189 :group 'gnus-group-select
1191 :type '(choice (const :tag "No limit" nil)
1194 (gnus-define-group-parameter
1198 "Return the ignored charsets of GROUP."
1199 :variable gnus-group-ignored-charsets-alist
1201 '(("alt\\.chinese\\.text" iso-8859-1))
1203 "Alist of regexps (to match group names) and charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :variable-group gnus-charset
1207 :variable-type '(repeat (cons (regexp :tag "Group")
1209 :parameter-type '(choice :tag "Ignored charsets"
1212 :parameter-document "\
1213 List of charsets that should be ignored.
1215 When these charsets are used in the \"charset\" parameter, the
1216 default charset will be used instead.")
1218 (defcustom gnus-group-highlight-words-alist nil
1219 "Alist of group regexps and highlight regexps.
1220 This variable uses the same syntax as `gnus-emphasis-alist'."
1222 :type '(repeat (cons (regexp :tag "Group")
1223 (repeat (list (regexp :tag "Highlight regexp")
1224 (number :tag "Group for entire word" 0)
1225 (number :tag "Group for displayed part" 0)
1227 gnus-emphasis-highlight-words)))))
1228 :group 'gnus-summary-visual)
1230 (defcustom gnus-summary-show-article-charset-alist
1232 "Alist of number and charset.
1233 The article will be shown with the charset corresponding to the
1235 For example: ((1 . cn-gb-2312) (2 . big5))."
1237 :type '(repeat (cons (number :tag "Argument" 1)
1238 (symbol :tag "Charset")))
1239 :group 'gnus-charset)
1241 (defcustom gnus-preserve-marks t
1242 "Whether marks are preserved when moving, copying and respooling messages."
1245 :group 'gnus-summary-marks)
1247 (defcustom gnus-alter-articles-to-read-function nil
1248 "Function to be called to alter the list of articles to be selected."
1249 :type '(choice (const nil) function)
1250 :group 'gnus-summary)
1252 (defcustom gnus-orphan-score nil
1253 "*All orphans get this score added. Set in the score file."
1254 :group 'gnus-score-default
1255 :type '(choice (const nil)
1258 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1259 "*A regexp to match MIME parts when saving multiple parts of a
1260 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1261 This regexp will be used by default when prompting the user for which
1262 type of files to save."
1263 :group 'gnus-summary
1266 (defcustom gnus-read-all-available-headers nil
1267 "Whether Gnus should parse all headers made available to it.
1268 This is mostly relevant for slow back ends where the user may
1269 wish to widen the summary buffer to include all headers
1272 :group 'gnus-summary
1273 :type '(choice boolean regexp))
1275 (defcustom gnus-summary-pipe-output-default-command nil
1276 "Command (and optional arguments) used to pipe article to subprocess.
1277 This will be used as the default command if it is non-nil. The value
1278 will be updated if you modify it when executing the command
1279 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1280 :version "23.1" ;; No Gnus
1281 :group 'gnus-summary
1282 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1284 (defcustom gnus-summary-muttprint-program "muttprint"
1285 "Command (and optional arguments) used to run Muttprint.
1286 The value will be updated if you modify it when executing the command
1287 `gnus-summary-muttprint'."
1289 :group 'gnus-summary
1292 (defcustom gnus-article-loose-mime t
1293 "If non-nil, don't require MIME-Version header.
1294 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1295 supply the MIME-Version header or deliberately strip it from the mail.
1296 If non-nil (the default), Gnus will treat some articles as MIME
1297 even if the MIME-Version header is missing."
1300 :group 'gnus-article-mime)
1302 (defcustom gnus-article-emulate-mime t
1303 "If non-nil, use MIME emulation for uuencode and the like.
1304 This means that Gnus will search message bodies for text that look
1305 like uuencoded bits, yEncoded bits, and so on, and present that using
1306 the normal Gnus MIME machinery."
1309 :group 'gnus-article-mime)
1311 ;;; Internal variables
1313 (defvar gnus-summary-display-cache nil)
1314 (defvar gnus-article-mime-handles nil)
1315 (defvar gnus-article-decoded-p nil)
1316 (defvar gnus-article-charset nil)
1317 (defvar gnus-article-ignored-charsets nil)
1318 (defvar gnus-scores-exclude-files nil)
1319 (defvar gnus-page-broken nil)
1321 (defvar gnus-original-article nil)
1322 (defvar gnus-article-internal-prepare-hook nil)
1323 (defvar gnus-newsgroup-process-stack nil)
1325 (defvar gnus-thread-indent-array nil)
1326 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1327 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1328 "Function called to sort the articles within a thread after it has been gathered together.")
1330 (defvar gnus-summary-save-parts-type-history nil)
1331 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1333 ;; Avoid highlighting in kill files.
1334 (defvar gnus-summary-inhibit-highlight nil)
1335 (defvar gnus-newsgroup-selected-overlay nil)
1336 (defvar gnus-inhibit-limiting nil)
1337 (defvar gnus-newsgroup-adaptive-score-file nil)
1338 (defvar gnus-current-score-file nil)
1339 (defvar gnus-current-move-group nil)
1340 (defvar gnus-current-copy-group nil)
1341 (defvar gnus-current-crosspost-group nil)
1342 (defvar gnus-newsgroup-display nil)
1344 (defvar gnus-newsgroup-dependencies nil)
1345 (defvar gnus-newsgroup-adaptive nil)
1346 (defvar gnus-summary-display-article-function nil)
1347 (defvar gnus-summary-highlight-line-function nil
1348 "Function called after highlighting a summary line.")
1350 (defvar gnus-summary-line-format-alist
1351 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1352 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1353 (?s gnus-tmp-subject-or-nil ?s)
1354 (?n gnus-tmp-name ?s)
1355 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1357 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1359 (?F gnus-tmp-from ?s)
1360 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1361 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1362 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1363 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1364 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1365 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1366 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1367 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1368 (?L gnus-tmp-lines ?s)
1369 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1371 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1373 (?g (or (gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header)))
1376 (?O gnus-tmp-downloaded ?c)
1377 (?I gnus-tmp-indentation ?s)
1378 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1379 (?R gnus-tmp-replied ?c)
1380 (?\[ gnus-tmp-opening-bracket ?c)
1381 (?\] gnus-tmp-closing-bracket ?c)
1382 (?\> (make-string gnus-tmp-level ? ) ?s)
1383 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1384 (?i gnus-tmp-score ?d)
1385 (?z gnus-tmp-score-char ?c)
1386 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1387 (?U gnus-tmp-unread ?c)
1388 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1390 (?t (gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1393 (?e (gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1396 (?u gnus-tmp-user-defined ?s)
1397 (?P (gnus-pick-line-number) ?d)
1398 (?B gnus-tmp-thread-tree-header-string ?s)
1399 (user-date (gnus-user-date
1400 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1401 "An alist of format specifications that can appear in summary lines.
1402 These are paired with what variables they correspond with, along with
1403 the type of the variable (string, integer, character, etc).")
1405 (defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s)
1407 (?N gnus-tmp-number ?d)
1408 (?u gnus-tmp-user-defined ?s)))
1410 (defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s)
1412 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1413 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1414 (?A gnus-tmp-article-number ?d)
1415 (?Z gnus-tmp-unread-and-unselected ?s)
1416 (?V gnus-version ?s)
1417 (?U gnus-tmp-unread-and-unticked ?d)
1418 (?S gnus-tmp-subject ?s)
1419 (?e gnus-tmp-unselected ?d)
1420 (?u gnus-tmp-user-defined ?s)
1421 (?d (length gnus-newsgroup-dormant) ?d)
1422 (?t (length gnus-newsgroup-marked) ?d)
1423 (?h (length gnus-newsgroup-spam-marked) ?d)
1424 (?r (length gnus-newsgroup-reads) ?d)
1425 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1426 (?E gnus-newsgroup-expunged-tally ?d)
1427 (?s (gnus-current-score-file-nondirectory) ?s)))
1429 ;; This is here rather than in gnus-art for compilation reasons.
1430 (defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w (gnus-article-wash-status) ?s)
1432 (?m (gnus-article-mime-part-status) ?s))
1433 gnus-summary-mode-line-format-alist))
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1441 (defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1443 (defvar gnus-newsgroup-begin nil)
1444 (defvar gnus-newsgroup-end nil)
1445 (defvar gnus-newsgroup-last-rmail nil)
1446 (defvar gnus-newsgroup-last-mail nil)
1447 (defvar gnus-newsgroup-last-folder nil)
1448 (defvar gnus-newsgroup-last-file nil)
1449 (defvar gnus-newsgroup-last-directory nil)
1450 (defvar gnus-newsgroup-auto-expire nil)
1451 (defvar gnus-newsgroup-active nil)
1452 (defvar gnus-newsgroup-highest nil)
1454 (defvar gnus-newsgroup-data nil)
1455 (defvar gnus-newsgroup-data-reverse nil)
1456 (defvar gnus-newsgroup-limit nil)
1457 (defvar gnus-newsgroup-limits nil)
1458 (defvar gnus-summary-use-undownloaded-faces nil)
1460 (defvar gnus-newsgroup-unreads nil
1461 "Sorted list of unread articles in the current newsgroup.")
1463 (defvar gnus-newsgroup-unselected nil
1464 "Sorted list of unselected unread articles in the current newsgroup.")
1466 (defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1469 (defvar gnus-newsgroup-expunged-tally nil)
1471 (defvar gnus-newsgroup-marked nil
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1474 (defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
1477 (defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1480 (defvar gnus-newsgroup-cached nil
1481 "Sorted list of articles that come from the article cache.")
1483 (defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1486 (defvar gnus-newsgroup-kill-headers nil)
1488 (defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1491 (defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1494 (defvar gnus-newsgroup-expirable nil
1495 "Sorted list of articles in the current newsgroup that can be expired.")
1497 (defvar gnus-newsgroup-processable nil
1498 "List of articles in the current newsgroup that can be processed.")
1500 (defvar gnus-newsgroup-downloadable nil
1501 "Sorted list of articles in the current newsgroup that can be processed.")
1503 (defvar gnus-newsgroup-unfetched nil
1504 "Sorted list of articles in the current newsgroup whose headers have
1505 not been fetched into the agent.
1507 This list will always be a subset of gnus-newsgroup-undownloaded.")
1509 (defvar gnus-newsgroup-undownloaded nil
1510 "List of articles in the current newsgroup that haven't been downloaded.")
1512 (defvar gnus-newsgroup-unsendable nil
1513 "List of articles in the current newsgroup that won't be sent.")
1515 (defvar gnus-newsgroup-bookmarks nil
1516 "List of articles in the current newsgroup that have bookmarks.")
1518 (defvar gnus-newsgroup-dormant nil
1519 "Sorted list of dormant articles in the current newsgroup.")
1521 (defvar gnus-newsgroup-unseen nil
1522 "List of unseen articles in the current newsgroup.")
1524 (defvar gnus-newsgroup-seen nil
1525 "Range of seen articles in the current newsgroup.")
1527 (defvar gnus-newsgroup-unexist nil
1528 "Range of unexistent articles in the current newsgroup.")
1530 (defvar gnus-newsgroup-articles nil
1531 "List of articles in the current newsgroup.")
1533 (defvar gnus-newsgroup-scored nil
1534 "List of scored articles in the current newsgroup.")
1536 (defvar gnus-newsgroup-headers nil
1537 "List of article headers in the current newsgroup.")
1539 (defvar gnus-newsgroup-threads nil)
1541 (defvar gnus-newsgroup-prepared nil
1542 "Whether the current group has been prepared properly.")
1544 (defvar gnus-newsgroup-ancient nil
1545 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1547 (defvar gnus-newsgroup-sparse nil)
1549 (defvar gnus-current-article nil)
1550 (defvar gnus-article-current nil)
1551 (defvar gnus-current-headers nil)
1552 (defvar gnus-have-all-headers nil)
1553 (defvar gnus-last-article nil)
1554 (defvar gnus-newsgroup-history nil)
1555 (defvar gnus-newsgroup-charset nil)
1556 (defvar gnus-newsgroup-ephemeral-charset nil)
1557 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1559 (defvar gnus-article-before-search nil)
1561 (defvar gnus-summary-local-variables
1562 '(gnus-newsgroup-name
1565 gnus-newsgroup-unreads
1566 gnus-newsgroup-unselected
1567 gnus-newsgroup-marked
1568 gnus-newsgroup-spam-marked
1569 gnus-newsgroup-reads
1570 gnus-newsgroup-saved
1571 gnus-newsgroup-replied
1572 gnus-newsgroup-forwarded
1573 gnus-newsgroup-expirable
1574 gnus-newsgroup-killed
1575 gnus-newsgroup-unseen
1577 gnus-newsgroup-unexist
1578 gnus-newsgroup-cached
1579 gnus-newsgroup-downloadable
1580 gnus-newsgroup-undownloaded
1581 gnus-newsgroup-unsendable
1583 gnus-newsgroup-begin gnus-newsgroup-end
1584 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1585 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1586 gnus-newsgroup-last-directory
1587 gnus-newsgroup-auto-expire
1588 gnus-newsgroup-processable
1589 gnus-newsgroup-unfetched
1590 gnus-newsgroup-articles
1591 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1592 gnus-newsgroup-headers gnus-newsgroup-threads
1593 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1594 gnus-current-article gnus-current-headers gnus-have-all-headers
1595 gnus-last-article gnus-article-internal-prepare-hook
1596 (gnus-summary-article-delete-hook . global)
1597 (gnus-summary-article-move-hook . global)
1598 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1599 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1600 gnus-thread-expunge-below
1601 gnus-score-alist gnus-current-score-file
1602 (gnus-summary-expunge-below . global)
1603 (gnus-summary-mark-below . global)
1604 (gnus-orphan-score . global)
1605 gnus-newsgroup-active gnus-scores-exclude-files
1606 gnus-newsgroup-highest
1607 gnus-newsgroup-history gnus-newsgroup-ancient
1608 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1609 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1610 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1611 (gnus-newsgroup-expunged-tally . 0)
1612 gnus-cache-removable-articles
1613 gnus-newsgroup-data gnus-newsgroup-data-reverse
1614 gnus-newsgroup-limit gnus-newsgroup-limits
1615 gnus-newsgroup-charset gnus-newsgroup-display
1616 gnus-summary-use-undownloaded-faces)
1617 "Variables that are buffer-local to the summary buffers.")
1619 (defvar gnus-newsgroup-variables nil
1620 "A list of variables that have separate values in different newsgroups.
1621 A list of newsgroup (summary buffer) local variables, or cons of
1622 variables and their default expressions to be evalled (when the default
1623 values are not nil), that should be made global while the summary buffer
1626 Note: The default expressions will be evaluated (using function `eval')
1627 before assignment to the local variable rather than just assigned to it.
1628 If the default expression is the symbol `global', that symbol will not
1629 be evaluated but the global value of the local variable will be used
1632 These variables can be used to set variables in the group parameters
1633 while still allowing them to affect operations done in other buffers.
1636 \(setq gnus-newsgroup-variables
1637 '(message-use-followup-to
1638 (gnus-visible-headers .
1639 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1643 ;; Bind features so that require will believe that gnus-sum has
1644 ;; already been loaded (avoids infinite recursion)
1645 (let ((features (cons 'gnus-sum features)))
1646 (require 'gnus-art)))
1650 (defvar gnus-decode-encoded-word-methods
1651 '(mail-decode-encoded-word-string)
1652 "List of methods used to decode encoded words.
1654 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1655 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1656 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1657 whose names match REGEXP.
1660 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1661 mail-decode-encoded-word-string
1662 (\"chinese\" . rfc1843-decode-string))")
1664 (defvar gnus-decode-encoded-word-methods-cache nil)
1666 (defun gnus-multi-decode-encoded-word-string (string)
1667 "Apply the functions from `gnus-encoded-word-methods' that match."
1668 (unless (and gnus-decode-encoded-word-methods-cache
1669 (eq gnus-newsgroup-name
1670 (car gnus-decode-encoded-word-methods-cache)))
1671 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1672 (dolist (method gnus-decode-encoded-word-methods)
1673 (if (symbolp method)
1674 (nconc gnus-decode-encoded-word-methods-cache (list method))
1675 (if (and gnus-newsgroup-name
1676 (string-match (car method) gnus-newsgroup-name))
1677 (nconc gnus-decode-encoded-word-methods-cache
1678 (list (cdr method)))))))
1679 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1680 (setq string (funcall method string))))
1682 ;; Subject simplification.
1684 (defun gnus-simplify-whitespace (str)
1685 "Remove excessive whitespace from STR."
1687 (while (string-match "[ \t][ \t]+" str)
1688 (setq str (concat (substring str 0 (match-beginning 0))
1690 (substring str (match-end 0)))))
1692 (when (string-match "^[ \t]+" str)
1693 (setq str (substring str (match-end 0))))
1695 (when (string-match "[ \t]+$" str)
1696 (setq str (substring str 0 (match-beginning 0))))
1699 (defun gnus-simplify-all-whitespace (str)
1700 "Remove all whitespace from STR."
1701 (while (string-match "[ \t\n]+" str)
1702 (setq str (replace-match "" nil nil str)))
1705 (defsubst gnus-simplify-subject-re (subject)
1706 "Remove \"Re:\" from subject lines."
1707 (if (string-match message-subject-re-regexp subject)
1708 (substring subject (match-end 0))
1711 (defun gnus-simplify-subject (subject &optional re-only)
1712 "Remove `Re:' and words in parentheses.
1713 If RE-ONLY is non-nil, strip leading `Re:'s only."
1714 (let ((case-fold-search t)) ;Ignore case.
1715 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1716 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1717 (setq subject (substring subject (match-end 0))))
1718 ;; Remove uninteresting prefixes.
1719 (when (and (not re-only)
1720 gnus-simplify-ignored-prefixes
1721 (string-match gnus-simplify-ignored-prefixes subject))
1722 (setq subject (substring subject (match-end 0))))
1723 ;; Remove words in parentheses from end.
1725 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1726 (setq subject (substring subject 0 (match-beginning 0)))))
1727 ;; Return subject string.
1730 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1732 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1733 (goto-char (point-min))
1734 (while (re-search-forward regexp nil t)
1735 (replace-match (or newtext ""))))
1737 (defun gnus-simplify-buffer-fuzzy (regexp)
1738 "Simplify string in the buffer fuzzily.
1739 The string in the accessible portion of the current buffer is simplified.
1740 It is assumed to be a single-line subject.
1741 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1742 matter is removed. Additional things can be deleted by setting
1743 `gnus-simplify-subject-fuzzy-regexp'."
1744 (let ((case-fold-search t)
1746 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1748 (while (not (eq modified-tick (buffer-modified-tick)))
1749 (setq modified-tick (buffer-modified-tick))
1752 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1754 (gnus-simplify-buffer-fuzzy-step regexp)))
1755 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1756 (gnus-simplify-buffer-fuzzy-step
1757 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1758 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1760 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1761 (gnus-simplify-buffer-fuzzy-step " +" " ")
1762 (gnus-simplify-buffer-fuzzy-step " $")
1763 (gnus-simplify-buffer-fuzzy-step "^ +")))
1765 (defun gnus-simplify-subject-fuzzy (subject)
1766 "Simplify a subject string fuzzily.
1767 See `gnus-simplify-buffer-fuzzy' for details."
1769 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1770 (gnus-set-work-buffer)
1771 (let ((case-fold-search t))
1772 ;; Remove uninteresting prefixes.
1773 (when (and gnus-simplify-ignored-prefixes
1774 (string-match gnus-simplify-ignored-prefixes subject))
1775 (setq subject (substring subject (match-end 0))))
1777 (inline (gnus-simplify-buffer-fuzzy regexp))
1780 (defsubst gnus-simplify-subject-fully (subject)
1781 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1783 (gnus-simplify-subject-functions
1784 (gnus-map-function gnus-simplify-subject-functions subject))
1785 ((null gnus-summary-gather-subject-limit)
1786 (gnus-simplify-subject-re subject))
1787 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1788 (gnus-simplify-subject-fuzzy subject))
1789 ((numberp gnus-summary-gather-subject-limit)
1790 (truncate-string-to-width (gnus-simplify-subject-re subject)
1791 gnus-summary-gather-subject-limit))
1795 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1796 "Check whether two subjects are equal.
1797 If optional argument SIMPLE-FIRST is t, first argument is already
1800 ((null simple-first)
1801 (equal (gnus-simplify-subject-fully s1)
1802 (gnus-simplify-subject-fully s2)))
1805 (gnus-simplify-subject-fully s2)))))
1807 (defun gnus-summary-bubble-group ()
1808 "Increase the score of the current group.
1809 This is a handy function to add to `gnus-summary-exit-hook' to
1810 increase the score of each group you read."
1811 (gnus-group-add-score gnus-newsgroup-name))
1815 ;;; Gnus summary mode
1818 (put 'gnus-summary-mode 'mode-class 'special)
1820 (defvar gnus-article-commands-menu)
1822 ;; Non-orthogonal keys
1824 (gnus-define-keys gnus-summary-mode-map
1825 " " gnus-summary-next-page
1826 "\177" gnus-summary-prev-page
1827 [delete] gnus-summary-prev-page
1828 [backspace] gnus-summary-prev-page
1829 "\r" gnus-summary-scroll-up
1830 "\M-\r" gnus-summary-scroll-down
1831 "n" gnus-summary-next-unread-article
1832 "p" gnus-summary-prev-unread-article
1833 "N" gnus-summary-next-article
1834 "P" gnus-summary-prev-article
1835 "\M-\C-n" gnus-summary-next-same-subject
1836 "\M-\C-p" gnus-summary-prev-same-subject
1837 "\M-n" gnus-summary-next-unread-subject
1838 "\M-p" gnus-summary-prev-unread-subject
1839 "." gnus-summary-first-unread-article
1840 "," gnus-summary-best-unread-article
1841 "\M-s" gnus-summary-search-article-forward
1842 "\M-r" gnus-summary-search-article-backward
1843 "\M-S" gnus-summary-repeat-search-article-forward
1844 "\M-R" gnus-summary-repeat-search-article-backward
1845 "<" gnus-summary-beginning-of-article
1846 ">" gnus-summary-end-of-article
1847 "j" gnus-summary-goto-article
1848 "^" gnus-summary-refer-parent-article
1849 "\M-^" gnus-summary-refer-article
1850 "u" gnus-summary-tick-article-forward
1851 "!" gnus-summary-tick-article-forward
1852 "U" gnus-summary-tick-article-backward
1853 "d" gnus-summary-mark-as-read-forward
1854 "D" gnus-summary-mark-as-read-backward
1855 "E" gnus-summary-mark-as-expirable
1856 "\M-u" gnus-summary-clear-mark-forward
1857 "\M-U" gnus-summary-clear-mark-backward
1858 "k" gnus-summary-kill-same-subject-and-select
1859 "\C-k" gnus-summary-kill-same-subject
1860 "\M-\C-k" gnus-summary-kill-thread
1861 "\M-\C-l" gnus-summary-lower-thread
1862 "e" gnus-summary-edit-article
1863 "#" gnus-summary-mark-as-processable
1864 "\M-#" gnus-summary-unmark-as-processable
1865 "\M-\C-t" gnus-summary-toggle-threads
1866 "\M-\C-s" gnus-summary-show-thread
1867 "\M-\C-h" gnus-summary-hide-thread
1868 "\M-\C-f" gnus-summary-next-thread
1869 "\M-\C-b" gnus-summary-prev-thread
1870 [(meta down)] gnus-summary-next-thread
1871 [(meta up)] gnus-summary-prev-thread
1872 "\M-\C-u" gnus-summary-up-thread
1873 "\M-\C-d" gnus-summary-down-thread
1874 "&" gnus-summary-execute-command
1875 "c" gnus-summary-catchup-and-exit
1876 "\C-w" gnus-summary-mark-region-as-read
1877 "\C-t" gnus-summary-toggle-truncation
1878 "?" gnus-summary-mark-as-dormant
1879 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1880 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1881 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1882 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1883 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1884 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1885 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1886 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1887 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1888 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1889 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1890 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1891 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1892 "=" gnus-summary-expand-window
1893 "\C-x\C-s" gnus-summary-reselect-current-group
1894 "\M-g" gnus-summary-rescan-group
1895 "\C-c\C-r" gnus-summary-caesar-message
1896 "f" gnus-summary-followup
1897 "F" gnus-summary-followup-with-original
1898 "C" gnus-summary-cancel-article
1899 "r" gnus-summary-reply
1900 "R" gnus-summary-reply-with-original
1901 "\C-c\C-f" gnus-summary-mail-forward
1902 "o" gnus-summary-save-article
1903 "\C-o" gnus-summary-save-article-mail
1904 "|" gnus-summary-pipe-output
1905 "\M-k" gnus-summary-edit-local-kill
1906 "\M-K" gnus-summary-edit-global-kill
1908 "\C-c\C-d" gnus-summary-describe-group
1909 "q" gnus-summary-exit
1910 "Q" gnus-summary-exit-no-update
1911 "\C-c\C-i" gnus-info-find-node
1912 gnus-mouse-2 gnus-mouse-pick-article
1913 [follow-link] mouse-face
1914 "m" gnus-summary-mail-other-window
1915 "a" gnus-summary-post-news
1916 "x" gnus-summary-limit-to-unread
1917 "s" gnus-summary-isearch-article
1918 [tab] gnus-summary-widget-forward
1919 [backtab] gnus-summary-widget-backward
1920 "t" gnus-summary-toggle-header
1921 "g" gnus-summary-show-article
1922 "l" gnus-summary-goto-last-article
1923 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1924 "\C-d" gnus-summary-enter-digest-group
1925 "\M-\C-d" gnus-summary-read-document
1926 "\M-\C-e" gnus-summary-edit-parameters
1927 "\M-\C-a" gnus-summary-customize-parameters
1929 "*" gnus-cache-enter-article
1930 "\M-*" gnus-cache-remove-article
1931 "\M-&" gnus-summary-universal-argument
1932 "\C-l" gnus-recenter
1933 "I" gnus-summary-increase-score
1934 "L" gnus-summary-lower-score
1935 "\M-i" gnus-symbolic-argument
1936 "h" gnus-summary-select-article-buffer
1938 "b" gnus-article-view-part
1939 "\M-t" gnus-summary-toggle-display-buttonized
1941 "V" gnus-summary-score-map
1942 "X" gnus-uu-extract-map
1943 "S" gnus-summary-send-map)
1945 ;; Sort of orthogonal keymap
1946 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1947 "t" gnus-summary-tick-article-forward
1948 "!" gnus-summary-tick-article-forward
1949 "d" gnus-summary-mark-as-read-forward
1950 "r" gnus-summary-mark-as-read-forward
1951 "c" gnus-summary-clear-mark-forward
1952 " " gnus-summary-clear-mark-forward
1953 "e" gnus-summary-mark-as-expirable
1954 "x" gnus-summary-mark-as-expirable
1955 "?" gnus-summary-mark-as-dormant
1956 "b" gnus-summary-set-bookmark
1957 "B" gnus-summary-remove-bookmark
1958 "#" gnus-summary-mark-as-processable
1959 "\M-#" gnus-summary-unmark-as-processable
1960 "S" gnus-summary-limit-include-expunged
1961 "C" gnus-summary-catchup
1962 "H" gnus-summary-catchup-to-here
1963 "h" gnus-summary-catchup-from-here
1964 "\C-c" gnus-summary-catchup-all
1965 "k" gnus-summary-kill-same-subject-and-select
1966 "K" gnus-summary-kill-same-subject
1967 "P" gnus-uu-mark-map)
1969 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1970 "c" gnus-summary-clear-above
1971 "u" gnus-summary-tick-above
1972 "m" gnus-summary-mark-above
1973 "k" gnus-summary-kill-below)
1975 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1976 "/" gnus-summary-limit-to-subject
1977 "n" gnus-summary-limit-to-articles
1978 "b" gnus-summary-limit-to-bodies
1979 "h" gnus-summary-limit-to-headers
1980 "w" gnus-summary-pop-limit
1981 "s" gnus-summary-limit-to-subject
1982 "a" gnus-summary-limit-to-author
1983 "u" gnus-summary-limit-to-unread
1984 "m" gnus-summary-limit-to-marks
1985 "M" gnus-summary-limit-exclude-marks
1986 "v" gnus-summary-limit-to-score
1987 "*" gnus-summary-limit-include-cached
1988 "D" gnus-summary-limit-include-dormant
1989 "T" gnus-summary-limit-include-thread
1990 "d" gnus-summary-limit-exclude-dormant
1991 "t" gnus-summary-limit-to-age
1992 "." gnus-summary-limit-to-unseen
1993 "x" gnus-summary-limit-to-extra
1994 "p" gnus-summary-limit-to-display-predicate
1995 "E" gnus-summary-limit-include-expunged
1996 "c" gnus-summary-limit-exclude-childless-dormant
1997 "C" gnus-summary-limit-mark-excluded-as-read
1998 "o" gnus-summary-insert-old-articles
1999 "N" gnus-summary-insert-new-articles
2000 "S" gnus-summary-limit-to-singletons
2001 "r" gnus-summary-limit-to-replied
2002 "R" gnus-summary-limit-to-recipient
2003 "A" gnus-summary-limit-to-address)
2005 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2006 "n" gnus-summary-next-unread-article
2007 "p" gnus-summary-prev-unread-article
2008 "N" gnus-summary-next-article
2009 "P" gnus-summary-prev-article
2010 "\C-n" gnus-summary-next-same-subject
2011 "\C-p" gnus-summary-prev-same-subject
2012 "\M-n" gnus-summary-next-unread-subject
2013 "\M-p" gnus-summary-prev-unread-subject
2014 "f" gnus-summary-first-unread-article
2015 "b" gnus-summary-best-unread-article
2016 "j" gnus-summary-goto-article
2017 "g" gnus-summary-goto-subject
2018 "l" gnus-summary-goto-last-article
2019 "o" gnus-summary-pop-article)
2021 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2022 "k" gnus-summary-kill-thread
2023 "E" gnus-summary-expire-thread
2024 "l" gnus-summary-lower-thread
2025 "i" gnus-summary-raise-thread
2026 "T" gnus-summary-toggle-threads
2027 "t" gnus-summary-rethread-current
2028 "^" gnus-summary-reparent-thread
2029 "\M-^" gnus-summary-reparent-children
2030 "s" gnus-summary-show-thread
2031 "S" gnus-summary-show-all-threads
2032 "h" gnus-summary-hide-thread
2033 "H" gnus-summary-hide-all-threads
2034 "n" gnus-summary-next-thread
2035 "p" gnus-summary-prev-thread
2036 "u" gnus-summary-up-thread
2037 "o" gnus-summary-top-thread
2038 "d" gnus-summary-down-thread
2039 "#" gnus-uu-mark-thread
2040 "\M-#" gnus-uu-unmark-thread)
2042 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2043 "g" gnus-summary-prepare
2044 "c" gnus-summary-insert-cached-articles
2045 "d" gnus-summary-insert-dormant-articles
2046 "t" gnus-summary-insert-ticked-articles)
2048 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2049 "c" gnus-summary-catchup-and-exit
2050 "C" gnus-summary-catchup-all-and-exit
2051 "E" gnus-summary-exit-no-update
2052 "Q" gnus-summary-exit
2053 "Z" gnus-summary-exit
2054 "n" gnus-summary-catchup-and-goto-next-group
2055 "p" gnus-summary-catchup-and-goto-prev-group
2056 "R" gnus-summary-reselect-current-group
2057 "G" gnus-summary-rescan-group
2058 "N" gnus-summary-next-group
2059 "s" gnus-summary-save-newsrc
2060 "P" gnus-summary-prev-group)
2062 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2063 " " gnus-summary-next-page
2064 "n" gnus-summary-next-page
2065 "\177" gnus-summary-prev-page
2066 [delete] gnus-summary-prev-page
2067 "p" gnus-summary-prev-page
2068 "\r" gnus-summary-scroll-up
2069 "\M-\r" gnus-summary-scroll-down
2070 "<" gnus-summary-beginning-of-article
2071 ">" gnus-summary-end-of-article
2072 "b" gnus-summary-beginning-of-article
2073 "e" gnus-summary-end-of-article
2074 "^" gnus-summary-refer-parent-article
2075 "r" gnus-summary-refer-parent-article
2076 "C" gnus-summary-show-complete-article
2077 "D" gnus-summary-enter-digest-group
2078 "R" gnus-summary-refer-references
2079 "T" gnus-summary-refer-thread
2080 "W" gnus-warp-to-article
2081 "g" gnus-summary-show-article
2082 "s" gnus-summary-isearch-article
2083 [tab] gnus-summary-widget-forward
2084 [backtab] gnus-summary-widget-backward
2085 "P" gnus-summary-print-article
2086 "S" gnus-sticky-article
2087 "M" gnus-mailing-list-insinuate
2088 "t" gnus-article-babel)
2090 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2091 "b" gnus-article-add-buttons
2092 "B" gnus-article-add-buttons-to-head
2093 "o" gnus-article-treat-overstrike
2094 "e" gnus-article-emphasize
2095 "w" gnus-article-fill-cited-article
2096 "Q" gnus-article-fill-long-lines
2097 "L" gnus-article-toggle-truncate-lines
2098 "C" gnus-article-capitalize-sentences
2099 "c" gnus-article-remove-cr
2100 "q" gnus-article-de-quoted-unreadable
2101 "6" gnus-article-de-base64-unreadable
2102 "Z" gnus-article-decode-HZ
2103 "A" gnus-article-treat-ansi-sequences
2104 "h" gnus-article-wash-html
2105 "u" gnus-article-unsplit-urls
2106 "s" gnus-summary-force-verify-and-decrypt
2107 "f" gnus-article-display-x-face
2108 "l" gnus-summary-stop-page-breaking
2109 "r" gnus-summary-caesar-message
2110 "m" gnus-summary-morse-message
2111 "t" gnus-summary-toggle-header
2112 "g" gnus-treat-smiley
2113 "v" gnus-summary-verbose-headers
2114 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2115 "p" gnus-article-verify-x-pgp-sig
2116 "d" gnus-article-treat-dumbquotes
2117 "U" gnus-article-treat-non-ascii
2118 "i" gnus-summary-idna-message)
2120 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2121 ;; mnemonic: deuglif*Y*
2122 "u" gnus-article-outlook-unwrap-lines
2123 "a" gnus-article-outlook-repair-attribution
2124 "c" gnus-article-outlook-rearrange-citation
2125 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2127 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2128 "a" gnus-article-hide
2129 "h" gnus-article-hide-headers
2130 "b" gnus-article-hide-boring-headers
2131 "s" gnus-article-hide-signature
2132 "c" gnus-article-hide-citation
2133 "C" gnus-article-hide-citation-in-followups
2134 "l" gnus-article-hide-list-identifiers
2135 "B" gnus-article-strip-banner
2136 "P" gnus-article-hide-pem
2137 "\C-c" gnus-article-hide-citation-maybe)
2139 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2140 "a" gnus-article-highlight
2141 "h" gnus-article-highlight-headers
2142 "c" gnus-article-highlight-citation
2143 "s" gnus-article-highlight-signature)
2145 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2146 "f" gnus-article-treat-fold-headers
2147 "u" gnus-article-treat-unfold-headers
2148 "n" gnus-article-treat-fold-newsgroups)
2150 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2151 "x" gnus-article-display-x-face
2152 "d" gnus-article-display-face
2153 "s" gnus-treat-smiley
2154 "D" gnus-article-remove-images
2155 "W" gnus-article-show-images
2156 "f" gnus-treat-from-picon
2157 "m" gnus-treat-mail-picon
2158 "n" gnus-treat-newsgroups-picon
2159 "g" gnus-treat-from-gravatar
2160 "h" gnus-treat-mail-gravatar)
2162 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2163 "w" gnus-article-decode-mime-words
2164 "c" gnus-article-decode-charset
2165 "v" gnus-mime-view-all-parts
2166 "b" gnus-article-view-part)
2168 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2169 "z" gnus-article-date-ut
2170 "u" gnus-article-date-ut
2171 "l" gnus-article-date-local
2172 "p" gnus-article-date-english
2173 "e" gnus-article-date-lapsed
2174 "o" gnus-article-date-original
2175 "i" gnus-article-date-iso8601
2176 "s" gnus-article-date-user)
2178 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2179 "t" gnus-article-remove-trailing-blank-lines
2180 "l" gnus-article-strip-leading-blank-lines
2181 "m" gnus-article-strip-multiple-blank-lines
2182 "a" gnus-article-strip-blank-lines
2183 "A" gnus-article-strip-all-blank-lines
2184 "s" gnus-article-strip-leading-space
2185 "e" gnus-article-strip-trailing-space
2186 "w" gnus-article-remove-leading-whitespace)
2188 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2190 "d" gnus-summary-describe-group
2191 "h" gnus-summary-describe-briefly
2192 "i" gnus-info-find-node)
2194 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2195 "e" gnus-summary-expire-articles
2196 "\M-\C-e" gnus-summary-expire-articles-now
2197 "\177" gnus-summary-delete-article
2198 [delete] gnus-summary-delete-article
2199 [backspace] gnus-summary-delete-article
2200 "m" gnus-summary-move-article
2201 "r" gnus-summary-respool-article
2202 "w" gnus-summary-edit-article
2203 "c" gnus-summary-copy-article
2204 "B" gnus-summary-crosspost-article
2205 "q" gnus-summary-respool-query
2206 "t" gnus-summary-respool-trace
2207 "i" gnus-summary-import-article
2208 "I" gnus-summary-create-article
2209 "p" gnus-summary-article-posted-p)
2211 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2212 "o" gnus-summary-save-article
2213 "m" gnus-summary-save-article-mail
2214 "F" gnus-summary-write-article-file
2215 "r" gnus-summary-save-article-rmail
2216 "f" gnus-summary-save-article-file
2217 "b" gnus-summary-save-article-body-file
2218 "B" gnus-summary-write-article-body-file
2219 "h" gnus-summary-save-article-folder
2220 "v" gnus-summary-save-article-vm
2221 "p" gnus-summary-pipe-output
2222 "P" gnus-summary-muttprint)
2224 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2225 "b" gnus-summary-display-buttonized
2226 "m" gnus-summary-repair-multipart
2227 "v" gnus-article-view-part
2228 "o" gnus-article-save-part
2229 "O" gnus-article-save-part-and-strip
2230 "r" gnus-article-replace-part
2231 "d" gnus-article-delete-part
2232 "t" gnus-article-view-part-as-type
2233 "j" gnus-article-jump-to-part
2234 "c" gnus-article-copy-part
2235 "C" gnus-article-view-part-as-charset
2236 "e" gnus-article-view-part-externally
2237 "H" gnus-article-browse-html-article
2238 "E" gnus-article-encrypt-body
2239 "i" gnus-article-inline-part
2240 "|" gnus-article-pipe-part)
2242 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2243 "p" gnus-summary-mark-as-processable
2244 "u" gnus-summary-unmark-as-processable
2245 "U" gnus-summary-unmark-all-processable
2246 "v" gnus-uu-mark-over
2247 "s" gnus-uu-mark-series
2248 "r" gnus-uu-mark-region
2249 "g" gnus-uu-unmark-region
2250 "R" gnus-uu-mark-by-regexp
2251 "G" gnus-uu-unmark-by-regexp
2252 "t" gnus-uu-mark-thread
2253 "T" gnus-uu-unmark-thread
2254 "a" gnus-uu-mark-all
2255 "b" gnus-uu-mark-buffer
2256 "S" gnus-uu-mark-sparse
2257 "k" gnus-summary-kill-process-mark
2258 "y" gnus-summary-yank-process-mark
2259 "w" gnus-summary-save-process-mark
2260 "i" gnus-uu-invert-processable)
2262 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2263 ;;"x" gnus-uu-extract-any
2264 "m" gnus-summary-save-parts
2265 "u" gnus-uu-decode-uu
2266 "U" gnus-uu-decode-uu-and-save
2267 "s" gnus-uu-decode-unshar
2268 "S" gnus-uu-decode-unshar-and-save
2269 "o" gnus-uu-decode-save
2270 "O" gnus-uu-decode-save
2271 "b" gnus-uu-decode-binhex
2272 "B" gnus-uu-decode-binhex
2273 "Y" gnus-uu-decode-yenc
2274 "p" gnus-uu-decode-postscript
2275 "P" gnus-uu-decode-postscript-and-save)
2278 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2279 "u" gnus-uu-decode-uu-view
2280 "U" gnus-uu-decode-uu-and-save-view
2281 "s" gnus-uu-decode-unshar-view
2282 "S" gnus-uu-decode-unshar-and-save-view
2283 "o" gnus-uu-decode-save-view
2284 "O" gnus-uu-decode-save-view
2285 "b" gnus-uu-decode-binhex-view
2286 "B" gnus-uu-decode-binhex-view
2287 "p" gnus-uu-decode-postscript-view
2288 "P" gnus-uu-decode-postscript-and-save-view)
2290 (defvar gnus-article-post-menu nil)
2292 (defconst gnus-summary-menu-maxlen 20)
2294 (defun gnus-summary-menu-split (menu)
2295 ;; If we have lots of elements, divide them into groups of 20
2296 ;; and make a pane (or submenu) for each one.
2297 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2298 (let ((menu menu) sublists next
2301 ;; Pull off the next gnus-summary-menu-maxlen elements
2302 ;; and make them the next element of sublist.
2303 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2305 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2307 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2308 (aref (car (last menu)) 0)) menu)
2312 (nreverse sublists))
2313 ;; Few elements--put them all in one pane.
2316 (defun gnus-summary-make-menu-bar ()
2317 (gnus-turn-off-edit-menu 'summary)
2319 (unless (boundp 'gnus-summary-misc-menu)
2322 gnus-summary-kill-menu gnus-summary-mode-map ""
2327 ["Customize" gnus-score-customize t])
2328 (gnus-make-score-map 'increase)
2329 (gnus-make-score-map 'lower)
2331 ["Kill below" gnus-summary-kill-below t]
2332 ["Mark above" gnus-summary-mark-above t]
2333 ["Tick above" gnus-summary-tick-above t]
2334 ["Clear above" gnus-summary-clear-above t])
2335 ["Current score" gnus-summary-current-score t]
2336 ["Set score" gnus-summary-set-score t]
2337 ["Switch current score file..." gnus-score-change-score-file t]
2338 ["Set mark below..." gnus-score-set-mark-below t]
2339 ["Set expunge below..." gnus-score-set-expunge-below t]
2340 ["Edit current score file" gnus-score-edit-current-scores t]
2341 ["Edit score file..." gnus-score-edit-file t]
2342 ["Trace score" gnus-score-find-trace t]
2343 ["Find words" gnus-score-find-favourite-words t]
2344 ["Rescore buffer" gnus-summary-rescore t]
2345 ["Increase score..." gnus-summary-increase-score t]
2346 ["Lower score..." gnus-summary-lower-score t]))))
2348 ;; Define both the Article menu in the summary buffer and the
2349 ;; equivalent Commands menu in the article buffer here for
2353 ["All" gnus-article-hide t]
2354 ["Headers" gnus-article-hide-headers t]
2355 ["Signature" gnus-article-hide-signature t]
2356 ["Citation" gnus-article-hide-citation t]
2357 ["List identifiers" gnus-article-hide-list-identifiers t]
2358 ["Banner" gnus-article-strip-banner t]
2359 ["Boring headers" gnus-article-hide-boring-headers t])
2361 ["All" gnus-article-highlight t]
2362 ["Headers" gnus-article-highlight-headers t]
2363 ["Signature" gnus-article-highlight-signature t]
2364 ["Citation" gnus-article-highlight-citation t])
2366 ["Words" gnus-article-decode-mime-words t]
2367 ["Charset" gnus-article-decode-charset t]
2368 ["QP" gnus-article-de-quoted-unreadable t]
2369 ["Base64" gnus-article-de-base64-unreadable t]
2370 ["View MIME buttons" gnus-summary-display-buttonized t]
2371 ["View all" gnus-mime-view-all-parts t]
2372 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2373 ["Encrypt body" gnus-article-encrypt-body
2374 :active (not (gnus-group-read-only-p))
2375 ,@(if (featurep 'xemacs) nil
2376 '(:help "Encrypt the message body on disk"))]
2377 ["Extract all parts..." gnus-summary-save-parts t]
2379 ["Repair multipart" gnus-summary-repair-multipart t]
2380 ["Pipe part..." gnus-article-pipe-part t]
2381 ["Inline part" gnus-article-inline-part t]
2382 ["View part as type..." gnus-article-view-part-as-type t]
2383 ["Encrypt body" gnus-article-encrypt-body
2384 :active (not (gnus-group-read-only-p))
2385 ,@(if (featurep 'xemacs) nil
2386 '(:help "Encrypt the message body on disk"))]
2387 ["View part externally" gnus-article-view-part-externally t]
2388 ["View HTML parts in browser" gnus-article-browse-html-article t]
2389 ["View part with charset..." gnus-article-view-part-as-charset t]
2390 ["Copy part" gnus-article-copy-part t]
2391 ["Save part..." gnus-article-save-part t]
2392 ["View part" gnus-article-view-part t]))
2394 ["Local" gnus-article-date-local t]
2395 ["ISO8601" gnus-article-date-iso8601 t]
2396 ["UT" gnus-article-date-ut t]
2397 ["Original" gnus-article-date-original t]
2398 ["Lapsed" gnus-article-date-lapsed t]
2399 ["User-defined" gnus-article-date-user t])
2401 ["Remove images" gnus-article-remove-images t]
2402 ["Toggle smiley" gnus-treat-smiley t]
2403 ["Show X-Face" gnus-article-display-x-face t]
2404 ["Show picons in From" gnus-treat-from-picon t]
2405 ["Show picons in mail headers" gnus-treat-mail-picon t]
2406 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2407 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2408 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2409 ("View as different encoding"
2410 ,@(gnus-summary-menu-split
2413 ;; Since easymenu under Emacs doesn't allow
2414 ;; lambda forms for menu commands, we should
2415 ;; provide intern'ed function symbols.
2416 (let ((command (intern (format "\
2417 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2421 (let ((gnus-summary-show-article-charset-alist
2423 (gnus-summary-show-article 1))))
2424 `[,(symbol-name cs) ,command t]))
2425 (sort (if (fboundp 'coding-system-list)
2426 (coding-system-list)
2427 (mapcar 'car mm-mime-mule-charset-alist))
2431 ["Leading" gnus-article-strip-leading-blank-lines t]
2432 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2433 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2434 ["All of the above" gnus-article-strip-blank-lines t]
2435 ["All" gnus-article-strip-all-blank-lines t]
2436 ["Leading space" gnus-article-strip-leading-space t]
2437 ["Trailing space" gnus-article-strip-trailing-space t]
2438 ["Leading space in headers"
2439 gnus-article-remove-leading-whitespace t])
2440 ["Overstrike" gnus-article-treat-overstrike t]
2441 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2442 ["Non-ASCII" gnus-article-treat-non-ascii t]
2443 ["Emphasis" gnus-article-emphasize t]
2444 ["Word wrap" gnus-article-fill-cited-article t]
2445 ["Fill long lines" gnus-article-fill-long-lines t]
2446 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2447 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2448 ["Remove CR" gnus-article-remove-cr t]
2449 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2450 ["Base64" gnus-article-de-base64-unreadable t]
2451 ["Rot 13" gnus-summary-caesar-message
2452 ,@(if (featurep 'xemacs) '(t)
2453 '(:help "\"Caesar rotate\" article by 13"))]
2454 ["De-IDNA" gnus-summary-idna-message t]
2455 ["Morse decode" gnus-summary-morse-message t]
2456 ["Unix pipe..." gnus-summary-pipe-message t]
2457 ["Add buttons" gnus-article-add-buttons t]
2458 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2459 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2460 ["Verbose header" gnus-summary-verbose-headers t]
2461 ["Toggle header" gnus-summary-toggle-header t]
2462 ["Unfold headers" gnus-article-treat-unfold-headers t]
2463 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2464 ["Html" gnus-article-wash-html t]
2465 ["Unsplit URLs" gnus-article-unsplit-urls t]
2466 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2467 ["Decode HZ" gnus-article-decode-HZ t]
2468 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2469 ("(Outlook) Deuglify"
2470 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2471 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2472 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2473 ["Full (Outlook) deuglify"
2474 gnus-article-outlook-deuglify-article t])
2477 ["Save in default format..." gnus-summary-save-article
2478 ,@(if (featurep 'xemacs) '(t)
2479 '(:help "Save article using default method"))]
2480 ["Save in file..." gnus-summary-save-article-file
2481 ,@(if (featurep 'xemacs) '(t)
2482 '(:help "Save article in file"))]
2483 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2484 ["Save in MH folder..." gnus-summary-save-article-folder t]
2485 ["Save in VM folder..." gnus-summary-save-article-vm t]
2486 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2487 ["Save body in file..." gnus-summary-save-article-body-file t]
2488 ["Pipe through a filter..." gnus-summary-pipe-output t]
2489 ["Print with Muttprint..." gnus-summary-muttprint t]
2490 ["Print" gnus-summary-print-article
2491 ,@(if (featurep 'xemacs) '(t)
2492 '(:help "Generate and print a PostScript image"))])
2493 ("Copy, move,... (Backend)"
2494 ,@(if (featurep 'xemacs) nil
2495 '(:help "Copying, moving, expiring articles..."))
2496 ["Respool article..." gnus-summary-respool-article t]
2497 ["Move article..." gnus-summary-move-article
2498 (gnus-check-backend-function
2499 'request-move-article gnus-newsgroup-name)]
2500 ["Copy article..." gnus-summary-copy-article t]
2501 ["Crosspost article..." gnus-summary-crosspost-article
2502 (gnus-check-backend-function
2503 'request-replace-article gnus-newsgroup-name)]
2504 ["Import file..." gnus-summary-import-article
2505 (gnus-check-backend-function
2506 'request-accept-article gnus-newsgroup-name)]
2507 ["Create article..." gnus-summary-create-article
2508 (gnus-check-backend-function
2509 'request-accept-article gnus-newsgroup-name)]
2510 ["Check if posted" gnus-summary-article-posted-p t]
2511 ["Edit article" gnus-summary-edit-article
2512 (not (gnus-group-read-only-p))]
2513 ["Delete article" gnus-summary-delete-article
2514 (gnus-check-backend-function
2515 'request-expire-articles gnus-newsgroup-name)]
2516 ["Query respool" gnus-summary-respool-query t]
2517 ["Trace respool" gnus-summary-respool-trace t]
2518 ["Delete expirable articles" gnus-summary-expire-articles-now
2519 (gnus-check-backend-function
2520 'request-expire-articles gnus-newsgroup-name)])
2522 ["Uudecode" gnus-uu-decode-uu
2523 ,@(if (featurep 'xemacs) '(t)
2524 '(:help "Decode uuencoded article(s)"))]
2525 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2526 ["Unshar" gnus-uu-decode-unshar t]
2527 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2528 ["Save" gnus-uu-decode-save t]
2529 ["Binhex" gnus-uu-decode-binhex t]
2530 ["PostScript" gnus-uu-decode-postscript t]
2531 ["All MIME parts" gnus-summary-save-parts t])
2533 ["Enter article" gnus-cache-enter-article t]
2534 ["Remove article" gnus-cache-remove-article t])
2535 ["Translate" gnus-article-babel t]
2536 ["Select article buffer" gnus-summary-select-article-buffer t]
2537 ["Make article buffer sticky" gnus-sticky-article t]
2538 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2539 ["Isearch article..." gnus-summary-isearch-article t]
2540 ["Beginning of the article" gnus-summary-beginning-of-article t]
2541 ["End of the article" gnus-summary-end-of-article t]
2542 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2543 ["Fetch referenced articles" gnus-summary-refer-references t]
2544 ["Fetch current thread" gnus-summary-refer-thread t]
2545 ["Fetch article with id..." gnus-summary-refer-article t]
2546 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2547 ["Redisplay" gnus-summary-show-article t]
2548 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2550 gnus-summary-article-menu gnus-summary-mode-map ""
2551 (cons "Article" innards))
2553 (if (not (keymapp gnus-summary-article-menu))
2555 gnus-article-commands-menu gnus-article-mode-map ""
2556 (cons "Commands" innards))
2557 ;; in Emacs, don't share menu.
2558 (setq gnus-article-commands-menu
2559 (copy-keymap gnus-summary-article-menu))
2560 (define-key gnus-article-mode-map [menu-bar commands]
2561 (cons "Commands" gnus-article-commands-menu))))
2564 gnus-summary-thread-menu gnus-summary-mode-map ""
2566 ["Find all messages in thread" gnus-summary-refer-thread t]
2567 ["Toggle threading" gnus-summary-toggle-threads t]
2568 ["Hide threads" gnus-summary-hide-all-threads t]
2569 ["Show threads" gnus-summary-show-all-threads t]
2570 ["Hide thread" gnus-summary-hide-thread t]
2571 ["Show thread" gnus-summary-show-thread t]
2572 ["Go to next thread" gnus-summary-next-thread t]
2573 ["Go to previous thread" gnus-summary-prev-thread t]
2574 ["Go down thread" gnus-summary-down-thread t]
2575 ["Go up thread" gnus-summary-up-thread t]
2576 ["Top of thread" gnus-summary-top-thread t]
2577 ["Mark thread as read" gnus-summary-kill-thread t]
2578 ["Mark thread as expired" gnus-summary-expire-thread t]
2579 ["Lower thread score" gnus-summary-lower-thread t]
2580 ["Raise thread score" gnus-summary-raise-thread t]
2581 ["Rethread current" gnus-summary-rethread-current t]))
2584 gnus-summary-post-menu gnus-summary-mode-map ""
2586 ["Send a message (mail or news)" gnus-summary-post-news
2587 ,@(if (featurep 'xemacs) '(t)
2588 '(:help "Compose a new message (mail or news)"))]
2589 ["Followup" gnus-summary-followup
2590 ,@(if (featurep 'xemacs) '(t)
2591 '(:help "Post followup to this article"))]
2592 ["Followup and yank" gnus-summary-followup-with-original
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Post followup to this article, quoting its contents"))]
2595 ["Supersede article" gnus-summary-supersede-article t]
2596 ["Cancel article" gnus-summary-cancel-article
2597 ,@(if (featurep 'xemacs) '(t)
2598 '(:help "Cancel an article you posted"))]
2599 ["Reply" gnus-summary-reply t]
2600 ["Reply and yank" gnus-summary-reply-with-original t]
2601 ["Wide reply" gnus-summary-wide-reply t]
2602 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a reply, quoting this article"))]
2605 ["Very wide reply" gnus-summary-very-wide-reply t]
2606 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2607 ,@(if (featurep 'xemacs) '(t)
2608 '(:help "Mail a very wide reply, quoting this article"))]
2609 ["Mail forward" gnus-summary-mail-forward t]
2610 ["Post forward" gnus-summary-post-forward t]
2611 ["Digest and mail" gnus-uu-digest-mail-forward t]
2612 ["Digest and post" gnus-uu-digest-post-forward t]
2613 ["Resend message" gnus-summary-resend-message t]
2614 ["Resend message edit" gnus-summary-resend-message-edit t]
2615 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2616 ["Send a mail" gnus-summary-mail-other-window t]
2617 ["Create a local message" gnus-summary-news-other-window t]
2618 ["Uuencode and post" gnus-uu-post-news
2619 ,@(if (featurep 'xemacs) '(t)
2620 '(:help "Post a uuencoded article"))]
2621 ["Followup via news" gnus-summary-followup-to-mail t]
2622 ["Followup via news and yank"
2623 gnus-summary-followup-to-mail-with-original t]
2624 ["Strip signature on reply"
2627 (if (not (memq message-cite-function
2628 '(message-cite-original-without-signature
2629 message-cite-original)))
2630 ;; Stupid workaround for XEmacs not honoring :visible.
2631 (message "Can't toggle this value of `message-cite-function'")
2632 (setq message-cite-function
2633 (if (eq message-cite-function
2634 'message-cite-original-without-signature)
2635 'message-cite-original
2636 'message-cite-original-without-signature))))
2637 ;; XEmacs barfs on :visible.
2638 ,@(if (featurep 'xemacs) nil
2639 '(:visible (memq message-cite-function
2640 '(message-cite-original-without-signature
2641 message-cite-original))))
2643 :selected (eq message-cite-function
2644 'message-cite-original-without-signature)
2645 ,@(if (featurep 'xemacs) nil
2646 '(:help "Strip signature from cited article when replying."))]
2648 ;;["Send" gnus-summary-send-draft t]
2649 ;;["Send bounced" gnus-resend-bounced-mail t])
2653 ((not (keymapp gnus-summary-post-menu))
2654 (setq gnus-article-post-menu gnus-summary-post-menu))
2655 ((not gnus-article-post-menu)
2656 ;; Don't share post menu.
2657 (setq gnus-article-post-menu
2658 (copy-keymap gnus-summary-post-menu))))
2659 (define-key gnus-article-mode-map [menu-bar post]
2660 (cons "Post" gnus-article-post-menu))
2663 gnus-summary-misc-menu gnus-summary-mode-map ""
2666 ["Mark as read" gnus-summary-mark-as-read-forward t]
2667 ["Mark same subject and select"
2668 gnus-summary-kill-same-subject-and-select t]
2669 ["Mark same subject" gnus-summary-kill-same-subject t]
2670 ["Catchup" gnus-summary-catchup
2671 ,@(if (featurep 'xemacs) '(t)
2672 '(:help "Mark unread articles in this group as read"))]
2673 ["Catchup all" gnus-summary-catchup-all t]
2674 ["Catchup to here" gnus-summary-catchup-to-here t]
2675 ["Catchup from here" gnus-summary-catchup-from-here t]
2676 ["Catchup region" gnus-summary-mark-region-as-read
2677 (gnus-mark-active-p)]
2678 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2680 ["Tick" gnus-summary-tick-article-forward t]
2681 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2682 ["Remove marks" gnus-summary-clear-mark-forward t]
2683 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2684 ["Set bookmark" gnus-summary-set-bookmark t]
2685 ["Remove bookmark" gnus-summary-remove-bookmark t])
2687 ["Marks..." gnus-summary-limit-to-marks t]
2688 ["Subject..." gnus-summary-limit-to-subject t]
2689 ["Author..." gnus-summary-limit-to-author t]
2690 ["Recipient..." gnus-summary-limit-to-recipient t]
2691 ["Address..." gnus-summary-limit-to-address t]
2692 ["Age..." gnus-summary-limit-to-age t]
2693 ["Extra..." gnus-summary-limit-to-extra t]
2694 ["Score..." gnus-summary-limit-to-score t]
2695 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2696 ["Unread" gnus-summary-limit-to-unread t]
2697 ["Unseen" gnus-summary-limit-to-unseen t]
2698 ["Singletons" gnus-summary-limit-to-singletons t]
2699 ["Replied" gnus-summary-limit-to-replied t]
2700 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2701 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2702 ["Pop limit" gnus-summary-pop-limit t]
2703 ["Show dormant" gnus-summary-limit-include-dormant t]
2704 ["Hide childless dormant"
2705 gnus-summary-limit-exclude-childless-dormant t]
2706 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2707 ["Hide marked" gnus-summary-limit-exclude-marks t]
2708 ["Show expunged" gnus-summary-limit-include-expunged t])
2710 ["Set mark" gnus-summary-mark-as-processable t]
2711 ["Remove mark" gnus-summary-unmark-as-processable t]
2712 ["Remove all marks" gnus-summary-unmark-all-processable t]
2713 ["Invert marks" gnus-uu-invert-processable t]
2714 ["Mark above" gnus-uu-mark-over t]
2715 ["Mark series" gnus-uu-mark-series t]
2716 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2717 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2718 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2719 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2720 ["Mark all" gnus-uu-mark-all t]
2721 ["Mark buffer" gnus-uu-mark-buffer t]
2722 ["Mark sparse" gnus-uu-mark-sparse t]
2723 ["Mark thread" gnus-uu-mark-thread t]
2724 ["Unmark thread" gnus-uu-unmark-thread t]
2725 ("Process Mark Sets"
2726 ["Kill" gnus-summary-kill-process-mark t]
2727 ["Yank" gnus-summary-yank-process-mark
2728 gnus-newsgroup-process-stack]
2729 ["Save" gnus-summary-save-process-mark t]
2730 ["Run command on marked..." gnus-summary-universal-argument t]))
2733 ["Page forward" gnus-summary-next-page
2734 ,@(if (featurep 'xemacs) '(t)
2735 '(:help "Show next page of article"))]
2736 ["Page backward" gnus-summary-prev-page
2737 ,@(if (featurep 'xemacs) '(t)
2738 '(:help "Show previous page of article"))]
2739 ["Line forward" gnus-summary-scroll-up t])
2741 ["Next unread article" gnus-summary-next-unread-article t]
2742 ["Previous unread article" gnus-summary-prev-unread-article t]
2743 ["Next article" gnus-summary-next-article t]
2744 ["Previous article" gnus-summary-prev-article t]
2745 ["Next unread subject" gnus-summary-next-unread-subject t]
2746 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2747 ["Next article same subject" gnus-summary-next-same-subject t]
2748 ["Previous article same subject" gnus-summary-prev-same-subject t]
2749 ["First unread article" gnus-summary-first-unread-article t]
2750 ["Best unread article" gnus-summary-best-unread-article t]
2751 ["Go to subject number..." gnus-summary-goto-subject t]
2752 ["Go to article number..." gnus-summary-goto-article t]
2753 ["Go to the last article" gnus-summary-goto-last-article t]
2754 ["Pop article off history" gnus-summary-pop-article t])
2756 ["Sort by number" gnus-summary-sort-by-number t]
2757 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2758 ["Sort by author" gnus-summary-sort-by-author t]
2759 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2760 ["Sort by subject" gnus-summary-sort-by-subject t]
2761 ["Sort by date" gnus-summary-sort-by-date t]
2762 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2763 ["Sort by score" gnus-summary-sort-by-score t]
2764 ["Sort by lines" gnus-summary-sort-by-lines t]
2765 ["Sort by characters" gnus-summary-sort-by-chars t]
2766 ["Randomize" gnus-summary-sort-by-random t]
2767 ["Original sort" gnus-summary-sort-by-original t])
2769 ["Describe group" gnus-summary-describe-group t]
2770 ["Read manual" gnus-info-find-node t])
2772 ["Pick and read" gnus-pick-mode t]
2773 ["Binary" gnus-binary-mode t])
2775 ["Regenerate" gnus-summary-prepare t]
2776 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2777 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2778 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2779 ["Toggle threading" gnus-summary-toggle-threads t])
2780 ["See old articles" gnus-summary-insert-old-articles t]
2781 ["See new articles" gnus-summary-insert-new-articles t]
2782 ["Filter articles..." gnus-summary-execute-command t]
2783 ["Run command on articles..." gnus-summary-universal-argument t]
2784 ["Search articles forward..." gnus-summary-search-article-forward t]
2785 ["Search articles backward..." gnus-summary-search-article-backward t]
2786 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2787 ["Expand window" gnus-summary-expand-window t]
2788 ["Expire expirable articles" gnus-summary-expire-articles
2789 (gnus-check-backend-function
2790 'request-expire-articles gnus-newsgroup-name)]
2791 ["Edit local kill file" gnus-summary-edit-local-kill t]
2792 ["Edit main kill file" gnus-summary-edit-global-kill t]
2793 ["Edit group parameters" gnus-summary-edit-parameters t]
2794 ["Customize group parameters" gnus-summary-customize-parameters t]
2795 ["Send a bug report" gnus-bug t]
2797 ["Catchup and exit" gnus-summary-catchup-and-exit
2798 ,@(if (featurep 'xemacs) '(t)
2799 '(:help "Mark unread articles in this group as read, then exit"))]
2800 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2801 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2802 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2803 ["Exit group" gnus-summary-exit
2804 ,@(if (featurep 'xemacs) '(t)
2805 '(:help "Exit current group, return to group selection mode"))]
2806 ["Exit group without updating" gnus-summary-exit-no-update t]
2807 ["Exit and goto next group" gnus-summary-next-group t]
2808 ["Exit and goto prev group" gnus-summary-prev-group t]
2809 ["Reselect group" gnus-summary-reselect-current-group t]
2810 ["Rescan group" gnus-summary-rescan-group t]
2811 ["Update dribble" gnus-summary-save-newsrc t])))
2813 (gnus-run-hooks 'gnus-summary-menu-hook)))
2815 (defvar gnus-summary-tool-bar-map nil)
2817 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2818 ;; affect _new_ message buffers. We might add a function that walks thru all
2819 ;; summary-mode buffers and force the update.
2820 (defun gnus-summary-tool-bar-update (&optional symbol value)
2821 "Update summary mode toolbar.
2822 Setter function for custom variables."
2823 (setq-default gnus-summary-tool-bar-map nil)
2825 ;; When used as ":set" function:
2826 (set-default symbol value))
2827 (when (gnus-buffer-live-p gnus-summary-buffer)
2828 (with-current-buffer gnus-summary-buffer
2829 (gnus-summary-make-tool-bar))))
2831 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2832 'gnus-summary-tool-bar-gnome
2833 'gnus-summary-tool-bar-retro)
2834 "Specifies the Gnus summary tool bar.
2836 It can be either a list or a symbol referring to a list. See
2837 `gmm-tool-bar-from-list' for the format of the list. The
2838 default key map is `gnus-summary-mode-map'.
2840 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2841 `gnus-summary-tool-bar-retro'."
2842 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2843 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2844 (repeat :tag "User defined list" gmm-tool-bar-item)
2846 :version "23.1" ;; No Gnus
2847 :initialize 'custom-initialize-default
2848 :set 'gnus-summary-tool-bar-update
2849 :group 'gnus-summary)
2851 (defcustom gnus-summary-tool-bar-gnome
2852 '((gnus-summary-post-news "mail/compose" nil)
2853 (gnus-summary-insert-new-articles "mail/inbox" nil
2854 :visible (or (not gnus-agent)
2856 (gnus-summary-reply-with-original "mail/reply")
2857 (gnus-summary-reply "mail/reply" nil :visible nil)
2858 (gnus-summary-followup-with-original "mail/reply-all")
2859 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2860 (gnus-summary-mail-forward "mail/forward")
2861 (gnus-summary-save-article "mail/save")
2862 (gnus-summary-search-article-forward "search" nil :visible nil)
2863 (gnus-summary-print-article "print")
2864 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2865 ;; Some new commands that may need more suitable icons:
2866 (gnus-summary-save-newsrc "save" nil :visible nil)
2867 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2868 (gnus-summary-prev-article "left-arrow")
2869 (gnus-summary-next-article "right-arrow")
2870 (gnus-summary-next-page "next-page")
2871 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2873 ;; Maybe some sort-by-... could be added:
2874 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2875 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2876 (gnus-summary-mark-as-expirable
2878 :visible (gnus-check-backend-function 'request-expire-articles
2879 gnus-newsgroup-name))
2880 (gnus-summary-mark-as-spam
2882 :visible (and (fboundp 'spam-group-ham-contents-p)
2883 (spam-group-ham-contents-p gnus-newsgroup-name))
2884 :help "Mark as spam")
2885 (gnus-summary-mark-as-read-forward
2887 :visible (and (fboundp 'spam-group-spam-contents-p)
2888 (spam-group-spam-contents-p gnus-newsgroup-name)))
2890 (gnus-summary-exit "exit")
2891 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2892 (gnus-info-find-node "help"))
2893 "List of functions for the summary tool bar (GNOME style).
2895 See `gmm-tool-bar-from-list' for the format of the list."
2896 :type '(repeat gmm-tool-bar-item)
2897 :version "23.1" ;; No Gnus
2898 :initialize 'custom-initialize-default
2899 :set 'gnus-summary-tool-bar-update
2900 :group 'gnus-summary)
2902 (defcustom gnus-summary-tool-bar-retro
2903 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2904 (gnus-summary-next-unread-article "gnus/next-ur")
2905 (gnus-summary-post-news "gnus/post")
2906 (gnus-summary-followup-with-original "gnus/fuwo")
2907 (gnus-summary-followup "gnus/followup")
2908 (gnus-summary-reply-with-original "gnus/reply-wo")
2909 (gnus-summary-reply "gnus/reply")
2910 (gnus-summary-caesar-message "gnus/rot13")
2911 (gnus-uu-decode-uu "gnus/uu-decode")
2912 (gnus-summary-save-article-file "gnus/save-aif")
2913 (gnus-summary-save-article "gnus/save-art")
2914 (gnus-uu-post-news "gnus/uu-post")
2915 (gnus-summary-catchup "gnus/catchup")
2916 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2917 (gnus-summary-exit "gnus/exit-summ")
2918 ;; Some new command that may need more suitable icons:
2919 (gnus-summary-print-article "gnus/print" nil :visible nil)
2920 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2921 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2922 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2923 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2924 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2925 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2927 (gnus-info-find-node "gnus/help" nil :visible nil))
2928 "List of functions for the summary tool bar (retro look).
2930 See `gmm-tool-bar-from-list' for the format of the list."
2931 :type '(repeat gmm-tool-bar-item)
2932 :version "23.1" ;; No Gnus
2933 :initialize 'custom-initialize-default
2934 :set 'gnus-summary-tool-bar-update
2935 :group 'gnus-summary)
2937 (defcustom gnus-summary-tool-bar-zap-list t
2938 "List of icon items from the global tool bar.
2939 These items are not displayed in the Gnus summary mode tool bar.
2941 See `gmm-tool-bar-from-list' for the format of the list."
2942 :type 'gmm-tool-bar-zap-list
2943 :version "23.1" ;; No Gnus
2944 :initialize 'custom-initialize-default
2945 :set 'gnus-summary-tool-bar-update
2946 :group 'gnus-summary)
2948 (defvar image-load-path)
2949 (defvar tool-bar-map)
2951 (defun gnus-summary-make-tool-bar (&optional force)
2952 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2953 When FORCE, rebuild the tool bar."
2954 (when (and (not (featurep 'xemacs))
2955 (boundp 'tool-bar-mode)
2957 (or (not gnus-summary-tool-bar-map) force))
2959 (gmm-image-load-path-for-library "gnus"
2962 (image-load-path (cons (car load-path)
2963 (when (boundp 'image-load-path)
2965 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2966 gnus-summary-tool-bar-zap-list
2967 'gnus-summary-mode-map)))
2969 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2971 (setq gnus-summary-tool-bar-map map))))
2972 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2974 (defun gnus-score-set-default (var value)
2975 "A version of set that updates the GNU Emacs menu-bar."
2977 ;; It is the message that forces the active status to be updated.
2980 (defun gnus-make-score-map (type)
2981 "Make a summary score map of type TYPE."
2984 (let ((headers '(("author" "from" string)
2985 ("subject" "subject" string)
2986 ("article body" "body" string)
2987 ("article head" "head" string)
2988 ("xref" "xref" string)
2989 ("extra header" "extra" string)
2990 ("lines" "lines" number)
2991 ("followups to author" "followup" string)))
2992 (types '((number ("less than" <)
2995 (string ("substring" s)
2999 (perms '(("temporary" (current-time-string))
3007 (if (eq type 'lower)
3012 (setq header (car headers))
3018 (let ((ts (cdr (assoc (nth 2 header) types)))
3034 'gnus-summary-score-entry
3036 (if (or (string= (nth 1 header)
3038 (string= (nth 1 header)
3041 (list 'gnus-summary-header
3043 (list 'quote (nth 1 (car ts)))
3044 (list 'gnus-score-delta-default
3051 (list (nreverse outp))))
3054 (list (nreverse outt))))
3056 (setq headers (cdr headers)))
3057 (list (nreverse outh))))))))
3060 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3061 (defvar bookmark-make-record-function)
3063 (defvar bidi-paragraph-direction)
3065 (defun gnus-summary-mode (&optional group)
3066 "Major mode for reading articles.
3068 All normal editing commands are switched off.
3069 \\<gnus-summary-mode-map>
3070 Each line in this buffer represents one article. To read an
3071 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3072 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3075 You can also post articles and send mail from this buffer. To
3076 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3077 of an article, type `\\[gnus-summary-reply]'.
3079 There are approx. one gazillion commands you can execute in this
3080 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3082 The following commands are available:
3084 \\{gnus-summary-mode-map}"
3086 (kill-all-local-variables)
3087 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3088 (gnus-summary-make-local-variables))
3089 (gnus-summary-make-local-variables)
3090 (setq gnus-newsgroup-name group)
3091 (when (gnus-visual-p 'summary-menu 'menu)
3092 (gnus-summary-make-menu-bar)
3093 (gnus-summary-make-tool-bar))
3094 (gnus-make-thread-indent-array)
3095 (gnus-simplify-mode-line)
3096 (setq major-mode 'gnus-summary-mode)
3097 (setq mode-name "Summary")
3098 (use-local-map gnus-summary-mode-map)
3099 (buffer-disable-undo)
3100 (setq buffer-read-only t ;Disable modification
3101 show-trailing-whitespace nil)
3102 (setq truncate-lines t)
3103 ;; Force paragraph direction to be left-to-right. Don't make it
3104 ;; bound globally in old Emacsen and XEmacsen.
3105 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3106 (add-to-invisibility-spec '(gnus-sum . t))
3107 (gnus-summary-set-display-table)
3108 (gnus-set-default-directory)
3109 (make-local-variable 'gnus-summary-line-format)
3110 (make-local-variable 'gnus-summary-line-format-spec)
3111 (make-local-variable 'gnus-summary-dummy-line-format)
3112 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3113 (make-local-variable 'gnus-summary-mark-positions)
3114 (gnus-make-local-hook 'pre-command-hook)
3115 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3116 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3117 (turn-on-gnus-mailing-list-mode)
3118 (mm-enable-multibyte)
3119 (set (make-local-variable 'bookmark-make-record-function)
3120 'gnus-summary-bookmark-make-record)
3121 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3122 (gnus-update-summary-mark-positions))
3124 (defun gnus-summary-make-local-variables ()
3125 "Make all the local summary buffer variables."
3127 (dolist (local gnus-summary-local-variables)
3130 (if (eq (cdr local) 'global)
3131 ;; Copy the global value of the variable.
3132 (setq global (symbol-value (car local)))
3133 ;; Use the value from the list.
3134 (setq global (eval (cdr local))))
3135 (set (make-local-variable (car local)) global))
3136 ;; Simple nil-valued local variable.
3137 (set (make-local-variable local) nil)))))
3139 ;; Summary data functions.
3141 (defmacro gnus-data-number (data)
3144 (defmacro gnus-data-set-number (data number)
3145 `(setcar ,data ,number))
3147 (defmacro gnus-data-mark (data)
3150 (defmacro gnus-data-set-mark (data mark)
3151 `(setcar (nthcdr 1 ,data) ,mark))
3153 (defmacro gnus-data-pos (data)
3156 (defmacro gnus-data-set-pos (data pos)
3157 `(setcar (nthcdr 2 ,data) ,pos))
3159 (defmacro gnus-data-header (data)
3162 (defmacro gnus-data-set-header (data header)
3163 `(setf (nth 3 ,data) ,header))
3165 (defmacro gnus-data-level (data)
3168 (defmacro gnus-data-unread-p (data)
3169 `(= (nth 1 ,data) gnus-unread-mark))
3171 (defmacro gnus-data-read-p (data)
3172 `(/= (nth 1 ,data) gnus-unread-mark))
3174 (defmacro gnus-data-pseudo-p (data)
3175 `(consp (nth 3 ,data)))
3177 (defmacro gnus-data-find (number)
3178 `(assq ,number gnus-newsgroup-data))
3180 (defmacro gnus-data-find-list (number &optional data)
3181 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3182 (memq (assq ,number bdata)
3185 (defmacro gnus-data-make (number mark pos header level)
3186 `(list ,number ,mark ,pos ,header ,level))
3188 (defun gnus-data-enter (after-article number mark pos header level offset)
3189 (let ((data (gnus-data-find-list after-article)))
3191 (error "No such article: %d" after-article))
3192 (setcdr data (cons (gnus-data-make number mark pos header level)
3194 (setq gnus-newsgroup-data-reverse nil)
3195 (gnus-data-update-list (cddr data) offset)))
3197 (defun gnus-data-enter-list (after-article list &optional offset)
3199 (let ((data (and after-article (gnus-data-find-list after-article)))
3203 (let ((odata gnus-newsgroup-data))
3204 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3206 (gnus-data-update-list odata offset)))
3207 ;; Find the last element in the list to be spliced into the main
3209 (setq list (last list))
3212 (setcdr list gnus-newsgroup-data)
3213 (setq gnus-newsgroup-data ilist)
3215 (gnus-data-update-list (cdr list) offset)))
3216 (setcdr list (cdr data))
3219 (gnus-data-update-list (cdr list) offset))))
3220 (setq gnus-newsgroup-data-reverse nil))))
3222 (defun gnus-data-remove (article &optional offset)
3223 (let ((data gnus-newsgroup-data))
3224 (if (= (gnus-data-number (car data)) article)
3226 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3227 gnus-newsgroup-data-reverse nil)
3229 (gnus-data-update-list gnus-newsgroup-data offset)))
3231 (when (= (gnus-data-number (cadr data)) article)
3232 (setcdr data (cddr data))
3234 (gnus-data-update-list (cdr data) offset))
3236 gnus-newsgroup-data-reverse nil))
3237 (setq data (cdr data))))))
3239 (defmacro gnus-data-list (backward)
3241 (or gnus-newsgroup-data-reverse
3242 (setq gnus-newsgroup-data-reverse
3243 (reverse gnus-newsgroup-data)))
3244 gnus-newsgroup-data))
3246 (defun gnus-data-update-list (data offset)
3247 "Add OFFSET to the POS of all data entries in DATA."
3248 (setq gnus-newsgroup-data-reverse nil)
3250 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3251 (setq data (cdr data))))
3253 (defun gnus-summary-article-pseudo-p (article)
3254 "Say whether this article is a pseudo article or not."
3255 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3257 (defmacro gnus-summary-article-sparse-p (article)
3258 "Say whether this article is a sparse article or not."
3259 `(memq ,article gnus-newsgroup-sparse))
3261 (defmacro gnus-summary-article-ancient-p (article)
3262 "Say whether this article is a sparse article or not."
3263 `(memq ,article gnus-newsgroup-ancient))
3265 (defun gnus-article-parent-p (number)
3266 "Say whether this article is a parent or not."
3267 (let ((data (gnus-data-find-list number)))
3268 (and (cdr data) ; There has to be an article after...
3269 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3270 (gnus-data-level (nth 1 data))))))
3272 (defun gnus-article-children (number)
3273 "Return a list of all children to NUMBER."
3274 (let* ((data (gnus-data-find-list number))
3275 (level (gnus-data-level (car data)))
3277 (setq data (cdr data))
3279 (= (gnus-data-level (car data)) (1+ level)))
3280 (push (gnus-data-number (car data)) children)
3281 (setq data (cdr data)))
3284 (defmacro gnus-summary-skip-intangible ()
3285 "If the current article is intangible, then jump to a different article."
3286 '(let ((to (get-text-property (point) 'gnus-intangible)))
3287 (and to (gnus-summary-goto-subject to))))
3289 (defmacro gnus-summary-article-intangible-p ()
3290 "Say whether this article is intangible or not."
3291 '(get-text-property (point) 'gnus-intangible))
3293 (defun gnus-article-read-p (article)
3294 "Say whether ARTICLE is read or not."
3295 (not (or (memq article gnus-newsgroup-marked)
3296 (memq article gnus-newsgroup-spam-marked)
3297 (memq article gnus-newsgroup-unreads)
3298 (memq article gnus-newsgroup-unselected)
3299 (memq article gnus-newsgroup-dormant))))
3301 ;; Some summary mode macros.
3303 (defmacro gnus-summary-article-number ()
3304 "The article number of the article on the current line.
3305 If there isn't an article number here, then we return the current
3308 (gnus-summary-skip-intangible)
3309 (or (get-text-property (point) 'gnus-number)
3310 (gnus-summary-last-subject))))
3312 (defmacro gnus-summary-article-header (&optional number)
3313 "Return the header of article NUMBER."
3314 `(gnus-data-header (gnus-data-find
3315 ,(or number '(gnus-summary-article-number)))))
3317 (defmacro gnus-summary-thread-level (&optional number)
3318 "Return the level of thread that starts with article NUMBER."
3319 `(if (and (eq gnus-summary-make-false-root 'dummy)
3320 (get-text-property (point) 'gnus-intangible))
3322 (gnus-data-level (gnus-data-find
3323 ,(or number '(gnus-summary-article-number))))))
3325 (defmacro gnus-summary-article-mark (&optional number)
3326 "Return the mark of article NUMBER."
3327 `(gnus-data-mark (gnus-data-find
3328 ,(or number '(gnus-summary-article-number)))))
3330 (defmacro gnus-summary-article-pos (&optional number)
3331 "Return the position of the line of article NUMBER."
3332 `(gnus-data-pos (gnus-data-find
3333 ,(or number '(gnus-summary-article-number)))))
3335 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3336 (defmacro gnus-summary-article-subject (&optional number)
3337 "Return current subject string or nil if nothing."
3340 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3341 '(gnus-data-header (assq (gnus-summary-article-number)
3342 gnus-newsgroup-data)))))
3345 (mail-header-subject headers))))
3347 (defmacro gnus-summary-article-score (&optional number)
3348 "Return current article score."
3349 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3350 gnus-newsgroup-scored))
3351 gnus-summary-default-score 0))
3353 (defun gnus-summary-article-children (&optional number)
3354 "Return a list of article numbers that are children of article NUMBER."
3355 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3356 (level (gnus-data-level (car data)))
3358 (while (and (setq data (cdr data))
3359 (> (setq l (gnus-data-level (car data))) level))
3360 (and (= (1+ level) l)
3361 (push (gnus-data-number (car data))
3363 (nreverse children)))
3365 (defun gnus-summary-article-parent (&optional number)
3366 "Return the article number of the parent of article NUMBER."
3367 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3368 (gnus-data-list t)))
3369 (level (gnus-data-level (car data))))
3371 () ; This is a root.
3372 ;; We search until we find an article with a level less than
3373 ;; this one. That function has to be the parent.
3374 (while (and (setq data (cdr data))
3375 (not (< (gnus-data-level (car data)) level))))
3376 (and data (gnus-data-number (car data))))))
3378 (defun gnus-unread-mark-p (mark)
3379 "Say whether MARK is the unread mark."
3380 (= mark gnus-unread-mark))
3382 (defun gnus-read-mark-p (mark)
3383 "Say whether MARK is one of the marks that mark as read.
3384 This is all marks except unread, ticked, dormant, and expirable."
3385 (not (or (= mark gnus-unread-mark)
3386 (= mark gnus-ticked-mark)
3387 (= mark gnus-spam-mark)
3388 (= mark gnus-dormant-mark)
3389 (= mark gnus-expirable-mark))))
3391 (defmacro gnus-article-mark (number)
3392 "Return the MARK of article NUMBER.
3393 This macro should only be used when computing the mark the \"first\"
3394 time; i.e., when generating the summary lines. After that,
3395 `gnus-summary-article-mark' should be used to examine the
3398 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3399 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3400 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3401 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3402 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3403 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3404 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3405 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3406 gnus-ancient-mark))))
3408 ;; Saving hidden threads.
3410 (defmacro gnus-save-hidden-threads (&rest forms)
3411 "Save hidden threads, eval FORMS, and restore the hidden threads."
3412 (let ((config (make-symbol "config")))
3413 `(let ((,config (gnus-hidden-threads-configuration)))
3417 (gnus-restore-hidden-threads-configuration ,config)))))
3418 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3419 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3421 (defun gnus-data-compute-positions ()
3422 "Compute the positions of all articles."
3423 (setq gnus-newsgroup-data-reverse nil)
3424 (let ((data gnus-newsgroup-data))
3426 (gnus-save-hidden-threads
3427 (gnus-summary-show-all-threads)
3428 (goto-char (point-min))
3430 (while (get-text-property (point) 'gnus-intangible)
3432 (gnus-data-set-pos (car data) (+ (point) 3))
3433 (setq data (cdr data))
3434 (forward-line 1))))))
3436 (defun gnus-hidden-threads-configuration ()
3437 "Return the current hidden threads configuration."
3440 (goto-char (point-min))
3442 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3443 (push (save-excursion (forward-line 0) (point)) config))
3447 (defun gnus-restore-hidden-threads-configuration (config)
3448 "Restore hidden threads configuration from CONFIG."
3450 (let (point (inhibit-read-only t))
3451 (while (setq point (pop config))
3453 (gnus-summary-hide-thread)))))
3455 ;; Various summary mode internalish functions.
3457 (defun gnus-mouse-pick-article (e)
3460 (gnus-summary-next-page nil t))
3462 (defun gnus-summary-set-display-table ()
3463 "Change the display table.
3464 Odd characters have a tendency to mess
3465 up nicely formatted displays - we make all possible glyphs
3466 display only a single character."
3468 ;; We start from the standard display table, if any.
3469 (let ((table (or (copy-sequence standard-display-table)
3470 (make-display-table)))
3472 ;; Nix out all the control chars...
3473 (while (>= (setq i (1- i)) 0)
3474 (gnus-put-display-table i [??] table))
3475 ;; ... but not newline and cr, of course. (cr is necessary for the
3476 ;; selective display).
3477 (gnus-put-display-table ?\n nil table)
3478 (gnus-put-display-table ?\r nil table)
3479 ;; We keep TAB as well.
3480 (gnus-put-display-table ?\t nil table)
3481 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3482 ;; Emacs 23 (unicode), that are not set already.
3483 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3486 (while (>= (setq i (1- i)) 127)
3487 ;; Only modify if the entry is nil.
3488 (unless (gnus-get-display-table i table)
3489 (gnus-put-display-table i [??] table))))
3490 (setq buffer-display-table table)))
3492 (defun gnus-summary-set-article-display-arrow (pos)
3493 "Update the overlay arrow to point to line at position POS."
3494 (when gnus-summary-display-arrow
3495 (make-local-variable 'overlay-arrow-position)
3496 (make-local-variable 'overlay-arrow-string)
3500 (unless overlay-arrow-position
3501 (setq overlay-arrow-position (make-marker)))
3502 (setq overlay-arrow-string "=>"
3503 overlay-arrow-position (set-marker overlay-arrow-position
3505 (current-buffer))))))
3507 (defun gnus-summary-setup-buffer (group)
3508 "Initialize summary buffer.
3509 If the setup was successful, non-nil is returned."
3510 (let ((buffer (gnus-summary-buffer-name group))
3511 (dead-name (concat "*Dead Summary "
3512 (gnus-group-decoded-name group) "*")))
3513 ;; If a dead summary buffer exists, we kill it.
3514 (when (gnus-buffer-live-p dead-name)
3515 (gnus-kill-buffer dead-name))
3516 (if (get-buffer buffer)
3519 (setq gnus-summary-buffer (current-buffer))
3520 (not gnus-newsgroup-prepared))
3521 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3522 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3523 (gnus-summary-mode group)
3524 (when (gnus-group-quit-config group)
3525 (set (make-local-variable 'gnus-single-article-buffer) nil))
3526 (make-local-variable 'gnus-article-buffer)
3527 (make-local-variable 'gnus-article-current)
3528 (make-local-variable 'gnus-original-article-buffer)
3529 (setq gnus-newsgroup-name group)
3530 ;; Set any local variables in the group parameters.
3531 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3534 (defun gnus-set-global-variables ()
3535 "Set the global equivalents of the buffer-local variables.
3536 They are set to the latest values they had. These reflect the summary
3537 buffer that was in action when the last article was fetched."
3538 (when (eq major-mode 'gnus-summary-mode)
3539 (setq gnus-summary-buffer (current-buffer))
3540 (let ((name gnus-newsgroup-name)
3541 (marked gnus-newsgroup-marked)
3542 (spam gnus-newsgroup-spam-marked)
3543 (unread gnus-newsgroup-unreads)
3544 (headers gnus-current-headers)
3545 (data gnus-newsgroup-data)
3546 (summary gnus-summary-buffer)
3547 (article-buffer gnus-article-buffer)
3548 (original gnus-original-article-buffer)
3549 (gac gnus-article-current)
3550 (reffed gnus-reffed-article-number)
3551 (score-file gnus-current-score-file)
3552 (default-charset gnus-newsgroup-charset)
3554 (let ((locals gnus-newsgroup-variables))
3556 (if (consp (car locals))
3557 (push (eval (caar locals)) vlist)
3558 (push (eval (car locals)) vlist))
3559 (setq locals (cdr locals)))
3560 (setq vlist (nreverse vlist)))
3562 (setq gnus-newsgroup-name name
3563 gnus-newsgroup-marked marked
3564 gnus-newsgroup-spam-marked spam
3565 gnus-newsgroup-unreads unread
3566 gnus-current-headers headers
3567 gnus-newsgroup-data data
3568 gnus-article-current gac
3569 gnus-summary-buffer summary
3570 gnus-article-buffer article-buffer
3571 gnus-original-article-buffer original
3572 gnus-reffed-article-number reffed
3573 gnus-current-score-file score-file
3574 gnus-newsgroup-charset default-charset)
3575 (let ((locals gnus-newsgroup-variables))
3577 (if (consp (car locals))
3578 (set (caar locals) (pop vlist))
3579 (set (car locals) (pop vlist)))
3580 (setq locals (cdr locals))))
3581 ;; The article buffer also has local variables.
3582 (when (gnus-buffer-live-p gnus-article-buffer)
3583 (set-buffer gnus-article-buffer)
3584 (setq gnus-summary-buffer summary))))))
3586 (defun gnus-summary-article-unread-p (article)
3587 "Say whether ARTICLE is unread or not."
3588 (memq article gnus-newsgroup-unreads))
3590 (defun gnus-summary-first-article-p (&optional article)
3591 "Return whether ARTICLE is the first article in the buffer."
3592 (if (not (setq article (or article (gnus-summary-article-number))))
3594 (eq article (caar gnus-newsgroup-data))))
3596 (defun gnus-summary-last-article-p (&optional article)
3597 "Return whether ARTICLE is the last article in the buffer."
3598 (if (not (setq article (or article (gnus-summary-article-number))))
3599 ;; All non-existent numbers are the last article. :-)
3601 (not (cdr (gnus-data-find-list article)))))
3603 (defun gnus-make-thread-indent-array (&optional n)
3605 (progn (setq n 200) nil)
3606 (null gnus-thread-indent-array)
3607 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3608 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3609 gnus-thread-indent-array-level gnus-thread-indent-level)
3611 (aset gnus-thread-indent-array n
3612 (make-string (* n gnus-thread-indent-level) ? ))
3615 (defun gnus-update-summary-mark-positions ()
3616 "Compute where the summary marks are to go."
3618 (when (gnus-buffer-exists-p gnus-summary-buffer)
3619 (set-buffer gnus-summary-buffer))
3620 (let ((spec gnus-summary-line-format-spec)
3623 (gnus-set-work-buffer)
3624 (let ((gnus-tmp-unread ?Z)
3625 (gnus-replied-mark ?Z)
3626 (gnus-score-below-mark ?Z)
3627 (gnus-score-over-mark ?Z)
3628 (gnus-undownloaded-mark ?Z)
3629 (gnus-summary-line-format-spec spec)
3630 (gnus-newsgroup-downloadable '(0))
3631 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3632 case-fold-search ignores)
3633 ;; Here, all marks are bound to Z.
3634 (gnus-summary-insert-line header
3635 0 nil t gnus-tmp-unread t nil "" nil 1)
3636 (goto-char (point-min))
3637 ;; Memorize the positions of the same characters as dummy marks.
3638 (while (re-search-forward "[A-D]" nil t)
3639 (push (point) ignores))
3641 ;; We use A-D as dummy marks in order to know column positions
3642 ;; where marks should be inserted.
3643 (setq gnus-tmp-unread ?A
3644 gnus-replied-mark ?B
3645 gnus-score-below-mark ?C
3646 gnus-score-over-mark ?C
3647 gnus-undownloaded-mark ?D)
3648 (gnus-summary-insert-line header
3649 0 nil t gnus-tmp-unread t nil "" nil 1)
3650 ;; Ignore characters which aren't dummy marks.
3652 (delete-region (goto-char (1- p)) p)
3654 (goto-char (point-min))
3655 (setq pos (list (cons 'unread
3656 (and (search-forward "A" nil t)
3657 (- (point) (point-min) 1)))))
3658 (goto-char (point-min))
3659 (push (cons 'replied (and (search-forward "B" nil t)
3660 (- (point) (point-min) 1)))
3662 (goto-char (point-min))
3663 (push (cons 'score (and (search-forward "C" nil t)
3664 (- (point) (point-min) 1)))
3666 (goto-char (point-min))
3667 (push (cons 'download (and (search-forward "D" nil t)
3668 (- (point) (point-min) 1)))
3670 (setq gnus-summary-mark-positions pos))))
3672 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3673 "Insert a dummy root in the summary buffer."
3675 (gnus-add-text-properties
3676 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3677 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3679 (defun gnus-summary-extract-address-component (from)
3680 (or (car (funcall gnus-extract-address-components from))
3683 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3684 (let ((mail-parse-charset gnus-newsgroup-charset)
3685 (ignored-from-addresses (gnus-ignored-from-addresses))
3686 ; Is it really necessary to do this next part for each summary line?
3687 ; Luckily, doesn't seem to slow things down much.
3688 (mail-parse-ignored-charsets
3689 (with-current-buffer gnus-summary-buffer
3690 gnus-newsgroup-ignored-charsets)))
3692 (and ignored-from-addresses
3693 (string-match ignored-from-addresses gnus-tmp-from)
3694 (let ((extra-headers (mail-header-extra header))
3698 ((setq to (cdr (assq 'To extra-headers)))
3699 (concat gnus-summary-to-prefix
3701 (gnus-summary-extract-address-component
3702 (funcall gnus-decode-encoded-address-function to)))))
3705 (cdr (assq 'Newsgroups extra-headers))
3707 (memq 'Newsgroups gnus-extra-headers)
3708 (eq (car (gnus-find-method-for-group
3709 gnus-newsgroup-name)) 'nntp)
3710 (gnus-group-real-name gnus-newsgroup-name))))
3711 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3712 (gnus-string-mark-left-to-right
3714 (gnus-summary-extract-address-component gnus-tmp-from))))))
3716 (defun gnus-summary-insert-line (gnus-tmp-header
3717 gnus-tmp-level gnus-tmp-current
3718 undownloaded gnus-tmp-unread gnus-tmp-replied
3719 gnus-tmp-expirable gnus-tmp-subject-or-nil
3720 &optional gnus-tmp-dummy gnus-tmp-score
3722 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3723 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3725 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3726 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3727 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3728 (gnus-tmp-score-char
3729 (if (or (null gnus-summary-default-score)
3730 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3731 gnus-summary-zcore-fuzz))
3733 (if (< gnus-tmp-score gnus-summary-default-score)
3734 gnus-score-below-mark gnus-score-over-mark)))
3735 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3737 (cond (gnus-tmp-process gnus-process-mark)
3738 ((memq gnus-tmp-current gnus-newsgroup-cached)
3740 (gnus-tmp-replied gnus-replied-mark)
3741 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3742 gnus-forwarded-mark)
3743 ((memq gnus-tmp-current gnus-newsgroup-saved)
3745 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3748 (gnus-tmp-downloaded
3750 gnus-undownloaded-mark)
3751 (gnus-newsgroup-agentized
3752 gnus-downloaded-mark)
3755 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3758 ((string-match "<[^>]+> *$" gnus-tmp-from)
3759 (let ((beg (match-beginning 0)))
3760 (or (and (string-match "^\".+\"" gnus-tmp-from)
3761 (substring gnus-tmp-from 1 (1- (match-end 0))))
3762 (substring gnus-tmp-from 0 beg))))
3763 ((string-match "(.+)" gnus-tmp-from)
3764 (substring gnus-tmp-from
3765 (1+ (match-beginning 0)) (1- (match-end 0))))
3767 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3768 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3769 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3770 (inhibit-read-only t))
3771 (when (string= gnus-tmp-name "")
3772 (setq gnus-tmp-name gnus-tmp-from))
3773 (unless (numberp gnus-tmp-lines)
3774 (setq gnus-tmp-lines -1))
3775 (if (= gnus-tmp-lines -1)
3776 (setq gnus-tmp-lines "?")
3777 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3779 (gnus-put-text-property
3781 (progn (eval gnus-summary-line-format-spec) (point))
3782 'gnus-number gnus-tmp-number)
3783 (error (gnus-message 5 "Error updating the summary line")))
3784 (when (gnus-visual-p 'summary-highlight 'highlight)
3786 (gnus-summary-highlight-line)
3787 (gnus-run-hooks 'gnus-summary-update-hook)
3790 (defun gnus-summary-update-line (&optional dont-update)
3791 "Update summary line after change."
3792 (when (and gnus-summary-default-score
3793 (not gnus-summary-inhibit-highlight))
3794 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3795 (article (gnus-summary-article-number))
3796 (score (gnus-summary-article-score article)))
3798 (if (and gnus-summary-mark-below
3799 (< (gnus-summary-article-score)
3800 gnus-summary-mark-below))
3801 ;; This article has a low score, so we mark it as read.
3802 (when (memq article gnus-newsgroup-unreads)
3803 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3804 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3805 ;; This article was previously marked as read on account
3806 ;; of a low score, but now it has risen, so we mark it as
3808 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3809 (gnus-summary-update-mark
3810 (if (or (null gnus-summary-default-score)
3811 (<= (abs (- score gnus-summary-default-score))
3812 gnus-summary-zcore-fuzz))
3814 (if (< score gnus-summary-default-score)
3815 gnus-score-below-mark gnus-score-over-mark))
3817 ;; Do visual highlighting.
3818 (when (gnus-visual-p 'summary-highlight 'highlight)
3819 (gnus-summary-highlight-line)
3820 (gnus-run-hooks 'gnus-summary-update-hook)))))
3822 (defvar gnus-tmp-new-adopts nil)
3824 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3825 "Return the number of articles in THREAD.
3826 This may be 0 in some cases -- if none of the articles in
3827 the thread are to be displayed."
3829 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3831 ((not (listp thread))
3833 ((and (consp thread) (cdr thread))
3836 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3839 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3842 (when (and level (zerop level) gnus-tmp-new-adopts)
3845 'gnus-summary-number-of-articles-in-thread
3846 gnus-tmp-new-adopts))))
3848 (if (> number 1) gnus-not-empty-thread-mark
3849 gnus-empty-thread-mark)
3852 (defsubst gnus-summary-line-message-size (head)
3853 "Return pretty-printed version of message size.
3854 This function is intended to be used in
3855 `gnus-summary-line-format-alist'."
3856 (let ((c (or (mail-header-chars head) -1)))
3857 (cond ((< c 0) "n/a") ; chars not available
3858 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3859 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3860 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3861 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3863 (defcustom gnus-user-date-format-alist
3864 '(((gnus-seconds-today) . "Today, %H:%M")
3865 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3866 (604800 . "%A %H:%M") ; That's one week
3867 ((gnus-seconds-month) . "%A %d")
3868 ((gnus-seconds-year) . "%B %d")
3869 (t . "%b %d %Y")) ; This one is used when no other
3871 "Specifies date format depending on age of article.
3872 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3873 seconds) or a Lisp expression evaluating to a number. When the age of
3874 the article is less than this number, then use `format-time-string'
3875 with the corresponding FORMAT for displaying the date of the article.
3876 If AGE is not a number or a Lisp expression evaluating to a
3877 non-number, then the corresponding FORMAT is used as a default value.
3879 Note that the list is processed from the beginning, so it should be
3880 sorted by ascending AGE. Also note that items following the first
3881 non-number AGE will be ignored.
3883 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3884 and `gnus-seconds-year' in the AGE spec. They return the number of
3885 seconds passed since the start of today, of this month, of this year,
3888 :group 'gnus-summary-format
3889 :type '(alist :key-type sexp :value-type string))
3891 (defun gnus-user-date (messy-date)
3892 "Format the messy-date according to `gnus-user-date-format-alist'.
3893 Returns \" ? \" if there's bad input or if another error occurs.
3894 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3896 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3897 (now (gnus-float-time))
3898 ;;If we don't find something suitable we'll use this one
3899 (my-format "%b %d '%y"))
3900 (let* ((difference (- now messy-date))
3901 (templist gnus-user-date-format-alist)
3902 (top (eval (caar templist))))
3903 (while (if (numberp top) (< top difference) (not top))
3905 (setq templist (cdr templist))
3906 (setq top (eval (caar templist)))))
3907 (if (stringp (cdr (car templist)))
3908 (setq my-format (cdr (car templist)))))
3909 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3912 (defun gnus-summary-set-local-parameters (group)
3913 "Go through the local params of GROUP and set all variable specs in that list."
3914 (let ((vars '(quit-config active))) ; Ignore things that aren't
3916 (dolist (elem (gnus-group-find-parameter group))
3917 (and (consp elem) ; Has to be a cons.
3918 (consp (cdr elem)) ; The cdr has to be a list.
3919 (symbolp (car elem)) ; Has to be a symbol in there.
3920 (not (memq (car elem) vars))
3922 (push (car elem) vars)
3923 ;; Variables like `gnus-show-threads' that are globally
3924 ;; bound, if used as group parameters, need to get to be
3925 ;; buffer-local, whereas just parameters like `gcc-self',
3926 ;; `timestamp', etc. should not be bound as variables.
3927 (if (boundp (car elem))
3928 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3929 (eval (nth 1 elem))))))))
3931 (defun gnus-summary-read-group (group &optional show-all no-article
3932 kill-buffer no-display backward
3934 "Start reading news in newsgroup GROUP.
3935 If SHOW-ALL is non-nil, already read articles are also listed.
3936 If NO-ARTICLE is non-nil, no article is selected initially.
3937 If NO-DISPLAY, don't generate the summary buffer contents.
3938 If KILL-BUFFER, it should be a buffer that's killed once the new
3939 summary buffer has been generated.
3940 If BACKWARD, move point to the previous group in the group buffer
3941 If SELECT-ARTICLES, only select those articles from GROUP."
3945 (let ((gnus-auto-select-next nil))
3946 (or (gnus-summary-read-group-1
3947 group show-all no-article
3948 kill-buffer no-display
3951 select-articles nil)))))
3952 (eq gnus-auto-select-next 'quietly))
3953 (set-buffer gnus-group-buffer)
3954 ;; The entry function called above goes to the next
3955 ;; group automatically, so we go two groups back
3956 ;; if we are searching for the previous group.
3958 (gnus-group-prev-unread-group 2))
3959 (if (not (equal group (gnus-group-group-name)))
3960 (setq group (gnus-group-group-name))
3964 (defun gnus-summary-read-group-1 (group show-all no-article
3965 kill-buffer no-display
3966 &optional select-articles)
3967 ;; Killed foreign groups can't be entered.
3968 ;; (when (and (not (gnus-group-native-p group))
3969 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3970 ;; (error "Dead non-native groups can't be entered"))
3971 (gnus-message 7 "Retrieving newsgroup: %s..."
3972 (gnus-group-decoded-name group))
3973 (let* ((new-group (gnus-summary-setup-buffer group))
3974 (quit-config (gnus-group-quit-config group))
3975 (did-select (and new-group (gnus-select-newsgroup
3976 group show-all select-articles))))
3978 ;; This summary buffer exists already, so we just select it.
3980 (gnus-set-global-variables)
3982 (gnus-kill-or-deaden-summary kill-buffer))
3983 (gnus-configure-windows 'summary 'force)
3984 (gnus-set-mode-line 'summary)
3985 (gnus-summary-position-point)
3988 ;; We couldn't select this group.
3990 (when (and (eq major-mode 'gnus-summary-mode)
3991 (not (equal (current-buffer) kill-buffer)))
3992 (kill-buffer (current-buffer))
3993 (if (not quit-config)
3995 ;; Update the info -- marks might need to be removed,
3997 (gnus-summary-update-info)
3998 (set-buffer gnus-group-buffer)
3999 (gnus-group-jump-to-group group)
4000 (gnus-group-next-unread-group 1))
4001 (gnus-handle-ephemeral-exit quit-config)))
4002 (if (null (gnus-list-of-unread-articles group))
4003 (gnus-message 3 "Group %s contains no messages" group)
4004 (gnus-message 3 "Can't select group"))
4006 ;; The user did a `C-g' while prompting for number of articles,
4007 ;; so we exit this group.
4008 ((eq did-select 'quit)
4009 (and (eq major-mode 'gnus-summary-mode)
4010 (not (equal (current-buffer) kill-buffer))
4011 (kill-buffer (current-buffer)))
4013 (gnus-kill-or-deaden-summary kill-buffer))
4014 (if (not quit-config)
4016 (set-buffer gnus-group-buffer)
4017 (gnus-group-jump-to-group group)
4018 (gnus-configure-windows 'group 'force))
4019 (gnus-handle-ephemeral-exit quit-config))
4020 ;; Finally signal the quit.
4022 ;; The group was successfully selected.
4024 (gnus-set-global-variables)
4025 ;; Save the active value in effect when the group was entered.
4026 (setq gnus-newsgroup-active
4028 (gnus-active gnus-newsgroup-name)))
4029 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4030 ;; You can change the summary buffer in some way with this hook.
4031 (gnus-run-hooks 'gnus-select-group-hook)
4032 (when (memq 'summary (gnus-update-format-specifications
4033 nil 'summary 'summary-mode 'summary-dummy))
4034 ;; The format specification for the summary line was updated,
4035 ;; so we need to update the mark positions as well.
4036 (gnus-update-summary-mark-positions))
4037 ;; Do score processing.
4038 (when gnus-use-scoring
4039 (gnus-possibly-score-headers))
4040 ;; Check whether to fill in the gaps in the threads.
4041 (when gnus-build-sparse-threads
4042 (gnus-build-sparse-threads))
4043 ;; Find the initial limit.
4045 (let ((gnus-newsgroup-dormant nil))
4046 (gnus-summary-initial-limit show-all))
4047 (gnus-summary-initial-limit show-all))
4048 ;; Generate the summary buffer.
4050 (gnus-summary-prepare))
4051 (when gnus-use-trees
4052 (gnus-tree-open group)
4053 (setq gnus-summary-highlight-line-function
4054 'gnus-tree-highlight-article))
4055 ;; If the summary buffer is empty, but there are some low-scored
4056 ;; articles or some excluded dormants, we include these in the
4058 (when (and (zerop (buffer-size))
4060 (cond (gnus-newsgroup-dormant
4061 (gnus-summary-limit-include-dormant))
4062 ((and gnus-newsgroup-scored show-all)
4063 (gnus-summary-limit-include-expunged t))))
4064 ;; Function `gnus-apply-kill-file' must be called in this hook.
4065 (gnus-run-hooks 'gnus-apply-kill-hook)
4066 (if (and (zerop (buffer-size))
4069 ;; This newsgroup is empty.
4070 (gnus-summary-catchup-and-exit nil t)
4071 (gnus-message 6 "No unread news")
4073 (gnus-kill-or-deaden-summary kill-buffer))
4074 ;; Return nil from this function.
4076 ;; Hide conversation thread subtrees. We cannot do this in
4077 ;; gnus-summary-prepare-hook since kill processing may not
4078 ;; work with hidden articles.
4079 (gnus-summary-maybe-hide-threads)
4080 (gnus-configure-windows 'summary)
4082 (gnus-kill-or-deaden-summary kill-buffer))
4083 (gnus-summary-auto-select-subject)
4084 ;; Show first unread article if requested.
4085 (if (and (not no-article)
4087 gnus-newsgroup-unreads
4088 gnus-auto-select-first)
4090 (let ((art (gnus-summary-article-number)))
4091 (unless (and (not gnus-plugged)
4092 (or (memq art gnus-newsgroup-undownloaded)
4093 (memq art gnus-newsgroup-downloadable)))
4094 (gnus-summary-goto-article art))))
4095 ;; Don't select any articles.
4096 (gnus-summary-position-point)
4097 (gnus-configure-windows 'summary 'force)
4098 (gnus-set-mode-line 'summary))
4099 (when (and gnus-auto-center-group
4100 (get-buffer-window gnus-group-buffer t))
4101 ;; Gotta use windows, because recenter does weird stuff if
4102 ;; the current buffer ain't the displayed window.
4103 (let ((owin (selected-window)))
4104 (select-window (get-buffer-window gnus-group-buffer t))
4105 (when (gnus-group-goto-group group)
4107 (select-window owin)))
4108 ;; Mark this buffer as "prepared".
4109 (setq gnus-newsgroup-prepared t)
4110 (gnus-run-hooks 'gnus-summary-prepared-hook)
4111 (unless (gnus-ephemeral-group-p group)
4112 (gnus-group-update-group group nil t))
4115 (defun gnus-summary-auto-select-subject ()
4116 "Select the subject line on initial group entry."
4117 (goto-char (point-min))
4119 ((eq gnus-auto-select-subject 'best)
4120 (gnus-summary-best-unread-subject))
4121 ((eq gnus-auto-select-subject 'unread)
4122 (gnus-summary-first-unread-subject))
4123 ((eq gnus-auto-select-subject 'unseen)
4124 (gnus-summary-first-unseen-subject))
4125 ((eq gnus-auto-select-subject 'unseen-or-unread)
4126 (gnus-summary-first-unseen-or-unread-subject))
4127 ((eq gnus-auto-select-subject 'first)
4130 ((functionp gnus-auto-select-subject)
4131 (funcall gnus-auto-select-subject))))
4133 (defun gnus-summary-prepare ()
4134 "Generate the summary buffer."
4136 (let ((inhibit-read-only t))
4138 (setq gnus-newsgroup-data nil
4139 gnus-newsgroup-data-reverse nil)
4140 (gnus-run-hooks 'gnus-summary-generate-hook)
4141 ;; Generate the buffer, either with threads or without.
4142 (when gnus-newsgroup-headers
4143 (gnus-summary-prepare-threads
4144 (if gnus-show-threads
4145 (gnus-sort-gathered-threads
4146 (funcall gnus-summary-thread-gathering-function
4148 (gnus-cut-threads (gnus-make-threads)))))
4149 ;; Unthreaded display.
4150 (gnus-sort-articles gnus-newsgroup-headers))))
4151 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4152 ;; Call hooks for modifying summary buffer.
4153 (goto-char (point-min))
4154 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4156 (defsubst gnus-general-simplify-subject (subject)
4157 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4160 ;; Truncate the subject.
4161 (gnus-simplify-subject-functions
4162 (gnus-map-function gnus-simplify-subject-functions subject))
4163 ((numberp gnus-summary-gather-subject-limit)
4164 (setq subject (gnus-simplify-subject-re subject))
4165 (if (> (length subject) gnus-summary-gather-subject-limit)
4166 (substring subject 0 gnus-summary-gather-subject-limit)
4168 ;; Fuzzily simplify it.
4169 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4170 (gnus-simplify-subject-fuzzy subject))
4171 ;; Just remove the leading "Re:".
4173 (gnus-simplify-subject-re subject))))
4175 (if (and gnus-summary-gather-exclude-subject
4176 (string-match gnus-summary-gather-exclude-subject subject))
4177 nil ; This article shouldn't be gathered
4180 (defun gnus-summary-simplify-subject-query ()
4181 "Query where the respool algorithm would put this article."
4183 (gnus-summary-select-article)
4184 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4186 (defun gnus-gather-threads-by-subject (threads)
4187 "Gather threads by looking at Subject headers."
4188 (if (not gnus-summary-make-false-root)
4190 (let ((hashtb (gnus-make-hashtable 1024))
4193 subject hthread whole-subject)
4195 (setq subject (gnus-general-simplify-subject
4196 (setq whole-subject (mail-header-subject
4199 (if (setq hthread (gnus-gethash subject hashtb))
4201 ;; We enter a dummy root into the thread, if we
4202 ;; haven't done that already.
4203 (unless (stringp (caar hthread))
4204 (setcar hthread (list whole-subject (car hthread))))
4205 ;; We add this new gathered thread to this gathered
4207 (setcdr (car hthread)
4208 (nconc (cdar hthread) (list (car threads))))
4209 ;; Remove it from the list of threads.
4210 (setcdr prev (cdr threads))
4211 (setq threads prev))
4212 ;; Enter this thread into the hash table.
4213 (gnus-sethash subject
4214 (if gnus-summary-make-false-root-always
4216 ;; If you want a dummy root above all
4218 (setcar threads (list whole-subject
4224 (setq threads (cdr threads)))
4227 (defun gnus-gather-threads-by-references (threads)
4228 "Gather threads by looking at References headers."
4229 (let ((idhashtb (gnus-make-hashtable 1024))
4230 (thhashtb (gnus-make-hashtable 1024))
4233 ids references id gthread gid entered ref)
4235 (when (setq references (mail-header-references (caar threads)))
4236 (setq id (mail-header-id (caar threads))
4237 ids (inline (gnus-split-references references))
4239 (while (setq ref (pop ids))
4240 (setq ids (delete ref ids))
4241 (if (not (setq gid (gnus-gethash ref idhashtb)))
4243 (gnus-sethash ref id idhashtb)
4244 (gnus-sethash id threads thhashtb))
4245 (setq gthread (gnus-gethash gid thhashtb))
4247 ;; We enter a dummy root into the thread, if we
4248 ;; haven't done that already.
4249 (unless (stringp (caar gthread))
4250 (setcar gthread (list (mail-header-subject (caar gthread))
4252 ;; We add this new gathered thread to this gathered
4254 (setcdr (car gthread)
4255 (nconc (cdar gthread) (list (car threads)))))
4256 ;; Add it into the thread hash table.
4257 (gnus-sethash id gthread thhashtb)
4259 ;; Remove it from the list of threads.
4260 (setcdr prev (cdr threads))
4261 (setq threads prev))))
4263 (setq threads (cdr threads)))
4266 (defun gnus-sort-gathered-threads (threads)
4267 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4268 (let ((result threads))
4270 (when (stringp (caar threads))
4271 (setcdr (car threads)
4272 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4273 (setq threads (cdr threads)))
4276 (defun gnus-thread-loop-p (root thread)
4277 "Say whether ROOT is in THREAD."
4278 (let ((stack (list thread))
4281 (while (setq thread (pop stack))
4282 (setq th (cdr thread))
4284 (not (eq (caar th) root)))
4287 ;; We have found a loop.
4289 (setcdr thread (delq (car th) (cdr thread)))
4290 (if (boundp (setq ref-dep (intern "none"
4291 gnus-newsgroup-dependencies)))
4292 (setcdr (symbol-value ref-dep)
4293 (nconc (cdr (symbol-value ref-dep))
4295 (set ref-dep (list nil (car th))))
4298 ;; Push all the subthreads onto the stack.
4299 (push (cdr thread) stack)))
4302 (defun gnus-make-threads ()
4303 "Go through the dependency hashtb and find the roots. Return all threads."
4305 (while (catch 'infloop
4308 ;; Deal with self-referencing References loops.
4309 (when (and (car (symbol-value refs))
4316 (car (symbol-value refs)) thread))
4317 (cdr (symbol-value refs)))))))
4320 (unless (car (symbol-value refs))
4321 ;; These threads do not refer back to any other
4322 ;; articles, so they're roots.
4323 (setq threads (append (cdr (symbol-value refs)) threads))))
4324 gnus-newsgroup-dependencies)))
4327 ;; Build the thread tree.
4328 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4329 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4331 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4332 if it was already present.
4334 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4335 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4336 Message-IDs will be renamed to a unique Message-ID before being
4339 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4340 (let* ((id (mail-header-id header))
4341 (id-dep (and id (intern id dependencies)))
4342 parent-id ref ref-dep ref-header replaced)
4343 ;; Enter this `header' in the `dependencies' table.
4347 ;; The first two cases do the normal part: enter a new `header'
4348 ;; in the `dependencies' table.
4349 ((not (boundp id-dep))
4350 (set id-dep (list header)))
4351 ((null (car (symbol-value id-dep)))
4352 (setcar (symbol-value id-dep) header))
4354 ;; From here the `header' was already present in the
4355 ;; `dependencies' table.
4357 ;; Overrides an existing entry;
4358 ;; just set the header part of the entry.
4359 (setcar (symbol-value id-dep) header)
4362 ;; Renames the existing `header' to a unique Message-ID.
4363 ((not gnus-summary-ignore-duplicates)
4364 ;; An article with this Message-ID has already been seen.
4365 ;; We rename the Message-ID.
4366 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4368 (mail-header-set-id header id))
4370 ;; The last case ignores an existing entry, except it adds any
4371 ;; additional Xrefs (in case the two articles came from different
4373 ;; Also sets `header' to `nil' meaning that the `dependencies'
4374 ;; table was *not* modified.
4376 (mail-header-set-xref
4377 (car (symbol-value id-dep))
4378 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4380 (or (mail-header-xref header) "")))
4383 (when (and header (not replaced))
4384 ;; First check that we are not creating a References loop.
4385 (setq parent-id (gnus-parent-id (mail-header-references header)))
4386 (setq ref parent-id)
4388 (setq ref-dep (intern-soft ref dependencies))
4390 (setq ref-header (car (symbol-value ref-dep))))
4391 (if (string= id ref)
4392 ;; Yuk! This is a reference loop. Make the article be a
4395 (mail-header-set-references (car (symbol-value id-dep)) "none")
4397 (setq parent-id nil))
4398 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4399 (setq ref-dep (intern (or parent-id "none") dependencies))
4400 (if (boundp ref-dep)
4401 (setcdr (symbol-value ref-dep)
4402 (nconc (cdr (symbol-value ref-dep))
4403 (list (symbol-value id-dep))))
4404 (set ref-dep (list nil (symbol-value id-dep)))))
4407 (defun gnus-extract-message-id-from-in-reply-to (string)
4408 (if (string-match "<[^>]+>" string)
4409 (substring string (match-beginning 0) (match-end 0))
4412 (defun gnus-build-sparse-threads ()
4413 (let ((headers gnus-newsgroup-headers)
4414 (mail-parse-charset gnus-newsgroup-charset)
4415 (gnus-summary-ignore-duplicates t)
4416 header references generation relations
4417 subject child end new-child date)
4418 ;; First we create an alist of generations/relations, where
4419 ;; generations is how much we trust the relation, and the relation
4421 (gnus-message 7 "Making sparse threads...")
4423 (nnheader-set-temp-buffer " *gnus sparse threads*")
4424 (while (setq header (pop headers))
4425 (when (and (setq references (mail-header-references header))
4426 (not (string= references "")))
4428 (setq child (mail-header-id header)
4429 subject (mail-header-subject header)
4430 date (mail-header-date header)
4432 (while (search-backward ">" nil t)
4433 (setq end (1+ (point)))
4434 (when (search-backward "<" nil t)
4435 (setq new-child (buffer-substring (point) end))
4436 (push (list (incf generation)
4437 child (setq child new-child)
4441 (push (list (1+ generation) child nil subject) relations))
4443 (kill-buffer (current-buffer)))
4444 ;; Sort over trustworthiness.
4445 (dolist (relation (sort relations 'car-less-than-car))
4446 (when (gnus-dependencies-add-header
4447 (make-full-mail-header
4448 gnus-reffed-article-number
4449 (nth 3 relation) "" (or (nth 4 relation) "")
4451 (or (nth 2 relation) "") 0 0 "")
4452 gnus-newsgroup-dependencies nil)
4453 (push gnus-reffed-article-number gnus-newsgroup-limit)
4454 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4455 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4456 gnus-newsgroup-reads)
4457 (decf gnus-reffed-article-number)))
4458 (gnus-message 7 "Making sparse threads...done")))
4460 (defun gnus-build-old-threads ()
4461 ;; Look at all the articles that refer back to old articles, and
4462 ;; fetch the headers for the articles that aren't there. This will
4463 ;; build complete threads - if the roots haven't been expired by the
4465 (let ((mail-parse-charset gnus-newsgroup-charset)
4469 (when (not (car (symbol-value refs)))
4470 (setq heads (cdr (symbol-value refs)))
4472 (if (memq (mail-header-number (caar heads))
4473 gnus-newsgroup-dormant)
4474 (setq heads (cdr heads))
4475 (setq id (symbol-name refs))
4476 (while (and (setq id (gnus-build-get-header id))
4477 (not (car (gnus-id-to-thread id)))))
4478 (setq heads nil)))))
4479 gnus-newsgroup-dependencies)))
4481 (defsubst gnus-remove-odd-characters (string)
4482 "Translate STRING into something that doesn't contain weird characters."
4483 (mm-subst-char-in-string
4485 (mm-subst-char-in-string ?\n ?\- string t) t))
4487 ;; This function has to be called with point after the article number
4488 ;; on the beginning of the line.
4489 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4490 (let ((eol (point-at-eol))
4491 (buffer (current-buffer))
4492 header references in-reply-to)
4494 ;; overview: [num subject from date id refs chars lines misc]
4497 (narrow-to-region (point) eol)
4502 (make-full-mail-header
4504 (condition-case () ; subject
4505 (gnus-remove-odd-characters
4506 (funcall gnus-decode-encoded-word-function
4507 (setq x (nnheader-nov-field))))
4509 (condition-case () ; from
4510 (gnus-remove-odd-characters
4511 (funcall gnus-decode-encoded-address-function
4512 (setq x (nnheader-nov-field))))
4514 (nnheader-nov-field) ; date
4515 (nnheader-nov-read-message-id number) ; id
4516 (setq references (nnheader-nov-field)) ; refs
4517 (nnheader-nov-read-integer) ; chars
4518 (nnheader-nov-read-integer) ; lines
4520 (if (looking-at "Xref: ")
4521 (goto-char (match-end 0)))
4522 (nnheader-nov-field)) ; Xref
4523 (nnheader-nov-parse-extra)))) ; extra
4527 (when (and (string= references "")
4528 (setq in-reply-to (mail-header-extra header))
4529 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4530 (mail-header-set-references
4531 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4533 (when gnus-alter-header-function
4534 (funcall gnus-alter-header-function header))
4535 (gnus-dependencies-add-header header dependencies force-new)))
4537 (defun gnus-build-get-header (id)
4538 "Look through the buffer of NOV lines and find the header to ID.
4539 Enter this line into the dependencies hash table, and return
4540 the id of the parent article (if any)."
4541 (let ((deps gnus-newsgroup-dependencies)
4544 (with-current-buffer nntp-server-buffer
4545 (let ((case-fold-search nil))
4546 (goto-char (point-min))
4547 (while (and (not found)
4548 (search-forward id nil t))
4550 (setq found (looking-at
4551 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4552 (regexp-quote id))))
4553 (or found (beginning-of-line 2)))
4557 (setq header (gnus-nov-parse-line
4558 (read (current-buffer)) deps))
4559 (gnus-parent-id (mail-header-references header))))))
4561 (let ((number (mail-header-number header)))
4562 (push number gnus-newsgroup-limit)
4563 (push header gnus-newsgroup-headers)
4564 (if (memq number gnus-newsgroup-unselected)
4566 (setq gnus-newsgroup-unreads
4567 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4569 (setq gnus-newsgroup-unselected
4570 (delq number gnus-newsgroup-unselected)))
4571 (push number gnus-newsgroup-ancient)))))))
4573 (defun gnus-build-all-threads ()
4574 "Read all the headers."
4575 (let ((gnus-summary-ignore-duplicates t)
4576 (mail-parse-charset gnus-newsgroup-charset)
4577 (dependencies gnus-newsgroup-dependencies)
4579 (with-current-buffer nntp-server-buffer
4580 (let ((case-fold-search nil))
4581 (goto-char (point-min))
4584 (setq article (read (current-buffer))
4585 header (gnus-nov-parse-line article dependencies t)))
4587 (with-current-buffer gnus-summary-buffer
4588 (push header gnus-newsgroup-headers)
4589 (if (memq (setq article (mail-header-number header))
4590 gnus-newsgroup-unselected)
4592 (setq gnus-newsgroup-unreads
4593 (gnus-add-to-sorted-list
4594 gnus-newsgroup-unreads article))
4595 (setq gnus-newsgroup-unselected
4596 (delq article gnus-newsgroup-unselected)))
4597 (push article gnus-newsgroup-ancient)))
4598 (forward-line 1)))))))
4600 (defun gnus-summary-update-article-line (article header)
4601 "Update the line for ARTICLE using HEADER."
4602 (let* ((id (mail-header-id header))
4603 (thread (gnus-id-to-thread id)))
4605 (error "Article in no thread"))
4606 ;; Update the thread.
4607 (setcar thread header)
4608 (gnus-summary-goto-subject article)
4609 (let* ((datal (gnus-data-find-list article))
4611 (inhibit-read-only t)
4612 (level (gnus-summary-thread-level)))
4614 (let ((inserted (- (point)
4616 (gnus-summary-insert-line
4618 (memq article gnus-newsgroup-undownloaded)
4619 (gnus-article-mark article)
4620 (memq article gnus-newsgroup-replied)
4621 (memq article gnus-newsgroup-expirable)
4622 ;; Only insert the Subject string when it's different
4623 ;; from the previous Subject string.
4628 (mail-header-subject
4631 (gnus-data-find-list
4633 (gnus-data-list t)))))
4634 ;; Error on the side of excessive subjects.
4636 (mail-header-subject header)))
4638 (mail-header-subject header))
4639 nil (cdr (assq article gnus-newsgroup-scored))
4640 (memq article gnus-newsgroup-processable))
4643 (gnus-data-update-list
4645 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4647 (defun gnus-summary-update-article (article &optional iheader)
4648 "Update ARTICLE in the summary buffer."
4649 (set-buffer gnus-summary-buffer)
4650 (let* ((header (gnus-summary-article-header article))
4651 (id (mail-header-id header))
4652 (data (gnus-data-find article))
4653 (thread (gnus-id-to-thread id))
4654 (references (mail-header-references header))
4658 (when (and references
4659 (not (equal "" references)))
4662 (inhibit-read-only t)
4668 (delq thread parent)))
4669 (if (gnus-summary-insert-subject id header)
4670 ;; Set the (possibly) new article number in the data structure.
4671 (gnus-data-set-number data (gnus-id-to-article id))
4675 (defun gnus-rebuild-thread (id &optional line)
4676 "Rebuild the thread containing ID.
4677 If LINE, insert the rebuilt thread starting on line LINE."
4678 (let ((inhibit-read-only t)
4679 old-pos current thread data)
4680 (if (not gnus-show-threads)
4681 (setq thread (list (car (gnus-id-to-thread id))))
4682 ;; Get the thread this article is part of.
4683 (setq thread (gnus-remove-thread id)))
4684 (setq old-pos (point-at-bol))
4685 (setq current (save-excursion
4686 (and (re-search-backward "[\r\n]" nil t)
4687 (gnus-summary-article-number))))
4688 ;; If this is a gathered thread, we have to go some re-gathering.
4689 (when (stringp (car thread))
4690 (let ((subject (car thread))
4692 (setq thread (cdr thread))
4694 (unless (memq (setq thr (gnus-id-to-thread
4696 (mail-header-id (caar thread)))))
4699 (setq thread (cdr thread)))
4700 ;; We now have all (unique) roots.
4701 (if (= (length roots) 1)
4702 ;; All the loose roots are now one solid root.
4703 (setq thread (car roots))
4704 (setq thread (cons subject (gnus-sort-threads roots))))))
4706 ;; We then insert this thread into the summary buffer.
4708 (goto-char (point-min))
4709 (forward-line (1- line)))
4710 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4711 (if gnus-show-threads
4712 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4713 (gnus-summary-prepare-unthreaded thread))
4714 (setq data (nreverse gnus-newsgroup-data))
4715 (setq threads gnus-newsgroup-threads))
4716 ;; We splice the new data into the data structure.
4717 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4718 ;;!!! then we want to insert at the beginning of the buffer.
4719 ;;!!! That happens to be true with Gnus now, but that may
4720 ;;!!! change in the future. Perhaps.
4721 (gnus-data-enter-list
4722 (if line nil current) data (- (point) old-pos))
4723 (setq gnus-newsgroup-threads
4724 (nconc threads gnus-newsgroup-threads))
4725 (gnus-data-compute-positions))))
4727 (defun gnus-number-to-header (number)
4728 "Return the header for article NUMBER."
4729 (let ((headers gnus-newsgroup-headers))
4731 (not (= number (mail-header-number (car headers)))))
4736 (defun gnus-parent-headers (in-headers &optional generation)
4737 "Return the headers of the GENERATIONth parent of HEADERS."
4739 (setq generation 1))
4741 (headers in-headers)
4744 (not (zerop generation))
4745 (setq references (mail-header-references headers)))
4746 (setq headers (if (and references
4747 (setq parent (gnus-parent-id references)))
4748 (car (gnus-id-to-thread parent))
4751 (and (not (eq headers in-headers))
4754 (defun gnus-id-to-thread (id)
4755 "Return the (sub-)thread where ID appears."
4756 (gnus-gethash id gnus-newsgroup-dependencies))
4758 (defun gnus-id-to-article (id)
4759 "Return the article number of ID."
4760 (let ((thread (gnus-id-to-thread id)))
4763 (mail-header-number (car thread)))))
4765 (defun gnus-id-to-header (id)
4766 "Return the article headers of ID."
4767 (car (gnus-id-to-thread id)))
4769 (defun gnus-article-displayed-root-p (article)
4770 "Say whether ARTICLE is a root(ish) article."
4771 (let ((level (gnus-summary-thread-level article))
4772 (refs (mail-header-references (gnus-summary-article-header article)))
4778 ((null (gnus-parent-id refs)) t)
4780 (null (setq particle (gnus-id-to-article
4781 (gnus-parent-id refs))))
4782 (null (gnus-summary-thread-level particle)))))))
4784 (defun gnus-root-id (id)
4785 "Return the id of the root of the thread where ID appears."
4787 (while (and id (setq prev (car (gnus-id-to-thread id))))
4789 id (gnus-parent-id (mail-header-references prev))))
4792 (defun gnus-articles-in-thread (thread)
4793 "Return the list of articles in THREAD."
4794 (cons (mail-header-number (car thread))
4795 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4797 (defun gnus-remove-thread (id &optional dont-remove)
4798 "Remove the thread that has ID in it."
4799 (let (headers thread last-id)
4800 ;; First go up in this thread until we find the root.
4801 (setq last-id (gnus-root-id id)
4802 headers (message-flatten-list (gnus-id-to-thread last-id)))
4803 ;; We have now found the real root of this thread. It might have
4804 ;; been gathered into some loose thread, so we have to search
4805 ;; through the threads to find the thread we wanted.
4806 (let ((threads gnus-newsgroup-threads)
4809 (setq sub (car threads))
4810 (if (stringp (car sub))
4811 ;; This is a gathered thread, so we look at the roots
4812 ;; below it to find whether this article is in this
4815 (setq sub (cdr sub))
4817 (when (member (caar sub) headers)
4818 (setq thread (car threads)
4821 (setq sub (cdr sub))))
4822 ;; It's an ordinary thread, so we check it.
4823 (when (eq (car sub) (car headers))
4826 (setq threads (cdr threads)))
4827 ;; If this article is in no thread, then it's a root.
4830 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4831 (setq thread (gnus-id-to-thread last-id)))
4834 thread ; We return this thread.
4836 (if (stringp (car thread))
4838 ;; If we use dummy roots, then we have to remove the
4839 ;; dummy root as well.
4840 (when (eq gnus-summary-make-false-root 'dummy)
4841 ;; We go to the dummy root by going to
4842 ;; the first sub-"thread", and then one line up.
4843 (gnus-summary-goto-article
4844 (mail-header-number (caadr thread)))
4847 (gnus-data-compute-positions))
4848 (setq thread (cdr thread))
4850 (gnus-remove-thread-1 (car thread))
4851 (setq thread (cdr thread))))
4852 (gnus-remove-thread-1 thread))))))))
4854 (defun gnus-remove-thread-1 (thread)
4855 "Remove the thread THREAD recursively."
4856 (let ((number (mail-header-number (pop thread)))
4858 (setq thread (reverse thread))
4860 (gnus-remove-thread-1 (pop thread)))
4861 (when (setq d (gnus-data-find number))
4862 (goto-char (gnus-data-pos d))
4863 (gnus-summary-show-thread)
4869 (gnus-delete-line)))))))
4871 (defun gnus-sort-threads-recursive (threads func)
4872 (sort (mapcar (lambda (thread)
4875 (gnus-sort-threads-recursive (cdr thread) func))))
4878 (defun gnus-sort-threads-loop (threads func)
4879 (let* ((superthread (cons nil threads))
4880 (stack (list (cons superthread threads)))
4881 remaining-threads thread)
4883 (setq remaining-threads (cdr (car stack)))
4884 (if remaining-threads
4885 (progn (setq thread (car remaining-threads))
4886 (setcdr (car stack) (cdr remaining-threads))
4888 (push (cons thread (cdr thread)) stack)))
4889 (setq thread (caar stack))
4890 (setcdr thread (sort (cdr thread) func))
4894 (defun gnus-sort-threads (threads)
4896 (if (not gnus-thread-sort-functions)
4898 (gnus-message 8 "Sorting threads...")
4901 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4902 (gnus-sort-threads-recursive
4903 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4904 ;; Even after binding max-lisp-eval-depth, the recursive
4905 ;; sorter might fail for very long threads. In that case,
4906 ;; try using a (less well-tested) non-recursive sorter.
4907 (error (gnus-message 9 "Sorting threads with loop...")
4908 (gnus-sort-threads-loop
4909 threads (gnus-make-sort-function
4910 gnus-thread-sort-functions))))
4911 (gnus-message 8 "Sorting threads...done"))))
4913 (defun gnus-sort-articles (articles)
4915 (when gnus-article-sort-functions
4916 (gnus-message 7 "Sorting articles...")
4918 (setq gnus-newsgroup-headers
4919 (sort articles (gnus-make-sort-function
4920 gnus-article-sort-functions)))
4921 (gnus-message 7 "Sorting articles...done"))))
4923 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4924 (defmacro gnus-thread-header (thread)
4925 "Return header of first article in THREAD.
4926 Note that THREAD must never, ever be anything else than a variable -
4927 using some other form will lead to serious barfage."
4928 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4929 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4930 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4933 (defsubst gnus-article-sort-by-number (h1 h2)
4934 "Sort articles by article number."
4935 (< (mail-header-number h1)
4936 (mail-header-number h2)))
4938 (defun gnus-thread-sort-by-number (h1 h2)
4939 "Sort threads by root article number."
4940 (gnus-article-sort-by-number
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4943 (defsubst gnus-article-sort-by-random (h1 h2)
4944 "Sort articles randomly."
4947 (defun gnus-thread-sort-by-random (h1 h2)
4948 "Sort threads randomly."
4949 (gnus-article-sort-by-random
4950 (gnus-thread-header h1) (gnus-thread-header h2)))
4952 (defsubst gnus-article-sort-by-lines (h1 h2)
4953 "Sort articles by article Lines header."
4954 (< (mail-header-lines h1)
4955 (mail-header-lines h2)))
4957 (defun gnus-thread-sort-by-lines (h1 h2)
4958 "Sort threads by root article Lines header."
4959 (gnus-article-sort-by-lines
4960 (gnus-thread-header h1) (gnus-thread-header h2)))
4962 (defsubst gnus-article-sort-by-chars (h1 h2)
4963 "Sort articles by octet length."
4964 (< (mail-header-chars h1)
4965 (mail-header-chars h2)))
4967 (defun gnus-thread-sort-by-chars (h1 h2)
4968 "Sort threads by root article octet length."
4969 (gnus-article-sort-by-chars
4970 (gnus-thread-header h1) (gnus-thread-header h2)))
4972 (defsubst gnus-article-sort-by-author (h1 h2)
4973 "Sort articles by root author."
4975 (let ((extract (funcall
4976 gnus-extract-address-components
4977 (mail-header-from h1))))
4978 (or (car extract) (cadr extract) ""))
4979 (let ((extract (funcall
4980 gnus-extract-address-components
4981 (mail-header-from h2))))
4982 (or (car extract) (cadr extract) ""))))
4984 (defun gnus-thread-sort-by-author (h1 h2)
4985 "Sort threads by root author."
4986 (gnus-article-sort-by-author
4987 (gnus-thread-header h1) (gnus-thread-header h2)))
4989 (defsubst gnus-article-sort-by-recipient (h1 h2)
4990 "Sort articles by recipient."
4992 (let ((extract (funcall
4993 gnus-extract-address-components
4994 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4995 (or (car extract) (cadr extract)))
4996 (let ((extract (funcall
4997 gnus-extract-address-components
4998 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4999 (or (car extract) (cadr extract)))))
5001 (defun gnus-thread-sort-by-recipient (h1 h2)
5002 "Sort threads by root recipient."
5003 (gnus-article-sort-by-recipient
5004 (gnus-thread-header h1) (gnus-thread-header h2)))
5006 (defsubst gnus-article-sort-by-subject (h1 h2)
5007 "Sort articles by root subject."
5009 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5010 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5012 (defun gnus-thread-sort-by-subject (h1 h2)
5013 "Sort threads by root subject."
5014 (gnus-article-sort-by-subject
5015 (gnus-thread-header h1) (gnus-thread-header h2)))
5017 (defsubst gnus-article-sort-by-date (h1 h2)
5018 "Sort articles by root article date."
5020 (gnus-date-get-time (mail-header-date h1))
5021 (gnus-date-get-time (mail-header-date h2))))
5023 (defun gnus-thread-sort-by-date (h1 h2)
5024 "Sort threads by root article date."
5025 (gnus-article-sort-by-date
5026 (gnus-thread-header h1) (gnus-thread-header h2)))
5028 (defsubst gnus-article-sort-by-score (h1 h2)
5029 "Sort articles by root article score.
5030 Unscored articles will be counted as having a score of zero."
5031 (> (or (cdr (assq (mail-header-number h1)
5032 gnus-newsgroup-scored))
5033 gnus-summary-default-score 0)
5034 (or (cdr (assq (mail-header-number h2)
5035 gnus-newsgroup-scored))
5036 gnus-summary-default-score 0)))
5038 (defun gnus-thread-sort-by-score (h1 h2)
5039 "Sort threads by root article score."
5040 (gnus-article-sort-by-score
5041 (gnus-thread-header h1) (gnus-thread-header h2)))
5043 (defun gnus-thread-sort-by-total-score (h1 h2)
5044 "Sort threads by the sum of all scores in the thread.
5045 Unscored articles will be counted as having a score of zero."
5046 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5048 (defun gnus-thread-total-score (thread)
5049 ;; This function find the total score of THREAD.
5054 (if (stringp (car thread))
5055 (apply gnus-thread-score-function 0
5056 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5057 (gnus-thread-total-score-1 thread)))
5059 (gnus-thread-total-score-1 (list thread)))))
5061 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5062 "Sort articles by number."
5063 (gnus-article-sort-by-number h1 h2))
5065 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5066 "Sort threads such that the thread with the most recently arrived article comes first."
5067 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5069 (defun gnus-thread-highest-number (thread)
5070 "Return the highest article number in THREAD."
5071 (apply 'max (mapcar (lambda (header)
5072 (mail-header-number header))
5073 (message-flatten-list thread))))
5075 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5076 "Sort articles by number."
5077 (gnus-article-sort-by-date h1 h2))
5079 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5080 "Sort threads such that the thread with the most recently dated article comes first."
5081 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5083 ; Since this is called not only to sort the top-level threads, but
5084 ; also in recursive sorts to order the articles within a thread, each
5085 ; article will be processed many times. Thus it speeds things up
5086 ; quite a bit to use gnus-date-get-time, which caches the time value.
5087 (defun gnus-thread-latest-date (thread)
5088 "Return the highest article date in THREAD."
5090 (mapcar (lambda (header) (gnus-float-time
5092 (mail-header-date header))))
5093 (message-flatten-list thread))))
5095 (defun gnus-thread-total-score-1 (root)
5096 ;; This function find the total score of the thread below ROOT.
5097 (setq root (car root))
5098 (apply gnus-thread-score-function
5100 (mapcar 'gnus-thread-total-score
5101 (cdr (gnus-id-to-thread (mail-header-id root))))
5102 (when (> (mail-header-number root) 0)
5103 (list (or (cdr (assq (mail-header-number root)
5104 gnus-newsgroup-scored))
5105 gnus-summary-default-score 0))))
5106 (list gnus-summary-default-score)
5109 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5110 (defvar gnus-tmp-prev-subject nil)
5111 (defvar gnus-tmp-false-parent nil)
5112 (defvar gnus-tmp-root-expunged nil)
5113 (defvar gnus-tmp-dummy-line nil)
5115 (defun gnus-extra-header (type &optional header)
5116 "Return the extra header of TYPE."
5117 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5120 (defvar gnus-tmp-thread-tree-header-string "")
5122 (defcustom gnus-sum-thread-tree-root "> "
5123 "With %B spec, used for the root of a thread.
5124 If nil, use subject instead."
5126 :type '(radio (const :format "%v " nil) string)
5127 :group 'gnus-thread)
5129 (defcustom gnus-sum-thread-tree-false-root "> "
5130 "With %B spec, used for a false root of a thread.
5131 If nil, use subject instead."
5133 :type '(radio (const :format "%v " nil) string)
5134 :group 'gnus-thread)
5136 (defcustom gnus-sum-thread-tree-single-indent ""
5137 "With %B spec, used for a thread with just one message.
5138 If nil, use subject instead."
5140 :type '(radio (const :format "%v " nil) string)
5141 :group 'gnus-thread)
5143 (defcustom gnus-sum-thread-tree-vertical "| "
5144 "With %B spec, used for drawing a vertical line."
5147 :group 'gnus-thread)
5149 (defcustom gnus-sum-thread-tree-indent " "
5150 "With %B spec, used for indenting."
5153 :group 'gnus-thread)
5155 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5156 "With %B spec, used for a leaf with brothers."
5159 :group 'gnus-thread)
5161 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5162 "With %B spec, used for a leaf without brothers."
5165 :group 'gnus-thread)
5167 (defcustom gnus-summary-display-while-building nil
5168 "If non-nil, show and update the summary buffer as it's being built.
5169 If the value is t, update the buffer after every line is inserted. If
5170 the value is an integer (N), update the display every N lines."
5173 :type '(choice (const :tag "off" nil)
5175 (const :tag "frequently" t)))
5177 (defun gnus-summary-prepare-threads (threads)
5178 "Prepare summary buffer from THREADS and indentation LEVEL.
5179 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5180 or a straight list of headers."
5181 (gnus-message 7 "Generating summary...")
5183 (setq gnus-newsgroup-threads threads)
5186 (let ((gnus-tmp-level 0)
5187 (default-score (or gnus-summary-default-score 0))
5188 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5189 (building-line-count gnus-summary-display-while-building)
5190 (building-count (integerp gnus-summary-display-while-building))
5191 thread number subject stack state gnus-tmp-gathered beg-match
5192 new-roots gnus-tmp-new-adopts thread-end simp-subject
5193 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5194 gnus-tmp-replied gnus-tmp-subject-or-nil
5195 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5196 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5197 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5200 (setq gnus-tmp-prev-subject nil
5201 gnus-tmp-thread-tree-header-string "")
5203 (if (vectorp (car threads))
5204 ;; If this is a straight (sic) list of headers, then a
5205 ;; threaded summary display isn't required, so we just create
5206 ;; an unthreaded one.
5207 (gnus-summary-prepare-unthreaded threads)
5209 ;; Do the threaded display.
5211 (if gnus-summary-display-while-building
5212 (switch-to-buffer (buffer-name)))
5213 (while (or threads stack gnus-tmp-new-adopts new-roots)
5215 (if (and (= gnus-tmp-level 0)
5218 (not gnus-tmp-false-parent)
5219 (or gnus-tmp-new-adopts new-roots))
5220 (if gnus-tmp-new-adopts
5221 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5222 thread (list (car gnus-tmp-new-adopts))
5223 gnus-tmp-header (caar thread)
5224 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5226 (setq thread (list (car new-roots))
5227 gnus-tmp-header (caar thread)
5228 new-roots (cdr new-roots))))
5231 ;; If there are some threads, we do them before the
5232 ;; threads on the stack.
5233 (setq thread threads
5234 gnus-tmp-header (caar thread))
5235 ;; There were no current threads, so we pop something off
5237 (setq state (car stack)
5238 gnus-tmp-level (car state)
5239 tree-stack (cadr state)
5240 thread (caddr state)
5242 gnus-tmp-header (caar thread))))
5244 (setq gnus-tmp-false-parent nil)
5245 (setq gnus-tmp-root-expunged nil)
5246 (setq thread-end nil)
5248 (if (stringp gnus-tmp-header)
5249 ;; The header is a dummy root.
5251 ((eq gnus-summary-make-false-root 'adopt)
5252 ;; We let the first article adopt the rest.
5253 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5255 (setq gnus-tmp-gathered
5257 (lambda (h) (mail-header-number (car h)))
5260 (setq thread (cons (list (caar thread)
5263 (setq gnus-tmp-level -1
5264 gnus-tmp-false-parent t))
5265 ((eq gnus-summary-make-false-root 'empty)
5266 ;; We print adopted articles with empty subject fields.
5267 (setq gnus-tmp-gathered
5269 (lambda (h) (mail-header-number (car h)))
5272 (setq gnus-tmp-level -1))
5273 ((eq gnus-summary-make-false-root 'dummy)
5274 ;; We remember that we probably want to output a dummy
5276 (setq gnus-tmp-dummy-line gnus-tmp-header)
5277 (setq gnus-tmp-prev-subject gnus-tmp-header))
5279 ;; We do not make a root for the gathered
5280 ;; sub-threads at all.
5281 (setq gnus-tmp-level -1)))
5283 (setq number (mail-header-number gnus-tmp-header)
5284 subject (mail-header-subject gnus-tmp-header)
5285 simp-subject (gnus-simplify-subject-fully subject))
5288 ;; If the thread has changed subject, we might want to make
5289 ;; this subthread into a root.
5290 ((and (null gnus-thread-ignore-subject)
5291 (not (zerop gnus-tmp-level))
5292 gnus-tmp-prev-subject
5293 (not (string= gnus-tmp-prev-subject simp-subject)))
5294 (setq new-roots (nconc new-roots (list (car thread)))
5296 gnus-tmp-header nil))
5297 ;; If the article lies outside the current limit,
5298 ;; then we do not display it.
5299 ((not (memq number gnus-newsgroup-limit))
5300 (setq gnus-tmp-gathered
5302 (lambda (h) (mail-header-number (car h)))
5305 (setq gnus-tmp-new-adopts (if (cdar thread)
5306 (append gnus-tmp-new-adopts
5308 gnus-tmp-new-adopts)
5310 gnus-tmp-header nil)
5311 (when (zerop gnus-tmp-level)
5312 (setq gnus-tmp-root-expunged t)))
5313 ;; Perhaps this article is to be marked as read?
5314 ((and gnus-summary-mark-below
5315 (< (or (cdr (assq number gnus-newsgroup-scored))
5317 gnus-summary-mark-below)
5318 ;; Don't touch sparse articles.
5319 (not (gnus-summary-article-sparse-p number))
5320 (not (gnus-summary-article-ancient-p number)))
5321 (setq gnus-newsgroup-unreads
5322 (delq number gnus-newsgroup-unreads))
5323 (if gnus-newsgroup-auto-expire
5324 (setq gnus-newsgroup-expirable
5325 (gnus-add-to-sorted-list
5326 gnus-newsgroup-expirable number))
5327 (push (cons number gnus-low-score-mark)
5328 gnus-newsgroup-reads))))
5330 (when gnus-tmp-header
5331 ;; We may have an old dummy line to output before this
5333 (when (and gnus-tmp-dummy-line
5336 (mail-header-subject gnus-tmp-header)))
5337 (gnus-summary-insert-dummy-line
5338 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5339 (setq gnus-tmp-dummy-line nil))
5341 ;; Compute the mark.
5342 (setq gnus-tmp-unread (gnus-article-mark number))
5344 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5345 gnus-tmp-header gnus-tmp-level)
5346 gnus-newsgroup-data)
5348 ;; Actually insert the line.
5350 gnus-tmp-subject-or-nil
5352 ((and gnus-thread-ignore-subject
5353 gnus-tmp-prev-subject
5354 (not (string= gnus-tmp-prev-subject simp-subject)))
5356 ((zerop gnus-tmp-level)
5357 (if (and (eq gnus-summary-make-false-root 'empty)
5358 (memq number gnus-tmp-gathered)
5359 gnus-tmp-prev-subject
5360 (string= gnus-tmp-prev-subject simp-subject))
5361 gnus-summary-same-subject
5363 (t gnus-summary-same-subject)))
5364 (if (and (eq gnus-summary-make-false-root 'adopt)
5365 (= gnus-tmp-level 1)
5366 (memq number gnus-tmp-gathered))
5367 (setq gnus-tmp-opening-bracket ?\<
5368 gnus-tmp-closing-bracket ?\>)
5369 (setq gnus-tmp-opening-bracket ?\[
5370 gnus-tmp-closing-bracket ?\]))
5371 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5372 (gnus-make-thread-indent-array
5373 (max (* 2 (length gnus-thread-indent-array))
5376 gnus-tmp-indentation
5377 (aref gnus-thread-indent-array gnus-tmp-level)
5378 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5379 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5380 gnus-summary-default-score 0)
5382 (if (or (null gnus-summary-default-score)
5383 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5384 gnus-summary-zcore-fuzz))
5386 (if (< gnus-tmp-score gnus-summary-default-score)
5387 gnus-score-below-mark gnus-score-over-mark))
5389 (cond ((memq number gnus-newsgroup-processable)
5391 ((memq number gnus-newsgroup-cached)
5393 ((memq number gnus-newsgroup-replied)
5395 ((memq number gnus-newsgroup-forwarded)
5396 gnus-forwarded-mark)
5397 ((memq number gnus-newsgroup-saved)
5399 ((memq number gnus-newsgroup-unseen)
5403 (cond ((memq number gnus-newsgroup-undownloaded)
5404 gnus-undownloaded-mark)
5405 (gnus-newsgroup-agentized
5406 gnus-downloaded-mark)
5409 gnus-tmp-from (mail-header-from gnus-tmp-header)
5412 ((string-match "<[^>]+> *$" gnus-tmp-from)
5413 (setq beg-match (match-beginning 0))
5414 (or (and (string-match "^\".+\"" gnus-tmp-from)
5415 (substring gnus-tmp-from 1 (1- (match-end 0))))
5416 (substring gnus-tmp-from 0 beg-match)))
5417 ((string-match "(.+)" gnus-tmp-from)
5418 (substring gnus-tmp-from
5419 (1+ (match-beginning 0)) (1- (match-end 0))))
5423 gnus-tmp-thread-tree-header-string
5425 ((not gnus-show-threads) "")
5426 ((zerop gnus-tmp-level)
5427 (cond ((cdar thread)
5428 (or gnus-sum-thread-tree-root subject))
5429 (gnus-tmp-new-adopts
5430 (or gnus-sum-thread-tree-false-root subject))
5432 (or gnus-sum-thread-tree-single-indent subject))))
5434 (concat (apply 'concat
5435 (mapcar (lambda (item)
5437 gnus-sum-thread-tree-vertical
5438 gnus-sum-thread-tree-indent))
5439 (cdr (reverse tree-stack))))
5441 gnus-sum-thread-tree-leaf-with-other
5442 gnus-sum-thread-tree-single-leaf)))))
5443 (when (string= gnus-tmp-name "")
5444 (setq gnus-tmp-name gnus-tmp-from))
5445 (unless (numberp gnus-tmp-lines)
5446 (setq gnus-tmp-lines -1))
5447 (if (= gnus-tmp-lines -1)
5448 (setq gnus-tmp-lines "?")
5449 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5450 (gnus-put-text-property
5452 (progn (eval gnus-summary-line-format-spec) (point))
5453 'gnus-number number)
5456 (gnus-summary-highlight-line)
5457 (when gnus-summary-update-hook
5458 (gnus-run-hooks 'gnus-summary-update-hook))
5461 (setq gnus-tmp-prev-subject simp-subject)))
5463 (when (nth 1 thread)
5464 (push (list (max 0 gnus-tmp-level)
5465 (copy-sequence tree-stack)
5468 (push (if (nth 1 thread) 1 0) tree-stack)
5469 (incf gnus-tmp-level)
5470 (setq threads (if thread-end nil (cdar thread)))
5471 (if gnus-summary-display-while-building
5474 ;; use a set frequency
5475 (setq building-line-count (1- building-line-count))
5476 (when (= building-line-count 0)
5478 (setq building-line-count
5479 gnus-summary-display-while-building)))
5483 (setq gnus-tmp-level 0)))))
5484 (gnus-message 7 "Generating summary...done"))
5486 (defun gnus-summary-prepare-unthreaded (headers)
5487 "Generate an unthreaded summary buffer based on HEADERS."
5488 (let (header number mark)
5493 ;; We may have to root out some bad articles...
5494 (when (memq (setq number (mail-header-number
5495 (setq header (pop headers))))
5496 gnus-newsgroup-limit)
5497 ;; Mark article as read when it has a low score.
5498 (when (and gnus-summary-mark-below
5499 (< (or (cdr (assq number gnus-newsgroup-scored))
5500 gnus-summary-default-score 0)
5501 gnus-summary-mark-below)
5502 (not (gnus-summary-article-ancient-p number)))
5503 (setq gnus-newsgroup-unreads
5504 (delq number gnus-newsgroup-unreads))
5505 (if gnus-newsgroup-auto-expire
5506 (push number gnus-newsgroup-expirable)
5507 (push (cons number gnus-low-score-mark)
5508 gnus-newsgroup-reads)))
5510 (setq mark (gnus-article-mark number))
5511 (push (gnus-data-make number mark (1+ (point)) header 0)
5512 gnus-newsgroup-data)
5513 (gnus-summary-insert-line
5515 (memq number gnus-newsgroup-undownloaded)
5516 mark (memq number gnus-newsgroup-replied)
5517 (memq number gnus-newsgroup-expirable)
5518 (mail-header-subject header) nil
5519 (cdr (assq number gnus-newsgroup-scored))
5520 (memq number gnus-newsgroup-processable))))))
5522 (defun gnus-group-get-list-identifiers (group)
5523 "Get list identifier regexp for GROUP."
5524 (or (gnus-parameter-list-identifier group)
5525 (if (consp gnus-list-identifiers)
5526 (mapconcat 'identity gnus-list-identifiers " *\\|")
5527 gnus-list-identifiers)))
5529 (defun gnus-summary-remove-list-identifiers ()
5530 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5531 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5534 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5535 (dolist (header gnus-newsgroup-headers)
5536 (setq subject (mail-header-subject header)
5538 (while (string-match regexp subject)
5540 (concat (substring subject 0 (match-beginning 1))
5541 (substring subject (match-end 0)))
5544 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5546 (concat (substring subject 0 (match-beginning 1))
5547 (substring subject (match-end 1)))))
5548 (mail-header-set-subject header subject))))))
5550 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5551 "Fetch headers of ARTICLES."
5552 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5553 (gnus-message 7 "Fetching headers for %s..." name)
5556 (setq gnus-headers-retrieved-by
5557 (gnus-retrieve-headers
5558 articles gnus-newsgroup-name
5560 ;; We might want to fetch old headers, but
5561 ;; not if there is only 1 article.
5563 (not (eq gnus-fetch-old-headers 'some))
5564 (not (numberp gnus-fetch-old-headers)))
5565 (> (length articles) 1))
5566 gnus-fetch-old-headers)))))
5567 (gnus-get-newsgroup-headers-xover
5568 articles force-new dependencies gnus-newsgroup-name t)
5569 (gnus-get-newsgroup-headers dependencies force-new))
5570 (gnus-message 7 "Fetching headers for %s...done" name))))
5572 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5573 "Select newsgroup GROUP.
5574 If READ-ALL is non-nil, all articles in the group are selected.
5575 If SELECT-ARTICLES, only select those articles from GROUP."
5576 (let* ((entry (gnus-group-entry group))
5577 ;;!!! Dirty hack; should be removed.
5578 (gnus-summary-ignore-duplicates
5579 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5581 gnus-summary-ignore-duplicates))
5582 (info (nth 2 entry))
5583 charset articles fetched-articles cached)
5585 (unless (gnus-check-server
5586 (set (make-local-variable 'gnus-current-select-method)
5587 (gnus-find-method-for-group group)))
5588 (error "Couldn't open server"))
5589 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5591 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5592 (gnus-activate-group group) ; Or we can activate it...
5593 (progn ; Or we bug out.
5594 (when (equal major-mode 'gnus-summary-mode)
5595 (gnus-kill-buffer (current-buffer)))
5597 "Couldn't activate group %s: %s"
5598 (mm-decode-coding-string group charset)
5599 (mm-decode-coding-string (gnus-status-message group) charset))))
5601 (unless (gnus-request-group group t)
5602 (when (equal major-mode 'gnus-summary-mode)
5603 (gnus-kill-buffer (current-buffer)))
5604 (error "Couldn't request group %s: %s"
5605 (mm-decode-coding-string group charset)
5606 (mm-decode-coding-string (gnus-status-message group) charset)))
5608 (when (and gnus-agent
5609 (gnus-active group))
5610 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5612 (setq gnus-summary-use-undownloaded-faces
5613 (gnus-agent-find-parameter
5615 'agent-enable-undownloaded-faces)))
5617 (setq gnus-newsgroup-name group
5618 gnus-newsgroup-unselected nil
5619 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5621 (let ((display (gnus-group-find-parameter group 'display)))
5622 (setq gnus-newsgroup-display
5624 ((not (zerop (or (car-safe read-all) 0)))
5625 ;; The user entered the group with C-u SPC/RET, let's show
5631 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5633 ;; The following is probably the "correct" solution, but
5634 ;; it makes Gnus fetch all headers and then limit the
5635 ;; articles (which is slow), so instead we hack the
5636 ;; select-articles parameter instead. -- Simon Josefsson
5639 ;; (gnus-byte-compile
5640 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5642 (setq select-articles
5643 (gnus-uncompress-range
5644 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5648 (cdr (gnus-active group)))))
5653 (gnus-summary-setup-default-charset)
5655 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5656 (when (gnus-virtual-group-p group)
5657 (setq cached gnus-newsgroup-cached))
5659 (setq gnus-newsgroup-unreads
5660 (gnus-sorted-ndifference
5661 (gnus-sorted-ndifference gnus-newsgroup-unreads
5662 gnus-newsgroup-marked)
5663 gnus-newsgroup-dormant))
5665 (setq gnus-newsgroup-processable nil)
5667 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5669 ;; Adjust and set lists of article marks.
5671 (gnus-adjust-marked-articles info))
5672 (if (setq articles select-articles)
5673 (setq gnus-newsgroup-unselected
5674 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5675 (setq articles (gnus-articles-to-read group read-all)))
5679 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5681 ((eq articles 0) nil)
5683 ;; Init the dependencies hash table.
5684 (setq gnus-newsgroup-dependencies
5685 (gnus-make-hashtable (length articles)))
5686 (if (gnus-buffer-live-p gnus-group-buffer)
5687 (gnus-set-global-variables)
5688 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5689 ;; Retrieve the headers and read them in.
5691 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5693 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5695 (setq gnus-newsgroup-cached cached))
5697 ;; Suppress duplicates?
5698 (when gnus-suppress-duplicates
5699 (gnus-dup-suppress-articles))
5701 ;; Set the initial limit.
5702 (setq gnus-newsgroup-limit (copy-sequence articles))
5703 ;; Remove canceled articles from the list of unread articles.
5704 (setq fetched-articles
5705 (mapcar (lambda (headers) (mail-header-number headers))
5706 gnus-newsgroup-headers))
5707 (setq gnus-newsgroup-articles fetched-articles)
5708 (setq gnus-newsgroup-unreads
5709 (gnus-sorted-nintersection
5710 gnus-newsgroup-unreads fetched-articles))
5711 (gnus-compute-unseen-list)
5713 ;; Removed marked articles that do not exist.
5714 (gnus-update-missing-marks
5715 (gnus-sorted-difference articles fetched-articles))
5716 ;; We might want to build some more threads first.
5717 (when (and gnus-fetch-old-headers
5718 (eq gnus-headers-retrieved-by 'nov))
5719 (if (eq gnus-fetch-old-headers 'invisible)
5720 (gnus-build-all-threads)
5721 (gnus-build-old-threads)))
5722 ;; Let the Gnus agent mark articles as read.
5724 (gnus-agent-get-undownloaded-list))
5725 ;; Remove list identifiers from subject
5726 (gnus-summary-remove-list-identifiers)
5727 ;; Check whether auto-expire is to be done in this group.
5728 (setq gnus-newsgroup-auto-expire
5729 (and (gnus-group-auto-expirable-p group)
5730 (not (gnus-group-read-only-p group))))
5731 ;; Set up the article buffer now, if necessary.
5732 (unless (and gnus-single-article-buffer
5733 (equal gnus-article-buffer "*Article*"))
5734 (gnus-article-setup-buffer))
5735 ;; First and last article in this newsgroup.
5736 (when gnus-newsgroup-headers
5737 (setq gnus-newsgroup-begin
5738 (mail-header-number (car gnus-newsgroup-headers))
5741 (gnus-last-element gnus-newsgroup-headers))))
5742 ;; GROUP is successfully selected.
5743 (or gnus-newsgroup-headers t)))))
5745 (defun gnus-compute-unseen-list ()
5746 ;; The `seen' marks are treated specially.
5747 (if (not gnus-newsgroup-seen)
5748 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5749 (setq gnus-newsgroup-unseen
5750 (gnus-inverse-list-range-intersection
5751 gnus-newsgroup-articles gnus-newsgroup-seen))))
5753 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5755 (defun gnus-summary-display-make-predicate (display)
5756 (require 'gnus-agent)
5757 (when (= (length display) 1)
5758 (setq display (car display)))
5759 (unless gnus-summary-display-cache
5760 (dolist (elem (append '((unread . unread)
5763 gnus-article-mark-lists))
5764 (push (cons (cdr elem)
5765 (gnus-byte-compile ;Why bother?
5766 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5767 gnus-summary-display-cache)))
5768 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5769 (gnus-category-predicate-cache gnus-summary-display-cache))
5770 (gnus-get-predicate display)))
5772 ;; Uses the dynamically bound `gnus-number' variable.
5773 (defvar gnus-number)
5774 (defun gnus-article-marked-p (type &optional article)
5775 (let ((article (or article gnus-number)))
5778 (memq article gnus-newsgroup-marked))
5780 (memq article gnus-newsgroup-spam-marked))
5782 (memq article gnus-newsgroup-unsendable))
5783 ((eq type 'undownload)
5784 (memq article gnus-newsgroup-undownloaded))
5785 ((eq type 'download)
5786 (memq article gnus-newsgroup-downloadable))
5788 (memq article gnus-newsgroup-unreads))
5790 (memq article gnus-newsgroup-reads))
5792 (memq article gnus-newsgroup-dormant) )
5794 (memq article gnus-newsgroup-expirable))
5796 (memq article gnus-newsgroup-replied))
5798 (memq article gnus-newsgroup-killed))
5799 ((eq type 'bookmark)
5800 (assq article gnus-newsgroup-bookmarks))
5802 (assq article gnus-newsgroup-scored))
5804 (memq article gnus-newsgroup-saved))
5806 (memq article gnus-newsgroup-cached))
5808 (memq article gnus-newsgroup-forwarded))
5810 (not (memq article gnus-newsgroup-unseen)))
5813 (defun gnus-articles-to-read (group &optional read-all)
5814 "Find out what articles the user wants to read."
5815 (let* ((only-read-p t)
5817 (gnus-list-range-difference
5818 ;; Select all articles if `read-all' is non-nil, or if there
5819 ;; are no unread articles.
5821 (and (zerop (length gnus-newsgroup-marked))
5822 (zerop (length gnus-newsgroup-unreads)))
5823 ;; Fetch all if the predicate is non-nil.
5824 gnus-newsgroup-display)
5825 ;; We want to select the headers for all the articles in
5826 ;; the group, so we select either all the active
5827 ;; articles in the group, or (if that's nil), the
5828 ;; articles in the cache.
5830 (if gnus-newsgroup-maximum-articles
5831 (let ((active (gnus-active group)))
5832 (gnus-uncompress-range
5833 (cons (max (car active)
5835 gnus-newsgroup-maximum-articles
5838 (gnus-uncompress-range (gnus-active group)))
5839 (gnus-cache-articles-in-group group))
5840 ;; Select only the "normal" subset of articles.
5841 (setq only-read-p nil)
5843 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5844 gnus-newsgroup-unreads))
5845 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5846 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5847 (scored (length scored-list))
5848 (number (length articles))
5849 (marked (+ (length gnus-newsgroup-marked)
5850 (length gnus-newsgroup-dormant)))
5855 ((numberp gnus-newsgroup-display)
5856 gnus-newsgroup-display)
5860 ((and (or (<= scored marked) (= scored number))
5861 (numberp gnus-large-newsgroup)
5862 (> number gnus-large-newsgroup))
5863 (let* ((cursor-in-echo-area nil)
5864 (initial (gnus-parameter-large-newsgroup-initial
5865 gnus-newsgroup-name))
5866 (default (if only-read-p
5867 (or initial gnus-large-newsgroup)
5873 "How many articles from %s (available %d, default %d): "
5874 (gnus-group-decoded-name
5875 (gnus-group-real-name gnus-newsgroup-name))
5878 "How many articles from %s (%d default): "
5879 (gnus-group-decoded-name
5880 (gnus-group-real-name gnus-newsgroup-name))
5884 (number-to-string default))))
5885 (if (string-match "^[ \t]*$" input) number input)))
5886 ((and (> scored marked) (< scored number)
5887 (> (- scored number) 20))
5890 (format "%s %s (%d scored, %d total): "
5891 "How many articles from"
5892 (gnus-group-decoded-name
5893 (gnus-group-real-name gnus-newsgroup-name))
5895 (if (string-match "^[ \t]*$" input)
5899 (message "Quit getting the articles to read")
5901 (setq select (if (stringp select) (string-to-number select) select))
5902 (if (or (null select) (zerop select))
5904 (if (and (not (zerop scored)) (<= (abs select) scored))
5906 (setq articles (sort scored-list '<))
5907 (setq number (length articles)))
5908 (setq articles (copy-sequence articles)))
5910 (when (< (abs select) number)
5912 ;; Select the N oldest articles.
5913 (setcdr (nthcdr (1- (abs select)) articles) nil)
5914 ;; Select the N most recent articles.
5915 (setq articles (nthcdr (- number select) articles))))
5916 (setq gnus-newsgroup-unselected
5917 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5918 (when gnus-alter-articles-to-read-function
5921 (funcall gnus-alter-articles-to-read-function
5922 gnus-newsgroup-name articles)
5926 (defun gnus-killed-articles (killed articles)
5929 (when (inline (gnus-member-of-range (car articles) killed))
5930 (push (car articles) out))
5931 (setq articles (cdr articles)))
5934 (defun gnus-uncompress-marks (marks)
5935 "Uncompress the mark ranges in MARKS."
5936 (let ((uncompressed '(score bookmark))
5939 (if (memq (caar marks) uncompressed)
5940 (push (car marks) out)
5941 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5942 (setq marks (cdr marks)))
5945 (defun gnus-article-mark-to-type (mark)
5946 "Return the type of MARK."
5947 (or (cadr (assq mark gnus-article-special-mark-lists))
5950 (defun gnus-article-unpropagatable-p (mark)
5951 "Return whether MARK should be propagated to back end."
5952 (memq mark gnus-article-unpropagated-mark-lists))
5954 (defun gnus-adjust-marked-articles (info)
5955 "Set all article lists and remove all marks that are no longer valid."
5956 (let* ((marked-lists (gnus-info-marks info))
5957 (active (gnus-active (gnus-info-group info)))
5960 (types gnus-article-mark-lists)
5961 marks var articles article mark mark-type
5963 ;; Hack to avoid adjusting marks for imap.
5964 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5968 (dolist (marks marked-lists)
5969 (setq mark (car marks)
5970 mark-type (gnus-article-mark-to-type mark)
5971 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5972 ;; We set the variable according to the type of the marks list,
5973 ;; and then adjust the marks to a subset of the active articles.
5975 ;; Adjust "simple" lists - compressed yet unsorted
5976 ((eq mark-type 'list)
5977 ;; Simultaneously uncompress and clip to active range
5978 ;; See gnus-uncompress-range for a description of possible marks
5980 (if (not (cadr marks))
5982 (setq articles (if (numberp (cddr marks))
5988 (while (setq article (pop articles))
5989 (cond ((consp article)
5990 (setq bgn (max (car article) min)
5991 end (min (cdr article) max))
5993 (setq l (setcdr l (cons bgn nil))
5995 ((and (<= min article)
5997 (setq l (setcdr l (cons article nil))))))
5998 (set var (cdr lh)))))
6000 ((eq mark-type 'tuple)
6001 (set var (setq articles (cdr marks)))
6002 (when (not (listp (cdr (symbol-value var))))
6003 (set var (list (symbol-value var))))
6004 (when (not (listp (cdr articles)))
6005 (setq articles (list articles)))
6007 (when (or (not (consp (setq article (pop articles))))
6008 (< (car article) min)
6009 (> (car article) max))
6010 (set var (delq article (symbol-value var))))))
6011 ;; Adjust ranges (sloppily).
6012 ((eq mark-type 'range)
6015 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6016 ;; It should be (seen (NUM1 . NUM2)).
6017 (when (numberp (cddr marks))
6018 (setcdr marks (list (cdr marks))))
6019 (setq articles (cdr marks))
6020 (while (and articles
6021 (or (and (consp (car articles))
6022 (> min (cdar articles)))
6023 (and (numberp (car articles))
6024 (> min (car articles)))))
6028 (set var (cdr marks)))))))))
6030 (defun gnus-update-missing-marks (missing)
6031 "Go through the list of MISSING articles and remove them from the mark lists."
6034 ;; Go through all types.
6035 (dolist (elem gnus-article-mark-lists)
6036 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6037 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6038 (when (symbol-value var)
6039 ;; This list has articles. So we delete all missing
6040 ;; articles from it.
6043 (set var (delq (pop m) (symbol-value var))))))))))
6045 (defun gnus-update-marks ()
6046 "Enter the various lists of marked articles into the newsgroup info list."
6047 (let ((types gnus-article-mark-lists)
6048 (info (gnus-get-info gnus-newsgroup-name))
6049 type list newmarked symbol delta-marks)
6051 ;; Add all marks lists to the list of marks lists.
6052 (while (setq type (pop types))
6053 (setq list (symbol-value
6055 (intern (format "gnus-newsgroup-%s" (car type))))))
6058 ;; Get rid of the entries of the articles that have the
6060 (when (and (eq (cdr type) 'score)
6064 (prev (cons nil list))
6067 (if (or (not (consp (car arts)))
6068 (= (cdar arts) gnus-summary-default-score))
6069 (setcdr prev (cdr arts))
6071 (setq arts (cdr arts)))
6072 (setq list (cdr all)))))
6074 (when (eq (cdr type) 'seen)
6075 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6077 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6078 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6080 (when (and (gnus-check-backend-function
6081 'request-set-mark gnus-newsgroup-name)
6082 (not (gnus-article-unpropagatable-p (cdr type))))
6083 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6084 ;; Don't do anything about marks for articles we
6085 ;; didn't actually get any headers for.
6087 (gnus-list-range-intersection
6088 gnus-newsgroup-articles
6089 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6091 (gnus-list-range-intersection
6092 gnus-newsgroup-articles
6093 (gnus-remove-from-range
6094 (gnus-copy-sequence list) old))))
6096 (push (list add 'add (list (cdr type))) delta-marks))
6098 ;; Don't delete marks from outside the active range.
6099 ;; This shouldn't happen, but is a sanity check.
6100 (setq del (gnus-sorted-range-intersection
6101 (gnus-active gnus-newsgroup-name) del))
6102 (push (list del 'del (list (cdr type))) delta-marks))))
6105 (push (cons (cdr type) list) newmarked)))
6108 (unless (gnus-check-group gnus-newsgroup-name)
6109 (error "Can't open server for %s" gnus-newsgroup-name))
6110 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6112 ;; Enter these new marks into the info of the group.
6114 (setcar (nthcdr 3 info) newmarked)
6115 ;; Add the marks lists to the end of the info.
6117 (setcdr (nthcdr 2 info) (list newmarked))))
6119 ;; Cut off the end of the info if there's nothing else there.
6123 (when (nthcdr (decf i) info)
6124 (setcdr (nthcdr i info) nil)))))))
6126 (defun gnus-set-mode-line (where)
6127 "Set the mode line of the article or summary buffers.
6128 If WHERE is `summary', the summary mode line format will be used."
6129 ;; Is this mode line one we keep updated?
6130 (when (and (memq where gnus-updated-mode-lines)
6132 (intern (format "gnus-%s-mode-line-format-spec" where))))
6134 ;; We evaluate this in the summary buffer since these
6135 ;; variables are buffer-local to that buffer.
6136 (with-current-buffer gnus-summary-buffer
6137 ;; We bind all these variables that are used in the `eval' form
6139 (let* ((mformat (symbol-value
6141 (format "gnus-%s-mode-line-format-spec" where))))
6142 (gnus-tmp-group-name (gnus-mode-string-quote
6143 (gnus-group-decoded-name
6144 gnus-newsgroup-name)))
6145 (gnus-tmp-article-number (or gnus-current-article 0))
6146 (gnus-tmp-unread gnus-newsgroup-unreads)
6147 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6148 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6149 (gnus-tmp-unread-and-unselected
6150 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6151 (zerop gnus-tmp-unselected))
6153 ((zerop gnus-tmp-unselected)
6154 (format "{%d more}" gnus-tmp-unread-and-unticked))
6155 (t (format "{%d(+%d) more}"
6156 gnus-tmp-unread-and-unticked
6157 gnus-tmp-unselected))))
6159 (if (and gnus-current-headers
6160 (vectorp gnus-current-headers))
6161 (gnus-mode-string-quote
6162 (mail-header-subject gnus-current-headers))
6164 bufname-length max-len
6165 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6166 (setq mode-string (eval mformat))
6167 (setq bufname-length (if (string-match "%b" mode-string)
6170 (if (eq where 'summary)
6172 (get-buffer gnus-article-buffer))))
6175 (setq max-len (max 4 (if gnus-mode-non-string-length
6177 gnus-mode-non-string-length
6179 (length mode-string))))
6180 ;; We might have to chop a bit of the string off...
6181 (when (> (length mode-string) max-len)
6183 (concat (truncate-string-to-width mode-string (- max-len 3))
6185 ;; Update the mode line.
6186 (setq mode-line-buffer-identification
6187 (gnus-mode-line-buffer-identification (list mode-string)))
6188 (set-buffer-modified-p t))))
6190 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6191 "Go through the HEADERS list and add all Xrefs to a hash table.
6192 The resulting hash table is returned, or nil if no Xrefs were found."
6193 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6194 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6195 (xref-hashtb (gnus-make-hashtable))
6196 start group entry number xrefs header)
6198 (setq header (pop headers))
6199 (when (and (setq xrefs (mail-header-xref header))
6200 (not (memq (setq number (mail-header-number header))
6203 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6204 (setq start (match-end 0))
6205 (setq group (if prefix
6206 (concat prefix (substring xrefs (match-beginning 1)
6208 (substring xrefs (match-beginning 1) (match-end 1))))
6210 (string-to-number (substring xrefs (match-beginning 2)
6212 (if (setq entry (gnus-gethash group xref-hashtb))
6213 (setcdr entry (cons number (cdr entry)))
6214 (gnus-sethash group (cons number nil) xref-hashtb)))))
6215 (and start xref-hashtb)))
6217 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6218 "Look through all the headers and mark the Xrefs as read."
6219 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6220 name info xref-hashtb idlist method nth4)
6221 (with-current-buffer gnus-group-buffer
6222 (when (setq xref-hashtb
6223 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6226 (unless (string= from-newsgroup (setq name (symbol-name group)))
6227 (setq idlist (symbol-value group))
6228 ;; Dead groups are not updated.
6230 (setq info (gnus-get-info name))
6231 (when (stringp (setq nth4 (gnus-info-method info)))
6232 (setq nth4 (gnus-server-to-method nth4))))
6233 ;; Only do the xrefs if the group has the same
6234 ;; select method as the group we have just read.
6235 (or (gnus-methods-equal-p
6236 nth4 (gnus-find-method-for-group from-newsgroup))
6238 (equal nth4 (setq method (gnus-find-method-for-group
6240 (and (equal (car nth4) (car method))
6241 (equal (nth 1 nth4) (nth 1 method))))
6242 gnus-use-cross-reference
6243 (or (not (eq gnus-use-cross-reference t))
6245 ;; Only do cross-references on subscribed
6246 ;; groups, if that is what is wanted.
6247 (<= (gnus-info-level info) gnus-level-subscribed))
6248 (gnus-group-make-articles-read name idlist))))
6251 (defun gnus-compute-read-articles (group articles)
6252 (let* ((entry (gnus-group-entry group))
6253 (info (nth 2 entry))
6254 (active (gnus-active group))
6257 ;; First peel off all invalid article numbers.
6259 (let ((ids articles)
6261 (while (setq id (pop ids))
6262 (when (and first (> id (cdr active)))
6263 ;; We'll end up in this situation in one particular
6264 ;; obscure situation. If you re-scan a group and get
6265 ;; a new article that is cross-posted to a different
6266 ;; group that has not been re-scanned, you might get
6267 ;; crossposted article that has a higher number than
6268 ;; Gnus believes possible. So we re-activate this
6269 ;; group as well. This might mean doing the
6270 ;; crossposting thingy will *increase* the number
6271 ;; of articles in some groups. Tsk, tsk.
6272 (setq active (or (gnus-activate-group group) active)))
6273 (when (or (> id (cdr active))
6274 (< id (car active)))
6275 (setq articles (delq id articles))))))
6276 ;; If the read list is nil, we init it.
6278 (null (gnus-info-read info))
6280 (setq ninfo (cons 1 (1- (car active))))
6281 (setq ninfo (gnus-info-read info)))
6282 ;; Then we add the read articles to the range.
6284 ninfo (setq articles (sort articles '<))))))
6286 (defun gnus-group-make-articles-read (group articles)
6287 "Update the info of GROUP to say that ARTICLES are read."
6289 (entry (gnus-group-entry group))
6290 (info (nth 2 entry))
6291 (active (gnus-active group))
6293 (gnus-method-option-p
6294 (gnus-find-method-for-group group)
6298 ;; Group that Gnus doesn't know exists, but still allow the
6299 ;; backend to set marks.
6301 (gnus-request-set-mark
6302 group (list (list (gnus-compress-sequence (sort articles #'<))
6304 ;; Normal, subscribed groups.
6305 (setq range (gnus-compute-read-articles group articles))
6306 (with-current-buffer gnus-group-buffer
6309 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6310 (gnus-info-set-read ',info ',(gnus-info-read info))
6311 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6313 (gnus-request-set-mark
6314 ,group (list (list ',range 'del '(read)))))
6315 (gnus-group-update-group ,group t))))
6316 ;; Add the read articles to the range.
6317 (gnus-info-set-read info range)
6319 (gnus-request-set-mark group (list (list range 'add '(read)))))
6320 ;; Then we have to re-compute how many unread
6321 ;; articles there are in this group.
6325 (setq num (- (1+ (cdr active)) (car active))))
6326 ((not (listp (cdr range)))
6327 (setq num (- (cdr active) (- (1+ (cdr range))
6331 (if (numberp (car range))
6333 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6334 (setq range (cdr range)))
6335 (setq num (- (cdr active) num))))
6336 ;; Update the number of unread articles.
6338 ;; Update the group buffer.
6339 (unless (gnus-ephemeral-group-p group)
6340 (gnus-group-update-group group t))))))
6342 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6343 (let ((cur nntp-server-buffer)
6346 (with-current-buffer gnus-summary-buffer
6347 gnus-newsgroup-dependencies)))
6348 headers id end ref number
6349 (mail-parse-charset gnus-newsgroup-charset)
6350 (mail-parse-ignored-charsets
6351 (save-current-buffer (condition-case nil
6352 (set-buffer gnus-summary-buffer)
6354 gnus-newsgroup-ignored-charsets)))
6355 (with-current-buffer nntp-server-buffer
6356 ;; Translate all TAB characters into SPACE characters.
6357 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6358 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6359 (ietf-drums-unfold-fws)
6360 (gnus-run-hooks 'gnus-parse-headers-hook)
6361 (let ((case-fold-search t)
6362 in-reply-to header p lines chars)
6363 (goto-char (point-min))
6364 ;; Search to the beginning of the next header. Error messages
6365 ;; do not begin with 2 or 3.
6366 (while (re-search-forward "^[23][0-9]+ " nil t)
6369 ;; This implementation of this function, with nine
6370 ;; search-forwards instead of the one re-search-forward and
6371 ;; a case (which basically was the old function) is actually
6372 ;; about twice as fast, even though it looks messier. You
6373 ;; can't have everything, I guess. Speed and elegance
6374 ;; doesn't always go hand in hand.
6380 (setq number (read cur))
6383 (narrow-to-region (point)
6384 (or (and (search-forward "\n.\n" nil t)
6390 (if (search-forward "\nsubject:" nil t)
6391 (funcall gnus-decode-encoded-word-function
6392 (nnheader-header-value))
6397 (if (search-forward "\nfrom:" nil t)
6398 (funcall gnus-decode-encoded-address-function
6399 (nnheader-header-value))
6404 (if (search-forward "\ndate:" nil t)
6405 (nnheader-header-value) ""))
6409 (setq id (if (re-search-forward
6410 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6411 ;; We do it this way to make sure the Message-ID
6412 ;; is (somewhat) syntactically valid.
6413 (buffer-substring (match-beginning 1)
6415 ;; If there was no message-id, we just fake one
6416 ;; to make subsequent routines simpler.
6417 (nnheader-generate-fake-message-id number))))
6421 (if (search-forward "\nreferences:" nil t)
6425 (nnheader-header-value)
6430 (search-backward ">" end t)
6433 (search-backward "<" end t)
6435 ;; Get the references from the in-reply-to header if there
6436 ;; were no references and the in-reply-to header looks
6438 (if (and (search-forward "\nin-reply-to:" nil t)
6439 (setq in-reply-to (nnheader-header-value))
6440 (string-match "<[^>]+>" in-reply-to))
6442 (setq ref (substring in-reply-to (match-beginning 0)
6444 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6445 (setq ref2 (substring in-reply-to (match-beginning 0)
6447 (when (> (length ref2) (length ref))
6454 (if (search-forward "\nchars: " nil t)
6455 (if (numberp (setq chars (ignore-errors (read cur))))
6461 (if (search-forward "\nlines: " nil t)
6462 (if (numberp (setq lines (ignore-errors (read cur))))
6468 (and (search-forward "\nxref:" nil t)
6469 (nnheader-header-value)))
6471 (when gnus-extra-headers
6472 (let ((extra gnus-extra-headers)
6476 (when (search-forward
6477 (concat "\n" (symbol-name (car extra)) ":") nil t)
6478 (push (cons (car extra) (nnheader-header-value))
6482 (when (equal id ref)
6485 (when gnus-alter-header-function
6486 (funcall gnus-alter-header-function header)
6487 (setq id (mail-header-id header)
6488 ref (gnus-parent-id (mail-header-references header))))
6491 (gnus-dependencies-add-header
6492 header dependencies force-new))
6493 (push header headers))
6494 (goto-char (point-max))
6496 (nreverse headers)))))
6498 ;; Goes through the xover lines and returns a list of vectors
6499 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6500 force-new dependencies
6501 group also-fetch-heads)
6502 "Parse the news overview data in the server buffer.
6503 Return a list of headers that match SEQUENCE (see
6504 `nntp-retrieve-headers')."
6505 ;; Get the Xref when the users reads the articles since most/some
6506 ;; NNTP servers do not include Xrefs when using XOVER.
6507 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6508 (let ((mail-parse-charset gnus-newsgroup-charset)
6509 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6510 (cur nntp-server-buffer)
6511 (dependencies (or dependencies gnus-newsgroup-dependencies))
6513 ((eq gnus-read-all-available-headers t)
6515 ((and (stringp gnus-read-all-available-headers)
6517 (string-match gnus-read-all-available-headers group))
6520 number headers header)
6521 (with-current-buffer nntp-server-buffer
6522 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6523 ;; Allow the user to mangle the headers before parsing them.
6524 (gnus-run-hooks 'gnus-parse-headers-hook)
6525 (goto-char (point-min))
6526 (gnus-parse-without-error
6527 (while (and (or sequence allp)
6529 (setq number (read cur))
6531 (while (and sequence
6532 (< (car sequence) number))
6533 (setq sequence (cdr sequence))))
6536 (eq number (car sequence))))
6538 (setq sequence (cdr sequence))
6539 (setq header (inline
6540 (gnus-nov-parse-line
6541 number dependencies force-new)))))
6542 (push header headers))
6544 ;; A common bug in inn is that if you have posted an article and
6545 ;; then retrieves the active file, it will answer correctly --
6546 ;; the new article is included. However, a NOV entry for the
6547 ;; article may not have been generated yet, so this may fail.
6548 ;; We work around this problem by retrieving the last few
6549 ;; headers using HEAD.
6550 (if (or (not also-fetch-heads)
6552 ;; We (probably) got all the headers.
6554 (let ((gnus-nov-is-evil t))
6557 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6558 (gnus-get-newsgroup-headers))))))))
6560 (defun gnus-article-get-xrefs ()
6561 "Fill in the Xref value in `gnus-current-headers', if necessary.
6562 This is meant to be called in `gnus-article-internal-prepare-hook'."
6563 (let ((headers (with-current-buffer gnus-summary-buffer
6564 gnus-current-headers)))
6565 (or (not gnus-use-cross-reference)
6567 (and (mail-header-xref headers)
6568 (not (string= (mail-header-xref headers) "")))
6569 (let ((case-fold-search t)
6572 (nnheader-narrow-to-headers)
6573 (goto-char (point-min))
6574 (when (or (and (not (eobp))
6575 (eq (downcase (char-after)) ?x)
6576 (looking-at "Xref:"))
6577 (search-forward "\nXref:" nil t))
6578 (goto-char (1+ (match-end 0)))
6579 (setq xref (buffer-substring (point) (point-at-eol)))
6580 (mail-header-set-xref headers xref)))))))
6582 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6583 "Find article ID and insert the summary line for that article.
6584 OLD-HEADER can either be a header or a line number to insert
6585 the subject line on.
6586 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6587 and OLD-HEADER will be used when the summary line is inserted,
6588 too, instead of trying to fetch new headers."
6589 (let* ((line (and (numberp old-header) old-header))
6590 (old-header (and (vectorp old-header) old-header))
6591 (header (cond ((and old-header use-old-header)
6594 (gnus-number-to-header id))
6595 (gnus-number-to-header id))
6597 (gnus-read-header id))))
6598 (number (and (numberp id) id))
6601 ;; Rebuild the thread that this article is part of and go to the
6602 ;; article we have fetched.
6603 (when (and (not gnus-show-threads)
6606 (setq d (gnus-data-find (mail-header-number old-header))))
6607 (goto-char (gnus-data-pos d))
6613 (gnus-delete-line))))))
6614 ;; Remove list identifiers from subject.
6615 (let ((gnus-newsgroup-headers (list header)))
6616 (gnus-summary-remove-list-identifiers))
6618 (mail-header-set-number header (mail-header-number old-header)))
6619 (setq gnus-newsgroup-sparse
6620 (delq (setq number (mail-header-number header))
6621 gnus-newsgroup-sparse))
6622 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6623 (push number gnus-newsgroup-limit)
6624 (gnus-rebuild-thread (mail-header-id header) line)
6625 (gnus-summary-goto-subject number nil t))
6626 (when (and (numberp number)
6628 ;; We have to update the boundaries even if we can't fetch the
6629 ;; article if ID is a number -- so that the next `P' or `N'
6630 ;; command will fetch the previous (or next) article even
6631 ;; if the one we tried to fetch this time has been canceled.
6632 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6633 (setq gnus-newsgroup-end number))
6634 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6635 (setq gnus-newsgroup-begin number))
6636 (setq gnus-newsgroup-unselected
6637 (delq number gnus-newsgroup-unselected)))
6638 ;; Report back a success?
6639 (and header (mail-header-number header))))
6641 ;;; Process/prefix in the summary buffer
6643 (defun gnus-summary-work-articles (n)
6644 "Return a list of articles to be worked upon.
6645 The prefix argument, the list of process marked articles, and the
6646 current article will be taken into consideration."
6647 (with-current-buffer gnus-summary-buffer
6650 ;; A numerical prefix has been given.
6651 (setq n (prefix-numeric-value n))
6652 (let ((backward (< n 0))
6653 (n (abs (prefix-numeric-value n)))
6658 (push (setq article (gnus-summary-article-number))
6661 (gnus-summary-find-prev nil article)
6662 (gnus-summary-find-next nil article)))
6664 (nreverse articles)))
6665 ((and (gnus-region-active-p) (mark))
6666 (message "region active")
6667 ;; Work on the region between point and mark.
6668 (let ((max (max (point) (mark)))
6671 (goto-char (min (point) (mark)))
6674 (push (setq article (gnus-summary-article-number)) articles)
6675 (gnus-summary-find-next nil article)
6677 (nreverse articles))))
6678 (gnus-newsgroup-processable
6679 ;; There are process-marked articles present.
6680 ;; Save current state.
6681 (gnus-summary-save-process-mark)
6683 (reverse gnus-newsgroup-processable))
6685 ;; Just return the current article.
6686 (list (gnus-summary-article-number))))))
6688 (defmacro gnus-summary-iterate (arg &rest forms)
6689 "Iterate over the process/prefixed articles and do FORMS.
6690 ARG is the interactive prefix given to the command. FORMS will be
6691 executed with point over the summary line of the articles."
6692 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6693 `(let ((,articles (gnus-summary-work-articles ,arg)))
6695 (gnus-summary-goto-subject (car ,articles))
6699 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6700 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6702 (defun gnus-summary-save-process-mark ()
6703 "Push the current set of process marked articles on the stack."
6705 (push (copy-sequence gnus-newsgroup-processable)
6706 gnus-newsgroup-process-stack))
6708 (defun gnus-summary-kill-process-mark ()
6709 "Push the current set of process marked articles on the stack and unmark."
6711 (gnus-summary-save-process-mark)
6712 (gnus-summary-unmark-all-processable))
6714 (defun gnus-summary-yank-process-mark ()
6715 "Pop the last process mark state off the stack and restore it."
6717 (unless gnus-newsgroup-process-stack
6718 (error "Empty mark stack"))
6719 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6721 (defun gnus-summary-process-mark-set (set)
6722 "Make SET into the current process marked articles."
6723 (gnus-summary-unmark-all-processable)
6724 (mapc 'gnus-summary-set-process-mark set))
6726 ;;; Searching and stuff
6728 (defun gnus-summary-search-group (&optional backward use-level)
6729 "Search for next unread newsgroup.
6730 If optional argument BACKWARD is non-nil, search backward instead."
6731 (with-current-buffer gnus-group-buffer
6732 (when (gnus-group-search-forward
6733 backward nil (if use-level (gnus-group-group-level) nil))
6734 (gnus-group-group-name))))
6736 (defun gnus-summary-best-group (&optional exclude-group)
6737 "Find the name of the best unread group.
6738 If EXCLUDE-GROUP, do not go to this group."
6739 (with-current-buffer gnus-group-buffer
6741 (gnus-group-best-unread-group exclude-group))))
6743 (defun gnus-summary-find-next (&optional unread article backward)
6745 (gnus-summary-find-prev unread article)
6746 (let* ((dummy (gnus-summary-article-intangible-p))
6747 (article (or article (gnus-summary-article-number)))
6748 (data (gnus-data-find-list article))
6750 (when (and (not dummy)
6751 (or (not gnus-summary-check-current)
6753 (not (gnus-data-unread-p (car data)))))
6754 (setq data (cdr data)))
6759 (unless (memq (gnus-data-number (car data))
6761 ((eq gnus-auto-goto-ignores
6762 'always-undownloaded)
6763 gnus-newsgroup-undownloaded)
6766 ((eq gnus-auto-goto-ignores
6768 gnus-newsgroup-unfetched)
6769 ((eq gnus-auto-goto-ignores
6771 gnus-newsgroup-undownloaded)))
6772 (when (gnus-data-unread-p (car data))
6773 (setq result (car data)
6775 (setq data (cdr data)))
6778 (goto-char (gnus-data-pos result))
6779 (gnus-data-number result)))))
6781 (defun gnus-summary-find-prev (&optional unread article)
6782 (let* ((eobp (eobp))
6783 (article (or article (gnus-summary-article-number)))
6784 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6786 (when (and (not eobp)
6787 (or (not gnus-summary-check-current)
6789 (not (gnus-data-unread-p (car data)))))
6790 (setq data (cdr data)))
6795 (unless (memq (gnus-data-number (car data))
6797 ((eq gnus-auto-goto-ignores
6798 'always-undownloaded)
6799 gnus-newsgroup-undownloaded)
6802 ((eq gnus-auto-goto-ignores
6804 gnus-newsgroup-unfetched)
6805 ((eq gnus-auto-goto-ignores
6807 gnus-newsgroup-undownloaded)))
6808 (when (gnus-data-unread-p (car data))
6809 (setq result (car data)
6811 (setq data (cdr data)))
6814 (goto-char (gnus-data-pos result))
6815 (gnus-data-number result))))
6817 (defun gnus-summary-find-subject (subject &optional unread backward article)
6818 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6819 (article (or article (gnus-summary-article-number)))
6820 (articles (gnus-data-list backward))
6821 (arts (gnus-data-find-list article articles))
6823 (when (or (not gnus-summary-check-current)
6825 (not (gnus-data-unread-p (car arts))))
6826 (setq arts (cdr arts)))
6828 (and (or (not unread)
6829 (gnus-data-unread-p (car arts)))
6830 (vectorp (gnus-data-header (car arts)))
6832 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6833 (setq result (car arts)
6835 (setq arts (cdr arts)))
6837 (goto-char (gnus-data-pos result))
6838 (gnus-data-number result))))
6840 (defun gnus-summary-search-forward (&optional unread subject backward)
6841 "Search forward for an article.
6842 If UNREAD, look for unread articles. If SUBJECT, look for
6843 articles with that subject. If BACKWARD, search backward instead."
6844 (cond (subject (gnus-summary-find-subject subject unread backward))
6845 (backward (gnus-summary-find-prev unread))
6846 (t (gnus-summary-find-next unread))))
6848 (defun gnus-recenter (&optional n)
6849 "Center point in window and redisplay frame.
6850 Also do horizontal recentering."
6852 (when (and gnus-auto-center-summary
6853 (not (eq gnus-auto-center-summary 'vertical)))
6854 (gnus-horizontal-recenter))
6855 (if (fboundp 'recenter-top-bottom)
6856 (recenter-top-bottom n)
6859 (put 'gnus-recenter 'isearch-scroll t)
6861 (defun gnus-forward-line-ignore-invisible (n)
6862 "Move N lines forward (backward if N is negative).
6863 Like forward-line, but skip over (and don't count) invisible lines."
6865 (while (and (> n 0) (not done))
6866 ;; If the following character is currently invisible,
6867 ;; skip all characters with that same `invisible' property value.
6868 (while (gnus-invisible-p (point))
6869 (goto-char (gnus-next-char-property-change (point))))
6874 (while (and (< n 0) (not done))
6876 (if (bobp) (setq done t)
6878 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6879 (goto-char (gnus-previous-char-property-change (point))))))))
6881 (defun gnus-summary-recenter ()
6882 "Center point in the summary window.
6883 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6884 displayed, no centering will be performed."
6885 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6886 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6888 ;; The user has to want it.
6889 (when gnus-auto-center-summary
6890 (let* ((top (cond ((< (window-height) 4) 0)
6891 ((< (window-height) 7) 1)
6892 (t (if (numberp gnus-auto-center-summary)
6893 gnus-auto-center-summary
6894 (/ (1- (window-height)) 2)))))
6895 (height (1- (window-height)))
6896 (bottom (save-excursion
6897 (goto-char (point-max))
6898 (gnus-forward-line-ignore-invisible (- height))
6900 (window (get-buffer-window (current-buffer))))
6901 (when (get-buffer-window gnus-article-buffer)
6902 ;; Only do recentering when the article buffer is displayed,
6903 ;; Set the window start to either `bottom', which is the biggest
6904 ;; possible valid number, or the second line from the top,
6905 ;; whichever is the least.
6906 (let ((top-pos (save-excursion
6907 (gnus-forward-line-ignore-invisible (- top))
6909 (if (> bottom top-pos)
6910 ;; Keep the second line from the top visible
6911 (set-window-start window top-pos)
6912 ;; Try to keep the bottom line visible; if it's partially
6913 ;; obscured, either scroll one more line to make it fully
6914 ;; visible, or revert to using TOP-POS.
6916 (goto-char (point-max))
6917 (gnus-forward-line-ignore-invisible -1)
6918 (let ((last-line-start (point)))
6920 (set-window-start window (point) t)
6921 (when (not (pos-visible-in-window-p last-line-start window))
6922 (gnus-forward-line-ignore-invisible 1)
6923 (set-window-start window (min (point) top-pos) t)))))))
6924 ;; Do horizontal recentering while we're at it.
6925 (when (and (get-buffer-window (current-buffer) t)
6926 (not (eq gnus-auto-center-summary 'vertical)))
6927 (let ((selected (selected-window)))
6928 (select-window (get-buffer-window (current-buffer) t))
6929 (gnus-summary-position-point)
6930 (gnus-horizontal-recenter)
6931 (select-window selected))))))
6933 (defun gnus-summary-jump-to-group (newsgroup)
6934 "Move point to NEWSGROUP in group mode buffer."
6935 ;; Keep update point of group mode buffer if visible.
6936 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6937 (save-window-excursion
6938 ;; Take care of tree window mode.
6939 (when (get-buffer-window gnus-group-buffer)
6940 (pop-to-buffer gnus-group-buffer))
6941 (gnus-group-jump-to-group newsgroup))
6943 ;; Take care of tree window mode.
6944 (if (get-buffer-window gnus-group-buffer 0)
6945 (pop-to-buffer gnus-group-buffer)
6946 (set-buffer gnus-group-buffer))
6947 (gnus-group-jump-to-group newsgroup))))
6949 ;; This function returns a list of article numbers based on the
6950 ;; difference between the ranges of read articles in this group and
6951 ;; the range of active articles.
6952 (defun gnus-list-of-unread-articles (group)
6953 (let* ((read (gnus-info-read (gnus-get-info group)))
6954 (active (or (gnus-active group) (gnus-activate-group group)))
6955 (last (or (cdr active)
6956 (error "Group %s couldn't be activated " group)))
6957 (bottom (if gnus-newsgroup-maximum-articles
6959 (- last gnus-newsgroup-maximum-articles -1))
6962 ;; If none are read, then all are unread.
6965 ;; If the range of read articles is a single range, then the
6966 ;; first unread article is the article after the last read
6967 ;; article. Sounds logical, doesn't it?
6968 (if (and (not (listp (cdr read)))
6969 (or (< (car read) bottom)
6970 (progn (setq read (list read))
6972 (setq first (max bottom (1+ (cdr read))))
6973 ;; `read' is a list of ranges.
6974 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6977 (setq first bottom))
6980 (while (< first nlast)
6981 (setq unread (cons first unread)
6983 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6984 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6985 (setq read (cdr read)))))
6986 ;; And add the last unread articles.
6987 (while (<= first last)
6988 (setq unread (cons first unread)
6990 ;; Return the list of unread articles.
6991 (delq 0 (nreverse unread))))
6993 (defun gnus-list-of-read-articles (group)
6994 "Return a list of unread, unticked and non-dormant articles."
6995 (let* ((info (gnus-get-info group))
6996 (marked (gnus-info-marks info))
6997 (active (gnus-active group)))
6999 (gnus-list-range-difference
7000 (gnus-list-range-difference
7001 (gnus-sorted-complement
7002 (gnus-uncompress-range
7003 (if gnus-newsgroup-maximum-articles
7004 (cons (max (car active)
7006 gnus-newsgroup-maximum-articles
7010 (gnus-list-of-unread-articles group))
7011 (cdr (assq 'dormant marked)))
7012 (cdr (assq 'tick marked))))))
7014 ;; This function returns a sequence of article numbers based on the
7015 ;; difference between the ranges of read articles in this group and
7016 ;; the range of active articles.
7017 (defun gnus-sequence-of-unread-articles (group)
7018 (let* ((read (gnus-info-read (gnus-get-info group)))
7019 (active (or (gnus-active group) (gnus-activate-group group)))
7021 (bottom (if gnus-newsgroup-maximum-articles
7023 (- last gnus-newsgroup-maximum-articles -1))
7026 ;; If none are read, then all are unread.
7029 ;; If the range of read articles is a single range, then the
7030 ;; first unread article is the article after the last read
7031 ;; article. Sounds logical, doesn't it?
7032 (if (and (not (listp (cdr read)))
7033 (or (< (car read) bottom)
7034 (progn (setq read (list read))
7036 (setq first (max bottom (1+ (cdr read))))
7037 ;; `read' is a list of ranges.
7038 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7041 (setq first bottom))
7044 (push (cons first nlast) unread))
7045 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7046 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7047 (setq read (cdr read)))))
7048 ;; And add the last unread articles.
7049 (cond ((not (and first last))
7052 (push (cons first last) unread))
7054 (push first unread)))
7055 ;; Return the sequence of unread articles.
7056 (delq 0 (nreverse unread))))
7058 ;; Various summary commands
7060 (defun gnus-summary-select-article-buffer ()
7061 "Reconfigure windows to show the article buffer.
7062 If `gnus-widen-article-window' is set, show only the article
7065 (if (not (gnus-buffer-live-p gnus-article-buffer))
7066 (error "There is no article buffer for this summary buffer")
7067 (unless (get-buffer-window gnus-article-buffer)
7068 (gnus-summary-show-article))
7069 (gnus-configure-windows
7070 (if gnus-widen-article-window
7074 (select-window (get-buffer-window gnus-article-buffer))))
7076 (defun gnus-summary-universal-argument (arg)
7077 "Perform any operation on all articles that are process/prefixed."
7079 (let ((articles (gnus-summary-work-articles arg))
7086 (substitute-command-keys
7087 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7089 (gnus-error 1 "Undefined key")
7092 (gnus-summary-goto-subject (setq article (pop articles)))
7093 (let (gnus-newsgroup-processable)
7094 (command-execute func))
7095 (gnus-summary-remove-process-mark article)))))
7096 (gnus-summary-position-point))
7098 (defun gnus-summary-toggle-truncation (&optional arg)
7099 "Toggle truncation of summary lines.
7100 With ARG, turn line truncation on if ARG is positive."
7102 (setq truncate-lines
7103 (if (null arg) (not truncate-lines)
7104 (> (prefix-numeric-value arg) 0)))
7107 (defun gnus-summary-find-for-reselect ()
7108 "Return the number of an article to stay on across a reselect.
7109 The current article is considered, then following articles, then previous
7110 articles. An article is sought which is not canceled and isn't a temporary
7111 insertion from another group. If there's no such then return a dummy 0."
7113 (dolist (rev '(nil t))
7114 (unless found ; don't demand the reverse list if we don't need it
7115 (let ((data (gnus-data-find-list
7116 (gnus-summary-article-number) (gnus-data-list rev))))
7117 (while (and data (not found))
7118 (if (and (< 0 (gnus-data-number (car data)))
7119 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7120 (setq found (gnus-data-number (car data))))
7121 (setq data (cdr data))))))
7124 (defun gnus-summary-reselect-current-group (&optional all rescan)
7125 "Exit and then reselect the current newsgroup.
7126 The prefix argument ALL means to select all articles."
7128 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7129 (error "Ephemeral groups can't be reselected"))
7130 (let ((current-subject (gnus-summary-find-for-reselect))
7131 (group gnus-newsgroup-name))
7132 (setq gnus-newsgroup-begin nil)
7133 (gnus-summary-exit nil 'leave-hidden)
7134 ;; We have to adjust the point of group mode buffer because
7135 ;; point was moved to the next unread newsgroup by exiting.
7136 (gnus-summary-jump-to-group group)
7139 (gnus-group-get-new-news-this-group 1)))
7140 (gnus-group-read-group all t)
7141 (gnus-summary-goto-subject current-subject nil t)))
7143 (defun gnus-summary-rescan-group (&optional all)
7144 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7146 (let ((config gnus-current-window-configuration))
7147 (gnus-summary-reselect-current-group all t)
7148 (gnus-configure-windows config)
7149 (when (eq config 'article)
7150 (gnus-summary-select-article))))
7152 (defun gnus-summary-update-info (&optional non-destructive)
7154 (let ((group gnus-newsgroup-name))
7156 (when gnus-newsgroup-kill-headers
7157 (setq gnus-newsgroup-killed
7158 (gnus-compress-sequence
7160 (gnus-list-range-intersection
7161 gnus-newsgroup-unselected gnus-newsgroup-killed)
7162 gnus-newsgroup-unreads)
7164 (unless (listp (cdr gnus-newsgroup-killed))
7165 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7166 (let ((headers gnus-newsgroup-headers)
7167 (ephemeral-p (gnus-ephemeral-group-p group))
7170 (setq info (copy-sequence (gnus-get-info group))
7171 info (delq (gnus-info-params info) info)))
7172 ;; Set the new ranges of read articles.
7173 (with-current-buffer gnus-group-buffer
7174 (gnus-undo-force-boundary))
7175 (gnus-update-read-articles
7176 group (gnus-sorted-union
7177 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7178 ;; Set the current article marks.
7179 (let ((gnus-newsgroup-scored
7180 (if (and (not gnus-save-score)
7181 (not non-destructive))
7183 gnus-newsgroup-scored)))
7185 (gnus-update-marks)))
7186 ;; Do the cross-ref thing.
7187 (when gnus-use-cross-reference
7188 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7189 ;; Do not switch windows but change the buffer to work.
7190 (set-buffer gnus-group-buffer)
7192 (gnus-group-update-group
7195 (setq info (copy-sequence (gnus-get-info group))
7196 info (delq (gnus-info-params info) info))))))))))
7198 (defun gnus-summary-save-newsrc (&optional force)
7199 "Save the current number of read/marked articles in the dribble buffer.
7200 The dribble buffer will then be saved.
7201 If FORCE (the prefix), also save the .newsrc file(s)."
7203 (gnus-summary-update-info t)
7205 (gnus-save-newsrc-file)
7206 (gnus-dribble-save)))
7208 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7210 (defun gnus-summary-exit (&optional temporary leave-hidden)
7211 "Exit reading current newsgroup, and then return to group selection mode.
7212 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7214 (gnus-set-global-variables)
7215 (when (gnus-buffer-live-p gnus-article-buffer)
7216 (with-current-buffer gnus-article-buffer
7217 (mm-destroy-parts gnus-article-mime-handles)
7218 ;; Set it to nil for safety reason.
7219 (setq gnus-article-mime-handle-alist nil)
7220 (setq gnus-article-mime-handles nil)))
7221 (gnus-kill-save-kill-buffer)
7222 (gnus-async-halt-prefetch)
7223 (let* ((group gnus-newsgroup-name)
7224 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7225 (gnus-group-is-exiting-p t)
7226 (article-buffer gnus-article-buffer)
7227 (original-article-buffer gnus-original-article-buffer)
7230 (buf (current-buffer))
7231 ;; `gnus-single-article-buffer' is nil buffer-locally in
7232 ;; ephemeral group of which summary buffer will be killed,
7233 ;; but the global value may be non-nil.
7234 (single-article-buffer gnus-single-article-buffer))
7236 ;; Do adaptive scoring, and possibly save score files.
7237 (when gnus-newsgroup-adaptive
7238 (gnus-score-adaptive))
7239 (when gnus-use-scoring
7241 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7242 (when gnus-use-cache
7243 (gnus-cache-possibly-remove-articles)
7244 (gnus-cache-save-buffers))
7245 (gnus-async-prefetch-remove-group group)
7246 (when gnus-suppress-duplicates
7247 (gnus-dup-enter-articles))
7248 (when gnus-use-trees
7249 (gnus-tree-close group))
7250 (when gnus-use-cache
7251 (gnus-cache-write-active))
7252 ;; Remove entries for this group.
7253 (nnmail-purge-split-history (gnus-group-real-name group))
7254 ;; Make all changes in this group permanent.
7256 (gnus-run-hooks 'gnus-exit-group-hook)
7257 (gnus-summary-update-info))
7258 (gnus-close-group group)
7259 ;; Make sure where we were, and go to next newsgroup.
7260 (when (buffer-live-p (get-buffer gnus-group-buffer))
7261 (set-buffer gnus-group-buffer))
7263 (gnus-group-jump-to-group group))
7264 (gnus-run-hooks 'gnus-summary-exit-hook)
7265 (unless (or quit-config
7266 (not gnus-summary-next-group-on-exit)
7267 ;; If this group has disappeared from the summary
7268 ;; buffer, don't skip forwards.
7269 (not (string= group (gnus-group-group-name))))
7270 (gnus-group-next-unread-group 1))
7271 (setq group-point (point))
7275 (if (not gnus-kill-summary-on-exit)
7277 (gnus-deaden-summary)
7279 (when (get-buffer gnus-article-buffer)
7280 (bury-buffer gnus-article-buffer))
7281 ;; Return to group mode buffer.
7282 (when (eq mode 'gnus-summary-mode)
7283 (gnus-kill-buffer buf)))
7285 (setq gnus-current-select-method gnus-select-method)
7286 (when (gnus-buffer-live-p gnus-group-buffer)
7287 (set-buffer gnus-group-buffer))
7289 (gnus-handle-ephemeral-exit quit-config)
7290 (goto-char group-point)
7291 ;; If gnus-group-buffer is already displayed, make sure we also move
7292 ;; the cursor in the window that displays it.
7293 (let ((win (get-buffer-window (current-buffer) 0)))
7294 (if win (set-window-point win (point))))
7295 (unless leave-hidden
7296 (gnus-configure-windows 'group 'force)))
7298 ;; If we have several article buffers, we kill them at exit.
7299 (unless single-article-buffer
7300 (when (gnus-buffer-live-p article-buffer)
7301 (with-current-buffer article-buffer
7302 ;; Don't kill sticky article buffers
7303 (unless (eq major-mode 'gnus-sticky-article-mode)
7304 (gnus-kill-buffer article-buffer)
7305 (setq gnus-article-current nil))))
7306 (gnus-kill-buffer original-article-buffer))
7308 ;; Clear the current group name.
7310 (setq gnus-newsgroup-name nil)))))
7312 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7313 (defun gnus-summary-exit-no-update (&optional no-questions)
7314 "Quit reading current newsgroup without updating read article info."
7316 (let* ((group gnus-newsgroup-name)
7317 (gnus-group-is-exiting-p t)
7318 (gnus-group-is-exiting-without-update-p t)
7319 (quit-config (gnus-group-quit-config group)))
7320 (when (or no-questions
7322 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7323 (gnus-async-halt-prefetch)
7324 (run-hooks 'gnus-summary-prepare-exit-hook)
7325 (when (gnus-buffer-live-p gnus-article-buffer)
7326 (with-current-buffer gnus-article-buffer
7327 (gnus-article-stop-animations)
7328 (gnus-stop-downloads)
7329 (mm-destroy-parts gnus-article-mime-handles)
7330 ;; Set it to nil for safety reason.
7331 (setq gnus-article-mime-handle-alist nil)
7332 (setq gnus-article-mime-handles nil)))
7333 ;; If we have several article buffers, we kill them at exit.
7334 (unless gnus-single-article-buffer
7335 (gnus-kill-buffer gnus-article-buffer)
7336 (gnus-kill-buffer gnus-original-article-buffer)
7337 (setq gnus-article-current nil))
7338 ;; Return to the group buffer.
7339 (if (not gnus-kill-summary-on-exit)
7341 (gnus-deaden-summary)
7342 (gnus-configure-windows 'group 'force))
7343 (gnus-configure-windows 'group 'force)
7344 (gnus-close-group group)
7345 (gnus-kill-buffer gnus-summary-buffer))
7346 (unless gnus-single-article-buffer
7347 (setq gnus-article-current nil))
7348 (when gnus-use-trees
7349 (gnus-tree-close group))
7350 (gnus-async-prefetch-remove-group group)
7351 (when (get-buffer gnus-article-buffer)
7352 (bury-buffer gnus-article-buffer))
7353 ;; Clear the current group name.
7354 (setq gnus-newsgroup-name nil)
7355 (unless (gnus-ephemeral-group-p group)
7356 (gnus-group-update-group group nil t))
7357 (when (equal (gnus-group-group-name) group)
7358 (gnus-group-next-unread-group 1))
7360 (gnus-handle-ephemeral-exit quit-config)))))
7362 (defun gnus-handle-ephemeral-exit (quit-config)
7363 "Handle movement when leaving an ephemeral group.
7364 The state which existed when entering the ephemeral is reset."
7365 (if (not (buffer-live-p (car quit-config)))
7366 (when (gnus-buffer-live-p gnus-group-buffer)
7367 (gnus-configure-windows 'group 'force))
7368 (set-buffer (car quit-config))
7369 (unless (eq (cdr quit-config) 'group)
7370 (setq gnus-current-select-method
7371 (gnus-find-method-for-group gnus-newsgroup-name)))
7372 (cond ((eq major-mode 'gnus-summary-mode)
7373 (gnus-set-global-variables))
7374 ((eq major-mode 'gnus-article-mode)
7375 (save-current-buffer
7376 ;; The `gnus-summary-buffer' variable may point
7377 ;; to the old summary buffer when using a single
7379 (unless (gnus-buffer-live-p gnus-summary-buffer)
7380 (set-buffer gnus-group-buffer))
7381 (set-buffer gnus-summary-buffer)
7382 (gnus-set-global-variables))))
7383 (if (or (eq (cdr quit-config) 'article)
7384 (eq (cdr quit-config) 'pick))
7385 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7386 (gnus-configure-windows 'pick 'force)
7387 (gnus-configure-windows (cdr quit-config) 'force))
7388 (gnus-configure-windows (cdr quit-config) 'force))
7389 (when (eq major-mode 'gnus-summary-mode)
7390 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7391 next-unread-noselect))
7392 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7394 (gnus-summary-next-subject 1 nil t))
7395 ((eq gnus-auto-select-on-ephemeral-exit
7396 'next-unread-noselect)
7397 (gnus-summary-next-subject 1 t t))))
7398 ;; Hide the article buffer which displays the article different
7399 ;; from the one that the cursor points to in the summary buffer.
7400 (gnus-configure-windows 'summary 'force))
7401 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7402 (gnus-summary-next-subject 1))
7403 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7404 (gnus-summary-next-subject 1 t))))
7405 (gnus-summary-recenter)
7406 (gnus-summary-position-point))))
7410 (defvar gnus-dead-summary-mode-map
7411 (let ((map (make-keymap)))
7412 (suppress-keymap map)
7413 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7414 (dolist (key '("\C-d" "\r" "\177" [delete]))
7415 (define-key map key 'gnus-summary-wake-up-the-dead))
7416 (dolist (key '("q" "Q"))
7417 (define-key map key 'bury-buffer))
7420 (define-minor-mode gnus-dead-summary-mode
7421 "Minor mode for Gnus summary buffers."
7422 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7423 (unless (derived-mode-p 'gnus-summary-mode)
7424 (setq gnus-dead-summary-mode nil)))
7426 (defun gnus-deaden-summary ()
7427 "Make the current summary buffer into a dead summary buffer."
7428 ;; Kill any previous dead summary buffer.
7429 (when (and gnus-dead-summary
7430 (buffer-name gnus-dead-summary))
7431 (with-current-buffer gnus-dead-summary
7432 (when gnus-dead-summary-mode
7433 (kill-buffer (current-buffer)))))
7434 ;; Make this the current dead summary.
7435 (setq gnus-dead-summary (current-buffer))
7436 (gnus-dead-summary-mode 1)
7437 (let ((name (buffer-name)))
7438 (when (string-match "Summary" name)
7440 (concat (substring name 0 (match-beginning 0)) "Dead "
7441 (substring name (match-beginning 0)))
7445 (defun gnus-kill-or-deaden-summary (buffer)
7446 "Kill or deaden the summary BUFFER."
7448 (when (and (buffer-name buffer)
7449 (not gnus-single-article-buffer))
7450 (with-current-buffer buffer
7451 (gnus-kill-buffer gnus-article-buffer)
7452 (gnus-kill-buffer gnus-original-article-buffer)))
7455 (gnus-kill-summary-on-exit
7456 (when (and gnus-use-trees
7457 (gnus-buffer-exists-p buffer))
7458 (with-current-buffer buffer
7459 (gnus-tree-close gnus-newsgroup-name)))
7460 (gnus-kill-buffer buffer))
7461 ;; Deaden the buffer.
7462 ((gnus-buffer-exists-p buffer)
7463 (with-current-buffer buffer
7464 (gnus-deaden-summary))))))
7466 (defun gnus-summary-wake-up-the-dead (&rest args)
7467 "Wake up the dead summary buffer."
7469 (gnus-dead-summary-mode -1)
7470 (let ((name (buffer-name)))
7471 (when (string-match "Dead " name)
7473 (concat (substring name 0 (match-beginning 0))
7474 (substring name (match-end 0)))
7476 (gnus-message 3 "This dead summary is now alive again"))
7478 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7479 (defun gnus-summary-describe-group (&optional force)
7480 "Describe the current newsgroup."
7482 (gnus-group-describe-group force gnus-newsgroup-name))
7484 (defun gnus-summary-describe-briefly ()
7485 "Describe summary mode commands briefly."
7487 (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")))
7489 ;; Walking around group mode buffer from summary mode.
7491 (defun gnus-summary-next-group (&optional no-article target-group backward)
7492 "Exit current newsgroup and then select next unread newsgroup.
7493 If prefix argument NO-ARTICLE is non-nil, no article is selected
7494 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7495 previous group instead."
7497 ;; Stop pre-fetching.
7498 (gnus-async-halt-prefetch)
7499 (let ((current-group gnus-newsgroup-name)
7500 (current-buffer (current-buffer))
7502 ;; First we semi-exit this group to update Xrefs and all variables.
7503 ;; We can't do a real exit, because the window conf must remain
7504 ;; the same in case the user is prompted for info, and we don't
7505 ;; want the window conf to change before that...
7506 (gnus-summary-exit t)
7507 (while (not entered)
7508 ;; Then we find what group we are supposed to enter.
7509 (set-buffer gnus-group-buffer)
7510 (gnus-group-jump-to-group current-group)
7513 (if (eq gnus-keep-same-level 'best)
7514 (gnus-summary-best-group gnus-newsgroup-name)
7515 (gnus-summary-search-group backward gnus-keep-same-level))))
7516 (if (not target-group)
7517 ;; There are no further groups, so we return to the group
7520 (gnus-message 5 "Returning to the group buffer")
7522 (when (gnus-buffer-live-p current-buffer)
7523 (set-buffer current-buffer)
7524 (gnus-summary-exit))
7525 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7526 ;; We try to enter the target group.
7527 (gnus-group-jump-to-group target-group)
7528 (let ((unreads (gnus-group-group-unread)))
7529 (if (and (or (eq t unreads)
7530 (and unreads (not (zerop unreads))))
7531 (gnus-summary-read-group
7532 target-group nil no-article
7533 (and (buffer-name current-buffer) current-buffer)
7536 (setq current-group target-group
7537 target-group nil)))))))
7539 (defun gnus-summary-prev-group (&optional no-article)
7540 "Exit current newsgroup and then select previous unread newsgroup.
7541 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7543 (gnus-summary-next-group no-article nil t))
7545 ;; Walking around summary lines.
7547 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7548 "Go to the first subject satisfying any non-nil constraint.
7549 If UNREAD is non-nil, the article should be unread.
7550 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7551 If UNSEEN is non-nil, the article should be unseen as well as unread.
7552 Returns the article selected or nil if there are no matching articles."
7556 ((null gnus-newsgroup-data)
7557 (gnus-message 3 "No articles in the group")
7559 ;; Pick the first article.
7560 ((not (or unread undownloaded unseen))
7561 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7562 (gnus-data-number (car gnus-newsgroup-data)))
7563 ;; Find the first unread article.
7565 (let ((data gnus-newsgroup-data))
7567 (let ((num (gnus-data-number (car data))))
7568 (or (memq num gnus-newsgroup-unfetched)
7569 (not (or (and unread
7570 (memq num gnus-newsgroup-unreads))
7572 (memq num gnus-newsgroup-undownloaded))
7574 (memq num gnus-newsgroup-unseen)
7575 (memq num gnus-newsgroup-unreads)))))))
7576 (setq data (cdr data)))
7580 (goto-char (gnus-data-pos (car data)))
7581 (gnus-data-number (car data)))
7582 (gnus-message 3 "No more%s articles"
7583 (let* ((r (when unread " unread"))
7584 (d (when undownloaded " undownloaded"))
7585 (s (when unseen " unseen"))
7586 (l (delq nil (list r d s))))
7587 (cond ((= 3 (length l))
7588 (concat r "," d ", or" s))
7590 (concat (car l) ", or" (cadr l)))
7597 (gnus-summary-position-point))))))
7599 (defun gnus-summary-next-subject (n &optional unread dont-display)
7600 "Go to next N'th summary line.
7601 If N is negative, go to the previous N'th subject line.
7602 If UNREAD is non-nil, only unread articles are selected.
7603 The difference between N and the actual number of steps taken is
7606 (let ((backward (< n 0))
7610 (gnus-summary-find-prev unread)
7611 (gnus-summary-find-next unread)))
7612 (unless (zerop (setq n (1- n)))
7613 (gnus-summary-show-thread)))
7615 (gnus-message 7 "No more%s articles"
7616 (if unread " unread" "")))
7617 (unless dont-display
7618 (gnus-summary-recenter)
7619 (gnus-summary-position-point))
7622 (defun gnus-summary-next-unread-subject (n)
7623 "Go to next N'th unread summary line."
7625 (gnus-summary-next-subject n t))
7627 (defun gnus-summary-prev-subject (n &optional unread)
7628 "Go to previous N'th summary line.
7629 If optional argument UNREAD is non-nil, only unread article is selected."
7631 (gnus-summary-next-subject (- n) unread))
7633 (defun gnus-summary-prev-unread-subject (n)
7634 "Go to previous N'th unread summary line."
7636 (gnus-summary-next-subject (- n) t))
7638 (defun gnus-summary-goto-subjects (articles)
7639 "Insert the subject header for ARTICLES in the current buffer."
7641 (dolist (article articles)
7642 (gnus-summary-goto-subject article t)))
7643 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7644 (gnus-summary-position-point))
7646 (defun gnus-summary-goto-subject (article &optional force silent)
7647 "Go to the subject line of ARTICLE.
7648 If FORCE, also allow jumping to articles not currently shown."
7649 (interactive "nArticle number: ")
7650 (unless (numberp article)
7651 (error "Article %s is not a number" article))
7653 (data (gnus-data-find article)))
7654 ;; We read in the article if we have to.
7657 (gnus-summary-insert-subject
7659 (if (or (numberp force) (vectorp force)) force)
7661 (setq data (gnus-data-find article)))
7666 (gnus-message 3 "Can't find article %d" article))
7668 (let ((pt (gnus-data-pos data)))
7670 (gnus-summary-set-article-display-arrow pt))
7671 (gnus-summary-position-point)
7674 ;; Walking around summary lines with displaying articles.
7676 (defun gnus-summary-expand-window (&optional arg)
7677 "Make the summary buffer take up the entire Emacs frame.
7678 Given a prefix, will force an `article' buffer configuration."
7681 (gnus-configure-windows 'article 'force)
7682 (gnus-configure-windows 'summary 'force)))
7684 (defun gnus-summary-display-article (article &optional all-header)
7685 "Display ARTICLE in article buffer."
7686 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7687 (with-current-buffer gnus-article-buffer
7688 (eq major-mode 'gnus-article-mode)))
7689 (gnus-article-setup-buffer))
7690 (gnus-set-global-variables)
7691 (with-current-buffer gnus-article-buffer
7692 (setq gnus-article-charset gnus-newsgroup-charset)
7693 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7694 (mm-enable-multibyte))
7698 (if gnus-summary-display-article-function
7699 (funcall gnus-summary-display-article-function article all-header)
7700 (gnus-article-prepare article all-header))
7701 (gnus-run-hooks 'gnus-select-article-hook)
7702 (when (and gnus-current-article
7703 (not (zerop gnus-current-article)))
7704 (gnus-summary-goto-subject gnus-current-article))
7705 (gnus-summary-recenter)
7706 (when (and gnus-use-trees gnus-show-threads)
7707 (gnus-possibly-generate-tree article)
7708 (gnus-highlight-selected-tree article))
7709 ;; Successfully display article.
7710 (gnus-article-set-window-start
7711 (cdr (assq article gnus-newsgroup-bookmarks))))))
7713 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7714 "Select the current article.
7715 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7716 non-nil, the article will be re-fetched even if it already present in
7717 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7719 ;; Make sure we are in the summary buffer to work around bbdb bug.
7720 (unless (eq major-mode 'gnus-summary-mode)
7721 (set-buffer gnus-summary-buffer))
7722 (let ((article (or article (gnus-summary-article-number)))
7723 (all-headers (not (not all-headers))) ;Must be t or nil.
7724 gnus-summary-display-article-function)
7726 (gnus-summary-article-pseudo-p article)
7727 (error "This is a pseudo-article"))
7728 (with-current-buffer gnus-summary-buffer
7729 (if (or (and gnus-single-article-buffer
7730 (or (null gnus-current-article)
7731 (null gnus-article-current)
7732 (null (get-buffer gnus-article-buffer))
7733 (not (eq article (cdr gnus-article-current)))
7734 (not (equal (car gnus-article-current)
7735 gnus-newsgroup-name))
7736 (not (get-buffer gnus-original-article-buffer))))
7737 (and (not gnus-single-article-buffer)
7738 (or (null gnus-current-article)
7739 (not (get-buffer gnus-original-article-buffer))
7740 (not (eq gnus-current-article article))))
7742 ;; The requested article is different from the current article.
7744 (gnus-summary-display-article article all-headers)
7745 (when (gnus-buffer-live-p gnus-article-buffer)
7746 (with-current-buffer gnus-article-buffer
7747 (if (not gnus-article-decoded-p) ;; a local variable
7748 (mm-disable-multibyte))))
7749 (gnus-article-set-window-start
7750 (cdr (assq article gnus-newsgroup-bookmarks)))
7754 (defun gnus-summary-force-verify-and-decrypt ()
7755 "Display buttons for signed/encrypted parts and verify/decrypt them."
7757 (let ((mm-verify-option 'known)
7758 (mm-decrypt-option 'known)
7759 (gnus-article-emulate-mime t)
7760 (gnus-buttonized-mime-types (append (list "multipart/signed"
7761 "multipart/encrypted")
7762 gnus-buttonized-mime-types)))
7763 (gnus-summary-select-article nil 'force)))
7765 (defun gnus-summary-set-current-mark (&optional current-mark)
7766 "Obsolete function."
7769 (defun gnus-summary-next-article (&optional unread subject backward push)
7770 "Select the next article.
7771 If UNREAD, only unread articles are selected.
7772 If SUBJECT, only articles with SUBJECT are selected.
7773 If BACKWARD, the previous article is selected instead of the next."
7775 ;; Make sure we are in the summary buffer.
7776 (unless (eq major-mode 'gnus-summary-mode)
7777 (set-buffer gnus-summary-buffer))
7779 ;; Is there such an article?
7780 ((and (gnus-summary-search-forward unread subject backward)
7781 (or (gnus-summary-display-article (gnus-summary-article-number))
7782 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7783 (gnus-summary-position-point))
7784 ;; If not, we try the first unread, if that is wanted.
7786 gnus-auto-select-same
7787 (gnus-summary-first-unread-article))
7788 (gnus-summary-position-point)
7789 (gnus-message 6 "Wrapped"))
7790 ;; Try to get next/previous article not displayed in this group.
7791 ((and gnus-auto-extend-newsgroup
7792 (not unread) (not subject))
7793 (gnus-summary-goto-article
7794 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7795 nil (count-lines (point-min) (point))))
7796 ;; Go to next/previous group.
7798 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7799 (gnus-summary-jump-to-group gnus-newsgroup-name))
7800 (let ((cmd (if (featurep 'xemacs)
7802 last-command-event))
7804 (with-current-buffer gnus-group-buffer
7806 (current-summary (current-buffer))
7808 (if (eq gnus-keep-same-level 'best)
7809 (gnus-summary-best-group gnus-newsgroup-name)
7810 (gnus-summary-search-group backward gnus-keep-same-level))))
7811 ;; Select next unread newsgroup automagically.
7813 ((or (not gnus-auto-select-next)
7815 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7816 ((or (eq gnus-auto-select-next 'quietly)
7817 (and (eq gnus-auto-select-next 'slightly-quietly)
7819 (and (eq gnus-auto-select-next 'almost-quietly)
7820 (gnus-summary-last-article-p)))
7822 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7824 (gnus-message 7 "No more%s articles (%s)..."
7825 (if unread " unread" "")
7826 (if group (concat "selecting " group)
7828 (gnus-summary-next-group nil group backward)))
7830 (when (gnus-key-press-event-p last-input-event)
7831 ;; Somehow or other, we may now have selected a different
7832 ;; window. Make point go back to the summary buffer.
7833 (when (eq current-summary (current-buffer))
7834 ;; FIXME: This burps when get-buffer-window returns nil.
7835 (select-window (get-buffer-window current-summary 0)))
7836 (gnus-summary-walk-group-buffer
7837 gnus-newsgroup-name cmd unread backward point))))))))
7839 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7840 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7841 (?\C-p (gnus-group-prev-unread-group 1))))
7842 (cursor-in-echo-area t)
7843 keve key group ended prompt)
7844 (with-current-buffer gnus-group-buffer
7847 (if (eq gnus-keep-same-level 'best)
7848 (gnus-summary-best-group gnus-newsgroup-name)
7849 (gnus-summary-search-group backward gnus-keep-same-level))))
7853 "No more%s articles%s " (if unread " unread" "")
7855 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7856 (format " (Type %s for %s [%s])"
7857 (single-key-description cmd)
7858 (gnus-group-decoded-name group)
7859 (gnus-group-unread group))
7860 (format " (Type %s to exit %s)"
7861 (single-key-description cmd)
7862 (gnus-group-decoded-name gnus-newsgroup-name)))))
7863 ;; Confirm auto selection.
7864 (setq key (car (setq keve (gnus-read-event-char prompt)))
7867 ((assq key keystrokes)
7868 (let ((obuf (current-buffer)))
7869 (switch-to-buffer gnus-group-buffer)
7871 (gnus-group-jump-to-group group))
7872 (eval (cadr (assq key keystrokes)))
7873 (setq group (gnus-group-group-name))
7874 (switch-to-buffer obuf))
7878 (gnus-ephemeral-group-p gnus-newsgroup-name))
7880 (gnus-summary-next-group nil group backward)))
7882 (push (cdr keve) unread-command-events))))))
7884 (defun gnus-summary-next-unread-article ()
7885 "Select unread article after current one."
7887 (gnus-summary-next-article
7888 (or (not (eq gnus-summary-goto-unread 'never))
7889 (gnus-summary-last-article-p (gnus-summary-article-number)))
7890 (and gnus-auto-select-same
7891 (gnus-summary-article-subject))))
7893 (defun gnus-summary-prev-article (&optional unread subject)
7894 "Select the article before the current one.
7895 If UNREAD is non-nil, only unread articles are selected."
7897 (gnus-summary-next-article unread subject t))
7899 (defun gnus-summary-prev-unread-article ()
7900 "Select unread article before current one."
7902 (gnus-summary-prev-article
7903 (or (not (eq gnus-summary-goto-unread 'never))
7904 (gnus-summary-first-article-p (gnus-summary-article-number)))
7905 (and gnus-auto-select-same
7906 (gnus-summary-article-subject))))
7908 (defun gnus-summary-next-page (&optional lines circular stop)
7909 "Show next page of the selected article.
7910 If at the end of the current article, select the next article.
7911 LINES says how many lines should be scrolled up.
7913 If CIRCULAR is non-nil, go to the start of the article instead of
7914 selecting the next article when reaching the end of the current
7917 If STOP is non-nil, just stop when reaching the end of the message.
7919 Also see the variable `gnus-article-skip-boring'."
7921 (setq gnus-summary-buffer (current-buffer))
7922 (gnus-set-global-variables)
7923 (let ((article (gnus-summary-article-number))
7924 (article-window (get-buffer-window gnus-article-buffer t))
7926 ;; If the buffer is empty, we have no article.
7928 (error "No article to select"))
7929 (gnus-configure-windows 'article)
7930 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7931 (if (and (eq gnus-summary-goto-unread 'never)
7932 (not (gnus-summary-last-article-p article)))
7933 (gnus-summary-next-article)
7934 (gnus-summary-next-unread-article))
7935 (if (or (null gnus-current-article)
7936 (null gnus-article-current)
7937 (/= article (cdr gnus-article-current))
7938 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7939 ;; Selected subject is different from current article's.
7940 (gnus-summary-display-article article)
7941 (when article-window
7942 (gnus-eval-in-buffer-window gnus-article-buffer
7943 (setq endp (or (gnus-article-next-page lines)
7944 (gnus-article-only-boring-p))))
7946 (cond ((or stop gnus-summary-stop-at-end-of-message)
7947 (gnus-message 3 "End of message"))
7949 (gnus-summary-beginning-of-article))
7951 (gnus-message 3 "End of message"))
7953 (if (and (eq gnus-summary-goto-unread 'never)
7954 (not (gnus-summary-last-article-p article)))
7955 (gnus-summary-next-article)
7956 (gnus-summary-next-unread-article))))))))
7957 (gnus-summary-recenter)
7958 (gnus-summary-position-point)))
7960 (defun gnus-summary-prev-page (&optional lines move)
7961 "Show previous page of selected article.
7962 Argument LINES specifies lines to be scrolled down.
7963 If MOVE, move to the previous unread article if point is at
7964 the beginning of the buffer."
7966 (let ((article (gnus-summary-article-number))
7967 (article-window (get-buffer-window gnus-article-buffer t))
7969 (gnus-configure-windows 'article)
7970 (if (or (null gnus-current-article)
7971 (null gnus-article-current)
7972 (/= article (cdr gnus-article-current))
7973 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7974 ;; Selected subject is different from current article's.
7975 (gnus-summary-display-article article)
7976 (gnus-summary-recenter)
7977 (when article-window
7978 (gnus-eval-in-buffer-window gnus-article-buffer
7979 (setq endp (gnus-article-prev-page lines)))
7980 (when (and move endp)
7982 (gnus-message 3 "Beginning of message"))
7984 (if (and (eq gnus-summary-goto-unread 'never)
7985 (not (gnus-summary-first-article-p article)))
7986 (gnus-summary-prev-article)
7987 (gnus-summary-prev-unread-article))))))))
7988 (gnus-summary-position-point))
7990 (defun gnus-summary-prev-page-or-article (&optional lines)
7991 "Show previous page of selected article.
7992 Argument LINES specifies lines to be scrolled down.
7993 If at the beginning of the article, go to the next article."
7995 (gnus-summary-prev-page lines t))
7997 (defun gnus-summary-scroll-up (lines)
7998 "Scroll up (or down) one line current article.
7999 Argument LINES specifies lines to be scrolled up (or down if negative).
8000 If no article is selected, then the current article will be selected first."
8002 (gnus-configure-windows 'article)
8003 (gnus-summary-show-thread)
8004 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8005 (gnus-eval-in-buffer-window gnus-article-buffer
8007 (when (gnus-article-next-page lines)
8008 (gnus-message 3 "End of message")))
8010 (gnus-article-prev-page (- lines))))))
8011 (gnus-summary-recenter)
8012 (gnus-summary-position-point))
8014 (defun gnus-summary-scroll-down (lines)
8015 "Scroll down (or up) one line current article.
8016 Argument LINES specifies lines to be scrolled down (or up if negative).
8017 If no article is selected, then the current article will be selected first."
8019 (gnus-summary-scroll-up (- lines)))
8021 (defun gnus-summary-next-same-subject ()
8022 "Select next article which has the same subject as current one."
8024 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8026 (defun gnus-summary-prev-same-subject ()
8027 "Select previous article which has the same subject as current one."
8029 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8031 (defun gnus-summary-next-unread-same-subject ()
8032 "Select next unread article which has the same subject as current one."
8034 (gnus-summary-next-article t (gnus-summary-article-subject)))
8036 (defun gnus-summary-prev-unread-same-subject ()
8037 "Select previous unread article which has the same subject as current one."
8039 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8041 (defun gnus-summary-first-unread-article ()
8042 "Select the first unread article.
8043 Return nil if there are no unread articles."
8046 (when (gnus-summary-first-subject t)
8047 (gnus-summary-show-thread)
8048 (gnus-summary-first-subject t)
8049 (gnus-summary-display-article (gnus-summary-article-number)))
8050 (gnus-summary-position-point)))
8052 (defun gnus-summary-first-unread-subject ()
8053 "Place the point on the subject line of the first unread article.
8054 Return nil if there are no unread articles."
8057 (when (gnus-summary-first-subject t)
8058 (gnus-summary-show-thread)
8059 (gnus-summary-first-subject t))
8060 (gnus-summary-position-point)))
8062 (defun gnus-summary-first-unseen-subject ()
8063 "Place the point on the subject line of the first unseen article.
8064 Return nil if there are no unseen articles."
8067 (when (gnus-summary-first-subject nil nil t)
8068 (gnus-summary-show-thread)
8069 (gnus-summary-first-subject nil nil t))
8070 (gnus-summary-position-point)))
8072 (defun gnus-summary-first-unseen-or-unread-subject ()
8073 "Place the point on the subject line of the first unseen and unread article.
8074 If all article have been seen, on the subject line of the first unread
8078 (unless (when (gnus-summary-first-subject nil nil t)
8079 (gnus-summary-show-thread)
8080 (gnus-summary-first-subject nil nil t))
8081 (when (gnus-summary-first-subject t)
8082 (gnus-summary-show-thread)
8083 (gnus-summary-first-subject t)))
8084 (gnus-summary-position-point)))
8086 (defun gnus-summary-first-article ()
8087 "Select the first article.
8088 Return nil if there are no articles."
8091 (when (gnus-summary-first-subject)
8092 (gnus-summary-show-thread)
8093 (gnus-summary-first-subject)
8094 (gnus-summary-display-article (gnus-summary-article-number)))
8095 (gnus-summary-position-point)))
8097 (defun gnus-summary-best-unread-article (&optional arg)
8098 "Select the unread article with the highest score.
8099 If given a prefix argument, select the next unread article that has a
8100 score higher than the default score."
8102 (let ((article (if arg
8103 (gnus-summary-better-unread-subject)
8104 (gnus-summary-best-unread-subject))))
8106 (gnus-summary-goto-article article)
8107 (error "No unread articles"))))
8109 (defun gnus-summary-best-unread-subject ()
8110 "Select the unread subject with the highest score."
8112 (let ((best -1000000)
8113 (data gnus-newsgroup-data)
8116 (and (gnus-data-unread-p (car data))
8118 (gnus-summary-article-score (gnus-data-number (car data))))
8121 article (gnus-data-number (car data))))
8122 (setq data (cdr data)))
8124 (gnus-summary-goto-subject article))
8125 (gnus-summary-position-point)
8128 (defun gnus-summary-better-unread-subject ()
8129 "Select the first unread subject that has a score over the default score."
8131 (let ((data gnus-newsgroup-data)
8133 (while (and (setq article (gnus-data-number (car data)))
8134 (or (gnus-data-read-p (car data))
8135 (not (> (gnus-summary-article-score article)
8136 gnus-summary-default-score))))
8137 (setq data (cdr data)))
8139 (gnus-summary-goto-subject article))
8140 (gnus-summary-position-point)
8143 (defun gnus-summary-last-subject ()
8144 "Go to the last displayed subject line in the group."
8145 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8147 (gnus-summary-goto-subject article))))
8149 (defun gnus-summary-goto-article (article &optional all-headers force)
8150 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8151 If ALL-HEADERS is non-nil, no header lines are hidden.
8152 If FORCE, go to the article even if it isn't displayed. If FORCE
8153 is a number, it is the line the article is to be displayed on."
8156 (gnus-completing-read
8157 "Article number or Message-ID"
8158 (mapcar 'int-to-string gnus-newsgroup-limit))
8162 (if (and (stringp article)
8163 (string-match "@\\|%40" article))
8164 (gnus-summary-refer-article article)
8165 (when (stringp article)
8166 (setq article (string-to-number article)))
8167 (if (gnus-summary-goto-subject article force)
8168 (gnus-summary-display-article article all-headers)
8169 (gnus-message 4 "Couldn't go to article %s" article) nil))
8170 (gnus-summary-position-point)))
8172 (defun gnus-summary-goto-last-article ()
8173 "Go to the previously read article."
8176 (when gnus-last-article
8177 (gnus-summary-goto-article gnus-last-article nil t))
8178 (gnus-summary-position-point)))
8180 (defun gnus-summary-pop-article (number)
8181 "Pop one article off the history and go to the previous.
8182 NUMBER articles will be popped off."
8185 (setq gnus-newsgroup-history
8186 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8188 (gnus-summary-goto-article (car to) nil t)
8189 (error "Article history empty")))
8190 (gnus-summary-position-point))
8192 ;; Summary commands and functions for limiting the summary buffer.
8194 (defun gnus-summary-limit-to-articles (n)
8195 "Limit the summary buffer to the next N articles.
8196 If not given a prefix, use the process marked articles instead."
8199 (let ((articles (gnus-summary-work-articles n)))
8200 (setq gnus-newsgroup-processable nil)
8201 (gnus-summary-limit articles))
8202 (gnus-summary-position-point)))
8204 (defun gnus-summary-pop-limit (&optional total)
8205 "Restore the previous limit.
8206 If given a prefix, remove all limits."
8209 (setq gnus-newsgroup-limits
8210 (list (mapcar (lambda (h) (mail-header-number h))
8211 gnus-newsgroup-headers))))
8212 (unless gnus-newsgroup-limits
8213 (error "No limit to pop"))
8215 (gnus-summary-limit nil 'pop)
8216 (gnus-summary-position-point)))
8218 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8219 "Limit the summary buffer to articles that have subjects that match a regexp.
8220 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8222 (list (read-string (if current-prefix-arg
8223 "Exclude subject (regexp): "
8224 "Limit to subject (regexp): "))
8225 nil current-prefix-arg))
8227 (setq header "subject"))
8228 (when (not (equal "" subject))
8230 (let ((articles (gnus-summary-find-matching
8231 (or header "subject") subject 'all nil nil
8234 (error "Found no matches for \"%s\"" subject))
8235 (gnus-summary-limit articles))
8236 (gnus-summary-position-point))))
8238 (defun gnus-summary-limit-to-author (from &optional not-matching)
8239 "Limit the summary buffer to articles that have authors that match a regexp.
8240 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8242 (list (read-string (if current-prefix-arg
8243 "Exclude author (regexp): "
8244 "Limit to author (regexp): "))
8245 current-prefix-arg))
8246 (gnus-summary-limit-to-subject from "from" not-matching))
8248 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8249 "Limit the summary buffer to articles with the given RECIPIENT.
8251 If NOT-MATCHING, exclude RECIPIENT.
8253 To and Cc headers are checked. You need to include them in
8254 `nnmail-extra-headers'."
8255 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8257 (list (read-string (format "%s recipient (regexp): "
8258 (if current-prefix-arg "Exclude" "Limit to")))
8259 current-prefix-arg))
8260 (when (not (equal "" recipient))
8262 (if (memq 'To nnmail-extra-headers)
8263 (gnus-summary-find-matching
8264 (cons 'extra 'To) recipient 'all nil nil
8267 1 "`To' isn't present in `nnmail-extra-headers'")
8271 (if (memq 'Cc nnmail-extra-headers)
8272 (gnus-summary-find-matching
8273 (cons 'extra 'Cc) recipient 'all nil nil
8276 1 "`Cc' isn't present in `nnmail-extra-headers'")
8281 ;; We need the numbers that are in both lists:
8283 (and (memq a to) a))
8287 (error "Found no matches for \"%s\"" recipient))
8288 (gnus-summary-limit articles))
8289 (gnus-summary-position-point))))
8291 (defun gnus-summary-limit-to-address (address &optional not-matching)
8292 "Limit the summary buffer to articles with the given ADDRESS.
8294 If NOT-MATCHING, exclude ADDRESS.
8296 To, Cc and From headers are checked. You need to include `To' and `Cc'
8297 in `nnmail-extra-headers'."
8299 (list (read-string (format "%s address (regexp): "
8300 (if current-prefix-arg "Exclude" "Limit to")))
8301 current-prefix-arg))
8302 (when (not (equal "" address))
8304 (if (memq 'To nnmail-extra-headers)
8305 (gnus-summary-find-matching
8306 (cons 'extra 'To) address 'all nil nil
8309 1 "`To' isn't present in `nnmail-extra-headers'")
8313 (if (memq 'Cc nnmail-extra-headers)
8314 (gnus-summary-find-matching
8315 (cons 'extra 'Cc) address 'all nil nil
8318 1 "`Cc' isn't present in `nnmail-extra-headers'")
8322 (gnus-summary-find-matching "from" address
8323 'all nil nil not-matching))
8326 ;; We need the numbers that are in all lists:
8330 (mapcar (lambda (a) (car (memq a from))) to))
8332 (mapcar (lambda (a) (car (memq a from))) cc)
8333 (mapcar (lambda (a) (car (memq a from)))
8334 (mapcar (lambda (a) (car (memq a to)))
8336 (nconc (if (eq to t) nil to)
8337 (if (eq cc t) nil cc)
8340 (error "Found no matches for \"%s\"" address))
8341 (gnus-summary-limit articles))
8342 (gnus-summary-position-point))))
8344 (defun gnus-summary-limit-strange-charsets-predicate (header)
8345 (when (fboundp 'char-charset)
8346 (let ((string (concat (mail-header-subject header)
8347 (mail-header-from header)))
8349 (dotimes (i (1- (length string)))
8350 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8351 (when (string-match "unicode\\|big\\|japanese" charset)
8355 (defun gnus-summary-limit-to-predicate (predicate)
8356 "Limit to articles where PREDICATE returns non-nil.
8357 PREDICATE will be called with the header structures of the
8359 (let ((articles nil)
8360 (case-fold-search t))
8361 (dolist (header gnus-newsgroup-headers)
8362 (when (funcall predicate header)
8363 (push (mail-header-number header) articles)))
8364 (gnus-summary-limit (nreverse articles))))
8366 (defun gnus-summary-limit-to-age (age &optional younger-p)
8367 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8368 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8369 articles that are younger than AGE days."
8371 (let ((younger current-prefix-arg)
8374 (while (not days-got)
8375 (setq days (if younger
8376 (read-string "Limit to articles younger than (in days, older when negative): ")
8378 "Limit to articles older than (in days, younger when negative): ")))
8379 (when (> (length days) 0)
8380 (setq days (read days)))
8385 (setq younger (not younger))
8386 (setq days (* days -1))))
8387 (message "Please enter a number.")
8389 (list days younger)))
8391 (let ((data gnus-newsgroup-data)
8392 (cutoff (days-to-time age))
8393 articles d date is-younger)
8394 (while (setq d (pop data))
8395 (when (and (vectorp (gnus-data-header d))
8396 (setq date (mail-header-date (gnus-data-header d))))
8397 (setq is-younger (time-less-p
8398 (time-since (gnus-date-get-time date))
8403 (push (gnus-data-number d) articles))))
8404 (gnus-summary-limit (nreverse articles)))
8405 (gnus-summary-position-point)))
8407 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8408 "Limit the summary buffer to articles that match an 'extra' header."
8412 (gnus-completing-read
8413 (if current-prefix-arg
8414 "Exclude extra header"
8415 "Limit extra header")
8416 (mapcar 'symbol-name gnus-extra-headers)
8418 (symbol-name (car gnus-extra-headers))))))
8420 (read-string (format "%s header %s (regexp): "
8421 (if current-prefix-arg "Exclude" "Limit to")
8423 current-prefix-arg)))
8424 (when (not (equal "" regexp))
8426 (let ((articles (gnus-summary-find-matching
8427 (cons 'extra header) regexp 'all nil nil
8430 (error "Found no matches for \"%s\"" regexp))
8431 (gnus-summary-limit articles))
8432 (gnus-summary-position-point))))
8434 (defun gnus-summary-limit-to-display-predicate ()
8435 "Limit the summary buffer to the predicated in the `display' group parameter."
8437 (unless gnus-newsgroup-display
8438 (error "There is no `display' group parameter"))
8440 (dolist (gnus-number gnus-newsgroup-articles)
8441 (when (funcall gnus-newsgroup-display)
8442 (push gnus-number articles)))
8443 (gnus-summary-limit articles))
8444 (gnus-summary-position-point))
8446 (defun gnus-summary-limit-to-unread (&optional all)
8447 "Limit the summary buffer to articles that are not marked as read.
8448 If ALL is non-nil, limit strictly to unread articles."
8451 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8452 (gnus-summary-limit-to-marks
8453 ;; Concat all the marks that say that an article is read and have
8455 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8456 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8457 gnus-low-score-mark gnus-expirable-mark
8458 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8459 gnus-duplicate-mark)
8462 (defun gnus-summary-limit-to-headers (match &optional reverse)
8463 "Limit the summary buffer to articles that have headers that match MATCH.
8464 If REVERSE (the prefix), limit to articles that don't match."
8465 (interactive "sMatch headers (regexp): \nP")
8466 (gnus-summary-limit-to-bodies match reverse t))
8468 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8469 "Limit the summary buffer to articles that have bodies that match MATCH.
8470 If REVERSE (the prefix), limit to articles that don't match."
8471 (interactive "sMatch body (regexp): \nP")
8472 (let ((articles nil)
8473 (gnus-select-article-hook nil) ;Disable hook.
8474 (gnus-article-prepare-hook nil)
8475 (gnus-use-article-prefetch nil)
8476 (gnus-keep-backlog nil)
8477 (gnus-break-pages nil)
8478 (gnus-summary-display-arrow nil)
8479 (gnus-updated-mode-lines nil)
8480 (gnus-auto-center-summary nil)
8481 (gnus-display-mime-function nil))
8482 (dolist (data gnus-newsgroup-data)
8483 (let (gnus-mark-article-hook)
8484 (gnus-summary-select-article t t nil (gnus-data-number data)))
8485 (with-current-buffer gnus-article-buffer
8487 (let* ((case-fold-search t)
8489 (re-search-backward match nil t)
8490 (re-search-forward match nil t))))
8491 (when (or (and found
8495 (push (gnus-data-number data) articles)))))
8497 (message "No messages matched")
8498 (gnus-summary-limit articles)))
8499 (gnus-summary-position-point))
8501 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8502 "Limit the summary buffer to articles that aren't part on any thread.
8503 If THREADSP (the prefix), limit to articles that are in threads."
8505 (let ((articles nil)
8508 (dolist (thread gnus-newsgroup-threads)
8509 (if (stringp (car thread))
8510 (dolist (thread (cdr thread))
8511 (push thread threads))
8512 (push thread threads)))
8513 (dolist (thread threads)
8514 (setq thread-articles (gnus-articles-in-thread thread))
8515 (when (or (and threadsp
8516 (> (length thread-articles) 1))
8518 (= (length thread-articles) 1)))
8519 (setq articles (nconc thread-articles articles))))
8521 (message "No messages matched")
8522 (gnus-summary-limit articles))
8523 (gnus-summary-position-point)))
8525 (defun gnus-summary-limit-to-replied (&optional unreplied)
8526 "Limit the summary buffer to replied articles.
8527 If UNREPLIED (the prefix), limit to unreplied articles."
8531 (gnus-set-difference gnus-newsgroup-articles
8532 gnus-newsgroup-replied))
8533 (gnus-summary-limit gnus-newsgroup-replied))
8534 (gnus-summary-position-point))
8536 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8537 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8538 If REVERSE, limit the summary buffer to articles that are marked
8539 with MARKS. MARKS can either be a string of marks or a list of marks.
8540 Returns how many articles were removed."
8541 (interactive "sMarks: ")
8542 (gnus-summary-limit-to-marks marks t))
8544 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8545 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8546 If REVERSE (the prefix), limit the summary buffer to articles that are
8547 not marked with MARKS. MARKS can either be a string of marks or a
8549 Returns how many articles were removed."
8550 (interactive "sMarks: \nP")
8552 (let ((data gnus-newsgroup-data)
8553 (marks (if (listp marks) marks
8554 (append marks nil))) ; Transform to list.
8557 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8558 (memq (gnus-data-mark (car data)) marks))
8559 (push (gnus-data-number (car data)) articles))
8560 (setq data (cdr data)))
8561 (gnus-summary-limit articles))
8562 (gnus-summary-position-point)))
8564 (defun gnus-summary-limit-to-score (score)
8565 "Limit to articles with score at or above SCORE."
8566 (interactive "NLimit to articles with score of at least: ")
8567 (let ((data gnus-newsgroup-data)
8570 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8572 (push (gnus-data-number (car data)) articles))
8573 (setq data (cdr data)))
8575 (gnus-summary-limit articles)
8576 (gnus-summary-position-point))))
8578 (defun gnus-summary-limit-to-unseen ()
8579 "Limit to unseen articles."
8582 (gnus-summary-limit gnus-newsgroup-unseen)
8583 (gnus-summary-position-point)))
8585 (defun gnus-summary-limit-include-thread (id)
8586 "Display all the hidden articles that is in the thread with ID in it.
8587 When called interactively, ID is the Message-ID of the current
8589 (interactive (list (mail-header-id (gnus-summary-article-header))))
8590 (let ((articles (gnus-articles-in-thread
8591 (gnus-id-to-thread (gnus-root-id id))))
8592 ;;we REALLY want the whole thread---this prevents cut-threads
8593 ;;from removing the thread we want to include.
8594 (gnus-fetch-old-headers nil)
8595 (gnus-build-sparse-threads nil))
8597 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8598 (gnus-summary-limit-include-matching-articles
8600 (regexp-quote (gnus-simplify-subject-re
8601 (mail-header-subject (gnus-id-to-header id)))))
8602 (gnus-summary-position-point))))
8604 (defun gnus-summary-limit-include-matching-articles (header regexp)
8605 "Display all the hidden articles that have HEADERs that match REGEXP."
8606 (interactive (list (read-string "Match on header: ")
8607 (read-string "Regexp: ")))
8608 (let ((articles (gnus-find-matching-articles header regexp)))
8610 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8611 (gnus-summary-position-point))))
8613 (defun gnus-summary-insert-dormant-articles ()
8614 "Insert all the dormant articles for this group into the current buffer."
8616 (let ((gnus-verbose (max 6 gnus-verbose)))
8617 (if (not gnus-newsgroup-dormant)
8618 (gnus-message 3 "No dormant articles for this group")
8619 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8621 (defun gnus-summary-insert-ticked-articles ()
8622 "Insert ticked articles for this group into the current buffer."
8624 (let ((gnus-verbose (max 6 gnus-verbose)))
8625 (if (not gnus-newsgroup-marked)
8626 (gnus-message 3 "No ticked articles for this group")
8627 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8629 (defun gnus-summary-limit-include-dormant ()
8630 "Display all the hidden articles that are marked as dormant.
8631 Note that this command only works on a subset of the articles currently
8632 fetched for this group."
8634 (unless gnus-newsgroup-dormant
8635 (error "There are no dormant articles in this group"))
8637 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8638 (gnus-summary-position-point)))
8640 (defun gnus-summary-include-articles (articles)
8641 "Fetch the headers for ARTICLES and then display the summary lines."
8642 (let ((gnus-inhibit-demon t)
8644 (gnus-read-all-available-headers t))
8645 (setq gnus-newsgroup-headers
8647 'list gnus-newsgroup-headers
8648 (gnus-fetch-headers articles nil t)
8649 'gnus-article-sort-by-number))
8650 (setq gnus-newsgroup-articles
8651 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8652 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8654 (defun gnus-summary-limit-exclude-dormant ()
8655 "Hide all dormant articles."
8658 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8659 (gnus-summary-position-point)))
8661 (defun gnus-summary-limit-exclude-childless-dormant ()
8662 "Hide all dormant articles that have no children."
8664 (let ((data (gnus-data-list t))
8665 articles d children)
8666 ;; Find all articles that are either not dormant or have
8668 (while (setq d (pop data))
8669 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8671 (gnus-article-children (gnus-data-number d)))
8674 (when (memq (car children) articles)
8679 (push (gnus-data-number d) articles)))
8682 (gnus-summary-limit articles)
8683 (gnus-summary-position-point))))
8685 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8686 "Mark all unread excluded articles as read.
8687 If ALL, mark even excluded ticked and dormants as read."
8689 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8690 (let ((articles (gnus-sorted-ndifference
8692 (mapcar (lambda (h) (mail-header-number h))
8693 gnus-newsgroup-headers)
8695 gnus-newsgroup-limit))
8697 (setq gnus-newsgroup-unreads
8698 (gnus-sorted-intersection gnus-newsgroup-unreads
8699 gnus-newsgroup-limit))
8701 (setq gnus-newsgroup-dormant nil
8702 gnus-newsgroup-marked nil
8703 gnus-newsgroup-reads
8705 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8706 gnus-newsgroup-reads))
8707 (while (setq article (pop articles))
8708 (unless (or (memq article gnus-newsgroup-dormant)
8709 (memq article gnus-newsgroup-marked))
8710 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8712 (defun gnus-summary-limit (articles &optional pop)
8714 ;; We pop the previous limit off the stack and use that.
8715 (setq articles (car gnus-newsgroup-limits)
8716 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8717 ;; We use the new limit, so we push the old limit on the stack.
8718 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8720 (setq gnus-newsgroup-limit articles)
8721 (let ((total (length gnus-newsgroup-data))
8722 (data (gnus-data-find-list (gnus-summary-article-number)))
8723 (gnus-summary-mark-below nil) ; Inhibit this.
8725 ;; This will do all the work of generating the new summary buffer
8726 ;; according to the new limit.
8727 (gnus-summary-prepare)
8728 ;; Hide any threads, possibly.
8729 (gnus-summary-maybe-hide-threads)
8730 ;; Try to return to the article you were at, or one in the
8733 ;; We try to find some article after the current one.
8735 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8738 (setq data (cdr data))))
8740 ;; If there is no data, that means that we were after the last
8741 ;; article. The same goes when we can't find any articles
8742 ;; after the current one.
8743 (goto-char (point-max))
8744 (gnus-summary-find-prev))
8745 (gnus-set-mode-line 'summary)
8746 ;; We return how many articles were removed from the summary
8747 ;; buffer as a result of the new limit.
8748 (- total (length gnus-newsgroup-data))))
8750 (defsubst gnus-invisible-cut-children (threads)
8753 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8758 (defsubst gnus-cut-thread (thread)
8759 "Go forwards in the thread until we find an article that we want to display."
8760 (when (or (eq gnus-fetch-old-headers 'some)
8761 (eq gnus-fetch-old-headers 'invisible)
8762 (numberp gnus-fetch-old-headers)
8763 (eq gnus-build-sparse-threads 'some)
8764 (eq gnus-build-sparse-threads 'more))
8765 ;; Deal with old-fetched headers and sparse threads.
8769 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8770 (gnus-summary-article-ancient-p
8771 (mail-header-number (car thread))))
8772 (if (or (<= (length (cdr thread)) 1)
8773 (eq gnus-fetch-old-headers 'invisible))
8774 (setq gnus-newsgroup-limit
8775 (delq (mail-header-number (car thread))
8776 gnus-newsgroup-limit)
8777 thread (cadr thread))
8778 (when (gnus-invisible-cut-children (cdr thread))
8779 (let ((th (cdr thread)))
8781 (if (memq (mail-header-number (caar th))
8782 gnus-newsgroup-limit)
8783 (setq thread (car th)
8785 (setq th (cdr th))))))))))
8788 (defun gnus-cut-threads (threads)
8789 "Cut off all uninteresting articles from the beginning of THREADS."
8790 (when (or (eq gnus-fetch-old-headers 'some)
8791 (eq gnus-fetch-old-headers 'invisible)
8792 (numberp gnus-fetch-old-headers)
8793 (eq gnus-build-sparse-threads 'some)
8794 (eq gnus-build-sparse-threads 'more))
8797 (setcar th (gnus-cut-thread (car th)))
8798 (setq th (cdr th)))))
8799 ;; Remove nixed out threads.
8802 (defun gnus-summary-initial-limit (&optional show-if-empty)
8803 "Figure out what the initial limit is supposed to be on group entry.
8804 This entails weeding out unwanted dormants, low-scored articles,
8805 fetch-old-headers verbiage, and so on."
8806 ;; Most groups have nothing to remove.
8807 (unless (or gnus-inhibit-limiting
8808 (and (null gnus-newsgroup-dormant)
8809 (eq gnus-newsgroup-display 'gnus-not-ignore)
8810 (not (eq gnus-fetch-old-headers 'some))
8811 (not (numberp gnus-fetch-old-headers))
8812 (not (eq gnus-fetch-old-headers 'invisible))
8813 (null gnus-summary-expunge-below)
8814 (not (eq gnus-build-sparse-threads 'some))
8815 (not (eq gnus-build-sparse-threads 'more))
8816 (null gnus-thread-expunge-below)))
8817 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8818 (setq gnus-newsgroup-limit nil)
8821 (unless (car (symbol-value node))
8822 ;; These threads have no parents -- they are roots.
8823 (let ((nodes (cdr (symbol-value node)))
8826 (if (and gnus-thread-expunge-below
8827 (< (gnus-thread-total-score (car nodes))
8828 gnus-thread-expunge-below))
8829 (gnus-expunge-thread (pop nodes))
8830 (setq thread (pop nodes))
8831 (gnus-summary-limit-children thread))))))
8832 gnus-newsgroup-dependencies)
8833 ;; If this limitation resulted in an empty group, we might
8834 ;; pop the previous limit and use it instead.
8835 (when (and (not gnus-newsgroup-limit)
8837 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8838 gnus-newsgroup-limit))
8840 (defun gnus-summary-limit-children (thread)
8841 "Return 1 if this subthread is visible and 0 if it is not."
8842 ;; First we get the number of visible children to this thread. This
8843 ;; is done by recursing down the thread using this function, so this
8844 ;; will really go down to a leaf article first, before slowly
8845 ;; working its way up towards the root.
8847 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8850 (apply '+ (mapcar 'gnus-summary-limit-children
8853 (number (mail-header-number (car thread)))
8856 (not (memq number gnus-newsgroup-marked))
8858 ;; If this article is dormant and has absolutely no visible
8859 ;; children, then this article isn't visible.
8860 (and (memq number gnus-newsgroup-dormant)
8862 ;; If this is "fetch-old-headered" and there is no
8863 ;; visible children, then we don't want this article.
8864 (and (or (eq gnus-fetch-old-headers 'some)
8865 (numberp gnus-fetch-old-headers))
8866 (gnus-summary-article-ancient-p number)
8868 ;; If this is "fetch-old-headered" and `invisible', then
8869 ;; we don't want this article.
8870 (and (eq gnus-fetch-old-headers 'invisible)
8871 (gnus-summary-article-ancient-p number))
8872 ;; If this is a sparsely inserted article with no children,
8873 ;; we don't want it.
8874 (and (eq gnus-build-sparse-threads 'some)
8875 (gnus-summary-article-sparse-p number)
8877 ;; If we use expunging, and this article is really
8878 ;; low-scored, then we don't want this article.
8879 (when (and gnus-summary-expunge-below
8881 (or (cdr (assq number gnus-newsgroup-scored))
8882 gnus-summary-default-score))
8883 gnus-summary-expunge-below))
8884 ;; We increase the expunge-tally here, but that has
8885 ;; nothing to do with the limits, really.
8886 (incf gnus-newsgroup-expunged-tally)
8887 ;; We also mark as read here, if that's wanted.
8888 (when (and gnus-summary-mark-below
8889 (< score gnus-summary-mark-below))
8890 (setq gnus-newsgroup-unreads
8891 (delq number gnus-newsgroup-unreads))
8892 (if gnus-newsgroup-auto-expire
8893 (push number gnus-newsgroup-expirable)
8894 (push (cons number gnus-low-score-mark)
8895 gnus-newsgroup-reads)))
8897 ;; Do the `display' group parameter.
8898 (and gnus-newsgroup-display
8899 (let ((gnus-number number))
8900 (not (funcall gnus-newsgroup-display))))))
8901 ;; Nope, invisible article.
8903 ;; Ok, this article is to be visible, so we add it to the limit
8905 (push number gnus-newsgroup-limit)
8908 (defun gnus-expunge-thread (thread)
8909 "Mark all articles in THREAD as read."
8910 (let* ((number (mail-header-number (car thread))))
8911 (incf gnus-newsgroup-expunged-tally)
8912 ;; We also mark as read here, if that's wanted.
8913 (setq gnus-newsgroup-unreads
8914 (delq number gnus-newsgroup-unreads))
8915 (if gnus-newsgroup-auto-expire
8916 (push number gnus-newsgroup-expirable)
8917 (push (cons number gnus-low-score-mark)
8918 gnus-newsgroup-reads)))
8919 ;; Go recursively through all subthreads.
8920 (mapcar 'gnus-expunge-thread (cdr thread)))
8922 ;; Summary article oriented commands
8924 (defun gnus-summary-refer-parent-article (n)
8925 "Refer parent article N times.
8926 If N is negative, go to ancestor -N instead.
8927 The difference between N and the number of articles fetched is returned."
8931 (when (not (natnump n))
8936 (setq header (gnus-summary-article-header))
8937 (if (and (eq (mail-header-number header)
8938 (cdr gnus-article-current))
8939 (equal gnus-newsgroup-name
8940 (car gnus-article-current)))
8941 ;; If we try to find the parent of the currently
8942 ;; displayed article, then we take a look at the actual
8943 ;; References header, since this is slightly more
8944 ;; reliable than the References field we got from the
8946 (with-current-buffer gnus-original-article-buffer
8947 (nnheader-narrow-to-headers)
8948 (unless (setq ref (message-fetch-field "references"))
8949 (when (setq ref (message-fetch-field "in-reply-to"))
8950 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8953 ;; It's not the current article, so we take a bet on
8954 ;; the value we got from the server.
8955 (mail-header-references header)))
8957 (not (equal ref "")))
8958 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8959 (gnus-message 1 "Couldn't find parent"))
8960 (gnus-message 1 "No references in article %d"
8961 (gnus-summary-article-number))
8964 (gnus-summary-position-point)
8967 (defun gnus-summary-refer-references ()
8968 "Fetch all articles mentioned in the References header.
8969 Return the number of articles fetched."
8971 (let ((ref (mail-header-references (gnus-summary-article-header)))
8972 (current (gnus-summary-article-number))
8976 (error "No References in the current article")
8977 ;; For each Message-ID in the References header...
8978 (while (string-match "<[^>]*>" ref)
8980 ;; ... fetch that article.
8981 (gnus-summary-refer-article
8982 (prog1 (match-string 0 ref)
8983 (setq ref (substring ref (match-end 0))))))
8984 (gnus-summary-goto-subject current)
8985 (gnus-summary-position-point)
8988 (defun gnus-delete-duplicate-headers (headers)
8989 ;; First remove leading duplicates.
8990 (while (and (> (length headers) 1)
8991 (= (mail-header-number (car headers))
8992 (mail-header-number (cadr headers))))
8995 (let ((result headers))
8996 (while (> (length headers) 1)
8997 (if (= (mail-header-number (car headers))
8998 (mail-header-number (cadr headers)))
8999 (setcdr headers (cddr headers))
9003 (defun gnus-summary-refer-thread (&optional limit)
9004 "Fetch all articles in the current thread. For backends that
9005 know how to search for threads (currently only 'nnimap) a
9006 non-numeric prefix arg will use nnir to search the entire
9007 server; without a prefix arg only the current group is
9008 searched. If the variable `gnus-refer-thread-use-nnir' is
9009 non-nil the prefix arg has the reverse meaning. If no
9010 backend-specific 'request-thread function is available fetch
9011 LIMIT (the numerical prefix) old headers. If LIMIT is
9012 non-numeric or nil fetch the number specified by the
9013 `gnus-refer-thread-limit' variable."
9015 (gnus-warp-to-article)
9016 (let* ((header (gnus-summary-article-header))
9017 (id (mail-header-id header))
9018 (gnus-inhibit-demon t)
9019 (gnus-summary-ignore-duplicates t)
9020 (gnus-read-all-available-headers t)
9021 (gnus-refer-thread-use-nnir
9022 (if (and (not (null limit)) (listp limit))
9023 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9025 (if (gnus-check-backend-function
9026 'request-thread gnus-newsgroup-name)
9027 (gnus-request-thread header gnus-newsgroup-name)
9028 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9029 gnus-refer-thread-limit))
9030 (last (if (numberp limit)
9031 (min (+ (mail-header-number header)
9033 gnus-newsgroup-highest)
9034 gnus-newsgroup-highest))
9035 (subject (gnus-simplify-subject
9036 (mail-header-subject header)))
9037 (refs (split-string (or (mail-header-references header)
9039 (gnus-parse-headers-hook
9040 `(lambda () (goto-char (point-min))
9042 (regexp-opt ',(append refs (list id subject)))))))
9043 (gnus-fetch-headers (list last) (if (numberp limit)
9044 (* 2 limit) limit) t))))
9046 (when (listp new-headers)
9047 (dolist (header new-headers)
9048 (push (mail-header-number header) article-ids)
9049 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9050 (push (mail-header-number header) gnus-newsgroup-unreads)
9051 (setq gnus-newsgroup-unselected
9052 (delete (mail-header-number header)
9053 gnus-newsgroup-unselected))))
9054 (setq gnus-newsgroup-headers
9055 (gnus-delete-duplicate-headers
9057 'list gnus-newsgroup-headers new-headers
9058 'gnus-article-sort-by-number)))
9059 (setq gnus-newsgroup-articles
9060 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9061 (gnus-summary-limit-include-thread id)))
9062 (gnus-summary-show-thread))
9064 (defun gnus-summary-refer-article (message-id)
9065 "Fetch an article specified by MESSAGE-ID."
9066 (interactive "sMessage-ID: ")
9067 (gnus-warp-to-article)
9068 (when (and (stringp message-id)
9069 (not (zerop (length message-id))))
9070 (setq message-id (gnus-replace-in-string message-id " " ""))
9071 ;; Construct the correct Message-ID if necessary.
9072 ;; Suggested by tale@pawl.rpi.edu.
9073 (unless (string-match "^<" message-id)
9074 (setq message-id (concat "<" message-id)))
9075 (unless (string-match ">$" message-id)
9076 (setq message-id (concat message-id ">")))
9077 ;; People often post MIDs from URLs, so unhex it:
9078 (unless (string-match "@" message-id)
9079 (setq message-id (gnus-url-unhex-string message-id)))
9080 (let* ((header (gnus-id-to-header message-id))
9082 (gnus-summary-article-sparse-p
9083 (mail-header-number header))
9084 (memq (mail-header-number header)
9085 gnus-newsgroup-limit)))
9088 ;; If the article is present in the buffer we just go to it.
9090 (or (not (gnus-summary-article-sparse-p
9091 (mail-header-number header)))
9094 (gnus-summary-goto-article
9095 (mail-header-number header) nil t)
9097 (gnus-summary-update-article (mail-header-number header)))))
9099 ;; We fetch the article.
9101 (dolist (gnus-override-method (gnus-refer-article-methods))
9102 (when (and (gnus-check-server gnus-override-method)
9103 ;; Fetch the header,
9104 (setq number (gnus-summary-insert-subject message-id)))
9105 ;; and display the article.
9106 (gnus-summary-select-article nil nil nil number)
9108 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9110 (defun gnus-refer-article-methods ()
9111 "Return a list of referable methods."
9113 ;; No method, so we default to current and native.
9114 ((null gnus-refer-article-method)
9115 (list gnus-current-select-method gnus-select-method))
9117 ((eq 'current gnus-refer-article-method)
9118 (list gnus-current-select-method))
9119 ;; List of select methods.
9120 ((not (and (symbolp (car gnus-refer-article-method))
9121 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9123 (dolist (method gnus-refer-article-method)
9124 (push (if (eq 'current method)
9125 gnus-current-select-method
9126 (if (eq 'nnir (car method))
9130 (gnus-method-to-server gnus-current-select-method)))
9134 ;; One single select method.
9136 (list gnus-refer-article-method))))
9138 (defun gnus-summary-edit-parameters ()
9139 "Edit the group parameters of the current group."
9141 (gnus-group-edit-group gnus-newsgroup-name 'params))
9143 (defun gnus-summary-customize-parameters ()
9144 "Customize the group parameters of the current group."
9146 (gnus-group-customize gnus-newsgroup-name))
9148 (defun gnus-summary-enter-digest-group (&optional force)
9149 "Enter an nndoc group based on the current article.
9150 If FORCE, force a digest interpretation. If not, try to guess
9151 what the document format is.
9153 To control what happens when you exit the group, see the
9154 `gnus-auto-select-on-ephemeral-exit' variable."
9156 (let ((conf gnus-current-window-configuration))
9157 (save-window-excursion
9159 (let (gnus-article-prepare-hook
9160 gnus-display-mime-function
9162 (gnus-summary-select-article))))
9163 (setq gnus-current-window-configuration conf)
9164 (let* ((name (format "%s-%d"
9165 (gnus-group-prefixed-name
9166 gnus-newsgroup-name (list 'nndoc ""))
9167 (with-current-buffer gnus-summary-buffer
9168 gnus-current-article)))
9169 (ogroup gnus-newsgroup-name)
9170 (params (append (gnus-info-params (gnus-get-info ogroup))
9171 (list (cons 'to-group ogroup))
9172 (list (cons 'parent-group ogroup))
9173 (list (cons 'save-article-group ogroup))))
9174 (case-fold-search t)
9175 (buf (current-buffer))
9177 (with-current-buffer gnus-original-article-buffer
9178 ;; Have the digest group inherit the main mail address of
9179 ;; the parent article.
9180 (when (setq to-address (or (gnus-fetch-field "reply-to")
9181 (gnus-fetch-field "from")))
9184 (list (cons 'to-address
9185 (funcall gnus-decode-encoded-address-function
9187 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9188 (insert-buffer-substring gnus-original-article-buffer)
9189 ;; Remove lines that may lead nndoc to misinterpret the
9192 (goto-char (point-min))
9193 (or (search-forward "\n\n" nil t) (point)))
9194 (goto-char (point-min))
9195 (delete-matching-lines "^Path:\\|^From ")
9198 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9199 (gnus-newsgroup-ephemeral-ignored-charsets
9200 gnus-newsgroup-ignored-charsets))
9201 (gnus-group-read-ephemeral-group
9202 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9204 ,(if force 'mbox 'guess)))
9206 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9208 ;; Make all postings to this group go to the parent group.
9209 (nconc (gnus-info-params (gnus-get-info name))
9211 ;; Couldn't select this doc group.
9212 (switch-to-buffer buf)
9213 (gnus-set-global-variables)
9214 (gnus-configure-windows 'summary)
9215 (gnus-message 3 "Article couldn't be entered?"))
9216 (kill-buffer dig)))))
9218 (defun gnus-summary-read-document (n)
9219 "Open a new group based on the current article(s).
9220 This will allow you to read digests and other similar
9221 documents as newsgroups.
9222 Obeys the standard process/prefix convention."
9224 (let* ((ogroup gnus-newsgroup-name)
9225 (params (append (gnus-info-params (gnus-get-info ogroup))
9226 (list (cons 'to-group ogroup))))
9227 group egroup groups vgroup)
9228 (dolist (article (gnus-summary-work-articles n))
9229 (setq group (format "%s-%d" gnus-newsgroup-name article))
9230 (gnus-summary-remove-process-mark article)
9231 (when (gnus-summary-display-article article)
9232 (save-excursion ;;What for?
9234 (insert-buffer-substring gnus-original-article-buffer)
9235 ;; Remove some headers that may lead nndoc to make
9237 (message-narrow-to-head)
9238 (goto-char (point-min))
9239 (delete-matching-lines "^Path:\\|^From ")
9242 (gnus-group-read-ephemeral-group
9243 group `(nndoc ,group (nndoc-address ,(current-buffer))
9244 (nndoc-article-type guess))
9247 ;; Make all postings to this group go to the parent group.
9248 (nconc (gnus-info-params (gnus-get-info egroup))
9250 (push egroup groups))
9251 ;; Couldn't select this doc group.
9252 (gnus-error 3 "Article couldn't be entered"))))))
9253 ;; Now we have selected all the documents.
9256 (error "None of the articles could be interpreted as documents"))
9257 ((gnus-group-read-ephemeral-group
9258 (setq vgroup (format
9259 "nnvirtual:%s-%s" gnus-newsgroup-name
9260 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9261 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9263 (cons (current-buffer) 'summary)))
9265 (error "Couldn't select virtual nndoc group")))))
9267 (defun gnus-summary-widget-forward (arg)
9268 "Move point to the next field or button in the article.
9269 With optional ARG, move across that many fields."
9271 (gnus-summary-select-article)
9272 (gnus-configure-windows 'article)
9273 (select-window (gnus-get-buffer-window gnus-article-buffer))
9274 (widget-forward arg))
9276 (defun gnus-summary-widget-backward (arg)
9277 "Move point to the previous field or button in the article.
9278 With optional ARG, move across that many fields."
9280 (gnus-summary-select-article)
9281 (gnus-configure-windows 'article)
9282 (select-window (gnus-get-buffer-window gnus-article-buffer))
9283 (unless (widget-at (point))
9284 (goto-char (point-max)))
9285 (widget-backward arg))
9287 (defun gnus-summary-isearch-article (&optional regexp-p)
9288 "Do incremental search forward on the current article.
9289 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9291 (gnus-summary-select-article)
9292 (gnus-configure-windows 'article)
9293 (gnus-eval-in-buffer-window gnus-article-buffer
9296 (isearch-forward regexp-p))))
9298 (defun gnus-summary-repeat-search-article-forward ()
9299 "Repeat the previous search forwards."
9301 (unless gnus-last-search-regexp
9302 (error "No previous search"))
9303 (gnus-summary-search-article-forward gnus-last-search-regexp))
9305 (defun gnus-summary-repeat-search-article-backward ()
9306 "Repeat the previous search backwards."
9308 (unless gnus-last-search-regexp
9309 (error "No previous search"))
9310 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9312 (defun gnus-summary-search-article-forward (regexp &optional backward)
9313 "Search for an article containing REGEXP forward.
9314 If BACKWARD, search backward instead."
9317 (format "Search article %s (regexp%s): "
9318 (if current-prefix-arg "backward" "forward")
9319 (if gnus-last-search-regexp
9320 (concat ", default " gnus-last-search-regexp)
9322 current-prefix-arg))
9323 (if (string-equal regexp "")
9324 (setq regexp (or gnus-last-search-regexp ""))
9325 (setq gnus-last-search-regexp regexp)
9326 (setq gnus-article-before-search gnus-current-article))
9327 ;; Intentionally set gnus-last-article.
9328 (setq gnus-last-article gnus-article-before-search)
9329 (let ((gnus-last-article gnus-last-article))
9330 (if (gnus-summary-search-article regexp backward)
9331 (gnus-summary-show-thread)
9332 (signal 'search-failed (list regexp)))))
9334 (defun gnus-summary-search-article-backward (regexp)
9335 "Search for an article containing REGEXP backward."
9338 (format "Search article backward (regexp%s): "
9339 (if gnus-last-search-regexp
9340 (concat ", default " gnus-last-search-regexp)
9342 (gnus-summary-search-article-forward regexp 'backward))
9344 (defun gnus-summary-search-article (regexp &optional backward)
9345 "Search for an article containing REGEXP.
9346 Optional argument BACKWARD means do search for backward.
9347 `gnus-select-article-hook' is not called during the search."
9348 ;; We have to require this here to make sure that the following
9349 ;; dynamic binding isn't shadowed by autoloading.
9350 (require 'gnus-async)
9352 (let ((gnus-select-article-hook nil) ;Disable hook.
9353 (gnus-article-prepare-hook nil)
9354 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9355 (gnus-use-article-prefetch nil)
9356 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9357 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9359 (gnus-keep-backlog nil)
9360 (gnus-break-pages nil)
9361 (gnus-summary-display-arrow nil)
9362 (gnus-updated-mode-lines nil)
9363 (gnus-auto-center-summary nil)
9364 (sum (current-buffer))
9365 (gnus-display-mime-function nil)
9368 (gnus-save-hidden-threads
9369 (gnus-summary-select-article)
9370 (set-buffer gnus-article-buffer)
9371 (goto-char (window-point (get-buffer-window (current-buffer))))
9375 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9377 (re-search-backward regexp nil t)
9378 (re-search-forward regexp nil t))
9379 ;; We found the regexp.
9384 (get-buffer-window (current-buffer))
9388 (get-buffer-window (current-buffer))
9391 (setq point (point)))
9392 ;; We didn't find it, so we go to the next article.
9395 (while (eq found 'not)
9396 (if (not (if backward (gnus-summary-find-prev)
9397 (gnus-summary-find-next)))
9398 ;; No more articles.
9400 ;; Select the next article and adjust point.
9401 (unless (gnus-summary-article-sparse-p
9402 (gnus-summary-article-number))
9404 (gnus-summary-select-article)
9405 (set-buffer gnus-article-buffer)
9407 (goto-char (if backward (point-max) (point-min))))))))
9408 (gnus-message 7 ""))
9409 ;; Return whether we found the regexp.
9410 (when (eq found 'found)
9412 (gnus-summary-show-thread)
9413 (gnus-summary-goto-subject gnus-current-article)
9414 (gnus-summary-position-point)
9417 (defun gnus-find-matching-articles (header regexp)
9418 "Return a list of all articles that match REGEXP on HEADER.
9419 This search includes all articles in the current group that Gnus has
9420 fetched headers for, whether they are displayed or not."
9421 (let ((articles nil)
9422 ;; Can't eta-reduce because it's a macro.
9423 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9424 (case-fold-search t))
9425 (dolist (header gnus-newsgroup-headers)
9426 (when (string-match regexp (funcall func header))
9427 (push (mail-header-number header) articles)))
9428 (nreverse articles)))
9430 (defun gnus-summary-find-matching (header regexp &optional backward unread
9431 not-case-fold not-matching)
9432 "Return a list of all articles that match REGEXP on HEADER.
9433 The search stars on the current article and goes forwards unless
9434 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9435 If UNREAD is non-nil, only unread articles will
9436 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9437 in the comparisons. If NOT-MATCHING, return a list of all articles that
9438 not match REGEXP on HEADER."
9439 (let ((case-fold-search (not not-case-fold))
9442 (if (eq (car header) 'extra)
9445 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9447 (error "%s is an invalid header" header))
9448 (unless (fboundp (intern (concat "mail-header-" header)))
9449 (error "%s is not a valid header" header))
9450 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9451 (dolist (d (if (eq backward 'all)
9453 (gnus-data-find-list
9454 (gnus-summary-article-number)
9455 (gnus-data-list backward))))
9456 (when (and (or (not unread) ; We want all articles...
9457 (gnus-data-unread-p d)) ; Or just unreads.
9458 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9462 (funcall func (gnus-data-header d))))
9463 (string-match regexp
9464 (funcall func (gnus-data-header d)))))
9465 (push (gnus-data-number d) articles))) ; Success!
9466 (nreverse articles)))
9468 (defun gnus-summary-execute-command (header regexp command &optional backward)
9469 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9470 If HEADER is an empty string (or nil), the match is done on the entire
9471 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9473 (list (let ((completion-ignore-case t))
9474 (gnus-completing-read
9476 (mapcar 'symbol-name
9478 '(Number Subject From Lines Date
9479 Message-ID Xref References Body)
9480 gnus-extra-headers))
9482 (read-string "Regexp: ")
9483 (read-key-sequence "Command: ")
9484 current-prefix-arg))
9485 (when (equal header "Body")
9487 ;; Hidden thread subtrees must be searched as well.
9488 (gnus-summary-show-all-threads)
9489 ;; We don't want to change current point nor window configuration.
9491 (save-window-excursion
9493 gnus-treat-strip-trailing-blank-lines
9494 gnus-treat-strip-leading-blank-lines
9495 gnus-treat-strip-multiple-blank-lines
9496 gnus-treat-hide-boring-headers
9497 gnus-treat-fold-newsgroups
9498 gnus-article-prepare-hook)
9499 (gnus-message 6 "Executing %s..." (key-description command))
9500 ;; We'd like to execute COMMAND interactively so as to give arguments.
9501 (gnus-execute header regexp
9502 `(call-interactively ',(key-binding command))
9504 (gnus-message 6 "Executing %s...done" (key-description command))))))
9506 (defun gnus-summary-beginning-of-article ()
9507 "Scroll the article back to the beginning."
9509 (gnus-summary-select-article)
9510 (gnus-configure-windows 'article)
9511 (gnus-eval-in-buffer-window gnus-article-buffer
9513 (goto-char (point-min))
9514 (when gnus-break-pages
9515 (gnus-narrow-to-page))))
9517 (defun gnus-summary-end-of-article ()
9518 "Scroll to the end of the article."
9520 (gnus-summary-select-article)
9521 (gnus-configure-windows 'article)
9522 (gnus-eval-in-buffer-window gnus-article-buffer
9524 (goto-char (point-max))
9526 (when gnus-break-pages
9527 (gnus-narrow-to-page))))
9529 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9530 "Truncate to LEN and quote all \"(\"'s in STRING."
9531 (gnus-replace-in-string (if (and len (> (length string) len))
9532 (substring string 0 len)
9536 (defun gnus-summary-print-article (&optional filename n)
9537 "Generate and print a PostScript image of the process-marked (mail) articles.
9539 If used interactively, print the current article if none are
9540 process-marked. With prefix arg, prompt the user for the name of the
9543 When used from Lisp, accept two optional args FILENAME and N. N means
9544 to print the next N articles. If N is negative, print the N previous
9545 articles. If N is nil and articles have been marked with the process
9546 mark, print these instead.
9548 If the optional first argument FILENAME is nil, send the image to the
9549 printer. If FILENAME is a string, save the PostScript image in a file with
9550 that name. If FILENAME is a number, prompt the user for the name of the file
9552 (interactive (list (ps-print-preprint current-prefix-arg)))
9553 (dolist (article (gnus-summary-work-articles n))
9554 (gnus-summary-select-article nil nil 'pseudo article)
9555 (gnus-eval-in-buffer-window gnus-article-buffer
9556 (gnus-print-buffer))
9557 (gnus-summary-remove-process-mark article))
9558 (ps-despool filename))
9560 (defun gnus-print-buffer ()
9561 (let ((ps-left-header
9564 (gnus-summary-print-truncate-and-quote
9565 (mail-header-subject gnus-current-headers)
9568 (gnus-summary-print-truncate-and-quote
9569 (mail-header-from gnus-current-headers)
9573 "/pagenumberstring load"
9575 (mail-header-date gnus-current-headers) ")"))))
9576 (gnus-run-hooks 'gnus-ps-print-hook)
9578 (if ps-print-color-p
9579 (ps-spool-buffer-with-faces)
9580 (ps-spool-buffer)))))
9582 (defun gnus-summary-show-complete-article ()
9583 "Show a complete version of the current article.
9584 This is only useful if you're looking at a partial version of the
9587 (let ((gnus-keep-backlog nil)
9588 (gnus-use-cache nil)
9591 (format "%s-fetch-partial-articles"
9592 (car (gnus-find-method-for-group
9593 gnus-newsgroup-name)))
9598 (setq old-val (symbol-value variable))
9600 (gnus-flush-original-article-buffer)
9601 (gnus-summary-show-article))
9602 (set variable old-val))))
9604 (defun gnus-summary-show-article (&optional arg)
9605 "Force redisplaying of the current article.
9606 If ARG (the prefix) is a number, show the article with the charset
9607 defined in `gnus-summary-show-article-charset-alist', or the charset
9609 If ARG (the prefix) is non-nil and not a number, show the article,
9610 but without running any of the article treatment functions
9611 article. Normally, the keystroke is `C-u g'. When using `C-u
9612 C-u g', show the raw article."
9616 (gnus-summary-show-article t)
9617 (let ((gnus-newsgroup-charset
9618 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9619 (mm-read-coding-system
9620 "View as charset: " ;; actually it is coding system.
9621 (with-current-buffer gnus-article-buffer
9622 (mm-detect-coding-region (point) (point-max))))))
9623 (gnus-newsgroup-ignored-charsets 'gnus-all))
9624 (gnus-summary-select-article nil 'force)
9625 (let ((deps gnus-newsgroup-dependencies)
9627 (with-current-buffer gnus-original-article-buffer
9629 (message-narrow-to-head)
9630 (setq head (buffer-string))
9631 (goto-char (point-min))
9632 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9633 (goto-char (point-max))
9635 (setq lines (1- (count-lines (point) (point-max))))))
9637 (insert (format "211 %d Article retrieved.\n"
9638 (cdr gnus-article-current)))
9640 (if lines (insert (format "Lines: %d\n" lines)))
9642 (let ((nntp-server-buffer (current-buffer)))
9643 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9644 (gnus-data-set-header
9645 (gnus-data-find (cdr gnus-article-current))
9647 (gnus-summary-update-article-line
9648 (cdr gnus-article-current) header)
9649 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9650 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9652 ;; Select the article the normal way.
9653 (if (eq mm-text-html-renderer 'shr)
9656 (let ((shr-ignore-cache t))
9657 (gnus-summary-select-article nil 'force)))
9658 (gnus-summary-select-article nil 'force)))
9661 (let ((gnus-inhibit-article-treatments t))
9662 (gnus-summary-select-article nil 'force)))
9664 ;; We have to require this here to make sure that the following
9665 ;; dynamic binding isn't shadowed by autoloading.
9666 (require 'gnus-async)
9668 ;; Bind the article treatment functions to nil.
9669 (let ((gnus-have-all-headers t)
9670 gnus-article-prepare-hook
9671 gnus-article-decode-hook
9672 gnus-display-mime-function
9674 ;; Destroy any MIME parts.
9675 (when (gnus-buffer-live-p gnus-article-buffer)
9676 (with-current-buffer gnus-article-buffer
9677 (gnus-article-stop-animations)
9678 (gnus-stop-downloads)
9679 (mm-destroy-parts gnus-article-mime-handles)
9680 ;; Set it to nil for safety reason.
9681 (setq gnus-article-mime-handle-alist nil)
9682 (setq gnus-article-mime-handles nil)))
9683 (gnus-summary-select-article nil 'force))))
9684 (gnus-summary-goto-subject gnus-current-article)
9685 (gnus-summary-position-point))
9687 (defun gnus-summary-show-raw-article ()
9688 "Show the raw article without any article massaging functions being run."
9690 (gnus-summary-show-article t))
9692 (defun gnus-summary-verbose-headers (&optional arg)
9693 "Toggle permanent full header display.
9694 If ARG is a positive number, turn header display on.
9695 If ARG is a negative number, turn header display off."
9697 (setq gnus-show-all-headers
9698 (cond ((or (not (numberp arg))
9700 (not gnus-show-all-headers))
9703 (gnus-summary-show-article))
9705 (defun gnus-summary-toggle-header (&optional arg)
9706 "Show the headers if they are hidden, or hide them if they are shown.
9707 If ARG is a positive number, show the entire header.
9708 If ARG is a negative number, hide the unwanted header lines."
9710 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9711 (get-buffer-window gnus-article-buffer t))))
9712 (with-current-buffer gnus-article-buffer
9714 (article-narrow-to-head)
9715 (let* ((inhibit-read-only t)
9716 (inhibit-point-motion-hooks t)
9717 (hidden (if (numberp arg)
9719 (or (not (looking-at "[^ \t\n]+:"))
9720 (gnus-article-hidden-text-p 'headers))))
9722 (delete-region (point-min) (point-max))
9723 (with-current-buffer gnus-original-article-buffer
9724 (goto-char (setq s (point-min)))
9725 (setq e (if (search-forward "\n\n" nil t)
9728 (insert-buffer-substring gnus-original-article-buffer s e)
9729 (run-hooks 'gnus-article-decode-hook)
9731 (let ((gnus-treat-hide-headers nil)
9732 (gnus-treat-hide-boring-headers nil))
9733 (gnus-delete-wash-type 'headers)
9734 (gnus-treat-article 'head))
9735 (gnus-treat-article 'head))
9738 (set-window-start window (goto-char (point-min))))
9739 (if gnus-break-pages
9740 (gnus-narrow-to-page)
9741 (when (gnus-visual-p 'page-marker)
9742 (let ((inhibit-read-only t))
9743 (gnus-remove-text-with-property 'gnus-prev)
9744 (gnus-remove-text-with-property 'gnus-next))))
9745 (gnus-set-mode-line 'article)))))
9747 (defun gnus-summary-show-all-headers ()
9748 "Make all header lines visible."
9750 (gnus-summary-toggle-header 1))
9752 (defun gnus-summary-caesar-message (&optional arg)
9753 "Caesar rotate the current article by 13.
9754 With a non-numerical prefix, also rotate headers. A numerical
9755 prefix specifies how many places to rotate each letter forward."
9757 (gnus-summary-select-article)
9758 (let ((mail-header-separator ""))
9759 (gnus-eval-in-buffer-window gnus-article-buffer
9762 (let ((start (window-start))
9763 (inhibit-read-only t))
9764 (if (equal arg '(4))
9765 (message-caesar-buffer-body nil t)
9766 (message-caesar-buffer-body arg))
9767 (set-window-start (get-buffer-window (current-buffer)) start)))))
9768 ;; Create buttons and stuff...
9769 (gnus-treat-article nil))
9771 (declare-function idna-to-unicode "ext:idna" (str))
9773 (defun gnus-summary-idna-message (&optional arg)
9774 "Decode IDNA encoded domain names in the current articles.
9775 IDNA encoded domain names looks like `xn--bar'. If a string
9776 remain unencoded after running this function, it is likely an
9777 invalid IDNA string (`xn--bar' is invalid).
9779 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9780 installed for this command to work."
9782 (if (not (and (condition-case nil (require 'idna)
9784 (mm-coding-system-p 'utf-8)
9785 (executable-find (symbol-value 'idna-program))))
9787 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9788 (gnus-summary-select-article)
9789 (let ((mail-header-separator ""))
9790 (gnus-eval-in-buffer-window gnus-article-buffer
9793 (let ((start (window-start))
9795 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9796 (replace-match (idna-to-unicode (match-string 1))))
9797 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9799 (defun gnus-summary-morse-message (&optional arg)
9800 "Morse decode the current article."
9802 (gnus-summary-select-article)
9803 (let ((mail-header-separator ""))
9804 (gnus-eval-in-buffer-window gnus-article-buffer
9808 (let ((pos (window-start))
9809 (inhibit-read-only t))
9810 (goto-char (point-min))
9811 (when (message-goto-body)
9812 (gnus-narrow-to-body))
9813 (goto-char (point-min))
9814 (while (search-forward "·" (point-max) t)
9815 (replace-match "."))
9816 (unmorse-region (point-min) (point-max))
9818 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9820 (defun gnus-summary-stop-page-breaking ()
9821 "Stop page breaking in the current article."
9823 (gnus-summary-select-article)
9824 (gnus-eval-in-buffer-window gnus-article-buffer
9826 (when (gnus-visual-p 'page-marker)
9827 (let ((inhibit-read-only t))
9828 (gnus-remove-text-with-property 'gnus-prev)
9829 (gnus-remove-text-with-property 'gnus-next))
9830 (setq gnus-page-broken nil))))
9832 (defun gnus-summary-move-article (&optional n to-newsgroup
9833 select-method action)
9834 "Move the current article to a different newsgroup.
9835 If N is a positive number, move the N next articles.
9836 If N is a negative number, move the N previous articles.
9837 If N is nil and any articles have been marked with the process mark,
9838 move those articles instead.
9839 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9840 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9841 re-spool using this method.
9843 When called interactively with TO-NEWSGROUP being nil, the value of
9844 the variable `gnus-move-split-methods' is used for finding a default
9845 for the target newsgroup.
9847 For this function to work, both the current newsgroup and the
9848 newsgroup that you want to move to have to support the `request-move'
9849 and `request-accept' functions.
9851 ACTION can be either `move' (the default), `crosspost' or `copy'."
9854 (setq action 'move))
9855 ;; Check whether the source group supports the required functions.
9856 (cond ((and (eq action 'move)
9857 (not (gnus-check-backend-function
9858 'request-move-article gnus-newsgroup-name)))
9859 (error "The current group does not support article moving"))
9860 ((and (eq action 'crosspost)
9861 (not (gnus-check-backend-function
9862 'request-replace-article gnus-newsgroup-name)))
9863 (error "The current group does not support article editing")))
9864 (let ((articles (gnus-summary-work-articles n))
9865 (prefix (if (gnus-check-backend-function
9866 'request-move-article gnus-newsgroup-name)
9867 (funcall gnus-move-group-prefix-function
9868 gnus-newsgroup-name)
9870 (names '((move "Move" "Moving")
9871 (copy "Copy" "Copying")
9872 (crosspost "Crosspost" "Crossposting")))
9873 (copy-buf (save-excursion
9874 (nnheader-set-temp-buffer " *copy article*")))
9875 art-group to-method new-xref article to-groups
9876 articles-to-update-marks encoded)
9877 (unless (assq action names)
9878 (error "Unknown action %s" action))
9879 ;; Read the newsgroup name.
9880 (when (and (not to-newsgroup)
9881 (not select-method))
9882 (if (and gnus-move-split-methods
9884 (and (memq gnus-current-article articles)
9885 (gnus-buffer-live-p gnus-original-article-buffer))))
9886 ;; When `gnus-move-split-methods' is non-nil, we have to
9887 ;; select an article to give `gnus-read-move-group-name' an
9888 ;; opportunity to suggest an appropriate default. However,
9889 ;; we needn't render or mark the article.
9890 (let ((gnus-display-mime-function nil)
9891 (gnus-article-prepare-hook nil)
9892 (gnus-mark-article-hook nil))
9893 (gnus-summary-select-article nil nil nil (car articles))))
9894 (setq to-newsgroup (gnus-read-move-group-name
9895 (cadr (assq action names))
9897 (intern (format "gnus-current-%s-group" action)))
9899 encoded to-newsgroup
9900 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9901 (set (intern (format "gnus-current-%s-group" action))
9902 (mm-decode-coding-string
9904 (gnus-group-name-charset to-method to-newsgroup))))
9906 (setq to-method (or select-method
9907 (gnus-server-to-method
9908 (gnus-group-method to-newsgroup)))))
9912 (mm-encode-coding-string
9914 (gnus-group-name-charset to-method to-newsgroup)))))
9915 ;; Check the method we are to move this article to...
9916 (unless (gnus-check-backend-function
9917 'request-accept-article (car to-method))
9918 (error "%s does not support article copying" (car to-method)))
9919 (unless (gnus-check-server to-method)
9920 (error "Can't open server %s" (car to-method)))
9921 (gnus-message 6 "%s to %s: %s..."
9922 (caddr (assq action names))
9923 (or (car select-method)
9924 (gnus-group-decoded-name to-newsgroup))
9927 (setq article (pop articles))
9928 ;; Set any marks that may have changed in the summary buffer.
9929 (when gnus-preserve-marks
9930 (gnus-summary-push-marks-to-backend article))
9934 ;; Move the article.
9936 ;; Remove this article from future suppression.
9937 (gnus-dup-unsuppress-article article)
9938 (let* ((from-method (gnus-find-method-for-group
9939 gnus-newsgroup-name))
9940 (to-method (or select-method
9941 (gnus-find-method-for-group to-newsgroup)))
9942 (move-is-internal (gnus-server-equal from-method to-method)))
9943 (gnus-request-move-article
9944 article ; Article to move
9945 gnus-newsgroup-name ; From newsgroup
9946 (nth 1 (gnus-find-method-for-group
9947 gnus-newsgroup-name)) ; Server
9948 (list 'gnus-request-accept-article
9949 to-newsgroup (list 'quote select-method)
9950 (not articles) t) ; Accept form
9951 (not articles) ; Only save nov last time
9952 (and move-is-internal
9953 to-newsgroup ; Not respooling
9954 ; Is this move internal?
9955 (gnus-group-real-name to-newsgroup)))))
9956 ;; Copy the article.
9958 (with-current-buffer copy-buf
9959 (when (gnus-request-article-this-buffer article
9960 gnus-newsgroup-name)
9962 (nnheader-narrow-to-headers)
9963 (dolist (hdr gnus-copy-article-ignored-headers)
9964 (message-remove-header hdr t)))
9965 (gnus-request-accept-article
9966 to-newsgroup select-method (not articles) t))))
9967 ;; Crosspost the article.
9968 ((eq action 'crosspost)
9969 (let ((xref (message-tokenize-header
9970 (mail-header-xref (gnus-summary-article-header
9973 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9974 ":" (number-to-string article)))
9976 (setq xref (list (system-name))))
9979 (mapconcat 'identity
9980 (delete "Xref:" (delete new-xref xref))
9983 (with-current-buffer copy-buf
9984 ;; First put the article in the destination group.
9985 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9986 (when (consp (setq art-group
9987 (gnus-request-accept-article
9988 to-newsgroup select-method (not articles)
9990 (setq new-xref (concat new-xref " " (car art-group)
9992 (number-to-string (cdr art-group))))
9993 ;; Now we have the new Xrefs header, so we insert
9994 ;; it and replace the new article.
9995 (nnheader-replace-header "Xref" new-xref)
9996 (gnus-request-replace-article
9997 (cdr art-group) to-newsgroup (current-buffer) t)
10001 (gnus-message 1 "Couldn't %s article %s: %s"
10002 (cadr (assq action names)) article
10003 (nnheader-get-report (car to-method))))
10004 ((eq art-group 'junk)
10005 (when (eq action 'move)
10006 (gnus-summary-mark-article article gnus-canceled-mark)
10007 (gnus-message 4 "Deleted article %s" article)
10008 ;; run the delete hook
10009 (run-hook-with-args 'gnus-summary-article-delete-hook
10012 (assoc article (gnus-data-list nil)))
10013 gnus-newsgroup-name nil
10016 (let* ((pto-group (gnus-group-prefixed-name
10017 (car art-group) to-method))
10018 (info (gnus-get-info pto-group))
10019 (to-group (gnus-info-group info))
10021 ;; Update the group that has been moved to.
10023 (memq action '(move copy)))
10024 (unless (member to-group to-groups)
10025 (push to-group to-groups))
10027 (when (and (not (memq article gnus-newsgroup-unreads))
10029 (push 'read to-marks)
10030 (gnus-info-set-read
10031 info (gnus-add-to-range (gnus-info-read info)
10032 (list (cdr art-group)))))
10034 ;; See whether the article is to be put in the cache.
10035 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10036 (marks (if expirable
10037 gnus-article-mark-lists
10038 (delete '(expirable . expire)
10040 gnus-article-mark-lists))))
10041 (to-article (cdr art-group)))
10043 ;; Enter the article into the cache in the new group,
10044 ;; if that is required.
10045 (when (and to-article
10047 (gnus-cache-possibly-enter-article
10048 to-group to-article
10049 (memq article gnus-newsgroup-marked)
10050 (memq article gnus-newsgroup-dormant)
10051 (memq article gnus-newsgroup-unreads)))
10053 (when (and gnus-preserve-marks
10055 ;; Copy any marks over to the new group.
10056 (when (and (equal to-group gnus-newsgroup-name)
10057 (not (memq article gnus-newsgroup-unreads)))
10058 ;; Mark this article as read in this group.
10059 (push (cons to-article gnus-read-mark)
10060 gnus-newsgroup-reads)
10061 ;; Increase the active status of this group.
10062 (setcdr (gnus-active to-group) to-article)
10063 (setcdr gnus-newsgroup-active to-article))
10066 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10067 (when (memq article (symbol-value
10068 (intern (format "gnus-newsgroup-%s"
10070 (push (cdar marks) to-marks)
10071 ;; If the other group is the same as this group,
10072 ;; then we have to add the mark to the list.
10073 (when (equal to-group gnus-newsgroup-name)
10074 (set (intern (format "gnus-newsgroup-%s"
10078 (intern (format "gnus-newsgroup-%s"
10080 ;; Copy the marks to other group.
10081 (gnus-add-marked-articles
10082 to-group (cdar marks) (list to-article) info)))
10083 (setq marks (cdr marks)))
10085 (when (and expirable
10086 gnus-mark-copied-or-moved-articles-as-expirable
10087 (not (memq 'expire to-marks)))
10088 ;; Mark this article as expirable.
10089 (push 'expire to-marks)
10090 (when (equal to-group gnus-newsgroup-name)
10091 (push to-article gnus-newsgroup-expirable))
10092 ;; Copy the expirable mark to other group.
10093 (gnus-add-marked-articles
10094 to-group 'expire (list to-article) info))
10096 (when (and to-marks
10097 (gnus-method-option-p
10098 (gnus-find-method-for-group to-group)
10100 (gnus-request-set-mark
10101 to-group (list (list (list to-article) 'add to-marks)))))
10103 (gnus-dribble-enter
10104 (concat "(gnus-group-set-info '"
10105 (gnus-prin1-to-string (gnus-get-info to-group))
10107 (concat "^(gnus-group-set-info '(\""
10108 (regexp-quote to-group) "\""))))
10110 ;; Update the Xref header in this article to point to
10111 ;; the new crossposted article we have just created.
10112 (when (eq action 'crosspost)
10113 (with-current-buffer copy-buf
10114 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10115 (nnheader-replace-header "Xref" new-xref)
10116 (gnus-request-replace-article
10117 article gnus-newsgroup-name (current-buffer) t)))
10119 ;; run the move/copy/crosspost/respool hook
10120 (run-hook-with-args 'gnus-summary-article-move-hook
10123 (assoc article (gnus-data-list nil)))
10124 gnus-newsgroup-name
10128 ;;;!!!Why is this necessary?
10129 (set-buffer gnus-summary-buffer)
10131 (when (eq action 'move)
10133 (gnus-summary-goto-subject article)
10134 (gnus-summary-mark-article article gnus-canceled-mark)))))
10135 (push article articles-to-update-marks))
10138 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10139 ;; Re-activate all groups that have been moved to.
10140 (with-current-buffer gnus-group-buffer
10141 (let ((gnus-group-marked to-groups))
10142 (gnus-group-get-new-news-this-group nil t)))
10144 (gnus-kill-buffer copy-buf)
10145 (gnus-summary-position-point)
10146 (gnus-set-mode-line 'summary)))
10148 (defun gnus-summary-push-marks-to-backend (article)
10150 (marks gnus-article-mark-lists))
10151 (unless (memq article gnus-newsgroup-unreads)
10154 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10155 (memq article (symbol-value
10156 (intern (format "gnus-newsgroup-%s"
10158 (push (cdar marks) set))
10160 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10162 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10163 "Copy the current article to some other group.
10164 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10165 When called interactively, if TO-NEWSGROUP is nil, use the value of
10166 the variable `gnus-move-split-methods' for finding a default target
10168 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10169 re-spool using this method."
10171 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10173 (defun gnus-summary-crosspost-article (&optional n)
10174 "Crosspost the current article to some other group."
10176 (gnus-summary-move-article n nil nil 'crosspost))
10178 (defcustom gnus-summary-respool-default-method nil
10179 "Default method type for respooling an article.
10180 If nil, use to the current newsgroup method."
10182 :group 'gnus-summary-mail)
10184 (defun gnus-summary-respool-article (&optional n method)
10185 "Respool the current article.
10186 The article will be squeezed through the mail spooling process again,
10187 which means that it will be put in some mail newsgroup or other
10188 depending on `nnmail-split-methods'.
10189 If N is a positive number, respool the N next articles.
10190 If N is a negative number, respool the N previous articles.
10191 If N is nil and any articles have been marked with the process mark,
10192 respool those articles instead.
10194 Respooling can be done both from mail groups and \"real\" newsgroups.
10195 In the former case, the articles in question will be moved from the
10196 current group into whatever groups they are destined to. In the
10197 latter case, they will be copied into the relevant groups."
10199 (list current-prefix-arg
10200 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10202 (symbol-name (or gnus-summary-respool-default-method
10203 (car (gnus-find-method-for-group
10204 gnus-newsgroup-name)))))
10206 (gnus-completing-read
10207 "Backend to use when respooling"
10208 methods t nil 'gnus-mail-method-history methname))
10211 ((zerop (length (setq ms (gnus-servers-using-backend
10212 (intern method)))))
10213 (list (intern method) ""))
10217 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10218 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10221 (error "No method given for respooling"))
10222 (if (assoc (symbol-name
10223 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10224 (gnus-methods-using 'respool))
10225 (gnus-summary-move-article n nil method)
10226 (gnus-summary-copy-article n nil method)))
10228 (defun gnus-summary-import-article (file &optional edit)
10229 "Import an arbitrary file into a mail newsgroup."
10230 (interactive "fImport file: \nP")
10231 (let ((group gnus-newsgroup-name)
10232 (now (current-time))
10233 atts lines group-art)
10234 (unless (gnus-check-backend-function 'request-accept-article group)
10235 (error "%s does not support article importing" group))
10236 (or (file-readable-p file)
10237 (not (file-regular-p file))
10238 (error "Can't read %s" file))
10239 (with-current-buffer (gnus-get-buffer-create " *import file*")
10241 (nnheader-insert-file-contents file)
10242 (goto-char (point-min))
10243 (if (nnheader-article-p)
10245 (goto-char (point-min))
10246 (search-forward "\n\n" nil t)
10247 (narrow-to-region (point-min) (1- (point)))
10248 (goto-char (point-min))
10249 (unless (re-search-forward "^date:" nil t)
10250 (goto-char (point-max))
10251 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10252 ;; This doesn't look like an article, so we fudge some headers.
10253 (setq atts (file-attributes file)
10254 lines (count-lines (point-min) (point-max)))
10255 (insert "From: " (read-string "From: ") "\n"
10256 "Subject: " (read-string "Subject: ") "\n"
10257 "Date: " (message-make-date (nth 5 atts)) "\n"
10258 "Message-ID: " (message-make-message-id) "\n"
10259 "Lines: " (int-to-string lines) "\n"
10260 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10261 (setq group-art (gnus-request-accept-article group nil t))
10262 (kill-buffer (current-buffer)))
10263 (setq gnus-newsgroup-active (gnus-activate-group group))
10265 (gnus-summary-goto-article (cdr group-art) nil t)
10267 (gnus-summary-edit-article))))
10269 (defun gnus-summary-create-article ()
10270 "Create an article in a mail newsgroup."
10272 (let ((group gnus-newsgroup-name)
10273 (now (current-time))
10275 (unless (gnus-check-backend-function 'request-accept-article group)
10276 (error "%s does not support article importing" group))
10277 (with-current-buffer (gnus-get-buffer-create " *import file*")
10279 (goto-char (point-min))
10280 ;; This doesn't look like an article, so we fudge some headers.
10281 (insert "From: " (read-string "From: ") "\n"
10282 "Subject: " (read-string "Subject: ") "\n"
10283 "Date: " (message-make-date now) "\n"
10284 "Message-ID: " (message-make-message-id) "\n")
10285 (setq group-art (gnus-request-accept-article group nil t))
10286 (kill-buffer (current-buffer)))
10287 (setq gnus-newsgroup-active (gnus-activate-group group))
10289 (gnus-summary-goto-article (cdr group-art) nil t)
10290 (gnus-summary-edit-article)))
10292 (defun gnus-summary-article-posted-p ()
10293 "Say whether the current (mail) article is available from news as well.
10294 This will be the case if the article has both been mailed and posted."
10296 (let ((id (mail-header-references (gnus-summary-article-header)))
10297 (gnus-override-method (car (gnus-refer-article-methods))))
10298 (if (gnus-request-head id "")
10299 (gnus-message 2 "The current message was found on %s"
10300 gnus-override-method)
10301 (gnus-message 2 "The current message couldn't be found on %s"
10302 gnus-override-method)
10305 (defun gnus-summary-expire-articles (&optional now)
10306 "Expire all articles that are marked as expirable in the current group."
10308 (when (and (not gnus-group-is-exiting-without-update-p)
10309 (gnus-check-backend-function
10310 'request-expire-articles gnus-newsgroup-name))
10311 ;; This backend supports expiry.
10312 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10314 (gnus-list-range-difference
10317 ;; We need to update the info for
10318 ;; this group for `gnus-list-of-read-articles'
10319 ;; to give us the right answer.
10320 (gnus-run-hooks 'gnus-exit-group-hook)
10321 (gnus-summary-update-info)
10322 (gnus-list-of-read-articles gnus-newsgroup-name))
10323 (setq gnus-newsgroup-expirable
10324 (sort gnus-newsgroup-expirable '<)))
10325 gnus-newsgroup-unexist))
10326 (expiry-wait (if now 'immediate
10327 (gnus-group-find-parameter
10328 gnus-newsgroup-name 'expiry-wait)))
10329 (nnmail-expiry-target
10330 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10331 nnmail-expiry-target))
10334 ;; There are expirable articles in this group, so we run them
10335 ;; through the expiry process.
10336 (gnus-message 6 "Expiring articles...")
10337 (when (gnus-check-group gnus-newsgroup-name)
10338 ;; The list of articles that weren't expired is returned.
10341 (let ((nnmail-expiry-wait-function nil)
10342 (nnmail-expiry-wait expiry-wait))
10343 (setq es (gnus-request-expire-articles
10344 expirable gnus-newsgroup-name)))
10345 (setq es (gnus-request-expire-articles
10346 expirable gnus-newsgroup-name)))
10348 (setq gnus-newsgroup-expirable es))
10349 ;; We go through the old list of expirable, and mark all
10350 ;; really expired articles as nonexistent.
10351 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10352 (let ((gnus-use-cache nil))
10353 (dolist (article expirable)
10354 (when (and (not (memq article es))
10355 (gnus-data-find article))
10356 (gnus-summary-mark-article article gnus-canceled-mark)
10357 (run-hook-with-args 'gnus-summary-article-expire-hook
10360 (assoc article (gnus-data-list nil)))
10361 gnus-newsgroup-name
10364 (gnus-message 6 "Expiring articles...done")))))
10366 (defun gnus-summary-expire-articles-now ()
10367 "Expunge all expirable articles in the current group.
10368 This means that *all* articles that are marked as expirable will be
10369 deleted forever, right now."
10371 (or gnus-expert-user
10373 "Are you really, really sure you want to delete all expirable messages? ")
10375 (gnus-summary-expire-articles t))
10377 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10378 (defun gnus-summary-delete-article (&optional n)
10379 "Delete the N next (mail) articles.
10380 This command actually deletes articles. This is not a marking
10381 command. The article will disappear forever from your life, never to
10384 If N is negative, delete backwards.
10385 If N is nil and articles have been marked with the process mark,
10386 delete these instead.
10388 If `gnus-novice-user' is non-nil you will be asked for
10389 confirmation before the articles are deleted."
10391 (unless (gnus-check-backend-function 'request-expire-articles
10392 gnus-newsgroup-name)
10393 (error "The current newsgroup does not support article deletion"))
10394 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10395 (error "Couldn't open server"))
10396 ;; Compute the list of articles to delete.
10397 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10398 (nnmail-expiry-target 'delete)
10400 (if (and gnus-novice-user
10401 (not (gnus-yes-or-no-p
10402 (format "Do you really want to delete %s forever? "
10403 (if (> (length articles) 1)
10404 (format "these %s articles" (length articles))
10405 "this article")))))
10407 ;; Delete the articles.
10408 (setq not-deleted (gnus-request-expire-articles
10409 articles gnus-newsgroup-name 'force))
10412 (gnus-summary-remove-process-mark (car articles))
10413 ;; The backend might not have been able to delete the article
10415 (unless (memq (car articles) not-deleted)
10416 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10417 (let* ((article (car articles))
10418 (ghead (gnus-data-header
10419 (assoc article (gnus-data-list nil)))))
10420 (run-hook-with-args 'gnus-summary-article-delete-hook
10421 'delete ghead gnus-newsgroup-name nil
10423 (setq articles (cdr articles))))
10425 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10426 (gnus-summary-position-point)
10427 (gnus-set-mode-line 'summary)
10430 (defun gnus-summary-edit-article (&optional arg)
10431 "Edit the current article.
10432 This will have permanent effect only in mail groups.
10433 If ARG is nil, edit the decoded articles.
10434 If ARG is 1, edit the raw articles.
10435 If ARG is 2, edit the raw articles even in read-only groups.
10436 If ARG is 3, edit the articles with the current handles.
10437 Otherwise, allow editing of articles even in read-only
10440 (let (force raw current-handles)
10449 (setq current-handles
10450 (and (gnus-buffer-live-p gnus-article-buffer)
10451 (with-current-buffer gnus-article-buffer
10453 gnus-article-mime-handles
10454 (setq gnus-article-mime-handles nil))))))
10457 (when (and raw (not force)
10458 (member gnus-newsgroup-name '("nndraft:delayed"
10461 (error "Can't edit the raw article in group %s"
10462 gnus-newsgroup-name))
10463 (with-current-buffer gnus-summary-buffer
10464 (let ((mail-parse-charset gnus-newsgroup-charset)
10465 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10466 (gnus-set-global-variables)
10467 (when (and (not force)
10468 (gnus-group-read-only-p))
10469 (error "The current newsgroup does not support article editing"))
10470 (gnus-summary-show-article t)
10471 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10472 (with-current-buffer gnus-article-buffer
10473 (mm-enable-multibyte)))
10474 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10476 (gnus-article-edit-article
10479 (let ((mbl mml-buffer-list))
10480 (setq mml-buffer-list nil)
10481 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10482 (mime-to-mml ,'current-handles))
10483 (let ((mbl1 mml-buffer-list))
10484 (setq mml-buffer-list mbl)
10485 (set (make-local-variable 'mml-buffer-list) mbl1))
10486 (gnus-make-local-hook 'kill-buffer-hook)
10487 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10488 `(lambda (no-highlight)
10489 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10490 (message-options message-options)
10491 (message-options-set-recipient)
10492 (mail-parse-ignored-charsets
10493 ',gnus-newsgroup-ignored-charsets)
10494 (rfc2047-header-encoding-alist
10495 ',(let ((charset (gnus-group-name-charset
10496 (gnus-find-method-for-group
10497 gnus-newsgroup-name)
10498 gnus-newsgroup-name)))
10499 (append (list (cons "Newsgroups" charset)
10500 (cons "Followup-To" charset)
10501 (cons "Xref" charset))
10502 rfc2047-header-encoding-alist))))
10503 ,(if (not raw) '(progn
10505 (mml-destroy-buffers)
10506 (remove-hook 'kill-buffer-hook
10507 'mml-destroy-buffers t)
10508 (kill-local-variable 'mml-buffer-list)))
10509 (gnus-summary-edit-article-done
10510 ,(or (mail-header-references gnus-current-headers) "")
10511 ,(gnus-group-read-only-p)
10512 ,gnus-summary-buffer no-highlight))))))))
10514 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10516 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10518 "Make edits to the current article permanent."
10521 ;; The buffer restriction contains the entire article if it exists.
10522 (when (article-goto-body)
10523 (let ((lines (count-lines (point) (point-max)))
10524 (length (- (point-max) (point)))
10525 (case-fold-search t)
10526 (body (copy-marker (point))))
10527 (goto-char (point-min))
10528 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10529 (delete-region (match-beginning 1) (match-end 1))
10530 (insert (number-to-string length)))
10531 (goto-char (point-min))
10532 (when (re-search-forward
10533 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10534 (delete-region (match-beginning 1) (match-end 1))
10535 (insert (number-to-string length)))
10536 (goto-char (point-min))
10537 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10538 (delete-region (match-beginning 1) (match-end 1))
10539 (insert (number-to-string lines))))))
10540 ;; Replace the article.
10541 (let ((buf (current-buffer))
10542 (article (cdr gnus-article-current))
10545 (insert-buffer-substring buf)
10546 (if (and (not read-only)
10547 (not (setq replace-result
10548 (gnus-request-replace-article
10549 article (car gnus-article-current)
10550 (current-buffer) t))))
10551 (error "Couldn't replace article")
10552 ;; If we got a number back, then that's the new article number
10553 ;; for this article. Otherwise, the article number didn't change.
10554 (when (numberp replace-result)
10555 (with-current-buffer gnus-summary-buffer
10556 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10557 (gnus-summary-limit gnus-newsgroup-limit)
10558 (setq article replace-result)
10559 (gnus-summary-goto-subject article t)))
10560 ;; Update the summary buffer.
10561 (if (and references
10562 (equal (message-tokenize-header references " ")
10563 (message-tokenize-header
10564 (or (message-fetch-field "references") "") " ")))
10565 ;; We only have to update this line.
10568 (message-narrow-to-head)
10569 (let ((head (buffer-substring-no-properties
10570 (point-min) (point-max)))
10573 (insert (format "211 %d Article retrieved.\n" article))
10576 (let ((nntp-server-buffer (current-buffer)))
10577 (setq header (car (gnus-get-newsgroup-headers nil t))))
10578 (with-current-buffer gnus-summary-buffer
10579 (gnus-data-set-header (gnus-data-find article) header)
10580 (gnus-summary-update-article-line article header)
10581 (if (gnus-summary-goto-subject article nil t)
10582 (gnus-summary-update-secondary-mark article)))))))
10584 (set-buffer (or buffer gnus-summary-buffer))
10585 (gnus-summary-update-article article)
10586 (if (gnus-summary-goto-subject article nil t)
10587 (gnus-summary-update-secondary-mark article)))
10588 ;; Prettify the article buffer again.
10589 (unless no-highlight
10590 (with-current-buffer gnus-article-buffer
10591 ;;!!! Fix this -- article should be rehighlighted.
10592 ;;(gnus-run-hooks 'gnus-article-display-hook)
10593 (set-buffer gnus-original-article-buffer)
10594 (gnus-request-article
10595 article (car gnus-article-current) (current-buffer))))
10596 ;; Prettify the summary buffer line.
10597 (when (gnus-visual-p 'summary-highlight 'highlight)
10598 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10600 (defun gnus-summary-edit-wash (key)
10601 "Perform editing command KEY in the article buffer."
10605 (message "%s" (concat (this-command-keys) "- "))
10608 (gnus-summary-edit-article)
10609 (execute-kbd-macro (concat (this-command-keys) key))
10610 (gnus-article-edit-done))
10614 (defun gnus-summary-respool-query (&optional silent trace)
10615 "Query where the respool algorithm would put this article."
10617 (let (gnus-mark-article-hook)
10618 (gnus-summary-select-article)
10619 (with-current-buffer gnus-original-article-buffer
10620 (let ((groups (nnmail-article-group 'identity trace)))
10623 (message "This message would go to %s"
10624 (mapconcat 'car groups ", "))
10625 (message "This message would go to no groups"))
10628 (defun gnus-summary-respool-trace ()
10629 "Trace where the respool algorithm would put this article.
10630 Display a buffer showing all fancy splitting patterns which matched."
10632 (gnus-summary-respool-query nil t))
10634 ;; Summary marking commands.
10636 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10637 "Mark articles which has the same subject as read, and then select the next.
10638 If UNMARK is positive, remove any kind of mark.
10639 If UNMARK is negative, tick articles."
10642 (setq unmark (prefix-numeric-value unmark)))
10644 (gnus-summary-mark-same-subject
10645 (gnus-summary-article-subject) unmark)))
10646 ;; Select next unread article. If auto-select-same mode, should
10647 ;; select the first unread article.
10648 (gnus-summary-next-article t (and gnus-auto-select-same
10649 (gnus-summary-article-subject)))
10650 (gnus-message 7 "%d article%s marked as %s"
10651 count (if (= count 1) " is" "s are")
10652 (if unmark "unread" "read"))))
10654 (defun gnus-summary-kill-same-subject (&optional unmark)
10655 "Mark articles which has the same subject as read.
10656 If UNMARK is positive, remove any kind of mark.
10657 If UNMARK is negative, tick articles."
10660 (setq unmark (prefix-numeric-value unmark)))
10662 (gnus-summary-mark-same-subject
10663 (gnus-summary-article-subject) unmark)))
10664 ;; If marked as read, go to next unread subject.
10665 (when (null unmark)
10666 ;; Go to next unread subject.
10667 (gnus-summary-next-subject 1 t))
10668 (gnus-message 7 "%d articles are marked as %s"
10669 count (if unmark "unread" "read"))))
10671 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10672 "Mark articles with same SUBJECT as read, and return marked number.
10673 If optional argument UNMARK is positive, remove any kinds of marks.
10674 If optional argument UNMARK is negative, mark articles as unread instead."
10678 ((null unmark) ; Mark as read.
10681 (gnus-summary-mark-article-as-read gnus-killed-mark)
10682 (gnus-summary-show-thread) t)
10683 (gnus-summary-find-subject subject))
10684 (setq count (1+ count))))
10685 ((> unmark 0) ; Tick.
10688 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10689 (gnus-summary-show-thread) t)
10690 (gnus-summary-find-subject subject))
10691 (setq count (1+ count))))
10692 (t ; Mark as unread.
10695 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10696 (gnus-summary-show-thread) t)
10697 (gnus-summary-find-subject subject))
10698 (setq count (1+ count)))))
10699 (gnus-set-mode-line 'summary)
10700 ;; Return the number of marked articles.
10703 (defun gnus-summary-mark-as-processable (n &optional unmark)
10704 "Set the process mark on the next N articles.
10705 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10706 the process mark instead. The difference between N and the actual
10707 number of articles marked is returned."
10709 (if (and (null n) (gnus-region-active-p))
10710 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10711 (setq n (prefix-numeric-value n))
10712 (let ((backward (< n 0))
10717 (gnus-summary-remove-process-mark
10718 (gnus-summary-article-number))
10719 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10720 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10723 (gnus-message 7 "No more articles"))
10724 (gnus-summary-recenter)
10725 (gnus-summary-position-point)
10728 (defun gnus-summary-unmark-as-processable (n)
10729 "Remove the process mark from the next N articles.
10730 If N is negative, unmark backward instead. The difference between N and
10731 the actual number of articles unmarked is returned."
10733 (gnus-summary-mark-as-processable n t))
10735 (defun gnus-summary-unmark-all-processable ()
10736 "Remove the process mark from all articles."
10739 (while gnus-newsgroup-processable
10740 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10741 (gnus-summary-position-point))
10743 (defun gnus-summary-add-mark (article type)
10744 "Mark ARTICLE with a mark of TYPE."
10745 (let ((vtype (car (assq type gnus-article-mark-lists)))
10748 (error "No such mark type: %s" type)
10749 (setq var (intern (format "gnus-newsgroup-%s" type)))
10750 (set var (cons article (symbol-value var)))
10751 (if (memq type '(processable cached replied forwarded recent saved))
10752 (gnus-summary-update-secondary-mark article)
10753 ;;; !!! This is bogus. We should find out what primary
10754 ;;; !!! mark we want to set.
10755 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10757 (defun gnus-summary-mark-as-expirable (n)
10758 "Mark N articles forward as expirable.
10759 If N is negative, mark backward instead. The difference between N and
10760 the actual number of articles marked is returned."
10762 (gnus-summary-mark-forward n gnus-expirable-mark))
10764 (defun gnus-summary-mark-as-spam (n)
10765 "Mark N articles forward as spam.
10766 If N is negative, mark backward instead. The difference between N and
10767 the actual number of articles marked is returned."
10769 (gnus-summary-mark-forward n gnus-spam-mark))
10771 (defun gnus-summary-mark-article-as-replied (article)
10772 "Mark ARTICLE as replied to and update the summary line.
10773 ARTICLE can also be a list of articles."
10774 (interactive (list (gnus-summary-article-number)))
10775 (let ((articles (if (listp article) article (list article))))
10776 (dolist (article articles)
10777 (unless (numberp article)
10778 (error "%s is not a number" article))
10779 (push article gnus-newsgroup-replied)
10780 (let ((inhibit-read-only t))
10781 (when (gnus-summary-goto-subject article nil t)
10782 (gnus-summary-update-secondary-mark article))))))
10784 (defun gnus-summary-mark-article-as-forwarded (article)
10785 "Mark ARTICLE as forwarded and update the summary line.
10786 ARTICLE can also be a list of articles."
10787 (let ((articles (if (listp article) article (list article))))
10788 (dolist (article articles)
10789 (push article gnus-newsgroup-forwarded)
10790 (let ((inhibit-read-only t))
10791 (when (gnus-summary-goto-subject article nil t)
10792 (gnus-summary-update-secondary-mark article))))))
10794 (defun gnus-summary-set-bookmark (article)
10795 "Set a bookmark in current article."
10796 (interactive (list (gnus-summary-article-number)))
10797 (when (or (not (get-buffer gnus-article-buffer))
10798 (not gnus-current-article)
10799 (not gnus-article-current)
10800 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10801 (error "No current article selected"))
10802 ;; Remove old bookmark, if one exists.
10803 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10804 ;; Set the new bookmark, which is on the form
10805 ;; (article-number . line-number-in-body).
10808 (with-current-buffer gnus-article-buffer
10812 (article-goto-body)
10815 gnus-newsgroup-bookmarks)
10816 (gnus-message 6 "A bookmark has been added to the current article."))
10818 (defun gnus-summary-remove-bookmark (article)
10819 "Remove the bookmark from the current article."
10820 (interactive (list (gnus-summary-article-number)))
10821 ;; Remove old bookmark, if one exists.
10822 (if (not (assq article gnus-newsgroup-bookmarks))
10823 (gnus-message 6 "No bookmark in current article.")
10824 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10825 (gnus-message 6 "Removed bookmark.")))
10827 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10828 (defun gnus-summary-mark-as-dormant (n)
10829 "Mark N articles forward as dormant.
10830 If N is negative, mark backward instead. The difference between N and
10831 the actual number of articles marked is returned."
10833 (gnus-summary-mark-forward n gnus-dormant-mark))
10835 (defun gnus-summary-set-process-mark (article)
10836 "Set the process mark on ARTICLE and update the summary line."
10837 (setq gnus-newsgroup-processable
10839 (delq article gnus-newsgroup-processable)))
10840 (when (gnus-summary-goto-subject article)
10841 (gnus-summary-show-thread)
10842 (gnus-summary-goto-subject article)
10843 (gnus-summary-update-secondary-mark article)))
10845 (defun gnus-summary-remove-process-mark (&rest articles)
10846 "Remove the process mark from ARTICLES and update the summary line."
10847 (dolist (article articles)
10848 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10849 (when (gnus-summary-goto-subject article)
10850 (gnus-summary-show-thread)
10851 (gnus-summary-goto-subject article)
10852 (gnus-summary-update-secondary-mark article)))
10855 (defun gnus-summary-set-saved-mark (article)
10856 "Set the process mark on ARTICLE and update the summary line."
10857 (push article gnus-newsgroup-saved)
10858 (when (gnus-summary-goto-subject article)
10859 (gnus-summary-update-secondary-mark article)))
10861 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10862 "Mark N articles as read forwards.
10863 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10864 The difference between N and the actual number of articles marked is
10866 If NO-EXPIRE, auto-expiry will be inhibited."
10868 (gnus-summary-show-thread)
10869 (let ((backward (< n 0))
10870 (gnus-summary-goto-unread
10871 (and gnus-summary-goto-unread
10872 (not (eq gnus-summary-goto-unread 'never))
10873 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10874 gnus-ticked-mark gnus-dormant-mark)))))
10876 (mark (or mark gnus-del-mark)))
10877 (while (and (> n 0)
10878 (gnus-summary-mark-article nil mark no-expire)
10879 (zerop (gnus-summary-next-subject
10881 (and gnus-summary-goto-unread
10882 (not (eq gnus-summary-goto-unread 'never)))
10886 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10887 (gnus-summary-recenter)
10888 (gnus-summary-position-point)
10889 (gnus-set-mode-line 'summary)
10892 (defun gnus-summary-mark-article-as-read (mark)
10893 "Mark the current article quickly as read with MARK."
10894 (let ((article (gnus-summary-article-number)))
10895 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10896 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10897 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10898 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10899 (push (cons article mark) gnus-newsgroup-reads)
10900 ;; Possibly remove from cache, if that is used.
10901 (when gnus-use-cache
10902 (gnus-cache-enter-remove-article article))
10903 ;; Allow the backend to change the mark.
10904 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10905 ;; Check for auto-expiry.
10906 (when (and gnus-newsgroup-auto-expire
10907 (memq mark gnus-auto-expirable-marks))
10908 (setq mark gnus-expirable-mark)
10909 ;; Let the backend know about the mark change.
10910 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10911 (push article gnus-newsgroup-expirable))
10912 ;; Set the mark in the buffer.
10913 (gnus-summary-update-mark mark 'unread)
10916 (defun gnus-summary-mark-article-as-unread (mark)
10917 "Mark the current article quickly as unread with MARK."
10918 (let* ((article (gnus-summary-article-number))
10919 (old-mark (gnus-summary-article-mark article)))
10920 ;; Allow the backend to change the mark.
10921 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10922 (if (eq mark old-mark)
10926 (gnus-error 1 "Can't mark negative article numbers")
10928 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10929 (setq gnus-newsgroup-spam-marked
10930 (delq article gnus-newsgroup-spam-marked))
10931 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10932 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10933 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10934 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10935 (cond ((= mark gnus-ticked-mark)
10936 (setq gnus-newsgroup-marked
10937 (gnus-add-to-sorted-list gnus-newsgroup-marked
10939 ((= mark gnus-spam-mark)
10940 (setq gnus-newsgroup-spam-marked
10941 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10943 ((= mark gnus-dormant-mark)
10944 (setq gnus-newsgroup-dormant
10945 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10948 (setq gnus-newsgroup-unreads
10949 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10951 (gnus-alist-pull article gnus-newsgroup-reads)
10953 ;; See whether the article is to be put in the cache.
10954 (and gnus-use-cache
10955 (vectorp (gnus-summary-article-header article))
10957 (gnus-cache-possibly-enter-article
10958 gnus-newsgroup-name article
10959 (= mark gnus-ticked-mark)
10960 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10963 (gnus-summary-update-mark mark 'unread)
10966 (defun gnus-summary-mark-article (&optional article mark no-expire)
10967 "Mark ARTICLE with MARK. MARK can be any character.
10968 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10969 `??' (dormant) and `?E' (expirable).
10970 If MARK is nil, then the default character `?r' is used.
10971 If ARTICLE is nil, then the article on the current line will be
10973 If NO-EXPIRE, auto-expiry will be inhibited."
10974 ;; The mark might be a string.
10975 (when (stringp mark)
10976 (setq mark (aref mark 0)))
10977 ;; If no mark is given, then we check auto-expiring.
10979 (setq mark gnus-del-mark))
10980 (when (and (not no-expire)
10981 gnus-newsgroup-auto-expire
10982 (memq mark gnus-auto-expirable-marks))
10983 (setq mark gnus-expirable-mark))
10984 (let ((article (or article (gnus-summary-article-number)))
10985 (old-mark (gnus-summary-article-mark article)))
10986 ;; Allow the backend to change the mark.
10987 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10988 (if (eq mark old-mark)
10991 (error "No article on current line"))
10992 (if (not (if (or (= mark gnus-unread-mark)
10993 (= mark gnus-ticked-mark)
10994 (= mark gnus-spam-mark)
10995 (= mark gnus-dormant-mark))
10996 (gnus-mark-article-as-unread article mark)
10997 (gnus-mark-article-as-read article mark)))
10999 ;; See whether the article is to be put in the cache.
11000 (and gnus-use-cache
11001 (not (= mark gnus-canceled-mark))
11002 (vectorp (gnus-summary-article-header article))
11004 (gnus-cache-possibly-enter-article
11005 gnus-newsgroup-name article
11006 (= mark gnus-ticked-mark)
11007 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11009 (when (gnus-summary-goto-subject article nil t)
11010 (let ((inhibit-read-only t))
11011 (gnus-summary-show-thread)
11013 (gnus-summary-update-mark mark 'unread)
11016 (defun gnus-summary-update-secondary-mark (article)
11017 "Update the secondary (read, process, cache) mark."
11018 (gnus-summary-update-mark
11019 (cond ((memq article gnus-newsgroup-processable)
11021 ((memq article gnus-newsgroup-cached)
11023 ((memq article gnus-newsgroup-replied)
11025 ((memq article gnus-newsgroup-forwarded)
11026 gnus-forwarded-mark)
11027 ((memq article gnus-newsgroup-saved)
11029 ((memq article gnus-newsgroup-unseen)
11033 (when (gnus-visual-p 'summary-highlight 'highlight)
11034 (gnus-summary-highlight-line)
11035 (gnus-run-hooks 'gnus-summary-update-hook))
11038 (defun gnus-summary-update-download-mark (article)
11039 "Update the download mark."
11040 (gnus-summary-update-mark
11041 (cond ((memq article gnus-newsgroup-undownloaded)
11042 gnus-undownloaded-mark)
11043 (gnus-newsgroup-agentized
11044 gnus-downloaded-mark)
11048 (gnus-summary-update-line t)
11051 (defun gnus-summary-update-mark (mark type)
11052 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11053 (inhibit-read-only t))
11054 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11056 (when (looking-at "\r")
11058 (when (<= (+ forward (point)) (point-max))
11059 ;; Go to the right position on the line.
11060 (goto-char (+ forward (point)))
11061 ;; Replace the old mark with the new mark.
11063 (mm-subst-char-in-string
11065 (buffer-substring (point) (1+ (point))))))
11066 (delete-region (point) (1+ (point)))
11067 (insert to-insert))
11068 ;; Optionally update the marks by some user rule.
11069 (when (eq type 'unread)
11070 (gnus-data-set-mark
11071 (gnus-data-find (gnus-summary-article-number)) mark)
11072 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11074 (defun gnus-mark-article-as-read (article &optional mark)
11075 "Enter ARTICLE in the pertinent lists and remove it from others."
11076 ;; Make the article expirable.
11077 (let ((mark (or mark gnus-del-mark)))
11078 (setq gnus-newsgroup-expirable
11079 (if (= mark gnus-expirable-mark)
11080 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11081 (delq article gnus-newsgroup-expirable)))
11082 ;; Remove from unread and marked lists.
11083 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11085 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11086 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11087 (push (cons article mark) gnus-newsgroup-reads)
11088 ;; Possibly remove from cache, if that is used.
11089 (when gnus-use-cache
11090 (gnus-cache-enter-remove-article article))
11093 (defun gnus-mark-article-as-unread (article &optional mark)
11094 "Enter ARTICLE in the pertinent lists and remove it from others."
11095 (let ((mark (or mark gnus-ticked-mark)))
11098 (gnus-error 1 "Can't mark negative article numbers")
11100 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11101 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11102 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11103 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11104 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11106 ;; Unsuppress duplicates?
11107 (when gnus-suppress-duplicates
11108 (gnus-dup-unsuppress-article article))
11110 (cond ((= mark gnus-ticked-mark)
11111 (setq gnus-newsgroup-marked
11112 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11113 ((= mark gnus-spam-mark)
11114 (setq gnus-newsgroup-spam-marked
11115 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11117 ((= mark gnus-dormant-mark)
11118 (setq gnus-newsgroup-dormant
11119 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11121 (setq gnus-newsgroup-unreads
11122 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11123 (gnus-alist-pull article gnus-newsgroup-reads)
11126 (defun gnus-summary-tick-article-forward (n)
11127 "Tick N articles forwards.
11128 If N is negative, tick backwards instead.
11129 The difference between N and the number of articles ticked is returned."
11131 (gnus-summary-mark-forward n gnus-ticked-mark))
11133 (defun gnus-summary-tick-article-backward (n)
11134 "Tick N articles backwards.
11135 The difference between N and the number of articles ticked is returned."
11137 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11139 (defun gnus-summary-tick-article (&optional article clear-mark)
11140 "Mark current article as unread.
11141 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11142 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11144 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11145 gnus-ticked-mark)))
11147 (defun gnus-summary-mark-as-read-forward (n)
11148 "Mark N articles as read forwards.
11149 If N is negative, mark backwards instead.
11150 The difference between N and the actual number of articles marked is
11153 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11155 (defun gnus-summary-mark-as-read-backward (n)
11156 "Mark the N articles as read backwards.
11157 The difference between N and the actual number of articles marked is
11160 (gnus-summary-mark-forward
11161 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11163 (defun gnus-summary-mark-as-read (&optional article mark)
11164 "Mark current article as read.
11165 ARTICLE specifies the article to be marked as read.
11166 MARK specifies a string to be inserted at the beginning of the line."
11167 (gnus-summary-mark-article article mark))
11169 (defun gnus-summary-clear-mark-forward (n)
11170 "Clear marks from N articles forward.
11171 If N is negative, clear backward instead.
11172 The difference between N and the number of marks cleared is returned."
11174 (gnus-summary-mark-forward n gnus-unread-mark))
11176 (defun gnus-summary-clear-mark-backward (n)
11177 "Clear marks from N articles backward.
11178 The difference between N and the number of marks cleared is returned."
11180 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11182 (defun gnus-summary-mark-unread-as-read ()
11183 "Intended to be used by `gnus-mark-article-hook'."
11184 (when (memq gnus-current-article gnus-newsgroup-unreads)
11185 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11187 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11188 "Intended to be used by `gnus-mark-article-hook'."
11189 (let ((mark (gnus-summary-article-mark)))
11190 (when (or (gnus-unread-mark-p mark)
11191 (gnus-read-mark-p mark))
11192 (gnus-summary-mark-article gnus-current-article
11193 (or new-mark gnus-read-mark)))))
11195 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11196 "Intended to be used by `gnus-mark-article-hook'."
11197 (let ((mark (gnus-summary-article-mark)))
11198 (when (or (gnus-unread-mark-p mark)
11199 (gnus-read-mark-p mark))
11200 (gnus-summary-mark-article (gnus-summary-article-number)
11201 (or new-mark gnus-read-mark)))))
11203 (defun gnus-summary-mark-unread-as-ticked ()
11204 "Intended to be used by `gnus-mark-article-hook'."
11205 (when (memq gnus-current-article gnus-newsgroup-unreads)
11206 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11208 (defun gnus-summary-mark-region-as-read (point mark all)
11209 "Mark all unread articles between point and mark as read.
11210 If given a prefix, mark all articles between point and mark as read,
11211 even ticked and dormant ones."
11212 (interactive "r\nP")
11216 (beginning-of-line)
11221 (memq (setq article (gnus-summary-article-number))
11222 gnus-newsgroup-unreads))
11223 (gnus-summary-mark-article article gnus-del-mark))
11225 (gnus-summary-find-next))))))
11227 (defun gnus-summary-mark-below (score mark)
11228 "Mark articles with score less than SCORE with MARK."
11229 (interactive "P\ncMark: ")
11230 (setq score (if score
11231 (prefix-numeric-value score)
11232 (or gnus-summary-default-score 0)))
11233 (with-current-buffer gnus-summary-buffer
11234 (goto-char (point-min))
11237 (and (< (gnus-summary-article-score) score)
11238 (gnus-summary-mark-article nil mark))
11239 (gnus-summary-find-next)))))
11241 (defun gnus-summary-kill-below (&optional score)
11242 "Mark articles with score below SCORE as read."
11244 (gnus-summary-mark-below score gnus-killed-mark))
11246 (defun gnus-summary-clear-above (&optional score)
11247 "Clear all marks from articles with score above SCORE."
11249 (gnus-summary-mark-above score gnus-unread-mark))
11251 (defun gnus-summary-tick-above (&optional score)
11252 "Tick all articles with score above SCORE."
11254 (gnus-summary-mark-above score gnus-ticked-mark))
11256 (defun gnus-summary-mark-above (score mark)
11257 "Mark articles with score over SCORE with MARK."
11258 (interactive "P\ncMark: ")
11259 (setq score (if score
11260 (prefix-numeric-value score)
11261 (or gnus-summary-default-score 0)))
11262 (with-current-buffer gnus-summary-buffer
11263 (goto-char (point-min))
11265 (when (> (gnus-summary-article-score) score)
11266 (gnus-summary-mark-article nil mark))
11268 (gnus-summary-find-next)))))
11270 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11271 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11272 (defun gnus-summary-limit-include-expunged (&optional no-error)
11273 "Display all the hidden articles that were expunged for low scores."
11275 (let ((inhibit-read-only t))
11276 (let ((scored gnus-newsgroup-scored)
11279 (unless (gnus-summary-article-header (caar scored))
11280 (and (setq h (gnus-number-to-header (caar scored)))
11281 (< (cdar scored) gnus-summary-expunge-below)
11283 (setq scored (cdr scored)))
11285 (when (not no-error)
11286 (error "No expunged articles hidden"))
11287 (goto-char (point-min))
11288 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11289 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11290 (dolist (x headers)
11291 (push (mail-header-number x) gnus-newsgroup-limit))
11292 (gnus-summary-prepare-unthreaded (nreverse headers))
11293 (goto-char (point-min))
11294 (gnus-summary-position-point)
11297 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11298 "Mark all unread articles in this newsgroup as read.
11299 If prefix argument ALL is non-nil, ticked and dormant articles will
11300 also be marked as read.
11301 If QUIETLY is non-nil, no questions will be asked.
11303 If TO-HERE is non-nil, it should be a point in the buffer. All
11304 articles before (after, if REVERSE is set) this point will be marked
11307 Note that this function will only catch up the unread article
11308 in the current summary buffer limitation.
11310 The number of articles marked as read is returned."
11315 (not gnus-interactive-catchup) ;Without confirmation?
11319 "Mark absolutely all articles as read? "
11320 "Mark all unread articles as read? ")))
11322 (not gnus-newsgroup-adaptive)
11323 (not gnus-newsgroup-auto-expire)
11324 (not gnus-suppress-duplicates)
11325 (or (not gnus-use-cache)
11326 (eq gnus-use-cache 'passive)))
11329 (setq gnus-newsgroup-marked nil
11330 gnus-newsgroup-spam-marked nil
11331 gnus-newsgroup-dormant nil))
11332 (setq gnus-newsgroup-unreads
11333 (gnus-sorted-nunion
11334 (gnus-sorted-intersection gnus-newsgroup-unreads
11335 gnus-newsgroup-downloadable)
11336 (gnus-sorted-difference gnus-newsgroup-unfetched
11337 gnus-newsgroup-cached))))
11338 ;; We actually mark all articles as canceled, which we
11339 ;; have to do when using auto-expiry or adaptive scoring.
11340 (gnus-summary-show-all-threads)
11341 (if (and to-here reverse)
11343 (goto-char to-here)
11344 (gnus-summary-mark-current-read-and-unread-as-read
11346 (while (gnus-summary-find-next (not all))
11347 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11348 (when (gnus-summary-first-subject (not all))
11350 (if to-here (< (point) to-here) t)
11351 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11352 (gnus-summary-find-next (not all))))))
11353 (gnus-set-mode-line 'summary))
11355 (gnus-summary-position-point)))
11357 (defun gnus-summary-catchup-to-here (&optional all)
11358 "Mark all unticked articles before the current one as read.
11359 If ALL is non-nil, also mark ticked and dormant articles as read."
11362 (gnus-save-hidden-threads
11363 (let ((beg (point)))
11364 ;; We check that there are unread articles.
11365 (when (or all (gnus-summary-find-prev))
11366 (gnus-summary-catchup all t beg)))))
11367 (gnus-summary-position-point))
11369 (defun gnus-summary-catchup-from-here (&optional all)
11370 "Mark all unticked articles after (and including) the current one as read.
11371 If ALL is non-nil, also mark ticked and dormant articles as read."
11374 (gnus-save-hidden-threads
11375 (let ((beg (point)))
11376 ;; We check that there are unread articles.
11377 (when (or all (gnus-summary-find-next))
11378 (gnus-summary-catchup all t beg nil t)))))
11379 (gnus-summary-position-point))
11381 (defun gnus-summary-catchup-all (&optional quietly)
11382 "Mark all articles in this newsgroup as read.
11383 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11384 instead, which marks only unread articles as read."
11386 (gnus-summary-catchup t quietly))
11388 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11389 "Mark all unread articles in this group as read, then exit.
11390 If prefix argument ALL is non-nil, all articles are marked as read.
11391 If QUIETLY is non-nil, no questions will be asked."
11393 (when (gnus-summary-catchup all quietly nil 'fast)
11394 ;; Select next newsgroup or exit.
11395 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11396 (eq gnus-auto-select-next 'quietly))
11397 (gnus-summary-next-group nil)
11398 (gnus-summary-exit))))
11400 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11401 "Mark all articles in this newsgroup as read, and then exit.
11402 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11403 instead, which marks only unread articles as read."
11405 (gnus-summary-catchup-and-exit t quietly))
11407 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11408 "Mark all articles in this group as read and select the next group.
11409 If given a prefix, mark all articles, unread as well as ticked, as
11413 (gnus-summary-catchup all))
11414 (gnus-summary-next-group))
11416 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11417 "Mark all articles in this group as read and select the previous group.
11418 If given a prefix, mark all articles, unread as well as ticked, as
11422 (gnus-summary-catchup all))
11423 (gnus-summary-next-group nil nil t))
11429 (defmacro gnus-with-article (article &rest forms)
11430 "Select ARTICLE and perform FORMS in the original article buffer.
11431 Then replace the article with the result."
11433 ;; We don't want the article to be marked as read.
11434 (let (gnus-mark-article-hook)
11435 (gnus-summary-select-article t t nil ,article))
11436 (set-buffer gnus-original-article-buffer)
11438 (if (not (gnus-check-backend-function
11439 'request-replace-article (car gnus-article-current)))
11440 (gnus-message 5 "Read-only group; not replacing")
11441 (unless (gnus-request-replace-article
11442 ,article (car gnus-article-current)
11443 (current-buffer) t)
11444 (error "Couldn't replace article")))
11445 ;; The cache and backlog have to be flushed somewhat.
11446 (when gnus-keep-backlog
11447 (gnus-backlog-remove-article
11448 (car gnus-article-current) (cdr gnus-article-current)))
11449 (when gnus-use-cache
11450 (gnus-cache-update-article
11451 (car gnus-article-current) (cdr gnus-article-current)))))
11453 (put 'gnus-with-article 'lisp-indent-function 1)
11454 (put 'gnus-with-article 'edebug-form-spec '(form body))
11456 ;; Thread-based commands.
11458 (defun gnus-summary-articles-in-thread (&optional article)
11459 "Return a list of all articles in the current thread.
11460 If ARTICLE is non-nil, return all articles in the thread that starts
11461 with that article."
11462 (let* ((article (or article (gnus-summary-article-number)))
11463 (data (gnus-data-find-list article))
11464 (top-level (gnus-data-level (car data)))
11466 (cond ((null gnus-thread-operation-ignore-subject)
11467 (gnus-simplify-subject-re
11468 (mail-header-subject (gnus-data-header (car data)))))
11469 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11470 (gnus-simplify-subject-fuzzy
11471 (mail-header-subject (gnus-data-header (car data)))))
11473 (end-point (save-excursion
11474 (goto-char (gnus-data-pos (car data)))
11475 (if (gnus-summary-go-to-next-thread)
11476 (point) (point-max))))
11479 (< (gnus-data-pos (car data)) end-point))
11480 (when (or (not top-subject)
11481 (string= top-subject
11482 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11483 (gnus-simplify-subject-fuzzy
11484 (mail-header-subject
11485 (gnus-data-header (car data))))
11486 (gnus-simplify-subject-re
11487 (mail-header-subject
11488 (gnus-data-header (car data)))))))
11489 (push (gnus-data-number (car data)) articles))
11490 (unless (and (setq data (cdr data))
11491 (> (gnus-data-level (car data)) top-level))
11493 ;; Return the list of articles.
11494 (nreverse articles)))
11496 (defun gnus-summary-rethread-current ()
11497 "Rethread the thread the current article is part of."
11499 (let* ((gnus-show-threads t)
11500 (article (gnus-summary-article-number))
11501 (id (mail-header-id (gnus-summary-article-header)))
11502 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11504 (error "No article on the current line"))
11505 (gnus-rebuild-thread id)
11506 (gnus-summary-goto-subject article)))
11508 (defun gnus-summary-reparent-thread ()
11509 "Make the current article child of the marked (or previous) article.
11511 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11512 is non-nil or the Subject: of both articles are the same."
11514 (unless (not (gnus-group-read-only-p))
11515 (error "The current newsgroup does not support article editing"))
11516 (unless (<= (length gnus-newsgroup-processable) 1)
11517 (error "No more than one article may be marked"))
11518 (let ((child (gnus-summary-article-number))
11519 ;; First grab the marked article, otherwise one line up.
11520 (parent (if (not (null gnus-newsgroup-processable))
11521 (car gnus-newsgroup-processable)
11523 (if (eq (forward-line -1) 0)
11524 (gnus-summary-article-number)
11525 (error "Beginning of summary buffer"))))))
11526 (gnus-summary-reparent-children parent (list child))))
11528 (defun gnus-summary-reparent-children (parent children)
11529 "Make PARENT the parent of CHILDREN.
11530 When called interactively, PARENT is the current article and CHILDREN
11531 are the process-marked articles."
11533 (list (gnus-summary-article-number)
11534 (gnus-summary-work-articles nil)))
11535 (dolist (child children)
11536 (save-window-excursion
11537 (let ((gnus-article-buffer " *reparent*"))
11538 (unless (not (eq parent child))
11539 (error "An article may not be self-referential"))
11540 (let ((message-id (mail-header-id
11541 (gnus-summary-article-header parent))))
11542 (unless (and message-id (not (equal message-id "")))
11543 (error "No message-id in desired parent"))
11544 (gnus-with-article child
11546 (goto-char (point-min))
11547 (message-narrow-to-head)
11548 (if (re-search-forward "^References: " nil t)
11550 (re-search-forward "^[^ \t]" nil t)
11553 (insert " " message-id))
11554 (insert "References: " message-id "\n"))))
11555 (set-buffer gnus-summary-buffer)
11556 (gnus-summary-unmark-all-processable)
11557 (gnus-summary-update-article child)
11558 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11559 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11560 (gnus-summary-rethread-current)
11561 (gnus-message 3 "Article %d is now the child of article %d"
11564 (defun gnus-summary-toggle-threads (&optional arg)
11565 "Toggle showing conversation threads.
11566 If ARG is positive number, turn showing conversation threads on."
11568 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11569 (setq gnus-show-threads
11570 (if (null arg) (not gnus-show-threads)
11571 (> (prefix-numeric-value arg) 0)))
11572 (gnus-summary-prepare)
11573 (gnus-summary-goto-subject current)
11574 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11575 (gnus-summary-position-point)))
11578 (if (fboundp 'remove-overlays)
11579 (defalias 'gnus-remove-overlays 'remove-overlays)
11580 (defun gnus-remove-overlays (beg end name val)
11581 "Clear BEG and END of overlays whose property NAME has value VAL.
11582 For compatibility with XEmacs."
11583 (dolist (ov (gnus-overlays-in beg end))
11584 (when (eq (gnus-overlay-get ov name) val)
11585 (gnus-delete-overlay ov))))))
11587 (defun gnus-summary-show-all-threads ()
11588 "Show all threads."
11590 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11591 (gnus-summary-position-point))
11593 (defsubst gnus-summary--inv (p)
11594 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11596 (defun gnus-summary-show-thread ()
11597 "Show thread subtrees.
11598 Returns nil if no thread was there to be shown."
11600 (let* ((orig (point))
11601 (end (point-at-eol))
11602 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11603 ;; Leave point at bol
11604 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11606 (if (fboundp 'next-single-char-property-change)
11607 ;; Note: XEmacs version of n-s-c-p-c may return nil
11608 (or (next-single-char-property-change end 'invisible)
11613 (eq (get-char-property (point) 'invisible)
11617 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11619 (gnus-summary-position-point)
11622 (defun gnus-summary-maybe-hide-threads ()
11623 "If requested, hide the threads that should be hidden."
11624 (when (and gnus-show-threads
11625 gnus-thread-hide-subtree)
11626 (gnus-summary-hide-all-threads
11627 (if (or (consp gnus-thread-hide-subtree)
11628 (functionp gnus-thread-hide-subtree))
11629 (gnus-make-predicate gnus-thread-hide-subtree)
11632 ;;; Hiding predicates.
11634 (defun gnus-article-unread-p (header)
11635 (memq (mail-header-number header) gnus-newsgroup-unreads))
11637 (defun gnus-article-unseen-p (header)
11638 (memq (mail-header-number header) gnus-newsgroup-unseen))
11640 (defun gnus-map-articles (predicate articles)
11641 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11642 (apply 'gnus-or (mapcar predicate
11643 (mapcar (lambda (number)
11644 (gnus-summary-article-header number))
11647 (defun gnus-summary-hide-all-threads (&optional predicate)
11648 "Hide all thread subtrees.
11649 If PREDICATE is supplied, threads that satisfy this predicate
11650 will not be hidden."
11653 (goto-char (point-min))
11658 (when (zerop (mod count 1000))
11659 (message "Hiding all threads... %d" count))
11660 (when (or (not predicate)
11662 predicate (gnus-summary-article-children)))
11663 (gnus-summary-hide-thread))
11664 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11665 (gnus-summary-position-point))
11667 (defun gnus-summary-hide-thread ()
11668 "Hide thread subtrees.
11669 If PREDICATE is supplied, threads that satisfy this predicate
11670 will not be hidden.
11671 Returns nil if no threads were there to be hidden."
11673 (let ((start (point))
11674 (starteol (line-end-position))
11675 (article (gnus-summary-article-number)))
11677 ;; Go forward until either the buffer ends or the subthread ends.
11678 (when (and (not (eobp))
11679 (or (zerop (gnus-summary-next-thread 1 t))
11680 (goto-char (point-max))))
11681 (if (and (> (point) start)
11682 ;; FIXME: this should actually search for a non-invisible \n.
11683 (search-backward "\n" start t))
11685 (when (> (point) starteol)
11686 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11687 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11688 (gnus-overlay-put ol 'invisible 'gnus-sum)
11689 (gnus-overlay-put ol 'evaporate t)))
11690 (gnus-summary-goto-subject article)
11691 (when (> start (point))
11692 (message "Hiding the thread moved us backwards, aborting!")
11693 (goto-char (point-max))))
11697 (defun gnus-summary-go-to-next-thread (&optional previous)
11698 "Go to the same level (or less) next thread.
11699 If PREVIOUS is non-nil, go to previous thread instead.
11700 Return the article number moved to, or nil if moving was impossible."
11701 (let ((level (gnus-summary-thread-level))
11702 (way (if previous -1 1))
11705 (while (and (not (eobp))
11706 (< level (gnus-summary-thread-level)))
11707 (forward-line way))
11714 (gnus-summary-article-number)
11715 (goto-char beg)))))
11717 (defun gnus-summary-next-thread (n &optional silent)
11718 "Go to the same level next N'th thread.
11719 If N is negative, search backward instead.
11720 Returns the difference between N and the number of skips actually
11723 If SILENT, don't output messages."
11725 (let ((backward (< n 0))
11727 (while (and (> n 0)
11728 (gnus-summary-go-to-next-thread backward))
11731 (gnus-summary-position-point))
11732 (when (and (not silent) (/= 0 n))
11733 (gnus-message 7 "No more threads"))
11736 (defun gnus-summary-prev-thread (n)
11737 "Go to the same level previous N'th thread.
11738 Returns the difference between N and the number of skips actually
11741 (gnus-summary-next-thread (- n)))
11743 (defun gnus-summary-go-down-thread ()
11744 "Go down one level in the current thread."
11745 (let ((children (gnus-summary-article-children)))
11747 (gnus-summary-goto-subject (car children)))))
11749 (defun gnus-summary-go-up-thread ()
11750 "Go up one level in the current thread."
11751 (let ((parent (gnus-summary-article-parent)))
11753 (gnus-summary-goto-subject parent))))
11755 (defun gnus-summary-down-thread (n)
11756 "Go down thread N steps.
11757 If N is negative, go up instead.
11758 Returns the difference between N and how many steps down that were
11763 (while (and (> n 0)
11764 (if up (gnus-summary-go-up-thread)
11765 (gnus-summary-go-down-thread)))
11767 (gnus-summary-position-point)
11769 (gnus-message 7 "Can't go further"))
11772 (defun gnus-summary-up-thread (n)
11773 "Go up thread N steps.
11774 If N is negative, go down instead.
11775 Returns the difference between N and how many steps down that were
11778 (gnus-summary-down-thread (- n)))
11780 (defun gnus-summary-top-thread ()
11781 "Go to the top of the thread."
11783 (while (gnus-summary-go-up-thread))
11784 (gnus-summary-article-number))
11786 (defun gnus-summary-expire-thread ()
11787 "Mark articles under current thread as expired."
11789 (gnus-summary-kill-thread 0))
11791 (defun gnus-summary-kill-thread (&optional unmark)
11792 "Mark articles under current thread as read.
11793 If the prefix argument is positive, remove any kinds of marks.
11794 If the prefix argument is zero, mark thread as expired.
11795 If the prefix argument is negative, tick articles instead."
11798 (setq unmark (prefix-numeric-value unmark)))
11799 (let ((articles (gnus-summary-articles-in-thread))
11800 (hide (or (null unmark) (= unmark 0))))
11802 ;; Expand the thread.
11803 (gnus-summary-show-thread)
11804 ;; Mark all the articles.
11806 (gnus-summary-goto-subject (car articles))
11807 (cond ((null unmark)
11808 (gnus-summary-mark-article-as-read gnus-killed-mark))
11810 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11812 (gnus-summary-mark-article nil gnus-expirable-mark))
11814 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11815 (setq articles (cdr articles))))
11816 ;; Hide killed subtrees when hide is true.
11818 gnus-thread-hide-killed
11819 (gnus-summary-hide-thread))
11820 ;; If hide is t, go to next unread subject.
11822 ;; Go to next unread subject.
11823 (gnus-summary-next-subject 1 t)))
11824 (gnus-set-mode-line 'summary))
11826 ;; Summary sorting commands
11828 (defun gnus-summary-sort-by-number (&optional reverse)
11829 "Sort the summary buffer by article number.
11830 Argument REVERSE means reverse order."
11832 (gnus-summary-sort 'number reverse))
11834 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11835 "Sort the summary buffer by most recent article number.
11836 Argument REVERSE means reverse order."
11838 (gnus-summary-sort 'most-recent-number reverse))
11840 (defun gnus-summary-sort-by-random (&optional reverse)
11841 "Randomize the order in the summary buffer.
11842 Argument REVERSE means to randomize in reverse order."
11844 (gnus-summary-sort 'random reverse))
11846 (defun gnus-summary-sort-by-author (&optional reverse)
11847 "Sort the summary buffer by author name alphabetically.
11848 If `case-fold-search' is non-nil, case of letters is ignored.
11849 Argument REVERSE means reverse order."
11851 (gnus-summary-sort 'author reverse))
11853 (defun gnus-summary-sort-by-recipient (&optional reverse)
11854 "Sort the summary buffer by recipient name alphabetically.
11855 If `case-fold-search' is non-nil, case of letters is ignored.
11856 Argument REVERSE means reverse order."
11858 (gnus-summary-sort 'recipient reverse))
11860 (defun gnus-summary-sort-by-subject (&optional reverse)
11861 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11862 If `case-fold-search' is non-nil, case of letters is ignored.
11863 Argument REVERSE means reverse order."
11865 (gnus-summary-sort 'subject reverse))
11867 (defun gnus-summary-sort-by-date (&optional reverse)
11868 "Sort the summary buffer by date.
11869 Argument REVERSE means reverse order."
11871 (gnus-summary-sort 'date reverse))
11873 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11874 "Sort the summary buffer by most recent date.
11875 Argument REVERSE means reverse order."
11877 (gnus-summary-sort 'most-recent-date reverse))
11879 (defun gnus-summary-sort-by-score (&optional reverse)
11880 "Sort the summary buffer by score.
11881 Argument REVERSE means reverse order."
11883 (gnus-summary-sort 'score reverse))
11885 (defun gnus-summary-sort-by-lines (&optional reverse)
11886 "Sort the summary buffer by the number of lines.
11887 Argument REVERSE means reverse order."
11889 (gnus-summary-sort 'lines reverse))
11891 (defun gnus-summary-sort-by-chars (&optional reverse)
11892 "Sort the summary buffer by article length.
11893 Argument REVERSE means reverse order."
11895 (gnus-summary-sort 'chars reverse))
11897 (defun gnus-summary-sort-by-original (&optional reverse)
11898 "Sort the summary buffer using the default sorting method.
11899 Argument REVERSE means reverse order."
11901 (let* ((inhibit-read-only t)
11902 (gnus-summary-prepare-hook nil))
11903 ;; We do the sorting by regenerating the threads.
11904 (gnus-summary-prepare)
11905 ;; Hide subthreads if needed.
11906 (gnus-summary-maybe-hide-threads)))
11908 (defun gnus-summary-sort (predicate reverse)
11909 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11910 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11911 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11912 (gnus-thread-sort-functions
11917 (gnus-sort-gathered-threads-function
11918 gnus-thread-sort-functions)
11919 (gnus-article-sort-functions
11923 (,article t2 t1))))
11924 (inhibit-read-only t)
11925 (gnus-summary-prepare-hook nil))
11926 ;; We do the sorting by regenerating the threads.
11927 (gnus-summary-prepare)
11928 ;; Hide subthreads if needed.
11929 (gnus-summary-maybe-hide-threads)))
11931 ;; Summary saving commands.
11933 (defun gnus-summary-save-article (&optional n not-saved)
11934 "Save the current article using the default saver function.
11935 If N is a positive number, save the N next articles.
11936 If N is a negative number, save the N previous articles.
11937 If N is nil and any articles have been marked with the process mark,
11938 save those articles instead.
11939 The variable `gnus-default-article-saver' specifies the saver function.
11941 If the optional second argument NOT-SAVED is non-nil, articles saved
11942 will not be marked as saved."
11944 (require 'gnus-art)
11945 (let* ((articles (gnus-summary-work-articles n))
11946 (save-buffer (save-excursion
11947 (nnheader-set-temp-buffer " *Gnus Save*")))
11948 (num (length articles))
11949 ;; Whether to save decoded articles or raw articles.
11950 (decode (when gnus-article-save-coding-system
11951 (get gnus-default-article-saver :decode)))
11952 ;; When saving many articles in a single file, use the other
11953 ;; function to save articles other than the first one.
11954 (saver2 (get gnus-default-article-saver :function))
11955 (gnus-prompt-before-saving (if saver2
11957 gnus-prompt-before-saving))
11958 (gnus-default-article-saver gnus-default-article-saver)
11960 (dolist (article articles)
11961 (setq header (gnus-summary-article-header article))
11962 (if (not (vectorp header))
11963 ;; This is a pseudo-article.
11964 (if (assq 'name header)
11965 (gnus-copy-file (cdr (assq 'name header)))
11966 (gnus-message 1 "Article %d is unsavable" article))
11967 ;; This is a real article.
11968 (save-window-excursion
11969 (gnus-summary-select-article decode decode nil article)
11970 (gnus-summary-goto-subject article))
11971 (with-current-buffer save-buffer
11973 (insert-buffer-substring (if decode
11974 gnus-article-buffer
11975 gnus-original-article-buffer)))
11976 (setq file (gnus-article-save save-buffer file num))
11977 (gnus-summary-remove-process-mark article)
11979 (gnus-summary-set-saved-mark article)))
11981 (setq gnus-default-article-saver saver2
11983 (gnus-kill-buffer save-buffer)
11984 (gnus-summary-position-point)
11985 (gnus-set-mode-line 'summary)
11988 (defun gnus-summary-pipe-output (&optional n sym)
11989 "Pipe the current article to a subprocess.
11990 If N is a positive number, pipe the N next articles.
11991 If N is a negative number, pipe the N previous articles.
11992 If N is nil and any articles have been marked with the process mark,
11993 pipe those articles instead.
11994 The default command to which articles are piped is specified by the
11995 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11996 will be prompted for the command.
11998 The properties `:decode' and `:headers' that are put to the function
11999 symbol `gnus-summary-save-in-pipe' control whether this function
12000 decodes articles and what headers to keep (see the doc string for the
12001 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12002 is neither omitted nor the symbol `r', force including all headers
12003 regardless of the `:headers' property. If it is the symbol `r',
12004 articles that are not decoded and include all headers will be piped
12005 no matter what the properties `:decode' and `:headers' are."
12006 (interactive (gnus-interactive "P\ny"))
12007 (require 'gnus-art)
12008 (let* ((articles (gnus-summary-work-articles n))
12009 (result-buffer "*Shell Command Output*")
12010 (all-headers (not (memq sym '(nil r))))
12011 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12013 (headers (get 'gnus-summary-save-in-pipe :headers))
12015 (unless (numberp (car articles))
12016 (error "No article to pipe"))
12017 (setq command (gnus-read-shell-command
12018 (concat "Shell command on "
12020 (format "these %d articles" (length articles))
12023 gnus-summary-pipe-output-default-command))
12024 (when (string-equal command "")
12025 (error "A command is required"))
12027 (put 'gnus-summary-save-in-pipe :headers nil))
12030 (gnus-summary-goto-subject (pop articles))
12031 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12032 (when (and (get-buffer result-buffer)
12033 (not (zerop (buffer-size (get-buffer result-buffer)))))
12034 (setq result (concat result (with-current-buffer result-buffer
12035 (buffer-string))))))
12036 (put 'gnus-summary-save-in-pipe :headers headers))
12037 (unless (zerop (length result))
12038 (if (with-current-buffer (get-buffer-create result-buffer)
12042 (and (= (count-lines (point-min) (point)) 1)
12045 (<= (current-column)
12046 (window-width (minibuffer-window)))))
12047 (goto-char (point-min))))
12048 (message "%s" (substring result 0 -1))
12050 (gnus-configure-windows 'pipe)))))
12052 (defun gnus-summary-save-article-mail (&optional arg)
12053 "Append the current article to a Unix mail box file.
12054 If N is a positive number, save the N next articles.
12055 If N is a negative number, save the N previous articles.
12056 If N is nil and any articles have been marked with the process mark,
12057 save those articles instead."
12059 (require 'gnus-art)
12060 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12061 (gnus-summary-save-article arg)))
12063 (defun gnus-summary-save-article-rmail (&optional arg)
12064 "Append the current article to an rmail file.
12065 If N is a positive number, save the N next articles.
12066 If N is a negative number, save the N previous articles.
12067 If N is nil and any articles have been marked with the process mark,
12068 save those articles instead."
12070 (require 'gnus-art)
12071 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12072 (gnus-summary-save-article arg)))
12074 (defun gnus-summary-save-article-file (&optional arg)
12075 "Append the current article to a file.
12076 If N is a positive number, save the N next articles.
12077 If N is a negative number, save the N previous articles.
12078 If N is nil and any articles have been marked with the process mark,
12079 save those articles instead."
12081 (require 'gnus-art)
12082 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12083 (gnus-summary-save-article arg)))
12085 (defun gnus-summary-write-article-file (&optional arg)
12086 "Write the current article to a file, deleting the previous file.
12087 If N is a positive number, save the N next articles.
12088 If N is a negative number, save the N previous articles.
12089 If N is nil and any articles have been marked with the process mark,
12090 save those articles instead."
12092 (require 'gnus-art)
12093 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12094 (gnus-summary-save-article arg)))
12096 (defun gnus-summary-save-article-body-file (&optional arg)
12097 "Append the current article body to a file.
12098 If N is a positive number, save the N next articles.
12099 If N is a negative number, save the N previous articles.
12100 If N is nil and any articles have been marked with the process mark,
12101 save those articles instead."
12103 (require 'gnus-art)
12104 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12105 (gnus-summary-save-article arg)))
12107 (defun gnus-summary-write-article-body-file (&optional arg)
12108 "Write the current article body to a file, deleting the previous file.
12109 If N is a positive number, save the N next articles.
12110 If N is a negative number, save the N previous articles.
12111 If N is nil and any articles have been marked with the process mark,
12112 save those articles instead."
12114 (require 'gnus-art)
12115 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12116 (gnus-summary-save-article arg)))
12118 (defun gnus-summary-muttprint (&optional arg)
12119 "Print the current article using Muttprint.
12120 If N is a positive number, save the N next articles.
12121 If N is a negative number, save the N previous articles.
12122 If N is nil and any articles have been marked with the process mark,
12123 save those articles instead."
12125 (require 'gnus-art)
12126 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12127 (gnus-summary-save-article arg t)))
12129 (defun gnus-summary-pipe-message (program)
12130 "Pipe the current article through PROGRAM."
12131 (interactive "sProgram: ")
12132 (gnus-summary-select-article)
12133 (let ((mail-header-separator ""))
12134 (gnus-eval-in-buffer-window gnus-article-buffer
12137 (let ((start (window-start))
12138 (inhibit-read-only t))
12139 (message-pipe-buffer-body program)
12140 (set-window-start (get-buffer-window (current-buffer)) start))))))
12142 (defun gnus-get-split-value (methods)
12143 "Return a value based on the split METHODS."
12144 (let (split-name method result match)
12146 (with-current-buffer gnus-original-article-buffer
12148 (nnheader-narrow-to-headers)
12149 (while (and methods (not split-name))
12150 (goto-char (point-min))
12151 (setq method (pop methods))
12152 (setq match (car method))
12155 ;; Regular expression.
12157 (re-search-forward match nil t)))
12162 (setq result (funcall match gnus-newsgroup-name))))
12167 (setq result (eval match)))))
12168 (setq split-name (cdr method))
12169 (cond ((stringp result)
12170 (push (expand-file-name
12171 result gnus-article-save-directory)
12174 (setq split-name (append result split-name)))))))))
12175 (nreverse split-name)))
12177 (defun gnus-valid-move-group-p (group)
12178 (and (symbolp group)
12180 (symbol-name group)
12181 (symbol-value group)
12182 (gnus-get-function (gnus-find-method-for-group
12183 (symbol-name group)) 'request-accept-article t)))
12185 (defun gnus-read-move-group-name (prompt default articles prefix)
12186 "Read a group name."
12187 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12188 (minibuffer-confirm-incomplete nil) ; XEmacs
12192 (if (> (length articles) 1)
12193 (format "these %d articles" (length articles))
12198 (gnus-group-completing-read
12200 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12201 nil prefix nil default))
12202 ((= 1 (length split-name))
12203 (gnus-group-completing-read
12205 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12206 nil prefix 'gnus-group-history (car split-name)))
12208 (gnus-completing-read
12209 prom (nreverse split-name) nil nil 'gnus-group-history))))
12210 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12213 (if (or (string= to-newsgroup "")
12214 (string= to-newsgroup prefix))
12215 (setq to-newsgroup default))
12216 (unless to-newsgroup
12217 (error "No group name entered"))
12218 (setq encoded (mm-encode-coding-string
12220 (gnus-group-name-charset to-method to-newsgroup)))
12221 (or (gnus-active encoded)
12222 (gnus-activate-group encoded nil nil to-method)
12223 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12225 (or (and (gnus-request-create-group encoded to-method)
12226 (gnus-activate-group encoded nil nil to-method)
12227 (gnus-subscribe-group encoded))
12228 (error "Couldn't create group %s" to-newsgroup)))
12229 (error "No such group: %s" to-newsgroup))
12232 (defvar gnus-summary-save-parts-counter)
12233 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12235 (defun gnus-summary-save-parts (type dir n &optional reverse)
12236 "Save parts matching TYPE to DIR.
12237 If REVERSE, save parts that do not match TYPE."
12239 (list (read-string "Save parts of type: "
12240 (or (car gnus-summary-save-parts-type-history)
12241 gnus-summary-save-parts-default-mime)
12242 'gnus-summary-save-parts-type-history)
12243 (setq gnus-summary-save-parts-last-directory
12244 (read-directory-name "Save to directory: "
12245 gnus-summary-save-parts-last-directory
12247 current-prefix-arg))
12248 (gnus-summary-iterate n
12249 (let ((gnus-display-mime-function nil)
12250 gnus-article-prepare-hook
12251 gnus-article-decode-hook
12252 gnus-display-mime-function
12254 (gnus-inhibit-treatment t))
12255 (gnus-summary-select-article))
12256 (with-current-buffer gnus-article-buffer
12257 (let ((handles (or gnus-article-mime-handles
12258 (mm-dissect-buffer nil gnus-article-loose-mime)
12259 (and gnus-article-emulate-mime
12261 (gnus-summary-save-parts-counter 1))
12263 (gnus-summary-save-parts-1 type dir handles reverse)
12264 (unless gnus-article-mime-handles ;; Don't destroy this case.
12265 (mm-destroy-parts handles)))))))
12267 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12268 (if (stringp (car handle))
12269 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12272 (not (string-match type (mm-handle-media-type handle)))
12273 (string-match type (mm-handle-media-type handle)))
12274 (let ((file (expand-file-name
12276 mm-file-name-rewrite-functions
12277 (file-name-nondirectory
12279 (mm-handle-filename handle)
12280 (format "%s.%d.%d" gnus-newsgroup-name
12281 (cdr gnus-article-current)
12282 gnus-summary-save-parts-counter))))
12284 (incf gnus-summary-save-parts-counter)
12285 (unless (file-exists-p file)
12286 (mm-save-part-to-file handle file))))))
12288 ;; Summary extract commands
12290 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12291 (let ((inhibit-read-only t)
12292 (article (gnus-summary-article-number))
12294 (unless (gnus-summary-goto-subject article)
12295 (error "No such article: %d" article))
12296 (gnus-summary-position-point)
12297 ;; If all commands are to be bunched up on one line, we collect
12299 (unless gnus-view-pseudos-separately
12300 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12303 (setq action (cdr (assq 'action (car ps))))
12304 (setq files (list (cdr (assq 'name (car ps)))))
12305 (while (and ps (cdr ps)
12306 (string= (or action "1")
12307 (or (cdr (assq 'action (cadr ps))) "2")))
12308 (push (cdr (assq 'name (cadr ps))) files)
12309 (setcdr ps (cddr ps)))
12311 (when (not (string-match "%s" action))
12314 (when (assq 'execute (car ps))
12315 (setcdr (assq 'execute (car ps))
12316 (funcall (if (string-match "%s" action)
12323 (shell-quote-argument f)))
12325 (setq ps (cdr ps)))))
12326 (if (and gnus-view-pseudos (not not-view))
12328 (when (assq 'execute (car pslist))
12329 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12330 (eq gnus-view-pseudos 'not-confirm)))
12331 (setq pslist (cdr pslist)))
12334 (setq after-article (or (cdr (assq 'article (car pslist)))
12335 (gnus-summary-article-number)))
12336 (gnus-summary-goto-subject after-article)
12339 (insert " " (file-name-nondirectory
12340 (cdr (assq 'name (car pslist))))
12341 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12343 (forward-line -1) ; back to `b'
12344 (gnus-add-text-properties
12345 b (1- e) (list 'gnus-number gnus-reffed-article-number
12346 gnus-mouse-face-prop gnus-mouse-face))
12348 after-article gnus-reffed-article-number
12349 gnus-unread-mark b (car pslist) 0 (- e b))
12350 (setq gnus-newsgroup-unreads
12351 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12352 gnus-reffed-article-number))
12353 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12354 (setq pslist (cdr pslist)))))))
12356 (defun gnus-pseudos< (p1 p2)
12357 (let ((c1 (cdr (assq 'action p1)))
12358 (c2 (cdr (assq 'action p2))))
12359 (and c1 c2 (string< c1 c2))))
12361 (defun gnus-request-pseudo-article (props)
12362 (cond ((assq 'execute props)
12363 (gnus-execute-command (cdr (assq 'execute props)))))
12364 (let ((gnus-current-article (gnus-summary-article-number)))
12365 (gnus-run-hooks 'gnus-mark-article-hook)))
12367 (defun gnus-execute-command (command &optional automatic)
12369 (gnus-article-setup-buffer)
12370 (set-buffer gnus-article-buffer)
12371 (setq buffer-read-only nil)
12372 (let ((command (if automatic command
12373 (read-string "Command: " (cons command 0)))))
12375 (insert "$ " command "\n\n")
12376 (if gnus-view-pseudo-asynchronously
12377 (start-process "gnus-execute" (current-buffer) shell-file-name
12378 shell-command-switch command)
12379 (call-process shell-file-name nil t nil
12380 shell-command-switch command)))))
12382 ;; Summary kill commands.
12384 (defun gnus-summary-edit-global-kill (article)
12385 "Edit the \"global\" kill file."
12386 (interactive (list (gnus-summary-article-number)))
12387 (gnus-group-edit-global-kill article))
12389 (defun gnus-summary-edit-local-kill ()
12390 "Edit a local kill file applied to the current newsgroup."
12392 (setq gnus-current-headers (gnus-summary-article-header))
12393 (gnus-group-edit-local-kill
12394 (gnus-summary-article-number) gnus-newsgroup-name))
12396 ;;; Header reading.
12398 (defun gnus-read-header (id &optional header)
12399 "Read the headers of article ID and enter them into the Gnus system."
12400 (let ((group gnus-newsgroup-name)
12401 (gnus-override-method
12403 gnus-override-method
12404 (and (gnus-news-group-p gnus-newsgroup-name)
12405 (car (gnus-refer-article-methods)))))
12407 ;; First we check to see whether the header in question is already
12410 ;; This is a Message-ID.
12411 (setq header (or header (gnus-id-to-header id)))
12412 ;; This is an article number.
12413 (setq header (or header (gnus-summary-article-header id))))
12415 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12416 ;; We have found the header.
12418 ;; We have to really fetch the header to this article.
12419 (with-current-buffer nntp-server-buffer
12420 (when (setq where (gnus-request-head id group))
12421 (nnheader-fold-continuation-lines)
12422 (goto-char (point-max))
12424 (goto-char (point-min))
12428 ((cdr where) (cdr where))
12429 (header (mail-header-number header))
12430 (t gnus-reffed-article-number))
12432 (insert " Article retrieved.\n"))
12433 (if (or (not where)
12434 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12435 () ; Malformed head.
12436 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12437 (when (and (bound-and-true-p gnus-registry-enabled)
12438 (not (gnus-ephemeral-group-p (car where))))
12439 (gnus-registry-handle-action
12440 (mail-header-id header) nil
12441 (gnus-group-prefixed-name (car where) gnus-override-method)
12442 (mail-header-subject header)
12443 (mail-header-from header)))
12444 (when (and (stringp id)
12446 (not (string= (gnus-group-real-name group)
12448 (not (gnus-server-equal gnus-override-method
12449 (gnus-group-method group)))))
12450 ;; If we fetched by Message-ID and the article came from
12451 ;; a different group (or server), we fudge some bogus
12452 ;; article numbers for this article.
12453 (mail-header-set-number header gnus-reffed-article-number))
12454 (with-current-buffer gnus-summary-buffer
12455 (decf gnus-reffed-article-number)
12456 (gnus-remove-header (mail-header-number header))
12457 (push header gnus-newsgroup-headers)
12458 (setq gnus-current-headers header)
12459 (push (mail-header-number header) gnus-newsgroup-limit)))
12462 (defun gnus-remove-header (number)
12463 "Remove header NUMBER from `gnus-newsgroup-headers'."
12464 (if (and gnus-newsgroup-headers
12465 (= number (mail-header-number (car gnus-newsgroup-headers))))
12466 (pop gnus-newsgroup-headers)
12467 (let ((headers gnus-newsgroup-headers))
12468 (while (and (cdr headers)
12469 (not (= number (mail-header-number (cadr headers)))))
12471 (when (cdr headers)
12472 (setcdr headers (cddr headers))))))
12475 ;;; summary highlights
12478 (defun gnus-highlight-selected-summary ()
12479 "Highlight selected article in summary buffer."
12480 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12481 (when gnus-summary-selected-face
12483 (let* ((beg (point-at-bol))
12484 (end (point-at-eol))
12485 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12486 (from (if (get-text-property beg gnus-mouse-face-prop)
12488 (or (next-single-property-change
12489 beg gnus-mouse-face-prop nil end)
12494 (or (next-single-property-change
12495 from gnus-mouse-face-prop nil end)
12497 ;; If no mouse-face prop on line we will have to = from = end,
12498 ;; so we highlight the entire line instead.
12499 (when (= (+ to 2) from)
12502 (if gnus-newsgroup-selected-overlay
12503 ;; Move old overlay.
12505 gnus-newsgroup-selected-overlay from to (current-buffer))
12506 ;; Create new overlay.
12508 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12509 'face gnus-summary-selected-face))))))
12511 (defvar gnus-summary-highlight-line-cached nil)
12512 (defvar gnus-summary-highlight-line-trigger nil)
12514 (defun gnus-summary-highlight-line-0 ()
12515 (if (and (eq gnus-summary-highlight-line-trigger
12516 gnus-summary-highlight)
12517 gnus-summary-highlight-line-cached)
12518 gnus-summary-highlight-line-cached
12519 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12520 gnus-summary-highlight-line-cached
12521 (let* ((cond (list 'cond))
12523 (list gnus-summary-highlight))
12525 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12529 (gnus-byte-compile (list 'lambda nil cond))))))
12531 (defun gnus-summary-highlight-line ()
12532 "Highlight current line according to `gnus-summary-highlight'."
12533 (let* ((beg (point-at-bol))
12534 (article (or (gnus-summary-article-number) gnus-current-article))
12535 (score (or (cdr (assq article
12536 gnus-newsgroup-scored))
12537 gnus-summary-default-score 0))
12538 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12539 (inhibit-read-only t)
12540 (default gnus-summary-default-score)
12541 (default-high gnus-summary-default-high-score)
12542 (default-low gnus-summary-default-low-score)
12543 (uncached (and gnus-summary-use-undownloaded-faces
12544 (memq article gnus-newsgroup-undownloaded)
12545 (not (memq article gnus-newsgroup-cached)))))
12546 (let ((face (funcall (gnus-summary-highlight-line-0))))
12547 (unless (eq face (get-text-property beg 'face))
12548 (gnus-put-text-property-excluding-characters-with-faces
12549 beg (point-at-eol) 'face
12550 (setq face (if (boundp face) (symbol-value face) face)))
12551 (when gnus-summary-highlight-line-function
12552 (funcall gnus-summary-highlight-line-function article face))))))
12554 (defun gnus-update-read-articles (group unread &optional compute)
12555 "Update the list of read articles in GROUP.
12556 UNREAD is a sorted list."
12557 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12558 (info (gnus-get-info group))
12561 (if (or (not info) (not active))
12562 ;; There is no info on this group if it was, in fact,
12563 ;; killed. Gnus stores no information on killed groups, so
12564 ;; there's nothing to be done.
12565 ;; One could store the information somewhere temporarily,
12566 ;; perhaps... Hmmm...
12568 ;; Remove any negative articles numbers.
12569 (while (and unread (< (car unread) 0))
12570 (setq unread (cdr unread)))
12571 ;; Remove any expired article numbers
12572 (while (and unread (< (car unread) (car active)))
12573 (setq unread (cdr unread)))
12574 ;; Compute the ranges of read articles by looking at the list of
12575 ;; unread articles.
12577 (when (/= (car unread) prev)
12578 (push (if (= prev (1- (car unread))) prev
12579 (cons prev (1- (car unread))))
12581 (setq prev (1+ (car unread)))
12582 (setq unread (cdr unread)))
12583 (when (<= prev (cdr active))
12584 (push (cons prev (cdr active)) read))
12585 (setq read (if (> (length read) 1) (nreverse read) read))
12590 ;; Propagate the read marks to the backend.
12591 (when (and (gnus-method-option-p
12592 (gnus-find-method-for-group group)
12594 (gnus-check-backend-function 'request-set-mark group))
12595 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12596 (add (gnus-remove-from-range read (gnus-info-read info))))
12598 (unless (gnus-check-group group)
12599 (error "Can't open server for %s" group))
12600 (gnus-request-set-mark
12601 group (delq nil (list (if add (list add 'add '(read)))
12602 (if del (list del 'del '(read))))))
12604 `(gnus-request-set-mark
12607 (if del (list del 'add '(read)))
12608 (if add (list add 'del '(read))))))))))
12609 (set-buffer gnus-group-buffer)
12610 (gnus-undo-register
12612 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12613 (gnus-info-set-read ',info ',(gnus-info-read info))
12614 (gnus-get-unread-articles-in-group ',info
12615 (gnus-active ,group))
12616 (gnus-group-update-group ,group t)
12618 ;; Enter this list into the group info.
12619 (gnus-info-set-read info read)
12620 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12621 (gnus-get-unread-articles-in-group info (gnus-active group))
12624 (defun gnus-offer-save-summaries ()
12625 "Offer to save all active summary buffers."
12627 ;; Go through all buffers and find all summaries.
12628 (dolist (buffer (buffer-list))
12629 (when (and (setq buffer (buffer-name buffer))
12630 (string-match "Summary" buffer)
12631 (with-current-buffer buffer
12632 ;; We check that this is, indeed, a summary buffer.
12633 (and (eq major-mode 'gnus-summary-mode)
12634 ;; Also make sure this isn't bogus.
12635 gnus-newsgroup-prepared
12636 ;; Also make sure that this isn't a
12637 ;; dead summary buffer.
12638 (not gnus-dead-summary-mode))))
12639 (push buffer buffers)))
12640 ;; Go through all these summary buffers and offer to save them.
12643 (if (eq gnus-interactive-exit 'quiet)
12644 (dolist (buffer buffers)
12645 (switch-to-buffer buffer)
12646 (gnus-summary-exit))
12648 "Update summary buffer %s? "
12650 (switch-to-buffer buf)
12651 (gnus-summary-exit))
12654 (defun gnus-summary-setup-default-charset ()
12655 "Setup newsgroup default charset."
12656 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12657 (setq gnus-newsgroup-charset nil)
12658 (let* ((ignored-charsets
12659 (or gnus-newsgroup-ephemeral-ignored-charsets
12661 (and gnus-newsgroup-name
12662 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12663 gnus-newsgroup-ignored-charsets))))
12664 (setq gnus-newsgroup-charset
12665 (or gnus-newsgroup-ephemeral-charset
12666 (and gnus-newsgroup-name
12667 (gnus-parameter-charset gnus-newsgroup-name))
12668 gnus-default-charset))
12669 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12670 ignored-charsets))))
12676 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12677 "Display the current article buffer fully MIME-buttonized.
12678 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12679 treated as multipart/mixed."
12681 (require 'gnus-art)
12682 (let ((gnus-unbuttonized-mime-types nil)
12683 (gnus-mime-display-multipart-as-mixed show-all-parts))
12684 (gnus-summary-show-article)))
12686 (defun gnus-summary-repair-multipart (article)
12687 "Add a Content-Type header to a multipart article without one."
12688 (interactive (list (gnus-summary-article-number)))
12689 (gnus-with-article article
12690 (message-narrow-to-head)
12691 (message-remove-header "Mime-Version")
12692 (goto-char (point-max))
12693 (insert "Mime-Version: 1.0\n")
12695 (when (search-forward "\n--" nil t)
12696 (let ((separator (buffer-substring (point) (point-at-eol))))
12697 (message-narrow-to-head)
12698 (message-remove-header "Content-Type")
12699 (goto-char (point-max))
12700 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12703 (let (gnus-mark-article-hook)
12704 (gnus-summary-select-article t t nil article)))
12706 (defun gnus-summary-toggle-display-buttonized ()
12707 "Toggle the buttonizing of the article buffer."
12709 (require 'gnus-art)
12710 (if (setq gnus-inhibit-mime-unbuttonizing
12711 (not gnus-inhibit-mime-unbuttonizing))
12712 (let ((gnus-unbuttonized-mime-types nil))
12713 (gnus-summary-show-article))
12714 (gnus-summary-show-article)))
12717 ;;; Generic summary marking commands
12720 (defvar gnus-summary-marking-alist
12721 '((read gnus-del-mark "d")
12722 (unread gnus-unread-mark "u")
12723 (ticked gnus-ticked-mark "!")
12724 (dormant gnus-dormant-mark "?")
12725 (expirable gnus-expirable-mark "e"))
12726 "An alist of names/marks/keystrokes.")
12728 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12729 (defvar gnus-summary-mark-map)
12731 (defun gnus-summary-make-all-marking-commands ()
12732 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12733 (dolist (elem gnus-summary-marking-alist)
12734 (apply 'gnus-summary-make-marking-command elem)))
12736 (defun gnus-summary-make-marking-command (name mark keystroke)
12737 (let ((map (make-sparse-keymap)))
12738 (define-key gnus-summary-generic-mark-map keystroke map)
12739 (dolist (lway `((next "next" next nil "n")
12740 (next-unread "next unread" next t "N")
12741 (prev "previous" prev nil "p")
12742 (prev-unread "previous unread" prev t "P")
12743 (nomove "" nil nil ,keystroke)))
12744 (let ((func (gnus-summary-make-marking-command-1
12745 mark (car lway) lway name)))
12746 (setq func (eval func))
12747 (define-key map (nth 4 lway) func)))))
12749 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12751 (format "gnus-summary-put-mark-as-%s%s"
12752 name (if (eq way 'nomove)
12754 (concat "-" (symbol-name way)))))
12757 "Mark the current article as %s%s.
12758 If N, the prefix, then repeat N times.
12759 If N is negative, move in reverse order.
12760 The difference between N and the actual number of articles marked is
12764 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12766 (defun gnus-summary-generic-mark (n mark move unread)
12767 "Mark N articles with MARK."
12768 (unless (eq major-mode 'gnus-summary-mode)
12769 (error "This command can only be used in the summary buffer"))
12770 (gnus-summary-show-thread)
12773 ((eq move 'next) 1)
12774 ((eq move 'prev) -1)
12776 (if (zerop nummove)
12780 nummove (* -1 nummove))))
12781 (while (and (> n 0)
12782 (gnus-summary-mark-article nil mark)
12783 (zerop (gnus-summary-next-subject nummove unread t)))
12786 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12787 (gnus-summary-recenter)
12788 (gnus-summary-position-point)
12789 (gnus-set-mode-line 'summary)
12792 (defun gnus-summary-insert-articles (articles)
12793 (when (setq articles
12794 (gnus-sorted-difference articles
12795 (mapcar (lambda (h)
12796 (mail-header-number h))
12797 gnus-newsgroup-headers)))
12798 (setq gnus-newsgroup-headers
12800 gnus-newsgroup-headers
12801 (gnus-fetch-headers articles)
12802 'gnus-article-sort-by-number))
12803 (setq gnus-newsgroup-articles
12804 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12805 ;; Suppress duplicates?
12806 (when gnus-suppress-duplicates
12807 (gnus-dup-suppress-articles))
12809 (if (and gnus-fetch-old-headers
12810 (eq gnus-headers-retrieved-by 'nov))
12811 ;; We might want to build some more threads first.
12812 (if (eq gnus-fetch-old-headers 'invisible)
12813 (gnus-build-all-threads)
12814 (gnus-build-old-threads))
12815 ;; Mark the inserted articles that are unread as unread.
12816 (setq gnus-newsgroup-unreads
12817 (gnus-sorted-nunion
12818 gnus-newsgroup-unreads
12819 (gnus-sorted-nintersection
12820 (gnus-list-of-unread-articles gnus-newsgroup-name)
12822 ;; Mark the inserted articles as selected so that the information
12823 ;; of the marks having been changed by a user may be updated when
12824 ;; exiting this group. See `gnus-summary-update-info'.
12825 (dolist (art articles)
12826 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12827 ;; Let the Gnus agent mark articles as read.
12829 (gnus-agent-get-undownloaded-list))
12830 ;; Remove list identifiers from subject
12831 (gnus-summary-remove-list-identifiers)
12832 ;; First and last article in this newsgroup.
12833 (when gnus-newsgroup-headers
12834 (setq gnus-newsgroup-begin
12835 (mail-header-number (car gnus-newsgroup-headers))
12837 (mail-header-number
12838 (gnus-last-element gnus-newsgroup-headers))))
12839 (when gnus-use-scoring
12840 (gnus-possibly-score-headers))))
12842 (defun gnus-summary-insert-old-articles (&optional all)
12843 "Insert all old articles in this group.
12844 If ALL is non-nil, already read articles become readable.
12845 If ALL is a number, fetch this number of articles."
12848 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12851 ;; Some nntp servers lie about their active range. When
12852 ;; this happens, the active range can be in the millions.
12853 ;; Use a compressed range to avoid creating a huge list.
12854 (gnus-range-difference (list gnus-newsgroup-active) old))
12855 (setq len (gnus-range-length older))
12860 (let ((older-range (nreverse older)))
12864 (let* ((r (pop older-range))
12865 (min (if (numberp r) r (car r)))
12866 (max (if (numberp r) r (cdr r))))
12867 (while (and (<= min max)
12872 (setq older (gnus-uncompress-range older))))
12874 (setq older (gnus-uncompress-range older)))
12876 (when (and (numberp gnus-large-newsgroup)
12877 (> len gnus-large-newsgroup))
12878 (let* ((cursor-in-echo-area nil)
12879 (initial (gnus-parameter-large-newsgroup-initial
12880 gnus-newsgroup-name))
12884 "How many articles from %s (%s %d): "
12885 (gnus-group-decoded-name gnus-newsgroup-name)
12886 (if initial "max" "default")
12890 (number-to-string initial)))))
12891 (unless (string-match "^[ \t]*$" input)
12892 (setq all (string-to-number input))
12894 (let ((older-range (nreverse older)))
12898 (let* ((r (pop older-range))
12899 (min (if (numberp r) r (car r)))
12900 (max (if (numberp r) r (cdr r))))
12901 (while (and (<= min max)
12905 max (1- max))))))))))
12906 (setq older (gnus-uncompress-range older))))
12908 (message "No old news.")
12909 (gnus-summary-insert-articles older)
12910 (gnus-summary-limit (gnus-sorted-nunion old older))))
12911 (gnus-summary-position-point)))
12913 (defun gnus-summary-insert-new-articles ()
12914 "Insert all new articles in this group."
12916 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12917 (old-high gnus-newsgroup-highest)
12918 (nnmail-fetched-sources (list t))
12919 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12922 (error "Couldn't fetch new data"))
12923 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12924 (setq i (cdr gnus-newsgroup-active)
12925 gnus-newsgroup-highest i)
12926 (while (> i old-high)
12930 (message "No gnus is bad news")
12931 (gnus-summary-insert-articles new)
12932 (setq gnus-newsgroup-unreads
12933 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12934 (gnus-summary-limit (gnus-sorted-nunion old new))))
12935 (gnus-summary-position-point))
12937 ;;; Bookmark support for Gnus.
12938 (declare-function bookmark-make-record-default
12939 "bookmark" (&optional no-file no-context posn))
12940 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12941 (declare-function bookmark-default-handler "bookmark" (bmk))
12942 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12943 (defvar bookmark-yank-point)
12944 (defvar bookmark-current-buffer)
12946 (defun gnus-summary-bookmark-make-record ()
12947 "Make a bookmark entry for a Gnus summary buffer."
12949 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12950 (save-restriction ; FIXME is it necessary to widen?
12951 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12952 (setq buf "art") ; We are recording bookmark from article buffer.
12953 (setq bookmark-yank-point (point))
12954 (setq bookmark-current-buffer (current-buffer))
12955 (gnus-article-show-summary)) ; Go back in summary buffer.
12956 ;; We are now recording bookmark from summary buffer.
12957 (unless buf (setq buf "sum"))
12958 (let* ((subject (elt (gnus-summary-article-header) 1))
12959 (grp (car gnus-article-current))
12960 (art (cdr gnus-article-current))
12961 (head (gnus-summary-article-header art))
12962 (id (mail-header-id head)))
12964 ,@(condition-case nil
12965 (bookmark-make-record-default 'no-file 'no-context pos)
12966 (wrong-number-of-arguments
12967 (bookmark-make-record-default 'point-only)))
12968 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12969 (group . ,grp) (article . ,art)
12970 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12973 (defun gnus-summary-bookmark-jump (bookmark)
12974 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12975 BOOKMARK is a bookmark name or a bookmark record."
12976 (let ((group (bookmark-prop-get bookmark 'group))
12977 (article (bookmark-prop-get bookmark 'article))
12978 (id (bookmark-prop-get bookmark 'message-id))
12979 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12980 (gnus-fetch-group group (list article))
12981 (gnus-summary-insert-cached-articles)
12982 (gnus-summary-goto-article id nil 'force)
12983 ;; FIXME we have to wait article buffer is ready (only large buffer)
12984 ;; Is there a better solution to know that?
12985 ;; If we don't wait `bookmark-default-handler' will have no chance
12986 ;; to set position. However there is no error, just wrong pos.
12988 (when (string= buf "Gnus-art")
12990 (bookmark-default-handler
12992 (buffer . ,(current-buffer))
12993 . ,(bookmark-get-bookmark-record bookmark)))))
12995 (gnus-summary-make-all-marking-commands)
12997 (gnus-ems-redefine)
12999 (provide 'gnus-sum)
13001 (run-hooks 'gnus-sum-load-hook)
13003 ;; Local Variables:
13004 ;; coding: iso-8859-1
13007 ;;; gnus-sum.el ends here