1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34 (when (featurep 'xemacs)
35 (require 'easy-mmode))) ; for `define-minor-mode'
37 (defvar tool-bar-mode)
38 (defvar gnus-tmp-header)
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-cache-write-active "gnus-cache")
53 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
54 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
55 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
60 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
64 (defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66 If nil, the summary will become a \"*Dead Summary*\" buffer, and
67 it will be killed sometime later."
68 :group 'gnus-summary-exit
71 (defcustom gnus-summary-next-group-on-exit t
72 "If non-nil, go to the next unread newsgroup on summary exit.
73 See `gnus-group-goto-unread'."
74 :link '(custom-manual "(gnus)Group Maneuvering")
75 :group 'gnus-summary-exit
76 :version "23.1" ;; No Gnus
79 (defcustom gnus-summary-stop-at-end-of-message nil
80 "If non-nil, don't select the next message when using `SPC'."
81 :link '(custom-manual "(gnus)Group Maneuvering")
82 :group 'gnus-summary-maneuvering
86 (defcustom gnus-fetch-old-headers nil
87 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
88 If an unread article in the group refers to an older, already
89 read (or just marked as read) article, the old article will not
90 normally be displayed in the Summary buffer. If this variable is
91 t, Gnus will attempt to grab the headers to the old articles, and
92 thereby build complete threads. If it has the value `some', all
93 old headers will be fetched but only enough headers to connect
94 otherwise loose threads will be displayed. This variable can
95 also be a number. In that case, no more than that number of old
96 headers will be fetched. If it has the value `invisible', all
97 old headers will be fetched, but none will be displayed.
99 The server has to support NOV for any of this to work.
101 This feature can seriously impact performance it ignores all
102 locally cached header entries. Setting it to t for groups for a
103 server that doesn't expire articles (such as news.gmane.org),
104 leads to very slow summary generation."
106 :type '(choice (const :tag "off" nil)
111 (sexp :menu-tag "other" t)))
113 (defcustom gnus-refer-thread-limit 500
114 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
115 If t, fetch all the available old headers."
117 :type '(choice number
118 (sexp :menu-tag "other" t)))
120 (defcustom gnus-summary-make-false-root 'adopt
121 "*nil means that Gnus won't gather loose threads.
122 If the root of a thread has expired or been read in a previous
123 session, the information necessary to build a complete thread has been
124 lost. Instead of having many small sub-threads from this original thread
125 scattered all over the summary buffer, Gnus can gather them.
127 If non-nil, Gnus will try to gather all loose sub-threads from an
128 original thread into one large thread.
130 If this variable is non-nil, it should be one of `none', `adopt',
133 If this variable is `none', Gnus will not make a false root, but just
134 present the sub-threads after another.
135 If this variable is `dummy', Gnus will create a dummy root that will
136 have all the sub-threads as children.
137 If this variable is `adopt', Gnus will make one of the \"children\"
138 the parent and mark all the step-children as such.
139 If this variable is `empty', the \"children\" are printed with empty
140 subject fields. (Or rather, they will be printed with a string
141 given by the `gnus-summary-same-subject' variable.)"
143 :type '(choice (const :tag "off" nil)
149 (defcustom gnus-summary-make-false-root-always nil
150 "Always make a false dummy root."
155 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
156 "*A regexp to match subjects to be excluded from loose thread gathering.
157 As loose thread gathering is done on subjects only, that means that
158 there can be many false gatherings performed. By rooting out certain
159 common subjects, gathering might become saner."
163 (defcustom gnus-summary-gather-subject-limit nil
164 "*Maximum length of subject comparisons when gathering loose threads.
165 Use nil to compare full subjects. Setting this variable to a low
166 number will help gather threads that have been corrupted by
167 newsreaders chopping off subject lines, but it might also mean that
168 unrelated articles that have subject that happen to begin with the
169 same few characters will be incorrectly gathered.
171 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
174 :type '(choice (const :tag "off" nil)
176 (sexp :menu-tag "on" t)))
178 (defcustom gnus-simplify-subject-functions nil
179 "List of functions taking a string argument that simplify subjects.
180 The functions are applied recursively.
182 Useful functions to put in this list include:
183 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
184 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
186 :type '(repeat function))
188 (defcustom gnus-simplify-ignored-prefixes nil
189 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
191 :type '(choice (const :tag "off" nil)
194 (defcustom gnus-build-sparse-threads nil
195 "*If non-nil, fill in the gaps in threads.
196 If `some', only fill in the gaps that are needed to tie loose threads
197 together. If `more', fill in all leaf nodes that Gnus can find. If
198 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
200 :type '(choice (const :tag "off" nil)
203 (sexp :menu-tag "all" t)))
205 (defcustom gnus-summary-thread-gathering-function
206 'gnus-gather-threads-by-subject
207 "*Function used for gathering loose threads.
208 There are two pre-defined functions: `gnus-gather-threads-by-subject',
209 which only takes Subjects into consideration; and
210 `gnus-gather-threads-by-references', which compared the References
211 headers of the articles to find matches."
213 :type '(radio (function-item gnus-gather-threads-by-subject)
214 (function-item gnus-gather-threads-by-references)
215 (function :tag "other")))
217 (defcustom gnus-summary-same-subject ""
218 "*String indicating that the current article has the same subject as the previous.
219 This variable will only be used if the value of
220 `gnus-summary-make-false-root' is `empty'."
221 :group 'gnus-summary-format
224 (defcustom gnus-summary-goto-unread nil
225 "*If t, many commands will go to the next unread article.
226 This applies to marking commands as well as other commands that
227 \"naturally\" select the next article, like, for instance, `SPC' at
228 the end of an article.
230 If nil, the marking commands do NOT go to the next unread article
231 \(they go to the next article instead). If `never', commands that
232 usually go to the next unread article, will go to the next article,
233 whether it is read or not."
235 :group 'gnus-summary-marks
236 :link '(custom-manual "(gnus)Setting Marks")
237 :type '(choice (const :tag "off" nil)
239 (sexp :menu-tag "on" t)))
241 (defcustom gnus-summary-default-score 0
242 "*Default article score level.
243 All scores generated by the score files will be added to this score.
244 If this variable is nil, scoring will be disabled."
245 :group 'gnus-score-default
246 :type '(choice (const :tag "disable")
249 (defcustom gnus-summary-default-high-score 0
250 "*Default threshold for a high scored article.
251 An article will be highlighted as high scored if its score is greater
254 :group 'gnus-score-default
257 (defcustom gnus-summary-default-low-score 0
258 "*Default threshold for a low scored article.
259 An article will be highlighted as low scored if its score is smaller
262 :group 'gnus-score-default
265 (defcustom gnus-summary-zcore-fuzz 0
266 "*Fuzziness factor for the zcore in the summary buffer.
267 Articles with scores closer than this to `gnus-summary-default-score'
269 :group 'gnus-summary-format
272 (defcustom gnus-simplify-subject-fuzzy-regexp nil
273 "*Strings to be removed when doing fuzzy matches.
274 This can either be a regular expression or list of regular expressions
275 that will be removed from subject strings if fuzzy subject
276 simplification is selected."
278 :type '(repeat regexp))
280 (defcustom gnus-show-threads t
281 "*If non-nil, display threads in summary mode."
285 (defcustom gnus-thread-hide-subtree nil
286 "*If non-nil, hide all threads initially.
287 This can be a predicate specifier which says which threads to hide.
288 If threads are hidden, you have to run the command
289 `gnus-summary-show-thread' by hand or select an article."
291 :type '(radio (sexp :format "Non-nil\n"
292 :match (lambda (widget value)
293 (not (or (consp value) (functionp value))))
296 (sexp :tag "Predicate specifier")))
298 (defcustom gnus-thread-hide-killed t
299 "*If non-nil, hide killed threads automatically."
303 (defcustom gnus-thread-ignore-subject t
304 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
305 If nil, articles that have different subjects from their parents will
306 start separate threads."
310 (defcustom gnus-thread-operation-ignore-subject t
311 "*If non-nil, subjects will be ignored when doing thread commands.
312 This affects commands like `gnus-summary-kill-thread' and
313 `gnus-summary-lower-thread'.
315 If this variable is nil, articles in the same thread with different
316 subjects will not be included in the operation in question. If this
317 variable is `fuzzy', only articles that have subjects that are fuzzily
318 equal will be included."
320 :type '(choice (const :tag "off" nil)
324 (defcustom gnus-thread-indent-level 4
325 "*Number that says how much each sub-thread should be indented."
329 (defcustom gnus-auto-extend-newsgroup t
330 "*If non-nil, extend newsgroup forward and backward when requested."
331 :group 'gnus-summary-choose
334 (defcustom gnus-auto-select-first t
335 "If non-nil, select an article on group entry.
336 An article is selected automatically when entering a group
337 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
338 `gnus-summary-catchup-and-goto-next-group'.
340 Which article is selected is controlled by the variable
341 `gnus-auto-select-subject'.
343 If you want to prevent automatic selection of articles in some
344 newsgroups, set the variable to nil in `gnus-select-group-hook'."
345 ;; Commands include...
346 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
347 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
349 :group 'gnus-group-select
350 :type '(choice (const :tag "none" nil)
351 (sexp :menu-tag "first" t)))
353 (defcustom gnus-auto-select-subject 'unseen-or-unread
354 "*Says what subject to place under point when entering a group.
356 This variable can either be the symbols `first' (place point on the
357 first subject), `unread' (place point on the subject line of the first
358 unread article), `best' (place point on the subject line of the
359 higest-scored article), `unseen' (place point on the subject line of
360 the first unseen article), `unseen-or-unread' (place point on the subject
361 line of the first unseen article or, if all article have been seen, on the
362 subject line of the first unread article), or a function to be called to
363 place point on some subject line."
365 :group 'gnus-group-select
366 :type '(choice (const best)
370 (const unseen-or-unread)))
372 (defcustom gnus-auto-select-next t
373 "*If non-nil, offer to go to the next group from the end of the previous.
374 If the value is t and the next newsgroup is empty, Gnus will exit
375 summary mode and go back to group mode. If the value is neither nil
376 nor t, Gnus will select the following unread newsgroup. In
377 particular, if the value is the symbol `quietly', the next unread
378 newsgroup will be selected without any confirmation, and if it is
379 `almost-quietly', the next group will be selected without any
380 confirmation if you are located on the last article in the group.
381 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
382 will go to the next group without confirmation."
383 :group 'gnus-summary-maneuvering
384 :type '(choice (const :tag "off" nil)
386 (const almost-quietly)
387 (const slightly-quietly)
388 (sexp :menu-tag "on" t)))
390 (defcustom gnus-auto-select-same nil
391 "*If non-nil, select the next article with the same subject.
392 If there are no more articles with the same subject, go to
393 the first unread article."
394 :group 'gnus-summary-maneuvering
397 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
398 "What article should be selected after exiting an ephemeral group.
399 Valid values include:
402 Select the next article.
404 Select the next unread article.
406 Move the cursor to the next article. This is the default.
407 `next-unread-noselect'
408 Move the cursor to the next unread article.
410 If it has any other value or there is no next (unread) article, the
411 article selected before entering to the ephemeral group will appear."
412 :version "23.1" ;; No Gnus
413 :group 'gnus-summary-maneuvering
414 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
415 (const next) (const next-unread)
416 (const next-noselect) (const next-unread-noselect)
417 (sexp :tag "other" :value nil)))
419 (defcustom gnus-auto-goto-ignores 'unfetched
420 "*Says how to handle unfetched articles when maneuvering.
422 This variable can either be the symbols nil (maneuver to any
423 article), `undownloaded' (maneuvering while unplugged ignores articles
424 that have not been fetched), `always-undownloaded' (maneuvering always
425 ignores articles that have not been fetched), `unfetched' (maneuvering
426 ignores articles whose headers have not been fetched).
428 NOTE: The list of unfetched articles will always be nil when plugged
429 and, when unplugged, a subset of the undownloaded article list."
431 :group 'gnus-summary-maneuvering
432 :type '(choice (const :tag "None" nil)
433 (const :tag "Undownloaded when unplugged" undownloaded)
434 (const :tag "Undownloaded" always-undownloaded)
435 (const :tag "Unfetched" unfetched)))
437 (defcustom gnus-summary-check-current nil
438 "*If non-nil, consider the current article when moving.
439 The \"unread\" movement commands will stay on the same line if the
440 current article is unread."
441 :group 'gnus-summary-maneuvering
444 (defcustom gnus-auto-center-summary 2
445 "*If non-nil, always center the current summary buffer.
446 In particular, if `vertical' do only vertical recentering. If non-nil
447 and non-`vertical', do both horizontal and vertical recentering."
448 :group 'gnus-summary-maneuvering
449 :type '(choice (const :tag "none" nil)
451 (integer :tag "height")
452 (sexp :menu-tag "both" t)))
454 (defvar gnus-auto-center-group t
455 "*If non-nil, always center the group buffer.")
457 (defcustom gnus-show-all-headers nil
458 "*If non-nil, don't hide any headers."
459 :group 'gnus-article-hiding
460 :group 'gnus-article-headers
463 (defcustom gnus-summary-ignore-duplicates nil
464 "*If non-nil, ignore articles with identical Message-ID headers."
468 (defcustom gnus-single-article-buffer nil
469 "*If non-nil, display all articles in the same buffer.
470 If nil, each group will get its own article buffer."
472 :group 'gnus-article-various
475 (defcustom gnus-break-pages t
476 "*If non-nil, do page breaking on articles.
477 The page delimiter is specified by the `gnus-page-delimiter'
479 :group 'gnus-article-various
482 (defcustom gnus-move-split-methods nil
483 "*Variable used to suggest where articles are to be moved to.
484 It uses the same syntax as the `gnus-split-methods' variable.
485 However, whereas `gnus-split-methods' specifies file names as targets,
486 this variable specifies group names."
487 :group 'gnus-summary-mail
488 :type '(repeat (choice (list :value (fun) function)
489 (cons :value ("" "") regexp (repeat string))
492 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
493 "Function used to compute default prefix for article move/copy/etc prompts.
494 The function should take one argument, a group name, and return a
495 string with the suggested prefix."
496 :group 'gnus-summary-mail
499 ;; FIXME: Although the custom type is `character' for the following variables,
500 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
502 (defcustom gnus-unread-mark ? ;Whitespace
503 "*Mark used for unread articles."
504 :group 'gnus-summary-marks
507 (defcustom gnus-ticked-mark ?!
508 "*Mark used for ticked articles."
509 :group 'gnus-summary-marks
512 (defcustom gnus-dormant-mark ??
513 "*Mark used for dormant articles."
514 :group 'gnus-summary-marks
517 (defcustom gnus-del-mark ?r
518 "*Mark used for del'd articles."
519 :group 'gnus-summary-marks
522 (defcustom gnus-read-mark ?R
523 "*Mark used for read articles."
524 :group 'gnus-summary-marks
527 (defcustom gnus-expirable-mark ?E
528 "*Mark used for expirable articles."
529 :group 'gnus-summary-marks
532 (defcustom gnus-killed-mark ?K
533 "*Mark used for killed articles."
534 :group 'gnus-summary-marks
537 (defcustom gnus-spam-mark ?$
538 "*Mark used for spam articles."
540 :group 'gnus-summary-marks
543 (defcustom gnus-kill-file-mark ?X
544 "*Mark used for articles killed by kill files."
545 :group 'gnus-summary-marks
548 (defcustom gnus-low-score-mark ?Y
549 "*Mark used for articles with a low score."
550 :group 'gnus-summary-marks
553 (defcustom gnus-catchup-mark ?C
554 "*Mark used for articles that are caught up."
555 :group 'gnus-summary-marks
558 (defcustom gnus-replied-mark ?A
559 "*Mark used for articles that have been replied to."
560 :group 'gnus-summary-marks
563 (defcustom gnus-forwarded-mark ?F
564 "*Mark used for articles that have been forwarded."
566 :group 'gnus-summary-marks
569 (defcustom gnus-recent-mark ?N
570 "*Mark used for articles that are recent."
572 :group 'gnus-summary-marks
575 (defcustom gnus-cached-mark ?*
576 "*Mark used for articles that are in the cache."
577 :group 'gnus-summary-marks
580 (defcustom gnus-saved-mark ?S
581 "*Mark used for articles that have been saved."
582 :group 'gnus-summary-marks
585 (defcustom gnus-unseen-mark ?.
586 "*Mark used for articles that haven't been seen."
588 :group 'gnus-summary-marks
591 (defcustom gnus-no-mark ? ;Whitespace
592 "*Mark used for articles that have no other secondary mark."
594 :group 'gnus-summary-marks
597 (defcustom gnus-ancient-mark ?O
598 "*Mark used for ancient articles."
599 :group 'gnus-summary-marks
602 (defcustom gnus-sparse-mark ?Q
603 "*Mark used for sparsely reffed articles."
604 :group 'gnus-summary-marks
607 (defcustom gnus-canceled-mark ?G
608 "*Mark used for canceled articles."
609 :group 'gnus-summary-marks
612 (defcustom gnus-duplicate-mark ?M
613 "*Mark used for duplicate articles."
614 :group 'gnus-summary-marks
617 (defcustom gnus-undownloaded-mark ?-
618 "*Mark used for articles that weren't downloaded."
620 :group 'gnus-summary-marks
623 (defcustom gnus-downloaded-mark ?+
624 "*Mark used for articles that were downloaded."
625 :group 'gnus-summary-marks
628 (defcustom gnus-downloadable-mark ?%
629 "*Mark used for articles that are to be downloaded."
630 :group 'gnus-summary-marks
633 (defcustom gnus-unsendable-mark ?=
634 "*Mark used for articles that won't be sent."
635 :group 'gnus-summary-marks
638 (defcustom gnus-score-over-mark ?+
639 "*Score mark used for articles with high scores."
640 :group 'gnus-summary-marks
643 (defcustom gnus-score-below-mark ?-
644 "*Score mark used for articles with low scores."
645 :group 'gnus-summary-marks
648 (defcustom gnus-empty-thread-mark ? ;Whitespace
649 "*There is no thread under the article."
650 :group 'gnus-summary-marks
653 (defcustom gnus-not-empty-thread-mark ?=
654 "*There is a thread under the article."
655 :group 'gnus-summary-marks
658 (defcustom gnus-view-pseudo-asynchronously nil
659 "*If non-nil, Gnus will view pseudo-articles asynchronously."
660 :group 'gnus-extract-view
663 (defcustom gnus-auto-expirable-marks
664 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
665 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
667 "*The list of marks converted into expiration if a group is auto-expirable."
670 :type '(repeat character))
672 (defcustom gnus-inhibit-user-auto-expire t
673 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
678 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
679 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
680 If nil, the expirable marks will be unchanged except that the marks
681 will be removed when copying or moving articles to a group that has
682 not turned auto-expire on. If non-nil, articles that have been read
683 will be marked as expirable when being copied or moved to a group in
684 which auto-expire is turned on."
687 :group 'gnus-summary-marks)
689 (defcustom gnus-view-pseudos nil
690 "*If `automatic', pseudo-articles will be viewed automatically.
691 If `not-confirm', pseudos will be viewed automatically, and the user
692 will not be asked to confirm the command."
693 :group 'gnus-extract-view
694 :type '(choice (const :tag "off" nil)
696 (const not-confirm)))
698 (defcustom gnus-view-pseudos-separately t
699 "*If non-nil, one pseudo-article will be created for each file to be viewed.
700 If nil, all files that use the same viewing command will be given as a
701 list of parameters to that command."
702 :group 'gnus-extract-view
705 (defcustom gnus-insert-pseudo-articles t
706 "*If non-nil, insert pseudo-articles when decoding articles."
707 :group 'gnus-extract-view
710 (defcustom gnus-summary-dummy-line-format
712 "*The format specification for the dummy roots in the summary buffer.
713 It works along the same lines as a normal formatting string,
714 with some simple extensions.
718 General format specifiers can also be used.
719 See `(gnus)Formatting Variables'."
720 :link '(custom-manual "(gnus)Formatting Variables")
721 :group 'gnus-threading
724 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
725 "*The format specification for the summary mode line.
726 It works along the same lines as a normal formatting string,
727 with some simple extensions:
730 %p Unprefixed group name
731 %A Current article number
732 %z Current article score
734 %U Number of unread articles in the group
735 %e Number of unselected articles in the group
736 %Z A string with unread/unselected article counts
737 %g Shortish group name
738 %S Subject of the current article
740 %s Current score file name
741 %d Number of dormant articles
742 %r Number of articles that have been marked as read in this session
743 %E Number of articles expunged by the score files"
744 :group 'gnus-summary-format
747 (defcustom gnus-list-identifiers nil
748 "Regexp that matches list identifiers to be removed from subject.
749 This can also be a list of regexps."
751 :group 'gnus-summary-format
752 :group 'gnus-article-hiding
753 :type '(choice (const :tag "none" nil)
755 (repeat :value (".*") regexp)))
757 (defcustom gnus-summary-mark-below 0
758 "*Mark all articles with a score below this variable as read.
759 This variable is local to each summary buffer and usually set by the
761 :group 'gnus-score-default
764 (defun gnus-widget-reversible-match (widget value)
765 "Ignoring WIDGET, convert VALUE to internal form.
766 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
770 (eq (length value) 2)
771 (eq (nth 0 value) 'not)
772 (symbolp (nth 1 value)))))
774 (defun gnus-widget-reversible-to-internal (widget value)
775 "Ignoring WIDGET, convert VALUE to internal form.
776 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
777 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
781 (list (nth 1 value) t)))
783 (defun gnus-widget-reversible-to-external (widget value)
784 "Ignoring WIDGET, convert VALUE to external form.
785 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
786 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
789 (list 'not (nth 0 value))
792 (define-widget 'gnus-widget-reversible 'group
793 "A `group' that convert values."
794 :match 'gnus-widget-reversible-match
795 :value-to-internal 'gnus-widget-reversible-to-internal
796 :value-to-external 'gnus-widget-reversible-to-external)
798 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
799 "*List of functions used for sorting articles in the summary buffer.
801 Each function takes two articles and returns non-nil if the first
802 article should be sorted before the other. If you use more than one
803 function, the primary sort function should be the last. You should
804 probably always include `gnus-article-sort-by-number' in the list of
805 sorting functions -- preferably first. Also note that sorting by date
806 is often much slower than sorting by number, and the sorting order is
807 very similar. (Sorting by date means sorting by the time the message
808 was sent, sorting by number means sorting by arrival time.)
810 Each item can also be a list `(not F)' where F is a function;
811 this reverses the sort order.
813 Ready-made functions include `gnus-article-sort-by-number',
814 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
815 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
816 and `gnus-article-sort-by-score'.
818 When threading is turned on, the variable `gnus-thread-sort-functions'
819 controls how articles are sorted."
820 :group 'gnus-summary-sort
821 :type '(repeat (gnus-widget-reversible
822 (choice (function-item gnus-article-sort-by-number)
823 (function-item gnus-article-sort-by-author)
824 (function-item gnus-article-sort-by-subject)
825 (function-item gnus-article-sort-by-date)
826 (function-item gnus-article-sort-by-score)
827 (function-item gnus-article-sort-by-random)
828 (function :tag "other"))
829 (boolean :tag "Reverse order"))))
832 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
833 "*List of functions used for sorting threads in the summary buffer.
834 By default, threads are sorted by article number.
836 Each function takes two threads and returns non-nil if the first
837 thread should be sorted before the other. If you use more than one
838 function, the primary sort function should be the last. You should
839 probably always include `gnus-thread-sort-by-number' in the list of
840 sorting functions -- preferably first. Also note that sorting by date
841 is often much slower than sorting by number, and the sorting order is
842 very similar. (Sorting by date means sorting by the time the message
843 was sent, sorting by number means sorting by arrival time.)
845 Each list item can also be a list `(not F)' where F is a
846 function; this specifies reversed sort order.
848 Ready-made functions include `gnus-thread-sort-by-number',
849 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
850 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
851 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
852 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
853 and `gnus-thread-sort-by-total-score' (see
854 `gnus-thread-score-function').
856 When threading is turned off, the variable
857 `gnus-article-sort-functions' controls how articles are sorted."
858 :group 'gnus-summary-sort
860 (gnus-widget-reversible
861 (choice (function-item gnus-thread-sort-by-number)
862 (function-item gnus-thread-sort-by-author)
863 (function-item gnus-thread-sort-by-recipient)
864 (function-item gnus-thread-sort-by-subject)
865 (function-item gnus-thread-sort-by-date)
866 (function-item gnus-thread-sort-by-score)
867 (function-item gnus-thread-sort-by-most-recent-number)
868 (function-item gnus-thread-sort-by-most-recent-date)
869 (function-item gnus-thread-sort-by-random)
870 (function-item gnus-thread-sort-by-total-score)
871 (function :tag "other"))
872 (boolean :tag "Reverse order"))))
874 (defcustom gnus-thread-score-function '+
875 "*Function used for calculating the total score of a thread.
877 The function is called with the scores of the article and each
878 subthread and should then return the score of the thread.
880 Some functions you can use are `+', `max', or `min'."
881 :group 'gnus-summary-sort
884 (defcustom gnus-summary-expunge-below nil
885 "All articles that have a score less than this variable will be expunged.
886 This variable is local to the summary buffers."
887 :group 'gnus-score-default
888 :type '(choice (const :tag "off" nil)
891 (defcustom gnus-thread-expunge-below nil
892 "All threads that have a total score less than this variable will be expunged.
893 See `gnus-thread-score-function' for en explanation of what a
896 This variable is local to the summary buffers."
897 :group 'gnus-threading
898 :group 'gnus-score-default
899 :type '(choice (const :tag "off" nil)
902 (defcustom gnus-summary-mode-hook nil
903 "*A hook for Gnus summary mode.
904 This hook is run before any variables are set in the summary buffer."
905 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
906 :group 'gnus-summary-various
909 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
910 (when (featurep 'xemacs)
911 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
912 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
913 (add-hook 'gnus-summary-mode-hook
914 'gnus-xmas-switch-horizontal-scrollbar-off))
916 (defcustom gnus-summary-menu-hook nil
917 "*Hook run after the creation of the summary mode menu."
918 :group 'gnus-summary-visual
921 (defcustom gnus-summary-exit-hook nil
922 "*A hook called on exit from the summary buffer.
923 It will be called with point in the group buffer."
924 :group 'gnus-summary-exit
927 (defcustom gnus-summary-prepare-hook nil
928 "*A hook called after the summary buffer has been generated.
929 If you want to modify the summary buffer, you can use this hook."
930 :group 'gnus-summary-various
933 (defcustom gnus-summary-prepared-hook nil
934 "*A hook called as the last thing after the summary buffer has been generated."
935 :group 'gnus-summary-various
938 (defcustom gnus-summary-generate-hook nil
939 "*A hook run just before generating the summary buffer.
940 This hook is commonly used to customize threading variables and the
942 :group 'gnus-summary-various
945 (defcustom gnus-select-group-hook nil
946 "*A hook called when a newsgroup is selected.
948 If you'd like to simplify subjects like the
949 `gnus-summary-next-same-subject' command does, you can use the
952 (add-hook gnus-select-group-hook
954 (mapcar (lambda (header)
955 (mail-header-set-subject
957 (gnus-simplify-subject
958 (mail-header-subject header) 're-only)))
959 gnus-newsgroup-headers)))"
960 :group 'gnus-group-select
963 (defcustom gnus-select-article-hook nil
964 "*A hook called when an article is selected."
965 :group 'gnus-summary-choose
966 :options '(gnus-agent-fetch-selected-article)
969 (defcustom gnus-visual-mark-article-hook
970 (list 'gnus-highlight-selected-summary)
971 "*Hook run after selecting an article in the summary buffer.
972 It is meant to be used for highlighting the article in some way. It
973 is not run if `gnus-visual' is nil."
974 :group 'gnus-summary-visual
977 (defcustom gnus-parse-headers-hook nil
978 "*A hook called before parsing the headers."
982 (defcustom gnus-exit-group-hook nil
983 "*A hook called when exiting summary mode.
984 This hook is not called from the non-updating exit commands like `Q'."
988 (defcustom gnus-summary-update-hook nil
989 "*A hook called when a summary line is changed.
990 The hook will not be called if `gnus-visual' is nil.
992 The default function `gnus-summary-highlight-line' will
993 highlight the line according to the `gnus-summary-highlight'
995 :group 'gnus-summary-visual
998 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
999 "*A hook called when an article is selected for the first time.
1000 The hook is intended to mark an article as read (or unread)
1001 automatically when it is selected."
1002 :group 'gnus-summary-choose
1005 (defcustom gnus-group-no-more-groups-hook nil
1006 "*A hook run when returning to group mode having no more (unread) groups."
1007 :group 'gnus-group-select
1010 (defcustom gnus-ps-print-hook nil
1011 "*A hook run before ps-printing something from Gnus."
1012 :group 'gnus-summary
1015 (defcustom gnus-summary-article-move-hook nil
1016 "*A hook called after an article is moved, copied, respooled, or crossposted."
1018 :group 'gnus-summary
1021 (defcustom gnus-summary-article-delete-hook nil
1022 "*A hook called after an article is deleted."
1024 :group 'gnus-summary
1027 (defcustom gnus-summary-article-expire-hook nil
1028 "*A hook called after an article is expired."
1030 :group 'gnus-summary
1033 (defcustom gnus-summary-display-arrow
1034 (and (fboundp 'display-graphic-p)
1035 (display-graphic-p))
1036 "*If non-nil, display an arrow highlighting the current article."
1038 :group 'gnus-summary
1041 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1042 "Face used for highlighting the current article in the summary buffer."
1043 :group 'gnus-summary-visual
1046 (defvar gnus-tmp-downloaded nil)
1048 (defcustom gnus-summary-highlight
1049 '(((eq mark gnus-canceled-mark)
1050 . gnus-summary-cancelled)
1051 ((and uncached (> score default-high))
1052 . gnus-summary-high-undownloaded)
1053 ((and uncached (< score default-low))
1054 . gnus-summary-low-undownloaded)
1056 . gnus-summary-normal-undownloaded)
1057 ((and (> score default-high)
1058 (or (eq mark gnus-dormant-mark)
1059 (eq mark gnus-ticked-mark)))
1060 . gnus-summary-high-ticked)
1061 ((and (< score default-low)
1062 (or (eq mark gnus-dormant-mark)
1063 (eq mark gnus-ticked-mark)))
1064 . gnus-summary-low-ticked)
1065 ((or (eq mark gnus-dormant-mark)
1066 (eq mark gnus-ticked-mark))
1067 . gnus-summary-normal-ticked)
1068 ((and (> score default-high) (eq mark gnus-ancient-mark))
1069 . gnus-summary-high-ancient)
1070 ((and (< score default-low) (eq mark gnus-ancient-mark))
1071 . gnus-summary-low-ancient)
1072 ((eq mark gnus-ancient-mark)
1073 . gnus-summary-normal-ancient)
1074 ((and (> score default-high) (eq mark gnus-unread-mark))
1075 . gnus-summary-high-unread)
1076 ((and (< score default-low) (eq mark gnus-unread-mark))
1077 . gnus-summary-low-unread)
1078 ((eq mark gnus-unread-mark)
1079 . gnus-summary-normal-unread)
1080 ((> score default-high)
1081 . gnus-summary-high-read)
1082 ((< score default-low)
1083 . gnus-summary-low-read)
1085 . gnus-summary-normal-read))
1086 "*Controls the highlighting of summary buffer lines.
1088 A list of (FORM . FACE) pairs. When deciding how a particular
1089 summary line should be displayed, each form is evaluated. The content
1090 of the face field after the first true form is used. You can change
1091 how those summary lines are displayed, by editing the face field.
1093 You can use the following variables in the FORM field.
1095 score: The article's score.
1096 default: The default article score.
1097 default-high: The default score for high scored articles.
1098 default-low: The default score for low scored articles.
1099 below: The score below which articles are automatically marked as read.
1100 mark: The article's mark.
1101 uncached: Non-nil if the article is uncached."
1102 :group 'gnus-summary-visual
1103 :type '(repeat (cons (sexp :tag "Form" nil)
1105 (put 'gnus-summary-highlight 'risky-local-variable t)
1107 (defcustom gnus-alter-header-function nil
1108 "Function called to allow alteration of article header structures.
1109 The function is called with one parameter, the article header vector,
1110 which it may alter in any way."
1111 :type '(choice (const :tag "None" nil)
1113 :group 'gnus-summary)
1115 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1116 "Function used to decode a string with encoded words.")
1118 (defvar gnus-decode-encoded-address-function
1119 'mail-decode-encoded-address-string
1120 "Function used to decode addresses with encoded words.")
1122 (defcustom gnus-extra-headers '(To Newsgroups)
1123 "*Extra headers to parse."
1125 :group 'gnus-summary
1126 :type '(repeat symbol))
1128 (defcustom gnus-ignored-from-addresses
1129 (and user-mail-address
1130 (not (string= user-mail-address ""))
1131 (regexp-quote user-mail-address))
1132 "*From headers that may be suppressed in favor of To headers.
1133 This can be a regexp or a list of regexps."
1135 :group 'gnus-summary
1136 :type '(choice regexp
1137 (repeat :tag "Regexp List" regexp)))
1139 (defsubst gnus-ignored-from-addresses ()
1140 (gmm-regexp-concat gnus-ignored-from-addresses))
1142 (defcustom gnus-summary-to-prefix "-> "
1143 "*String prefixed to the To field in the summary line when
1144 using `gnus-ignored-from-addresses'."
1146 :group 'gnus-summary
1149 (defcustom gnus-summary-newsgroup-prefix "=> "
1150 "*String prefixed to the Newsgroup field in the summary
1151 line when using `gnus-ignored-from-addresses'."
1153 :group 'gnus-summary
1156 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1157 "List of charsets that should be ignored.
1158 When these charsets are used in the \"charset\" parameter, the
1159 default charset will be used instead."
1161 :type '(repeat symbol)
1162 :group 'gnus-charset)
1164 (defcustom gnus-newsgroup-maximum-articles nil
1165 "The maximum number of articles a newsgroup.
1166 If this is a number, old articles in a newsgroup exceeding this number
1167 are silently ignored. If it is nil, no article is ignored. Note that
1168 setting this variable to a number might prevent you from reading very
1170 :group 'gnus-group-select
1172 :type '(choice (const :tag "No limit" nil)
1175 (gnus-define-group-parameter
1179 "Return the ignored charsets of GROUP."
1180 :variable gnus-group-ignored-charsets-alist
1182 '(("alt\\.chinese\\.text" iso-8859-1))
1184 "Alist of regexps (to match group names) and charsets that should be ignored.
1185 When these charsets are used in the \"charset\" parameter, the
1186 default charset will be used instead."
1187 :variable-group gnus-charset
1188 :variable-type '(repeat (cons (regexp :tag "Group")
1190 :parameter-type '(choice :tag "Ignored charsets"
1193 :parameter-document "\
1194 List of charsets that should be ignored.
1196 When these charsets are used in the \"charset\" parameter, the
1197 default charset will be used instead.")
1199 (defcustom gnus-group-highlight-words-alist nil
1200 "Alist of group regexps and highlight regexps.
1201 This variable uses the same syntax as `gnus-emphasis-alist'."
1203 :type '(repeat (cons (regexp :tag "Group")
1204 (repeat (list (regexp :tag "Highlight regexp")
1205 (number :tag "Group for entire word" 0)
1206 (number :tag "Group for displayed part" 0)
1208 gnus-emphasis-highlight-words)))))
1209 :group 'gnus-summary-visual)
1211 (defcustom gnus-summary-show-article-charset-alist
1213 "Alist of number and charset.
1214 The article will be shown with the charset corresponding to the
1216 For example: ((1 . cn-gb-2312) (2 . big5))."
1218 :type '(repeat (cons (number :tag "Argument" 1)
1219 (symbol :tag "Charset")))
1220 :group 'gnus-charset)
1222 (defcustom gnus-preserve-marks t
1223 "Whether marks are preserved when moving, copying and respooling messages."
1226 :group 'gnus-summary-marks)
1228 (defcustom gnus-propagate-marks t
1229 "If non-nil, do not propagate marks to the backends."
1230 :version "23.1" ;; No Gnus
1232 :group 'gnus-summary-marks)
1234 (defcustom gnus-alter-articles-to-read-function nil
1235 "Function to be called to alter the list of articles to be selected."
1236 :type '(choice (const nil) function)
1237 :group 'gnus-summary)
1239 (defcustom gnus-orphan-score nil
1240 "*All orphans get this score added. Set in the score file."
1241 :group 'gnus-score-default
1242 :type '(choice (const nil)
1245 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1246 "*A regexp to match MIME parts when saving multiple parts of a
1247 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1248 This regexp will be used by default when prompting the user for which
1249 type of files to save."
1250 :group 'gnus-summary
1253 (defcustom gnus-read-all-available-headers nil
1254 "Whether Gnus should parse all headers made available to it.
1255 This is mostly relevant for slow back ends where the user may
1256 wish to widen the summary buffer to include all headers
1259 :group 'gnus-summary
1260 :type '(choice boolean regexp))
1262 (defcustom gnus-summary-pipe-output-default-command nil
1263 "Command (and optional arguments) used to pipe article to subprocess.
1264 This will be used as the default command if it is non-nil. The value
1265 will be updated if you modify it when executing the command
1266 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1267 :version "23.1" ;; No Gnus
1268 :group 'gnus-summary
1269 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1271 (defcustom gnus-summary-muttprint-program "muttprint"
1272 "Command (and optional arguments) used to run Muttprint.
1273 The value will be updated if you modify it when executing the command
1274 `gnus-summary-muttprint'."
1276 :group 'gnus-summary
1279 (defcustom gnus-article-loose-mime t
1280 "If non-nil, don't require MIME-Version header.
1281 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1282 supply the MIME-Version header or deliberately strip it from the mail.
1283 If non-nil (the default), Gnus will treat some articles as MIME
1284 even if the MIME-Version header is missing."
1287 :group 'gnus-article-mime)
1289 (defcustom gnus-article-emulate-mime t
1290 "If non-nil, use MIME emulation for uuencode and the like.
1291 This means that Gnus will search message bodies for text that look
1292 like uuencoded bits, yEncoded bits, and so on, and present that using
1293 the normal Gnus MIME machinery."
1296 :group 'gnus-article-mime)
1298 ;;; Internal variables
1300 (defvar gnus-summary-display-cache nil)
1301 (defvar gnus-article-mime-handles nil)
1302 (defvar gnus-article-decoded-p nil)
1303 (defvar gnus-article-charset nil)
1304 (defvar gnus-article-ignored-charsets nil)
1305 (defvar gnus-scores-exclude-files nil)
1306 (defvar gnus-page-broken nil)
1308 (defvar gnus-original-article nil)
1309 (defvar gnus-article-internal-prepare-hook nil)
1310 (defvar gnus-newsgroup-process-stack nil)
1312 (defvar gnus-thread-indent-array nil)
1313 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1314 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1315 "Function called to sort the articles within a thread after it has been gathered together.")
1317 (defvar gnus-summary-save-parts-type-history nil)
1318 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1320 ;; Avoid highlighting in kill files.
1321 (defvar gnus-summary-inhibit-highlight nil)
1322 (defvar gnus-newsgroup-selected-overlay nil)
1323 (defvar gnus-inhibit-limiting nil)
1324 (defvar gnus-newsgroup-adaptive-score-file nil)
1325 (defvar gnus-current-score-file nil)
1326 (defvar gnus-current-move-group nil)
1327 (defvar gnus-current-copy-group nil)
1328 (defvar gnus-current-crosspost-group nil)
1329 (defvar gnus-newsgroup-display nil)
1331 (defvar gnus-newsgroup-dependencies nil)
1332 (defvar gnus-newsgroup-adaptive nil)
1333 (defvar gnus-summary-display-article-function nil)
1334 (defvar gnus-summary-highlight-line-function nil
1335 "Function called after highlighting a summary line.")
1337 (defvar gnus-summary-line-format-alist
1338 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1339 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1340 (?s gnus-tmp-subject-or-nil ?s)
1341 (?n gnus-tmp-name ?s)
1342 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1344 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1346 (?F gnus-tmp-from ?s)
1347 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1348 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1349 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1350 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1351 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1352 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1353 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1354 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1355 (?L gnus-tmp-lines ?s)
1356 (?O gnus-tmp-downloaded ?c)
1357 (?I gnus-tmp-indentation ?s)
1358 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1359 (?R gnus-tmp-replied ?c)
1360 (?\[ gnus-tmp-opening-bracket ?c)
1361 (?\] gnus-tmp-closing-bracket ?c)
1362 (?\> (make-string gnus-tmp-level ? ) ?s)
1363 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1364 (?i gnus-tmp-score ?d)
1365 (?z gnus-tmp-score-char ?c)
1366 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1367 (?U gnus-tmp-unread ?c)
1368 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1370 (?t (gnus-summary-number-of-articles-in-thread
1371 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1373 (?e (gnus-summary-number-of-articles-in-thread
1374 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1376 (?u gnus-tmp-user-defined ?s)
1377 (?P (gnus-pick-line-number) ?d)
1378 (?B gnus-tmp-thread-tree-header-string ?s)
1379 (user-date (gnus-user-date
1380 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1381 "An alist of format specifications that can appear in summary lines.
1382 These are paired with what variables they correspond with, along with
1383 the type of the variable (string, integer, character, etc).")
1385 (defvar gnus-summary-dummy-line-format-alist
1386 `((?S gnus-tmp-subject ?s)
1387 (?N gnus-tmp-number ?d)
1388 (?u gnus-tmp-user-defined ?s)))
1390 (defvar gnus-summary-mode-line-format-alist
1391 `((?G gnus-tmp-group-name ?s)
1392 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1393 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1394 (?A gnus-tmp-article-number ?d)
1395 (?Z gnus-tmp-unread-and-unselected ?s)
1396 (?V gnus-version ?s)
1397 (?U gnus-tmp-unread-and-unticked ?d)
1398 (?S gnus-tmp-subject ?s)
1399 (?e gnus-tmp-unselected ?d)
1400 (?u gnus-tmp-user-defined ?s)
1401 (?d (length gnus-newsgroup-dormant) ?d)
1402 (?t (length gnus-newsgroup-marked) ?d)
1403 (?h (length gnus-newsgroup-spam-marked) ?d)
1404 (?r (length gnus-newsgroup-reads) ?d)
1405 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1406 (?E gnus-newsgroup-expunged-tally ?d)
1407 (?s (gnus-current-score-file-nondirectory) ?s)))
1409 ;; This is here rather than in gnus-art for compilation reasons.
1410 (defvar gnus-article-mode-line-format-alist
1411 (nconc '((?w (gnus-article-wash-status) ?s)
1412 (?m (gnus-article-mime-part-status) ?s))
1413 gnus-summary-mode-line-format-alist))
1415 (defvar gnus-last-search-regexp nil
1416 "Default regexp for article search command.")
1418 (defvar gnus-last-shell-command nil
1419 "Default shell command on article.")
1421 (defvar gnus-newsgroup-agentized nil
1422 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1423 (defvar gnus-newsgroup-begin nil)
1424 (defvar gnus-newsgroup-end nil)
1425 (defvar gnus-newsgroup-last-rmail nil)
1426 (defvar gnus-newsgroup-last-mail nil)
1427 (defvar gnus-newsgroup-last-folder nil)
1428 (defvar gnus-newsgroup-last-file nil)
1429 (defvar gnus-newsgroup-last-directory nil)
1430 (defvar gnus-newsgroup-auto-expire nil)
1431 (defvar gnus-newsgroup-active nil)
1433 (defvar gnus-newsgroup-data nil)
1434 (defvar gnus-newsgroup-data-reverse nil)
1435 (defvar gnus-newsgroup-limit nil)
1436 (defvar gnus-newsgroup-limits nil)
1437 (defvar gnus-summary-use-undownloaded-faces nil)
1439 (defvar gnus-newsgroup-unreads nil
1440 "Sorted list of unread articles in the current newsgroup.")
1442 (defvar gnus-newsgroup-unselected nil
1443 "Sorted list of unselected unread articles in the current newsgroup.")
1445 (defvar gnus-newsgroup-reads nil
1446 "Alist of read articles and article marks in the current newsgroup.")
1448 (defvar gnus-newsgroup-expunged-tally nil)
1450 (defvar gnus-newsgroup-marked nil
1451 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1453 (defvar gnus-newsgroup-spam-marked nil
1454 "List of ranges of articles that have been marked as spam.")
1456 (defvar gnus-newsgroup-killed nil
1457 "List of ranges of articles that have been through the scoring process.")
1459 (defvar gnus-newsgroup-cached nil
1460 "Sorted list of articles that come from the article cache.")
1462 (defvar gnus-newsgroup-saved nil
1463 "List of articles that have been saved.")
1465 (defvar gnus-newsgroup-kill-headers nil)
1467 (defvar gnus-newsgroup-replied nil
1468 "List of articles that have been replied to in the current newsgroup.")
1470 (defvar gnus-newsgroup-forwarded nil
1471 "List of articles that have been forwarded in the current newsgroup.")
1473 (defvar gnus-newsgroup-recent nil
1474 "List of articles that have are recent in the current newsgroup.")
1476 (defvar gnus-newsgroup-expirable nil
1477 "Sorted list of articles in the current newsgroup that can be expired.")
1479 (defvar gnus-newsgroup-processable nil
1480 "List of articles in the current newsgroup that can be processed.")
1482 (defvar gnus-newsgroup-downloadable nil
1483 "Sorted list of articles in the current newsgroup that can be processed.")
1485 (defvar gnus-newsgroup-unfetched nil
1486 "Sorted list of articles in the current newsgroup whose headers have
1487 not been fetched into the agent.
1489 This list will always be a subset of gnus-newsgroup-undownloaded.")
1491 (defvar gnus-newsgroup-undownloaded nil
1492 "List of articles in the current newsgroup that haven't been downloaded.")
1494 (defvar gnus-newsgroup-unsendable nil
1495 "List of articles in the current newsgroup that won't be sent.")
1497 (defvar gnus-newsgroup-bookmarks nil
1498 "List of articles in the current newsgroup that have bookmarks.")
1500 (defvar gnus-newsgroup-dormant nil
1501 "Sorted list of dormant articles in the current newsgroup.")
1503 (defvar gnus-newsgroup-unseen nil
1504 "List of unseen articles in the current newsgroup.")
1506 (defvar gnus-newsgroup-seen nil
1507 "Range of seen articles in the current newsgroup.")
1509 (defvar gnus-newsgroup-articles nil
1510 "List of articles in the current newsgroup.")
1512 (defvar gnus-newsgroup-scored nil
1513 "List of scored articles in the current newsgroup.")
1515 (defvar gnus-newsgroup-headers nil
1516 "List of article headers in the current newsgroup.")
1518 (defvar gnus-newsgroup-threads nil)
1520 (defvar gnus-newsgroup-prepared nil
1521 "Whether the current group has been prepared properly.")
1523 (defvar gnus-newsgroup-ancient nil
1524 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1526 (defvar gnus-newsgroup-sparse nil)
1528 (defvar gnus-current-article nil)
1529 (defvar gnus-article-current nil)
1530 (defvar gnus-current-headers nil)
1531 (defvar gnus-have-all-headers nil)
1532 (defvar gnus-last-article nil)
1533 (defvar gnus-newsgroup-history nil)
1534 (defvar gnus-newsgroup-charset nil)
1535 (defvar gnus-newsgroup-ephemeral-charset nil)
1536 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1538 (defvar gnus-article-before-search nil)
1540 (defvar gnus-summary-local-variables
1541 '(gnus-newsgroup-name
1544 gnus-newsgroup-unreads
1545 gnus-newsgroup-unselected
1546 gnus-newsgroup-marked
1547 gnus-newsgroup-spam-marked
1548 gnus-newsgroup-reads
1549 gnus-newsgroup-saved
1550 gnus-newsgroup-replied
1551 gnus-newsgroup-forwarded
1552 gnus-newsgroup-recent
1553 gnus-newsgroup-expirable
1554 gnus-newsgroup-killed
1555 gnus-newsgroup-unseen
1557 gnus-newsgroup-cached
1558 gnus-newsgroup-downloadable
1559 gnus-newsgroup-undownloaded
1560 gnus-newsgroup-unsendable
1562 gnus-newsgroup-begin gnus-newsgroup-end
1563 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1564 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1565 gnus-newsgroup-last-directory
1566 gnus-newsgroup-auto-expire
1567 gnus-newsgroup-processable
1568 gnus-newsgroup-unfetched
1569 gnus-newsgroup-articles
1570 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1571 gnus-newsgroup-headers gnus-newsgroup-threads
1572 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1573 gnus-current-article gnus-current-headers gnus-have-all-headers
1574 gnus-last-article gnus-article-internal-prepare-hook
1575 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1576 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1577 gnus-thread-expunge-below
1578 gnus-score-alist gnus-current-score-file
1579 (gnus-summary-expunge-below . global)
1580 (gnus-summary-mark-below . global)
1581 (gnus-orphan-score . global)
1582 gnus-newsgroup-active gnus-scores-exclude-files
1583 gnus-newsgroup-history gnus-newsgroup-ancient
1584 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1585 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1586 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1587 (gnus-newsgroup-expunged-tally . 0)
1588 gnus-cache-removable-articles
1589 gnus-newsgroup-data gnus-newsgroup-data-reverse
1590 gnus-newsgroup-limit gnus-newsgroup-limits
1591 gnus-newsgroup-charset gnus-newsgroup-display
1592 gnus-summary-use-undownloaded-faces)
1593 "Variables that are buffer-local to the summary buffers.")
1595 (defvar gnus-newsgroup-variables nil
1596 "A list of variables that have separate values in different newsgroups.
1597 A list of newsgroup (summary buffer) local variables, or cons of
1598 variables and their default expressions to be evalled (when the default
1599 values are not nil), that should be made global while the summary buffer
1602 Note: The default expressions will be evaluated (using function `eval')
1603 before assignment to the local variable rather than just assigned to it.
1604 If the default expression is the symbol `global', that symbol will not
1605 be evaluated but the global value of the local variable will be used
1608 These variables can be used to set variables in the group parameters
1609 while still allowing them to affect operations done in other buffers.
1612 \(setq gnus-newsgroup-variables
1613 '(message-use-followup-to
1614 (gnus-visible-headers .
1615 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1619 ;; Bind features so that require will believe that gnus-sum has
1620 ;; already been loaded (avoids infinite recursion)
1621 (let ((features (cons 'gnus-sum features)))
1622 (require 'gnus-art)))
1626 (defvar gnus-decode-encoded-word-methods
1627 '(mail-decode-encoded-word-string)
1628 "List of methods used to decode encoded words.
1630 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1631 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1632 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1633 whose names match REGEXP.
1636 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1637 mail-decode-encoded-word-string
1638 (\"chinese\" . rfc1843-decode-string))")
1640 (defvar gnus-decode-encoded-word-methods-cache nil)
1642 (defun gnus-multi-decode-encoded-word-string (string)
1643 "Apply the functions from `gnus-encoded-word-methods' that match."
1644 (unless (and gnus-decode-encoded-word-methods-cache
1645 (eq gnus-newsgroup-name
1646 (car gnus-decode-encoded-word-methods-cache)))
1647 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1648 (dolist (method gnus-decode-encoded-word-methods)
1649 (if (symbolp method)
1650 (nconc gnus-decode-encoded-word-methods-cache (list method))
1651 (if (and gnus-newsgroup-name
1652 (string-match (car method) gnus-newsgroup-name))
1653 (nconc gnus-decode-encoded-word-methods-cache
1654 (list (cdr method)))))))
1655 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1656 (setq string (funcall method string))))
1658 ;; Subject simplification.
1660 (defun gnus-simplify-whitespace (str)
1661 "Remove excessive whitespace from STR."
1663 (while (string-match "[ \t][ \t]+" str)
1664 (setq str (concat (substring str 0 (match-beginning 0))
1666 (substring str (match-end 0)))))
1668 (when (string-match "^[ \t]+" str)
1669 (setq str (substring str (match-end 0))))
1671 (when (string-match "[ \t]+$" str)
1672 (setq str (substring str 0 (match-beginning 0))))
1675 (defun gnus-simplify-all-whitespace (str)
1676 "Remove all whitespace from STR."
1677 (while (string-match "[ \t\n]+" str)
1678 (setq str (replace-match "" nil nil str)))
1681 (defsubst gnus-simplify-subject-re (subject)
1682 "Remove \"Re:\" from subject lines."
1683 (if (string-match message-subject-re-regexp subject)
1684 (substring subject (match-end 0))
1687 (defun gnus-simplify-subject (subject &optional re-only)
1688 "Remove `Re:' and words in parentheses.
1689 If RE-ONLY is non-nil, strip leading `Re:'s only."
1690 (let ((case-fold-search t)) ;Ignore case.
1691 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1692 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1693 (setq subject (substring subject (match-end 0))))
1694 ;; Remove uninteresting prefixes.
1695 (when (and (not re-only)
1696 gnus-simplify-ignored-prefixes
1697 (string-match gnus-simplify-ignored-prefixes subject))
1698 (setq subject (substring subject (match-end 0))))
1699 ;; Remove words in parentheses from end.
1701 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1702 (setq subject (substring subject 0 (match-beginning 0)))))
1703 ;; Return subject string.
1706 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1708 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1709 (goto-char (point-min))
1710 (while (re-search-forward regexp nil t)
1711 (replace-match (or newtext ""))))
1713 (defun gnus-simplify-buffer-fuzzy ()
1714 "Simplify string in the buffer fuzzily.
1715 The string in the accessible portion of the current buffer is simplified.
1716 It is assumed to be a single-line subject.
1717 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1718 matter is removed. Additional things can be deleted by setting
1719 `gnus-simplify-subject-fuzzy-regexp'."
1720 (let ((case-fold-search t)
1722 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1724 (while (not (eq modified-tick (buffer-modified-tick)))
1725 (setq modified-tick (buffer-modified-tick))
1727 ((listp gnus-simplify-subject-fuzzy-regexp)
1728 (mapc 'gnus-simplify-buffer-fuzzy-step
1729 gnus-simplify-subject-fuzzy-regexp))
1730 (gnus-simplify-subject-fuzzy-regexp
1731 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1732 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1733 (gnus-simplify-buffer-fuzzy-step
1734 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1735 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1737 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1738 (gnus-simplify-buffer-fuzzy-step " +" " ")
1739 (gnus-simplify-buffer-fuzzy-step " $")
1740 (gnus-simplify-buffer-fuzzy-step "^ +")))
1742 (defun gnus-simplify-subject-fuzzy (subject)
1743 "Simplify a subject string fuzzily.
1744 See `gnus-simplify-buffer-fuzzy' for details."
1746 (gnus-set-work-buffer)
1747 (let ((case-fold-search t))
1748 ;; Remove uninteresting prefixes.
1749 (when (and gnus-simplify-ignored-prefixes
1750 (string-match gnus-simplify-ignored-prefixes subject))
1751 (setq subject (substring subject (match-end 0))))
1753 (inline (gnus-simplify-buffer-fuzzy))
1756 (defsubst gnus-simplify-subject-fully (subject)
1757 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1759 (gnus-simplify-subject-functions
1760 (gnus-map-function gnus-simplify-subject-functions subject))
1761 ((null gnus-summary-gather-subject-limit)
1762 (gnus-simplify-subject-re subject))
1763 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1764 (gnus-simplify-subject-fuzzy subject))
1765 ((numberp gnus-summary-gather-subject-limit)
1766 (truncate-string-to-width (gnus-simplify-subject-re subject)
1767 gnus-summary-gather-subject-limit))
1771 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1772 "Check whether two subjects are equal.
1773 If optional argument SIMPLE-FIRST is t, first argument is already
1776 ((null simple-first)
1777 (equal (gnus-simplify-subject-fully s1)
1778 (gnus-simplify-subject-fully s2)))
1781 (gnus-simplify-subject-fully s2)))))
1783 (defun gnus-summary-bubble-group ()
1784 "Increase the score of the current group.
1785 This is a handy function to add to `gnus-summary-exit-hook' to
1786 increase the score of each group you read."
1787 (gnus-group-add-score gnus-newsgroup-name))
1791 ;;; Gnus summary mode
1794 (put 'gnus-summary-mode 'mode-class 'special)
1796 (defvar gnus-article-commands-menu)
1798 ;; Non-orthogonal keys
1800 (gnus-define-keys gnus-summary-mode-map
1801 " " gnus-summary-next-page
1802 "\177" gnus-summary-prev-page
1803 [delete] gnus-summary-prev-page
1804 [backspace] gnus-summary-prev-page
1805 "\r" gnus-summary-scroll-up
1806 "\M-\r" gnus-summary-scroll-down
1807 "n" gnus-summary-next-unread-article
1808 "p" gnus-summary-prev-unread-article
1809 "N" gnus-summary-next-article
1810 "P" gnus-summary-prev-article
1811 "\M-\C-n" gnus-summary-next-same-subject
1812 "\M-\C-p" gnus-summary-prev-same-subject
1813 "\M-n" gnus-summary-next-unread-subject
1814 "\M-p" gnus-summary-prev-unread-subject
1815 "." gnus-summary-first-unread-article
1816 "," gnus-summary-best-unread-article
1817 "\M-s" gnus-summary-search-article-forward
1818 "\M-r" gnus-summary-search-article-backward
1819 "\M-S" gnus-summary-repeat-search-article-forward
1820 "\M-R" gnus-summary-repeat-search-article-backward
1821 "<" gnus-summary-beginning-of-article
1822 ">" gnus-summary-end-of-article
1823 "j" gnus-summary-goto-article
1824 "^" gnus-summary-refer-parent-article
1825 "\M-^" gnus-summary-refer-article
1826 "u" gnus-summary-tick-article-forward
1827 "!" gnus-summary-tick-article-forward
1828 "U" gnus-summary-tick-article-backward
1829 "d" gnus-summary-mark-as-read-forward
1830 "D" gnus-summary-mark-as-read-backward
1831 "E" gnus-summary-mark-as-expirable
1832 "\M-u" gnus-summary-clear-mark-forward
1833 "\M-U" gnus-summary-clear-mark-backward
1834 "k" gnus-summary-kill-same-subject-and-select
1835 "\C-k" gnus-summary-kill-same-subject
1836 "\M-\C-k" gnus-summary-kill-thread
1837 "\M-\C-l" gnus-summary-lower-thread
1838 "e" gnus-summary-edit-article
1839 "#" gnus-summary-mark-as-processable
1840 "\M-#" gnus-summary-unmark-as-processable
1841 "\M-\C-t" gnus-summary-toggle-threads
1842 "\M-\C-s" gnus-summary-show-thread
1843 "\M-\C-h" gnus-summary-hide-thread
1844 "\M-\C-f" gnus-summary-next-thread
1845 "\M-\C-b" gnus-summary-prev-thread
1846 [(meta down)] gnus-summary-next-thread
1847 [(meta up)] gnus-summary-prev-thread
1848 "\M-\C-u" gnus-summary-up-thread
1849 "\M-\C-d" gnus-summary-down-thread
1850 "&" gnus-summary-execute-command
1851 "c" gnus-summary-catchup-and-exit
1852 "\C-w" gnus-summary-mark-region-as-read
1853 "\C-t" gnus-summary-toggle-truncation
1854 "?" gnus-summary-mark-as-dormant
1855 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1856 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1857 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1858 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1859 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1860 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1861 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1862 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1863 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1864 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1865 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1866 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1867 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1868 "=" gnus-summary-expand-window
1869 "\C-x\C-s" gnus-summary-reselect-current-group
1870 "\M-g" gnus-summary-rescan-group
1871 "\C-c\C-r" gnus-summary-caesar-message
1872 "f" gnus-summary-followup
1873 "F" gnus-summary-followup-with-original
1874 "C" gnus-summary-cancel-article
1875 "r" gnus-summary-reply
1876 "R" gnus-summary-reply-with-original
1877 "\C-c\C-f" gnus-summary-mail-forward
1878 "o" gnus-summary-save-article
1879 "\C-o" gnus-summary-save-article-mail
1880 "|" gnus-summary-pipe-output
1881 "\M-k" gnus-summary-edit-local-kill
1882 "\M-K" gnus-summary-edit-global-kill
1884 "\C-c\C-d" gnus-summary-describe-group
1885 "q" gnus-summary-exit
1886 "Q" gnus-summary-exit-no-update
1887 "\C-c\C-i" gnus-info-find-node
1888 gnus-mouse-2 gnus-mouse-pick-article
1889 [follow-link] mouse-face
1890 "m" gnus-summary-mail-other-window
1891 "a" gnus-summary-post-news
1892 "x" gnus-summary-limit-to-unread
1893 "s" gnus-summary-isearch-article
1894 "t" gnus-summary-toggle-header
1895 "g" gnus-summary-show-article
1896 "l" gnus-summary-goto-last-article
1897 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1898 "\C-d" gnus-summary-enter-digest-group
1899 "\M-\C-d" gnus-summary-read-document
1900 "\M-\C-e" gnus-summary-edit-parameters
1901 "\M-\C-a" gnus-summary-customize-parameters
1903 "*" gnus-cache-enter-article
1904 "\M-*" gnus-cache-remove-article
1905 "\M-&" gnus-summary-universal-argument
1906 "\C-l" gnus-recenter
1907 "I" gnus-summary-increase-score
1908 "L" gnus-summary-lower-score
1909 "\M-i" gnus-symbolic-argument
1910 "h" gnus-summary-select-article-buffer
1912 "b" gnus-article-view-part
1913 "\M-t" gnus-summary-toggle-display-buttonized
1915 "V" gnus-summary-score-map
1916 "X" gnus-uu-extract-map
1917 "S" gnus-summary-send-map)
1919 ;; Sort of orthogonal keymap
1920 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1921 "t" gnus-summary-tick-article-forward
1922 "!" gnus-summary-tick-article-forward
1923 "d" gnus-summary-mark-as-read-forward
1924 "r" gnus-summary-mark-as-read-forward
1925 "c" gnus-summary-clear-mark-forward
1926 " " gnus-summary-clear-mark-forward
1927 "e" gnus-summary-mark-as-expirable
1928 "x" gnus-summary-mark-as-expirable
1929 "?" gnus-summary-mark-as-dormant
1930 "b" gnus-summary-set-bookmark
1931 "B" gnus-summary-remove-bookmark
1932 "#" gnus-summary-mark-as-processable
1933 "\M-#" gnus-summary-unmark-as-processable
1934 "S" gnus-summary-limit-include-expunged
1935 "C" gnus-summary-catchup
1936 "H" gnus-summary-catchup-to-here
1937 "h" gnus-summary-catchup-from-here
1938 "\C-c" gnus-summary-catchup-all
1939 "k" gnus-summary-kill-same-subject-and-select
1940 "K" gnus-summary-kill-same-subject
1941 "P" gnus-uu-mark-map)
1943 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1944 "c" gnus-summary-clear-above
1945 "u" gnus-summary-tick-above
1946 "m" gnus-summary-mark-above
1947 "k" gnus-summary-kill-below)
1949 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1950 "/" gnus-summary-limit-to-subject
1951 "n" gnus-summary-limit-to-articles
1952 "b" gnus-summary-limit-to-bodies
1953 "h" gnus-summary-limit-to-headers
1954 "w" gnus-summary-pop-limit
1955 "s" gnus-summary-limit-to-subject
1956 "a" gnus-summary-limit-to-author
1957 "u" gnus-summary-limit-to-unread
1958 "m" gnus-summary-limit-to-marks
1959 "M" gnus-summary-limit-exclude-marks
1960 "v" gnus-summary-limit-to-score
1961 "*" gnus-summary-limit-include-cached
1962 "D" gnus-summary-limit-include-dormant
1963 "T" gnus-summary-limit-include-thread
1964 "d" gnus-summary-limit-exclude-dormant
1965 "t" gnus-summary-limit-to-age
1966 "." gnus-summary-limit-to-unseen
1967 "x" gnus-summary-limit-to-extra
1968 "p" gnus-summary-limit-to-display-predicate
1969 "E" gnus-summary-limit-include-expunged
1970 "c" gnus-summary-limit-exclude-childless-dormant
1971 "C" gnus-summary-limit-mark-excluded-as-read
1972 "o" gnus-summary-insert-old-articles
1973 "N" gnus-summary-insert-new-articles
1974 "S" gnus-summary-limit-to-singletons
1975 "r" gnus-summary-limit-to-replied
1976 "R" gnus-summary-limit-to-recipient
1977 "A" gnus-summary-limit-to-address)
1979 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1980 "n" gnus-summary-next-unread-article
1981 "p" gnus-summary-prev-unread-article
1982 "N" gnus-summary-next-article
1983 "P" gnus-summary-prev-article
1984 "\C-n" gnus-summary-next-same-subject
1985 "\C-p" gnus-summary-prev-same-subject
1986 "\M-n" gnus-summary-next-unread-subject
1987 "\M-p" gnus-summary-prev-unread-subject
1988 "f" gnus-summary-first-unread-article
1989 "b" gnus-summary-best-unread-article
1990 "j" gnus-summary-goto-article
1991 "g" gnus-summary-goto-subject
1992 "l" gnus-summary-goto-last-article
1993 "o" gnus-summary-pop-article)
1995 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1996 "k" gnus-summary-kill-thread
1997 "E" gnus-summary-expire-thread
1998 "l" gnus-summary-lower-thread
1999 "i" gnus-summary-raise-thread
2000 "T" gnus-summary-toggle-threads
2001 "t" gnus-summary-rethread-current
2002 "^" gnus-summary-reparent-thread
2003 "\M-^" gnus-summary-reparent-children
2004 "s" gnus-summary-show-thread
2005 "S" gnus-summary-show-all-threads
2006 "h" gnus-summary-hide-thread
2007 "H" gnus-summary-hide-all-threads
2008 "n" gnus-summary-next-thread
2009 "p" gnus-summary-prev-thread
2010 "u" gnus-summary-up-thread
2011 "o" gnus-summary-top-thread
2012 "d" gnus-summary-down-thread
2013 "#" gnus-uu-mark-thread
2014 "\M-#" gnus-uu-unmark-thread)
2016 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2017 "g" gnus-summary-prepare
2018 "c" gnus-summary-insert-cached-articles
2019 "d" gnus-summary-insert-dormant-articles
2020 "t" gnus-summary-insert-ticked-articles)
2022 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2023 "c" gnus-summary-catchup-and-exit
2024 "C" gnus-summary-catchup-all-and-exit
2025 "E" gnus-summary-exit-no-update
2026 "Q" gnus-summary-exit
2027 "Z" gnus-summary-exit
2028 "n" gnus-summary-catchup-and-goto-next-group
2029 "p" gnus-summary-catchup-and-goto-prev-group
2030 "R" gnus-summary-reselect-current-group
2031 "G" gnus-summary-rescan-group
2032 "N" gnus-summary-next-group
2033 "s" gnus-summary-save-newsrc
2034 "P" gnus-summary-prev-group)
2036 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2037 " " gnus-summary-next-page
2038 "n" gnus-summary-next-page
2039 "\177" gnus-summary-prev-page
2040 [delete] gnus-summary-prev-page
2041 "p" gnus-summary-prev-page
2042 "\r" gnus-summary-scroll-up
2043 "\M-\r" gnus-summary-scroll-down
2044 "<" gnus-summary-beginning-of-article
2045 ">" gnus-summary-end-of-article
2046 "b" gnus-summary-beginning-of-article
2047 "e" gnus-summary-end-of-article
2048 "^" gnus-summary-refer-parent-article
2049 "r" gnus-summary-refer-parent-article
2050 "D" gnus-summary-enter-digest-group
2051 "R" gnus-summary-refer-references
2052 "T" gnus-summary-refer-thread
2053 "g" gnus-summary-show-article
2054 "s" gnus-summary-isearch-article
2055 "P" gnus-summary-print-article
2056 "S" gnus-sticky-article
2057 "M" gnus-mailing-list-insinuate
2058 "t" gnus-article-babel)
2060 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2061 "b" gnus-article-add-buttons
2062 "B" gnus-article-add-buttons-to-head
2063 "o" gnus-article-treat-overstrike
2064 "e" gnus-article-emphasize
2065 "w" gnus-article-fill-cited-article
2066 "Q" gnus-article-fill-long-lines
2067 "L" gnus-article-toggle-truncate-lines
2068 "C" gnus-article-capitalize-sentences
2069 "c" gnus-article-remove-cr
2070 "q" gnus-article-de-quoted-unreadable
2071 "6" gnus-article-de-base64-unreadable
2072 "Z" gnus-article-decode-HZ
2073 "A" gnus-article-treat-ansi-sequences
2074 "h" gnus-article-wash-html
2075 "u" gnus-article-unsplit-urls
2076 "s" gnus-summary-force-verify-and-decrypt
2077 "f" gnus-article-display-x-face
2078 "l" gnus-summary-stop-page-breaking
2079 "r" gnus-summary-caesar-message
2080 "m" gnus-summary-morse-message
2081 "t" gnus-summary-toggle-header
2082 "g" gnus-treat-smiley
2083 "v" gnus-summary-verbose-headers
2084 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2085 "p" gnus-article-verify-x-pgp-sig
2086 "d" gnus-article-treat-dumbquotes
2087 "i" gnus-summary-idna-message)
2089 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2090 ;; mnemonic: deuglif*Y*
2091 "u" gnus-article-outlook-unwrap-lines
2092 "a" gnus-article-outlook-repair-attribution
2093 "c" gnus-article-outlook-rearrange-citation
2094 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2096 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2097 "a" gnus-article-hide
2098 "h" gnus-article-hide-headers
2099 "b" gnus-article-hide-boring-headers
2100 "s" gnus-article-hide-signature
2101 "c" gnus-article-hide-citation
2102 "C" gnus-article-hide-citation-in-followups
2103 "l" gnus-article-hide-list-identifiers
2104 "B" gnus-article-strip-banner
2105 "P" gnus-article-hide-pem
2106 "\C-c" gnus-article-hide-citation-maybe)
2108 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2109 "a" gnus-article-highlight
2110 "h" gnus-article-highlight-headers
2111 "c" gnus-article-highlight-citation
2112 "s" gnus-article-highlight-signature)
2114 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2115 "f" gnus-article-treat-fold-headers
2116 "u" gnus-article-treat-unfold-headers
2117 "n" gnus-article-treat-fold-newsgroups)
2119 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2120 "x" gnus-article-display-x-face
2121 "d" gnus-article-display-face
2122 "s" gnus-treat-smiley
2123 "D" gnus-article-remove-images
2124 "W" gnus-html-show-images
2125 "f" gnus-treat-from-picon
2126 "m" gnus-treat-mail-picon
2127 "n" gnus-treat-newsgroups-picon)
2129 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2130 "w" gnus-article-decode-mime-words
2131 "c" gnus-article-decode-charset
2132 "v" gnus-mime-view-all-parts
2133 "b" gnus-article-view-part)
2135 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2136 "z" gnus-article-date-ut
2137 "u" gnus-article-date-ut
2138 "l" gnus-article-date-local
2139 "p" gnus-article-date-english
2140 "e" gnus-article-date-lapsed
2141 "o" gnus-article-date-original
2142 "i" gnus-article-date-iso8601
2143 "s" gnus-article-date-user)
2145 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2146 "t" gnus-article-remove-trailing-blank-lines
2147 "l" gnus-article-strip-leading-blank-lines
2148 "m" gnus-article-strip-multiple-blank-lines
2149 "a" gnus-article-strip-blank-lines
2150 "A" gnus-article-strip-all-blank-lines
2151 "s" gnus-article-strip-leading-space
2152 "e" gnus-article-strip-trailing-space
2153 "w" gnus-article-remove-leading-whitespace)
2155 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2157 "d" gnus-summary-describe-group
2158 "h" gnus-summary-describe-briefly
2159 "i" gnus-info-find-node
2160 "C" gnus-group-fetch-control)
2162 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2163 "e" gnus-summary-expire-articles
2164 "\M-\C-e" gnus-summary-expire-articles-now
2165 "\177" gnus-summary-delete-article
2166 [delete] gnus-summary-delete-article
2167 [backspace] gnus-summary-delete-article
2168 "m" gnus-summary-move-article
2169 "r" gnus-summary-respool-article
2170 "w" gnus-summary-edit-article
2171 "c" gnus-summary-copy-article
2172 "B" gnus-summary-crosspost-article
2173 "q" gnus-summary-respool-query
2174 "t" gnus-summary-respool-trace
2175 "i" gnus-summary-import-article
2176 "I" gnus-summary-create-article
2177 "p" gnus-summary-article-posted-p)
2179 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2180 "o" gnus-summary-save-article
2181 "m" gnus-summary-save-article-mail
2182 "F" gnus-summary-write-article-file
2183 "r" gnus-summary-save-article-rmail
2184 "f" gnus-summary-save-article-file
2185 "b" gnus-summary-save-article-body-file
2186 "B" gnus-summary-write-article-body-file
2187 "h" gnus-summary-save-article-folder
2188 "v" gnus-summary-save-article-vm
2189 "p" gnus-summary-pipe-output
2190 "P" gnus-summary-muttprint)
2192 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2193 "b" gnus-summary-display-buttonized
2194 "m" gnus-summary-repair-multipart
2195 "v" gnus-article-view-part
2196 "o" gnus-article-save-part
2197 "O" gnus-article-save-part-and-strip
2198 "r" gnus-article-replace-part
2199 "d" gnus-article-delete-part
2200 "t" gnus-article-view-part-as-type
2201 "j" gnus-article-jump-to-part
2202 "c" gnus-article-copy-part
2203 "C" gnus-article-view-part-as-charset
2204 "e" gnus-article-view-part-externally
2205 "H" gnus-article-browse-html-article
2206 "E" gnus-article-encrypt-body
2207 "i" gnus-article-inline-part
2208 "|" gnus-article-pipe-part)
2210 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2211 "p" gnus-summary-mark-as-processable
2212 "u" gnus-summary-unmark-as-processable
2213 "U" gnus-summary-unmark-all-processable
2214 "v" gnus-uu-mark-over
2215 "s" gnus-uu-mark-series
2216 "r" gnus-uu-mark-region
2217 "g" gnus-uu-unmark-region
2218 "R" gnus-uu-mark-by-regexp
2219 "G" gnus-uu-unmark-by-regexp
2220 "t" gnus-uu-mark-thread
2221 "T" gnus-uu-unmark-thread
2222 "a" gnus-uu-mark-all
2223 "b" gnus-uu-mark-buffer
2224 "S" gnus-uu-mark-sparse
2225 "k" gnus-summary-kill-process-mark
2226 "y" gnus-summary-yank-process-mark
2227 "w" gnus-summary-save-process-mark
2228 "i" gnus-uu-invert-processable)
2230 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2231 ;;"x" gnus-uu-extract-any
2232 "m" gnus-summary-save-parts
2233 "u" gnus-uu-decode-uu
2234 "U" gnus-uu-decode-uu-and-save
2235 "s" gnus-uu-decode-unshar
2236 "S" gnus-uu-decode-unshar-and-save
2237 "o" gnus-uu-decode-save
2238 "O" gnus-uu-decode-save
2239 "b" gnus-uu-decode-binhex
2240 "B" gnus-uu-decode-binhex
2241 "Y" gnus-uu-decode-yenc
2242 "p" gnus-uu-decode-postscript
2243 "P" gnus-uu-decode-postscript-and-save)
2246 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2247 "u" gnus-uu-decode-uu-view
2248 "U" gnus-uu-decode-uu-and-save-view
2249 "s" gnus-uu-decode-unshar-view
2250 "S" gnus-uu-decode-unshar-and-save-view
2251 "o" gnus-uu-decode-save-view
2252 "O" gnus-uu-decode-save-view
2253 "b" gnus-uu-decode-binhex-view
2254 "B" gnus-uu-decode-binhex-view
2255 "p" gnus-uu-decode-postscript-view
2256 "P" gnus-uu-decode-postscript-and-save-view)
2258 (defvar gnus-article-post-menu nil)
2260 (defconst gnus-summary-menu-maxlen 20)
2262 (defun gnus-summary-menu-split (menu)
2263 ;; If we have lots of elements, divide them into groups of 20
2264 ;; and make a pane (or submenu) for each one.
2265 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2266 (let ((menu menu) sublists next
2269 ;; Pull off the next gnus-summary-menu-maxlen elements
2270 ;; and make them the next element of sublist.
2271 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2273 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2275 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2276 (aref (car (last menu)) 0)) menu)
2280 (nreverse sublists))
2281 ;; Few elements--put them all in one pane.
2284 (defun gnus-summary-make-menu-bar ()
2285 (gnus-turn-off-edit-menu 'summary)
2287 (unless (boundp 'gnus-summary-misc-menu)
2290 gnus-summary-kill-menu gnus-summary-mode-map ""
2295 ["Customize" gnus-score-customize t])
2296 (gnus-make-score-map 'increase)
2297 (gnus-make-score-map 'lower)
2299 ["Kill below" gnus-summary-kill-below t]
2300 ["Mark above" gnus-summary-mark-above t]
2301 ["Tick above" gnus-summary-tick-above t]
2302 ["Clear above" gnus-summary-clear-above t])
2303 ["Current score" gnus-summary-current-score t]
2304 ["Set score" gnus-summary-set-score t]
2305 ["Switch current score file..." gnus-score-change-score-file t]
2306 ["Set mark below..." gnus-score-set-mark-below t]
2307 ["Set expunge below..." gnus-score-set-expunge-below t]
2308 ["Edit current score file" gnus-score-edit-current-scores t]
2309 ["Edit score file..." gnus-score-edit-file t]
2310 ["Trace score" gnus-score-find-trace t]
2311 ["Find words" gnus-score-find-favourite-words t]
2312 ["Rescore buffer" gnus-summary-rescore t]
2313 ["Increase score..." gnus-summary-increase-score t]
2314 ["Lower score..." gnus-summary-lower-score t]))))
2316 ;; Define both the Article menu in the summary buffer and the
2317 ;; equivalent Commands menu in the article buffer here for
2321 ["All" gnus-article-hide t]
2322 ["Headers" gnus-article-hide-headers t]
2323 ["Signature" gnus-article-hide-signature t]
2324 ["Citation" gnus-article-hide-citation t]
2325 ["List identifiers" gnus-article-hide-list-identifiers t]
2326 ["Banner" gnus-article-strip-banner t]
2327 ["Boring headers" gnus-article-hide-boring-headers t])
2329 ["All" gnus-article-highlight t]
2330 ["Headers" gnus-article-highlight-headers t]
2331 ["Signature" gnus-article-highlight-signature t]
2332 ["Citation" gnus-article-highlight-citation t])
2334 ["Words" gnus-article-decode-mime-words t]
2335 ["Charset" gnus-article-decode-charset t]
2336 ["QP" gnus-article-de-quoted-unreadable t]
2337 ["Base64" gnus-article-de-base64-unreadable t]
2338 ["View MIME buttons" gnus-summary-display-buttonized t]
2339 ["View all" gnus-mime-view-all-parts t]
2340 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2341 ["Encrypt body" gnus-article-encrypt-body
2342 :active (not (gnus-group-read-only-p))
2343 ,@(if (featurep 'xemacs) nil
2344 '(:help "Encrypt the message body on disk"))]
2345 ["Extract all parts..." gnus-summary-save-parts t]
2347 ["Repair multipart" gnus-summary-repair-multipart t]
2348 ["Pipe part..." gnus-article-pipe-part t]
2349 ["Inline part" gnus-article-inline-part t]
2350 ["View part as type..." gnus-article-view-part-as-type t]
2351 ["Encrypt body" gnus-article-encrypt-body
2352 :active (not (gnus-group-read-only-p))
2353 ,@(if (featurep 'xemacs) nil
2354 '(:help "Encrypt the message body on disk"))]
2355 ["View part externally" gnus-article-view-part-externally t]
2356 ["View HTML parts in browser" gnus-article-browse-html-article t]
2357 ["View part with charset..." gnus-article-view-part-as-charset t]
2358 ["Copy part" gnus-article-copy-part t]
2359 ["Save part..." gnus-article-save-part t]
2360 ["View part" gnus-article-view-part t]))
2362 ["Local" gnus-article-date-local t]
2363 ["ISO8601" gnus-article-date-iso8601 t]
2364 ["UT" gnus-article-date-ut t]
2365 ["Original" gnus-article-date-original t]
2366 ["Lapsed" gnus-article-date-lapsed t]
2367 ["User-defined" gnus-article-date-user t])
2369 ["Remove images" gnus-article-remove-images t]
2370 ["Toggle smiley" gnus-treat-smiley t]
2371 ["Show X-Face" gnus-article-display-x-face t]
2372 ["Show picons in From" gnus-treat-from-picon t]
2373 ["Show picons in mail headers" gnus-treat-mail-picon t]
2374 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2375 ("View as different encoding"
2376 ,@(gnus-summary-menu-split
2379 ;; Since easymenu under Emacs doesn't allow
2380 ;; lambda forms for menu commands, we should
2381 ;; provide intern'ed function symbols.
2382 (let ((command (intern (format "\
2383 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2387 (let ((gnus-summary-show-article-charset-alist
2389 (gnus-summary-show-article 1))))
2390 `[,(symbol-name cs) ,command t]))
2391 (sort (if (fboundp 'coding-system-list)
2392 (coding-system-list)
2393 (mapcar 'car mm-mime-mule-charset-alist))
2397 ["Leading" gnus-article-strip-leading-blank-lines t]
2398 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2399 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2400 ["All of the above" gnus-article-strip-blank-lines t]
2401 ["All" gnus-article-strip-all-blank-lines t]
2402 ["Leading space" gnus-article-strip-leading-space t]
2403 ["Trailing space" gnus-article-strip-trailing-space t]
2404 ["Leading space in headers"
2405 gnus-article-remove-leading-whitespace t])
2406 ["Overstrike" gnus-article-treat-overstrike t]
2407 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2408 ["Emphasis" gnus-article-emphasize t]
2409 ["Word wrap" gnus-article-fill-cited-article t]
2410 ["Fill long lines" gnus-article-fill-long-lines t]
2411 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2412 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2413 ["Remove CR" gnus-article-remove-cr t]
2414 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2415 ["Base64" gnus-article-de-base64-unreadable t]
2416 ["Rot 13" gnus-summary-caesar-message
2417 ,@(if (featurep 'xemacs) '(t)
2418 '(:help "\"Caesar rotate\" article by 13"))]
2419 ["De-IDNA" gnus-summary-idna-message t]
2420 ["Morse decode" gnus-summary-morse-message t]
2421 ["Unix pipe..." gnus-summary-pipe-message t]
2422 ["Add buttons" gnus-article-add-buttons t]
2423 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2424 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2425 ["Verbose header" gnus-summary-verbose-headers t]
2426 ["Toggle header" gnus-summary-toggle-header t]
2427 ["Unfold headers" gnus-article-treat-unfold-headers t]
2428 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2429 ["Html" gnus-article-wash-html t]
2430 ["Unsplit URLs" gnus-article-unsplit-urls t]
2431 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2432 ["Decode HZ" gnus-article-decode-HZ t]
2433 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2434 ("(Outlook) Deuglify"
2435 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2436 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2437 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2438 ["Full (Outlook) deuglify"
2439 gnus-article-outlook-deuglify-article t])
2442 ["Save in default format..." gnus-summary-save-article
2443 ,@(if (featurep 'xemacs) '(t)
2444 '(:help "Save article using default method"))]
2445 ["Save in file..." gnus-summary-save-article-file
2446 ,@(if (featurep 'xemacs) '(t)
2447 '(:help "Save article in file"))]
2448 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2449 ["Save in MH folder..." gnus-summary-save-article-folder t]
2450 ["Save in VM folder..." gnus-summary-save-article-vm t]
2451 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2452 ["Save body in file..." gnus-summary-save-article-body-file t]
2453 ["Pipe through a filter..." gnus-summary-pipe-output t]
2454 ["Print with Muttprint..." gnus-summary-muttprint t]
2455 ["Print" gnus-summary-print-article
2456 ,@(if (featurep 'xemacs) '(t)
2457 '(:help "Generate and print a PostScript image"))])
2458 ("Copy, move,... (Backend)"
2459 ,@(if (featurep 'xemacs) nil
2460 '(:help "Copying, moving, expiring articles..."))
2461 ["Respool article..." gnus-summary-respool-article t]
2462 ["Move article..." gnus-summary-move-article
2463 (gnus-check-backend-function
2464 'request-move-article gnus-newsgroup-name)]
2465 ["Copy article..." gnus-summary-copy-article t]
2466 ["Crosspost article..." gnus-summary-crosspost-article
2467 (gnus-check-backend-function
2468 'request-replace-article gnus-newsgroup-name)]
2469 ["Import file..." gnus-summary-import-article
2470 (gnus-check-backend-function
2471 'request-accept-article gnus-newsgroup-name)]
2472 ["Create article..." gnus-summary-create-article
2473 (gnus-check-backend-function
2474 'request-accept-article gnus-newsgroup-name)]
2475 ["Check if posted" gnus-summary-article-posted-p t]
2476 ["Edit article" gnus-summary-edit-article
2477 (not (gnus-group-read-only-p))]
2478 ["Delete article" gnus-summary-delete-article
2479 (gnus-check-backend-function
2480 'request-expire-articles gnus-newsgroup-name)]
2481 ["Query respool" gnus-summary-respool-query t]
2482 ["Trace respool" gnus-summary-respool-trace t]
2483 ["Delete expirable articles" gnus-summary-expire-articles-now
2484 (gnus-check-backend-function
2485 'request-expire-articles gnus-newsgroup-name)])
2487 ["Uudecode" gnus-uu-decode-uu
2488 ,@(if (featurep 'xemacs) '(t)
2489 '(:help "Decode uuencoded article(s)"))]
2490 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2491 ["Unshar" gnus-uu-decode-unshar t]
2492 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2493 ["Save" gnus-uu-decode-save t]
2494 ["Binhex" gnus-uu-decode-binhex t]
2495 ["Postscript" gnus-uu-decode-postscript t]
2496 ["All MIME parts" gnus-summary-save-parts t])
2498 ["Enter article" gnus-cache-enter-article t]
2499 ["Remove article" gnus-cache-remove-article t])
2500 ["Translate" gnus-article-babel t]
2501 ["Select article buffer" gnus-summary-select-article-buffer t]
2502 ["Make article buffer sticky" gnus-sticky-article t]
2503 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2504 ["Isearch article..." gnus-summary-isearch-article t]
2505 ["Beginning of the article" gnus-summary-beginning-of-article t]
2506 ["End of the article" gnus-summary-end-of-article t]
2507 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2508 ["Fetch referenced articles" gnus-summary-refer-references t]
2509 ["Fetch current thread" gnus-summary-refer-thread t]
2510 ["Fetch article with id..." gnus-summary-refer-article t]
2511 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2512 ["Redisplay" gnus-summary-show-article t]
2513 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2515 gnus-summary-article-menu gnus-summary-mode-map ""
2516 (cons "Article" innards))
2518 (if (not (keymapp gnus-summary-article-menu))
2520 gnus-article-commands-menu gnus-article-mode-map ""
2521 (cons "Commands" innards))
2522 ;; in Emacs, don't share menu.
2523 (setq gnus-article-commands-menu
2524 (copy-keymap gnus-summary-article-menu))
2525 (define-key gnus-article-mode-map [menu-bar commands]
2526 (cons "Commands" gnus-article-commands-menu))))
2529 gnus-summary-thread-menu gnus-summary-mode-map ""
2531 ["Find all messages in thread" gnus-summary-refer-thread t]
2532 ["Toggle threading" gnus-summary-toggle-threads t]
2533 ["Hide threads" gnus-summary-hide-all-threads t]
2534 ["Show threads" gnus-summary-show-all-threads t]
2535 ["Hide thread" gnus-summary-hide-thread t]
2536 ["Show thread" gnus-summary-show-thread t]
2537 ["Go to next thread" gnus-summary-next-thread t]
2538 ["Go to previous thread" gnus-summary-prev-thread t]
2539 ["Go down thread" gnus-summary-down-thread t]
2540 ["Go up thread" gnus-summary-up-thread t]
2541 ["Top of thread" gnus-summary-top-thread t]
2542 ["Mark thread as read" gnus-summary-kill-thread t]
2543 ["Mark thread as expired" gnus-summary-expire-thread t]
2544 ["Lower thread score" gnus-summary-lower-thread t]
2545 ["Raise thread score" gnus-summary-raise-thread t]
2546 ["Rethread current" gnus-summary-rethread-current t]))
2549 gnus-summary-post-menu gnus-summary-mode-map ""
2551 ["Send a message (mail or news)" gnus-summary-post-news
2552 ,@(if (featurep 'xemacs) '(t)
2553 '(:help "Compose a new message (mail or news)"))]
2554 ["Followup" gnus-summary-followup
2555 ,@(if (featurep 'xemacs) '(t)
2556 '(:help "Post followup to this article"))]
2557 ["Followup and yank" gnus-summary-followup-with-original
2558 ,@(if (featurep 'xemacs) '(t)
2559 '(:help "Post followup to this article, quoting its contents"))]
2560 ["Supersede article" gnus-summary-supersede-article t]
2561 ["Cancel article" gnus-summary-cancel-article
2562 ,@(if (featurep 'xemacs) '(t)
2563 '(:help "Cancel an article you posted"))]
2564 ["Reply" gnus-summary-reply t]
2565 ["Reply and yank" gnus-summary-reply-with-original t]
2566 ["Wide reply" gnus-summary-wide-reply t]
2567 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2568 ,@(if (featurep 'xemacs) '(t)
2569 '(:help "Mail a reply, quoting this article"))]
2570 ["Very wide reply" gnus-summary-very-wide-reply t]
2571 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2572 ,@(if (featurep 'xemacs) '(t)
2573 '(:help "Mail a very wide reply, quoting this article"))]
2574 ["Mail forward" gnus-summary-mail-forward t]
2575 ["Post forward" gnus-summary-post-forward t]
2576 ["Digest and mail" gnus-uu-digest-mail-forward t]
2577 ["Digest and post" gnus-uu-digest-post-forward t]
2578 ["Resend message" gnus-summary-resend-message t]
2579 ["Resend message edit" gnus-summary-resend-message-edit t]
2580 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2581 ["Send a mail" gnus-summary-mail-other-window t]
2582 ["Create a local message" gnus-summary-news-other-window t]
2583 ["Uuencode and post" gnus-uu-post-news
2584 ,@(if (featurep 'xemacs) '(t)
2585 '(:help "Post a uuencoded article"))]
2586 ["Followup via news" gnus-summary-followup-to-mail t]
2587 ["Followup via news and yank"
2588 gnus-summary-followup-to-mail-with-original t]
2589 ["Strip signature on reply"
2592 (if (not (memq message-cite-function
2593 '(message-cite-original-without-signature
2594 message-cite-original)))
2595 ;; Stupid workaround for XEmacs not honoring :visible.
2596 (message "Can't toggle this value of `message-cite-function'")
2597 (setq message-cite-function
2598 (if (eq message-cite-function
2599 'message-cite-original-without-signature)
2600 'message-cite-original
2601 'message-cite-original-without-signature))))
2602 ;; XEmacs barfs on :visible.
2603 ,@(if (featurep 'xemacs) nil
2604 '(:visible (memq message-cite-function
2605 '(message-cite-original-without-signature
2606 message-cite-original))))
2608 :selected (eq message-cite-function
2609 'message-cite-original-without-signature)
2610 ,@(if (featurep 'xemacs) nil
2611 '(:help "Strip signature from cited article when replying."))]
2613 ;;["Send" gnus-summary-send-draft t]
2614 ;;["Send bounced" gnus-resend-bounced-mail t])
2618 ((not (keymapp gnus-summary-post-menu))
2619 (setq gnus-article-post-menu gnus-summary-post-menu))
2620 ((not gnus-article-post-menu)
2621 ;; Don't share post menu.
2622 (setq gnus-article-post-menu
2623 (copy-keymap gnus-summary-post-menu))))
2624 (define-key gnus-article-mode-map [menu-bar post]
2625 (cons "Post" gnus-article-post-menu))
2628 gnus-summary-misc-menu gnus-summary-mode-map ""
2631 ["Mark as read" gnus-summary-mark-as-read-forward t]
2632 ["Mark same subject and select"
2633 gnus-summary-kill-same-subject-and-select t]
2634 ["Mark same subject" gnus-summary-kill-same-subject t]
2635 ["Catchup" gnus-summary-catchup
2636 ,@(if (featurep 'xemacs) '(t)
2637 '(:help "Mark unread articles in this group as read"))]
2638 ["Catchup all" gnus-summary-catchup-all t]
2639 ["Catchup to here" gnus-summary-catchup-to-here t]
2640 ["Catchup from here" gnus-summary-catchup-from-here t]
2641 ["Catchup region" gnus-summary-mark-region-as-read
2642 (gnus-mark-active-p)]
2643 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2645 ["Tick" gnus-summary-tick-article-forward t]
2646 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2647 ["Remove marks" gnus-summary-clear-mark-forward t]
2648 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2649 ["Set bookmark" gnus-summary-set-bookmark t]
2650 ["Remove bookmark" gnus-summary-remove-bookmark t])
2652 ["Marks..." gnus-summary-limit-to-marks t]
2653 ["Subject..." gnus-summary-limit-to-subject t]
2654 ["Author..." gnus-summary-limit-to-author t]
2655 ["Recipient..." gnus-summary-limit-to-recipient t]
2656 ["Address..." gnus-summary-limit-to-address t]
2657 ["Age..." gnus-summary-limit-to-age t]
2658 ["Extra..." gnus-summary-limit-to-extra t]
2659 ["Score..." gnus-summary-limit-to-score t]
2660 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2661 ["Unread" gnus-summary-limit-to-unread t]
2662 ["Unseen" gnus-summary-limit-to-unseen t]
2663 ["Singletons" gnus-summary-limit-to-singletons t]
2664 ["Replied" gnus-summary-limit-to-replied t]
2665 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2666 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2667 ["Pop limit" gnus-summary-pop-limit t]
2668 ["Show dormant" gnus-summary-limit-include-dormant t]
2669 ["Hide childless dormant"
2670 gnus-summary-limit-exclude-childless-dormant t]
2671 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2672 ["Hide marked" gnus-summary-limit-exclude-marks t]
2673 ["Show expunged" gnus-summary-limit-include-expunged t])
2675 ["Set mark" gnus-summary-mark-as-processable t]
2676 ["Remove mark" gnus-summary-unmark-as-processable t]
2677 ["Remove all marks" gnus-summary-unmark-all-processable t]
2678 ["Invert marks" gnus-uu-invert-processable t]
2679 ["Mark above" gnus-uu-mark-over t]
2680 ["Mark series" gnus-uu-mark-series t]
2681 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2682 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2683 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2684 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2685 ["Mark all" gnus-uu-mark-all t]
2686 ["Mark buffer" gnus-uu-mark-buffer t]
2687 ["Mark sparse" gnus-uu-mark-sparse t]
2688 ["Mark thread" gnus-uu-mark-thread t]
2689 ["Unmark thread" gnus-uu-unmark-thread t]
2690 ("Process Mark Sets"
2691 ["Kill" gnus-summary-kill-process-mark t]
2692 ["Yank" gnus-summary-yank-process-mark
2693 gnus-newsgroup-process-stack]
2694 ["Save" gnus-summary-save-process-mark t]
2695 ["Run command on marked..." gnus-summary-universal-argument t]))
2698 ["Page forward" gnus-summary-next-page
2699 ,@(if (featurep 'xemacs) '(t)
2700 '(:help "Show next page of article"))]
2701 ["Page backward" gnus-summary-prev-page
2702 ,@(if (featurep 'xemacs) '(t)
2703 '(:help "Show previous page of article"))]
2704 ["Line forward" gnus-summary-scroll-up t])
2706 ["Next unread article" gnus-summary-next-unread-article t]
2707 ["Previous unread article" gnus-summary-prev-unread-article t]
2708 ["Next article" gnus-summary-next-article t]
2709 ["Previous article" gnus-summary-prev-article t]
2710 ["Next unread subject" gnus-summary-next-unread-subject t]
2711 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2712 ["Next article same subject" gnus-summary-next-same-subject t]
2713 ["Previous article same subject" gnus-summary-prev-same-subject t]
2714 ["First unread article" gnus-summary-first-unread-article t]
2715 ["Best unread article" gnus-summary-best-unread-article t]
2716 ["Go to subject number..." gnus-summary-goto-subject t]
2717 ["Go to article number..." gnus-summary-goto-article t]
2718 ["Go to the last article" gnus-summary-goto-last-article t]
2719 ["Pop article off history" gnus-summary-pop-article t])
2721 ["Sort by number" gnus-summary-sort-by-number t]
2722 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2723 ["Sort by author" gnus-summary-sort-by-author t]
2724 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2725 ["Sort by subject" gnus-summary-sort-by-subject t]
2726 ["Sort by date" gnus-summary-sort-by-date t]
2727 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2728 ["Sort by score" gnus-summary-sort-by-score t]
2729 ["Sort by lines" gnus-summary-sort-by-lines t]
2730 ["Sort by characters" gnus-summary-sort-by-chars t]
2731 ["Randomize" gnus-summary-sort-by-random t]
2732 ["Original sort" gnus-summary-sort-by-original t])
2734 ["Describe group" gnus-summary-describe-group t]
2735 ["Fetch control message" gnus-group-fetch-control
2736 ,@(if (featurep 'xemacs) nil
2737 '(:help "Display the archived control message for the current group"))]
2738 ["Read manual" gnus-info-find-node t])
2740 ["Pick and read" gnus-pick-mode t]
2741 ["Binary" gnus-binary-mode t])
2743 ["Regenerate" gnus-summary-prepare t]
2744 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2745 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2746 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2747 ["Toggle threading" gnus-summary-toggle-threads t])
2748 ["See old articles" gnus-summary-insert-old-articles t]
2749 ["See new articles" gnus-summary-insert-new-articles t]
2750 ["Filter articles..." gnus-summary-execute-command t]
2751 ["Run command on articles..." gnus-summary-universal-argument t]
2752 ["Search articles forward..." gnus-summary-search-article-forward t]
2753 ["Search articles backward..." gnus-summary-search-article-backward t]
2754 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2755 ["Expand window" gnus-summary-expand-window t]
2756 ["Expire expirable articles" gnus-summary-expire-articles
2757 (gnus-check-backend-function
2758 'request-expire-articles gnus-newsgroup-name)]
2759 ["Edit local kill file" gnus-summary-edit-local-kill t]
2760 ["Edit main kill file" gnus-summary-edit-global-kill t]
2761 ["Edit group parameters" gnus-summary-edit-parameters t]
2762 ["Customize group parameters" gnus-summary-customize-parameters t]
2763 ["Send a bug report" gnus-bug t]
2765 ["Catchup and exit" gnus-summary-catchup-and-exit
2766 ,@(if (featurep 'xemacs) '(t)
2767 '(:help "Mark unread articles in this group as read, then exit"))]
2768 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2769 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2770 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2771 ["Exit group" gnus-summary-exit
2772 ,@(if (featurep 'xemacs) '(t)
2773 '(:help "Exit current group, return to group selection mode"))]
2774 ["Exit group without updating" gnus-summary-exit-no-update t]
2775 ["Exit and goto next group" gnus-summary-next-group t]
2776 ["Exit and goto prev group" gnus-summary-prev-group t]
2777 ["Reselect group" gnus-summary-reselect-current-group t]
2778 ["Rescan group" gnus-summary-rescan-group t]
2779 ["Update dribble" gnus-summary-save-newsrc t])))
2781 (gnus-run-hooks 'gnus-summary-menu-hook)))
2783 (defvar gnus-summary-tool-bar-map nil)
2785 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2786 ;; affect _new_ message buffers. We might add a function that walks thru all
2787 ;; summary-mode buffers and force the update.
2788 (defun gnus-summary-tool-bar-update (&optional symbol value)
2789 "Update summary mode toolbar.
2790 Setter function for custom variables."
2791 (setq-default gnus-summary-tool-bar-map nil)
2793 ;; When used as ":set" function:
2794 (set-default symbol value))
2795 (when (gnus-buffer-live-p gnus-summary-buffer)
2796 (with-current-buffer gnus-summary-buffer
2797 (gnus-summary-make-tool-bar))))
2799 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2800 'gnus-summary-tool-bar-gnome
2801 'gnus-summary-tool-bar-retro)
2802 "Specifies the Gnus summary tool bar.
2804 It can be either a list or a symbol refering to a list. See
2805 `gmm-tool-bar-from-list' for the format of the list. The
2806 default key map is `gnus-summary-mode-map'.
2808 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2809 `gnus-summary-tool-bar-retro'."
2810 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2811 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2812 (repeat :tag "User defined list" gmm-tool-bar-item)
2814 :version "23.1" ;; No Gnus
2815 :initialize 'custom-initialize-default
2816 :set 'gnus-summary-tool-bar-update
2817 :group 'gnus-summary)
2819 (defcustom gnus-summary-tool-bar-gnome
2820 '((gnus-summary-post-news "mail/compose" nil)
2821 (gnus-summary-insert-new-articles "mail/inbox" nil
2822 :visible (or (not gnus-agent)
2824 (gnus-summary-reply-with-original "mail/reply")
2825 (gnus-summary-reply "mail/reply" nil :visible nil)
2826 (gnus-summary-followup-with-original "mail/reply-all")
2827 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2828 (gnus-summary-mail-forward "mail/forward")
2829 (gnus-summary-save-article "mail/save")
2830 (gnus-summary-search-article-forward "search" nil :visible nil)
2831 (gnus-summary-print-article "print")
2832 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2833 ;; Some new commands that may need more suitable icons:
2834 (gnus-summary-save-newsrc "save" nil :visible nil)
2835 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2836 (gnus-summary-prev-article "left-arrow")
2837 (gnus-summary-next-article "right-arrow")
2838 (gnus-summary-next-page "next-page")
2839 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2841 ;; Maybe some sort-by-... could be added:
2842 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2843 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2844 (gnus-summary-mark-as-expirable
2846 :visible (gnus-check-backend-function 'request-expire-articles
2847 gnus-newsgroup-name))
2848 (gnus-summary-mark-as-spam
2850 :visible (and (fboundp 'spam-group-ham-contents-p)
2851 (spam-group-ham-contents-p gnus-newsgroup-name))
2852 :help "Mark as spam")
2853 (gnus-summary-mark-as-read-forward
2855 :visible (and (fboundp 'spam-group-spam-contents-p)
2856 (spam-group-spam-contents-p gnus-newsgroup-name)))
2858 (gnus-summary-exit "exit")
2859 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2860 (gnus-info-find-node "help"))
2861 "List of functions for the summary tool bar (GNOME style).
2863 See `gmm-tool-bar-from-list' for the format of the list."
2864 :type '(repeat gmm-tool-bar-item)
2865 :version "23.1" ;; No Gnus
2866 :initialize 'custom-initialize-default
2867 :set 'gnus-summary-tool-bar-update
2868 :group 'gnus-summary)
2870 (defcustom gnus-summary-tool-bar-retro
2871 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2872 (gnus-summary-next-unread-article "gnus/next-ur")
2873 (gnus-summary-post-news "gnus/post")
2874 (gnus-summary-followup-with-original "gnus/fuwo")
2875 (gnus-summary-followup "gnus/followup")
2876 (gnus-summary-reply-with-original "gnus/reply-wo")
2877 (gnus-summary-reply "gnus/reply")
2878 (gnus-summary-caesar-message "gnus/rot13")
2879 (gnus-uu-decode-uu "gnus/uu-decode")
2880 (gnus-summary-save-article-file "gnus/save-aif")
2881 (gnus-summary-save-article "gnus/save-art")
2882 (gnus-uu-post-news "gnus/uu-post")
2883 (gnus-summary-catchup "gnus/catchup")
2884 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2885 (gnus-summary-exit "gnus/exit-summ")
2886 ;; Some new command that may need more suitable icons:
2887 (gnus-summary-print-article "gnus/print" nil :visible nil)
2888 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2889 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2890 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2891 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2892 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2893 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2895 (gnus-info-find-node "gnus/help" nil :visible nil))
2896 "List of functions for the summary tool bar (retro look).
2898 See `gmm-tool-bar-from-list' for the format of the list."
2899 :type '(repeat gmm-tool-bar-item)
2900 :version "23.1" ;; No Gnus
2901 :initialize 'custom-initialize-default
2902 :set 'gnus-summary-tool-bar-update
2903 :group 'gnus-summary)
2905 (defcustom gnus-summary-tool-bar-zap-list t
2906 "List of icon items from the global tool bar.
2907 These items are not displayed in the Gnus summary mode tool bar.
2909 See `gmm-tool-bar-from-list' for the format of the list."
2910 :type 'gmm-tool-bar-zap-list
2911 :version "23.1" ;; No Gnus
2912 :initialize 'custom-initialize-default
2913 :set 'gnus-summary-tool-bar-update
2914 :group 'gnus-summary)
2916 (defvar image-load-path)
2917 (defvar tool-bar-map)
2919 (defun gnus-summary-make-tool-bar (&optional force)
2920 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2921 When FORCE, rebuild the tool bar."
2922 (when (and (not (featurep 'xemacs))
2923 (boundp 'tool-bar-mode)
2925 (or (not gnus-summary-tool-bar-map) force))
2927 (gmm-image-load-path-for-library "gnus"
2930 (image-load-path (cons (car load-path)
2931 (when (boundp 'image-load-path)
2933 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2934 gnus-summary-tool-bar-zap-list
2935 'gnus-summary-mode-map)))
2937 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2939 (setq gnus-summary-tool-bar-map map))))
2940 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2942 (defun gnus-score-set-default (var value)
2943 "A version of set that updates the GNU Emacs menu-bar."
2945 ;; It is the message that forces the active status to be updated.
2948 (defun gnus-make-score-map (type)
2949 "Make a summary score map of type TYPE."
2952 (let ((headers '(("author" "from" string)
2953 ("subject" "subject" string)
2954 ("article body" "body" string)
2955 ("article head" "head" string)
2956 ("xref" "xref" string)
2957 ("extra header" "extra" string)
2958 ("lines" "lines" number)
2959 ("followups to author" "followup" string)))
2960 (types '((number ("less than" <)
2963 (string ("substring" s)
2967 (perms '(("temporary" (current-time-string))
2975 (if (eq type 'lower)
2980 (setq header (car headers))
2986 (let ((ts (cdr (assoc (nth 2 header) types)))
3002 'gnus-summary-score-entry
3004 (if (or (string= (nth 1 header)
3006 (string= (nth 1 header)
3009 (list 'gnus-summary-header
3011 (list 'quote (nth 1 (car ts)))
3012 (list 'gnus-score-delta-default
3019 (list (nreverse outp))))
3022 (list (nreverse outt))))
3024 (setq headers (cdr headers)))
3025 (list (nreverse outh))))))))
3028 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3029 (defvar bookmark-make-record-function)
3032 (defun gnus-summary-mode (&optional group)
3033 "Major mode for reading articles.
3035 All normal editing commands are switched off.
3036 \\<gnus-summary-mode-map>
3037 Each line in this buffer represents one article. To read an
3038 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3039 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3042 You can also post articles and send mail from this buffer. To
3043 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3044 of an article, type `\\[gnus-summary-reply]'.
3046 There are approx. one gazillion commands you can execute in this
3047 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3049 The following commands are available:
3051 \\{gnus-summary-mode-map}"
3053 (kill-all-local-variables)
3054 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3055 (gnus-summary-make-local-variables))
3056 (gnus-summary-make-local-variables)
3057 (setq gnus-newsgroup-name group)
3058 (when (gnus-visual-p 'summary-menu 'menu)
3059 (gnus-summary-make-menu-bar)
3060 (gnus-summary-make-tool-bar))
3061 (gnus-make-thread-indent-array)
3062 (gnus-simplify-mode-line)
3063 (setq major-mode 'gnus-summary-mode)
3064 (setq mode-name "Summary")
3065 (use-local-map gnus-summary-mode-map)
3066 (buffer-disable-undo)
3067 (setq buffer-read-only t ;Disable modification
3068 show-trailing-whitespace nil)
3069 (setq truncate-lines t)
3070 (add-to-invisibility-spec '(gnus-sum . t))
3071 (gnus-summary-set-display-table)
3072 (gnus-set-default-directory)
3073 (make-local-variable 'gnus-summary-line-format)
3074 (make-local-variable 'gnus-summary-line-format-spec)
3075 (make-local-variable 'gnus-summary-dummy-line-format)
3076 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3077 (make-local-variable 'gnus-summary-mark-positions)
3078 (gnus-make-local-hook 'pre-command-hook)
3079 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3080 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3081 (turn-on-gnus-mailing-list-mode)
3082 (mm-enable-multibyte)
3083 (set (make-local-variable 'bookmark-make-record-function)
3084 'gnus-summary-bookmark-make-record)
3085 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3086 (gnus-update-summary-mark-positions))
3088 (defun gnus-summary-make-local-variables ()
3089 "Make all the local summary buffer variables."
3091 (dolist (local gnus-summary-local-variables)
3094 (if (eq (cdr local) 'global)
3095 ;; Copy the global value of the variable.
3096 (setq global (symbol-value (car local)))
3097 ;; Use the value from the list.
3098 (setq global (eval (cdr local))))
3099 (set (make-local-variable (car local)) global))
3100 ;; Simple nil-valued local variable.
3101 (set (make-local-variable local) nil)))))
3103 (defun gnus-summary-clear-local-variables ()
3104 (let ((locals gnus-summary-local-variables))
3106 (if (consp (car locals))
3107 (and (symbolp (caar locals))
3108 (set (caar locals) nil))
3109 (and (symbolp (car locals))
3110 (set (car locals) nil)))
3111 (setq locals (cdr locals)))))
3113 ;; Summary data functions.
3115 (defmacro gnus-data-number (data)
3118 (defmacro gnus-data-set-number (data number)
3119 `(setcar ,data ,number))
3121 (defmacro gnus-data-mark (data)
3124 (defmacro gnus-data-set-mark (data mark)
3125 `(setcar (nthcdr 1 ,data) ,mark))
3127 (defmacro gnus-data-pos (data)
3130 (defmacro gnus-data-set-pos (data pos)
3131 `(setcar (nthcdr 2 ,data) ,pos))
3133 (defmacro gnus-data-header (data)
3136 (defmacro gnus-data-set-header (data header)
3137 `(setf (nth 3 ,data) ,header))
3139 (defmacro gnus-data-level (data)
3142 (defmacro gnus-data-unread-p (data)
3143 `(= (nth 1 ,data) gnus-unread-mark))
3145 (defmacro gnus-data-read-p (data)
3146 `(/= (nth 1 ,data) gnus-unread-mark))
3148 (defmacro gnus-data-pseudo-p (data)
3149 `(consp (nth 3 ,data)))
3151 (defmacro gnus-data-find (number)
3152 `(assq ,number gnus-newsgroup-data))
3154 (defmacro gnus-data-find-list (number &optional data)
3155 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3156 (memq (assq ,number bdata)
3159 (defmacro gnus-data-make (number mark pos header level)
3160 `(list ,number ,mark ,pos ,header ,level))
3162 (defun gnus-data-enter (after-article number mark pos header level offset)
3163 (let ((data (gnus-data-find-list after-article)))
3165 (error "No such article: %d" after-article))
3166 (setcdr data (cons (gnus-data-make number mark pos header level)
3168 (setq gnus-newsgroup-data-reverse nil)
3169 (gnus-data-update-list (cddr data) offset)))
3171 (defun gnus-data-enter-list (after-article list &optional offset)
3173 (let ((data (and after-article (gnus-data-find-list after-article)))
3177 (let ((odata gnus-newsgroup-data))
3178 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3180 (gnus-data-update-list odata offset)))
3181 ;; Find the last element in the list to be spliced into the main
3183 (setq list (last list))
3186 (setcdr list gnus-newsgroup-data)
3187 (setq gnus-newsgroup-data ilist)
3189 (gnus-data-update-list (cdr list) offset)))
3190 (setcdr list (cdr data))
3193 (gnus-data-update-list (cdr list) offset))))
3194 (setq gnus-newsgroup-data-reverse nil))))
3196 (defun gnus-data-remove (article &optional offset)
3197 (let ((data gnus-newsgroup-data))
3198 (if (= (gnus-data-number (car data)) article)
3200 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3201 gnus-newsgroup-data-reverse nil)
3203 (gnus-data-update-list gnus-newsgroup-data offset)))
3205 (when (= (gnus-data-number (cadr data)) article)
3206 (setcdr data (cddr data))
3208 (gnus-data-update-list (cdr data) offset))
3210 gnus-newsgroup-data-reverse nil))
3211 (setq data (cdr data))))))
3213 (defmacro gnus-data-list (backward)
3215 (or gnus-newsgroup-data-reverse
3216 (setq gnus-newsgroup-data-reverse
3217 (reverse gnus-newsgroup-data)))
3218 gnus-newsgroup-data))
3220 (defun gnus-data-update-list (data offset)
3221 "Add OFFSET to the POS of all data entries in DATA."
3222 (setq gnus-newsgroup-data-reverse nil)
3224 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3225 (setq data (cdr data))))
3227 (defun gnus-summary-article-pseudo-p (article)
3228 "Say whether this article is a pseudo article or not."
3229 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3231 (defmacro gnus-summary-article-sparse-p (article)
3232 "Say whether this article is a sparse article or not."
3233 `(memq ,article gnus-newsgroup-sparse))
3235 (defmacro gnus-summary-article-ancient-p (article)
3236 "Say whether this article is a sparse article or not."
3237 `(memq ,article gnus-newsgroup-ancient))
3239 (defun gnus-article-parent-p (number)
3240 "Say whether this article is a parent or not."
3241 (let ((data (gnus-data-find-list number)))
3242 (and (cdr data) ; There has to be an article after...
3243 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3244 (gnus-data-level (nth 1 data))))))
3246 (defun gnus-article-children (number)
3247 "Return a list of all children to NUMBER."
3248 (let* ((data (gnus-data-find-list number))
3249 (level (gnus-data-level (car data)))
3251 (setq data (cdr data))
3253 (= (gnus-data-level (car data)) (1+ level)))
3254 (push (gnus-data-number (car data)) children)
3255 (setq data (cdr data)))
3258 (defmacro gnus-summary-skip-intangible ()
3259 "If the current article is intangible, then jump to a different article."
3260 '(let ((to (get-text-property (point) 'gnus-intangible)))
3261 (and to (gnus-summary-goto-subject to))))
3263 (defmacro gnus-summary-article-intangible-p ()
3264 "Say whether this article is intangible or not."
3265 '(get-text-property (point) 'gnus-intangible))
3267 (defun gnus-article-read-p (article)
3268 "Say whether ARTICLE is read or not."
3269 (not (or (memq article gnus-newsgroup-marked)
3270 (memq article gnus-newsgroup-spam-marked)
3271 (memq article gnus-newsgroup-unreads)
3272 (memq article gnus-newsgroup-unselected)
3273 (memq article gnus-newsgroup-dormant))))
3275 ;; Some summary mode macros.
3277 (defmacro gnus-summary-article-number ()
3278 "The article number of the article on the current line.
3279 If there isn't an article number here, then we return the current
3282 (gnus-summary-skip-intangible)
3283 (or (get-text-property (point) 'gnus-number)
3284 (gnus-summary-last-subject))))
3286 (defmacro gnus-summary-article-header (&optional number)
3287 "Return the header of article NUMBER."
3288 `(gnus-data-header (gnus-data-find
3289 ,(or number '(gnus-summary-article-number)))))
3291 (defmacro gnus-summary-thread-level (&optional number)
3292 "Return the level of thread that starts with article NUMBER."
3293 `(if (and (eq gnus-summary-make-false-root 'dummy)
3294 (get-text-property (point) 'gnus-intangible))
3296 (gnus-data-level (gnus-data-find
3297 ,(or number '(gnus-summary-article-number))))))
3299 (defmacro gnus-summary-article-mark (&optional number)
3300 "Return the mark of article NUMBER."
3301 `(gnus-data-mark (gnus-data-find
3302 ,(or number '(gnus-summary-article-number)))))
3304 (defmacro gnus-summary-article-pos (&optional number)
3305 "Return the position of the line of article NUMBER."
3306 `(gnus-data-pos (gnus-data-find
3307 ,(or number '(gnus-summary-article-number)))))
3309 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3310 (defmacro gnus-summary-article-subject (&optional number)
3311 "Return current subject string or nil if nothing."
3314 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3315 '(gnus-data-header (assq (gnus-summary-article-number)
3316 gnus-newsgroup-data)))))
3319 (mail-header-subject headers))))
3321 (defmacro gnus-summary-article-score (&optional number)
3322 "Return current article score."
3323 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3324 gnus-newsgroup-scored))
3325 gnus-summary-default-score 0))
3327 (defun gnus-summary-article-children (&optional number)
3328 "Return a list of article numbers that are children of article NUMBER."
3329 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3330 (level (gnus-data-level (car data)))
3332 (while (and (setq data (cdr data))
3333 (> (setq l (gnus-data-level (car data))) level))
3334 (and (= (1+ level) l)
3335 (push (gnus-data-number (car data))
3337 (nreverse children)))
3339 (defun gnus-summary-article-parent (&optional number)
3340 "Return the article number of the parent of article NUMBER."
3341 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3342 (gnus-data-list t)))
3343 (level (gnus-data-level (car data))))
3345 () ; This is a root.
3346 ;; We search until we find an article with a level less than
3347 ;; this one. That function has to be the parent.
3348 (while (and (setq data (cdr data))
3349 (not (< (gnus-data-level (car data)) level))))
3350 (and data (gnus-data-number (car data))))))
3352 (defun gnus-unread-mark-p (mark)
3353 "Say whether MARK is the unread mark."
3354 (= mark gnus-unread-mark))
3356 (defun gnus-read-mark-p (mark)
3357 "Say whether MARK is one of the marks that mark as read.
3358 This is all marks except unread, ticked, dormant, and expirable."
3359 (not (or (= mark gnus-unread-mark)
3360 (= mark gnus-ticked-mark)
3361 (= mark gnus-spam-mark)
3362 (= mark gnus-dormant-mark)
3363 (= mark gnus-expirable-mark))))
3365 (defmacro gnus-article-mark (number)
3366 "Return the MARK of article NUMBER.
3367 This macro should only be used when computing the mark the \"first\"
3368 time; i.e., when generating the summary lines. After that,
3369 `gnus-summary-article-mark' should be used to examine the
3372 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3373 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3374 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3375 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3376 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3377 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3378 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3379 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3380 gnus-ancient-mark))))
3382 ;; Saving hidden threads.
3384 (defmacro gnus-save-hidden-threads (&rest forms)
3385 "Save hidden threads, eval FORMS, and restore the hidden threads."
3386 (let ((config (make-symbol "config")))
3387 `(let ((,config (gnus-hidden-threads-configuration)))
3391 (gnus-restore-hidden-threads-configuration ,config)))))
3392 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3393 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3395 (defun gnus-data-compute-positions ()
3396 "Compute the positions of all articles."
3397 (setq gnus-newsgroup-data-reverse nil)
3398 (let ((data gnus-newsgroup-data))
3400 (gnus-save-hidden-threads
3401 (gnus-summary-show-all-threads)
3402 (goto-char (point-min))
3404 (while (get-text-property (point) 'gnus-intangible)
3406 (gnus-data-set-pos (car data) (+ (point) 3))
3407 (setq data (cdr data))
3408 (forward-line 1))))))
3410 (defun gnus-hidden-threads-configuration ()
3411 "Return the current hidden threads configuration."
3414 (goto-char (point-min))
3416 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3417 (push (save-excursion (forward-line 0) (point)) config))
3421 (defun gnus-restore-hidden-threads-configuration (config)
3422 "Restore hidden threads configuration from CONFIG."
3424 (let (point (inhibit-read-only t))
3425 (while (setq point (pop config))
3427 (gnus-summary-hide-thread)))))
3429 ;; Various summary mode internalish functions.
3431 (defun gnus-mouse-pick-article (e)
3434 (gnus-summary-next-page nil t))
3436 (defun gnus-summary-set-display-table ()
3437 "Change the display table.
3438 Odd characters have a tendency to mess
3439 up nicely formatted displays - we make all possible glyphs
3440 display only a single character."
3442 ;; We start from the standard display table, if any.
3443 (let ((table (or (copy-sequence standard-display-table)
3444 (make-display-table)))
3446 ;; Nix out all the control chars...
3447 (while (>= (setq i (1- i)) 0)
3448 (gnus-put-display-table i [??] table))
3449 ;; ... but not newline and cr, of course. (cr is necessary for the
3450 ;; selective display).
3451 (gnus-put-display-table ?\n nil table)
3452 (gnus-put-display-table ?\r nil table)
3453 ;; We keep TAB as well.
3454 (gnus-put-display-table ?\t nil table)
3455 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3456 ;; Emacs 23 (unicode), that are not set already.
3457 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3460 (while (>= (setq i (1- i)) 127)
3461 ;; Only modify if the entry is nil.
3462 (unless (gnus-get-display-table i table)
3463 (gnus-put-display-table i [??] table))))
3464 (setq buffer-display-table table)))
3466 (defun gnus-summary-set-article-display-arrow (pos)
3467 "Update the overlay arrow to point to line at position POS."
3468 (when gnus-summary-display-arrow
3469 (make-local-variable 'overlay-arrow-position)
3470 (make-local-variable 'overlay-arrow-string)
3474 (unless overlay-arrow-position
3475 (setq overlay-arrow-position (make-marker)))
3476 (setq overlay-arrow-string "=>"
3477 overlay-arrow-position (set-marker overlay-arrow-position
3479 (current-buffer))))))
3481 (defun gnus-summary-setup-buffer (group)
3482 "Initialize summary buffer."
3483 (let ((buffer (gnus-summary-buffer-name group))
3484 (dead-name (concat "*Dead Summary "
3485 (gnus-group-decoded-name group) "*")))
3486 ;; If a dead summary buffer exists, we kill it.
3487 (when (gnus-buffer-live-p dead-name)
3488 (gnus-kill-buffer dead-name))
3489 (if (get-buffer buffer)
3492 (setq gnus-summary-buffer (current-buffer))
3493 (not gnus-newsgroup-prepared))
3494 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3495 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3496 (gnus-summary-mode group)
3498 (gnus-carpal-setup-buffer 'summary))
3499 (when (gnus-group-quit-config group)
3500 (set (make-local-variable 'gnus-single-article-buffer) nil))
3501 (make-local-variable 'gnus-article-buffer)
3502 (make-local-variable 'gnus-article-current)
3503 (make-local-variable 'gnus-original-article-buffer)
3504 (setq gnus-newsgroup-name group)
3505 ;; Set any local variables in the group parameters.
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3509 (defun gnus-set-global-variables ()
3510 "Set the global equivalents of the buffer-local variables.
3511 They are set to the latest values they had. These reflect the summary
3512 buffer that was in action when the last article was fetched."
3513 (when (eq major-mode 'gnus-summary-mode)
3514 (setq gnus-summary-buffer (current-buffer))
3515 (let ((name gnus-newsgroup-name)
3516 (marked gnus-newsgroup-marked)
3517 (spam gnus-newsgroup-spam-marked)
3518 (unread gnus-newsgroup-unreads)
3519 (headers gnus-current-headers)
3520 (data gnus-newsgroup-data)
3521 (summary gnus-summary-buffer)
3522 (article-buffer gnus-article-buffer)
3523 (original gnus-original-article-buffer)
3524 (gac gnus-article-current)
3525 (reffed gnus-reffed-article-number)
3526 (score-file gnus-current-score-file)
3527 (default-charset gnus-newsgroup-charset)
3529 (let ((locals gnus-newsgroup-variables))
3531 (if (consp (car locals))
3532 (push (eval (caar locals)) vlist)
3533 (push (eval (car locals)) vlist))
3534 (setq locals (cdr locals)))
3535 (setq vlist (nreverse vlist)))
3536 (with-current-buffer gnus-group-buffer
3537 (setq gnus-newsgroup-name name
3538 gnus-newsgroup-marked marked
3539 gnus-newsgroup-spam-marked spam
3540 gnus-newsgroup-unreads unread
3541 gnus-current-headers headers
3542 gnus-newsgroup-data data
3543 gnus-article-current gac
3544 gnus-summary-buffer summary
3545 gnus-article-buffer article-buffer
3546 gnus-original-article-buffer original
3547 gnus-reffed-article-number reffed
3548 gnus-current-score-file score-file
3549 gnus-newsgroup-charset default-charset)
3550 (let ((locals gnus-newsgroup-variables))
3552 (if (consp (car locals))
3553 (set (caar locals) (pop vlist))
3554 (set (car locals) (pop vlist)))
3555 (setq locals (cdr locals))))
3556 ;; The article buffer also has local variables.
3557 (when (gnus-buffer-live-p gnus-article-buffer)
3558 (set-buffer gnus-article-buffer)
3559 (setq gnus-summary-buffer summary))))))
3561 (defun gnus-summary-article-unread-p (article)
3562 "Say whether ARTICLE is unread or not."
3563 (memq article gnus-newsgroup-unreads))
3565 (defun gnus-summary-first-article-p (&optional article)
3566 "Return whether ARTICLE is the first article in the buffer."
3567 (if (not (setq article (or article (gnus-summary-article-number))))
3569 (eq article (caar gnus-newsgroup-data))))
3571 (defun gnus-summary-last-article-p (&optional article)
3572 "Return whether ARTICLE is the last article in the buffer."
3573 (if (not (setq article (or article (gnus-summary-article-number))))
3574 ;; All non-existent numbers are the last article. :-)
3576 (not (cdr (gnus-data-find-list article)))))
3578 (defun gnus-make-thread-indent-array (&optional n)
3580 (progn (setq n 200) nil)
3581 (null gnus-thread-indent-array)
3582 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3583 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3584 gnus-thread-indent-array-level gnus-thread-indent-level)
3586 (aset gnus-thread-indent-array n
3587 (make-string (* n gnus-thread-indent-level) ? ))
3590 (defun gnus-update-summary-mark-positions ()
3591 "Compute where the summary marks are to go."
3593 (when (gnus-buffer-exists-p gnus-summary-buffer)
3594 (set-buffer gnus-summary-buffer))
3595 (let ((spec gnus-summary-line-format-spec)
3598 (gnus-set-work-buffer)
3599 (let ((gnus-tmp-unread ?Z)
3600 (gnus-replied-mark ?Z)
3601 (gnus-score-below-mark ?Z)
3602 (gnus-score-over-mark ?Z)
3603 (gnus-undownloaded-mark ?Z)
3604 (gnus-summary-line-format-spec spec)
3605 (gnus-newsgroup-downloadable '(0))
3606 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3607 case-fold-search ignores)
3608 ;; Here, all marks are bound to Z.
3609 (gnus-summary-insert-line header
3610 0 nil t gnus-tmp-unread t nil "" nil 1)
3611 (goto-char (point-min))
3612 ;; Memorize the positions of the same characters as dummy marks.
3613 (while (re-search-forward "[A-D]" nil t)
3614 (push (point) ignores))
3616 ;; We use A-D as dummy marks in order to know column positions
3617 ;; where marks should be inserted.
3618 (setq gnus-tmp-unread ?A
3619 gnus-replied-mark ?B
3620 gnus-score-below-mark ?C
3621 gnus-score-over-mark ?C
3622 gnus-undownloaded-mark ?D)
3623 (gnus-summary-insert-line header
3624 0 nil t gnus-tmp-unread t nil "" nil 1)
3625 ;; Ignore characters which aren't dummy marks.
3627 (delete-region (goto-char (1- p)) p)
3629 (goto-char (point-min))
3630 (setq pos (list (cons 'unread
3631 (and (search-forward "A" nil t)
3632 (- (point) (point-min) 1)))))
3633 (goto-char (point-min))
3634 (push (cons 'replied (and (search-forward "B" nil t)
3635 (- (point) (point-min) 1)))
3637 (goto-char (point-min))
3638 (push (cons 'score (and (search-forward "C" nil t)
3639 (- (point) (point-min) 1)))
3641 (goto-char (point-min))
3642 (push (cons 'download (and (search-forward "D" nil t)
3643 (- (point) (point-min) 1)))
3645 (setq gnus-summary-mark-positions pos))))
3647 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3648 "Insert a dummy root in the summary buffer."
3650 (gnus-add-text-properties
3651 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3652 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3654 (defun gnus-summary-extract-address-component (from)
3655 (or (car (funcall gnus-extract-address-components from))
3658 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3659 (let ((mail-parse-charset gnus-newsgroup-charset)
3660 (ignored-from-addresses (gnus-ignored-from-addresses))
3661 ; Is it really necessary to do this next part for each summary line?
3662 ; Luckily, doesn't seem to slow things down much.
3663 (mail-parse-ignored-charsets
3664 (with-current-buffer gnus-summary-buffer
3665 gnus-newsgroup-ignored-charsets)))
3667 (and ignored-from-addresses
3668 (string-match ignored-from-addresses gnus-tmp-from)
3669 (let ((extra-headers (mail-header-extra header))
3673 ((setq to (cdr (assq 'To extra-headers)))
3674 (concat gnus-summary-to-prefix
3676 (gnus-summary-extract-address-component
3677 (funcall gnus-decode-encoded-address-function to)))))
3680 (cdr (assq 'Newsgroups extra-headers))
3682 (memq 'Newsgroups gnus-extra-headers)
3683 (eq (car (gnus-find-method-for-group
3684 gnus-newsgroup-name)) 'nntp)
3685 (gnus-group-real-name gnus-newsgroup-name))))
3686 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3687 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3689 (defun gnus-summary-insert-line (gnus-tmp-header
3690 gnus-tmp-level gnus-tmp-current
3691 undownloaded gnus-tmp-unread gnus-tmp-replied
3692 gnus-tmp-expirable gnus-tmp-subject-or-nil
3693 &optional gnus-tmp-dummy gnus-tmp-score
3695 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3696 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3698 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3699 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3700 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3701 (gnus-tmp-score-char
3702 (if (or (null gnus-summary-default-score)
3703 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3704 gnus-summary-zcore-fuzz))
3706 (if (< gnus-tmp-score gnus-summary-default-score)
3707 gnus-score-below-mark gnus-score-over-mark)))
3708 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3710 (cond (gnus-tmp-process gnus-process-mark)
3711 ((memq gnus-tmp-current gnus-newsgroup-cached)
3713 (gnus-tmp-replied gnus-replied-mark)
3714 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3715 gnus-forwarded-mark)
3716 ((memq gnus-tmp-current gnus-newsgroup-saved)
3718 ((memq gnus-tmp-number gnus-newsgroup-recent)
3720 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3723 (gnus-tmp-downloaded
3725 gnus-undownloaded-mark)
3726 (gnus-newsgroup-agentized
3727 gnus-downloaded-mark)
3730 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3733 ((string-match "<[^>]+> *$" gnus-tmp-from)
3734 (let ((beg (match-beginning 0)))
3735 (or (and (string-match "^\".+\"" gnus-tmp-from)
3736 (substring gnus-tmp-from 1 (1- (match-end 0))))
3737 (substring gnus-tmp-from 0 beg))))
3738 ((string-match "(.+)" gnus-tmp-from)
3739 (substring gnus-tmp-from
3740 (1+ (match-beginning 0)) (1- (match-end 0))))
3742 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3743 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3744 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3745 (inhibit-read-only t))
3746 (when (string= gnus-tmp-name "")
3747 (setq gnus-tmp-name gnus-tmp-from))
3748 (unless (numberp gnus-tmp-lines)
3749 (setq gnus-tmp-lines -1))
3750 (if (= gnus-tmp-lines -1)
3751 (setq gnus-tmp-lines "?")
3752 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3754 (gnus-put-text-property
3756 (progn (eval gnus-summary-line-format-spec) (point))
3757 'gnus-number gnus-tmp-number)
3758 (error (gnus-message 5 "Error updating the summary line")))
3759 (when (gnus-visual-p 'summary-highlight 'highlight)
3761 (gnus-summary-highlight-line)
3762 (gnus-run-hooks 'gnus-summary-update-hook)
3765 (defun gnus-summary-update-line (&optional dont-update)
3766 "Update summary line after change."
3767 (when (and gnus-summary-default-score
3768 (not gnus-summary-inhibit-highlight))
3769 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3770 (article (gnus-summary-article-number))
3771 (score (gnus-summary-article-score article)))
3773 (if (and gnus-summary-mark-below
3774 (< (gnus-summary-article-score)
3775 gnus-summary-mark-below))
3776 ;; This article has a low score, so we mark it as read.
3777 (when (memq article gnus-newsgroup-unreads)
3778 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3779 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3780 ;; This article was previously marked as read on account
3781 ;; of a low score, but now it has risen, so we mark it as
3783 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3784 (gnus-summary-update-mark
3785 (if (or (null gnus-summary-default-score)
3786 (<= (abs (- score gnus-summary-default-score))
3787 gnus-summary-zcore-fuzz))
3789 (if (< score gnus-summary-default-score)
3790 gnus-score-below-mark gnus-score-over-mark))
3792 ;; Do visual highlighting.
3793 (when (gnus-visual-p 'summary-highlight 'highlight)
3794 (gnus-summary-highlight-line)
3795 (gnus-run-hooks 'gnus-summary-update-hook)))))
3797 (defvar gnus-tmp-new-adopts nil)
3799 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3800 "Return the number of articles in THREAD.
3801 This may be 0 in some cases -- if none of the articles in
3802 the thread are to be displayed."
3804 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3806 ((not (listp thread))
3808 ((and (consp thread) (cdr thread))
3811 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3814 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3817 (when (and level (zerop level) gnus-tmp-new-adopts)
3820 'gnus-summary-number-of-articles-in-thread
3821 gnus-tmp-new-adopts))))
3823 (if (> number 1) gnus-not-empty-thread-mark
3824 gnus-empty-thread-mark)
3827 (defsubst gnus-summary-line-message-size (head)
3828 "Return pretty-printed version of message size.
3829 This function is intended to be used in
3830 `gnus-summary-line-format-alist'."
3831 (let ((c (or (mail-header-chars head) -1)))
3832 (cond ((< c 0) "n/a") ; chars not available
3833 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3834 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3835 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3836 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3839 (defun gnus-summary-set-local-parameters (group)
3840 "Go through the local params of GROUP and set all variable specs in that list."
3841 (let ((vars '(quit-config))) ; Ignore quit-config.
3842 (dolist (elem (gnus-group-find-parameter group))
3843 (and (consp elem) ; Has to be a cons.
3844 (consp (cdr elem)) ; The cdr has to be a list.
3845 (symbolp (car elem)) ; Has to be a symbol in there.
3846 (not (memq (car elem) vars))
3848 (push (car elem) vars)
3849 ;; Variables like `gnus-show-threads' that are globally
3850 ;; bound, if used as group parameters, need to get to be
3851 ;; buffer-local, whereas just parameters like `gcc-self',
3852 ;; `timestamp', etc. should not be bound as variables.
3853 (if (boundp (car elem))
3854 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3855 (eval (nth 1 elem))))))))
3857 (defun gnus-summary-read-group (group &optional show-all no-article
3858 kill-buffer no-display backward
3860 "Start reading news in newsgroup GROUP.
3861 If SHOW-ALL is non-nil, already read articles are also listed.
3862 If NO-ARTICLE is non-nil, no article is selected initially.
3863 If NO-DISPLAY, don't generate a summary buffer."
3867 (let ((gnus-auto-select-next nil))
3868 (or (gnus-summary-read-group-1
3869 group show-all no-article
3870 kill-buffer no-display
3873 select-articles nil)))))
3874 (eq gnus-auto-select-next 'quietly))
3875 (set-buffer gnus-group-buffer)
3876 ;; The entry function called above goes to the next
3877 ;; group automatically, so we go two groups back
3878 ;; if we are searching for the previous group.
3880 (gnus-group-prev-unread-group 2))
3881 (if (not (equal group (gnus-group-group-name)))
3882 (setq group (gnus-group-group-name))
3886 (defun gnus-summary-read-group-1 (group show-all no-article
3887 kill-buffer no-display
3888 &optional select-articles)
3889 ;; Killed foreign groups can't be entered.
3890 ;; (when (and (not (gnus-group-native-p group))
3891 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3892 ;; (error "Dead non-native groups can't be entered"))
3893 (gnus-message 5 "Retrieving newsgroup: %s..."
3894 (gnus-group-decoded-name group))
3895 (let* ((new-group (gnus-summary-setup-buffer group))
3896 (quit-config (gnus-group-quit-config group))
3897 (did-select (and new-group (gnus-select-newsgroup
3898 group show-all select-articles))))
3900 ;; This summary buffer exists already, so we just select it.
3902 (gnus-set-global-variables)
3904 (gnus-kill-or-deaden-summary kill-buffer))
3905 (gnus-configure-windows 'summary 'force)
3906 (gnus-set-mode-line 'summary)
3907 (gnus-summary-position-point)
3910 ;; We couldn't select this group.
3912 (when (and (eq major-mode 'gnus-summary-mode)
3913 (not (equal (current-buffer) kill-buffer)))
3914 (kill-buffer (current-buffer))
3915 (if (not quit-config)
3917 ;; Update the info -- marks might need to be removed,
3919 (gnus-summary-update-info)
3920 (set-buffer gnus-group-buffer)
3921 (gnus-group-jump-to-group group)
3922 (gnus-group-next-unread-group 1))
3923 (gnus-handle-ephemeral-exit quit-config)))
3924 (let ((grpinfo (gnus-get-info group)))
3925 (if (null (gnus-info-read grpinfo))
3926 (gnus-message 3 "Group %s contains no messages"
3927 (gnus-group-decoded-name group))
3928 (gnus-message 3 "Can't select group")))
3930 ;; The user did a `C-g' while prompting for number of articles,
3931 ;; so we exit this group.
3932 ((eq did-select 'quit)
3933 (and (eq major-mode 'gnus-summary-mode)
3934 (not (equal (current-buffer) kill-buffer))
3935 (kill-buffer (current-buffer)))
3937 (gnus-kill-or-deaden-summary kill-buffer))
3938 (if (not quit-config)
3940 (set-buffer gnus-group-buffer)
3941 (gnus-group-jump-to-group group)
3942 (gnus-configure-windows 'group 'force))
3943 (gnus-handle-ephemeral-exit quit-config))
3944 ;; Finally signal the quit.
3946 ;; The group was successfully selected.
3948 (gnus-set-global-variables)
3949 ;; Save the active value in effect when the group was entered.
3950 (setq gnus-newsgroup-active
3952 (gnus-active gnus-newsgroup-name)))
3953 ;; You can change the summary buffer in some way with this hook.
3954 (gnus-run-hooks 'gnus-select-group-hook)
3955 (when (memq 'summary (gnus-update-format-specifications
3956 nil 'summary 'summary-mode 'summary-dummy))
3957 ;; The format specification for the summary line was updated,
3958 ;; so we need to update the mark positions as well.
3959 (gnus-update-summary-mark-positions))
3960 ;; Do score processing.
3961 (when gnus-use-scoring
3962 (gnus-possibly-score-headers))
3963 ;; Check whether to fill in the gaps in the threads.
3964 (when gnus-build-sparse-threads
3965 (gnus-build-sparse-threads))
3966 ;; Find the initial limit.
3968 (let ((gnus-newsgroup-dormant nil))
3969 (gnus-summary-initial-limit show-all))
3970 (gnus-summary-initial-limit show-all))
3971 ;; Generate the summary buffer.
3973 (gnus-summary-prepare))
3974 (when gnus-use-trees
3975 (gnus-tree-open group)
3976 (setq gnus-summary-highlight-line-function
3977 'gnus-tree-highlight-article))
3978 ;; If the summary buffer is empty, but there are some low-scored
3979 ;; articles or some excluded dormants, we include these in the
3981 (when (and (zerop (buffer-size))
3983 (cond (gnus-newsgroup-dormant
3984 (gnus-summary-limit-include-dormant))
3985 ((and gnus-newsgroup-scored show-all)
3986 (gnus-summary-limit-include-expunged t))))
3987 ;; Function `gnus-apply-kill-file' must be called in this hook.
3988 (gnus-run-hooks 'gnus-apply-kill-hook)
3989 (if (and (zerop (buffer-size))
3992 ;; This newsgroup is empty.
3993 (gnus-summary-catchup-and-exit nil t)
3994 (gnus-message 6 "No unread news")
3996 (gnus-kill-or-deaden-summary kill-buffer))
3997 ;; Return nil from this function.
3999 ;; Hide conversation thread subtrees. We cannot do this in
4000 ;; gnus-summary-prepare-hook since kill processing may not
4001 ;; work with hidden articles.
4002 (gnus-summary-maybe-hide-threads)
4004 (gnus-kill-or-deaden-summary kill-buffer))
4005 (gnus-summary-auto-select-subject)
4006 ;; Show first unread article if requested.
4007 (if (and (not no-article)
4009 gnus-newsgroup-unreads
4010 gnus-auto-select-first)
4012 (gnus-configure-windows 'summary)
4013 (let ((art (gnus-summary-article-number)))
4014 (unless (and (not gnus-plugged)
4015 (or (memq art gnus-newsgroup-undownloaded)
4016 (memq art gnus-newsgroup-downloadable)))
4017 (gnus-summary-goto-article art))))
4018 ;; Don't select any articles.
4019 (gnus-summary-position-point)
4020 (gnus-configure-windows 'summary 'force)
4021 (gnus-set-mode-line 'summary))
4022 (when (and gnus-auto-center-group
4023 (get-buffer-window gnus-group-buffer t))
4024 ;; Gotta use windows, because recenter does weird stuff if
4025 ;; the current buffer ain't the displayed window.
4026 (let ((owin (selected-window)))
4027 (select-window (get-buffer-window gnus-group-buffer t))
4028 (when (gnus-group-goto-group group)
4030 (select-window owin)))
4031 ;; Mark this buffer as "prepared".
4032 (setq gnus-newsgroup-prepared t)
4033 (gnus-run-hooks 'gnus-summary-prepared-hook)
4034 (unless (gnus-ephemeral-group-p group)
4035 (gnus-group-update-group group))
4038 (defun gnus-summary-auto-select-subject ()
4039 "Select the subject line on initial group entry."
4040 (goto-char (point-min))
4042 ((eq gnus-auto-select-subject 'best)
4043 (gnus-summary-best-unread-subject))
4044 ((eq gnus-auto-select-subject 'unread)
4045 (gnus-summary-first-unread-subject))
4046 ((eq gnus-auto-select-subject 'unseen)
4047 (gnus-summary-first-unseen-subject))
4048 ((eq gnus-auto-select-subject 'unseen-or-unread)
4049 (gnus-summary-first-unseen-or-unread-subject))
4050 ((eq gnus-auto-select-subject 'first)
4053 ((functionp gnus-auto-select-subject)
4054 (funcall gnus-auto-select-subject))))
4056 (defun gnus-summary-prepare ()
4057 "Generate the summary buffer."
4059 (let ((inhibit-read-only t))
4061 (setq gnus-newsgroup-data nil
4062 gnus-newsgroup-data-reverse nil)
4063 (gnus-run-hooks 'gnus-summary-generate-hook)
4064 ;; Generate the buffer, either with threads or without.
4065 (when gnus-newsgroup-headers
4066 (gnus-summary-prepare-threads
4067 (if gnus-show-threads
4068 (gnus-sort-gathered-threads
4069 (funcall gnus-summary-thread-gathering-function
4071 (gnus-cut-threads (gnus-make-threads)))))
4072 ;; Unthreaded display.
4073 (gnus-sort-articles gnus-newsgroup-headers))))
4074 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4075 ;; Call hooks for modifying summary buffer.
4076 (goto-char (point-min))
4077 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4079 (defsubst gnus-general-simplify-subject (subject)
4080 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4083 ;; Truncate the subject.
4084 (gnus-simplify-subject-functions
4085 (gnus-map-function gnus-simplify-subject-functions subject))
4086 ((numberp gnus-summary-gather-subject-limit)
4087 (setq subject (gnus-simplify-subject-re subject))
4088 (if (> (length subject) gnus-summary-gather-subject-limit)
4089 (substring subject 0 gnus-summary-gather-subject-limit)
4091 ;; Fuzzily simplify it.
4092 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4093 (gnus-simplify-subject-fuzzy subject))
4094 ;; Just remove the leading "Re:".
4096 (gnus-simplify-subject-re subject))))
4098 (if (and gnus-summary-gather-exclude-subject
4099 (string-match gnus-summary-gather-exclude-subject subject))
4100 nil ; This article shouldn't be gathered
4103 (defun gnus-summary-simplify-subject-query ()
4104 "Query where the respool algorithm would put this article."
4106 (gnus-summary-select-article)
4107 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4109 (defun gnus-gather-threads-by-subject (threads)
4110 "Gather threads by looking at Subject headers."
4111 (if (not gnus-summary-make-false-root)
4113 (let ((hashtb (gnus-make-hashtable 1024))
4116 subject hthread whole-subject)
4118 (setq subject (gnus-general-simplify-subject
4119 (setq whole-subject (mail-header-subject
4122 (if (setq hthread (gnus-gethash subject hashtb))
4124 ;; We enter a dummy root into the thread, if we
4125 ;; haven't done that already.
4126 (unless (stringp (caar hthread))
4127 (setcar hthread (list whole-subject (car hthread))))
4128 ;; We add this new gathered thread to this gathered
4130 (setcdr (car hthread)
4131 (nconc (cdar hthread) (list (car threads))))
4132 ;; Remove it from the list of threads.
4133 (setcdr prev (cdr threads))
4134 (setq threads prev))
4135 ;; Enter this thread into the hash table.
4136 (gnus-sethash subject
4137 (if gnus-summary-make-false-root-always
4139 ;; If you want a dummy root above all
4141 (setcar threads (list whole-subject
4147 (setq threads (cdr threads)))
4150 (defun gnus-gather-threads-by-references (threads)
4151 "Gather threads by looking at References headers."
4152 (let ((idhashtb (gnus-make-hashtable 1024))
4153 (thhashtb (gnus-make-hashtable 1024))
4156 ids references id gthread gid entered ref)
4158 (when (setq references (mail-header-references (caar threads)))
4159 (setq id (mail-header-id (caar threads))
4160 ids (inline (gnus-split-references references))
4162 (while (setq ref (pop ids))
4163 (setq ids (delete ref ids))
4164 (if (not (setq gid (gnus-gethash ref idhashtb)))
4166 (gnus-sethash ref id idhashtb)
4167 (gnus-sethash id threads thhashtb))
4168 (setq gthread (gnus-gethash gid thhashtb))
4170 ;; We enter a dummy root into the thread, if we
4171 ;; haven't done that already.
4172 (unless (stringp (caar gthread))
4173 (setcar gthread (list (mail-header-subject (caar gthread))
4175 ;; We add this new gathered thread to this gathered
4177 (setcdr (car gthread)
4178 (nconc (cdar gthread) (list (car threads)))))
4179 ;; Add it into the thread hash table.
4180 (gnus-sethash id gthread thhashtb)
4182 ;; Remove it from the list of threads.
4183 (setcdr prev (cdr threads))
4184 (setq threads prev))))
4186 (setq threads (cdr threads)))
4189 (defun gnus-sort-gathered-threads (threads)
4190 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4191 (let ((result threads))
4193 (when (stringp (caar threads))
4194 (setcdr (car threads)
4195 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4196 (setq threads (cdr threads)))
4199 (defun gnus-thread-loop-p (root thread)
4200 "Say whether ROOT is in THREAD."
4201 (let ((stack (list thread))
4204 (while (setq thread (pop stack))
4205 (setq th (cdr thread))
4207 (not (eq (caar th) root)))
4210 ;; We have found a loop.
4212 (setcdr thread (delq (car th) (cdr thread)))
4213 (if (boundp (setq ref-dep (intern "none"
4214 gnus-newsgroup-dependencies)))
4215 (setcdr (symbol-value ref-dep)
4216 (nconc (cdr (symbol-value ref-dep))
4218 (set ref-dep (list nil (car th))))
4221 ;; Push all the subthreads onto the stack.
4222 (push (cdr thread) stack)))
4225 (defun gnus-make-threads ()
4226 "Go through the dependency hashtb and find the roots. Return all threads."
4228 (while (catch 'infloop
4231 ;; Deal with self-referencing References loops.
4232 (when (and (car (symbol-value refs))
4239 (car (symbol-value refs)) thread))
4240 (cdr (symbol-value refs)))))))
4243 (unless (car (symbol-value refs))
4244 ;; These threads do not refer back to any other
4245 ;; articles, so they're roots.
4246 (setq threads (append (cdr (symbol-value refs)) threads))))
4247 gnus-newsgroup-dependencies)))
4250 ;; Build the thread tree.
4251 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4252 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4254 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4255 if it was already present.
4257 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4258 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4259 Message-IDs will be renamed to a unique Message-ID before being
4262 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4263 (let* ((id (mail-header-id header))
4264 (id-dep (and id (intern id dependencies)))
4265 parent-id ref ref-dep ref-header replaced)
4266 ;; Enter this `header' in the `dependencies' table.
4270 ;; The first two cases do the normal part: enter a new `header'
4271 ;; in the `dependencies' table.
4272 ((not (boundp id-dep))
4273 (set id-dep (list header)))
4274 ((null (car (symbol-value id-dep)))
4275 (setcar (symbol-value id-dep) header))
4277 ;; From here the `header' was already present in the
4278 ;; `dependencies' table.
4280 ;; Overrides an existing entry;
4281 ;; just set the header part of the entry.
4282 (setcar (symbol-value id-dep) header)
4285 ;; Renames the existing `header' to a unique Message-ID.
4286 ((not gnus-summary-ignore-duplicates)
4287 ;; An article with this Message-ID has already been seen.
4288 ;; We rename the Message-ID.
4289 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4291 (mail-header-set-id header id))
4293 ;; The last case ignores an existing entry, except it adds any
4294 ;; additional Xrefs (in case the two articles came from different
4296 ;; Also sets `header' to `nil' meaning that the `dependencies'
4297 ;; table was *not* modified.
4299 (mail-header-set-xref
4300 (car (symbol-value id-dep))
4301 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4303 (or (mail-header-xref header) "")))
4306 (when (and header (not replaced))
4307 ;; First check that we are not creating a References loop.
4308 (setq parent-id (gnus-parent-id (mail-header-references header)))
4309 (setq ref parent-id)
4311 (setq ref-dep (intern-soft ref dependencies))
4313 (setq ref-header (car (symbol-value ref-dep))))
4314 (if (string= id ref)
4315 ;; Yuk! This is a reference loop. Make the article be a
4318 (mail-header-set-references (car (symbol-value id-dep)) "none")
4320 (setq parent-id nil))
4321 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4322 (setq ref-dep (intern (or parent-id "none") dependencies))
4323 (if (boundp ref-dep)
4324 (setcdr (symbol-value ref-dep)
4325 (nconc (cdr (symbol-value ref-dep))
4326 (list (symbol-value id-dep))))
4327 (set ref-dep (list nil (symbol-value id-dep)))))
4330 (defun gnus-extract-message-id-from-in-reply-to (string)
4331 (if (string-match "<[^>]+>" string)
4332 (substring string (match-beginning 0) (match-end 0))
4335 (defun gnus-build-sparse-threads ()
4336 (let ((headers gnus-newsgroup-headers)
4337 (mail-parse-charset gnus-newsgroup-charset)
4338 (gnus-summary-ignore-duplicates t)
4339 header references generation relations
4340 subject child end new-child date)
4341 ;; First we create an alist of generations/relations, where
4342 ;; generations is how much we trust the relation, and the relation
4344 (gnus-message 7 "Making sparse threads...")
4346 (nnheader-set-temp-buffer " *gnus sparse threads*")
4347 (while (setq header (pop headers))
4348 (when (and (setq references (mail-header-references header))
4349 (not (string= references "")))
4351 (setq child (mail-header-id header)
4352 subject (mail-header-subject header)
4353 date (mail-header-date header)
4355 (while (search-backward ">" nil t)
4356 (setq end (1+ (point)))
4357 (when (search-backward "<" nil t)
4358 (setq new-child (buffer-substring (point) end))
4359 (push (list (incf generation)
4360 child (setq child new-child)
4364 (push (list (1+ generation) child nil subject) relations))
4366 (kill-buffer (current-buffer)))
4367 ;; Sort over trustworthiness.
4368 (dolist (relation (sort relations 'car-less-than-car))
4369 (when (gnus-dependencies-add-header
4370 (make-full-mail-header
4371 gnus-reffed-article-number
4372 (nth 3 relation) "" (or (nth 4 relation) "")
4374 (or (nth 2 relation) "") 0 0 "")
4375 gnus-newsgroup-dependencies nil)
4376 (push gnus-reffed-article-number gnus-newsgroup-limit)
4377 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4378 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4379 gnus-newsgroup-reads)
4380 (decf gnus-reffed-article-number)))
4381 (gnus-message 7 "Making sparse threads...done")))
4383 (defun gnus-build-old-threads ()
4384 ;; Look at all the articles that refer back to old articles, and
4385 ;; fetch the headers for the articles that aren't there. This will
4386 ;; build complete threads - if the roots haven't been expired by the
4388 (let ((mail-parse-charset gnus-newsgroup-charset)
4392 (when (not (car (symbol-value refs)))
4393 (setq heads (cdr (symbol-value refs)))
4395 (if (memq (mail-header-number (caar heads))
4396 gnus-newsgroup-dormant)
4397 (setq heads (cdr heads))
4398 (setq id (symbol-name refs))
4399 (while (and (setq id (gnus-build-get-header id))
4400 (not (car (gnus-id-to-thread id)))))
4401 (setq heads nil)))))
4402 gnus-newsgroup-dependencies)))
4404 (defsubst gnus-remove-odd-characters (string)
4405 "Translate STRING into something that doesn't contain weird characters."
4406 (mm-subst-char-in-string
4408 (mm-subst-char-in-string ?\n ?\- string t) t))
4410 ;; This function has to be called with point after the article number
4411 ;; on the beginning of the line.
4412 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4413 (let ((eol (point-at-eol))
4414 (buffer (current-buffer))
4415 header references in-reply-to)
4417 ;; overview: [num subject from date id refs chars lines misc]
4420 (narrow-to-region (point) eol)
4425 (make-full-mail-header
4427 (condition-case () ; subject
4428 (gnus-remove-odd-characters
4429 (funcall gnus-decode-encoded-word-function
4430 (setq x (nnheader-nov-field))))
4432 (condition-case () ; from
4433 (gnus-remove-odd-characters
4434 (funcall gnus-decode-encoded-address-function
4435 (setq x (nnheader-nov-field))))
4437 (nnheader-nov-field) ; date
4438 (nnheader-nov-read-message-id number) ; id
4439 (setq references (nnheader-nov-field)) ; refs
4440 (nnheader-nov-read-integer) ; chars
4441 (nnheader-nov-read-integer) ; lines
4443 (if (looking-at "Xref: ")
4444 (goto-char (match-end 0)))
4445 (nnheader-nov-field)) ; Xref
4446 (nnheader-nov-parse-extra)))) ; extra
4450 (when (and (string= references "")
4451 (setq in-reply-to (mail-header-extra header))
4452 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4453 (mail-header-set-references
4454 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4456 (when gnus-alter-header-function
4457 (funcall gnus-alter-header-function header))
4458 (gnus-dependencies-add-header header dependencies force-new)))
4460 (defun gnus-build-get-header (id)
4461 "Look through the buffer of NOV lines and find the header to ID.
4462 Enter this line into the dependencies hash table, and return
4463 the id of the parent article (if any)."
4464 (let ((deps gnus-newsgroup-dependencies)
4467 (with-current-buffer nntp-server-buffer
4468 (let ((case-fold-search nil))
4469 (goto-char (point-min))
4470 (while (and (not found)
4471 (search-forward id nil t))
4473 (setq found (looking-at
4474 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4475 (regexp-quote id))))
4476 (or found (beginning-of-line 2)))
4480 (setq header (gnus-nov-parse-line
4481 (read (current-buffer)) deps))
4482 (gnus-parent-id (mail-header-references header))))))
4484 (let ((number (mail-header-number header)))
4485 (push number gnus-newsgroup-limit)
4486 (push header gnus-newsgroup-headers)
4487 (if (memq number gnus-newsgroup-unselected)
4489 (setq gnus-newsgroup-unreads
4490 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4492 (setq gnus-newsgroup-unselected
4493 (delq number gnus-newsgroup-unselected)))
4494 (push number gnus-newsgroup-ancient)))))))
4496 (defun gnus-build-all-threads ()
4497 "Read all the headers."
4498 (let ((gnus-summary-ignore-duplicates t)
4499 (mail-parse-charset gnus-newsgroup-charset)
4500 (dependencies gnus-newsgroup-dependencies)
4502 (with-current-buffer nntp-server-buffer
4503 (let ((case-fold-search nil))
4504 (goto-char (point-min))
4507 (setq article (read (current-buffer))
4508 header (gnus-nov-parse-line article dependencies)))
4510 (with-current-buffer gnus-summary-buffer
4511 (push header gnus-newsgroup-headers)
4512 (if (memq (setq article (mail-header-number header))
4513 gnus-newsgroup-unselected)
4515 (setq gnus-newsgroup-unreads
4516 (gnus-add-to-sorted-list
4517 gnus-newsgroup-unreads article))
4518 (setq gnus-newsgroup-unselected
4519 (delq article gnus-newsgroup-unselected)))
4520 (push article gnus-newsgroup-ancient)))
4521 (forward-line 1)))))))
4523 (defun gnus-summary-update-article-line (article header)
4524 "Update the line for ARTICLE using HEADER."
4525 (let* ((id (mail-header-id header))
4526 (thread (gnus-id-to-thread id)))
4528 (error "Article in no thread"))
4529 ;; Update the thread.
4530 (setcar thread header)
4531 (gnus-summary-goto-subject article)
4532 (let* ((datal (gnus-data-find-list article))
4534 (inhibit-read-only t)
4535 (level (gnus-summary-thread-level)))
4537 (let ((inserted (- (point)
4539 (gnus-summary-insert-line
4541 (memq article gnus-newsgroup-undownloaded)
4542 (gnus-article-mark article)
4543 (memq article gnus-newsgroup-replied)
4544 (memq article gnus-newsgroup-expirable)
4545 ;; Only insert the Subject string when it's different
4546 ;; from the previous Subject string.
4551 (mail-header-subject
4554 (gnus-data-find-list
4556 (gnus-data-list t)))))
4557 ;; Error on the side of excessive subjects.
4559 (mail-header-subject header)))
4561 (mail-header-subject header))
4562 nil (cdr (assq article gnus-newsgroup-scored))
4563 (memq article gnus-newsgroup-processable))
4566 (gnus-data-update-list
4568 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4570 (defun gnus-summary-update-article (article &optional iheader)
4571 "Update ARTICLE in the summary buffer."
4572 (set-buffer gnus-summary-buffer)
4573 (let* ((header (gnus-summary-article-header article))
4574 (id (mail-header-id header))
4575 (data (gnus-data-find article))
4576 (thread (gnus-id-to-thread id))
4577 (references (mail-header-references header))
4581 (when (and references
4582 (not (equal "" references)))
4585 (inhibit-read-only t)
4591 (delq thread parent)))
4592 (if (gnus-summary-insert-subject id header)
4593 ;; Set the (possibly) new article number in the data structure.
4594 (gnus-data-set-number data (gnus-id-to-article id))
4598 (defun gnus-rebuild-thread (id &optional line)
4599 "Rebuild the thread containing ID.
4600 If LINE, insert the rebuilt thread starting on line LINE."
4601 (let ((inhibit-read-only t)
4602 old-pos current thread data)
4603 (if (not gnus-show-threads)
4604 (setq thread (list (car (gnus-id-to-thread id))))
4605 ;; Get the thread this article is part of.
4606 (setq thread (gnus-remove-thread id)))
4607 (setq old-pos (point-at-bol))
4608 (setq current (save-excursion
4609 (and (re-search-backward "[\r\n]" nil t)
4610 (gnus-summary-article-number))))
4611 ;; If this is a gathered thread, we have to go some re-gathering.
4612 (when (stringp (car thread))
4613 (let ((subject (car thread))
4615 (setq thread (cdr thread))
4617 (unless (memq (setq thr (gnus-id-to-thread
4619 (mail-header-id (caar thread)))))
4622 (setq thread (cdr thread)))
4623 ;; We now have all (unique) roots.
4624 (if (= (length roots) 1)
4625 ;; All the loose roots are now one solid root.
4626 (setq thread (car roots))
4627 (setq thread (cons subject (gnus-sort-threads roots))))))
4629 ;; We then insert this thread into the summary buffer.
4631 (goto-char (point-min))
4632 (forward-line (1- line)))
4633 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4634 (if gnus-show-threads
4635 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4636 (gnus-summary-prepare-unthreaded thread))
4637 (setq data (nreverse gnus-newsgroup-data))
4638 (setq threads gnus-newsgroup-threads))
4639 ;; We splice the new data into the data structure.
4640 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4641 ;;!!! then we want to insert at the beginning of the buffer.
4642 ;;!!! That happens to be true with Gnus now, but that may
4643 ;;!!! change in the future. Perhaps.
4644 (gnus-data-enter-list
4645 (if line nil current) data (- (point) old-pos))
4646 (setq gnus-newsgroup-threads
4647 (nconc threads gnus-newsgroup-threads))
4648 (gnus-data-compute-positions))))
4650 (defun gnus-number-to-header (number)
4651 "Return the header for article NUMBER."
4652 (let ((headers gnus-newsgroup-headers))
4654 (not (= number (mail-header-number (car headers)))))
4659 (defun gnus-parent-headers (in-headers &optional generation)
4660 "Return the headers of the GENERATIONeth parent of HEADERS."
4662 (setq generation 1))
4664 (headers in-headers)
4667 (not (zerop generation))
4668 (setq references (mail-header-references headers)))
4669 (setq headers (if (and references
4670 (setq parent (gnus-parent-id references)))
4671 (car (gnus-id-to-thread parent))
4674 (and (not (eq headers in-headers))
4677 (defun gnus-id-to-thread (id)
4678 "Return the (sub-)thread where ID appears."
4679 (gnus-gethash id gnus-newsgroup-dependencies))
4681 (defun gnus-id-to-article (id)
4682 "Return the article number of ID."
4683 (let ((thread (gnus-id-to-thread id)))
4686 (mail-header-number (car thread)))))
4688 (defun gnus-id-to-header (id)
4689 "Return the article headers of ID."
4690 (car (gnus-id-to-thread id)))
4692 (defun gnus-article-displayed-root-p (article)
4693 "Say whether ARTICLE is a root(ish) article."
4694 (let ((level (gnus-summary-thread-level article))
4695 (refs (mail-header-references (gnus-summary-article-header article)))
4701 ((null (gnus-parent-id refs)) t)
4703 (null (setq particle (gnus-id-to-article
4704 (gnus-parent-id refs))))
4705 (null (gnus-summary-thread-level particle)))))))
4707 (defun gnus-root-id (id)
4708 "Return the id of the root of the thread where ID appears."
4710 (while (and id (setq prev (car (gnus-id-to-thread id))))
4712 id (gnus-parent-id (mail-header-references prev))))
4715 (defun gnus-articles-in-thread (thread)
4716 "Return the list of articles in THREAD."
4717 (cons (mail-header-number (car thread))
4718 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4720 (defun gnus-remove-thread (id &optional dont-remove)
4721 "Remove the thread that has ID in it."
4722 (let (headers thread last-id)
4723 ;; First go up in this thread until we find the root.
4724 (setq last-id (gnus-root-id id)
4725 headers (message-flatten-list (gnus-id-to-thread last-id)))
4726 ;; We have now found the real root of this thread. It might have
4727 ;; been gathered into some loose thread, so we have to search
4728 ;; through the threads to find the thread we wanted.
4729 (let ((threads gnus-newsgroup-threads)
4732 (setq sub (car threads))
4733 (if (stringp (car sub))
4734 ;; This is a gathered thread, so we look at the roots
4735 ;; below it to find whether this article is in this
4738 (setq sub (cdr sub))
4740 (when (member (caar sub) headers)
4741 (setq thread (car threads)
4744 (setq sub (cdr sub))))
4745 ;; It's an ordinary thread, so we check it.
4746 (when (eq (car sub) (car headers))
4749 (setq threads (cdr threads)))
4750 ;; If this article is in no thread, then it's a root.
4753 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4754 (setq thread (gnus-id-to-thread last-id)))
4757 thread ; We return this thread.
4759 (if (stringp (car thread))
4761 ;; If we use dummy roots, then we have to remove the
4762 ;; dummy root as well.
4763 (when (eq gnus-summary-make-false-root 'dummy)
4764 ;; We go to the dummy root by going to
4765 ;; the first sub-"thread", and then one line up.
4766 (gnus-summary-goto-article
4767 (mail-header-number (caadr thread)))
4770 (gnus-data-compute-positions))
4771 (setq thread (cdr thread))
4773 (gnus-remove-thread-1 (car thread))
4774 (setq thread (cdr thread))))
4775 (gnus-remove-thread-1 thread))))))))
4777 (defun gnus-remove-thread-1 (thread)
4778 "Remove the thread THREAD recursively."
4779 (let ((number (mail-header-number (pop thread)))
4781 (setq thread (reverse thread))
4783 (gnus-remove-thread-1 (pop thread)))
4784 (when (setq d (gnus-data-find number))
4785 (goto-char (gnus-data-pos d))
4786 (gnus-summary-show-thread)
4792 (gnus-delete-line)))))))
4794 (defun gnus-sort-threads-recursive (threads func)
4795 (sort (mapcar (lambda (thread)
4798 (gnus-sort-threads-recursive (cdr thread) func))))
4801 (defun gnus-sort-threads-loop (threads func)
4802 (let* ((superthread (cons nil threads))
4803 (stack (list (cons superthread threads)))
4804 remaining-threads thread)
4806 (setq remaining-threads (cdr (car stack)))
4807 (if remaining-threads
4808 (progn (setq thread (car remaining-threads))
4809 (setcdr (car stack) (cdr remaining-threads))
4811 (push (cons thread (cdr thread)) stack)))
4812 (setq thread (caar stack))
4813 (setcdr thread (sort (cdr thread) func))
4817 (defun gnus-sort-threads (threads)
4819 (if (not gnus-thread-sort-functions)
4821 (gnus-message 8 "Sorting threads...")
4824 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4825 (gnus-sort-threads-recursive
4826 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4827 ;; Even after binding max-lisp-eval-depth, the recursive
4828 ;; sorter might fail for very long threads. In that case,
4829 ;; try using a (less well-tested) non-recursive sorter.
4830 (error (gnus-message 9 "Sorting threads with loop...")
4831 (gnus-sort-threads-loop
4832 threads (gnus-make-sort-function
4833 gnus-thread-sort-functions))))
4834 (gnus-message 8 "Sorting threads...done"))))
4836 (defun gnus-sort-articles (articles)
4838 (when gnus-article-sort-functions
4839 (gnus-message 7 "Sorting articles...")
4841 (setq gnus-newsgroup-headers
4842 (sort articles (gnus-make-sort-function
4843 gnus-article-sort-functions)))
4844 (gnus-message 7 "Sorting articles...done"))))
4846 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4847 (defmacro gnus-thread-header (thread)
4848 "Return header of first article in THREAD.
4849 Note that THREAD must never, ever be anything else than a variable -
4850 using some other form will lead to serious barfage."
4851 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4852 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4853 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4856 (defsubst gnus-article-sort-by-number (h1 h2)
4857 "Sort articles by article number."
4858 (< (mail-header-number h1)
4859 (mail-header-number h2)))
4861 (defun gnus-thread-sort-by-number (h1 h2)
4862 "Sort threads by root article number."
4863 (gnus-article-sort-by-number
4864 (gnus-thread-header h1) (gnus-thread-header h2)))
4866 (defsubst gnus-article-sort-by-random (h1 h2)
4867 "Sort articles randomly."
4870 (defun gnus-thread-sort-by-random (h1 h2)
4871 "Sort threads randomly."
4872 (gnus-article-sort-by-random
4873 (gnus-thread-header h1) (gnus-thread-header h2)))
4875 (defsubst gnus-article-sort-by-lines (h1 h2)
4876 "Sort articles by article Lines header."
4877 (< (mail-header-lines h1)
4878 (mail-header-lines h2)))
4880 (defun gnus-thread-sort-by-lines (h1 h2)
4881 "Sort threads by root article Lines header."
4882 (gnus-article-sort-by-lines
4883 (gnus-thread-header h1) (gnus-thread-header h2)))
4885 (defsubst gnus-article-sort-by-chars (h1 h2)
4886 "Sort articles by octet length."
4887 (< (mail-header-chars h1)
4888 (mail-header-chars h2)))
4890 (defun gnus-thread-sort-by-chars (h1 h2)
4891 "Sort threads by root article octet length."
4892 (gnus-article-sort-by-chars
4893 (gnus-thread-header h1) (gnus-thread-header h2)))
4895 (defsubst gnus-article-sort-by-author (h1 h2)
4896 "Sort articles by root author."
4898 (let ((extract (funcall
4899 gnus-extract-address-components
4900 (mail-header-from h1))))
4901 (or (car extract) (cadr extract) ""))
4902 (let ((extract (funcall
4903 gnus-extract-address-components
4904 (mail-header-from h2))))
4905 (or (car extract) (cadr extract) ""))))
4907 (defun gnus-thread-sort-by-author (h1 h2)
4908 "Sort threads by root author."
4909 (gnus-article-sort-by-author
4910 (gnus-thread-header h1) (gnus-thread-header h2)))
4912 (defsubst gnus-article-sort-by-recipient (h1 h2)
4913 "Sort articles by recipient."
4915 (let ((extract (funcall
4916 gnus-extract-address-components
4917 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4918 (or (car extract) (cadr extract)))
4919 (let ((extract (funcall
4920 gnus-extract-address-components
4921 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4922 (or (car extract) (cadr extract)))))
4924 (defun gnus-thread-sort-by-recipient (h1 h2)
4925 "Sort threads by root recipient."
4926 (gnus-article-sort-by-recipient
4927 (gnus-thread-header h1) (gnus-thread-header h2)))
4929 (defsubst gnus-article-sort-by-subject (h1 h2)
4930 "Sort articles by root subject."
4932 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4933 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4935 (defun gnus-thread-sort-by-subject (h1 h2)
4936 "Sort threads by root subject."
4937 (gnus-article-sort-by-subject
4938 (gnus-thread-header h1) (gnus-thread-header h2)))
4940 (defsubst gnus-article-sort-by-date (h1 h2)
4941 "Sort articles by root article date."
4943 (gnus-date-get-time (mail-header-date h1))
4944 (gnus-date-get-time (mail-header-date h2))))
4946 (defun gnus-thread-sort-by-date (h1 h2)
4947 "Sort threads by root article date."
4948 (gnus-article-sort-by-date
4949 (gnus-thread-header h1) (gnus-thread-header h2)))
4951 (defsubst gnus-article-sort-by-score (h1 h2)
4952 "Sort articles by root article score.
4953 Unscored articles will be counted as having a score of zero."
4954 (> (or (cdr (assq (mail-header-number h1)
4955 gnus-newsgroup-scored))
4956 gnus-summary-default-score 0)
4957 (or (cdr (assq (mail-header-number h2)
4958 gnus-newsgroup-scored))
4959 gnus-summary-default-score 0)))
4961 (defun gnus-thread-sort-by-score (h1 h2)
4962 "Sort threads by root article score."
4963 (gnus-article-sort-by-score
4964 (gnus-thread-header h1) (gnus-thread-header h2)))
4966 (defun gnus-thread-sort-by-total-score (h1 h2)
4967 "Sort threads by the sum of all scores in the thread.
4968 Unscored articles will be counted as having a score of zero."
4969 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4971 (defun gnus-thread-total-score (thread)
4972 ;; This function find the total score of THREAD.
4977 (if (stringp (car thread))
4978 (apply gnus-thread-score-function 0
4979 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4980 (gnus-thread-total-score-1 thread)))
4982 (gnus-thread-total-score-1 (list thread)))))
4984 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4985 "Sort threads such that the thread with the most recently arrived article comes first."
4986 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4988 (defun gnus-thread-highest-number (thread)
4989 "Return the highest article number in THREAD."
4990 (apply 'max (mapcar (lambda (header)
4991 (mail-header-number header))
4992 (message-flatten-list thread))))
4994 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4995 "Sort threads such that the thread with the most recently dated article comes first."
4996 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4998 ; Since this is called not only to sort the top-level threads, but
4999 ; also in recursive sorts to order the articles within a thread, each
5000 ; article will be processed many times. Thus it speeds things up
5001 ; quite a bit to use gnus-date-get-time, which caches the time value.
5002 (defun gnus-thread-latest-date (thread)
5003 "Return the highest article date in THREAD."
5005 (mapcar (lambda (header) (gnus-float-time
5007 (mail-header-date header))))
5008 (message-flatten-list thread))))
5010 (defun gnus-thread-total-score-1 (root)
5011 ;; This function find the total score of the thread below ROOT.
5012 (setq root (car root))
5013 (apply gnus-thread-score-function
5015 (mapcar 'gnus-thread-total-score
5016 (cdr (gnus-id-to-thread (mail-header-id root))))
5017 (when (> (mail-header-number root) 0)
5018 (list (or (cdr (assq (mail-header-number root)
5019 gnus-newsgroup-scored))
5020 gnus-summary-default-score 0))))
5021 (list gnus-summary-default-score)
5024 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5025 (defvar gnus-tmp-prev-subject nil)
5026 (defvar gnus-tmp-false-parent nil)
5027 (defvar gnus-tmp-root-expunged nil)
5028 (defvar gnus-tmp-dummy-line nil)
5030 (defun gnus-extra-header (type &optional header)
5031 "Return the extra header of TYPE."
5032 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5035 (defvar gnus-tmp-thread-tree-header-string "")
5037 (defcustom gnus-sum-thread-tree-root "> "
5038 "With %B spec, used for the root of a thread.
5039 If nil, use subject instead."
5041 :type '(radio (const :format "%v " nil) string)
5042 :group 'gnus-thread)
5044 (defcustom gnus-sum-thread-tree-false-root "> "
5045 "With %B spec, used for a false root of a thread.
5046 If nil, use subject instead."
5048 :type '(radio (const :format "%v " nil) string)
5049 :group 'gnus-thread)
5051 (defcustom gnus-sum-thread-tree-single-indent ""
5052 "With %B spec, used for a thread with just one message.
5053 If nil, use subject instead."
5055 :type '(radio (const :format "%v " nil) string)
5056 :group 'gnus-thread)
5058 (defcustom gnus-sum-thread-tree-vertical "| "
5059 "With %B spec, used for drawing a vertical line."
5062 :group 'gnus-thread)
5064 (defcustom gnus-sum-thread-tree-indent " "
5065 "With %B spec, used for indenting."
5068 :group 'gnus-thread)
5070 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5071 "With %B spec, used for a leaf with brothers."
5074 :group 'gnus-thread)
5076 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5077 "With %B spec, used for a leaf without brothers."
5080 :group 'gnus-thread)
5082 (defcustom gnus-summary-display-while-building nil
5083 "If non-nil, show and update the summary buffer as it's being built.
5084 If the value is t, update the buffer after every line is inserted. If
5085 the value is an integer (N), update the display every N lines."
5088 :type '(choice (const :tag "off" nil)
5090 (const :tag "frequently" t)))
5092 (defun gnus-summary-prepare-threads (threads)
5093 "Prepare summary buffer from THREADS and indentation LEVEL.
5094 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5095 or a straight list of headers."
5096 (gnus-message 7 "Generating summary...")
5098 (setq gnus-newsgroup-threads threads)
5101 (let ((gnus-tmp-level 0)
5102 (default-score (or gnus-summary-default-score 0))
5103 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5104 (building-line-count gnus-summary-display-while-building)
5105 (building-count (integerp gnus-summary-display-while-building))
5106 thread number subject stack state gnus-tmp-gathered beg-match
5107 new-roots gnus-tmp-new-adopts thread-end simp-subject
5108 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5109 gnus-tmp-replied gnus-tmp-subject-or-nil
5110 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5111 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5112 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5115 (setq gnus-tmp-prev-subject nil
5116 gnus-tmp-thread-tree-header-string "")
5118 (if (vectorp (car threads))
5119 ;; If this is a straight (sic) list of headers, then a
5120 ;; threaded summary display isn't required, so we just create
5121 ;; an unthreaded one.
5122 (gnus-summary-prepare-unthreaded threads)
5124 ;; Do the threaded display.
5126 (if gnus-summary-display-while-building
5127 (switch-to-buffer (buffer-name)))
5128 (while (or threads stack gnus-tmp-new-adopts new-roots)
5130 (if (and (= gnus-tmp-level 0)
5133 (not gnus-tmp-false-parent)
5134 (or gnus-tmp-new-adopts new-roots))
5135 (if gnus-tmp-new-adopts
5136 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5137 thread (list (car gnus-tmp-new-adopts))
5138 gnus-tmp-header (caar thread)
5139 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5141 (setq thread (list (car new-roots))
5142 gnus-tmp-header (caar thread)
5143 new-roots (cdr new-roots))))
5146 ;; If there are some threads, we do them before the
5147 ;; threads on the stack.
5148 (setq thread threads
5149 gnus-tmp-header (caar thread))
5150 ;; There were no current threads, so we pop something off
5152 (setq state (car stack)
5153 gnus-tmp-level (car state)
5154 tree-stack (cadr state)
5155 thread (caddr state)
5157 gnus-tmp-header (caar thread))))
5159 (setq gnus-tmp-false-parent nil)
5160 (setq gnus-tmp-root-expunged nil)
5161 (setq thread-end nil)
5163 (if (stringp gnus-tmp-header)
5164 ;; The header is a dummy root.
5166 ((eq gnus-summary-make-false-root 'adopt)
5167 ;; We let the first article adopt the rest.
5168 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5170 (setq gnus-tmp-gathered
5172 (lambda (h) (mail-header-number (car h)))
5175 (setq thread (cons (list (caar thread)
5178 (setq gnus-tmp-level -1
5179 gnus-tmp-false-parent t))
5180 ((eq gnus-summary-make-false-root 'empty)
5181 ;; We print adopted articles with empty subject fields.
5182 (setq gnus-tmp-gathered
5184 (lambda (h) (mail-header-number (car h)))
5187 (setq gnus-tmp-level -1))
5188 ((eq gnus-summary-make-false-root 'dummy)
5189 ;; We remember that we probably want to output a dummy
5191 (setq gnus-tmp-dummy-line gnus-tmp-header)
5192 (setq gnus-tmp-prev-subject gnus-tmp-header))
5194 ;; We do not make a root for the gathered
5195 ;; sub-threads at all.
5196 (setq gnus-tmp-level -1)))
5198 (setq number (mail-header-number gnus-tmp-header)
5199 subject (mail-header-subject gnus-tmp-header)
5200 simp-subject (gnus-simplify-subject-fully subject))
5203 ;; If the thread has changed subject, we might want to make
5204 ;; this subthread into a root.
5205 ((and (null gnus-thread-ignore-subject)
5206 (not (zerop gnus-tmp-level))
5207 gnus-tmp-prev-subject
5208 (not (string= gnus-tmp-prev-subject simp-subject)))
5209 (setq new-roots (nconc new-roots (list (car thread)))
5211 gnus-tmp-header nil))
5212 ;; If the article lies outside the current limit,
5213 ;; then we do not display it.
5214 ((not (memq number gnus-newsgroup-limit))
5215 (setq gnus-tmp-gathered
5217 (lambda (h) (mail-header-number (car h)))
5220 (setq gnus-tmp-new-adopts (if (cdar thread)
5221 (append gnus-tmp-new-adopts
5223 gnus-tmp-new-adopts)
5225 gnus-tmp-header nil)
5226 (when (zerop gnus-tmp-level)
5227 (setq gnus-tmp-root-expunged t)))
5228 ;; Perhaps this article is to be marked as read?
5229 ((and gnus-summary-mark-below
5230 (< (or (cdr (assq number gnus-newsgroup-scored))
5232 gnus-summary-mark-below)
5233 ;; Don't touch sparse articles.
5234 (not (gnus-summary-article-sparse-p number))
5235 (not (gnus-summary-article-ancient-p number)))
5236 (setq gnus-newsgroup-unreads
5237 (delq number gnus-newsgroup-unreads))
5238 (if gnus-newsgroup-auto-expire
5239 (setq gnus-newsgroup-expirable
5240 (gnus-add-to-sorted-list
5241 gnus-newsgroup-expirable number))
5242 (push (cons number gnus-low-score-mark)
5243 gnus-newsgroup-reads))))
5245 (when gnus-tmp-header
5246 ;; We may have an old dummy line to output before this
5248 (when (and gnus-tmp-dummy-line
5251 (mail-header-subject gnus-tmp-header)))
5252 (gnus-summary-insert-dummy-line
5253 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5254 (setq gnus-tmp-dummy-line nil))
5256 ;; Compute the mark.
5257 (setq gnus-tmp-unread (gnus-article-mark number))
5259 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5260 gnus-tmp-header gnus-tmp-level)
5261 gnus-newsgroup-data)
5263 ;; Actually insert the line.
5265 gnus-tmp-subject-or-nil
5267 ((and gnus-thread-ignore-subject
5268 gnus-tmp-prev-subject
5269 (not (string= gnus-tmp-prev-subject simp-subject)))
5271 ((zerop gnus-tmp-level)
5272 (if (and (eq gnus-summary-make-false-root 'empty)
5273 (memq number gnus-tmp-gathered)
5274 gnus-tmp-prev-subject
5275 (string= gnus-tmp-prev-subject simp-subject))
5276 gnus-summary-same-subject
5278 (t gnus-summary-same-subject)))
5279 (if (and (eq gnus-summary-make-false-root 'adopt)
5280 (= gnus-tmp-level 1)
5281 (memq number gnus-tmp-gathered))
5282 (setq gnus-tmp-opening-bracket ?\<
5283 gnus-tmp-closing-bracket ?\>)
5284 (setq gnus-tmp-opening-bracket ?\[
5285 gnus-tmp-closing-bracket ?\]))
5286 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5287 (gnus-make-thread-indent-array
5288 (max (* 2 (length gnus-thread-indent-array))
5291 gnus-tmp-indentation
5292 (aref gnus-thread-indent-array gnus-tmp-level)
5293 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5294 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5295 gnus-summary-default-score 0)
5297 (if (or (null gnus-summary-default-score)
5298 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5299 gnus-summary-zcore-fuzz))
5301 (if (< gnus-tmp-score gnus-summary-default-score)
5302 gnus-score-below-mark gnus-score-over-mark))
5304 (cond ((memq number gnus-newsgroup-processable)
5306 ((memq number gnus-newsgroup-cached)
5308 ((memq number gnus-newsgroup-replied)
5310 ((memq number gnus-newsgroup-forwarded)
5311 gnus-forwarded-mark)
5312 ((memq number gnus-newsgroup-saved)
5314 ((memq number gnus-newsgroup-recent)
5316 ((memq number gnus-newsgroup-unseen)
5320 (cond ((memq number gnus-newsgroup-undownloaded)
5321 gnus-undownloaded-mark)
5322 (gnus-newsgroup-agentized
5323 gnus-downloaded-mark)
5326 gnus-tmp-from (mail-header-from gnus-tmp-header)
5329 ((string-match "<[^>]+> *$" gnus-tmp-from)
5330 (setq beg-match (match-beginning 0))
5331 (or (and (string-match "^\".+\"" gnus-tmp-from)
5332 (substring gnus-tmp-from 1 (1- (match-end 0))))
5333 (substring gnus-tmp-from 0 beg-match)))
5334 ((string-match "(.+)" gnus-tmp-from)
5335 (substring gnus-tmp-from
5336 (1+ (match-beginning 0)) (1- (match-end 0))))
5340 gnus-tmp-thread-tree-header-string
5342 ((not gnus-show-threads) "")
5343 ((zerop gnus-tmp-level)
5344 (cond ((cdar thread)
5345 (or gnus-sum-thread-tree-root subject))
5346 (gnus-tmp-new-adopts
5347 (or gnus-sum-thread-tree-false-root subject))
5349 (or gnus-sum-thread-tree-single-indent subject))))
5351 (concat (apply 'concat
5352 (mapcar (lambda (item)
5354 gnus-sum-thread-tree-vertical
5355 gnus-sum-thread-tree-indent))
5356 (cdr (reverse tree-stack))))
5358 gnus-sum-thread-tree-leaf-with-other
5359 gnus-sum-thread-tree-single-leaf)))))
5360 (when (string= gnus-tmp-name "")
5361 (setq gnus-tmp-name gnus-tmp-from))
5362 (unless (numberp gnus-tmp-lines)
5363 (setq gnus-tmp-lines -1))
5364 (if (= gnus-tmp-lines -1)
5365 (setq gnus-tmp-lines "?")
5366 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5367 (gnus-put-text-property
5369 (progn (eval gnus-summary-line-format-spec) (point))
5370 'gnus-number number)
5373 (gnus-summary-highlight-line)
5374 (when gnus-summary-update-hook
5375 (gnus-run-hooks 'gnus-summary-update-hook))
5378 (setq gnus-tmp-prev-subject simp-subject)))
5380 (when (nth 1 thread)
5381 (push (list (max 0 gnus-tmp-level)
5382 (copy-sequence tree-stack)
5385 (push (if (nth 1 thread) 1 0) tree-stack)
5386 (incf gnus-tmp-level)
5387 (setq threads (if thread-end nil (cdar thread)))
5388 (if gnus-summary-display-while-building
5391 ;; use a set frequency
5392 (setq building-line-count (1- building-line-count))
5393 (when (= building-line-count 0)
5395 (setq building-line-count
5396 gnus-summary-display-while-building)))
5400 (setq gnus-tmp-level 0)))))
5401 (gnus-message 7 "Generating summary...done"))
5403 (defun gnus-summary-prepare-unthreaded (headers)
5404 "Generate an unthreaded summary buffer based on HEADERS."
5405 (let (header number mark)
5410 ;; We may have to root out some bad articles...
5411 (when (memq (setq number (mail-header-number
5412 (setq header (pop headers))))
5413 gnus-newsgroup-limit)
5414 ;; Mark article as read when it has a low score.
5415 (when (and gnus-summary-mark-below
5416 (< (or (cdr (assq number gnus-newsgroup-scored))
5417 gnus-summary-default-score 0)
5418 gnus-summary-mark-below)
5419 (not (gnus-summary-article-ancient-p number)))
5420 (setq gnus-newsgroup-unreads
5421 (delq number gnus-newsgroup-unreads))
5422 (if gnus-newsgroup-auto-expire
5423 (push number gnus-newsgroup-expirable)
5424 (push (cons number gnus-low-score-mark)
5425 gnus-newsgroup-reads)))
5427 (setq mark (gnus-article-mark number))
5428 (push (gnus-data-make number mark (1+ (point)) header 0)
5429 gnus-newsgroup-data)
5430 (gnus-summary-insert-line
5432 (memq number gnus-newsgroup-undownloaded)
5433 mark (memq number gnus-newsgroup-replied)
5434 (memq number gnus-newsgroup-expirable)
5435 (mail-header-subject header) nil
5436 (cdr (assq number gnus-newsgroup-scored))
5437 (memq number gnus-newsgroup-processable))))))
5439 (defun gnus-summary-remove-list-identifiers ()
5440 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5441 (let ((regexp (if (consp gnus-list-identifiers)
5442 (mapconcat 'identity gnus-list-identifiers " *\\|")
5443 gnus-list-identifiers))
5446 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5447 (dolist (header gnus-newsgroup-headers)
5448 (setq subject (mail-header-subject header)
5450 (while (string-match regexp subject)
5452 (concat (substring subject 0 (match-beginning 1))
5453 (substring subject (match-end 0)))
5456 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5458 (concat (substring subject 0 (match-beginning 1))
5459 (substring subject (match-end 1)))))
5460 (mail-header-set-subject header subject))))))
5462 (defun gnus-fetch-headers (articles)
5463 "Fetch headers of ARTICLES."
5464 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5465 (gnus-message 5 "Fetching headers for %s..." name)
5468 (setq gnus-headers-retrieved-by
5469 (gnus-retrieve-headers
5470 articles gnus-newsgroup-name
5471 ;; We might want to fetch old headers, but
5472 ;; not if there is only 1 article.
5474 (not (eq gnus-fetch-old-headers 'some))
5475 (not (numberp gnus-fetch-old-headers)))
5476 (> (length articles) 1))
5477 gnus-fetch-old-headers))))
5478 (gnus-get-newsgroup-headers-xover
5479 articles nil nil gnus-newsgroup-name t)
5480 (gnus-get-newsgroup-headers))
5481 (gnus-message 5 "Fetching headers for %s...done" name))))
5483 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5484 "Select newsgroup GROUP.
5485 If READ-ALL is non-nil, all articles in the group are selected.
5486 If SELECT-ARTICLES, only select those articles from GROUP."
5487 (let* ((entry (gnus-group-entry group))
5488 ;;!!! Dirty hack; should be removed.
5489 (gnus-summary-ignore-duplicates
5490 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5492 gnus-summary-ignore-duplicates))
5493 (info (nth 2 entry))
5494 charset articles fetched-articles cached)
5496 (unless (gnus-check-server
5497 (set (make-local-variable 'gnus-current-select-method)
5498 (gnus-find-method-for-group group)))
5499 (error "Couldn't open server"))
5500 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5502 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5503 (gnus-activate-group group) ; Or we can activate it...
5504 (progn ; Or we bug out.
5505 (when (equal major-mode 'gnus-summary-mode)
5506 (gnus-kill-buffer (current-buffer)))
5508 "Couldn't activate group %s: %s"
5509 (mm-decode-coding-string group charset)
5510 (mm-decode-coding-string (gnus-status-message group) charset))))
5512 (unless (gnus-request-group group t)
5513 (when (equal major-mode 'gnus-summary-mode)
5514 (gnus-kill-buffer (current-buffer)))
5515 (error "Couldn't request group %s: %s"
5516 (mm-decode-coding-string group charset)
5517 (mm-decode-coding-string (gnus-status-message group) charset)))
5520 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5522 (setq gnus-summary-use-undownloaded-faces
5523 (gnus-agent-find-parameter
5525 'agent-enable-undownloaded-faces)))
5527 (setq gnus-newsgroup-name group
5528 gnus-newsgroup-unselected nil
5529 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5531 (let ((display (gnus-group-find-parameter group 'display)))
5532 (setq gnus-newsgroup-display
5534 ((not (zerop (or (car-safe read-all) 0)))
5535 ;; The user entered the group with C-u SPC/RET, let's show
5541 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5543 ;; The following is probably the "correct" solution, but
5544 ;; it makes Gnus fetch all headers and then limit the
5545 ;; articles (which is slow), so instead we hack the
5546 ;; select-articles parameter instead. -- Simon Josefsson
5549 ;; (gnus-byte-compile
5550 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5552 (setq select-articles
5553 (gnus-uncompress-range
5554 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5558 (cdr (gnus-active group)))))
5563 (gnus-summary-setup-default-charset)
5565 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5566 (when (gnus-virtual-group-p group)
5567 (setq cached gnus-newsgroup-cached))
5569 (setq gnus-newsgroup-unreads
5570 (gnus-sorted-ndifference
5571 (gnus-sorted-ndifference gnus-newsgroup-unreads
5572 gnus-newsgroup-marked)
5573 gnus-newsgroup-dormant))
5575 (setq gnus-newsgroup-processable nil)
5577 (gnus-update-read-articles group gnus-newsgroup-unreads)
5579 ;; Adjust and set lists of article marks.
5581 (gnus-adjust-marked-articles info))
5582 (if (setq articles select-articles)
5583 (setq gnus-newsgroup-unselected
5584 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5585 (setq articles (gnus-articles-to-read group read-all)))
5589 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5591 ((eq articles 0) nil)
5593 ;; Init the dependencies hash table.
5594 (setq gnus-newsgroup-dependencies
5595 (gnus-make-hashtable (length articles)))
5596 (gnus-set-global-variables)
5597 ;; Retrieve the headers and read them in.
5599 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5601 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5603 (setq gnus-newsgroup-cached cached))
5605 ;; Suppress duplicates?
5606 (when gnus-suppress-duplicates
5607 (gnus-dup-suppress-articles))
5609 ;; Set the initial limit.
5610 (setq gnus-newsgroup-limit (copy-sequence articles))
5611 ;; Remove canceled articles from the list of unread articles.
5612 (setq fetched-articles
5613 (mapcar (lambda (headers) (mail-header-number headers))
5614 gnus-newsgroup-headers))
5615 (setq gnus-newsgroup-articles fetched-articles)
5616 (setq gnus-newsgroup-unreads
5617 (gnus-sorted-nintersection
5618 gnus-newsgroup-unreads fetched-articles))
5619 (gnus-compute-unseen-list)
5621 ;; Removed marked articles that do not exist.
5622 (gnus-update-missing-marks
5623 (gnus-sorted-difference articles fetched-articles))
5624 ;; We might want to build some more threads first.
5625 (when (and gnus-fetch-old-headers
5626 (eq gnus-headers-retrieved-by 'nov))
5627 (if (eq gnus-fetch-old-headers 'invisible)
5628 (gnus-build-all-threads)
5629 (gnus-build-old-threads)))
5630 ;; Let the Gnus agent mark articles as read.
5632 (gnus-agent-get-undownloaded-list))
5633 ;; Remove list identifiers from subject
5634 (when gnus-list-identifiers
5635 (gnus-summary-remove-list-identifiers))
5636 ;; Check whether auto-expire is to be done in this group.
5637 (setq gnus-newsgroup-auto-expire
5638 (gnus-group-auto-expirable-p group))
5639 ;; Set up the article buffer now, if necessary.
5640 (unless (and gnus-single-article-buffer
5641 (equal gnus-article-buffer "*Article*"))
5642 (gnus-article-setup-buffer))
5643 ;; First and last article in this newsgroup.
5644 (when gnus-newsgroup-headers
5645 (setq gnus-newsgroup-begin
5646 (mail-header-number (car gnus-newsgroup-headers))
5649 (gnus-last-element gnus-newsgroup-headers))))
5650 ;; GROUP is successfully selected.
5651 (or gnus-newsgroup-headers t)))))
5653 (defun gnus-compute-unseen-list ()
5654 ;; The `seen' marks are treated specially.
5655 (if (not gnus-newsgroup-seen)
5656 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5657 (setq gnus-newsgroup-unseen
5658 (gnus-inverse-list-range-intersection
5659 gnus-newsgroup-articles gnus-newsgroup-seen))))
5661 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5663 (defun gnus-summary-display-make-predicate (display)
5664 (require 'gnus-agent)
5665 (when (= (length display) 1)
5666 (setq display (car display)))
5667 (unless gnus-summary-display-cache
5668 (dolist (elem (append '((unread . unread)
5671 gnus-article-mark-lists))
5672 (push (cons (cdr elem)
5674 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5675 gnus-summary-display-cache)))
5676 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5677 (gnus-category-predicate-cache gnus-summary-display-cache))
5678 (gnus-get-predicate display)))
5680 ;; Uses the dynamically bound `number' variable.
5682 (defun gnus-article-marked-p (type &optional article)
5683 (let ((article (or article number)))
5686 (memq article gnus-newsgroup-marked))
5688 (memq article gnus-newsgroup-spam-marked))
5690 (memq article gnus-newsgroup-unsendable))
5691 ((eq type 'undownload)
5692 (memq article gnus-newsgroup-undownloaded))
5693 ((eq type 'download)
5694 (memq article gnus-newsgroup-downloadable))
5696 (memq article gnus-newsgroup-unreads))
5698 (memq article gnus-newsgroup-reads))
5700 (memq article gnus-newsgroup-dormant) )
5702 (memq article gnus-newsgroup-expirable))
5704 (memq article gnus-newsgroup-replied))
5706 (memq article gnus-newsgroup-killed))
5707 ((eq type 'bookmark)
5708 (assq article gnus-newsgroup-bookmarks))
5710 (assq article gnus-newsgroup-scored))
5712 (memq article gnus-newsgroup-saved))
5714 (memq article gnus-newsgroup-cached))
5716 (memq article gnus-newsgroup-forwarded))
5718 (not (memq article gnus-newsgroup-unseen)))
5720 (memq article gnus-newsgroup-recent))
5723 (defun gnus-articles-to-read (group &optional read-all)
5724 "Find out what articles the user wants to read."
5726 ;; Select all articles if `read-all' is non-nil, or if there
5727 ;; are no unread articles.
5729 (and (zerop (length gnus-newsgroup-marked))
5730 (zerop (length gnus-newsgroup-unreads)))
5731 ;; Fetch all if the predicate is non-nil.
5732 gnus-newsgroup-display)
5733 ;; We want to select the headers for all the articles in
5734 ;; the group, so we select either all the active
5735 ;; articles in the group, or (if that's nil), the
5736 ;; articles in the cache.
5738 (if gnus-newsgroup-maximum-articles
5739 (let ((active (gnus-active group)))
5740 (gnus-uncompress-range
5741 (cons (max (car active)
5743 gnus-newsgroup-maximum-articles
5746 (gnus-uncompress-range (gnus-active group)))
5747 (gnus-cache-articles-in-group group))
5748 ;; Select only the "normal" subset of articles.
5750 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5751 gnus-newsgroup-unreads)))
5752 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5753 (scored (length scored-list))
5754 (number (length articles))
5755 (marked (+ (length gnus-newsgroup-marked)
5756 (length gnus-newsgroup-dormant)))
5761 ((numberp gnus-newsgroup-display)
5762 gnus-newsgroup-display)
5766 ((and (or (<= scored marked) (= scored number))
5767 (numberp gnus-large-newsgroup)
5768 (> number gnus-large-newsgroup))
5769 (let* ((cursor-in-echo-area nil)
5770 (initial (gnus-parameter-large-newsgroup-initial
5771 gnus-newsgroup-name))
5775 "How many articles from %s (%s %d): "
5776 (gnus-group-decoded-name gnus-newsgroup-name)
5777 (if initial "max" "default")
5780 (cons (number-to-string initial)
5782 (if (string-match "^[ \t]*$" input) number input)))
5783 ((and (> scored marked) (< scored number)
5784 (> (- scored number) 20))
5787 (format "%s %s (%d scored, %d total): "
5788 "How many articles from"
5789 (gnus-group-decoded-name group)
5791 (if (string-match "^[ \t]*$" input)
5795 (message "Quit getting the articles to read")
5797 (setq select (if (stringp select) (string-to-number select) select))
5798 (if (or (null select) (zerop select))
5800 (if (and (not (zerop scored)) (<= (abs select) scored))
5802 (setq articles (sort scored-list '<))
5803 (setq number (length articles)))
5804 (setq articles (copy-sequence articles)))
5806 (when (< (abs select) number)
5808 ;; Select the N oldest articles.
5809 (setcdr (nthcdr (1- (abs select)) articles) nil)
5810 ;; Select the N most recent articles.
5811 (setq articles (nthcdr (- number select) articles))))
5812 (setq gnus-newsgroup-unselected
5813 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5814 (when gnus-alter-articles-to-read-function
5817 (funcall gnus-alter-articles-to-read-function
5818 gnus-newsgroup-name articles)
5822 (defun gnus-killed-articles (killed articles)
5825 (when (inline (gnus-member-of-range (car articles) killed))
5826 (push (car articles) out))
5827 (setq articles (cdr articles)))
5830 (defun gnus-uncompress-marks (marks)
5831 "Uncompress the mark ranges in MARKS."
5832 (let ((uncompressed '(score bookmark))
5835 (if (memq (caar marks) uncompressed)
5836 (push (car marks) out)
5837 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5838 (setq marks (cdr marks)))
5841 (defun gnus-article-mark-to-type (mark)
5842 "Return the type of MARK."
5843 (or (cadr (assq mark gnus-article-special-mark-lists))
5846 (defun gnus-article-unpropagatable-p (mark)
5847 "Return whether MARK should be propagated to back end."
5848 (memq mark gnus-article-unpropagated-mark-lists))
5850 (defun gnus-adjust-marked-articles (info)
5851 "Set all article lists and remove all marks that are no longer valid."
5852 (let* ((marked-lists (gnus-info-marks info))
5853 (active (gnus-active (gnus-info-group info)))
5856 (types gnus-article-mark-lists)
5857 marks var articles article mark mark-type
5859 ;; Hack to avoid adjusting marks for imap.
5860 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5864 (dolist (marks marked-lists)
5865 (setq mark (car marks)
5866 mark-type (gnus-article-mark-to-type mark)
5867 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5869 ;; We set the variable according to the type of the marks list,
5870 ;; and then adjust the marks to a subset of the active articles.
5872 ;; Adjust "simple" lists - compressed yet unsorted
5873 ((eq mark-type 'list)
5874 ;; Simultaneously uncompress and clip to active range
5875 ;; See gnus-uncompress-range for a description of possible marks
5877 (if (not (cadr marks))
5879 (setq articles (if (numberp (cddr marks))
5885 (while (setq article (pop articles))
5886 (cond ((consp article)
5887 (setq bgn (max (car article) min)
5888 end (min (cdr article) max))
5890 (setq l (setcdr l (cons bgn nil))
5892 ((and (<= min article)
5894 (setq l (setcdr l (cons article nil))))))
5895 (set var (cdr lh)))))
5897 ((eq mark-type 'tuple)
5898 (set var (setq articles (cdr marks)))
5899 (when (not (listp (cdr (symbol-value var))))
5900 (set var (list (symbol-value var))))
5901 (when (not (listp (cdr articles)))
5902 (setq articles (list articles)))
5904 (when (or (not (consp (setq article (pop articles))))
5905 (< (car article) min)
5906 (> (car article) max))
5907 (set var (delq article (symbol-value var))))))
5908 ;; Adjust ranges (sloppily).
5909 ((eq mark-type 'range)
5912 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5913 ;; It should be (seen (NUM1 . NUM2)).
5914 (when (numberp (cddr marks))
5915 (setcdr marks (list (cdr marks))))
5916 (setq articles (cdr marks))
5917 (while (and articles
5918 (or (and (consp (car articles))
5919 (> min (cdar articles)))
5920 (and (numberp (car articles))
5921 (> min (car articles)))))
5923 (set var articles))))))))
5925 (defun gnus-update-missing-marks (missing)
5926 "Go through the list of MISSING articles and remove them from the mark lists."
5929 ;; Go through all types.
5930 (dolist (elem gnus-article-mark-lists)
5931 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5932 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5933 (when (symbol-value var)
5934 ;; This list has articles. So we delete all missing
5935 ;; articles from it.
5938 (set var (delq (pop m) (symbol-value var))))))))))
5940 (defun gnus-update-marks ()
5941 "Enter the various lists of marked articles into the newsgroup info list."
5942 (let ((types gnus-article-mark-lists)
5943 (info (gnus-get-info gnus-newsgroup-name))
5944 type list newmarked symbol delta-marks)
5946 ;; Add all marks lists to the list of marks lists.
5947 (while (setq type (pop types))
5948 (setq list (symbol-value
5950 (intern (format "gnus-newsgroup-%s" (car type))))))
5953 ;; Get rid of the entries of the articles that have the
5955 (when (and (eq (cdr type) 'score)
5959 (prev (cons nil list))
5962 (if (or (not (consp (car arts)))
5963 (= (cdar arts) gnus-summary-default-score))
5964 (setcdr prev (cdr arts))
5966 (setq arts (cdr arts)))
5967 (setq list (cdr all)))))
5969 (when (eq (cdr type) 'seen)
5970 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5972 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5973 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5975 (when (and (gnus-check-backend-function
5976 'request-set-mark gnus-newsgroup-name)
5977 (not (gnus-article-unpropagatable-p (cdr type))))
5978 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5979 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5980 (add (gnus-remove-from-range
5981 (gnus-copy-sequence list) old)))
5983 (push (list add 'add (list (cdr type))) delta-marks))
5985 ;; Don't delete marks from outside the active range. This
5986 ;; shouldn't happen, but is a sanity check.
5987 (setq del (gnus-sorted-range-intersection
5988 (gnus-active gnus-newsgroup-name) del))
5989 (push (list del 'del (list (cdr type))) delta-marks))))
5992 (push (cons (cdr type) list) newmarked)))
5995 (unless (gnus-check-group gnus-newsgroup-name)
5996 (error "Can't open server for %s" gnus-newsgroup-name))
5997 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5999 ;; Enter these new marks into the info of the group.
6001 (setcar (nthcdr 3 info) newmarked)
6002 ;; Add the marks lists to the end of the info.
6004 (setcdr (nthcdr 2 info) (list newmarked))))
6006 ;; Cut off the end of the info if there's nothing else there.
6010 (when (nthcdr (decf i) info)
6011 (setcdr (nthcdr i info) nil)))))))
6013 (defun gnus-set-mode-line (where)
6014 "Set the mode line of the article or summary buffers.
6015 If WHERE is `summary', the summary mode line format will be used."
6016 ;; Is this mode line one we keep updated?
6017 (when (and (memq where gnus-updated-mode-lines)
6019 (intern (format "gnus-%s-mode-line-format-spec" where))))
6021 ;; We evaluate this in the summary buffer since these
6022 ;; variables are buffer-local to that buffer.
6023 (with-current-buffer gnus-summary-buffer
6024 ;; We bind all these variables that are used in the `eval' form
6026 (let* ((mformat (symbol-value
6028 (format "gnus-%s-mode-line-format-spec" where))))
6029 (gnus-tmp-group-name (gnus-mode-string-quote
6030 (gnus-group-decoded-name
6031 gnus-newsgroup-name)))
6032 (gnus-tmp-article-number (or gnus-current-article 0))
6033 (gnus-tmp-unread gnus-newsgroup-unreads)
6034 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6035 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6036 (gnus-tmp-unread-and-unselected
6037 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6038 (zerop gnus-tmp-unselected))
6040 ((zerop gnus-tmp-unselected)
6041 (format "{%d more}" gnus-tmp-unread-and-unticked))
6042 (t (format "{%d(+%d) more}"
6043 gnus-tmp-unread-and-unticked
6044 gnus-tmp-unselected))))
6046 (if (and gnus-current-headers
6047 (vectorp gnus-current-headers))
6048 (gnus-mode-string-quote
6049 (mail-header-subject gnus-current-headers))
6051 bufname-length max-len
6052 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6053 (setq mode-string (eval mformat))
6054 (setq bufname-length (if (string-match "%b" mode-string)
6057 (if (eq where 'summary)
6059 (get-buffer gnus-article-buffer))))
6062 (setq max-len (max 4 (if gnus-mode-non-string-length
6064 gnus-mode-non-string-length
6066 (length mode-string))))
6067 ;; We might have to chop a bit of the string off...
6068 (when (> (length mode-string) max-len)
6070 (concat (truncate-string-to-width mode-string (- max-len 3))
6072 ;; Update the mode line.
6073 (setq mode-line-buffer-identification
6074 (gnus-mode-line-buffer-identification (list mode-string)))
6075 (set-buffer-modified-p t))))
6077 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6078 "Go through the HEADERS list and add all Xrefs to a hash table.
6079 The resulting hash table is returned, or nil if no Xrefs were found."
6080 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6081 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6082 (xref-hashtb (gnus-make-hashtable))
6083 start group entry number xrefs header)
6085 (setq header (pop headers))
6086 (when (and (setq xrefs (mail-header-xref header))
6087 (not (memq (setq number (mail-header-number header))
6090 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6091 (setq start (match-end 0))
6092 (setq group (if prefix
6093 (concat prefix (substring xrefs (match-beginning 1)
6095 (substring xrefs (match-beginning 1) (match-end 1))))
6097 (string-to-number (substring xrefs (match-beginning 2)
6099 (if (setq entry (gnus-gethash group xref-hashtb))
6100 (setcdr entry (cons number (cdr entry)))
6101 (gnus-sethash group (cons number nil) xref-hashtb)))))
6102 (and start xref-hashtb)))
6104 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6105 "Look through all the headers and mark the Xrefs as read."
6106 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6107 name info xref-hashtb idlist method nth4)
6108 (with-current-buffer gnus-group-buffer
6109 (when (setq xref-hashtb
6110 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6113 (unless (string= from-newsgroup (setq name (symbol-name group)))
6114 (setq idlist (symbol-value group))
6115 ;; Dead groups are not updated.
6117 (setq info (gnus-get-info name))
6118 (when (stringp (setq nth4 (gnus-info-method info)))
6119 (setq nth4 (gnus-server-to-method nth4))))
6120 ;; Only do the xrefs if the group has the same
6121 ;; select method as the group we have just read.
6122 (or (gnus-methods-equal-p
6123 nth4 (gnus-find-method-for-group from-newsgroup))
6125 (equal nth4 (setq method (gnus-find-method-for-group
6127 (and (equal (car nth4) (car method))
6128 (equal (nth 1 nth4) (nth 1 method))))
6129 gnus-use-cross-reference
6130 (or (not (eq gnus-use-cross-reference t))
6132 ;; Only do cross-references on subscribed
6133 ;; groups, if that is what is wanted.
6134 (<= (gnus-info-level info) gnus-level-subscribed))
6135 (gnus-group-make-articles-read name idlist))))
6138 (defun gnus-compute-read-articles (group articles)
6139 (let* ((entry (gnus-group-entry group))
6140 (info (nth 2 entry))
6141 (active (gnus-active group))
6144 ;; First peel off all invalid article numbers.
6146 (let ((ids articles)
6148 (while (setq id (pop ids))
6149 (when (and first (> id (cdr active)))
6150 ;; We'll end up in this situation in one particular
6151 ;; obscure situation. If you re-scan a group and get
6152 ;; a new article that is cross-posted to a different
6153 ;; group that has not been re-scanned, you might get
6154 ;; crossposted article that has a higher number than
6155 ;; Gnus believes possible. So we re-activate this
6156 ;; group as well. This might mean doing the
6157 ;; crossposting thingy will *increase* the number
6158 ;; of articles in some groups. Tsk, tsk.
6159 (setq active (or (gnus-activate-group group) active)))
6160 (when (or (> id (cdr active))
6161 (< id (car active)))
6162 (setq articles (delq id articles))))))
6163 ;; If the read list is nil, we init it.
6165 (null (gnus-info-read info))
6167 (setq ninfo (cons 1 (1- (car active))))
6168 (setq ninfo (gnus-info-read info)))
6169 ;; Then we add the read articles to the range.
6171 ninfo (setq articles (sort articles '<))))))
6173 (defun gnus-group-make-articles-read (group articles)
6174 "Update the info of GROUP to say that ARTICLES are read."
6176 (entry (gnus-group-entry group))
6177 (info (nth 2 entry))
6178 (active (gnus-active group))
6181 (setq range (gnus-compute-read-articles group articles))
6182 (with-current-buffer gnus-group-buffer
6185 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6186 (gnus-info-set-read ',info ',(gnus-info-read info))
6187 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6188 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6189 (gnus-group-update-group ,group t))))
6190 ;; Add the read articles to the range.
6191 (gnus-info-set-read info range)
6192 (gnus-request-set-mark group (list (list range 'add '(read))))
6193 ;; Then we have to re-compute how many unread
6194 ;; articles there are in this group.
6198 (setq num (- (1+ (cdr active)) (car active))))
6199 ((not (listp (cdr range)))
6200 (setq num (- (cdr active) (- (1+ (cdr range))
6204 (if (numberp (car range))
6206 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6207 (setq range (cdr range)))
6208 (setq num (- (cdr active) num))))
6209 ;; Update the number of unread articles.
6211 ;; Update the group buffer.
6212 (unless (gnus-ephemeral-group-p group)
6213 (gnus-group-update-group group t))))))
6215 (defvar gnus-newsgroup-none-id 0)
6217 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6218 (let ((cur nntp-server-buffer)
6221 (with-current-buffer gnus-summary-buffer
6222 gnus-newsgroup-dependencies)))
6223 headers id end ref number
6224 (mail-parse-charset gnus-newsgroup-charset)
6225 (mail-parse-ignored-charsets
6226 (save-current-buffer (condition-case nil
6227 (set-buffer gnus-summary-buffer)
6229 gnus-newsgroup-ignored-charsets)))
6230 (with-current-buffer nntp-server-buffer
6231 ;; Translate all TAB characters into SPACE characters.
6232 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6233 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6234 (ietf-drums-unfold-fws)
6235 (gnus-run-hooks 'gnus-parse-headers-hook)
6236 (let ((case-fold-search t)
6237 in-reply-to header p lines chars)
6238 (goto-char (point-min))
6239 ;; Search to the beginning of the next header. Error messages
6240 ;; do not begin with 2 or 3.
6241 (while (re-search-forward "^[23][0-9]+ " nil t)
6244 ;; This implementation of this function, with nine
6245 ;; search-forwards instead of the one re-search-forward and
6246 ;; a case (which basically was the old function) is actually
6247 ;; about twice as fast, even though it looks messier. You
6248 ;; can't have everything, I guess. Speed and elegance
6249 ;; doesn't always go hand in hand.
6255 (setq number (read cur))
6258 (narrow-to-region (point)
6259 (or (and (search-forward "\n.\n" nil t)
6265 (if (search-forward "\nsubject:" nil t)
6266 (funcall gnus-decode-encoded-word-function
6267 (nnheader-header-value))
6272 (if (search-forward "\nfrom:" nil t)
6273 (funcall gnus-decode-encoded-address-function
6274 (nnheader-header-value))
6279 (if (search-forward "\ndate:" nil t)
6280 (nnheader-header-value) ""))
6284 (setq id (if (re-search-forward
6285 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6286 ;; We do it this way to make sure the Message-ID
6287 ;; is (somewhat) syntactically valid.
6288 (buffer-substring (match-beginning 1)
6290 ;; If there was no message-id, we just fake one
6291 ;; to make subsequent routines simpler.
6292 (nnheader-generate-fake-message-id number))))
6296 (if (search-forward "\nreferences:" nil t)
6300 (nnheader-header-value)
6305 (search-backward ">" end t)
6308 (search-backward "<" end t)
6310 ;; Get the references from the in-reply-to header if there
6311 ;; were no references and the in-reply-to header looks
6313 (if (and (search-forward "\nin-reply-to:" nil t)
6314 (setq in-reply-to (nnheader-header-value))
6315 (string-match "<[^>]+>" in-reply-to))
6317 (setq ref (substring in-reply-to (match-beginning 0)
6319 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6320 (setq ref2 (substring in-reply-to (match-beginning 0)
6322 (when (> (length ref2) (length ref))
6329 (if (search-forward "\nchars: " nil t)
6330 (if (numberp (setq chars (ignore-errors (read cur))))
6336 (if (search-forward "\nlines: " nil t)
6337 (if (numberp (setq lines (ignore-errors (read cur))))
6343 (and (search-forward "\nxref:" nil t)
6344 (nnheader-header-value)))
6346 (when gnus-extra-headers
6347 (let ((extra gnus-extra-headers)
6351 (when (search-forward
6352 (concat "\n" (symbol-name (car extra)) ":") nil t)
6353 (push (cons (car extra) (nnheader-header-value))
6357 (when (equal id ref)
6360 (when gnus-alter-header-function
6361 (funcall gnus-alter-header-function header)
6362 (setq id (mail-header-id header)
6363 ref (gnus-parent-id (mail-header-references header))))
6366 (gnus-dependencies-add-header
6367 header dependencies force-new))
6368 (push header headers))
6369 (goto-char (point-max))
6371 (nreverse headers)))))
6373 ;; Goes through the xover lines and returns a list of vectors
6374 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6375 force-new dependencies
6376 group also-fetch-heads)
6377 "Parse the news overview data in the server buffer.
6378 Return a list of headers that match SEQUENCE (see
6379 `nntp-retrieve-headers')."
6380 ;; Get the Xref when the users reads the articles since most/some
6381 ;; NNTP servers do not include Xrefs when using XOVER.
6382 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6383 (let ((mail-parse-charset gnus-newsgroup-charset)
6384 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6385 (cur nntp-server-buffer)
6386 (dependencies (or dependencies gnus-newsgroup-dependencies))
6388 ((eq gnus-read-all-available-headers t)
6390 ((and (stringp gnus-read-all-available-headers)
6392 (string-match gnus-read-all-available-headers group))
6395 number headers header)
6396 (with-current-buffer nntp-server-buffer
6397 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6398 ;; Allow the user to mangle the headers before parsing them.
6399 (gnus-run-hooks 'gnus-parse-headers-hook)
6400 (goto-char (point-min))
6401 (gnus-parse-without-error
6402 (while (and (or sequence allp)
6404 (setq number (read cur))
6406 (while (and sequence
6407 (< (car sequence) number))
6408 (setq sequence (cdr sequence))))
6411 (eq number (car sequence))))
6413 (setq sequence (cdr sequence))
6414 (setq header (inline
6415 (gnus-nov-parse-line
6416 number dependencies force-new)))))
6417 (push header headers))
6419 ;; A common bug in inn is that if you have posted an article and
6420 ;; then retrieves the active file, it will answer correctly --
6421 ;; the new article is included. However, a NOV entry for the
6422 ;; article may not have been generated yet, so this may fail.
6423 ;; We work around this problem by retrieving the last few
6424 ;; headers using HEAD.
6425 (if (or (not also-fetch-heads)
6427 ;; We (probably) got all the headers.
6429 (let ((gnus-nov-is-evil t))
6432 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6433 (gnus-get-newsgroup-headers))))))))
6435 (defun gnus-article-get-xrefs ()
6436 "Fill in the Xref value in `gnus-current-headers', if necessary.
6437 This is meant to be called in `gnus-article-internal-prepare-hook'."
6438 (let ((headers (with-current-buffer gnus-summary-buffer
6439 gnus-current-headers)))
6440 (or (not gnus-use-cross-reference)
6442 (and (mail-header-xref headers)
6443 (not (string= (mail-header-xref headers) "")))
6444 (let ((case-fold-search t)
6447 (nnheader-narrow-to-headers)
6448 (goto-char (point-min))
6449 (when (or (and (not (eobp))
6450 (eq (downcase (char-after)) ?x)
6451 (looking-at "Xref:"))
6452 (search-forward "\nXref:" nil t))
6453 (goto-char (1+ (match-end 0)))
6454 (setq xref (buffer-substring (point) (point-at-eol)))
6455 (mail-header-set-xref headers xref)))))))
6457 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6458 "Find article ID and insert the summary line for that article.
6459 OLD-HEADER can either be a header or a line number to insert
6460 the subject line on."
6461 (let* ((line (and (numberp old-header) old-header))
6462 (old-header (and (vectorp old-header) old-header))
6463 (header (cond ((and old-header use-old-header)
6466 (gnus-number-to-header id))
6467 (gnus-number-to-header id))
6469 (gnus-read-header id))))
6470 (number (and (numberp id) id))
6473 ;; Rebuild the thread that this article is part of and go to the
6474 ;; article we have fetched.
6475 (when (and (not gnus-show-threads)
6478 (setq d (gnus-data-find (mail-header-number old-header))))
6479 (goto-char (gnus-data-pos d))
6485 (gnus-delete-line))))))
6486 ;; Remove list identifiers from subject.
6487 (when gnus-list-identifiers
6488 (let ((gnus-newsgroup-headers (list header)))
6489 (gnus-summary-remove-list-identifiers)))
6491 (mail-header-set-number header (mail-header-number old-header)))
6492 (setq gnus-newsgroup-sparse
6493 (delq (setq number (mail-header-number header))
6494 gnus-newsgroup-sparse))
6495 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6496 (push number gnus-newsgroup-limit)
6497 (gnus-rebuild-thread (mail-header-id header) line)
6498 (gnus-summary-goto-subject number nil t))
6499 (when (and (numberp number)
6501 ;; We have to update the boundaries even if we can't fetch the
6502 ;; article if ID is a number -- so that the next `P' or `N'
6503 ;; command will fetch the previous (or next) article even
6504 ;; if the one we tried to fetch this time has been canceled.
6505 (when (> number gnus-newsgroup-end)
6506 (setq gnus-newsgroup-end number))
6507 (when (< number gnus-newsgroup-begin)
6508 (setq gnus-newsgroup-begin number))
6509 (setq gnus-newsgroup-unselected
6510 (delq number gnus-newsgroup-unselected)))
6511 ;; Report back a success?
6512 (and header (mail-header-number header))))
6514 ;;; Process/prefix in the summary buffer
6516 (defun gnus-summary-work-articles (n)
6517 "Return a list of articles to be worked upon.
6518 The prefix argument, the list of process marked articles, and the
6519 current article will be taken into consideration."
6520 (with-current-buffer gnus-summary-buffer
6523 ;; A numerical prefix has been given.
6524 (setq n (prefix-numeric-value n))
6525 (let ((backward (< n 0))
6526 (n (abs (prefix-numeric-value n)))
6531 (push (setq article (gnus-summary-article-number))
6534 (gnus-summary-find-prev nil article)
6535 (gnus-summary-find-next nil article)))
6537 (nreverse articles)))
6538 ((and (gnus-region-active-p) (mark))
6539 (message "region active")
6540 ;; Work on the region between point and mark.
6541 (let ((max (max (point) (mark)))
6544 (goto-char (min (point) (mark)))
6547 (push (setq article (gnus-summary-article-number)) articles)
6548 (gnus-summary-find-next nil article)
6550 (nreverse articles))))
6551 (gnus-newsgroup-processable
6552 ;; There are process-marked articles present.
6553 ;; Save current state.
6554 (gnus-summary-save-process-mark)
6556 (reverse gnus-newsgroup-processable))
6558 ;; Just return the current article.
6559 (list (gnus-summary-article-number))))))
6561 (defmacro gnus-summary-iterate (arg &rest forms)
6562 "Iterate over the process/prefixed articles and do FORMS.
6563 ARG is the interactive prefix given to the command. FORMS will be
6564 executed with point over the summary line of the articles."
6565 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6566 `(let ((,articles (gnus-summary-work-articles ,arg)))
6568 (gnus-summary-goto-subject (car ,articles))
6572 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6573 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6575 (defun gnus-summary-save-process-mark ()
6576 "Push the current set of process marked articles on the stack."
6578 (push (copy-sequence gnus-newsgroup-processable)
6579 gnus-newsgroup-process-stack))
6581 (defun gnus-summary-kill-process-mark ()
6582 "Push the current set of process marked articles on the stack and unmark."
6584 (gnus-summary-save-process-mark)
6585 (gnus-summary-unmark-all-processable))
6587 (defun gnus-summary-yank-process-mark ()
6588 "Pop the last process mark state off the stack and restore it."
6590 (unless gnus-newsgroup-process-stack
6591 (error "Empty mark stack"))
6592 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6594 (defun gnus-summary-process-mark-set (set)
6595 "Make SET into the current process marked articles."
6596 (gnus-summary-unmark-all-processable)
6597 (mapc 'gnus-summary-set-process-mark set))
6599 ;;; Searching and stuff
6601 (defun gnus-summary-search-group (&optional backward use-level)
6602 "Search for next unread newsgroup.
6603 If optional argument BACKWARD is non-nil, search backward instead."
6604 (with-current-buffer gnus-group-buffer
6605 (when (gnus-group-search-forward
6606 backward nil (if use-level (gnus-group-group-level) nil))
6607 (gnus-group-group-name))))
6609 (defun gnus-summary-best-group (&optional exclude-group)
6610 "Find the name of the best unread group.
6611 If EXCLUDE-GROUP, do not go to this group."
6612 (with-current-buffer gnus-group-buffer
6614 (gnus-group-best-unread-group exclude-group))))
6616 (defun gnus-summary-find-next (&optional unread article backward)
6618 (gnus-summary-find-prev unread article)
6619 (let* ((dummy (gnus-summary-article-intangible-p))
6620 (article (or article (gnus-summary-article-number)))
6621 (data (gnus-data-find-list article))
6623 (when (and (not dummy)
6624 (or (not gnus-summary-check-current)
6626 (not (gnus-data-unread-p (car data)))))
6627 (setq data (cdr data)))
6632 (unless (memq (gnus-data-number (car data))
6634 ((eq gnus-auto-goto-ignores
6635 'always-undownloaded)
6636 gnus-newsgroup-undownloaded)
6639 ((eq gnus-auto-goto-ignores
6641 gnus-newsgroup-unfetched)
6642 ((eq gnus-auto-goto-ignores
6644 gnus-newsgroup-undownloaded)))
6645 (when (gnus-data-unread-p (car data))
6646 (setq result (car data)
6648 (setq data (cdr data)))
6651 (goto-char (gnus-data-pos result))
6652 (gnus-data-number result)))))
6654 (defun gnus-summary-find-prev (&optional unread article)
6655 (let* ((eobp (eobp))
6656 (article (or article (gnus-summary-article-number)))
6657 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6659 (when (and (not eobp)
6660 (or (not gnus-summary-check-current)
6662 (not (gnus-data-unread-p (car data)))))
6663 (setq data (cdr data)))
6668 (unless (memq (gnus-data-number (car data))
6670 ((eq gnus-auto-goto-ignores
6671 'always-undownloaded)
6672 gnus-newsgroup-undownloaded)
6675 ((eq gnus-auto-goto-ignores
6677 gnus-newsgroup-unfetched)
6678 ((eq gnus-auto-goto-ignores
6680 gnus-newsgroup-undownloaded)))
6681 (when (gnus-data-unread-p (car data))
6682 (setq result (car data)
6684 (setq data (cdr data)))
6687 (goto-char (gnus-data-pos result))
6688 (gnus-data-number result))))
6690 (defun gnus-summary-find-subject (subject &optional unread backward article)
6691 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6692 (article (or article (gnus-summary-article-number)))
6693 (articles (gnus-data-list backward))
6694 (arts (gnus-data-find-list article articles))
6696 (when (or (not gnus-summary-check-current)
6698 (not (gnus-data-unread-p (car arts))))
6699 (setq arts (cdr arts)))
6701 (and (or (not unread)
6702 (gnus-data-unread-p (car arts)))
6703 (vectorp (gnus-data-header (car arts)))
6705 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6706 (setq result (car arts)
6708 (setq arts (cdr arts)))
6710 (goto-char (gnus-data-pos result))
6711 (gnus-data-number result))))
6713 (defun gnus-summary-search-forward (&optional unread subject backward)
6714 "Search forward for an article.
6715 If UNREAD, look for unread articles. If SUBJECT, look for
6716 articles with that subject. If BACKWARD, search backward instead."
6717 (cond (subject (gnus-summary-find-subject subject unread backward))
6718 (backward (gnus-summary-find-prev unread))
6719 (t (gnus-summary-find-next unread))))
6721 (defun gnus-recenter (&optional n)
6722 "Center point in window and redisplay frame.
6723 Also do horizontal recentering."
6725 (when (and gnus-auto-center-summary
6726 (not (eq gnus-auto-center-summary 'vertical)))
6727 (gnus-horizontal-recenter))
6728 (if (fboundp 'recenter-top-bottom)
6729 (recenter-top-bottom n)
6732 (put 'gnus-recenter 'isearch-scroll t)
6734 (defun gnus-forward-line-ignore-invisible (n)
6735 "Move N lines forward (backward if N is negative).
6736 Like forward-line, but skip over (and don't count) invisible lines."
6738 (while (and (> n 0) (not done))
6739 ;; If the following character is currently invisible,
6740 ;; skip all characters with that same `invisible' property value.
6741 (while (gnus-invisible-p (point))
6742 (goto-char (gnus-next-char-property-change (point))))
6747 (while (and (< n 0) (not done))
6749 (if (bobp) (setq done t)
6751 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6752 (goto-char (gnus-previous-char-property-change (point))))))))
6754 (defun gnus-summary-recenter ()
6755 "Center point in the summary window.
6756 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6757 displayed, no centering will be performed."
6758 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6759 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6761 ;; The user has to want it.
6762 (when gnus-auto-center-summary
6763 (let* ((top (cond ((< (window-height) 4) 0)
6764 ((< (window-height) 7) 1)
6765 (t (if (numberp gnus-auto-center-summary)
6766 gnus-auto-center-summary
6767 (/ (1- (window-height)) 2)))))
6768 (height (1- (window-height)))
6769 (bottom (save-excursion
6770 (goto-char (point-max))
6771 (gnus-forward-line-ignore-invisible (- height))
6773 (window (get-buffer-window (current-buffer))))
6774 (when (get-buffer-window gnus-article-buffer)
6775 ;; Only do recentering when the article buffer is displayed,
6776 ;; Set the window start to either `bottom', which is the biggest
6777 ;; possible valid number, or the second line from the top,
6778 ;; whichever is the least.
6779 (let ((top-pos (save-excursion
6780 (gnus-forward-line-ignore-invisible (- top))
6782 (if (> bottom top-pos)
6783 ;; Keep the second line from the top visible
6784 (set-window-start window top-pos)
6785 ;; Try to keep the bottom line visible; if it's partially
6786 ;; obscured, either scroll one more line to make it fully
6787 ;; visible, or revert to using TOP-POS.
6789 (goto-char (point-max))
6790 (gnus-forward-line-ignore-invisible -1)
6791 (let ((last-line-start (point)))
6793 (set-window-start window (point) t)
6794 (when (not (pos-visible-in-window-p last-line-start window))
6795 (gnus-forward-line-ignore-invisible 1)
6796 (set-window-start window (min (point) top-pos) t)))))))
6797 ;; Do horizontal recentering while we're at it.
6798 (when (and (get-buffer-window (current-buffer) t)
6799 (not (eq gnus-auto-center-summary 'vertical)))
6800 (let ((selected (selected-window)))
6801 (select-window (get-buffer-window (current-buffer) t))
6802 (gnus-summary-position-point)
6803 (gnus-horizontal-recenter)
6804 (select-window selected))))))
6806 (defun gnus-summary-jump-to-group (newsgroup)
6807 "Move point to NEWSGROUP in group mode buffer."
6808 ;; Keep update point of group mode buffer if visible.
6809 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6810 (save-window-excursion
6811 ;; Take care of tree window mode.
6812 (when (get-buffer-window gnus-group-buffer)
6813 (pop-to-buffer gnus-group-buffer))
6814 (gnus-group-jump-to-group newsgroup))
6816 ;; Take care of tree window mode.
6817 (if (get-buffer-window gnus-group-buffer 0)
6818 (pop-to-buffer gnus-group-buffer)
6819 (set-buffer gnus-group-buffer))
6820 (gnus-group-jump-to-group newsgroup))))
6822 ;; This function returns a list of article numbers based on the
6823 ;; difference between the ranges of read articles in this group and
6824 ;; the range of active articles.
6825 (defun gnus-list-of-unread-articles (group)
6826 (let* ((read (gnus-info-read (gnus-get-info group)))
6827 (active (or (gnus-active group) (gnus-activate-group group)))
6828 (last (or (cdr active)
6829 (error "Group %s couldn't be activated " group)))
6830 (bottom (if gnus-newsgroup-maximum-articles
6832 (- last gnus-newsgroup-maximum-articles -1))
6835 ;; If none are read, then all are unread.
6838 ;; If the range of read articles is a single range, then the
6839 ;; first unread article is the article after the last read
6840 ;; article. Sounds logical, doesn't it?
6841 (if (and (not (listp (cdr read)))
6842 (or (< (car read) bottom)
6843 (progn (setq read (list read))
6845 (setq first (max bottom (1+ (cdr read))))
6846 ;; `read' is a list of ranges.
6847 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6850 (setq first bottom))
6853 (while (< first nlast)
6854 (setq unread (cons first unread)
6856 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6857 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6858 (setq read (cdr read)))))
6859 ;; And add the last unread articles.
6860 (while (<= first last)
6861 (setq unread (cons first unread)
6863 ;; Return the list of unread articles.
6864 (delq 0 (nreverse unread))))
6866 (defun gnus-list-of-read-articles (group)
6867 "Return a list of unread, unticked and non-dormant articles."
6868 (let* ((info (gnus-get-info group))
6869 (marked (gnus-info-marks info))
6870 (active (gnus-active group)))
6872 (gnus-list-range-difference
6873 (gnus-list-range-difference
6874 (gnus-sorted-complement
6875 (gnus-uncompress-range
6876 (if gnus-newsgroup-maximum-articles
6877 (cons (max (car active)
6879 gnus-newsgroup-maximum-articles
6883 (gnus-list-of-unread-articles group))
6884 (cdr (assq 'dormant marked)))
6885 (cdr (assq 'tick marked))))))
6887 ;; This function returns a sequence of article numbers based on the
6888 ;; difference between the ranges of read articles in this group and
6889 ;; the range of active articles.
6890 (defun gnus-sequence-of-unread-articles (group)
6891 (let* ((read (gnus-info-read (gnus-get-info group)))
6892 (active (or (gnus-active group) (gnus-activate-group group)))
6894 (bottom (if gnus-newsgroup-maximum-articles
6896 (- last gnus-newsgroup-maximum-articles -1))
6899 ;; If none are read, then all are unread.
6902 ;; If the range of read articles is a single range, then the
6903 ;; first unread article is the article after the last read
6904 ;; article. Sounds logical, doesn't it?
6905 (if (and (not (listp (cdr read)))
6906 (or (< (car read) bottom)
6907 (progn (setq read (list read))
6909 (setq first (max bottom (1+ (cdr read))))
6910 ;; `read' is a list of ranges.
6911 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6914 (setq first bottom))
6917 (push (cons first nlast) unread))
6918 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6919 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6920 (setq read (cdr read)))))
6921 ;; And add the last unread articles.
6922 (cond ((not (and first last))
6925 (push (cons first last) unread))
6927 (push first unread)))
6928 ;; Return the sequence of unread articles.
6929 (delq 0 (nreverse unread))))
6931 ;; Various summary commands
6933 (defun gnus-summary-select-article-buffer ()
6934 "Reconfigure windows to show article buffer."
6936 (if (not (gnus-buffer-live-p gnus-article-buffer))
6937 (error "There is no article buffer for this summary buffer")
6938 (gnus-configure-windows 'article)
6939 (select-window (get-buffer-window gnus-article-buffer))))
6941 (defun gnus-summary-universal-argument (arg)
6942 "Perform any operation on all articles that are process/prefixed."
6944 (let ((articles (gnus-summary-work-articles arg))
6951 (substitute-command-keys
6952 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6954 (gnus-error 1 "Undefined key")
6957 (gnus-summary-goto-subject (setq article (pop articles)))
6958 (let (gnus-newsgroup-processable)
6959 (command-execute func))
6960 (gnus-summary-remove-process-mark article)))))
6961 (gnus-summary-position-point))
6963 (defun gnus-summary-toggle-truncation (&optional arg)
6964 "Toggle truncation of summary lines.
6965 With ARG, turn line truncation on if ARG is positive."
6967 (setq truncate-lines
6968 (if (null arg) (not truncate-lines)
6969 (> (prefix-numeric-value arg) 0)))
6972 (defun gnus-summary-find-for-reselect ()
6973 "Return the number of an article to stay on across a reselect.
6974 The current article is considered, then following articles, then previous
6975 articles. An article is sought which is not cancelled and isn't a temporary
6976 insertion from another group. If there's no such then return a dummy 0."
6978 (dolist (rev '(nil t))
6979 (unless found ; don't demand the reverse list if we don't need it
6980 (let ((data (gnus-data-find-list
6981 (gnus-summary-article-number) (gnus-data-list rev))))
6982 (while (and data (not found))
6983 (if (and (< 0 (gnus-data-number (car data)))
6984 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6985 (setq found (gnus-data-number (car data))))
6986 (setq data (cdr data))))))
6989 (defun gnus-summary-reselect-current-group (&optional all rescan)
6990 "Exit and then reselect the current newsgroup.
6991 The prefix argument ALL means to select all articles."
6993 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6994 (error "Ephemeral groups can't be reselected"))
6995 (let ((current-subject (gnus-summary-find-for-reselect))
6996 (group gnus-newsgroup-name))
6997 (setq gnus-newsgroup-begin nil)
6998 (gnus-summary-exit nil 'leave-hidden)
6999 ;; We have to adjust the point of group mode buffer because
7000 ;; point was moved to the next unread newsgroup by exiting.
7001 (gnus-summary-jump-to-group group)
7004 (gnus-group-get-new-news-this-group 1)))
7005 (gnus-group-read-group all t)
7006 (gnus-summary-goto-subject current-subject nil t)))
7008 (defun gnus-summary-rescan-group (&optional all)
7009 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7011 (gnus-summary-reselect-current-group all t))
7013 (defun gnus-summary-update-info (&optional non-destructive)
7015 (let ((group gnus-newsgroup-name))
7017 (when gnus-newsgroup-kill-headers
7018 (setq gnus-newsgroup-killed
7019 (gnus-compress-sequence
7021 (gnus-list-range-intersection
7022 gnus-newsgroup-unselected gnus-newsgroup-killed)
7023 gnus-newsgroup-unreads)
7025 (unless (listp (cdr gnus-newsgroup-killed))
7026 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7027 (let ((headers gnus-newsgroup-headers))
7028 ;; Set the new ranges of read articles.
7029 (with-current-buffer gnus-group-buffer
7030 (gnus-undo-force-boundary))
7031 (gnus-update-read-articles
7032 group (gnus-sorted-union
7033 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7034 ;; Set the current article marks.
7035 (let ((gnus-newsgroup-scored
7036 (if (and (not gnus-save-score)
7037 (not non-destructive))
7039 gnus-newsgroup-scored)))
7041 (gnus-update-marks)))
7042 ;; Do the cross-ref thing.
7043 (when gnus-use-cross-reference
7044 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7045 ;; Do not switch windows but change the buffer to work.
7046 (set-buffer gnus-group-buffer)
7047 (unless (gnus-ephemeral-group-p group)
7048 (gnus-group-update-group group)))))))
7050 (defun gnus-summary-save-newsrc (&optional force)
7051 "Save the current number of read/marked articles in the dribble buffer.
7052 The dribble buffer will then be saved.
7053 If FORCE (the prefix), also save the .newsrc file(s)."
7055 (gnus-summary-update-info t)
7057 (gnus-save-newsrc-file)
7058 (gnus-dribble-save)))
7060 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7062 (defun gnus-summary-exit (&optional temporary leave-hidden)
7063 "Exit reading current newsgroup, and then return to group selection mode.
7064 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7066 (gnus-set-global-variables)
7067 (when (gnus-buffer-live-p gnus-article-buffer)
7068 (with-current-buffer gnus-article-buffer
7069 (mm-destroy-parts gnus-article-mime-handles)
7070 ;; Set it to nil for safety reason.
7071 (setq gnus-article-mime-handle-alist nil)
7072 (setq gnus-article-mime-handles nil)))
7073 (gnus-kill-save-kill-buffer)
7074 (gnus-async-halt-prefetch)
7075 (let* ((group gnus-newsgroup-name)
7076 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7077 (gnus-group-is-exiting-p t)
7080 (buf (current-buffer)))
7082 ;; Do adaptive scoring, and possibly save score files.
7083 (when gnus-newsgroup-adaptive
7084 (gnus-score-adaptive))
7085 (when gnus-use-scoring
7087 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7088 ;; If we have several article buffers, we kill them at exit.
7089 (unless gnus-single-article-buffer
7090 (when (gnus-buffer-live-p gnus-article-buffer)
7091 (with-current-buffer gnus-article-buffer
7092 ;; Don't kill sticky article buffers
7093 (unless (eq major-mode 'gnus-sticky-article-mode)
7094 (gnus-kill-buffer gnus-article-buffer)
7095 (setq gnus-article-current nil))))
7096 (gnus-kill-buffer gnus-original-article-buffer))
7097 (when gnus-use-cache
7098 (gnus-cache-possibly-remove-articles)
7099 (gnus-cache-save-buffers))
7100 (gnus-async-prefetch-remove-group group)
7101 (when gnus-suppress-duplicates
7102 (gnus-dup-enter-articles))
7103 (when gnus-use-trees
7104 (gnus-tree-close group))
7105 (when gnus-use-cache
7106 (gnus-cache-write-active))
7107 ;; Remove entries for this group.
7108 (nnmail-purge-split-history (gnus-group-real-name group))
7109 ;; Make all changes in this group permanent.
7111 (gnus-run-hooks 'gnus-exit-group-hook)
7112 (gnus-summary-update-info))
7113 (gnus-close-group group)
7114 ;; Make sure where we were, and go to next newsgroup.
7115 (set-buffer gnus-group-buffer)
7117 (gnus-group-jump-to-group group))
7118 (gnus-run-hooks 'gnus-summary-exit-hook)
7119 (unless (or quit-config
7120 (not gnus-summary-next-group-on-exit)
7121 ;; If this group has disappeared from the summary
7122 ;; buffer, don't skip forwards.
7123 (not (string= group (gnus-group-group-name))))
7124 (gnus-group-next-unread-group 1))
7125 (setq group-point (point))
7129 (if (not gnus-kill-summary-on-exit)
7131 (gnus-deaden-summary)
7133 ;; We set all buffer-local variables to nil. It is unclear why
7134 ;; this is needed, but if we don't, buffer-local variables are
7135 ;; not garbage-collected, it seems. This would the lead to en
7136 ;; ever-growing Emacs.
7137 (gnus-summary-clear-local-variables)
7138 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7139 (gnus-summary-clear-local-variables))
7140 (when (get-buffer gnus-article-buffer)
7141 (bury-buffer gnus-article-buffer))
7142 ;; Return to group mode buffer.
7143 (when (eq mode 'gnus-summary-mode)
7144 (gnus-kill-buffer buf)))
7145 (setq gnus-current-select-method gnus-select-method)
7146 (set-buffer gnus-group-buffer)
7148 (gnus-handle-ephemeral-exit quit-config)
7149 (goto-char group-point)
7150 ;; If gnus-group-buffer is already displayed, make sure we also move
7151 ;; the cursor in the window that displays it.
7152 (let ((win (get-buffer-window (current-buffer) 0)))
7153 (if win (set-window-point win (point))))
7154 (unless leave-hidden
7155 (gnus-configure-windows 'group 'force)))
7156 ;; Clear the current group name.
7158 (setq gnus-newsgroup-name nil)))))
7160 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7161 (defun gnus-summary-exit-no-update (&optional no-questions)
7162 "Quit reading current newsgroup without updating read article info."
7164 (let* ((group gnus-newsgroup-name)
7165 (gnus-group-is-exiting-p t)
7166 (gnus-group-is-exiting-without-update-p t)
7167 (quit-config (gnus-group-quit-config group)))
7168 (when (or no-questions
7170 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7171 (gnus-async-halt-prefetch)
7172 (run-hooks 'gnus-summary-prepare-exit-hook)
7173 (when (gnus-buffer-live-p gnus-article-buffer)
7174 (with-current-buffer gnus-article-buffer
7175 (mm-destroy-parts gnus-article-mime-handles)
7176 ;; Set it to nil for safety reason.
7177 (setq gnus-article-mime-handle-alist nil)
7178 (setq gnus-article-mime-handles nil)))
7179 ;; If we have several article buffers, we kill them at exit.
7180 (unless gnus-single-article-buffer
7181 (gnus-kill-buffer gnus-article-buffer)
7182 (gnus-kill-buffer gnus-original-article-buffer)
7183 (setq gnus-article-current nil))
7184 (if (not gnus-kill-summary-on-exit)
7185 (gnus-deaden-summary)
7186 (gnus-close-group group)
7187 (gnus-summary-clear-local-variables)
7188 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7189 (gnus-summary-clear-local-variables))
7190 (gnus-kill-buffer gnus-summary-buffer))
7191 (unless gnus-single-article-buffer
7192 (setq gnus-article-current nil))
7193 (when gnus-use-trees
7194 (gnus-tree-close group))
7195 (gnus-async-prefetch-remove-group group)
7196 (when (get-buffer gnus-article-buffer)
7197 (bury-buffer gnus-article-buffer))
7198 ;; Return to the group buffer.
7199 (gnus-configure-windows 'group 'force)
7200 ;; Clear the current group name.
7201 (setq gnus-newsgroup-name nil)
7202 (unless (gnus-ephemeral-group-p group)
7203 (gnus-group-update-group group))
7204 (when (equal (gnus-group-group-name) group)
7205 (gnus-group-next-unread-group 1))
7207 (gnus-handle-ephemeral-exit quit-config)))))
7209 (defun gnus-handle-ephemeral-exit (quit-config)
7210 "Handle movement when leaving an ephemeral group.
7211 The state which existed when entering the ephemeral is reset."
7212 (if (not (buffer-name (car quit-config)))
7213 (gnus-configure-windows 'group 'force)
7214 (set-buffer (car quit-config))
7215 (cond ((eq major-mode 'gnus-summary-mode)
7216 (gnus-set-global-variables))
7217 ((eq major-mode 'gnus-article-mode)
7218 (save-current-buffer
7219 ;; The `gnus-summary-buffer' variable may point
7220 ;; to the old summary buffer when using a single
7222 (unless (gnus-buffer-live-p gnus-summary-buffer)
7223 (set-buffer gnus-group-buffer))
7224 (set-buffer gnus-summary-buffer)
7225 (gnus-set-global-variables))))
7226 (if (or (eq (cdr quit-config) 'article)
7227 (eq (cdr quit-config) 'pick))
7228 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7229 (gnus-configure-windows 'pick 'force)
7230 (gnus-configure-windows (cdr quit-config) 'force))
7231 (gnus-configure-windows (cdr quit-config) 'force))
7232 (when (eq major-mode 'gnus-summary-mode)
7233 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7234 next-unread-noselect))
7235 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7237 (gnus-summary-next-subject 1 nil t))
7238 ((eq gnus-auto-select-on-ephemeral-exit
7239 'next-unread-noselect)
7240 (gnus-summary-next-subject 1 t t))))
7241 ;; Hide the article buffer which displays the article different
7242 ;; from the one that the cursor points to in the summary buffer.
7243 (gnus-configure-windows 'summary 'force))
7244 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7245 (gnus-summary-next-subject 1))
7246 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7247 (gnus-summary-next-subject 1 t))))
7248 (gnus-summary-recenter)
7249 (gnus-summary-position-point))))
7253 (defvar gnus-dead-summary-mode-map
7254 (let ((map (make-keymap)))
7255 (suppress-keymap map)
7256 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7257 (dolist (key '("\C-d" "\r" "\177" [delete]))
7258 (define-key map key 'gnus-summary-wake-up-the-dead))
7259 (dolist (key '("q" "Q"))
7260 (define-key map key 'bury-buffer))
7263 (define-minor-mode gnus-dead-summary-mode
7264 "Minor mode for Gnus summary buffers."
7265 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7266 (unless (derived-mode-p 'gnus-summary-mode)
7267 (setq gnus-dead-summary-mode nil)))
7269 (defun gnus-deaden-summary ()
7270 "Make the current summary buffer into a dead summary buffer."
7271 ;; Kill any previous dead summary buffer.
7272 (when (and gnus-dead-summary
7273 (buffer-name gnus-dead-summary))
7274 (with-current-buffer gnus-dead-summary
7275 (when gnus-dead-summary-mode
7276 (kill-buffer (current-buffer)))))
7277 ;; Make this the current dead summary.
7278 (setq gnus-dead-summary (current-buffer))
7279 (gnus-dead-summary-mode 1)
7280 (let ((name (buffer-name)))
7281 (when (string-match "Summary" name)
7283 (concat (substring name 0 (match-beginning 0)) "Dead "
7284 (substring name (match-beginning 0)))
7288 (defun gnus-kill-or-deaden-summary (buffer)
7289 "Kill or deaden the summary BUFFER."
7291 (when (and (buffer-name buffer)
7292 (not gnus-single-article-buffer))
7293 (with-current-buffer buffer
7294 (gnus-kill-buffer gnus-article-buffer)
7295 (gnus-kill-buffer gnus-original-article-buffer)))
7298 (gnus-kill-summary-on-exit
7299 (when (and gnus-use-trees
7300 (gnus-buffer-exists-p buffer))
7301 (with-current-buffer buffer
7302 (gnus-tree-close gnus-newsgroup-name)))
7303 (gnus-kill-buffer buffer))
7304 ;; Deaden the buffer.
7305 ((gnus-buffer-exists-p buffer)
7306 (with-current-buffer buffer
7307 (gnus-deaden-summary))))))
7309 (defun gnus-summary-wake-up-the-dead (&rest args)
7310 "Wake up the dead summary buffer."
7312 (gnus-dead-summary-mode -1)
7313 (let ((name (buffer-name)))
7314 (when (string-match "Dead " name)
7316 (concat (substring name 0 (match-beginning 0))
7317 (substring name (match-end 0)))
7319 (gnus-message 3 "This dead summary is now alive again"))
7321 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7322 (defun gnus-summary-describe-group (&optional force)
7323 "Describe the current newsgroup."
7325 (gnus-group-describe-group force gnus-newsgroup-name))
7327 (defun gnus-summary-describe-briefly ()
7328 "Describe summary mode commands briefly."
7330 (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")))
7332 ;; Walking around group mode buffer from summary mode.
7334 (defun gnus-summary-next-group (&optional no-article target-group backward)
7335 "Exit current newsgroup and then select next unread newsgroup.
7336 If prefix argument NO-ARTICLE is non-nil, no article is selected
7337 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7338 previous group instead."
7340 ;; Stop pre-fetching.
7341 (gnus-async-halt-prefetch)
7342 (let ((current-group gnus-newsgroup-name)
7343 (current-buffer (current-buffer))
7345 ;; First we semi-exit this group to update Xrefs and all variables.
7346 ;; We can't do a real exit, because the window conf must remain
7347 ;; the same in case the user is prompted for info, and we don't
7348 ;; want the window conf to change before that...
7349 (gnus-summary-exit t)
7350 (while (not entered)
7351 ;; Then we find what group we are supposed to enter.
7352 (set-buffer gnus-group-buffer)
7353 (gnus-group-jump-to-group current-group)
7356 (if (eq gnus-keep-same-level 'best)
7357 (gnus-summary-best-group gnus-newsgroup-name)
7358 (gnus-summary-search-group backward gnus-keep-same-level))))
7359 (if (not target-group)
7360 ;; There are no further groups, so we return to the group
7363 (gnus-message 5 "Returning to the group buffer")
7365 (when (gnus-buffer-live-p current-buffer)
7366 (set-buffer current-buffer)
7367 (gnus-summary-exit))
7368 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7369 ;; We try to enter the target group.
7370 (gnus-group-jump-to-group target-group)
7371 (let ((unreads (gnus-group-group-unread)))
7372 (if (and (or (eq t unreads)
7373 (and unreads (not (zerop unreads))))
7374 (gnus-summary-read-group
7375 target-group nil no-article
7376 (and (buffer-name current-buffer) current-buffer)
7379 (setq current-group target-group
7380 target-group nil)))))))
7382 (defun gnus-summary-prev-group (&optional no-article)
7383 "Exit current newsgroup and then select previous unread newsgroup.
7384 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7386 (gnus-summary-next-group no-article nil t))
7388 ;; Walking around summary lines.
7390 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7391 "Go to the first subject satisfying any non-nil constraint.
7392 If UNREAD is non-nil, the article should be unread.
7393 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7394 If UNSEEN is non-nil, the article should be unseen as well as unread.
7395 Returns the article selected or nil if there are no matching articles."
7399 ((null gnus-newsgroup-data)
7400 (gnus-message 3 "No articles in the group")
7402 ;; Pick the first article.
7403 ((not (or unread undownloaded unseen))
7404 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7405 (gnus-data-number (car gnus-newsgroup-data)))
7406 ;; Find the first unread article.
7408 (let ((data gnus-newsgroup-data))
7410 (let ((num (gnus-data-number (car data))))
7411 (or (memq num gnus-newsgroup-unfetched)
7412 (not (or (and unread
7413 (memq num gnus-newsgroup-unreads))
7415 (memq num gnus-newsgroup-undownloaded))
7417 (memq num gnus-newsgroup-unseen)
7418 (memq num gnus-newsgroup-unreads)))))))
7419 (setq data (cdr data)))
7423 (goto-char (gnus-data-pos (car data)))
7424 (gnus-data-number (car data)))
7425 (gnus-message 3 "No more%s articles"
7426 (let* ((r (when unread " unread"))
7427 (d (when undownloaded " undownloaded"))
7428 (s (when unseen " unseen"))
7429 (l (delq nil (list r d s))))
7430 (cond ((= 3 (length l))
7431 (concat r "," d ", or" s))
7433 (concat (car l) ", or" (cadr l)))
7440 (gnus-summary-position-point))))))
7442 (defun gnus-summary-next-subject (n &optional unread dont-display)
7443 "Go to next N'th summary line.
7444 If N is negative, go to the previous N'th subject line.
7445 If UNREAD is non-nil, only unread articles are selected.
7446 The difference between N and the actual number of steps taken is
7449 (let ((backward (< n 0))
7453 (gnus-summary-find-prev unread)
7454 (gnus-summary-find-next unread)))
7455 (unless (zerop (setq n (1- n)))
7456 (gnus-summary-show-thread)))
7458 (gnus-message 7 "No more%s articles"
7459 (if unread " unread" "")))
7460 (unless dont-display
7461 (gnus-summary-recenter)
7462 (gnus-summary-position-point))
7465 (defun gnus-summary-next-unread-subject (n)
7466 "Go to next N'th unread summary line."
7468 (gnus-summary-next-subject n t))
7470 (defun gnus-summary-prev-subject (n &optional unread)
7471 "Go to previous N'th summary line.
7472 If optional argument UNREAD is non-nil, only unread article is selected."
7474 (gnus-summary-next-subject (- n) unread))
7476 (defun gnus-summary-prev-unread-subject (n)
7477 "Go to previous N'th unread summary line."
7479 (gnus-summary-next-subject (- n) t))
7481 (defun gnus-summary-goto-subjects (articles)
7482 "Insert the subject header for ARTICLES in the current buffer."
7484 (dolist (article articles)
7485 (gnus-summary-goto-subject article t)))
7486 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7487 (gnus-summary-position-point))
7489 (defun gnus-summary-goto-subject (article &optional force silent)
7490 "Go to the subject line of ARTICLE.
7491 If FORCE, also allow jumping to articles not currently shown."
7492 (interactive "nArticle number: ")
7493 (unless (numberp article)
7494 (error "Article %s is not a number" article))
7496 (data (gnus-data-find article)))
7497 ;; We read in the article if we have to.
7500 (gnus-summary-insert-subject
7502 (if (or (numberp force) (vectorp force)) force)
7504 (setq data (gnus-data-find article)))
7509 (gnus-message 3 "Can't find article %d" article))
7511 (let ((pt (gnus-data-pos data)))
7513 (gnus-summary-set-article-display-arrow pt))
7514 (gnus-summary-position-point)
7517 ;; Walking around summary lines with displaying articles.
7519 (defun gnus-summary-expand-window (&optional arg)
7520 "Make the summary buffer take up the entire Emacs frame.
7521 Given a prefix, will force an `article' buffer configuration."
7524 (gnus-configure-windows 'article 'force)
7525 (gnus-configure-windows 'summary 'force)))
7527 (defun gnus-summary-display-article (article &optional all-header)
7528 "Display ARTICLE in article buffer."
7529 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7530 (with-current-buffer gnus-article-buffer
7531 (eq major-mode 'gnus-article-mode)))
7532 (gnus-article-setup-buffer))
7533 (gnus-set-global-variables)
7534 (with-current-buffer gnus-article-buffer
7535 (setq gnus-article-charset gnus-newsgroup-charset)
7536 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7537 (mm-enable-multibyte))
7541 (if gnus-summary-display-article-function
7542 (funcall gnus-summary-display-article-function article all-header)
7543 (gnus-article-prepare article all-header))
7544 (gnus-run-hooks 'gnus-select-article-hook)
7545 (when (and gnus-current-article
7546 (not (zerop gnus-current-article)))
7547 (gnus-summary-goto-subject gnus-current-article))
7548 (gnus-summary-recenter)
7549 (when (and gnus-use-trees gnus-show-threads)
7550 (gnus-possibly-generate-tree article)
7551 (gnus-highlight-selected-tree article))
7552 ;; Successfully display article.
7553 (gnus-article-set-window-start
7554 (cdr (assq article gnus-newsgroup-bookmarks))))))
7556 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7557 "Select the current article.
7558 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7559 non-nil, the article will be re-fetched even if it already present in
7560 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7562 ;; Make sure we are in the summary buffer to work around bbdb bug.
7563 (unless (eq major-mode 'gnus-summary-mode)
7564 (set-buffer gnus-summary-buffer))
7565 (let ((article (or article (gnus-summary-article-number)))
7566 (all-headers (not (not all-headers))) ;Must be t or nil.
7567 gnus-summary-display-article-function)
7569 (gnus-summary-article-pseudo-p article)
7570 (error "This is a pseudo-article"))
7571 (with-current-buffer gnus-summary-buffer
7572 (if (or (and gnus-single-article-buffer
7573 (or (null gnus-current-article)
7574 (null gnus-article-current)
7575 (null (get-buffer gnus-article-buffer))
7576 (not (eq article (cdr gnus-article-current)))
7577 (not (equal (car gnus-article-current)
7578 gnus-newsgroup-name))))
7579 (and (not gnus-single-article-buffer)
7580 (or (null gnus-current-article)
7581 (not (eq gnus-current-article article))))
7583 ;; The requested article is different from the current article.
7585 (gnus-summary-display-article article all-headers)
7586 (when (gnus-buffer-live-p gnus-article-buffer)
7587 (with-current-buffer gnus-article-buffer
7588 (if (not gnus-article-decoded-p) ;; a local variable
7589 (mm-disable-multibyte))))
7590 (gnus-article-set-window-start
7591 (cdr (assq article gnus-newsgroup-bookmarks)))
7595 (defun gnus-summary-force-verify-and-decrypt ()
7596 "Display buttons for signed/encrypted parts and verify/decrypt them."
7598 (let ((mm-verify-option 'known)
7599 (mm-decrypt-option 'known)
7600 (gnus-article-emulate-mime t)
7601 (gnus-buttonized-mime-types (append (list "multipart/signed"
7602 "multipart/encrypted")
7603 gnus-buttonized-mime-types)))
7604 (gnus-summary-select-article nil 'force)))
7606 (defun gnus-summary-set-current-mark (&optional current-mark)
7607 "Obsolete function."
7610 (defun gnus-summary-next-article (&optional unread subject backward push)
7611 "Select the next article.
7612 If UNREAD, only unread articles are selected.
7613 If SUBJECT, only articles with SUBJECT are selected.
7614 If BACKWARD, the previous article is selected instead of the next."
7616 ;; Make sure we are in the summary buffer.
7617 (unless (eq major-mode 'gnus-summary-mode)
7618 (set-buffer gnus-summary-buffer))
7620 ;; Is there such an article?
7621 ((and (gnus-summary-search-forward unread subject backward)
7622 (or (gnus-summary-display-article (gnus-summary-article-number))
7623 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7624 (gnus-summary-position-point))
7625 ;; If not, we try the first unread, if that is wanted.
7627 gnus-auto-select-same
7628 (gnus-summary-first-unread-article))
7629 (gnus-summary-position-point)
7630 (gnus-message 6 "Wrapped"))
7631 ;; Try to get next/previous article not displayed in this group.
7632 ((and gnus-auto-extend-newsgroup
7633 (not unread) (not subject))
7634 (gnus-summary-goto-article
7635 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7636 nil (count-lines (point-min) (point))))
7637 ;; Go to next/previous group.
7639 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7640 (gnus-summary-jump-to-group gnus-newsgroup-name))
7641 (let ((cmd (if (featurep 'xemacs)
7643 last-command-event))
7645 (with-current-buffer gnus-group-buffer
7648 (if (eq gnus-keep-same-level 'best)
7649 (gnus-summary-best-group gnus-newsgroup-name)
7650 (gnus-summary-search-group backward gnus-keep-same-level))))
7651 ;; For some reason, the group window gets selected. We change
7653 (select-window (get-buffer-window (current-buffer)))
7654 ;; Select next unread newsgroup automagically.
7656 ((or (not gnus-auto-select-next)
7658 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7659 ((or (eq gnus-auto-select-next 'quietly)
7660 (and (eq gnus-auto-select-next 'slightly-quietly)
7662 (and (eq gnus-auto-select-next 'almost-quietly)
7663 (gnus-summary-last-article-p)))
7665 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7667 (gnus-message 7 "No more%s articles (%s)..."
7668 (if unread " unread" "")
7669 (if group (concat "selecting " group)
7671 (gnus-summary-next-group nil group backward)))
7673 (when (gnus-key-press-event-p last-input-event)
7674 (gnus-summary-walk-group-buffer
7675 gnus-newsgroup-name cmd unread backward point))))))))
7677 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7678 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7679 (?\C-p (gnus-group-prev-unread-group 1))))
7680 (cursor-in-echo-area t)
7681 keve key group ended prompt)
7682 (with-current-buffer gnus-group-buffer
7685 (if (eq gnus-keep-same-level 'best)
7686 (gnus-summary-best-group gnus-newsgroup-name)
7687 (gnus-summary-search-group backward gnus-keep-same-level))))
7691 "No more%s articles%s " (if unread " unread" "")
7693 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7694 (format " (Type %s for %s [%s])"
7695 (single-key-description cmd)
7696 (gnus-group-decoded-name group)
7697 (gnus-group-unread group))
7698 (format " (Type %s to exit %s)"
7699 (single-key-description cmd)
7700 (gnus-group-decoded-name gnus-newsgroup-name)))))
7701 ;; Confirm auto selection.
7702 (setq key (car (setq keve (gnus-read-event-char prompt)))
7705 ((assq key keystrokes)
7706 (let ((obuf (current-buffer)))
7707 (switch-to-buffer gnus-group-buffer)
7709 (gnus-group-jump-to-group group))
7710 (eval (cadr (assq key keystrokes)))
7711 (setq group (gnus-group-group-name))
7712 (switch-to-buffer obuf))
7716 (gnus-ephemeral-group-p gnus-newsgroup-name))
7718 (gnus-summary-next-group nil group backward)))
7720 (push (cdr keve) unread-command-events))))))
7722 (defun gnus-summary-next-unread-article ()
7723 "Select unread article after current one."
7725 (gnus-summary-next-article
7726 (or (not (eq gnus-summary-goto-unread 'never))
7727 (gnus-summary-last-article-p (gnus-summary-article-number)))
7728 (and gnus-auto-select-same
7729 (gnus-summary-article-subject))))
7731 (defun gnus-summary-prev-article (&optional unread subject)
7732 "Select the article before the current one.
7733 If UNREAD is non-nil, only unread articles are selected."
7735 (gnus-summary-next-article unread subject t))
7737 (defun gnus-summary-prev-unread-article ()
7738 "Select unread article before current one."
7740 (gnus-summary-prev-article
7741 (or (not (eq gnus-summary-goto-unread 'never))
7742 (gnus-summary-first-article-p (gnus-summary-article-number)))
7743 (and gnus-auto-select-same
7744 (gnus-summary-article-subject))))
7746 (defun gnus-summary-next-page (&optional lines circular stop)
7747 "Show next page of the selected article.
7748 If at the end of the current article, select the next article.
7749 LINES says how many lines should be scrolled up.
7751 If CIRCULAR is non-nil, go to the start of the article instead of
7752 selecting the next article when reaching the end of the current
7755 If STOP is non-nil, just stop when reaching the end of the message.
7757 Also see the variable `gnus-article-skip-boring'."
7759 (setq gnus-summary-buffer (current-buffer))
7760 (gnus-set-global-variables)
7761 (let ((article (gnus-summary-article-number))
7762 (article-window (get-buffer-window gnus-article-buffer t))
7764 ;; If the buffer is empty, we have no article.
7766 (error "No article to select"))
7767 (gnus-configure-windows 'article)
7768 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7769 (if (and (eq gnus-summary-goto-unread 'never)
7770 (not (gnus-summary-last-article-p article)))
7771 (gnus-summary-next-article)
7772 (gnus-summary-next-unread-article))
7773 (if (or (null gnus-current-article)
7774 (null gnus-article-current)
7775 (/= article (cdr gnus-article-current))
7776 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7777 ;; Selected subject is different from current article's.
7778 (gnus-summary-display-article article)
7779 (when article-window
7780 (gnus-eval-in-buffer-window gnus-article-buffer
7781 (setq endp (or (gnus-article-next-page lines)
7782 (gnus-article-only-boring-p))))
7784 (cond ((or stop gnus-summary-stop-at-end-of-message)
7785 (gnus-message 3 "End of message"))
7787 (gnus-summary-beginning-of-article))
7789 (gnus-message 3 "End of message"))
7791 (if (and (eq gnus-summary-goto-unread 'never)
7792 (not (gnus-summary-last-article-p article)))
7793 (gnus-summary-next-article)
7794 (gnus-summary-next-unread-article))))))))
7795 (gnus-summary-recenter)
7796 (gnus-summary-position-point)))
7798 (defun gnus-summary-prev-page (&optional lines move)
7799 "Show previous page of selected article.
7800 Argument LINES specifies lines to be scrolled down.
7801 If MOVE, move to the previous unread article if point is at
7802 the beginning of the buffer."
7804 (let ((article (gnus-summary-article-number))
7805 (article-window (get-buffer-window gnus-article-buffer t))
7807 (gnus-configure-windows 'article)
7808 (if (or (null gnus-current-article)
7809 (null gnus-article-current)
7810 (/= article (cdr gnus-article-current))
7811 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7812 ;; Selected subject is different from current article's.
7813 (gnus-summary-display-article article)
7814 (gnus-summary-recenter)
7815 (when article-window
7816 (gnus-eval-in-buffer-window gnus-article-buffer
7817 (setq endp (gnus-article-prev-page lines)))
7818 (when (and move endp)
7820 (gnus-message 3 "Beginning of message"))
7822 (if (and (eq gnus-summary-goto-unread 'never)
7823 (not (gnus-summary-first-article-p article)))
7824 (gnus-summary-prev-article)
7825 (gnus-summary-prev-unread-article))))))))
7826 (gnus-summary-position-point))
7828 (defun gnus-summary-prev-page-or-article (&optional lines)
7829 "Show previous page of selected article.
7830 Argument LINES specifies lines to be scrolled down.
7831 If at the beginning of the article, go to the next article."
7833 (gnus-summary-prev-page lines t))
7835 (defun gnus-summary-scroll-up (lines)
7836 "Scroll up (or down) one line current article.
7837 Argument LINES specifies lines to be scrolled up (or down if negative)."
7839 (gnus-configure-windows 'article)
7840 (gnus-summary-show-thread)
7841 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7842 (gnus-eval-in-buffer-window gnus-article-buffer
7844 (when (gnus-article-next-page lines)
7845 (gnus-message 3 "End of message")))
7847 (gnus-article-prev-page (- lines))))))
7848 (gnus-summary-recenter)
7849 (gnus-summary-position-point))
7851 (defun gnus-summary-scroll-down (lines)
7852 "Scroll down (or up) one line current article.
7853 Argument LINES specifies lines to be scrolled down (or up if negative)."
7855 (gnus-summary-scroll-up (- lines)))
7857 (defun gnus-summary-next-same-subject ()
7858 "Select next article which has the same subject as current one."
7860 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7862 (defun gnus-summary-prev-same-subject ()
7863 "Select previous article which has the same subject as current one."
7865 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7867 (defun gnus-summary-next-unread-same-subject ()
7868 "Select next unread article which has the same subject as current one."
7870 (gnus-summary-next-article t (gnus-summary-article-subject)))
7872 (defun gnus-summary-prev-unread-same-subject ()
7873 "Select previous unread article which has the same subject as current one."
7875 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7877 (defun gnus-summary-first-unread-article ()
7878 "Select the first unread article.
7879 Return nil if there are no unread articles."
7882 (when (gnus-summary-first-subject t)
7883 (gnus-summary-show-thread)
7884 (gnus-summary-first-subject t)
7885 (gnus-summary-display-article (gnus-summary-article-number)))
7886 (gnus-summary-position-point)))
7888 (defun gnus-summary-first-unread-subject ()
7889 "Place the point on the subject line of the first unread article.
7890 Return nil if there are no unread articles."
7893 (when (gnus-summary-first-subject t)
7894 (gnus-summary-show-thread)
7895 (gnus-summary-first-subject t))
7896 (gnus-summary-position-point)))
7898 (defun gnus-summary-first-unseen-subject ()
7899 "Place the point on the subject line of the first unseen article.
7900 Return nil if there are no unseen articles."
7903 (when (gnus-summary-first-subject nil nil t)
7904 (gnus-summary-show-thread)
7905 (gnus-summary-first-subject nil nil t))
7906 (gnus-summary-position-point)))
7908 (defun gnus-summary-first-unseen-or-unread-subject ()
7909 "Place the point on the subject line of the first unseen and unread article.
7910 If all article have been seen, on the subject line of the first unread
7914 (unless (when (gnus-summary-first-subject nil nil t)
7915 (gnus-summary-show-thread)
7916 (gnus-summary-first-subject nil nil t))
7917 (when (gnus-summary-first-subject t)
7918 (gnus-summary-show-thread)
7919 (gnus-summary-first-subject t)))
7920 (gnus-summary-position-point)))
7922 (defun gnus-summary-first-article ()
7923 "Select the first article.
7924 Return nil if there are no articles."
7927 (when (gnus-summary-first-subject)
7928 (gnus-summary-show-thread)
7929 (gnus-summary-first-subject)
7930 (gnus-summary-display-article (gnus-summary-article-number)))
7931 (gnus-summary-position-point)))
7933 (defun gnus-summary-best-unread-article (&optional arg)
7934 "Select the unread article with the highest score.
7935 If given a prefix argument, select the next unread article that has a
7936 score higher than the default score."
7938 (let ((article (if arg
7939 (gnus-summary-better-unread-subject)
7940 (gnus-summary-best-unread-subject))))
7942 (gnus-summary-goto-article article)
7943 (error "No unread articles"))))
7945 (defun gnus-summary-best-unread-subject ()
7946 "Select the unread subject with the highest score."
7948 (let ((best -1000000)
7949 (data gnus-newsgroup-data)
7952 (and (gnus-data-unread-p (car data))
7954 (gnus-summary-article-score (gnus-data-number (car data))))
7957 article (gnus-data-number (car data))))
7958 (setq data (cdr data)))
7960 (gnus-summary-goto-subject article))
7961 (gnus-summary-position-point)
7964 (defun gnus-summary-better-unread-subject ()
7965 "Select the first unread subject that has a score over the default score."
7967 (let ((data gnus-newsgroup-data)
7969 (while (and (setq article (gnus-data-number (car data)))
7970 (or (gnus-data-read-p (car data))
7971 (not (> (gnus-summary-article-score article)
7972 gnus-summary-default-score))))
7973 (setq data (cdr data)))
7975 (gnus-summary-goto-subject article))
7976 (gnus-summary-position-point)
7979 (defun gnus-summary-last-subject ()
7980 "Go to the last displayed subject line in the group."
7981 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7983 (gnus-summary-goto-subject article))))
7985 (defun gnus-summary-goto-article (article &optional all-headers force)
7986 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7987 If ALL-HEADERS is non-nil, no header lines are hidden.
7988 If FORCE, go to the article even if it isn't displayed. If FORCE
7989 is a number, it is the line the article is to be displayed on."
7993 "Article number or Message-ID: "
7994 (mapcar (lambda (number) (list (int-to-string number)))
7995 gnus-newsgroup-limit))
7999 (if (and (stringp article)
8000 (string-match "@\\|%40" article))
8001 (gnus-summary-refer-article article)
8002 (when (stringp article)
8003 (setq article (string-to-number article)))
8004 (if (gnus-summary-goto-subject article force)
8005 (gnus-summary-display-article article all-headers)
8006 (gnus-message 4 "Couldn't go to article %s" article) nil))
8007 (gnus-summary-position-point)))
8009 (defun gnus-summary-goto-last-article ()
8010 "Go to the previously read article."
8013 (when gnus-last-article
8014 (gnus-summary-goto-article gnus-last-article nil t))
8015 (gnus-summary-position-point)))
8017 (defun gnus-summary-pop-article (number)
8018 "Pop one article off the history and go to the previous.
8019 NUMBER articles will be popped off."
8022 (setq gnus-newsgroup-history
8023 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8025 (gnus-summary-goto-article (car to) nil t)
8026 (error "Article history empty")))
8027 (gnus-summary-position-point))
8029 ;; Summary commands and functions for limiting the summary buffer.
8031 (defun gnus-summary-limit-to-articles (n)
8032 "Limit the summary buffer to the next N articles.
8033 If not given a prefix, use the process marked articles instead."
8036 (let ((articles (gnus-summary-work-articles n)))
8037 (setq gnus-newsgroup-processable nil)
8038 (gnus-summary-limit articles))
8039 (gnus-summary-position-point)))
8041 (defun gnus-summary-pop-limit (&optional total)
8042 "Restore the previous limit.
8043 If given a prefix, remove all limits."
8046 (setq gnus-newsgroup-limits
8047 (list (mapcar (lambda (h) (mail-header-number h))
8048 gnus-newsgroup-headers))))
8049 (unless gnus-newsgroup-limits
8050 (error "No limit to pop"))
8052 (gnus-summary-limit nil 'pop)
8053 (gnus-summary-position-point)))
8055 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8056 "Limit the summary buffer to articles that have subjects that match a regexp.
8057 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8059 (list (read-string (if current-prefix-arg
8060 "Exclude subject (regexp): "
8061 "Limit to subject (regexp): "))
8062 nil current-prefix-arg))
8064 (setq header "subject"))
8065 (when (not (equal "" subject))
8067 (let ((articles (gnus-summary-find-matching
8068 (or header "subject") subject 'all nil nil
8071 (error "Found no matches for \"%s\"" subject))
8072 (gnus-summary-limit articles))
8073 (gnus-summary-position-point))))
8075 (defun gnus-summary-limit-to-author (from &optional not-matching)
8076 "Limit the summary buffer to articles that have authors that match a regexp.
8077 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8079 (list (read-string (if current-prefix-arg
8080 "Exclude author (regexp): "
8081 "Limit to author (regexp): "))
8082 current-prefix-arg))
8083 (gnus-summary-limit-to-subject from "from" not-matching))
8085 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8086 "Limit the summary buffer to articles with the given RECIPIENT.
8088 If NOT-MATCHING, exclude RECIPIENT.
8090 To and Cc headers are checked. You need to include them in
8091 `nnmail-extra-headers'."
8092 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8094 (list (read-string (format "%s recipient (regexp): "
8095 (if current-prefix-arg "Exclude" "Limit to")))
8096 current-prefix-arg))
8097 (when (not (equal "" recipient))
8099 (if (memq 'To nnmail-extra-headers)
8100 (gnus-summary-find-matching
8101 (cons 'extra 'To) recipient 'all nil nil
8104 1 "`To' isn't present in `nnmail-extra-headers'")
8108 (if (memq 'Cc nnmail-extra-headers)
8109 (gnus-summary-find-matching
8110 (cons 'extra 'Cc) recipient 'all nil nil
8113 1 "`Cc' isn't present in `nnmail-extra-headers'")
8118 ;; We need the numbers that are in both lists:
8120 (and (memq a to) a))
8124 (error "Found no matches for \"%s\"" recipient))
8125 (gnus-summary-limit articles))
8126 (gnus-summary-position-point))))
8128 (defun gnus-summary-limit-to-address (address &optional not-matching)
8129 "Limit the summary buffer to articles with the given ADDRESS.
8131 If NOT-MATCHING, exclude ADDRESS.
8133 To, Cc and From headers are checked. You need to include `To' and `Cc'
8134 in `nnmail-extra-headers'."
8136 (list (read-string (format "%s address (regexp): "
8137 (if current-prefix-arg "Exclude" "Limit to")))
8138 current-prefix-arg))
8139 (when (not (equal "" address))
8141 (if (memq 'To nnmail-extra-headers)
8142 (gnus-summary-find-matching
8143 (cons 'extra 'To) address 'all nil nil
8146 1 "`To' isn't present in `nnmail-extra-headers'")
8150 (if (memq 'Cc nnmail-extra-headers)
8151 (gnus-summary-find-matching
8152 (cons 'extra 'Cc) address 'all nil nil
8155 1 "`Cc' isn't present in `nnmail-extra-headers'")
8159 (gnus-summary-find-matching "from" address
8160 'all nil nil not-matching))
8163 ;; We need the numbers that are in all lists:
8167 (mapcar (lambda (a) (car (memq a from))) to))
8169 (mapcar (lambda (a) (car (memq a from))) cc)
8170 (mapcar (lambda (a) (car (memq a from)))
8171 (mapcar (lambda (a) (car (memq a to)))
8173 (nconc (if (eq to t) nil to)
8174 (if (eq cc t) nil cc)
8177 (error "Found no matches for \"%s\"" address))
8178 (gnus-summary-limit articles))
8179 (gnus-summary-position-point))))
8181 (defun gnus-summary-limit-strange-charsets-predicate (header)
8182 (when (fboundp 'char-charset)
8183 (let ((string (concat (mail-header-subject header)
8184 (mail-header-from header)))
8186 (dotimes (i (1- (length string)))
8187 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8188 (when (string-match "unicode\\|big\\|japanese" charset)
8192 (defun gnus-summary-limit-to-predicate (predicate)
8193 "Limit to articles where PREDICATE returns non-nil.
8194 PREDICATE will be called with the header structures of the
8196 (let ((articles nil)
8197 (case-fold-search t))
8198 (dolist (header gnus-newsgroup-headers)
8199 (when (funcall predicate header)
8200 (push (mail-header-number header) articles)))
8201 (gnus-summary-limit (nreverse articles))))
8203 (defun gnus-summary-limit-to-age (age &optional younger-p)
8204 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8205 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8206 articles that are younger than AGE days."
8208 (let ((younger current-prefix-arg)
8211 (while (not days-got)
8212 (setq days (if younger
8213 (read-string "Limit to articles younger than (in days, older when negative): ")
8215 "Limit to articles older than (in days, younger when negative): ")))
8216 (when (> (length days) 0)
8217 (setq days (read days)))
8222 (setq younger (not younger))
8223 (setq days (* days -1))))
8224 (message "Please enter a number.")
8226 (list days younger)))
8228 (let ((data gnus-newsgroup-data)
8229 (cutoff (days-to-time age))
8230 articles d date is-younger)
8231 (while (setq d (pop data))
8232 (when (and (vectorp (gnus-data-header d))
8233 (setq date (mail-header-date (gnus-data-header d))))
8234 (setq is-younger (time-less-p
8235 (time-since (gnus-date-get-time date))
8240 (push (gnus-data-number d) articles))))
8241 (gnus-summary-limit (nreverse articles)))
8242 (gnus-summary-position-point)))
8244 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8245 "Limit the summary buffer to articles that match an 'extra' header."
8249 (gnus-completing-read-with-default
8250 (symbol-name (car gnus-extra-headers))
8251 (if current-prefix-arg
8252 "Exclude extra header"
8253 "Limit extra header")
8255 (cons (symbol-name x) x))
8260 (read-string (format "%s header %s (regexp): "
8261 (if current-prefix-arg "Exclude" "Limit to")
8263 current-prefix-arg)))
8264 (when (not (equal "" regexp))
8266 (let ((articles (gnus-summary-find-matching
8267 (cons 'extra header) regexp 'all nil nil
8270 (error "Found no matches for \"%s\"" regexp))
8271 (gnus-summary-limit articles))
8272 (gnus-summary-position-point))))
8274 (defun gnus-summary-limit-to-display-predicate ()
8275 "Limit the summary buffer to the predicated in the `display' group parameter."
8277 (unless gnus-newsgroup-display
8278 (error "There is no `display' group parameter"))
8280 (dolist (number gnus-newsgroup-articles)
8281 (when (funcall gnus-newsgroup-display)
8282 (push number articles)))
8283 (gnus-summary-limit articles))
8284 (gnus-summary-position-point))
8286 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8288 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
8290 (defun gnus-summary-limit-to-unread (&optional all)
8291 "Limit the summary buffer to articles that are not marked as read.
8292 If ALL is non-nil, limit strictly to unread articles."
8295 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8296 (gnus-summary-limit-to-marks
8297 ;; Concat all the marks that say that an article is read and have
8299 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8300 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8301 gnus-low-score-mark gnus-expirable-mark
8302 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8303 gnus-duplicate-mark)
8306 (defun gnus-summary-limit-to-headers (match &optional reverse)
8307 "Limit the summary buffer to articles that have headers that match MATCH.
8308 If REVERSE (the prefix), limit to articles that don't match."
8309 (interactive "sMatch headers (regexp): \nP")
8310 (gnus-summary-limit-to-bodies match reverse t))
8312 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8313 "Limit the summary buffer to articles that have bodies that match MATCH.
8314 If REVERSE (the prefix), limit to articles that don't match."
8315 (interactive "sMatch body (regexp): \nP")
8316 (let ((articles nil)
8317 (gnus-select-article-hook nil) ;Disable hook.
8318 (gnus-article-prepare-hook nil)
8319 (gnus-use-article-prefetch nil)
8320 (gnus-keep-backlog nil)
8321 (gnus-break-pages nil)
8322 (gnus-summary-display-arrow nil)
8323 (gnus-updated-mode-lines nil)
8324 (gnus-auto-center-summary nil)
8325 (gnus-display-mime-function nil))
8326 (dolist (data gnus-newsgroup-data)
8327 (let (gnus-mark-article-hook)
8328 (gnus-summary-select-article t t nil (gnus-data-number data)))
8329 (with-current-buffer gnus-article-buffer
8331 (let* ((case-fold-search t)
8333 (re-search-backward match nil t)
8334 (re-search-forward match nil t))))
8335 (when (or (and found
8339 (push (gnus-data-number data) articles)))))
8341 (message "No messages matched")
8342 (gnus-summary-limit articles)))
8343 (gnus-summary-position-point))
8345 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8346 "Limit the summary buffer to articles that aren't part on any thread.
8347 If THREADSP (the prefix), limit to articles that are in threads."
8349 (let ((articles nil)
8352 (dolist (thread gnus-newsgroup-threads)
8353 (if (stringp (car thread))
8354 (dolist (thread (cdr thread))
8355 (push thread threads))
8356 (push thread threads)))
8357 (dolist (thread threads)
8358 (setq thread-articles (gnus-articles-in-thread thread))
8359 (when (or (and threadsp
8360 (> (length thread-articles) 1))
8362 (= (length thread-articles) 1)))
8363 (setq articles (nconc thread-articles articles))))
8365 (message "No messages matched")
8366 (gnus-summary-limit articles))
8367 (gnus-summary-position-point)))
8369 (defun gnus-summary-limit-to-replied (&optional unreplied)
8370 "Limit the summary buffer to replied articles.
8371 If UNREPLIED (the prefix), limit to unreplied articles."
8375 (gnus-set-difference gnus-newsgroup-articles
8376 gnus-newsgroup-replied))
8377 (gnus-summary-limit gnus-newsgroup-replied))
8378 (gnus-summary-position-point))
8380 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8381 (make-obsolete 'gnus-summary-delete-marked-with
8382 'gnus-summary-limit-exclude-marks "Emacs 20.4")
8384 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8385 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8386 If REVERSE, limit the summary buffer to articles that are marked
8387 with MARKS. MARKS can either be a string of marks or a list of marks.
8388 Returns how many articles were removed."
8389 (interactive "sMarks: ")
8390 (gnus-summary-limit-to-marks marks t))
8392 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8393 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8394 If REVERSE (the prefix), limit the summary buffer to articles that are
8395 not marked with MARKS. MARKS can either be a string of marks or a
8397 Returns how many articles were removed."
8398 (interactive "sMarks: \nP")
8400 (let ((data gnus-newsgroup-data)
8401 (marks (if (listp marks) marks
8402 (append marks nil))) ; Transform to list.
8405 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8406 (memq (gnus-data-mark (car data)) marks))
8407 (push (gnus-data-number (car data)) articles))
8408 (setq data (cdr data)))
8409 (gnus-summary-limit articles))
8410 (gnus-summary-position-point)))
8412 (defun gnus-summary-limit-to-score (score)
8413 "Limit to articles with score at or above SCORE."
8414 (interactive "NLimit to articles with score of at least: ")
8415 (let ((data gnus-newsgroup-data)
8418 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8420 (push (gnus-data-number (car data)) articles))
8421 (setq data (cdr data)))
8423 (gnus-summary-limit articles)
8424 (gnus-summary-position-point))))
8426 (defun gnus-summary-limit-to-unseen ()
8427 "Limit to unseen articles."
8430 (gnus-summary-limit gnus-newsgroup-unseen)
8431 (gnus-summary-position-point)))
8433 (defun gnus-summary-limit-include-thread (id)
8434 "Display all the hidden articles that is in the thread with ID in it.
8435 When called interactively, ID is the Message-ID of the current
8437 (interactive (list (mail-header-id (gnus-summary-article-header))))
8438 (let ((articles (gnus-articles-in-thread
8439 (gnus-id-to-thread (gnus-root-id id)))))
8441 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8442 (gnus-summary-limit-include-matching-articles
8444 (regexp-quote (gnus-simplify-subject-re
8445 (mail-header-subject (gnus-id-to-header id)))))
8446 (gnus-summary-position-point))))
8448 (defun gnus-summary-limit-include-matching-articles (header regexp)
8449 "Display all the hidden articles that have HEADERs that match REGEXP."
8450 (interactive (list (read-string "Match on header: ")
8451 (read-string "Regexp: ")))
8452 (let ((articles (gnus-find-matching-articles header regexp)))
8454 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8455 (gnus-summary-position-point))))
8457 (defun gnus-summary-insert-dormant-articles ()
8458 "Insert all the dormant articles for this group into the current buffer."
8460 (let ((gnus-verbose (max 6 gnus-verbose)))
8461 (if (not gnus-newsgroup-dormant)
8462 (gnus-message 3 "No dormant articles for this group")
8463 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8465 (defun gnus-summary-insert-ticked-articles ()
8466 "Insert ticked articles for this group into the current buffer."
8468 (let ((gnus-verbose (max 6 gnus-verbose)))
8469 (if (not gnus-newsgroup-marked)
8470 (gnus-message 3 "No ticked articles for this group")
8471 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8473 (defun gnus-summary-limit-include-dormant ()
8474 "Display all the hidden articles that are marked as dormant.
8475 Note that this command only works on a subset of the articles currently
8476 fetched for this group."
8478 (unless gnus-newsgroup-dormant
8479 (error "There are no dormant articles in this group"))
8481 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8482 (gnus-summary-position-point)))
8484 (defun gnus-summary-limit-exclude-dormant ()
8485 "Hide all dormant articles."
8488 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8489 (gnus-summary-position-point)))
8491 (defun gnus-summary-limit-exclude-childless-dormant ()
8492 "Hide all dormant articles that have no children."
8494 (let ((data (gnus-data-list t))
8495 articles d children)
8496 ;; Find all articles that are either not dormant or have
8498 (while (setq d (pop data))
8499 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8501 (gnus-article-children (gnus-data-number d)))
8504 (when (memq (car children) articles)
8509 (push (gnus-data-number d) articles)))
8512 (gnus-summary-limit articles)
8513 (gnus-summary-position-point))))
8515 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8516 "Mark all unread excluded articles as read.
8517 If ALL, mark even excluded ticked and dormants as read."
8519 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8520 (let ((articles (gnus-sorted-ndifference
8522 (mapcar (lambda (h) (mail-header-number h))
8523 gnus-newsgroup-headers)
8525 gnus-newsgroup-limit))
8527 (setq gnus-newsgroup-unreads
8528 (gnus-sorted-intersection gnus-newsgroup-unreads
8529 gnus-newsgroup-limit))
8531 (setq gnus-newsgroup-dormant nil
8532 gnus-newsgroup-marked nil
8533 gnus-newsgroup-reads
8535 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8536 gnus-newsgroup-reads))
8537 (while (setq article (pop articles))
8538 (unless (or (memq article gnus-newsgroup-dormant)
8539 (memq article gnus-newsgroup-marked))
8540 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8542 (defun gnus-summary-limit (articles &optional pop)
8544 ;; We pop the previous limit off the stack and use that.
8545 (setq articles (car gnus-newsgroup-limits)
8546 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8547 ;; We use the new limit, so we push the old limit on the stack.
8548 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8550 (setq gnus-newsgroup-limit articles)
8551 (let ((total (length gnus-newsgroup-data))
8552 (data (gnus-data-find-list (gnus-summary-article-number)))
8553 (gnus-summary-mark-below nil) ; Inhibit this.
8555 ;; This will do all the work of generating the new summary buffer
8556 ;; according to the new limit.
8557 (gnus-summary-prepare)
8558 ;; Hide any threads, possibly.
8559 (gnus-summary-maybe-hide-threads)
8560 ;; Try to return to the article you were at, or one in the
8563 ;; We try to find some article after the current one.
8565 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8568 (setq data (cdr data))))
8570 ;; If there is no data, that means that we were after the last
8571 ;; article. The same goes when we can't find any articles
8572 ;; after the current one.
8573 (goto-char (point-max))
8574 (gnus-summary-find-prev))
8575 (gnus-set-mode-line 'summary)
8576 ;; We return how many articles were removed from the summary
8577 ;; buffer as a result of the new limit.
8578 (- total (length gnus-newsgroup-data))))
8580 (defsubst gnus-invisible-cut-children (threads)
8583 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8588 (defsubst gnus-cut-thread (thread)
8589 "Go forwards in the thread until we find an article that we want to display."
8590 (when (or (eq gnus-fetch-old-headers 'some)
8591 (eq gnus-fetch-old-headers 'invisible)
8592 (numberp gnus-fetch-old-headers)
8593 (eq gnus-build-sparse-threads 'some)
8594 (eq gnus-build-sparse-threads 'more))
8595 ;; Deal with old-fetched headers and sparse threads.
8599 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8600 (gnus-summary-article-ancient-p
8601 (mail-header-number (car thread))))
8602 (if (or (<= (length (cdr thread)) 1)
8603 (eq gnus-fetch-old-headers 'invisible))
8604 (setq gnus-newsgroup-limit
8605 (delq (mail-header-number (car thread))
8606 gnus-newsgroup-limit)
8607 thread (cadr thread))
8608 (when (gnus-invisible-cut-children (cdr thread))
8609 (let ((th (cdr thread)))
8611 (if (memq (mail-header-number (caar th))
8612 gnus-newsgroup-limit)
8613 (setq thread (car th)
8615 (setq th (cdr th))))))))))
8618 (defun gnus-cut-threads (threads)
8619 "Cut off all uninteresting articles from the beginning of THREADS."
8620 (when (or (eq gnus-fetch-old-headers 'some)
8621 (eq gnus-fetch-old-headers 'invisible)
8622 (numberp gnus-fetch-old-headers)
8623 (eq gnus-build-sparse-threads 'some)
8624 (eq gnus-build-sparse-threads 'more))
8627 (setcar th (gnus-cut-thread (car th)))
8628 (setq th (cdr th)))))
8629 ;; Remove nixed out threads.
8632 (defun gnus-summary-initial-limit (&optional show-if-empty)
8633 "Figure out what the initial limit is supposed to be on group entry.
8634 This entails weeding out unwanted dormants, low-scored articles,
8635 fetch-old-headers verbiage, and so on."
8636 ;; Most groups have nothing to remove.
8637 (unless (or gnus-inhibit-limiting
8638 (and (null gnus-newsgroup-dormant)
8639 (eq gnus-newsgroup-display 'gnus-not-ignore)
8640 (not (eq gnus-fetch-old-headers 'some))
8641 (not (numberp gnus-fetch-old-headers))
8642 (not (eq gnus-fetch-old-headers 'invisible))
8643 (null gnus-summary-expunge-below)
8644 (not (eq gnus-build-sparse-threads 'some))
8645 (not (eq gnus-build-sparse-threads 'more))
8646 (null gnus-thread-expunge-below)
8647 (not gnus-use-nocem)))
8648 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8649 (setq gnus-newsgroup-limit nil)
8652 (unless (car (symbol-value node))
8653 ;; These threads have no parents -- they are roots.
8654 (let ((nodes (cdr (symbol-value node)))
8657 (if (and gnus-thread-expunge-below
8658 (< (gnus-thread-total-score (car nodes))
8659 gnus-thread-expunge-below))
8660 (gnus-expunge-thread (pop nodes))
8661 (setq thread (pop nodes))
8662 (gnus-summary-limit-children thread))))))
8663 gnus-newsgroup-dependencies)
8664 ;; If this limitation resulted in an empty group, we might
8665 ;; pop the previous limit and use it instead.
8666 (when (and (not gnus-newsgroup-limit)
8668 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8669 gnus-newsgroup-limit))
8671 (defun gnus-summary-limit-children (thread)
8672 "Return 1 if this subthread is visible and 0 if it is not."
8673 ;; First we get the number of visible children to this thread. This
8674 ;; is done by recursing down the thread using this function, so this
8675 ;; will really go down to a leaf article first, before slowly
8676 ;; working its way up towards the root.
8678 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8681 (apply '+ (mapcar 'gnus-summary-limit-children
8684 (number (mail-header-number (car thread)))
8687 (not (memq number gnus-newsgroup-marked))
8689 ;; If this article is dormant and has absolutely no visible
8690 ;; children, then this article isn't visible.
8691 (and (memq number gnus-newsgroup-dormant)
8693 ;; If this is "fetch-old-headered" and there is no
8694 ;; visible children, then we don't want this article.
8695 (and (or (eq gnus-fetch-old-headers 'some)
8696 (numberp gnus-fetch-old-headers))
8697 (gnus-summary-article-ancient-p number)
8699 ;; If this is "fetch-old-headered" and `invisible', then
8700 ;; we don't want this article.
8701 (and (eq gnus-fetch-old-headers 'invisible)
8702 (gnus-summary-article-ancient-p number))
8703 ;; If this is a sparsely inserted article with no children,
8704 ;; we don't want it.
8705 (and (eq gnus-build-sparse-threads 'some)
8706 (gnus-summary-article-sparse-p number)
8708 ;; If we use expunging, and this article is really
8709 ;; low-scored, then we don't want this article.
8710 (when (and gnus-summary-expunge-below
8712 (or (cdr (assq number gnus-newsgroup-scored))
8713 gnus-summary-default-score))
8714 gnus-summary-expunge-below))
8715 ;; We increase the expunge-tally here, but that has
8716 ;; nothing to do with the limits, really.
8717 (incf gnus-newsgroup-expunged-tally)
8718 ;; We also mark as read here, if that's wanted.
8719 (when (and gnus-summary-mark-below
8720 (< score gnus-summary-mark-below))
8721 (setq gnus-newsgroup-unreads
8722 (delq number gnus-newsgroup-unreads))
8723 (if gnus-newsgroup-auto-expire
8724 (push number gnus-newsgroup-expirable)
8725 (push (cons number gnus-low-score-mark)
8726 gnus-newsgroup-reads)))
8728 ;; Do the `display' group parameter.
8729 (and gnus-newsgroup-display
8730 (not (funcall gnus-newsgroup-display)))
8731 ;; Check NoCeM things.
8732 (when (and gnus-use-nocem
8733 (gnus-nocem-unwanted-article-p
8734 (mail-header-id (car thread))))
8735 (setq gnus-newsgroup-unreads
8736 (delq number gnus-newsgroup-unreads))
8738 ;; Nope, invisible article.
8740 ;; Ok, this article is to be visible, so we add it to the limit
8742 (push number gnus-newsgroup-limit)
8745 (defun gnus-expunge-thread (thread)
8746 "Mark all articles in THREAD as read."
8747 (let* ((number (mail-header-number (car thread))))
8748 (incf gnus-newsgroup-expunged-tally)
8749 ;; We also mark as read here, if that's wanted.
8750 (setq gnus-newsgroup-unreads
8751 (delq number gnus-newsgroup-unreads))
8752 (if gnus-newsgroup-auto-expire
8753 (push number gnus-newsgroup-expirable)
8754 (push (cons number gnus-low-score-mark)
8755 gnus-newsgroup-reads)))
8756 ;; Go recursively through all subthreads.
8757 (mapcar 'gnus-expunge-thread (cdr thread)))
8759 ;; Summary article oriented commands
8761 (defun gnus-summary-refer-parent-article (n)
8762 "Refer parent article N times.
8763 If N is negative, go to ancestor -N instead.
8764 The difference between N and the number of articles fetched is returned."
8768 (when (not (natnump n))
8773 (setq header (gnus-summary-article-header))
8774 (if (and (eq (mail-header-number header)
8775 (cdr gnus-article-current))
8776 (equal gnus-newsgroup-name
8777 (car gnus-article-current)))
8778 ;; If we try to find the parent of the currently
8779 ;; displayed article, then we take a look at the actual
8780 ;; References header, since this is slightly more
8781 ;; reliable than the References field we got from the
8783 (with-current-buffer gnus-original-article-buffer
8784 (nnheader-narrow-to-headers)
8785 (unless (setq ref (message-fetch-field "references"))
8786 (when (setq ref (message-fetch-field "in-reply-to"))
8787 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8790 ;; It's not the current article, so we take a bet on
8791 ;; the value we got from the server.
8792 (mail-header-references header)))
8794 (not (equal ref "")))
8795 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8796 (gnus-message 1 "Couldn't find parent"))
8797 (gnus-message 1 "No references in article %d"
8798 (gnus-summary-article-number))
8801 (gnus-summary-position-point)
8804 (defun gnus-summary-refer-references ()
8805 "Fetch all articles mentioned in the References header.
8806 Return the number of articles fetched."
8808 (let ((ref (mail-header-references (gnus-summary-article-header)))
8809 (current (gnus-summary-article-number))
8813 (error "No References in the current article")
8814 ;; For each Message-ID in the References header...
8815 (while (string-match "<[^>]*>" ref)
8817 ;; ... fetch that article.
8818 (gnus-summary-refer-article
8819 (prog1 (match-string 0 ref)
8820 (setq ref (substring ref (match-end 0))))))
8821 (gnus-summary-goto-subject current)
8822 (gnus-summary-position-point)
8825 (defun gnus-summary-refer-thread (&optional limit)
8826 "Fetch all articles in the current thread.
8827 If LIMIT (the numerical prefix), fetch that many old headers instead
8828 of what's specified by the `gnus-refer-thread-limit' variable."
8830 (let ((id (mail-header-id (gnus-summary-article-header)))
8831 (limit (if limit (prefix-numeric-value limit)
8832 gnus-refer-thread-limit)))
8833 (unless (eq gnus-fetch-old-headers 'invisible)
8834 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8835 ;; Retrieve the headers and read them in.
8836 (if (eq (if (numberp limit)
8837 (gnus-retrieve-headers
8839 (+ (mail-header-number
8840 (gnus-summary-article-header))
8842 gnus-newsgroup-end))
8843 gnus-newsgroup-name (* limit 2))
8844 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8846 (gnus-retrieve-headers (list gnus-newsgroup-end)
8847 gnus-newsgroup-name limit))
8849 (gnus-build-all-threads)
8850 (error "Can't fetch thread from back ends that don't support NOV"))
8851 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8852 (gnus-summary-limit-include-thread id)))
8854 (defun gnus-summary-refer-article (message-id)
8855 "Fetch an article specified by MESSAGE-ID."
8856 (interactive "sMessage-ID: ")
8857 (when (and (stringp message-id)
8858 (not (zerop (length message-id))))
8859 (setq message-id (gnus-replace-in-string message-id " " ""))
8860 ;; Construct the correct Message-ID if necessary.
8861 ;; Suggested by tale@pawl.rpi.edu.
8862 (unless (string-match "^<" message-id)
8863 (setq message-id (concat "<" message-id)))
8864 (unless (string-match ">$" message-id)
8865 (setq message-id (concat message-id ">")))
8866 ;; People often post MIDs from URLs, so unhex it:
8867 (unless (string-match "@" message-id)
8868 (setq message-id (gnus-url-unhex-string message-id)))
8869 (let* ((header (gnus-id-to-header message-id))
8871 (gnus-summary-article-sparse-p
8872 (mail-header-number header))
8873 (memq (mail-header-number header)
8874 gnus-newsgroup-limit)))
8877 ;; If the article is present in the buffer we just go to it.
8879 (or (not (gnus-summary-article-sparse-p
8880 (mail-header-number header)))
8883 (gnus-summary-goto-article
8884 (mail-header-number header) nil t)
8886 (gnus-summary-update-article (mail-header-number header)))))
8888 ;; We fetch the article.
8890 (dolist (gnus-override-method (gnus-refer-article-methods))
8891 (when (and (gnus-check-server gnus-override-method)
8892 ;; Fetch the header,
8893 (setq number (gnus-summary-insert-subject message-id)))
8894 ;; and display the article.
8895 (gnus-summary-select-article nil nil nil number)
8897 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8899 (defun gnus-refer-article-methods ()
8900 "Return a list of referable methods."
8902 ;; No method, so we default to current and native.
8903 ((null gnus-refer-article-method)
8904 (list gnus-current-select-method gnus-select-method))
8906 ((eq 'current gnus-refer-article-method)
8907 (list gnus-current-select-method))
8908 ;; List of select methods.
8909 ((not (and (symbolp (car gnus-refer-article-method))
8910 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8912 (dolist (method gnus-refer-article-method)
8913 (push (if (eq 'current method)
8914 gnus-current-select-method
8918 ;; One single select method.
8920 (list gnus-refer-article-method))))
8922 (defun gnus-summary-edit-parameters ()
8923 "Edit the group parameters of the current group."
8925 (gnus-group-edit-group gnus-newsgroup-name 'params))
8927 (defun gnus-summary-customize-parameters ()
8928 "Customize the group parameters of the current group."
8930 (gnus-group-customize gnus-newsgroup-name))
8932 (defun gnus-summary-enter-digest-group (&optional force)
8933 "Enter an nndoc group based on the current article.
8934 If FORCE, force a digest interpretation. If not, try
8935 to guess what the document format is."
8937 (let ((conf gnus-current-window-configuration))
8938 (save-window-excursion
8940 (let (gnus-article-prepare-hook
8941 gnus-display-mime-function
8943 (gnus-summary-select-article))))
8944 (setq gnus-current-window-configuration conf)
8945 (let* ((name (format "%s-%d"
8946 (gnus-group-prefixed-name
8947 gnus-newsgroup-name (list 'nndoc ""))
8948 (with-current-buffer gnus-summary-buffer
8949 gnus-current-article)))
8950 (ogroup gnus-newsgroup-name)
8951 (params (append (gnus-info-params (gnus-get-info ogroup))
8952 (list (cons 'to-group ogroup))
8953 (list (cons 'parent-group ogroup))
8954 (list (cons 'save-article-group ogroup))))
8955 (case-fold-search t)
8956 (buf (current-buffer))
8958 (with-current-buffer gnus-original-article-buffer
8959 ;; Have the digest group inherit the main mail address of
8960 ;; the parent article.
8961 (when (setq to-address (or (gnus-fetch-field "reply-to")
8962 (gnus-fetch-field "from")))
8965 (list (cons 'to-address
8966 (funcall gnus-decode-encoded-address-function
8968 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8969 (insert-buffer-substring gnus-original-article-buffer)
8970 ;; Remove lines that may lead nndoc to misinterpret the
8973 (goto-char (point-min))
8974 (or (search-forward "\n\n" nil t) (point)))
8975 (goto-char (point-min))
8976 (delete-matching-lines "^Path:\\|^From ")
8979 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8980 (gnus-newsgroup-ephemeral-ignored-charsets
8981 gnus-newsgroup-ignored-charsets))
8982 (gnus-group-read-ephemeral-group
8983 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8985 ,(if force 'mbox 'guess)))
8987 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8989 ;; Make all postings to this group go to the parent group.
8990 (nconc (gnus-info-params (gnus-get-info name))
8992 ;; Couldn't select this doc group.
8993 (switch-to-buffer buf)
8994 (gnus-set-global-variables)
8995 (gnus-configure-windows 'summary)
8996 (gnus-message 3 "Article couldn't be entered?"))
8997 (kill-buffer dig)))))
8999 (defun gnus-summary-read-document (n)
9000 "Open a new group based on the current article(s).
9001 This will allow you to read digests and other similar
9002 documents as newsgroups.
9003 Obeys the standard process/prefix convention."
9005 (let* ((ogroup gnus-newsgroup-name)
9006 (params (append (gnus-info-params (gnus-get-info ogroup))
9007 (list (cons 'to-group ogroup))))
9008 group egroup groups vgroup)
9009 (dolist (article (gnus-summary-work-articles n))
9010 (setq group (format "%s-%d" gnus-newsgroup-name article))
9011 (gnus-summary-remove-process-mark article)
9012 (when (gnus-summary-display-article article)
9013 (save-excursion ;;What for?
9015 (insert-buffer-substring gnus-original-article-buffer)
9016 ;; Remove some headers that may lead nndoc to make
9018 (message-narrow-to-head)
9019 (goto-char (point-min))
9020 (delete-matching-lines "^Path:\\|^From ")
9023 (gnus-group-read-ephemeral-group
9024 group `(nndoc ,group (nndoc-address ,(current-buffer))
9025 (nndoc-article-type guess))
9028 ;; Make all postings to this group go to the parent group.
9029 (nconc (gnus-info-params (gnus-get-info egroup))
9031 (push egroup groups))
9032 ;; Couldn't select this doc group.
9033 (gnus-error 3 "Article couldn't be entered"))))))
9034 ;; Now we have selected all the documents.
9037 (error "None of the articles could be interpreted as documents"))
9038 ((gnus-group-read-ephemeral-group
9039 (setq vgroup (format
9040 "nnvirtual:%s-%s" gnus-newsgroup-name
9041 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9042 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9044 (cons (current-buffer) 'summary)))
9046 (error "Couldn't select virtual nndoc group")))))
9048 (defun gnus-summary-isearch-article (&optional regexp-p)
9049 "Do incremental search forward on the current article.
9050 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9052 (gnus-summary-select-article)
9053 (gnus-configure-windows 'article)
9054 (gnus-eval-in-buffer-window gnus-article-buffer
9057 (isearch-forward regexp-p))))
9059 (defun gnus-summary-repeat-search-article-forward ()
9060 "Repeat the previous search forwards."
9062 (unless gnus-last-search-regexp
9063 (error "No previous search"))
9064 (gnus-summary-search-article-forward gnus-last-search-regexp))
9066 (defun gnus-summary-repeat-search-article-backward ()
9067 "Repeat the previous search backwards."
9069 (unless gnus-last-search-regexp
9070 (error "No previous search"))
9071 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9073 (defun gnus-summary-search-article-forward (regexp &optional backward)
9074 "Search for an article containing REGEXP forward.
9075 If BACKWARD, search backward instead."
9078 (format "Search article %s (regexp%s): "
9079 (if current-prefix-arg "backward" "forward")
9080 (if gnus-last-search-regexp
9081 (concat ", default " gnus-last-search-regexp)
9083 current-prefix-arg))
9084 (if (string-equal regexp "")
9085 (setq regexp (or gnus-last-search-regexp ""))
9086 (setq gnus-last-search-regexp regexp)
9087 (setq gnus-article-before-search gnus-current-article))
9088 ;; Intentionally set gnus-last-article.
9089 (setq gnus-last-article gnus-article-before-search)
9090 (let ((gnus-last-article gnus-last-article))
9091 (if (gnus-summary-search-article regexp backward)
9092 (gnus-summary-show-thread)
9093 (signal 'search-failed (list regexp)))))
9095 (defun gnus-summary-search-article-backward (regexp)
9096 "Search for an article containing REGEXP backward."
9099 (format "Search article backward (regexp%s): "
9100 (if gnus-last-search-regexp
9101 (concat ", default " gnus-last-search-regexp)
9103 (gnus-summary-search-article-forward regexp 'backward))
9105 (defun gnus-summary-search-article (regexp &optional backward)
9106 "Search for an article containing REGEXP.
9107 Optional argument BACKWARD means do search for backward.
9108 `gnus-select-article-hook' is not called during the search."
9109 ;; We have to require this here to make sure that the following
9110 ;; dynamic binding isn't shadowed by autoloading.
9111 (require 'gnus-async)
9113 (let ((gnus-select-article-hook nil) ;Disable hook.
9114 (gnus-article-prepare-hook nil)
9115 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9116 (gnus-use-article-prefetch nil)
9117 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9118 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9120 (gnus-keep-backlog nil)
9121 (gnus-break-pages nil)
9122 (gnus-summary-display-arrow nil)
9123 (gnus-updated-mode-lines nil)
9124 (gnus-auto-center-summary nil)
9125 (sum (current-buffer))
9126 (gnus-display-mime-function nil)
9129 (gnus-save-hidden-threads
9130 (gnus-summary-select-article)
9131 (set-buffer gnus-article-buffer)
9132 (goto-char (window-point (get-buffer-window (current-buffer))))
9136 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9138 (re-search-backward regexp nil t)
9139 (re-search-forward regexp nil t))
9140 ;; We found the regexp.
9145 (get-buffer-window (current-buffer))
9149 (get-buffer-window (current-buffer))
9152 (setq point (point)))
9153 ;; We didn't find it, so we go to the next article.
9156 (while (eq found 'not)
9157 (if (not (if backward (gnus-summary-find-prev)
9158 (gnus-summary-find-next)))
9159 ;; No more articles.
9161 ;; Select the next article and adjust point.
9162 (unless (gnus-summary-article-sparse-p
9163 (gnus-summary-article-number))
9165 (gnus-summary-select-article)
9166 (set-buffer gnus-article-buffer)
9168 (goto-char (if backward (point-max) (point-min))))))))
9169 (gnus-message 7 ""))
9170 ;; Return whether we found the regexp.
9171 (when (eq found 'found)
9173 (gnus-summary-show-thread)
9174 (gnus-summary-goto-subject gnus-current-article)
9175 (gnus-summary-position-point)
9178 (defun gnus-find-matching-articles (header regexp)
9179 "Return a list of all articles that match REGEXP on HEADER.
9180 This search includes all articles in the current group that Gnus has
9181 fetched headers for, whether they are displayed or not."
9182 (let ((articles nil)
9183 ;; Can't eta-reduce because it's a macro.
9184 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9185 (case-fold-search t))
9186 (dolist (header gnus-newsgroup-headers)
9187 (when (string-match regexp (funcall func header))
9188 (push (mail-header-number header) articles)))
9189 (nreverse articles)))
9191 (defun gnus-summary-find-matching (header regexp &optional backward unread
9192 not-case-fold not-matching)
9193 "Return a list of all articles that match REGEXP on HEADER.
9194 The search stars on the current article and goes forwards unless
9195 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9196 If UNREAD is non-nil, only unread articles will
9197 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9198 in the comparisons. If NOT-MATCHING, return a list of all articles that
9199 not match REGEXP on HEADER."
9200 (let ((case-fold-search (not not-case-fold))
9203 (if (eq (car header) 'extra)
9206 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9208 (error "%s is an invalid header" header))
9209 (unless (fboundp (intern (concat "mail-header-" header)))
9210 (error "%s is not a valid header" header))
9211 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9212 (dolist (d (if (eq backward 'all)
9214 (gnus-data-find-list
9215 (gnus-summary-article-number)
9216 (gnus-data-list backward))))
9217 (when (and (or (not unread) ; We want all articles...
9218 (gnus-data-unread-p d)) ; Or just unreads.
9219 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9223 (funcall func (gnus-data-header d))))
9224 (string-match regexp
9225 (funcall func (gnus-data-header d)))))
9226 (push (gnus-data-number d) articles))) ; Success!
9227 (nreverse articles)))
9229 (defun gnus-summary-execute-command (header regexp command &optional backward)
9230 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9231 If HEADER is an empty string (or nil), the match is done on the entire
9232 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9234 (list (let ((completion-ignore-case t))
9237 (mapcar (lambda (header) (list (format "%s" header)))
9239 '("Number" "Subject" "From" "Lines" "Date"
9240 "Message-ID" "Xref" "References" "Body")
9241 gnus-extra-headers))
9242 nil 'require-match))
9243 (read-string "Regexp: ")
9244 (read-key-sequence "Command: ")
9245 current-prefix-arg))
9246 (when (equal header "Body")
9248 ;; Hidden thread subtrees must be searched as well.
9249 (gnus-summary-show-all-threads)
9250 ;; We don't want to change current point nor window configuration.
9252 (save-window-excursion
9254 gnus-treat-strip-trailing-blank-lines
9255 gnus-treat-strip-leading-blank-lines
9256 gnus-treat-strip-multiple-blank-lines
9257 gnus-treat-hide-boring-headers
9258 gnus-treat-fold-newsgroups
9259 gnus-article-prepare-hook)
9260 (gnus-message 6 "Executing %s..." (key-description command))
9261 ;; We'd like to execute COMMAND interactively so as to give arguments.
9262 (gnus-execute header regexp
9263 `(call-interactively ',(key-binding command))
9265 (gnus-message 6 "Executing %s...done" (key-description command))))))
9267 (defun gnus-summary-beginning-of-article ()
9268 "Scroll the article back to the beginning."
9270 (gnus-summary-select-article)
9271 (gnus-configure-windows 'article)
9272 (gnus-eval-in-buffer-window gnus-article-buffer
9274 (goto-char (point-min))
9275 (when gnus-break-pages
9276 (gnus-narrow-to-page))))
9278 (defun gnus-summary-end-of-article ()
9279 "Scroll to the end of the article."
9281 (gnus-summary-select-article)
9282 (gnus-configure-windows 'article)
9283 (gnus-eval-in-buffer-window gnus-article-buffer
9285 (goto-char (point-max))
9287 (when gnus-break-pages
9288 (gnus-narrow-to-page))))
9290 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9291 "Truncate to LEN and quote all \"(\"'s in STRING."
9292 (gnus-replace-in-string (if (and len (> (length string) len))
9293 (substring string 0 len)
9297 (defun gnus-summary-print-article (&optional filename n)
9298 "Generate and print a PostScript image of the process-marked (mail) articles.
9300 If used interactively, print the current article if none are
9301 process-marked. With prefix arg, prompt the user for the name of the
9304 When used from Lisp, accept two optional args FILENAME and N. N means
9305 to print the next N articles. If N is negative, print the N previous
9306 articles. If N is nil and articles have been marked with the process
9307 mark, print these instead.
9309 If the optional first argument FILENAME is nil, send the image to the
9310 printer. If FILENAME is a string, save the PostScript image in a file with
9311 that name. If FILENAME is a number, prompt the user for the name of the file
9313 (interactive (list (ps-print-preprint current-prefix-arg)))
9314 (dolist (article (gnus-summary-work-articles n))
9315 (gnus-summary-select-article nil nil 'pseudo article)
9316 (gnus-eval-in-buffer-window gnus-article-buffer
9317 (gnus-print-buffer))
9318 (gnus-summary-remove-process-mark article))
9319 (ps-despool filename))
9321 (defun gnus-print-buffer ()
9322 (let ((buffer (generate-new-buffer " *print*")))
9325 (copy-to-buffer buffer (point-min) (point-max))
9327 (gnus-remove-text-with-property 'gnus-decoration)
9328 (when (gnus-visual-p 'article-highlight 'highlight)
9329 ;; Copy-to-buffer doesn't copy overlay. So redo
9331 (let ((gnus-article-buffer buffer))
9332 (gnus-article-highlight-citation t)
9333 (gnus-article-highlight-signature)
9334 (gnus-article-emphasize)
9335 (gnus-article-delete-invisible-text)))
9336 (let ((ps-left-header
9339 (gnus-summary-print-truncate-and-quote
9340 (mail-header-subject gnus-current-headers)
9343 (gnus-summary-print-truncate-and-quote
9344 (mail-header-from gnus-current-headers)
9348 "/pagenumberstring load"
9350 (mail-header-date gnus-current-headers) ")"))))
9351 (gnus-run-hooks 'gnus-ps-print-hook)
9353 (if ps-print-color-p
9354 (ps-spool-buffer-with-faces)
9355 (ps-spool-buffer)))))
9356 (kill-buffer buffer))))
9358 (defun gnus-summary-show-article (&optional arg)
9359 "Force redisplaying of the current article.
9360 If ARG (the prefix) is a number, show the article with the charset
9361 defined in `gnus-summary-show-article-charset-alist', or the charset
9363 If ARG (the prefix) is non-nil and not a number, show the raw article
9364 without any article massaging functions being run. Normally, the key
9365 strokes are `C-u g'."
9369 (gnus-summary-show-article t)
9370 (let ((gnus-newsgroup-charset
9371 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9372 (mm-read-coding-system
9373 "View as charset: " ;; actually it is coding system.
9374 (with-current-buffer gnus-article-buffer
9375 (mm-detect-coding-region (point) (point-max))))))
9376 (gnus-newsgroup-ignored-charsets 'gnus-all))
9377 (gnus-summary-select-article nil 'force)
9378 (let ((deps gnus-newsgroup-dependencies)
9380 (with-current-buffer gnus-original-article-buffer
9382 (message-narrow-to-head)
9383 (setq head (buffer-string))
9384 (goto-char (point-min))
9385 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9386 (goto-char (point-max))
9388 (setq lines (1- (count-lines (point) (point-max))))))
9390 (insert (format "211 %d Article retrieved.\n"
9391 (cdr gnus-article-current)))
9393 (if lines (insert (format "Lines: %d\n" lines)))
9395 (let ((nntp-server-buffer (current-buffer)))
9396 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9397 (gnus-data-set-header
9398 (gnus-data-find (cdr gnus-article-current))
9400 (gnus-summary-update-article-line
9401 (cdr gnus-article-current) header)
9402 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9403 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9405 ;; Select the article the normal way.
9406 (gnus-summary-select-article nil 'force))
9408 ;; We have to require this here to make sure that the following
9409 ;; dynamic binding isn't shadowed by autoloading.
9410 (require 'gnus-async)
9412 ;; Bind the article treatment functions to nil.
9413 (let ((gnus-have-all-headers t)
9414 gnus-article-prepare-hook
9415 gnus-article-decode-hook
9416 gnus-display-mime-function
9418 ;; Destroy any MIME parts.
9419 (when (gnus-buffer-live-p gnus-article-buffer)
9420 (with-current-buffer gnus-article-buffer
9421 (mm-destroy-parts gnus-article-mime-handles)
9422 ;; Set it to nil for safety reason.
9423 (setq gnus-article-mime-handle-alist nil)
9424 (setq gnus-article-mime-handles nil)))
9425 (gnus-summary-select-article nil 'force))))
9426 (gnus-summary-goto-subject gnus-current-article)
9427 (gnus-summary-position-point))
9429 (defun gnus-summary-show-raw-article ()
9430 "Show the raw article without any article massaging functions being run."
9432 (gnus-summary-show-article t))
9434 (defun gnus-summary-verbose-headers (&optional arg)
9435 "Toggle permanent full header display.
9436 If ARG is a positive number, turn header display on.
9437 If ARG is a negative number, turn header display off."
9439 (setq gnus-show-all-headers
9440 (cond ((or (not (numberp arg))
9442 (not gnus-show-all-headers))
9445 (gnus-summary-show-article))
9447 (defun gnus-summary-toggle-header (&optional arg)
9448 "Show the headers if they are hidden, or hide them if they are shown.
9449 If ARG is a positive number, show the entire header.
9450 If ARG is a negative number, hide the unwanted header lines."
9452 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9453 (get-buffer-window gnus-article-buffer t))))
9454 (with-current-buffer gnus-article-buffer
9456 (article-narrow-to-head)
9457 (let* ((inhibit-read-only t)
9458 (inhibit-point-motion-hooks t)
9459 (hidden (if (numberp arg)
9461 (or (not (looking-at "[^ \t\n]+:"))
9462 (gnus-article-hidden-text-p 'headers))))
9464 (delete-region (point-min) (point-max))
9465 (with-current-buffer gnus-original-article-buffer
9466 (goto-char (setq s (point-min)))
9467 (setq e (if (search-forward "\n\n" nil t)
9470 (insert-buffer-substring gnus-original-article-buffer s e)
9471 (run-hooks 'gnus-article-decode-hook)
9473 (let ((gnus-treat-hide-headers nil)
9474 (gnus-treat-hide-boring-headers nil))
9475 (gnus-delete-wash-type 'headers)
9476 (gnus-treat-article 'head))
9477 (gnus-treat-article 'head))
9480 (set-window-start window (goto-char (point-min))))
9481 (if gnus-break-pages
9482 (gnus-narrow-to-page)
9483 (when (gnus-visual-p 'page-marker)
9484 (let ((inhibit-read-only t))
9485 (gnus-remove-text-with-property 'gnus-prev)
9486 (gnus-remove-text-with-property 'gnus-next))))
9487 (gnus-set-mode-line 'article)))))
9489 (defun gnus-summary-show-all-headers ()
9490 "Make all header lines visible."
9492 (gnus-summary-toggle-header 1))
9494 (defun gnus-summary-caesar-message (&optional arg)
9495 "Caesar rotate the current article by 13.
9496 With a non-numerical prefix, also rotate headers. A numerical
9497 prefix specifies how many places to rotate each letter forward."
9499 (gnus-summary-select-article)
9500 (let ((mail-header-separator ""))
9501 (gnus-eval-in-buffer-window gnus-article-buffer
9504 (let ((start (window-start))
9505 (inhibit-read-only t))
9506 (if (equal arg '(4))
9507 (message-caesar-buffer-body nil t)
9508 (message-caesar-buffer-body arg))
9509 (set-window-start (get-buffer-window (current-buffer)) start)))))
9510 ;; Create buttons and stuff...
9511 (gnus-treat-article nil))
9513 (declare-function idna-to-unicode "ext:idna" (str))
9515 (defun gnus-summary-idna-message (&optional arg)
9516 "Decode IDNA encoded domain names in the current articles.
9517 IDNA encoded domain names looks like `xn--bar'. If a string
9518 remain unencoded after running this function, it is likely an
9519 invalid IDNA string (`xn--bar' is invalid).
9521 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9522 installed for this command to work."
9524 (if (not (and (condition-case nil (require 'idna)
9526 (mm-coding-system-p 'utf-8)
9527 (executable-find (symbol-value 'idna-program))))
9529 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9530 (gnus-summary-select-article)
9531 (let ((mail-header-separator ""))
9532 (gnus-eval-in-buffer-window gnus-article-buffer
9535 (let ((start (window-start))
9537 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9538 (replace-match (idna-to-unicode (match-string 1))))
9539 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9541 (defun gnus-summary-morse-message (&optional arg)
9542 "Morse decode the current article."
9544 (gnus-summary-select-article)
9545 (let ((mail-header-separator ""))
9546 (gnus-eval-in-buffer-window gnus-article-buffer
9550 (let ((pos (window-start))
9551 (inhibit-read-only t))
9552 (goto-char (point-min))
9553 (when (message-goto-body)
9554 (gnus-narrow-to-body))
9555 (goto-char (point-min))
9556 (while (search-forward "·" (point-max) t)
9557 (replace-match "."))
9558 (unmorse-region (point-min) (point-max))
9560 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9562 (defun gnus-summary-stop-page-breaking ()
9563 "Stop page breaking in the current article."
9565 (gnus-summary-select-article)
9566 (gnus-eval-in-buffer-window gnus-article-buffer
9568 (when (gnus-visual-p 'page-marker)
9569 (let ((inhibit-read-only t))
9570 (gnus-remove-text-with-property 'gnus-prev)
9571 (gnus-remove-text-with-property 'gnus-next))
9572 (setq gnus-page-broken nil))))
9574 (defun gnus-summary-move-article (&optional n to-newsgroup
9575 select-method action)
9576 "Move the current article to a different newsgroup.
9577 If N is a positive number, move the N next articles.
9578 If N is a negative number, move the N previous articles.
9579 If N is nil and any articles have been marked with the process mark,
9580 move those articles instead.
9581 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9582 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9583 re-spool using this method.
9585 When called interactively with TO-NEWSGROUP being nil, the value of
9586 the variable `gnus-move-split-methods' is used for finding a default
9587 for the target newsgroup.
9589 For this function to work, both the current newsgroup and the
9590 newsgroup that you want to move to have to support the `request-move'
9591 and `request-accept' functions.
9593 ACTION can be either `move' (the default), `crosspost' or `copy'."
9596 (setq action 'move))
9597 ;; Check whether the source group supports the required functions.
9598 (cond ((and (eq action 'move)
9599 (not (gnus-check-backend-function
9600 'request-move-article gnus-newsgroup-name)))
9601 (error "The current group does not support article moving"))
9602 ((and (eq action 'crosspost)
9603 (not (gnus-check-backend-function
9604 'request-replace-article gnus-newsgroup-name)))
9605 (error "The current group does not support article editing")))
9606 (let ((articles (gnus-summary-work-articles n))
9607 (prefix (if (gnus-check-backend-function
9608 'request-move-article gnus-newsgroup-name)
9609 (funcall gnus-move-group-prefix-function
9610 gnus-newsgroup-name)
9612 (names '((move "Move" "Moving")
9613 (copy "Copy" "Copying")
9614 (crosspost "Crosspost" "Crossposting")))
9615 (copy-buf (save-excursion
9616 (nnheader-set-temp-buffer " *copy article*")))
9617 art-group to-method new-xref article to-groups
9618 articles-to-update-marks encoded)
9619 (unless (assq action names)
9620 (error "Unknown action %s" action))
9621 ;; Read the newsgroup name.
9622 (when (and (not to-newsgroup)
9623 (not select-method))
9624 (if (and gnus-move-split-methods
9626 (and (memq gnus-current-article articles)
9627 (gnus-buffer-live-p gnus-original-article-buffer))))
9628 ;; When `gnus-move-split-methods' is non-nil, we have to
9629 ;; select an article to give `gnus-read-move-group-name' an
9630 ;; opportunity to suggest an appropriate default. However,
9631 ;; we needn't render or mark the article.
9632 (let ((gnus-display-mime-function nil)
9633 (gnus-article-prepare-hook nil)
9634 (gnus-mark-article-hook nil))
9635 (gnus-summary-select-article nil nil nil (car articles))))
9636 (setq to-newsgroup (gnus-read-move-group-name
9637 (cadr (assq action names))
9639 (intern (format "gnus-current-%s-group" action)))
9641 encoded to-newsgroup
9642 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9643 (set (intern (format "gnus-current-%s-group" action))
9644 (mm-decode-coding-string
9646 (gnus-group-name-charset to-method to-newsgroup))))
9648 (setq to-method (or select-method
9649 (gnus-server-to-method
9650 (gnus-group-method to-newsgroup)))))
9654 (mm-encode-coding-string
9656 (gnus-group-name-charset to-method to-newsgroup)))))
9657 ;; Check the method we are to move this article to...
9658 (unless (gnus-check-backend-function
9659 'request-accept-article (car to-method))
9660 (error "%s does not support article copying" (car to-method)))
9661 (unless (gnus-check-server to-method)
9662 (error "Can't open server %s" (car to-method)))
9663 (gnus-message 6 "%s to %s: %s..."
9664 (caddr (assq action names))
9665 (or (car select-method)
9666 (gnus-group-decoded-name to-newsgroup))
9669 (setq article (pop articles))
9673 ;; Move the article.
9675 ;; Remove this article from future suppression.
9676 (gnus-dup-unsuppress-article article)
9677 (let* ((from-method (gnus-find-method-for-group
9678 gnus-newsgroup-name))
9679 (to-method (or select-method
9680 (gnus-find-method-for-group to-newsgroup)))
9681 (move-is-internal (gnus-server-equal from-method to-method)))
9682 (gnus-request-move-article
9683 article ; Article to move
9684 gnus-newsgroup-name ; From newsgroup
9685 (nth 1 (gnus-find-method-for-group
9686 gnus-newsgroup-name)) ; Server
9687 (list 'gnus-request-accept-article
9688 to-newsgroup (list 'quote select-method)
9689 (not articles) t) ; Accept form
9690 (not articles) ; Only save nov last time
9691 (and move-is-internal
9692 to-newsgroup ; Not respooling
9693 (gnus-group-real-name to-newsgroup))))) ; Is this move internal?
9694 ;; Copy the article.
9696 (with-current-buffer copy-buf
9697 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9699 (nnheader-narrow-to-headers)
9700 (dolist (hdr gnus-copy-article-ignored-headers)
9701 (message-remove-header hdr t)))
9702 (gnus-request-accept-article
9703 to-newsgroup select-method (not articles) t))))
9704 ;; Crosspost the article.
9705 ((eq action 'crosspost)
9706 (let ((xref (message-tokenize-header
9707 (mail-header-xref (gnus-summary-article-header article))
9709 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9710 ":" (number-to-string article)))
9712 (setq xref (list (system-name))))
9715 (mapconcat 'identity
9716 (delete "Xref:" (delete new-xref xref))
9719 (with-current-buffer copy-buf
9720 ;; First put the article in the destination group.
9721 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9722 (when (consp (setq art-group
9723 (gnus-request-accept-article
9724 to-newsgroup select-method (not articles) t)))
9725 (setq new-xref (concat new-xref " " (car art-group)
9727 (number-to-string (cdr art-group))))
9728 ;; Now we have the new Xrefs header, so we insert
9729 ;; it and replace the new article.
9730 (nnheader-replace-header "Xref" new-xref)
9731 (gnus-request-replace-article
9732 (cdr art-group) to-newsgroup (current-buffer) t)
9736 (gnus-message 1 "Couldn't %s article %s: %s"
9737 (cadr (assq action names)) article
9738 (nnheader-get-report (car to-method))))
9739 ((eq art-group 'junk)
9740 (when (eq action 'move)
9741 (gnus-summary-mark-article article gnus-canceled-mark)
9742 (gnus-message 4 "Deleted article %s" article)
9743 ;; run the delete hook
9744 (run-hook-with-args 'gnus-summary-article-delete-hook
9747 (assoc article (gnus-data-list nil)))
9748 gnus-newsgroup-name nil
9751 (let* ((pto-group (gnus-group-prefixed-name
9752 (car art-group) to-method))
9753 (info (gnus-get-info pto-group))
9754 (to-group (gnus-info-group info))
9756 ;; Update the group that has been moved to.
9758 (memq action '(move copy)))
9759 (unless (member to-group to-groups)
9760 (push to-group to-groups))
9762 (unless (memq article gnus-newsgroup-unreads)
9763 (push 'read to-marks)
9765 info (gnus-add-to-range (gnus-info-read info)
9766 (list (cdr art-group)))))
9768 ;; See whether the article is to be put in the cache.
9769 (let* ((expirable (gnus-group-auto-expirable-p to-group))
9770 (marks (if expirable
9771 gnus-article-mark-lists
9772 (delete '(expirable . expire)
9773 (copy-sequence gnus-article-mark-lists))))
9774 (to-article (cdr art-group)))
9776 ;; Enter the article into the cache in the new group,
9777 ;; if that is required.
9778 (when gnus-use-cache
9779 (gnus-cache-possibly-enter-article
9781 (memq article gnus-newsgroup-marked)
9782 (memq article gnus-newsgroup-dormant)
9783 (memq article gnus-newsgroup-unreads)))
9785 (when gnus-preserve-marks
9786 ;; Copy any marks over to the new group.
9787 (when (and (equal to-group gnus-newsgroup-name)
9788 (not (memq article gnus-newsgroup-unreads)))
9789 ;; Mark this article as read in this group.
9790 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9791 (setcdr (gnus-active to-group) to-article)
9792 (setcdr gnus-newsgroup-active to-article))
9795 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9796 (when (memq article (symbol-value
9797 (intern (format "gnus-newsgroup-%s"
9799 (push (cdar marks) to-marks)
9800 ;; If the other group is the same as this group,
9801 ;; then we have to add the mark to the list.
9802 (when (equal to-group gnus-newsgroup-name)
9803 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9806 (intern (format "gnus-newsgroup-%s"
9808 ;; Copy the marks to other group.
9809 (gnus-add-marked-articles
9810 to-group (cdar marks) (list to-article) info)))
9811 (setq marks (cdr marks)))
9813 (when (and expirable
9814 gnus-mark-copied-or-moved-articles-as-expirable
9815 (not (memq 'expire to-marks)))
9816 ;; Mark this article as expirable.
9817 (push 'expire to-marks)
9818 (when (equal to-group gnus-newsgroup-name)
9819 (push to-article gnus-newsgroup-expirable))
9820 ;; Copy the expirable mark to other group.
9821 (gnus-add-marked-articles
9822 to-group 'expire (list to-article) info))
9825 (gnus-request-set-mark
9826 to-group (list (list (list to-article) 'add to-marks)))))
9829 (concat "(gnus-group-set-info '"
9830 (gnus-prin1-to-string (gnus-get-info to-group))
9833 ;; Update the Xref header in this article to point to
9834 ;; the new crossposted article we have just created.
9835 (when (eq action 'crosspost)
9836 (with-current-buffer copy-buf
9837 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9838 (nnheader-replace-header "Xref" new-xref)
9839 (gnus-request-replace-article
9840 article gnus-newsgroup-name (current-buffer) t)))
9842 ;; run the move/copy/crosspost/respool hook
9843 (run-hook-with-args 'gnus-summary-article-move-hook
9846 (assoc article (gnus-data-list nil)))
9851 ;;;!!!Why is this necessary?
9852 (set-buffer gnus-summary-buffer)
9854 (when (eq action 'move)
9856 (gnus-summary-goto-subject article)
9857 (gnus-summary-mark-article article gnus-canceled-mark)))))
9858 (push article articles-to-update-marks))
9861 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
9862 ;; Re-activate all groups that have been moved to.
9863 (with-current-buffer gnus-group-buffer
9864 (let ((gnus-group-marked to-groups))
9865 (gnus-group-get-new-news-this-group nil t)))
9867 (gnus-kill-buffer copy-buf)
9868 (gnus-summary-position-point)
9869 (gnus-set-mode-line 'summary)))
9871 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9872 "Copy the current article to some other group.
9873 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9874 When called interactively, if TO-NEWSGROUP is nil, use the value of
9875 the variable `gnus-move-split-methods' for finding a default target
9877 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9878 re-spool using this method."
9880 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9882 (defun gnus-summary-crosspost-article (&optional n)
9883 "Crosspost the current article to some other group."
9885 (gnus-summary-move-article n nil nil 'crosspost))
9887 (defcustom gnus-summary-respool-default-method nil
9888 "Default method type for respooling an article.
9889 If nil, use to the current newsgroup method."
9891 :group 'gnus-summary-mail)
9893 (defun gnus-summary-respool-article (&optional n method)
9894 "Respool the current article.
9895 The article will be squeezed through the mail spooling process again,
9896 which means that it will be put in some mail newsgroup or other
9897 depending on `nnmail-split-methods'.
9898 If N is a positive number, respool the N next articles.
9899 If N is a negative number, respool the N previous articles.
9900 If N is nil and any articles have been marked with the process mark,
9901 respool those articles instead.
9903 Respooling can be done both from mail groups and \"real\" newsgroups.
9904 In the former case, the articles in question will be moved from the
9905 current group into whatever groups they are destined to. In the
9906 latter case, they will be copied into the relevant groups."
9908 (list current-prefix-arg
9909 (let* ((methods (gnus-methods-using 'respool))
9911 (symbol-name (or gnus-summary-respool-default-method
9912 (car (gnus-find-method-for-group
9913 gnus-newsgroup-name)))))
9915 (gnus-completing-read-with-default
9916 methname "Backend to use when respooling"
9917 methods nil t nil 'gnus-mail-method-history))
9920 ((zerop (length (setq ms (gnus-servers-using-backend
9922 (list (intern method) ""))
9926 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9927 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9930 (error "No method given for respooling"))
9931 (if (assoc (symbol-name
9932 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9933 (gnus-methods-using 'respool))
9934 (gnus-summary-move-article n nil method)
9935 (gnus-summary-copy-article n nil method)))
9937 (defun gnus-summary-import-article (file &optional edit)
9938 "Import an arbitrary file into a mail newsgroup."
9939 (interactive "fImport file: \nP")
9940 (let ((group gnus-newsgroup-name)
9941 (now (current-time))
9942 atts lines group-art)
9943 (unless (gnus-check-backend-function 'request-accept-article group)
9944 (error "%s does not support article importing" group))
9945 (or (file-readable-p file)
9946 (not (file-regular-p file))
9947 (error "Can't read %s" file))
9948 (with-current-buffer (gnus-get-buffer-create " *import file*")
9950 (nnheader-insert-file-contents file)
9951 (goto-char (point-min))
9952 (if (nnheader-article-p)
9954 (goto-char (point-min))
9955 (search-forward "\n\n" nil t)
9956 (narrow-to-region (point-min) (1- (point)))
9957 (goto-char (point-min))
9958 (unless (re-search-forward "^date:" nil t)
9959 (goto-char (point-max))
9960 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9961 ;; This doesn't look like an article, so we fudge some headers.
9962 (setq atts (file-attributes file)
9963 lines (count-lines (point-min) (point-max)))
9964 (insert "From: " (read-string "From: ") "\n"
9965 "Subject: " (read-string "Subject: ") "\n"
9966 "Date: " (message-make-date (nth 5 atts)) "\n"
9967 "Message-ID: " (message-make-message-id) "\n"
9968 "Lines: " (int-to-string lines) "\n"
9969 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9970 (setq group-art (gnus-request-accept-article group nil t))
9971 (kill-buffer (current-buffer)))
9972 (setq gnus-newsgroup-active (gnus-activate-group group))
9974 (gnus-summary-goto-article (cdr group-art) nil t)
9976 (gnus-summary-edit-article))))
9978 (defun gnus-summary-create-article ()
9979 "Create an article in a mail newsgroup."
9981 (let ((group gnus-newsgroup-name)
9982 (now (current-time))
9984 (unless (gnus-check-backend-function 'request-accept-article group)
9985 (error "%s does not support article importing" group))
9986 (with-current-buffer (gnus-get-buffer-create " *import file*")
9988 (goto-char (point-min))
9989 ;; This doesn't look like an article, so we fudge some headers.
9990 (insert "From: " (read-string "From: ") "\n"
9991 "Subject: " (read-string "Subject: ") "\n"
9992 "Date: " (message-make-date now) "\n"
9993 "Message-ID: " (message-make-message-id) "\n")
9994 (setq group-art (gnus-request-accept-article group nil t))
9995 (kill-buffer (current-buffer)))
9996 (setq gnus-newsgroup-active (gnus-activate-group group))
9998 (gnus-summary-goto-article (cdr group-art) nil t)
9999 (gnus-summary-edit-article)))
10001 (defun gnus-summary-article-posted-p ()
10002 "Say whether the current (mail) article is available from news as well.
10003 This will be the case if the article has both been mailed and posted."
10005 (let ((id (mail-header-references (gnus-summary-article-header)))
10006 (gnus-override-method (car (gnus-refer-article-methods))))
10007 (if (gnus-request-head id "")
10008 (gnus-message 2 "The current message was found on %s"
10009 gnus-override-method)
10010 (gnus-message 2 "The current message couldn't be found on %s"
10011 gnus-override-method)
10014 (defun gnus-summary-expire-articles (&optional now)
10015 "Expire all articles that are marked as expirable in the current group."
10017 (when (and (not gnus-group-is-exiting-without-update-p)
10018 (gnus-check-backend-function
10019 'request-expire-articles gnus-newsgroup-name))
10020 ;; This backend supports expiry.
10021 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10022 (expirable (if total
10024 ;; We need to update the info for
10025 ;; this group for `gnus-list-of-read-articles'
10026 ;; to give us the right answer.
10027 (gnus-run-hooks 'gnus-exit-group-hook)
10028 (gnus-summary-update-info)
10029 (gnus-list-of-read-articles gnus-newsgroup-name))
10030 (setq gnus-newsgroup-expirable
10031 (sort gnus-newsgroup-expirable '<))))
10032 (expiry-wait (if now 'immediate
10033 (gnus-group-find-parameter
10034 gnus-newsgroup-name 'expiry-wait)))
10035 (nnmail-expiry-target
10036 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10037 nnmail-expiry-target))
10040 ;; There are expirable articles in this group, so we run them
10041 ;; through the expiry process.
10042 (gnus-message 6 "Expiring articles...")
10043 (unless (gnus-check-group gnus-newsgroup-name)
10044 (error "Can't open server for %s" gnus-newsgroup-name))
10045 ;; The list of articles that weren't expired is returned.
10048 (let ((nnmail-expiry-wait-function nil)
10049 (nnmail-expiry-wait expiry-wait))
10050 (setq es (gnus-request-expire-articles
10051 expirable gnus-newsgroup-name)))
10052 (setq es (gnus-request-expire-articles
10053 expirable gnus-newsgroup-name)))
10055 (setq gnus-newsgroup-expirable es))
10056 ;; We go through the old list of expirable, and mark all
10057 ;; really expired articles as nonexistent.
10058 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10059 (let ((gnus-use-cache nil))
10060 (dolist (article expirable)
10061 (when (and (not (memq article es))
10062 (gnus-data-find article))
10063 (gnus-summary-mark-article article gnus-canceled-mark)
10064 (run-hook-with-args 'gnus-summary-article-expire-hook
10067 (assoc article (gnus-data-list nil)))
10068 gnus-newsgroup-name
10071 (gnus-message 6 "Expiring articles...done")))))
10073 (defun gnus-summary-expire-articles-now ()
10074 "Expunge all expirable articles in the current group.
10075 This means that *all* articles that are marked as expirable will be
10076 deleted forever, right now."
10078 (or gnus-expert-user
10080 "Are you really, really sure you want to delete all expirable messages? ")
10082 (gnus-summary-expire-articles t))
10084 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10085 (defun gnus-summary-delete-article (&optional n)
10086 "Delete the N next (mail) articles.
10087 This command actually deletes articles. This is not a marking
10088 command. The article will disappear forever from your life, never to
10091 If N is negative, delete backwards.
10092 If N is nil and articles have been marked with the process mark,
10093 delete these instead.
10095 If `gnus-novice-user' is non-nil you will be asked for
10096 confirmation before the articles are deleted."
10098 (unless (gnus-check-backend-function 'request-expire-articles
10099 gnus-newsgroup-name)
10100 (error "The current newsgroup does not support article deletion"))
10101 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10102 (error "Couldn't open server"))
10103 ;; Compute the list of articles to delete.
10104 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10105 (nnmail-expiry-target 'delete)
10107 (if (and gnus-novice-user
10108 (not (gnus-yes-or-no-p
10109 (format "Do you really want to delete %s forever? "
10110 (if (> (length articles) 1)
10111 (format "these %s articles" (length articles))
10112 "this article")))))
10114 ;; Delete the articles.
10115 (setq not-deleted (gnus-request-expire-articles
10116 articles gnus-newsgroup-name 'force))
10119 (gnus-summary-remove-process-mark (car articles))
10120 ;; The backend might not have been able to delete the article
10122 (unless (memq (car articles) not-deleted)
10123 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
10124 (let* ((article (car articles))
10125 (ghead (gnus-data-header
10126 (assoc article (gnus-data-list nil)))))
10127 (run-hook-with-args 'gnus-summary-article-delete-hook
10128 'delete ghead gnus-newsgroup-name nil
10130 (setq articles (cdr articles))))
10132 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10133 (gnus-summary-position-point)
10134 (gnus-set-mode-line 'summary)
10137 (defun gnus-summary-edit-article (&optional arg)
10138 "Edit the current article.
10139 This will have permanent effect only in mail groups.
10140 If ARG is nil, edit the decoded articles.
10141 If ARG is 1, edit the raw articles.
10142 If ARG is 2, edit the raw articles even in read-only groups.
10143 If ARG is 3, edit the articles with the current handles.
10144 Otherwise, allow editing of articles even in read-only
10147 (let (force raw current-handles)
10156 (setq current-handles
10157 (and (gnus-buffer-live-p gnus-article-buffer)
10158 (with-current-buffer gnus-article-buffer
10160 gnus-article-mime-handles
10161 (setq gnus-article-mime-handles nil))))))
10164 (when (and raw (not force)
10165 (member gnus-newsgroup-name '("nndraft:delayed"
10168 (error "Can't edit the raw article in group %s"
10169 gnus-newsgroup-name))
10170 (with-current-buffer gnus-summary-buffer
10171 (let ((mail-parse-charset gnus-newsgroup-charset)
10172 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10173 (gnus-set-global-variables)
10174 (when (and (not force)
10175 (gnus-group-read-only-p))
10176 (error "The current newsgroup does not support article editing"))
10177 (gnus-summary-show-article t)
10178 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10179 (with-current-buffer gnus-article-buffer
10180 (mm-enable-multibyte)))
10181 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10183 (gnus-article-edit-article
10186 (let ((mbl mml-buffer-list))
10187 (setq mml-buffer-list nil)
10188 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10189 (mime-to-mml ,'current-handles))
10190 (let ((mbl1 mml-buffer-list))
10191 (setq mml-buffer-list mbl)
10192 (set (make-local-variable 'mml-buffer-list) mbl1))
10193 (gnus-make-local-hook 'kill-buffer-hook)
10194 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10195 `(lambda (no-highlight)
10196 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10197 (message-options message-options)
10198 (message-options-set-recipient)
10199 (mail-parse-ignored-charsets
10200 ',gnus-newsgroup-ignored-charsets)
10201 (rfc2047-header-encoding-alist
10202 ',(let ((charset (gnus-group-name-charset
10203 (gnus-find-method-for-group
10204 gnus-newsgroup-name)
10205 gnus-newsgroup-name)))
10206 (append (list (cons "Newsgroups" charset)
10207 (cons "Followup-To" charset)
10208 (cons "Xref" charset))
10209 rfc2047-header-encoding-alist))))
10210 ,(if (not raw) '(progn
10212 (mml-destroy-buffers)
10213 (remove-hook 'kill-buffer-hook
10214 'mml-destroy-buffers t)
10215 (kill-local-variable 'mml-buffer-list)))
10216 (gnus-summary-edit-article-done
10217 ,(or (mail-header-references gnus-current-headers) "")
10218 ,(gnus-group-read-only-p)
10219 ,gnus-summary-buffer no-highlight))))))))
10221 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10223 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10225 "Make edits to the current article permanent."
10228 ;; The buffer restriction contains the entire article if it exists.
10229 (when (article-goto-body)
10230 (let ((lines (count-lines (point) (point-max)))
10231 (length (- (point-max) (point)))
10232 (case-fold-search t)
10233 (body (copy-marker (point))))
10234 (goto-char (point-min))
10235 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10236 (delete-region (match-beginning 1) (match-end 1))
10237 (insert (number-to-string length)))
10238 (goto-char (point-min))
10239 (when (re-search-forward
10240 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10241 (delete-region (match-beginning 1) (match-end 1))
10242 (insert (number-to-string length)))
10243 (goto-char (point-min))
10244 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10245 (delete-region (match-beginning 1) (match-end 1))
10246 (insert (number-to-string lines))))))
10247 ;; Replace the article.
10248 (let ((buf (current-buffer)))
10250 (insert-buffer-substring buf)
10252 (if (and (not read-only)
10253 (not (gnus-request-replace-article
10254 (cdr gnus-article-current) (car gnus-article-current)
10255 (current-buffer) t)))
10256 (error "Couldn't replace article")
10257 ;; Update the summary buffer.
10258 (if (and references
10259 (equal (message-tokenize-header references " ")
10260 (message-tokenize-header
10261 (or (message-fetch-field "references") "") " ")))
10262 ;; We only have to update this line.
10265 (message-narrow-to-head)
10266 (let ((head (buffer-substring-no-properties
10267 (point-min) (point-max)))
10270 (insert (format "211 %d Article retrieved.\n"
10271 (cdr gnus-article-current)))
10274 (let ((nntp-server-buffer (current-buffer)))
10275 (setq header (car (gnus-get-newsgroup-headers
10277 (with-current-buffer gnus-summary-buffer
10278 (gnus-data-set-header
10279 (gnus-data-find (cdr gnus-article-current))
10281 (gnus-summary-update-article-line
10282 (cdr gnus-article-current) header)
10283 (if (gnus-summary-goto-subject
10284 (cdr gnus-article-current) nil t)
10285 (gnus-summary-update-secondary-mark
10286 (cdr gnus-article-current))))))))
10288 (set-buffer (or buffer gnus-summary-buffer))
10289 (gnus-summary-update-article (cdr gnus-article-current))
10290 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10291 (gnus-summary-update-secondary-mark
10292 (cdr gnus-article-current))))
10293 ;; Prettify the article buffer again.
10294 (unless no-highlight
10295 (with-current-buffer gnus-article-buffer
10296 ;;;!!! Fix this -- article should be rehighlighted.
10297 ;;;(gnus-run-hooks 'gnus-article-display-hook)
10298 (set-buffer gnus-original-article-buffer)
10299 (gnus-request-article
10300 (cdr gnus-article-current)
10301 (car gnus-article-current) (current-buffer))))
10302 ;; Prettify the summary buffer line.
10303 (when (gnus-visual-p 'summary-highlight 'highlight)
10304 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10306 (defun gnus-summary-edit-wash (key)
10307 "Perform editing command KEY in the article buffer."
10311 (message "%s" (concat (this-command-keys) "- "))
10314 (gnus-summary-edit-article)
10315 (execute-kbd-macro (concat (this-command-keys) key))
10316 (gnus-article-edit-done))
10320 (defun gnus-summary-respool-query (&optional silent trace)
10321 "Query where the respool algorithm would put this article."
10323 (let (gnus-mark-article-hook)
10324 (gnus-summary-select-article)
10325 (with-current-buffer gnus-original-article-buffer
10326 (let ((groups (nnmail-article-group 'identity trace)))
10329 (message "This message would go to %s"
10330 (mapconcat 'car groups ", "))
10331 (message "This message would go to no groups"))
10334 (defun gnus-summary-respool-trace ()
10335 "Trace where the respool algorithm would put this article.
10336 Display a buffer showing all fancy splitting patterns which matched."
10338 (gnus-summary-respool-query nil t))
10340 ;; Summary marking commands.
10342 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10343 "Mark articles which has the same subject as read, and then select the next.
10344 If UNMARK is positive, remove any kind of mark.
10345 If UNMARK is negative, tick articles."
10348 (setq unmark (prefix-numeric-value unmark)))
10350 (gnus-summary-mark-same-subject
10351 (gnus-summary-article-subject) unmark)))
10352 ;; Select next unread article. If auto-select-same mode, should
10353 ;; select the first unread article.
10354 (gnus-summary-next-article t (and gnus-auto-select-same
10355 (gnus-summary-article-subject)))
10356 (gnus-message 7 "%d article%s marked as %s"
10357 count (if (= count 1) " is" "s are")
10358 (if unmark "unread" "read"))))
10360 (defun gnus-summary-kill-same-subject (&optional unmark)
10361 "Mark articles which has the same subject as read.
10362 If UNMARK is positive, remove any kind of mark.
10363 If UNMARK is negative, tick articles."
10366 (setq unmark (prefix-numeric-value unmark)))
10368 (gnus-summary-mark-same-subject
10369 (gnus-summary-article-subject) unmark)))
10370 ;; If marked as read, go to next unread subject.
10371 (when (null unmark)
10372 ;; Go to next unread subject.
10373 (gnus-summary-next-subject 1 t))
10374 (gnus-message 7 "%d articles are marked as %s"
10375 count (if unmark "unread" "read"))))
10377 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10378 "Mark articles with same SUBJECT as read, and return marked number.
10379 If optional argument UNMARK is positive, remove any kinds of marks.
10380 If optional argument UNMARK is negative, mark articles as unread instead."
10384 ((null unmark) ; Mark as read.
10387 (gnus-summary-mark-article-as-read gnus-killed-mark)
10388 (gnus-summary-show-thread) t)
10389 (gnus-summary-find-subject subject))
10390 (setq count (1+ count))))
10391 ((> unmark 0) ; Tick.
10394 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10395 (gnus-summary-show-thread) t)
10396 (gnus-summary-find-subject subject))
10397 (setq count (1+ count))))
10398 (t ; Mark as unread.
10401 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10402 (gnus-summary-show-thread) t)
10403 (gnus-summary-find-subject subject))
10404 (setq count (1+ count)))))
10405 (gnus-set-mode-line 'summary)
10406 ;; Return the number of marked articles.
10409 (defun gnus-summary-mark-as-processable (n &optional unmark)
10410 "Set the process mark on the next N articles.
10411 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10412 the process mark instead. The difference between N and the actual
10413 number of articles marked is returned."
10415 (if (and (null n) (gnus-region-active-p))
10416 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10417 (setq n (prefix-numeric-value n))
10418 (let ((backward (< n 0))
10423 (gnus-summary-remove-process-mark
10424 (gnus-summary-article-number))
10425 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10426 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10429 (gnus-message 7 "No more articles"))
10430 (gnus-summary-recenter)
10431 (gnus-summary-position-point)
10434 (defun gnus-summary-unmark-as-processable (n)
10435 "Remove the process mark from the next N articles.
10436 If N is negative, unmark backward instead. The difference between N and
10437 the actual number of articles unmarked is returned."
10439 (gnus-summary-mark-as-processable n t))
10441 (defun gnus-summary-unmark-all-processable ()
10442 "Remove the process mark from all articles."
10445 (while gnus-newsgroup-processable
10446 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10447 (gnus-summary-position-point))
10449 (defun gnus-summary-add-mark (article type)
10450 "Mark ARTICLE with a mark of TYPE."
10451 (let ((vtype (car (assq type gnus-article-mark-lists)))
10454 (error "No such mark type: %s" type)
10455 (setq var (intern (format "gnus-newsgroup-%s" type)))
10456 (set var (cons article (symbol-value var)))
10457 (if (memq type '(processable cached replied forwarded recent saved))
10458 (gnus-summary-update-secondary-mark article)
10459 ;;; !!! This is bogus. We should find out what primary
10460 ;;; !!! mark we want to set.
10461 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10463 (defun gnus-summary-mark-as-expirable (n)
10464 "Mark N articles forward as expirable.
10465 If N is negative, mark backward instead. The difference between N and
10466 the actual number of articles marked is returned."
10468 (gnus-summary-mark-forward n gnus-expirable-mark))
10470 (defun gnus-summary-mark-as-spam (n)
10471 "Mark N articles forward as spam.
10472 If N is negative, mark backward instead. The difference between N and
10473 the actual number of articles marked is returned."
10475 (gnus-summary-mark-forward n gnus-spam-mark))
10477 (defun gnus-summary-mark-article-as-replied (article)
10478 "Mark ARTICLE as replied to and update the summary line.
10479 ARTICLE can also be a list of articles."
10480 (interactive (list (gnus-summary-article-number)))
10481 (let ((articles (if (listp article) article (list article))))
10482 (dolist (article articles)
10483 (unless (numberp article)
10484 (error "%s is not a number" article))
10485 (push article gnus-newsgroup-replied)
10486 (let ((inhibit-read-only t))
10487 (when (gnus-summary-goto-subject article nil t)
10488 (gnus-summary-update-secondary-mark article))))))
10490 (defun gnus-summary-mark-article-as-forwarded (article)
10491 "Mark ARTICLE as forwarded and update the summary line.
10492 ARTICLE can also be a list of articles."
10493 (let ((articles (if (listp article) article (list article))))
10494 (dolist (article articles)
10495 (push article gnus-newsgroup-forwarded)
10496 (let ((inhibit-read-only t))
10497 (when (gnus-summary-goto-subject article nil t)
10498 (gnus-summary-update-secondary-mark article))))))
10500 (defun gnus-summary-set-bookmark (article)
10501 "Set a bookmark in current article."
10502 (interactive (list (gnus-summary-article-number)))
10503 (when (or (not (get-buffer gnus-article-buffer))
10504 (not gnus-current-article)
10505 (not gnus-article-current)
10506 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10507 (error "No current article selected"))
10508 ;; Remove old bookmark, if one exists.
10509 (gnus-pull article gnus-newsgroup-bookmarks)
10510 ;; Set the new bookmark, which is on the form
10511 ;; (article-number . line-number-in-body).
10514 (with-current-buffer gnus-article-buffer
10518 (article-goto-body)
10521 gnus-newsgroup-bookmarks)
10522 (gnus-message 6 "A bookmark has been added to the current article."))
10524 (defun gnus-summary-remove-bookmark (article)
10525 "Remove the bookmark from the current article."
10526 (interactive (list (gnus-summary-article-number)))
10527 ;; Remove old bookmark, if one exists.
10528 (if (not (assq article gnus-newsgroup-bookmarks))
10529 (gnus-message 6 "No bookmark in current article.")
10530 (gnus-pull article gnus-newsgroup-bookmarks)
10531 (gnus-message 6 "Removed bookmark.")))
10533 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10534 (defun gnus-summary-mark-as-dormant (n)
10535 "Mark N articles forward as dormant.
10536 If N is negative, mark backward instead. The difference between N and
10537 the actual number of articles marked is returned."
10539 (gnus-summary-mark-forward n gnus-dormant-mark))
10541 (defun gnus-summary-set-process-mark (article)
10542 "Set the process mark on ARTICLE and update the summary line."
10543 (setq gnus-newsgroup-processable
10545 (delq article gnus-newsgroup-processable)))
10546 (when (gnus-summary-goto-subject article)
10547 (gnus-summary-show-thread)
10548 (gnus-summary-goto-subject article)
10549 (gnus-summary-update-secondary-mark article)))
10551 (defun gnus-summary-remove-process-mark (&rest articles)
10552 "Remove the process mark from ARTICLES and update the summary line."
10553 (dolist (article articles)
10554 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10555 (when (gnus-summary-goto-subject article)
10556 (gnus-summary-show-thread)
10557 (gnus-summary-goto-subject article)
10558 (gnus-summary-update-secondary-mark article)))
10561 (defun gnus-summary-set-saved-mark (article)
10562 "Set the process mark on ARTICLE and update the summary line."
10563 (push article gnus-newsgroup-saved)
10564 (when (gnus-summary-goto-subject article)
10565 (gnus-summary-update-secondary-mark article)))
10567 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10568 "Mark N articles as read forwards.
10569 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10570 The difference between N and the actual number of articles marked is
10572 If NO-EXPIRE, auto-expiry will be inhibited."
10574 (gnus-summary-show-thread)
10575 (let ((backward (< n 0))
10576 (gnus-summary-goto-unread
10577 (and gnus-summary-goto-unread
10578 (not (eq gnus-summary-goto-unread 'never))
10579 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10580 gnus-ticked-mark gnus-dormant-mark)))))
10582 (mark (or mark gnus-del-mark)))
10583 (while (and (> n 0)
10584 (gnus-summary-mark-article nil mark no-expire)
10585 (zerop (gnus-summary-next-subject
10587 (and gnus-summary-goto-unread
10588 (not (eq gnus-summary-goto-unread 'never)))
10592 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10593 (gnus-summary-recenter)
10594 (gnus-summary-position-point)
10595 (gnus-set-mode-line 'summary)
10598 (defun gnus-summary-mark-article-as-read (mark)
10599 "Mark the current article quickly as read with MARK."
10600 (let ((article (gnus-summary-article-number)))
10601 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10602 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10603 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10604 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10605 (push (cons article mark) gnus-newsgroup-reads)
10606 ;; Possibly remove from cache, if that is used.
10607 (when gnus-use-cache
10608 (gnus-cache-enter-remove-article article))
10609 ;; Allow the backend to change the mark.
10610 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10611 ;; Check for auto-expiry.
10612 (when (and gnus-newsgroup-auto-expire
10613 (memq mark gnus-auto-expirable-marks))
10614 (setq mark gnus-expirable-mark)
10615 ;; Let the backend know about the mark change.
10616 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10617 (push article gnus-newsgroup-expirable))
10618 ;; Set the mark in the buffer.
10619 (gnus-summary-update-mark mark 'unread)
10622 (defun gnus-summary-mark-article-as-unread (mark)
10623 "Mark the current article quickly as unread with MARK."
10624 (let* ((article (gnus-summary-article-number))
10625 (old-mark (gnus-summary-article-mark article)))
10626 ;; Allow the backend to change the mark.
10627 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10628 (if (eq mark old-mark)
10632 (gnus-error 1 "Can't mark negative article numbers")
10634 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10635 (setq gnus-newsgroup-spam-marked
10636 (delq article gnus-newsgroup-spam-marked))
10637 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10638 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10639 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10640 (cond ((= mark gnus-ticked-mark)
10641 (setq gnus-newsgroup-marked
10642 (gnus-add-to-sorted-list gnus-newsgroup-marked
10644 ((= mark gnus-spam-mark)
10645 (setq gnus-newsgroup-spam-marked
10646 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10648 ((= mark gnus-dormant-mark)
10649 (setq gnus-newsgroup-dormant
10650 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10653 (setq gnus-newsgroup-unreads
10654 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10656 (gnus-pull article gnus-newsgroup-reads)
10658 ;; See whether the article is to be put in the cache.
10659 (and gnus-use-cache
10660 (vectorp (gnus-summary-article-header article))
10662 (gnus-cache-possibly-enter-article
10663 gnus-newsgroup-name article
10664 (= mark gnus-ticked-mark)
10665 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10668 (gnus-summary-update-mark mark 'unread)
10671 (defun gnus-summary-mark-article (&optional article mark no-expire)
10672 "Mark ARTICLE with MARK. MARK can be any character.
10673 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10674 `??' (dormant) and `?E' (expirable).
10675 If MARK is nil, then the default character `?r' is used.
10676 If ARTICLE is nil, then the article on the current line will be
10678 If NO-EXPIRE, auto-expiry will be inhibited."
10679 ;; The mark might be a string.
10680 (when (stringp mark)
10681 (setq mark (aref mark 0)))
10682 ;; If no mark is given, then we check auto-expiring.
10684 (setq mark gnus-del-mark))
10685 (when (and (not no-expire)
10686 gnus-newsgroup-auto-expire
10687 (memq mark gnus-auto-expirable-marks))
10688 (setq mark gnus-expirable-mark))
10689 (let ((article (or article (gnus-summary-article-number)))
10690 (old-mark (gnus-summary-article-mark article)))
10691 ;; Allow the backend to change the mark.
10692 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10693 (if (eq mark old-mark)
10696 (error "No article on current line"))
10697 (if (not (if (or (= mark gnus-unread-mark)
10698 (= mark gnus-ticked-mark)
10699 (= mark gnus-spam-mark)
10700 (= mark gnus-dormant-mark))
10701 (gnus-mark-article-as-unread article mark)
10702 (gnus-mark-article-as-read article mark)))
10704 ;; See whether the article is to be put in the cache.
10705 (and gnus-use-cache
10706 (not (= mark gnus-canceled-mark))
10707 (vectorp (gnus-summary-article-header article))
10709 (gnus-cache-possibly-enter-article
10710 gnus-newsgroup-name article
10711 (= mark gnus-ticked-mark)
10712 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10714 (when (gnus-summary-goto-subject article nil t)
10715 (let ((inhibit-read-only t))
10716 (gnus-summary-show-thread)
10718 (gnus-summary-update-mark mark 'unread)
10721 (defun gnus-summary-update-secondary-mark (article)
10722 "Update the secondary (read, process, cache) mark."
10723 (gnus-summary-update-mark
10724 (cond ((memq article gnus-newsgroup-processable)
10726 ((memq article gnus-newsgroup-cached)
10728 ((memq article gnus-newsgroup-replied)
10730 ((memq article gnus-newsgroup-forwarded)
10731 gnus-forwarded-mark)
10732 ((memq article gnus-newsgroup-saved)
10734 ((memq article gnus-newsgroup-recent)
10736 ((memq article gnus-newsgroup-unseen)
10740 (when (gnus-visual-p 'summary-highlight 'highlight)
10741 (gnus-summary-highlight-line)
10742 (gnus-run-hooks 'gnus-summary-update-hook))
10745 (defun gnus-summary-update-download-mark (article)
10746 "Update the download mark."
10747 (gnus-summary-update-mark
10748 (cond ((memq article gnus-newsgroup-undownloaded)
10749 gnus-undownloaded-mark)
10750 (gnus-newsgroup-agentized
10751 gnus-downloaded-mark)
10755 (gnus-summary-update-line t)
10758 (defun gnus-summary-update-mark (mark type)
10759 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10760 (inhibit-read-only t))
10761 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10763 (when (looking-at "\r")
10765 (when (<= (+ forward (point)) (point-max))
10766 ;; Go to the right position on the line.
10767 (goto-char (+ forward (point)))
10768 ;; Replace the old mark with the new mark.
10770 (mm-subst-char-in-string
10772 (buffer-substring (point) (1+ (point))))))
10773 (delete-region (point) (1+ (point)))
10774 (insert to-insert))
10775 ;; Optionally update the marks by some user rule.
10776 (when (eq type 'unread)
10777 (gnus-data-set-mark
10778 (gnus-data-find (gnus-summary-article-number)) mark)
10779 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10781 (defun gnus-mark-article-as-read (article &optional mark)
10782 "Enter ARTICLE in the pertinent lists and remove it from others."
10783 ;; Make the article expirable.
10784 (let ((mark (or mark gnus-del-mark)))
10785 (setq gnus-newsgroup-expirable
10786 (if (= mark gnus-expirable-mark)
10787 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10788 (delq article gnus-newsgroup-expirable)))
10789 ;; Remove from unread and marked lists.
10790 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10791 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10792 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10793 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10794 (push (cons article mark) gnus-newsgroup-reads)
10795 ;; Possibly remove from cache, if that is used.
10796 (when gnus-use-cache
10797 (gnus-cache-enter-remove-article article))
10800 (defun gnus-mark-article-as-unread (article &optional mark)
10801 "Enter ARTICLE in the pertinent lists and remove it from others."
10802 (let ((mark (or mark gnus-ticked-mark)))
10805 (gnus-error 1 "Can't mark negative article numbers")
10807 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10808 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10809 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10810 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10811 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10813 ;; Unsuppress duplicates?
10814 (when gnus-suppress-duplicates
10815 (gnus-dup-unsuppress-article article))
10817 (cond ((= mark gnus-ticked-mark)
10818 (setq gnus-newsgroup-marked
10819 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10820 ((= mark gnus-spam-mark)
10821 (setq gnus-newsgroup-spam-marked
10822 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10824 ((= mark gnus-dormant-mark)
10825 (setq gnus-newsgroup-dormant
10826 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10828 (setq gnus-newsgroup-unreads
10829 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10830 (gnus-pull article gnus-newsgroup-reads)
10833 (defalias 'gnus-summary-mark-as-unread-forward
10834 'gnus-summary-tick-article-forward)
10835 (make-obsolete 'gnus-summary-mark-as-unread-forward
10836 'gnus-summary-tick-article-forward "Emacs 20.4")
10837 (defun gnus-summary-tick-article-forward (n)
10838 "Tick N articles forwards.
10839 If N is negative, tick backwards instead.
10840 The difference between N and the number of articles ticked is returned."
10842 (gnus-summary-mark-forward n gnus-ticked-mark))
10844 (defalias 'gnus-summary-mark-as-unread-backward
10845 'gnus-summary-tick-article-backward)
10846 (make-obsolete 'gnus-summary-mark-as-unread-backward
10847 'gnus-summary-tick-article-backward "Emacs 20.4")
10848 (defun gnus-summary-tick-article-backward (n)
10849 "Tick N articles backwards.
10850 The difference between N and the number of articles ticked is returned."
10852 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10854 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10855 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article "Emacs 20.4")
10856 (defun gnus-summary-tick-article (&optional article clear-mark)
10857 "Mark current article as unread.
10858 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10859 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10861 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10862 gnus-ticked-mark)))
10864 (defun gnus-summary-mark-as-read-forward (n)
10865 "Mark N articles as read forwards.
10866 If N is negative, mark backwards instead.
10867 The difference between N and the actual number of articles marked is
10870 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10872 (defun gnus-summary-mark-as-read-backward (n)
10873 "Mark the N articles as read backwards.
10874 The difference between N and the actual number of articles marked is
10877 (gnus-summary-mark-forward
10878 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10880 (defun gnus-summary-mark-as-read (&optional article mark)
10881 "Mark current article as read.
10882 ARTICLE specifies the article to be marked as read.
10883 MARK specifies a string to be inserted at the beginning of the line."
10884 (gnus-summary-mark-article article mark))
10886 (defun gnus-summary-clear-mark-forward (n)
10887 "Clear marks from N articles forward.
10888 If N is negative, clear backward instead.
10889 The difference between N and the number of marks cleared is returned."
10891 (gnus-summary-mark-forward n gnus-unread-mark))
10893 (defun gnus-summary-clear-mark-backward (n)
10894 "Clear marks from N articles backward.
10895 The difference between N and the number of marks cleared is returned."
10897 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10899 (defun gnus-summary-mark-unread-as-read ()
10900 "Intended to be used by `gnus-mark-article-hook'."
10901 (when (memq gnus-current-article gnus-newsgroup-unreads)
10902 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10904 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10905 "Intended to be used by `gnus-mark-article-hook'."
10906 (let ((mark (gnus-summary-article-mark)))
10907 (when (or (gnus-unread-mark-p mark)
10908 (gnus-read-mark-p mark))
10909 (gnus-summary-mark-article gnus-current-article
10910 (or new-mark gnus-read-mark)))))
10912 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10913 "Intended to be used by `gnus-mark-article-hook'."
10914 (let ((mark (gnus-summary-article-mark)))
10915 (when (or (gnus-unread-mark-p mark)
10916 (gnus-read-mark-p mark))
10917 (gnus-summary-mark-article (gnus-summary-article-number)
10918 (or new-mark gnus-read-mark)))))
10920 (defun gnus-summary-mark-unread-as-ticked ()
10921 "Intended to be used by `gnus-mark-article-hook'."
10922 (when (memq gnus-current-article gnus-newsgroup-unreads)
10923 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10925 (defun gnus-summary-mark-region-as-read (point mark all)
10926 "Mark all unread articles between point and mark as read.
10927 If given a prefix, mark all articles between point and mark as read,
10928 even ticked and dormant ones."
10929 (interactive "r\nP")
10933 (beginning-of-line)
10938 (memq (setq article (gnus-summary-article-number))
10939 gnus-newsgroup-unreads))
10940 (gnus-summary-mark-article article gnus-del-mark))
10942 (gnus-summary-find-next))))))
10944 (defun gnus-summary-mark-below (score mark)
10945 "Mark articles with score less than SCORE with MARK."
10946 (interactive "P\ncMark: ")
10947 (setq score (if score
10948 (prefix-numeric-value score)
10949 (or gnus-summary-default-score 0)))
10950 (with-current-buffer gnus-summary-buffer
10951 (goto-char (point-min))
10954 (and (< (gnus-summary-article-score) score)
10955 (gnus-summary-mark-article nil mark))
10956 (gnus-summary-find-next)))))
10958 (defun gnus-summary-kill-below (&optional score)
10959 "Mark articles with score below SCORE as read."
10961 (gnus-summary-mark-below score gnus-killed-mark))
10963 (defun gnus-summary-clear-above (&optional score)
10964 "Clear all marks from articles with score above SCORE."
10966 (gnus-summary-mark-above score gnus-unread-mark))
10968 (defun gnus-summary-tick-above (&optional score)
10969 "Tick all articles with score above SCORE."
10971 (gnus-summary-mark-above score gnus-ticked-mark))
10973 (defun gnus-summary-mark-above (score mark)
10974 "Mark articles with score over SCORE with MARK."
10975 (interactive "P\ncMark: ")
10976 (setq score (if score
10977 (prefix-numeric-value score)
10978 (or gnus-summary-default-score 0)))
10979 (with-current-buffer gnus-summary-buffer
10980 (goto-char (point-min))
10982 (when (> (gnus-summary-article-score) score)
10983 (gnus-summary-mark-article nil mark))
10985 (gnus-summary-find-next)))))
10987 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10988 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10989 (defun gnus-summary-limit-include-expunged (&optional no-error)
10990 "Display all the hidden articles that were expunged for low scores."
10992 (let ((inhibit-read-only t))
10993 (let ((scored gnus-newsgroup-scored)
10996 (unless (gnus-summary-article-header (caar scored))
10997 (and (setq h (gnus-number-to-header (caar scored)))
10998 (< (cdar scored) gnus-summary-expunge-below)
11000 (setq scored (cdr scored)))
11002 (when (not no-error)
11003 (error "No expunged articles hidden"))
11004 (goto-char (point-min))
11005 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11006 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11007 (dolist (x headers)
11008 (push (mail-header-number x) gnus-newsgroup-limit))
11009 (gnus-summary-prepare-unthreaded (nreverse headers))
11010 (goto-char (point-min))
11011 (gnus-summary-position-point)
11014 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11015 "Mark all unread articles in this newsgroup as read.
11016 If prefix argument ALL is non-nil, ticked and dormant articles will
11017 also be marked as read.
11018 If QUIETLY is non-nil, no questions will be asked.
11020 If TO-HERE is non-nil, it should be a point in the buffer. All
11021 articles before (after, if REVERSE is set) this point will be marked
11024 Note that this function will only catch up the unread article
11025 in the current summary buffer limitation.
11027 The number of articles marked as read is returned."
11032 (not gnus-interactive-catchup) ;Without confirmation?
11036 "Mark absolutely all articles as read? "
11037 "Mark all unread articles as read? ")))
11039 (not gnus-newsgroup-adaptive)
11040 (not gnus-newsgroup-auto-expire)
11041 (not gnus-suppress-duplicates)
11042 (or (not gnus-use-cache)
11043 (eq gnus-use-cache 'passive)))
11046 (setq gnus-newsgroup-marked nil
11047 gnus-newsgroup-spam-marked nil
11048 gnus-newsgroup-dormant nil))
11049 (setq gnus-newsgroup-unreads
11050 (gnus-sorted-nunion
11051 (gnus-sorted-intersection gnus-newsgroup-unreads
11052 gnus-newsgroup-downloadable)
11053 (gnus-sorted-difference gnus-newsgroup-unfetched
11054 gnus-newsgroup-cached))))
11055 ;; We actually mark all articles as canceled, which we
11056 ;; have to do when using auto-expiry or adaptive scoring.
11057 (gnus-summary-show-all-threads)
11058 (if (and to-here reverse)
11060 (goto-char to-here)
11061 (gnus-summary-mark-current-read-and-unread-as-read
11063 (while (gnus-summary-find-next (not all))
11064 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11065 (when (gnus-summary-first-subject (not all))
11067 (if to-here (< (point) to-here) t)
11068 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11069 (gnus-summary-find-next (not all))))))
11070 (gnus-set-mode-line 'summary))
11072 (gnus-summary-position-point)))
11074 (defun gnus-summary-catchup-to-here (&optional all)
11075 "Mark all unticked articles before the current one as read.
11076 If ALL is non-nil, also mark ticked and dormant articles as read."
11079 (gnus-save-hidden-threads
11080 (let ((beg (point)))
11081 ;; We check that there are unread articles.
11082 (when (or all (gnus-summary-find-prev))
11083 (gnus-summary-catchup all t beg)))))
11084 (gnus-summary-position-point))
11086 (defun gnus-summary-catchup-from-here (&optional all)
11087 "Mark all unticked articles after (and including) the current one as read.
11088 If ALL is non-nil, also mark ticked and dormant articles as read."
11091 (gnus-save-hidden-threads
11092 (let ((beg (point)))
11093 ;; We check that there are unread articles.
11094 (when (or all (gnus-summary-find-next))
11095 (gnus-summary-catchup all t beg nil t)))))
11096 (gnus-summary-position-point))
11098 (defun gnus-summary-catchup-all (&optional quietly)
11099 "Mark all articles in this newsgroup as read.
11100 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11101 instead, which marks only unread articles as read."
11103 (gnus-summary-catchup t quietly))
11105 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11106 "Mark all unread articles in this group as read, then exit.
11107 If prefix argument ALL is non-nil, all articles are marked as read.
11108 If QUIETLY is non-nil, no questions will be asked."
11110 (when (gnus-summary-catchup all quietly nil 'fast)
11111 ;; Select next newsgroup or exit.
11112 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11113 (eq gnus-auto-select-next 'quietly))
11114 (gnus-summary-next-group nil)
11115 (gnus-summary-exit))))
11117 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11118 "Mark all articles in this newsgroup as read, and then exit.
11119 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11120 instead, which marks only unread articles as read."
11122 (gnus-summary-catchup-and-exit t quietly))
11124 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11125 "Mark all articles in this group as read and select the next group.
11126 If given a prefix, mark all articles, unread as well as ticked, as
11130 (gnus-summary-catchup all))
11131 (gnus-summary-next-group))
11133 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11134 "Mark all articles in this group as read and select the previous group.
11135 If given a prefix, mark all articles, unread as well as ticked, as
11139 (gnus-summary-catchup all))
11140 (gnus-summary-next-group nil nil t))
11146 (defmacro gnus-with-article (article &rest forms)
11147 "Select ARTICLE and perform FORMS in the original article buffer.
11148 Then replace the article with the result."
11150 ;; We don't want the article to be marked as read.
11151 (let (gnus-mark-article-hook)
11152 (gnus-summary-select-article t t nil ,article))
11153 (set-buffer gnus-original-article-buffer)
11155 (if (not (gnus-check-backend-function
11156 'request-replace-article (car gnus-article-current)))
11157 (gnus-message 5 "Read-only group; not replacing")
11158 (unless (gnus-request-replace-article
11159 ,article (car gnus-article-current)
11160 (current-buffer) t)
11161 (error "Couldn't replace article")))
11162 ;; The cache and backlog have to be flushed somewhat.
11163 (when gnus-keep-backlog
11164 (gnus-backlog-remove-article
11165 (car gnus-article-current) (cdr gnus-article-current)))
11166 (when gnus-use-cache
11167 (gnus-cache-update-article
11168 (car gnus-article-current) (cdr gnus-article-current)))))
11170 (put 'gnus-with-article 'lisp-indent-function 1)
11171 (put 'gnus-with-article 'edebug-form-spec '(form body))
11173 ;; Thread-based commands.
11175 (defun gnus-summary-articles-in-thread (&optional article)
11176 "Return a list of all articles in the current thread.
11177 If ARTICLE is non-nil, return all articles in the thread that starts
11178 with that article."
11179 (let* ((article (or article (gnus-summary-article-number)))
11180 (data (gnus-data-find-list article))
11181 (top-level (gnus-data-level (car data)))
11183 (cond ((null gnus-thread-operation-ignore-subject)
11184 (gnus-simplify-subject-re
11185 (mail-header-subject (gnus-data-header (car data)))))
11186 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11187 (gnus-simplify-subject-fuzzy
11188 (mail-header-subject (gnus-data-header (car data)))))
11190 (end-point (save-excursion
11191 (if (gnus-summary-go-to-next-thread)
11192 (point) (point-max))))
11195 (< (gnus-data-pos (car data)) end-point))
11196 (when (or (not top-subject)
11197 (string= top-subject
11198 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11199 (gnus-simplify-subject-fuzzy
11200 (mail-header-subject
11201 (gnus-data-header (car data))))
11202 (gnus-simplify-subject-re
11203 (mail-header-subject
11204 (gnus-data-header (car data)))))))
11205 (push (gnus-data-number (car data)) articles))
11206 (unless (and (setq data (cdr data))
11207 (> (gnus-data-level (car data)) top-level))
11209 ;; Return the list of articles.
11210 (nreverse articles)))
11212 (defun gnus-summary-rethread-current ()
11213 "Rethread the thread the current article is part of."
11215 (let* ((gnus-show-threads t)
11216 (article (gnus-summary-article-number))
11217 (id (mail-header-id (gnus-summary-article-header)))
11218 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11220 (error "No article on the current line"))
11221 (gnus-rebuild-thread id)
11222 (gnus-summary-goto-subject article)))
11224 (defun gnus-summary-reparent-thread ()
11225 "Make the current article child of the marked (or previous) article.
11227 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11228 is non-nil or the Subject: of both articles are the same."
11230 (unless (not (gnus-group-read-only-p))
11231 (error "The current newsgroup does not support article editing"))
11232 (unless (<= (length gnus-newsgroup-processable) 1)
11233 (error "No more than one article may be marked"))
11234 (let ((child (gnus-summary-article-number))
11235 ;; First grab the marked article, otherwise one line up.
11236 (parent (if (not (null gnus-newsgroup-processable))
11237 (car gnus-newsgroup-processable)
11239 (if (eq (forward-line -1) 0)
11240 (gnus-summary-article-number)
11241 (error "Beginning of summary buffer"))))))
11242 (gnus-summary-reparent-children parent (list child))))
11244 (defun gnus-summary-reparent-children (parent children)
11245 "Make PARENT the parent of CHILDREN.
11246 When called interactively, PARENT is the current article and CHILDREN
11247 are the process-marked articles."
11249 (list (gnus-summary-article-number)
11250 (gnus-summary-work-articles nil)))
11251 (dolist (child children)
11252 (save-window-excursion
11253 (let ((gnus-article-buffer " *reparent*"))
11254 (unless (not (eq parent child))
11255 (error "An article may not be self-referential"))
11256 (let ((message-id (mail-header-id
11257 (gnus-summary-article-header parent))))
11258 (unless (and message-id (not (equal message-id "")))
11259 (error "No message-id in desired parent"))
11260 (gnus-with-article child
11262 (goto-char (point-min))
11263 (message-narrow-to-head)
11264 (if (re-search-forward "^References: " nil t)
11266 (re-search-forward "^[^ \t]" nil t)
11269 (insert " " message-id))
11270 (insert "References: " message-id "\n"))))
11271 (set-buffer gnus-summary-buffer)
11272 (gnus-summary-unmark-all-processable)
11273 (gnus-summary-update-article child)
11274 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11275 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11276 (gnus-summary-rethread-current)
11277 (gnus-message 3 "Article %d is now the child of article %d"
11280 (defun gnus-summary-toggle-threads (&optional arg)
11281 "Toggle showing conversation threads.
11282 If ARG is positive number, turn showing conversation threads on."
11284 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11285 (setq gnus-show-threads
11286 (if (null arg) (not gnus-show-threads)
11287 (> (prefix-numeric-value arg) 0)))
11288 (gnus-summary-prepare)
11289 (gnus-summary-goto-subject current)
11290 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11291 (gnus-summary-position-point)))
11294 (if (fboundp 'remove-overlays)
11295 (defalias 'gnus-remove-overlays 'remove-overlays)
11296 (defun gnus-remove-overlays (beg end name val)
11297 "Clear BEG and END of overlays whose property NAME has value VAL.
11298 For compatibility with XEmacs."
11299 (dolist (ov (gnus-overlays-in beg end))
11300 (when (eq (gnus-overlay-get ov name) val)
11301 (gnus-delete-overlay ov))))))
11303 (defun gnus-summary-show-all-threads ()
11304 "Show all threads."
11306 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11307 (gnus-summary-position-point))
11309 (defun gnus-summary-show-thread ()
11310 "Show thread subtrees.
11311 Returns nil if no thread was there to be shown."
11313 (let* ((orig (point))
11314 (end (point-at-eol))
11315 ;; Leave point at bol
11316 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11317 (eoi (when (eq (get-char-property end 'invisible) 'gnus-sum)
11318 (if (fboundp 'next-single-char-property-change)
11319 (or (next-single-char-property-change end 'invisible)
11324 (eq (get-char-property (point) 'invisible)
11328 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11330 (gnus-summary-position-point)
11333 (defun gnus-summary-maybe-hide-threads ()
11334 "If requested, hide the threads that should be hidden."
11335 (when (and gnus-show-threads
11336 gnus-thread-hide-subtree)
11337 (gnus-summary-hide-all-threads
11338 (if (or (consp gnus-thread-hide-subtree)
11339 (functionp gnus-thread-hide-subtree))
11340 (gnus-make-predicate gnus-thread-hide-subtree)
11343 ;;; Hiding predicates.
11345 (defun gnus-article-unread-p (header)
11346 (memq (mail-header-number header) gnus-newsgroup-unreads))
11348 (defun gnus-article-unseen-p (header)
11349 (memq (mail-header-number header) gnus-newsgroup-unseen))
11351 (defun gnus-map-articles (predicate articles)
11352 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11353 (apply 'gnus-or (mapcar predicate
11354 (mapcar (lambda (number)
11355 (gnus-summary-article-header number))
11358 (defun gnus-summary-hide-all-threads (&optional predicate)
11359 "Hide all thread subtrees.
11360 If PREDICATE is supplied, threads that satisfy this predicate
11361 will not be hidden."
11364 (goto-char (point-min))
11367 (when (or (not predicate)
11369 predicate (gnus-summary-article-children)))
11370 (gnus-summary-hide-thread))
11371 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11372 (gnus-summary-position-point))
11374 (defun gnus-summary-hide-thread ()
11375 "Hide thread subtrees.
11376 If PREDICATE is supplied, threads that satisfy this predicate
11377 will not be hidden.
11378 Returns nil if no threads were there to be hidden."
11380 (let ((start (point))
11381 (starteol (line-end-position))
11382 (article (gnus-summary-article-number)))
11384 ;; Go forward until either the buffer ends or the subthread ends.
11385 (when (and (not (eobp))
11386 (or (zerop (gnus-summary-next-thread 1 t))
11387 (goto-char (point-max))))
11388 (if (and (> (point) start)
11389 ;; FIXME: this should actually search for a non-invisible \n.
11390 (search-backward "\n" start t))
11392 (when (> (point) starteol)
11393 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11394 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11395 (gnus-overlay-put ol 'invisible 'gnus-sum)
11396 (gnus-overlay-put ol 'evaporate t)))
11397 (gnus-summary-goto-subject article))
11401 (defun gnus-summary-go-to-next-thread (&optional previous)
11402 "Go to the same level (or less) next thread.
11403 If PREVIOUS is non-nil, go to previous thread instead.
11404 Return the article number moved to, or nil if moving was impossible."
11405 (let ((level (gnus-summary-thread-level))
11406 (way (if previous -1 1))
11409 (while (and (not (eobp))
11410 (< level (gnus-summary-thread-level)))
11411 (forward-line way))
11418 (gnus-summary-article-number)
11419 (goto-char beg)))))
11421 (defun gnus-summary-next-thread (n &optional silent)
11422 "Go to the same level next N'th thread.
11423 If N is negative, search backward instead.
11424 Returns the difference between N and the number of skips actually
11427 If SILENT, don't output messages."
11429 (let ((backward (< n 0))
11431 (while (and (> n 0)
11432 (gnus-summary-go-to-next-thread backward))
11435 (gnus-summary-position-point))
11436 (when (and (not silent) (/= 0 n))
11437 (gnus-message 7 "No more threads"))
11440 (defun gnus-summary-prev-thread (n)
11441 "Go to the same level previous N'th thread.
11442 Returns the difference between N and the number of skips actually
11445 (gnus-summary-next-thread (- n)))
11447 (defun gnus-summary-go-down-thread ()
11448 "Go down one level in the current thread."
11449 (let ((children (gnus-summary-article-children)))
11451 (gnus-summary-goto-subject (car children)))))
11453 (defun gnus-summary-go-up-thread ()
11454 "Go up one level in the current thread."
11455 (let ((parent (gnus-summary-article-parent)))
11457 (gnus-summary-goto-subject parent))))
11459 (defun gnus-summary-down-thread (n)
11460 "Go down thread N steps.
11461 If N is negative, go up instead.
11462 Returns the difference between N and how many steps down that were
11467 (while (and (> n 0)
11468 (if up (gnus-summary-go-up-thread)
11469 (gnus-summary-go-down-thread)))
11471 (gnus-summary-position-point)
11473 (gnus-message 7 "Can't go further"))
11476 (defun gnus-summary-up-thread (n)
11477 "Go up thread N steps.
11478 If N is negative, go down instead.
11479 Returns the difference between N and how many steps down that were
11482 (gnus-summary-down-thread (- n)))
11484 (defun gnus-summary-top-thread ()
11485 "Go to the top of the thread."
11487 (while (gnus-summary-go-up-thread))
11488 (gnus-summary-article-number))
11490 (defun gnus-summary-expire-thread ()
11491 "Mark articles under current thread as expired."
11493 (gnus-summary-kill-thread 0))
11495 (defun gnus-summary-kill-thread (&optional unmark)
11496 "Mark articles under current thread as read.
11497 If the prefix argument is positive, remove any kinds of marks.
11498 If the prefix argument is zero, mark thread as expired.
11499 If the prefix argument is negative, tick articles instead."
11502 (setq unmark (prefix-numeric-value unmark)))
11503 (let ((articles (gnus-summary-articles-in-thread))
11504 (hide (or (null unmark) (= unmark 0))))
11506 ;; Expand the thread.
11507 (gnus-summary-show-thread)
11508 ;; Mark all the articles.
11510 (gnus-summary-goto-subject (car articles))
11511 (cond ((null unmark)
11512 (gnus-summary-mark-article-as-read gnus-killed-mark))
11514 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11516 (gnus-summary-mark-article nil gnus-expirable-mark))
11518 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11519 (setq articles (cdr articles))))
11520 ;; Hide killed subtrees when hide is true.
11522 gnus-thread-hide-killed
11523 (gnus-summary-hide-thread))
11524 ;; If hide is t, go to next unread subject.
11526 ;; Go to next unread subject.
11527 (gnus-summary-next-subject 1 t)))
11528 (gnus-set-mode-line 'summary))
11530 ;; Summary sorting commands
11532 (defun gnus-summary-sort-by-number (&optional reverse)
11533 "Sort the summary buffer by article number.
11534 Argument REVERSE means reverse order."
11536 (gnus-summary-sort 'number reverse))
11538 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11539 "Sort the summary buffer by most recent article number.
11540 Argument REVERSE means reverse order."
11542 (gnus-summary-sort 'most-recent-number reverse))
11544 (defun gnus-summary-sort-by-random (&optional reverse)
11545 "Randomize the order in the summary buffer.
11546 Argument REVERSE means to randomize in reverse order."
11548 (gnus-summary-sort 'random reverse))
11550 (defun gnus-summary-sort-by-author (&optional reverse)
11551 "Sort the summary buffer by author name alphabetically.
11552 If `case-fold-search' is non-nil, case of letters is ignored.
11553 Argument REVERSE means reverse order."
11555 (gnus-summary-sort 'author reverse))
11557 (defun gnus-summary-sort-by-recipient (&optional reverse)
11558 "Sort the summary buffer by recipient name alphabetically.
11559 If `case-fold-search' is non-nil, case of letters is ignored.
11560 Argument REVERSE means reverse order."
11562 (gnus-summary-sort 'recipient reverse))
11564 (defun gnus-summary-sort-by-subject (&optional reverse)
11565 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11566 If `case-fold-search' is non-nil, case of letters is ignored.
11567 Argument REVERSE means reverse order."
11569 (gnus-summary-sort 'subject reverse))
11571 (defun gnus-summary-sort-by-date (&optional reverse)
11572 "Sort the summary buffer by date.
11573 Argument REVERSE means reverse order."
11575 (gnus-summary-sort 'date reverse))
11577 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11578 "Sort the summary buffer by most recent date.
11579 Argument REVERSE means reverse order."
11581 (gnus-summary-sort 'most-recent-date reverse))
11583 (defun gnus-summary-sort-by-score (&optional reverse)
11584 "Sort the summary buffer by score.
11585 Argument REVERSE means reverse order."
11587 (gnus-summary-sort 'score reverse))
11589 (defun gnus-summary-sort-by-lines (&optional reverse)
11590 "Sort the summary buffer by the number of lines.
11591 Argument REVERSE means reverse order."
11593 (gnus-summary-sort 'lines reverse))
11595 (defun gnus-summary-sort-by-chars (&optional reverse)
11596 "Sort the summary buffer by article length.
11597 Argument REVERSE means reverse order."
11599 (gnus-summary-sort 'chars reverse))
11601 (defun gnus-summary-sort-by-original (&optional reverse)
11602 "Sort the summary buffer using the default sorting method.
11603 Argument REVERSE means reverse order."
11605 (let* ((inhibit-read-only t)
11606 (gnus-summary-prepare-hook nil))
11607 ;; We do the sorting by regenerating the threads.
11608 (gnus-summary-prepare)
11609 ;; Hide subthreads if needed.
11610 (gnus-summary-maybe-hide-threads)))
11612 (defun gnus-summary-sort (predicate reverse)
11613 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11614 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11615 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11616 (gnus-thread-sort-functions
11621 (gnus-sort-gathered-threads-function
11622 gnus-thread-sort-functions)
11623 (gnus-article-sort-functions
11627 (,article t2 t1))))
11628 (inhibit-read-only t)
11629 (gnus-summary-prepare-hook nil))
11630 ;; We do the sorting by regenerating the threads.
11631 (gnus-summary-prepare)
11632 ;; Hide subthreads if needed.
11633 (gnus-summary-maybe-hide-threads)))
11635 ;; Summary saving commands.
11637 (defun gnus-summary-save-article (&optional n not-saved)
11638 "Save the current article using the default saver function.
11639 If N is a positive number, save the N next articles.
11640 If N is a negative number, save the N previous articles.
11641 If N is nil and any articles have been marked with the process mark,
11642 save those articles instead.
11643 The variable `gnus-default-article-saver' specifies the saver function.
11645 If the optional second argument NOT-SAVED is non-nil, articles saved
11646 will not be marked as saved."
11648 (require 'gnus-art)
11649 (let* ((articles (gnus-summary-work-articles n))
11650 (save-buffer (save-excursion
11651 (nnheader-set-temp-buffer " *Gnus Save*")))
11652 (num (length articles))
11653 ;; Whether to save decoded articles or raw articles.
11654 (decode (when gnus-article-save-coding-system
11655 (get gnus-default-article-saver :decode)))
11656 ;; When saving many articles in a single file, use the other
11657 ;; function to save articles other than the first one.
11658 (saver2 (get gnus-default-article-saver :function))
11659 (gnus-prompt-before-saving (if saver2
11661 gnus-prompt-before-saving))
11662 (gnus-default-article-saver gnus-default-article-saver)
11664 (dolist (article articles)
11665 (setq header (gnus-summary-article-header article))
11666 (if (not (vectorp header))
11667 ;; This is a pseudo-article.
11668 (if (assq 'name header)
11669 (gnus-copy-file (cdr (assq 'name header)))
11670 (gnus-message 1 "Article %d is unsaveable" article))
11671 ;; This is a real article.
11672 (save-window-excursion
11673 (gnus-summary-select-article decode decode nil article)
11674 (gnus-summary-goto-subject article))
11675 (with-current-buffer save-buffer
11677 (insert-buffer-substring (if decode
11678 gnus-article-buffer
11679 gnus-original-article-buffer)))
11680 (setq file (gnus-article-save save-buffer file num))
11681 (gnus-summary-remove-process-mark article)
11683 (gnus-summary-set-saved-mark article)))
11685 (setq gnus-default-article-saver saver2
11687 (gnus-kill-buffer save-buffer)
11688 (gnus-summary-position-point)
11689 (gnus-set-mode-line 'summary)
11692 (defun gnus-summary-pipe-output (&optional n sym)
11693 "Pipe the current article to a subprocess.
11694 If N is a positive number, pipe the N next articles.
11695 If N is a negative number, pipe the N previous articles.
11696 If N is nil and any articles have been marked with the process mark,
11697 pipe those articles instead.
11698 The default command to which articles are piped is specified by the
11699 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11700 will be prompted for the command.
11702 The properties `:decode' and `:headers' that are put to the function
11703 symbol `gnus-summary-save-in-pipe' control whether this function
11704 decodes articles and what headers to keep (see the doc string for the
11705 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11706 is neither omitted nor the symbol `r', force including all headers
11707 regardless of the `:headers' property. If it is the symbol `r',
11708 articles that are not decoded and include all headers will be piped
11709 no matter what the properties `:decode' and `:headers' are."
11710 (interactive (gnus-interactive "P\ny"))
11711 (require 'gnus-art)
11712 (let* ((articles (gnus-summary-work-articles n))
11713 (result-buffer "*Shell Command Output*")
11714 (all-headers (not (memq sym '(nil r))))
11715 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11717 (headers (get 'gnus-summary-save-in-pipe :headers))
11719 (unless (numberp (car articles))
11720 (error "No article to pipe"))
11721 (setq command (gnus-read-shell-command
11722 (concat "Shell command on "
11724 (format "these %d articles" (length articles))
11727 gnus-summary-pipe-output-default-command))
11728 (when (string-equal command "")
11729 (error "A command is required"))
11731 (put 'gnus-summary-save-in-pipe :headers nil))
11734 (gnus-summary-goto-subject (pop articles))
11735 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11736 (when (and (get-buffer result-buffer)
11737 (not (zerop (buffer-size (get-buffer result-buffer)))))
11738 (setq result (concat result (with-current-buffer result-buffer
11739 (buffer-string))))))
11740 (put 'gnus-summary-save-in-pipe :headers headers))
11741 (unless (zerop (length result))
11742 (if (with-current-buffer (get-buffer-create result-buffer)
11746 (and (= (count-lines (point-min) (point)) 1)
11749 (<= (current-column)
11750 (window-width (minibuffer-window)))))
11751 (goto-char (point-min))))
11752 (message "%s" (substring result 0 -1))
11754 (gnus-configure-windows 'pipe)))))
11756 (defun gnus-summary-save-article-mail (&optional arg)
11757 "Append the current article to a Unix mail box file.
11758 If N is a positive number, save the N next articles.
11759 If N is a negative number, save the N previous articles.
11760 If N is nil and any articles have been marked with the process mark,
11761 save those articles instead."
11763 (require 'gnus-art)
11764 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11765 (gnus-summary-save-article arg)))
11767 (defun gnus-summary-save-article-rmail (&optional arg)
11768 "Append the current article to an rmail file.
11769 If N is a positive number, save the N next articles.
11770 If N is a negative number, save the N previous articles.
11771 If N is nil and any articles have been marked with the process mark,
11772 save those articles instead."
11774 (require 'gnus-art)
11775 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11776 (gnus-summary-save-article arg)))
11778 (defun gnus-summary-save-article-file (&optional arg)
11779 "Append the current article to a file.
11780 If N is a positive number, save the N next articles.
11781 If N is a negative number, save the N previous articles.
11782 If N is nil and any articles have been marked with the process mark,
11783 save those articles instead."
11785 (require 'gnus-art)
11786 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11787 (gnus-summary-save-article arg)))
11789 (defun gnus-summary-write-article-file (&optional arg)
11790 "Write the current article to a file, deleting the previous file.
11791 If N is a positive number, save the N next articles.
11792 If N is a negative number, save the N previous articles.
11793 If N is nil and any articles have been marked with the process mark,
11794 save those articles instead."
11796 (require 'gnus-art)
11797 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11798 (gnus-summary-save-article arg)))
11800 (defun gnus-summary-save-article-body-file (&optional arg)
11801 "Append the current article body to a file.
11802 If N is a positive number, save the N next articles.
11803 If N is a negative number, save the N previous articles.
11804 If N is nil and any articles have been marked with the process mark,
11805 save those articles instead."
11807 (require 'gnus-art)
11808 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11809 (gnus-summary-save-article arg)))
11811 (defun gnus-summary-write-article-body-file (&optional arg)
11812 "Write the current article body to a file, deleting the previous file.
11813 If N is a positive number, save the N next articles.
11814 If N is a negative number, save the N previous articles.
11815 If N is nil and any articles have been marked with the process mark,
11816 save those articles instead."
11818 (require 'gnus-art)
11819 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11820 (gnus-summary-save-article arg)))
11822 (defun gnus-summary-muttprint (&optional arg)
11823 "Print the current article using Muttprint.
11824 If N is a positive number, save the N next articles.
11825 If N is a negative number, save the N previous articles.
11826 If N is nil and any articles have been marked with the process mark,
11827 save those articles instead."
11829 (require 'gnus-art)
11830 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11831 (gnus-summary-save-article arg t)))
11833 (defun gnus-summary-pipe-message (program)
11834 "Pipe the current article through PROGRAM."
11835 (interactive "sProgram: ")
11836 (gnus-summary-select-article)
11837 (let ((mail-header-separator ""))
11838 (gnus-eval-in-buffer-window gnus-article-buffer
11841 (let ((start (window-start))
11842 (inhibit-read-only t))
11843 (message-pipe-buffer-body program)
11844 (set-window-start (get-buffer-window (current-buffer)) start))))))
11846 (defun gnus-get-split-value (methods)
11847 "Return a value based on the split METHODS."
11848 (let (split-name method result match)
11850 (with-current-buffer gnus-original-article-buffer
11852 (nnheader-narrow-to-headers)
11853 (while (and methods (not split-name))
11854 (goto-char (point-min))
11855 (setq method (pop methods))
11856 (setq match (car method))
11859 ;; Regular expression.
11861 (re-search-forward match nil t)))
11866 (setq result (funcall match gnus-newsgroup-name))))
11871 (setq result (eval match)))))
11872 (setq split-name (cdr method))
11873 (cond ((stringp result)
11874 (push (expand-file-name
11875 result gnus-article-save-directory)
11878 (setq split-name (append result split-name)))))))))
11879 (nreverse split-name)))
11881 (defun gnus-valid-move-group-p (group)
11882 (and (boundp group)
11883 (symbol-name group)
11884 (symbol-value group)
11885 (gnus-get-function (gnus-find-method-for-group
11886 (symbol-name group)) 'request-accept-article t)))
11888 (defun gnus-read-move-group-name (prompt default articles prefix)
11889 "Read a group name."
11890 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11891 (minibuffer-confirm-incomplete nil) ; XEmacs
11895 (if (> (length articles) 1)
11896 (format "these %d articles" (length articles))
11899 (let (active group)
11900 (when (or (null split-name) (= 1 (length split-name)))
11901 (setq active (gnus-make-hashtable (length gnus-active-hashtb)))
11902 (mapatoms (lambda (symbol)
11903 (setq group (symbol-name symbol))
11904 (when (string-match "[^\000-\177]" group)
11905 (setq group (gnus-group-decoded-name group)))
11906 (set (intern group active) group))
11907 gnus-active-hashtb))
11910 (gnus-completing-read-with-default
11911 default prom active 'gnus-valid-move-group-p nil prefix
11912 'gnus-group-history))
11913 ((= 1 (length split-name))
11914 (gnus-completing-read-with-default
11915 (car split-name) prom active 'gnus-valid-move-group-p nil nil
11916 'gnus-group-history))
11918 (gnus-completing-read-with-default
11919 nil prom (mapcar 'list (nreverse split-name)) nil nil nil
11920 'gnus-group-history)))))
11921 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
11924 (if (or (string= to-newsgroup "")
11925 (string= to-newsgroup prefix))
11926 (setq to-newsgroup default))
11927 (unless to-newsgroup
11928 (error "No group name entered"))
11929 (setq encoded (mm-encode-coding-string
11931 (gnus-group-name-charset to-method to-newsgroup)))
11932 (or (gnus-active encoded)
11933 (gnus-activate-group encoded nil nil to-method)
11934 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11936 (or (and (gnus-request-create-group encoded to-method)
11937 (gnus-activate-group encoded nil nil to-method)
11938 (gnus-subscribe-group encoded))
11939 (error "Couldn't create group %s" to-newsgroup)))
11940 (error "No such group: %s" to-newsgroup))
11943 (defvar gnus-summary-save-parts-counter)
11944 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
11946 (defun gnus-summary-save-parts (type dir n &optional reverse)
11947 "Save parts matching TYPE to DIR.
11948 If REVERSE, save parts that do not match TYPE."
11950 (list (read-string "Save parts of type: "
11951 (or (car gnus-summary-save-parts-type-history)
11952 gnus-summary-save-parts-default-mime)
11953 'gnus-summary-save-parts-type-history)
11954 (setq gnus-summary-save-parts-last-directory
11955 (read-file-name "Save to directory: "
11956 gnus-summary-save-parts-last-directory
11958 current-prefix-arg))
11959 (gnus-summary-iterate n
11960 (let ((gnus-display-mime-function nil)
11961 gnus-article-prepare-hook
11962 gnus-article-decode-hook
11963 gnus-display-mime-function
11965 (gnus-inhibit-treatment t))
11966 (gnus-summary-select-article))
11967 (with-current-buffer gnus-article-buffer
11968 (let ((handles (or gnus-article-mime-handles
11969 (mm-dissect-buffer nil gnus-article-loose-mime)
11970 (and gnus-article-emulate-mime
11972 (gnus-summary-save-parts-counter 1))
11974 (gnus-summary-save-parts-1 type dir handles reverse)
11975 (unless gnus-article-mime-handles ;; Don't destroy this case.
11976 (mm-destroy-parts handles)))))))
11978 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11979 (if (stringp (car handle))
11980 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11983 (not (string-match type (mm-handle-media-type handle)))
11984 (string-match type (mm-handle-media-type handle)))
11985 (let ((file (expand-file-name
11987 mm-file-name-rewrite-functions
11988 (file-name-nondirectory
11990 (mail-content-type-get
11991 (mm-handle-disposition handle) 'filename)
11992 (mail-content-type-get
11993 (mm-handle-type handle) 'name)
11994 (format "%s.%d.%d" gnus-newsgroup-name
11995 (cdr gnus-article-current)
11996 gnus-summary-save-parts-counter))))
11998 (incf gnus-summary-save-parts-counter)
11999 (unless (file-exists-p file)
12000 (mm-save-part-to-file handle file))))))
12002 ;; Summary extract commands
12004 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12005 (let ((inhibit-read-only t)
12006 (article (gnus-summary-article-number))
12008 (unless (gnus-summary-goto-subject article)
12009 (error "No such article: %d" article))
12010 (gnus-summary-position-point)
12011 ;; If all commands are to be bunched up on one line, we collect
12013 (unless gnus-view-pseudos-separately
12014 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12017 (setq action (cdr (assq 'action (car ps))))
12018 (setq files (list (cdr (assq 'name (car ps)))))
12019 (while (and ps (cdr ps)
12020 (string= (or action "1")
12021 (or (cdr (assq 'action (cadr ps))) "2")))
12022 (push (cdr (assq 'name (cadr ps))) files)
12023 (setcdr ps (cddr ps)))
12025 (when (not (string-match "%s" action))
12028 (when (assq 'execute (car ps))
12029 (setcdr (assq 'execute (car ps))
12030 (funcall (if (string-match "%s" action)
12037 (shell-quote-argument f)))
12039 (setq ps (cdr ps)))))
12040 (if (and gnus-view-pseudos (not not-view))
12042 (when (assq 'execute (car pslist))
12043 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12044 (eq gnus-view-pseudos 'not-confirm)))
12045 (setq pslist (cdr pslist)))
12048 (setq after-article (or (cdr (assq 'article (car pslist)))
12049 (gnus-summary-article-number)))
12050 (gnus-summary-goto-subject after-article)
12053 (insert " " (file-name-nondirectory
12054 (cdr (assq 'name (car pslist))))
12055 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12057 (forward-line -1) ; back to `b'
12058 (gnus-add-text-properties
12059 b (1- e) (list 'gnus-number gnus-reffed-article-number
12060 gnus-mouse-face-prop gnus-mouse-face))
12062 after-article gnus-reffed-article-number
12063 gnus-unread-mark b (car pslist) 0 (- e b))
12064 (setq gnus-newsgroup-unreads
12065 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12066 gnus-reffed-article-number))
12067 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12068 (setq pslist (cdr pslist)))))))
12070 (defun gnus-pseudos< (p1 p2)
12071 (let ((c1 (cdr (assq 'action p1)))
12072 (c2 (cdr (assq 'action p2))))
12073 (and c1 c2 (string< c1 c2))))
12075 (defun gnus-request-pseudo-article (props)
12076 (cond ((assq 'execute props)
12077 (gnus-execute-command (cdr (assq 'execute props)))))
12078 (let ((gnus-current-article (gnus-summary-article-number)))
12079 (gnus-run-hooks 'gnus-mark-article-hook)))
12081 (defun gnus-execute-command (command &optional automatic)
12083 (gnus-article-setup-buffer)
12084 (set-buffer gnus-article-buffer)
12085 (setq buffer-read-only nil)
12086 (let ((command (if automatic command
12087 (read-string "Command: " (cons command 0)))))
12089 (insert "$ " command "\n\n")
12090 (if gnus-view-pseudo-asynchronously
12091 (start-process "gnus-execute" (current-buffer) shell-file-name
12092 shell-command-switch command)
12093 (call-process shell-file-name nil t nil
12094 shell-command-switch command)))))
12096 ;; Summary kill commands.
12098 (defun gnus-summary-edit-global-kill (article)
12099 "Edit the \"global\" kill file."
12100 (interactive (list (gnus-summary-article-number)))
12101 (gnus-group-edit-global-kill article))
12103 (defun gnus-summary-edit-local-kill ()
12104 "Edit a local kill file applied to the current newsgroup."
12106 (setq gnus-current-headers (gnus-summary-article-header))
12107 (gnus-group-edit-local-kill
12108 (gnus-summary-article-number) gnus-newsgroup-name))
12110 ;;; Header reading.
12112 (defun gnus-read-header (id &optional header)
12113 "Read the headers of article ID and enter them into the Gnus system."
12114 (let ((group gnus-newsgroup-name)
12115 (gnus-override-method
12117 gnus-override-method
12118 (and (gnus-news-group-p gnus-newsgroup-name)
12119 (car (gnus-refer-article-methods)))))
12121 ;; First we check to see whether the header in question is already
12124 ;; This is a Message-ID.
12125 (setq header (or header (gnus-id-to-header id)))
12126 ;; This is an article number.
12127 (setq header (or header (gnus-summary-article-header id))))
12129 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12130 ;; We have found the header.
12132 ;; We have to really fetch the header to this article.
12133 (with-current-buffer nntp-server-buffer
12134 (when (setq where (gnus-request-head id group))
12135 (nnheader-fold-continuation-lines)
12136 (goto-char (point-max))
12138 (goto-char (point-min))
12142 ((cdr where) (cdr where))
12143 (header (mail-header-number header))
12144 (t gnus-reffed-article-number))
12146 (insert " Article retrieved.\n"))
12147 (if (or (not where)
12148 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12149 () ; Malformed head.
12150 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12151 (when (and (stringp id)
12153 (not (string= (gnus-group-real-name group)
12155 (not (gnus-server-equal gnus-override-method
12156 (gnus-group-method group)))))
12157 ;; If we fetched by Message-ID and the article came from
12158 ;; a different group (or server), we fudge some bogus
12159 ;; article numbers for this article.
12160 (mail-header-set-number header gnus-reffed-article-number))
12161 (with-current-buffer gnus-summary-buffer
12162 (decf gnus-reffed-article-number)
12163 (gnus-remove-header (mail-header-number header))
12164 (push header gnus-newsgroup-headers)
12165 (setq gnus-current-headers header)
12166 (push (mail-header-number header) gnus-newsgroup-limit)))
12169 (defun gnus-remove-header (number)
12170 "Remove header NUMBER from `gnus-newsgroup-headers'."
12171 (if (and gnus-newsgroup-headers
12172 (= number (mail-header-number (car gnus-newsgroup-headers))))
12173 (pop gnus-newsgroup-headers)
12174 (let ((headers gnus-newsgroup-headers))
12175 (while (and (cdr headers)
12176 (not (= number (mail-header-number (cadr headers)))))
12178 (when (cdr headers)
12179 (setcdr headers (cddr headers))))))
12182 ;;; summary highlights
12185 (defun gnus-highlight-selected-summary ()
12186 "Highlight selected article in summary buffer."
12187 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12188 (when gnus-summary-selected-face
12190 (let* ((beg (point-at-bol))
12191 (end (point-at-eol))
12192 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12193 (from (if (get-text-property beg gnus-mouse-face-prop)
12195 (or (next-single-property-change
12196 beg gnus-mouse-face-prop nil end)
12201 (or (next-single-property-change
12202 from gnus-mouse-face-prop nil end)
12204 ;; If no mouse-face prop on line we will have to = from = end,
12205 ;; so we highlight the entire line instead.
12206 (when (= (+ to 2) from)
12209 (if gnus-newsgroup-selected-overlay
12210 ;; Move old overlay.
12212 gnus-newsgroup-selected-overlay from to (current-buffer))
12213 ;; Create new overlay.
12215 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12216 'face gnus-summary-selected-face))))))
12218 (defvar gnus-summary-highlight-line-cached nil)
12219 (defvar gnus-summary-highlight-line-trigger nil)
12221 (defun gnus-summary-highlight-line-0 ()
12222 (if (and (eq gnus-summary-highlight-line-trigger
12223 gnus-summary-highlight)
12224 gnus-summary-highlight-line-cached)
12225 gnus-summary-highlight-line-cached
12226 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12227 gnus-summary-highlight-line-cached
12228 (let* ((cond (list 'cond))
12230 (list gnus-summary-highlight))
12232 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12236 (gnus-byte-compile (list 'lambda nil cond))))))
12238 (defun gnus-summary-highlight-line ()
12239 "Highlight current line according to `gnus-summary-highlight'."
12240 (let* ((beg (point-at-bol))
12241 (article (or (gnus-summary-article-number) gnus-current-article))
12242 (score (or (cdr (assq article
12243 gnus-newsgroup-scored))
12244 gnus-summary-default-score 0))
12245 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12246 (inhibit-read-only t)
12247 (default gnus-summary-default-score)
12248 (default-high gnus-summary-default-high-score)
12249 (default-low gnus-summary-default-low-score)
12250 (uncached (and gnus-summary-use-undownloaded-faces
12251 (memq article gnus-newsgroup-undownloaded)
12252 (not (memq article gnus-newsgroup-cached)))))
12253 (let ((face (funcall (gnus-summary-highlight-line-0))))
12254 (unless (eq face (get-text-property beg 'face))
12255 (gnus-put-text-property-excluding-characters-with-faces
12256 beg (point-at-eol) 'face
12257 (setq face (if (boundp face) (symbol-value face) face)))
12258 (when gnus-summary-highlight-line-function
12259 (funcall gnus-summary-highlight-line-function article face))))))
12261 (defun gnus-update-read-articles (group unread &optional compute)
12262 "Update the list of read articles in GROUP.
12263 UNREAD is a sorted list."
12264 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12265 (info (gnus-get-info group))
12268 (if (or (not info) (not active))
12269 ;; There is no info on this group if it was, in fact,
12270 ;; killed. Gnus stores no information on killed groups, so
12271 ;; there's nothing to be done.
12272 ;; One could store the information somewhere temporarily,
12273 ;; perhaps... Hmmm...
12275 ;; Remove any negative articles numbers.
12276 (while (and unread (< (car unread) 0))
12277 (setq unread (cdr unread)))
12278 ;; Remove any expired article numbers
12279 (while (and unread (< (car unread) (car active)))
12280 (setq unread (cdr unread)))
12281 ;; Compute the ranges of read articles by looking at the list of
12282 ;; unread articles.
12284 (when (/= (car unread) prev)
12285 (push (if (= prev (1- (car unread))) prev
12286 (cons prev (1- (car unread))))
12288 (setq prev (1+ (car unread)))
12289 (setq unread (cdr unread)))
12290 (when (<= prev (cdr active))
12291 (push (cons prev (cdr active)) read))
12292 (setq read (if (> (length read) 1) (nreverse read) read))
12297 ;; Propagate the read marks to the backend.
12298 (when (and gnus-propagate-marks
12299 (gnus-check-backend-function 'request-set-mark group))
12300 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12301 (add (gnus-remove-from-range read (gnus-info-read info))))
12303 (unless (gnus-check-group group)
12304 (error "Can't open server for %s" group))
12305 (gnus-request-set-mark
12306 group (delq nil (list (if add (list add 'add '(read)))
12307 (if del (list del 'del '(read))))))
12309 `(gnus-request-set-mark
12312 (if del (list del 'add '(read)))
12313 (if add (list add 'del '(read))))))))))
12314 (set-buffer gnus-group-buffer)
12315 (gnus-undo-register
12317 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12318 (gnus-info-set-read ',info ',(gnus-info-read info))
12319 (gnus-get-unread-articles-in-group ',info
12320 (gnus-active ,group))
12321 (gnus-group-update-group ,group t)
12323 ;; Enter this list into the group info.
12324 (gnus-info-set-read info read)
12325 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12326 (gnus-get-unread-articles-in-group info (gnus-active group))
12329 (defun gnus-offer-save-summaries ()
12330 "Offer to save all active summary buffers."
12332 ;; Go through all buffers and find all summaries.
12333 (dolist (buffer (buffer-list))
12334 (when (and (setq buffer (buffer-name buffer))
12335 (string-match "Summary" buffer)
12336 (with-current-buffer buffer
12337 ;; We check that this is, indeed, a summary buffer.
12338 (and (eq major-mode 'gnus-summary-mode)
12339 ;; Also make sure this isn't bogus.
12340 gnus-newsgroup-prepared
12341 ;; Also make sure that this isn't a
12342 ;; dead summary buffer.
12343 (not gnus-dead-summary-mode))))
12344 (push buffer buffers)))
12345 ;; Go through all these summary buffers and offer to save them.
12349 "Update summary buffer %s? "
12351 (switch-to-buffer buf)
12352 (gnus-summary-exit))
12355 (defun gnus-summary-setup-default-charset ()
12356 "Setup newsgroup default charset."
12357 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12358 (setq gnus-newsgroup-charset nil)
12359 (let* ((ignored-charsets
12360 (or gnus-newsgroup-ephemeral-ignored-charsets
12362 (and gnus-newsgroup-name
12363 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12364 gnus-newsgroup-ignored-charsets))))
12365 (setq gnus-newsgroup-charset
12366 (or gnus-newsgroup-ephemeral-charset
12367 (and gnus-newsgroup-name
12368 (gnus-parameter-charset gnus-newsgroup-name))
12369 gnus-default-charset))
12370 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12371 ignored-charsets))))
12377 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12378 "Display the current article buffer fully MIME-buttonized.
12379 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12380 treated as multipart/mixed."
12382 (require 'gnus-art)
12383 (let ((gnus-unbuttonized-mime-types nil)
12384 (gnus-mime-display-multipart-as-mixed show-all-parts))
12385 (gnus-summary-show-article)))
12387 (defun gnus-summary-repair-multipart (article)
12388 "Add a Content-Type header to a multipart article without one."
12389 (interactive (list (gnus-summary-article-number)))
12390 (gnus-with-article article
12391 (message-narrow-to-head)
12392 (message-remove-header "Mime-Version")
12393 (goto-char (point-max))
12394 (insert "Mime-Version: 1.0\n")
12396 (when (search-forward "\n--" nil t)
12397 (let ((separator (buffer-substring (point) (point-at-eol))))
12398 (message-narrow-to-head)
12399 (message-remove-header "Content-Type")
12400 (goto-char (point-max))
12401 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12404 (let (gnus-mark-article-hook)
12405 (gnus-summary-select-article t t nil article)))
12407 (defun gnus-summary-toggle-display-buttonized ()
12408 "Toggle the buttonizing of the article buffer."
12410 (require 'gnus-art)
12411 (if (setq gnus-inhibit-mime-unbuttonizing
12412 (not gnus-inhibit-mime-unbuttonizing))
12413 (let ((gnus-unbuttonized-mime-types nil))
12414 (gnus-summary-show-article))
12415 (gnus-summary-show-article)))
12418 ;;; Generic summary marking commands
12421 (defvar gnus-summary-marking-alist
12422 '((read gnus-del-mark "d")
12423 (unread gnus-unread-mark "u")
12424 (ticked gnus-ticked-mark "!")
12425 (dormant gnus-dormant-mark "?")
12426 (expirable gnus-expirable-mark "e"))
12427 "An alist of names/marks/keystrokes.")
12429 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12430 (defvar gnus-summary-mark-map)
12432 (defun gnus-summary-make-all-marking-commands ()
12433 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12434 (dolist (elem gnus-summary-marking-alist)
12435 (apply 'gnus-summary-make-marking-command elem)))
12437 (defun gnus-summary-make-marking-command (name mark keystroke)
12438 (let ((map (make-sparse-keymap)))
12439 (define-key gnus-summary-generic-mark-map keystroke map)
12440 (dolist (lway `((next "next" next nil "n")
12441 (next-unread "next unread" next t "N")
12442 (prev "previous" prev nil "p")
12443 (prev-unread "previous unread" prev t "P")
12444 (nomove "" nil nil ,keystroke)))
12445 (let ((func (gnus-summary-make-marking-command-1
12446 mark (car lway) lway name)))
12447 (setq func (eval func))
12448 (define-key map (nth 4 lway) func)))))
12450 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12452 (format "gnus-summary-put-mark-as-%s%s"
12453 name (if (eq way 'nomove)
12455 (concat "-" (symbol-name way)))))
12458 "Mark the current article as %s%s.
12459 If N, the prefix, then repeat N times.
12460 If N is negative, move in reverse order.
12461 The difference between N and the actual number of articles marked is
12465 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12467 (defun gnus-summary-generic-mark (n mark move unread)
12468 "Mark N articles with MARK."
12469 (unless (eq major-mode 'gnus-summary-mode)
12470 (error "This command can only be used in the summary buffer"))
12471 (gnus-summary-show-thread)
12474 ((eq move 'next) 1)
12475 ((eq move 'prev) -1)
12477 (if (zerop nummove)
12481 nummove (* -1 nummove))))
12482 (while (and (> n 0)
12483 (gnus-summary-mark-article nil mark)
12484 (zerop (gnus-summary-next-subject nummove unread t)))
12487 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12488 (gnus-summary-recenter)
12489 (gnus-summary-position-point)
12490 (gnus-set-mode-line 'summary)
12493 (defun gnus-summary-insert-articles (articles)
12494 (when (setq articles
12495 (gnus-sorted-difference articles
12496 (mapcar (lambda (h)
12497 (mail-header-number h))
12498 gnus-newsgroup-headers)))
12499 (setq gnus-newsgroup-headers
12501 gnus-newsgroup-headers
12502 (gnus-fetch-headers articles)
12503 'gnus-article-sort-by-number))
12504 ;; Suppress duplicates?
12505 (when gnus-suppress-duplicates
12506 (gnus-dup-suppress-articles))
12508 (if (and gnus-fetch-old-headers
12509 (eq gnus-headers-retrieved-by 'nov))
12510 ;; We might want to build some more threads first.
12511 (if (eq gnus-fetch-old-headers 'invisible)
12512 (gnus-build-all-threads)
12513 (gnus-build-old-threads))
12514 ;; Mark the inserted articles that are unread as unread.
12515 (setq gnus-newsgroup-unreads
12516 (gnus-sorted-nunion
12517 gnus-newsgroup-unreads
12518 (gnus-sorted-nintersection
12519 (gnus-list-of-unread-articles gnus-newsgroup-name)
12521 ;; Mark the inserted articles as selected so that the information
12522 ;; of the marks having been changed by a user may be updated when
12523 ;; exiting this group. See `gnus-summary-update-info'.
12524 (dolist (art articles)
12525 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12526 ;; Let the Gnus agent mark articles as read.
12528 (gnus-agent-get-undownloaded-list))
12529 ;; Remove list identifiers from subject
12530 (when gnus-list-identifiers
12531 (gnus-summary-remove-list-identifiers))
12532 ;; First and last article in this newsgroup.
12533 (when gnus-newsgroup-headers
12534 (setq gnus-newsgroup-begin
12535 (mail-header-number (car gnus-newsgroup-headers))
12537 (mail-header-number
12538 (gnus-last-element gnus-newsgroup-headers))))
12539 (when gnus-use-scoring
12540 (gnus-possibly-score-headers))))
12542 (defun gnus-summary-insert-old-articles (&optional all)
12543 "Insert all old articles in this group.
12544 If ALL is non-nil, already read articles become readable.
12545 If ALL is a number, fetch this number of articles."
12548 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12551 ;; Some nntp servers lie about their active range. When
12552 ;; this happens, the active range can be in the millions.
12553 ;; Use a compressed range to avoid creating a huge list.
12554 (gnus-range-difference (list gnus-newsgroup-active) old))
12555 (setq len (gnus-range-length older))
12560 (let ((older-range (nreverse older)))
12564 (let* ((r (pop older-range))
12565 (min (if (numberp r) r (car r)))
12566 (max (if (numberp r) r (cdr r))))
12567 (while (and (<= min max)
12572 (setq older (gnus-uncompress-range older))))
12574 (setq older (gnus-uncompress-range older)))
12576 (when (and (numberp gnus-large-newsgroup)
12577 (> len gnus-large-newsgroup))
12578 (let* ((cursor-in-echo-area nil)
12579 (initial (gnus-parameter-large-newsgroup-initial
12580 gnus-newsgroup-name))
12584 "How many articles from %s (%s %d): "
12585 (gnus-group-decoded-name gnus-newsgroup-name)
12586 (if initial "max" "default")
12589 (cons (number-to-string initial)
12591 (unless (string-match "^[ \t]*$" input)
12592 (setq all (string-to-number input))
12594 (let ((older-range (nreverse older)))
12598 (let* ((r (pop older-range))
12599 (min (if (numberp r) r (car r)))
12600 (max (if (numberp r) r (cdr r))))
12601 (while (and (<= min max)
12605 max (1- max))))))))))
12606 (setq older (gnus-uncompress-range older))))
12608 (message "No old news.")
12609 (gnus-summary-insert-articles older)
12610 (gnus-summary-limit (gnus-sorted-nunion old older))))
12611 (gnus-summary-position-point)))
12613 (defun gnus-summary-insert-new-articles ()
12614 "Insert all new articles in this group."
12617 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12618 (old-active gnus-newsgroup-active)
12619 (nnmail-fetched-sources (list t))
12621 (setq gnus-newsgroup-active
12622 (gnus-activate-group gnus-newsgroup-name 'scan))
12623 (setq i (cdr gnus-newsgroup-active))
12624 (while (> i (cdr old-active))
12628 (message "No gnus is bad news")
12629 (gnus-summary-insert-articles new)
12630 (setq gnus-newsgroup-unreads
12631 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12632 (gnus-summary-limit (gnus-sorted-nunion old new))))
12633 (gnus-summary-position-point)))
12635 ;;; Bookmark support for Gnus.
12636 (declare-function bookmark-make-record-default
12637 "bookmark" (&optional no-file no-context posn))
12638 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12639 (declare-function bookmark-default-handler "bookmark" (bmk))
12640 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12641 (defvar bookmark-yank-point)
12642 (defvar bookmark-current-buffer)
12644 (defun gnus-summary-bookmark-make-record ()
12645 "Make a bookmark entry for a Gnus summary buffer."
12647 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12648 (save-restriction ; FIXME is it necessary to widen?
12649 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12650 (setq buf "art") ; We are recording bookmark from article buffer.
12651 (setq bookmark-yank-point (point))
12652 (setq bookmark-current-buffer (current-buffer))
12653 (gnus-article-show-summary)) ; Go back in summary buffer.
12654 ;; We are now recording bookmark from summary buffer.
12655 (unless buf (setq buf "sum"))
12656 (let* ((subject (elt (gnus-summary-article-header) 1))
12657 (grp (car gnus-article-current))
12658 (art (cdr gnus-article-current))
12659 (head (gnus-summary-article-header art))
12660 (id (mail-header-id head)))
12662 ,@(condition-case nil
12663 (bookmark-make-record-default 'no-file 'no-context pos)
12664 (wrong-number-of-arguments
12665 (bookmark-make-record-default 'point-only)))
12666 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12667 (group . ,grp) (article . ,art)
12668 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12671 (defun gnus-summary-bookmark-jump (bookmark)
12672 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12673 BOOKMARK is a bookmark name or a bookmark record."
12674 (let ((group (bookmark-prop-get bookmark 'group))
12675 (article (bookmark-prop-get bookmark 'article))
12676 (id (bookmark-prop-get bookmark 'message-id))
12677 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12678 (gnus-fetch-group group (list article))
12679 (gnus-summary-insert-cached-articles)
12680 (gnus-summary-goto-article id nil 'force)
12681 ;; FIXME we have to wait article buffer is ready (only large buffer)
12682 ;; Is there a better solution to know that?
12683 ;; If we don't wait `bookmark-default-handler' will have no chance
12684 ;; to set position. However there is no error, just wrong pos.
12686 (when (string= buf "Gnus-art")
12688 (bookmark-default-handler
12690 (buffer . ,(current-buffer))
12691 . ,(bookmark-get-bookmark-record bookmark)))))
12693 (gnus-summary-make-all-marking-commands)
12695 (gnus-ems-redefine)
12697 (provide 'gnus-sum)
12699 (run-hooks 'gnus-sum-load-hook)
12701 ;; Local Variables:
12702 ;; coding: iso-8859-1
12705 ;;; gnus-sum.el ends here