Support transparency for ImageMagick images.
[emacs.git] / lisp / gnus / gnus-sum.el
blob7f095e15496870509678640c86e4270c49ae0624
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 ;; For Emacs <22.2 and XEmacs.
28 (eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30 (eval-when-compile
31 (require 'cl))
32 (eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
39 (require 'gnus)
40 (require 'gnus-group)
41 (require 'gnus-spec)
42 (require 'gnus-range)
43 (require 'gnus-int)
44 (require 'gnus-undo)
45 (require 'gnus-util)
46 (require 'gmm-utils)
47 (require 'mm-decode)
48 (require 'nnoo)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
78 :type 'boolean)
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
84 :version "24.1"
85 :type 'boolean)
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
108 (const :tag "on" t)
109 (const some)
110 (const invisible)
111 number
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
124 current group."
125 :version "24.1"
126 :group 'gnus-thread
127 :type 'boolean)
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
140 `dummy' or `empty'.
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
151 :group 'gnus-thread
152 :type '(choice (const :tag "off" nil)
153 (const none)
154 (const dummy)
155 (const adopt)
156 (const empty)))
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
160 :version "22.1"
161 :group 'gnus-thread
162 :type 'boolean)
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
169 :group 'gnus-thread
170 :type 'regexp)
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
181 comparing subjects."
182 :group 'gnus-thread
183 :type '(choice (const :tag "off" nil)
184 (const fuzzy)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
194 :group 'gnus-thread
195 :type '(repeat function))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 regexp))
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
208 :group 'gnus-thread
209 :type '(choice (const :tag "off" nil)
210 (const some)
211 (const more)
212 (sexp :menu-tag "all" t)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
221 :group 'gnus-thread
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
231 :type 'string)
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
243 :version "24.1"
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
247 (const never)
248 (sexp :menu-tag "on" t)))
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
256 integer))
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
261 than this score."
262 :version "22.1"
263 :group 'gnus-score-default
264 :type 'integer)
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
269 than this score."
270 :version "22.1"
271 :group 'gnus-score-default
272 :type 'integer)
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
277 will not be marked."
278 :group 'gnus-summary-format
279 :type 'integer)
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
286 :group 'gnus-thread
287 :type '(repeat regexp))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
291 :group 'gnus-thread
292 :type 'boolean)
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
299 :group 'gnus-thread
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
303 :value t)
304 (const nil)
305 (sexp :tag "Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
309 :group 'gnus-thread
310 :type 'boolean)
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
316 :group 'gnus-thread
317 :type 'boolean)
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
328 :group 'gnus-thread
329 :type '(choice (const :tag "off" nil)
330 (const fuzzy)
331 (sexp :tag "on" t)))
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
335 :group 'gnus-thread
336 :type 'integer)
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
341 :type 'boolean)
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
373 :version "24.1"
374 :group 'gnus-group-select
375 :type '(choice (const best)
376 (const unread)
377 (const first)
378 (const unseen)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
395 (const quietly)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
405 :type 'boolean)
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
411 `next'
412 Select the next article.
413 `next-unread'
414 Select the next unread article.
415 `next-noselect'
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
440 :version "22.1"
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
452 :type 'boolean)
454 (defcustom gnus-auto-center-summary 2
455 "*If non-nil, always center the current summary buffer.
456 In particular, if `vertical' do only vertical recentering. If non-nil
457 and non-`vertical', do both horizontal and vertical recentering."
458 :group 'gnus-summary-maneuvering
459 :type '(choice (const :tag "none" nil)
460 (const vertical)
461 (integer :tag "height")
462 (sexp :menu-tag "both" t)))
464 (defcustom gnus-auto-center-group t
465 "If non-nil, always center the group buffer."
466 :group 'gnus-summary-maneuvering
467 :type 'boolean)
469 (defcustom gnus-show-all-headers nil
470 "*If non-nil, don't hide any headers."
471 :group 'gnus-article-hiding
472 :group 'gnus-article-headers
473 :type 'boolean)
475 (defcustom gnus-summary-ignore-duplicates nil
476 "*If non-nil, ignore articles with identical Message-ID headers."
477 :group 'gnus-summary
478 :type 'boolean)
480 (defcustom gnus-single-article-buffer nil
481 "*If non-nil, display all articles in the same buffer.
482 If nil, each group will get its own article buffer."
483 :version "24.1"
484 :group 'gnus-article-various
485 :type 'boolean)
487 (defcustom gnus-widen-article-window nil
488 "If non-nil, selecting the article buffer will display only the article buffer."
489 :version "24.1"
490 :group 'gnus-article-various
491 :type 'boolean)
493 (defcustom gnus-break-pages t
494 "*If non-nil, do page breaking on articles.
495 The page delimiter is specified by the `gnus-page-delimiter'
496 variable."
497 :group 'gnus-article-various
498 :type 'boolean)
500 (defcustom gnus-move-split-methods nil
501 "*Variable used to suggest where articles are to be moved to.
502 It uses the same syntax as the `gnus-split-methods' variable.
503 However, whereas `gnus-split-methods' specifies file names as targets,
504 this variable specifies group names."
505 :group 'gnus-summary-mail
506 :type '(repeat (choice (list :value (fun) function)
507 (cons :value ("" "") regexp (repeat string))
508 (sexp :value nil))))
510 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
511 "Function used to compute default prefix for article move/copy/etc prompts.
512 The function should take one argument, a group name, and return a
513 string with the suggested prefix."
514 :group 'gnus-summary-mail
515 :type 'function)
517 ;; FIXME: Although the custom type is `character' for the following variables,
518 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
520 (defcustom gnus-unread-mark ? ;Whitespace
521 "*Mark used for unread articles."
522 :group 'gnus-summary-marks
523 :type 'character)
525 (defcustom gnus-ticked-mark ?!
526 "*Mark used for ticked articles."
527 :group 'gnus-summary-marks
528 :type 'character)
530 (defcustom gnus-dormant-mark ??
531 "*Mark used for dormant articles."
532 :group 'gnus-summary-marks
533 :type 'character)
535 (defcustom gnus-del-mark ?r
536 "*Mark used for del'd articles."
537 :group 'gnus-summary-marks
538 :type 'character)
540 (defcustom gnus-read-mark ?R
541 "*Mark used for read articles."
542 :group 'gnus-summary-marks
543 :type 'character)
545 (defcustom gnus-expirable-mark ?E
546 "*Mark used for expirable articles."
547 :group 'gnus-summary-marks
548 :type 'character)
550 (defcustom gnus-killed-mark ?K
551 "*Mark used for killed articles."
552 :group 'gnus-summary-marks
553 :type 'character)
555 (defcustom gnus-spam-mark ?$
556 "*Mark used for spam articles."
557 :version "22.1"
558 :group 'gnus-summary-marks
559 :type 'character)
561 (defcustom gnus-kill-file-mark ?X
562 "*Mark used for articles killed by kill files."
563 :group 'gnus-summary-marks
564 :type 'character)
566 (defcustom gnus-low-score-mark ?Y
567 "*Mark used for articles with a low score."
568 :group 'gnus-summary-marks
569 :type 'character)
571 (defcustom gnus-catchup-mark ?C
572 "*Mark used for articles that are caught up."
573 :group 'gnus-summary-marks
574 :type 'character)
576 (defcustom gnus-replied-mark ?A
577 "*Mark used for articles that have been replied to."
578 :group 'gnus-summary-marks
579 :type 'character)
581 (defcustom gnus-forwarded-mark ?F
582 "*Mark used for articles that have been forwarded."
583 :version "22.1"
584 :group 'gnus-summary-marks
585 :type 'character)
587 (defcustom gnus-recent-mark ?N
588 "*Mark used for articles that are recent."
589 :version "22.1"
590 :group 'gnus-summary-marks
591 :type 'character)
593 (defcustom gnus-cached-mark ?*
594 "*Mark used for articles that are in the cache."
595 :group 'gnus-summary-marks
596 :type 'character)
598 (defcustom gnus-saved-mark ?S
599 "*Mark used for articles that have been saved."
600 :group 'gnus-summary-marks
601 :type 'character)
603 (defcustom gnus-unseen-mark ?.
604 "*Mark used for articles that haven't been seen."
605 :version "22.1"
606 :group 'gnus-summary-marks
607 :type 'character)
609 (defcustom gnus-no-mark ? ;Whitespace
610 "*Mark used for articles that have no other secondary mark."
611 :version "22.1"
612 :group 'gnus-summary-marks
613 :type 'character)
615 (defcustom gnus-ancient-mark ?O
616 "*Mark used for ancient articles."
617 :group 'gnus-summary-marks
618 :type 'character)
620 (defcustom gnus-sparse-mark ?Q
621 "*Mark used for sparsely reffed articles."
622 :group 'gnus-summary-marks
623 :type 'character)
625 (defcustom gnus-canceled-mark ?G
626 "*Mark used for canceled articles."
627 :group 'gnus-summary-marks
628 :type 'character)
630 (defcustom gnus-duplicate-mark ?M
631 "*Mark used for duplicate articles."
632 :group 'gnus-summary-marks
633 :type 'character)
635 (defcustom gnus-undownloaded-mark ?-
636 "*Mark used for articles that weren't downloaded."
637 :version "22.1"
638 :group 'gnus-summary-marks
639 :type 'character)
641 (defcustom gnus-downloaded-mark ?+
642 "*Mark used for articles that were downloaded."
643 :group 'gnus-summary-marks
644 :type 'character)
646 (defcustom gnus-downloadable-mark ?%
647 "*Mark used for articles that are to be downloaded."
648 :group 'gnus-summary-marks
649 :type 'character)
651 (defcustom gnus-unsendable-mark ?=
652 "*Mark used for articles that won't be sent."
653 :group 'gnus-summary-marks
654 :type 'character)
656 (defcustom gnus-score-over-mark ?+
657 "*Score mark used for articles with high scores."
658 :group 'gnus-summary-marks
659 :type 'character)
661 (defcustom gnus-score-below-mark ?-
662 "*Score mark used for articles with low scores."
663 :group 'gnus-summary-marks
664 :type 'character)
666 (defcustom gnus-empty-thread-mark ? ;Whitespace
667 "*There is no thread under the article."
668 :group 'gnus-summary-marks
669 :type 'character)
671 (defcustom gnus-not-empty-thread-mark ?=
672 "*There is a thread under the article."
673 :group 'gnus-summary-marks
674 :type 'character)
676 (defcustom gnus-view-pseudo-asynchronously nil
677 "*If non-nil, Gnus will view pseudo-articles asynchronously."
678 :group 'gnus-extract-view
679 :type 'boolean)
681 (defcustom gnus-auto-expirable-marks
682 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
683 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
684 gnus-duplicate-mark)
685 "*The list of marks converted into expiration if a group is auto-expirable."
686 :version "24.1"
687 :group 'gnus-summary
688 :type '(repeat character))
690 (defcustom gnus-inhibit-user-auto-expire t
691 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
692 :version "21.1"
693 :group 'gnus-summary
694 :type 'boolean)
696 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
697 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
698 If nil, the expirable marks will be unchanged except that the marks
699 will be removed when copying or moving articles to a group that has
700 not turned auto-expire on. If non-nil, articles that have been read
701 will be marked as expirable when being copied or moved to a group in
702 which auto-expire is turned on."
703 :version "23.2"
704 :type 'boolean
705 :group 'gnus-summary-marks)
707 (defcustom gnus-view-pseudos nil
708 "*If `automatic', pseudo-articles will be viewed automatically.
709 If `not-confirm', pseudos will be viewed automatically, and the user
710 will not be asked to confirm the command."
711 :group 'gnus-extract-view
712 :type '(choice (const :tag "off" nil)
713 (const automatic)
714 (const not-confirm)))
716 (defcustom gnus-view-pseudos-separately t
717 "*If non-nil, one pseudo-article will be created for each file to be viewed.
718 If nil, all files that use the same viewing command will be given as a
719 list of parameters to that command."
720 :group 'gnus-extract-view
721 :type 'boolean)
723 (defcustom gnus-insert-pseudo-articles t
724 "*If non-nil, insert pseudo-articles when decoding articles."
725 :group 'gnus-extract-view
726 :type 'boolean)
728 (defcustom gnus-summary-dummy-line-format
729 " %(: :%) %S\n"
730 "*The format specification for the dummy roots in the summary buffer.
731 It works along the same lines as a normal formatting string,
732 with some simple extensions.
734 %S The subject
736 General format specifiers can also be used.
737 See `(gnus)Formatting Variables'."
738 :link '(custom-manual "(gnus)Formatting Variables")
739 :group 'gnus-threading
740 :type 'string)
742 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
743 "*The format specification for the summary mode line.
744 It works along the same lines as a normal formatting string,
745 with some simple extensions:
747 %G Group name
748 %p Unprefixed group name
749 %A Current article number
750 %z Current article score
751 %V Gnus version
752 %U Number of unread articles in the group
753 %e Number of unselected articles in the group
754 %Z A string with unread/unselected article counts
755 %g Shortish group name
756 %S Subject of the current article
757 %u User-defined spec
758 %s Current score file name
759 %d Number of dormant articles
760 %r Number of articles that have been marked as read in this session
761 %E Number of articles expunged by the score files"
762 :group 'gnus-summary-format
763 :type 'string)
765 (defcustom gnus-list-identifiers nil
766 "Regexp that matches list identifiers to be removed from subject.
767 This can also be a list of regexps."
768 :version "21.1"
769 :group 'gnus-summary-format
770 :group 'gnus-article-hiding
771 :type '(choice (const :tag "none" nil)
772 (regexp :value ".*")
773 (repeat :value (".*") regexp)))
775 (defcustom gnus-summary-mark-below 0
776 "*Mark all articles with a score below this variable as read.
777 This variable is local to each summary buffer and usually set by the
778 score file."
779 :group 'gnus-score-default
780 :type 'integer)
782 (defun gnus-widget-reversible-match (widget value)
783 "Ignoring WIDGET, convert VALUE to internal form.
784 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
785 ;; (debug value)
786 (or (symbolp value)
787 (and (listp value)
788 (eq (length value) 2)
789 (eq (nth 0 value) 'not)
790 (symbolp (nth 1 value)))))
792 (defun gnus-widget-reversible-to-internal (widget value)
793 "Ignoring WIDGET, convert VALUE to internal form.
794 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
795 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
796 ;; (debug value)
797 (if (atom value)
798 (list value nil)
799 (list (nth 1 value) t)))
801 (defun gnus-widget-reversible-to-external (widget value)
802 "Ignoring WIDGET, convert VALUE to external form.
803 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
804 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
805 ;; (debug value)
806 (if (nth 1 value)
807 (list 'not (nth 0 value))
808 (nth 0 value)))
810 (define-widget 'gnus-widget-reversible 'group
811 "A `group' that convert values."
812 :match 'gnus-widget-reversible-match
813 :value-to-internal 'gnus-widget-reversible-to-internal
814 :value-to-external 'gnus-widget-reversible-to-external)
816 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
817 "*List of functions used for sorting articles in the summary buffer.
819 Each function takes two articles and returns non-nil if the first
820 article should be sorted before the other. If you use more than one
821 function, the primary sort function should be the last. You should
822 probably always include `gnus-article-sort-by-number' in the list of
823 sorting functions -- preferably first. Also note that sorting by date
824 is often much slower than sorting by number, and the sorting order is
825 very similar. (Sorting by date means sorting by the time the message
826 was sent, sorting by number means sorting by arrival time.)
828 Each item can also be a list `(not F)' where F is a function;
829 this reverses the sort order.
831 Ready-made functions include `gnus-article-sort-by-number',
832 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
833 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
834 and `gnus-article-sort-by-score'.
836 When threading is turned on, the variable `gnus-thread-sort-functions'
837 controls how articles are sorted."
838 :group 'gnus-summary-sort
839 :type '(repeat (gnus-widget-reversible
840 (choice (function-item gnus-article-sort-by-number)
841 (function-item gnus-article-sort-by-author)
842 (function-item gnus-article-sort-by-subject)
843 (function-item gnus-article-sort-by-date)
844 (function-item gnus-article-sort-by-score)
845 (function-item gnus-article-sort-by-random)
846 (function :tag "other"))
847 (boolean :tag "Reverse order"))))
850 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
851 "*List of functions used for sorting threads in the summary buffer.
852 By default, threads are sorted by article number.
854 Each function takes two threads and returns non-nil if the first
855 thread should be sorted before the other. If you use more than one
856 function, the primary sort function should be the last. You should
857 probably always include `gnus-thread-sort-by-number' in the list of
858 sorting functions -- preferably first. Also note that sorting by date
859 is often much slower than sorting by number, and the sorting order is
860 very similar. (Sorting by date means sorting by the time the message
861 was sent, sorting by number means sorting by arrival time.)
863 Each list item can also be a list `(not F)' where F is a
864 function; this specifies reversed sort order.
866 Ready-made functions include `gnus-thread-sort-by-number',
867 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
868 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
869 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
870 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
871 and `gnus-thread-sort-by-total-score' (see
872 `gnus-thread-score-function').
874 When threading is turned off, the variable
875 `gnus-article-sort-functions' controls how articles are sorted."
876 :group 'gnus-summary-sort
877 :type '(repeat
878 (gnus-widget-reversible
879 (choice (function-item gnus-thread-sort-by-number)
880 (function-item gnus-thread-sort-by-author)
881 (function-item gnus-thread-sort-by-recipient)
882 (function-item gnus-thread-sort-by-subject)
883 (function-item gnus-thread-sort-by-date)
884 (function-item gnus-thread-sort-by-score)
885 (function-item gnus-thread-sort-by-most-recent-number)
886 (function-item gnus-thread-sort-by-most-recent-date)
887 (function-item gnus-thread-sort-by-random)
888 (function-item gnus-thread-sort-by-total-score)
889 (function :tag "other"))
890 (boolean :tag "Reverse order"))))
892 (defcustom gnus-thread-score-function '+
893 "*Function used for calculating the total score of a thread.
895 The function is called with the scores of the article and each
896 subthread and should then return the score of the thread.
898 Some functions you can use are `+', `max', or `min'."
899 :group 'gnus-summary-sort
900 :type 'function)
902 (defcustom gnus-summary-expunge-below nil
903 "All articles that have a score less than this variable will be expunged.
904 This variable is local to the summary buffers."
905 :group 'gnus-score-default
906 :type '(choice (const :tag "off" nil)
907 integer))
909 (defcustom gnus-thread-expunge-below nil
910 "All threads that have a total score less than this variable will be expunged.
911 See `gnus-thread-score-function' for en explanation of what a
912 \"thread score\" is.
914 This variable is local to the summary buffers."
915 :group 'gnus-threading
916 :group 'gnus-score-default
917 :type '(choice (const :tag "off" nil)
918 integer))
920 (defcustom gnus-summary-mode-hook nil
921 "*A hook for Gnus summary mode.
922 This hook is run before any variables are set in the summary buffer."
923 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
924 :group 'gnus-summary-various
925 :type 'hook)
927 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
928 (when (featurep 'xemacs)
929 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
930 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
931 (add-hook 'gnus-summary-mode-hook
932 'gnus-xmas-switch-horizontal-scrollbar-off))
934 (defcustom gnus-summary-menu-hook nil
935 "*Hook run after the creation of the summary mode menu."
936 :group 'gnus-summary-visual
937 :type 'hook)
939 (defcustom gnus-summary-exit-hook nil
940 "*A hook called on exit from the summary buffer.
941 It will be called with point in the group buffer."
942 :group 'gnus-summary-exit
943 :type 'hook)
945 (defcustom gnus-summary-prepare-hook nil
946 "*A hook called after the summary buffer has been generated.
947 If you want to modify the summary buffer, you can use this hook."
948 :group 'gnus-summary-various
949 :type 'hook)
951 (defcustom gnus-summary-prepared-hook nil
952 "*A hook called as the last thing after the summary buffer has been generated."
953 :group 'gnus-summary-various
954 :type 'hook)
956 (defcustom gnus-summary-generate-hook nil
957 "*A hook run just before generating the summary buffer.
958 This hook is commonly used to customize threading variables and the
959 like."
960 :group 'gnus-summary-various
961 :type 'hook)
963 (defcustom gnus-select-group-hook nil
964 "*A hook called when a newsgroup is selected.
966 If you'd like to simplify subjects like the
967 `gnus-summary-next-same-subject' command does, you can use the
968 following hook:
970 (add-hook gnus-select-group-hook
971 (lambda ()
972 (mapcar (lambda (header)
973 (mail-header-set-subject
974 header
975 (gnus-simplify-subject
976 (mail-header-subject header) 're-only)))
977 gnus-newsgroup-headers)))"
978 :group 'gnus-group-select
979 :type 'hook)
981 (defcustom gnus-select-article-hook nil
982 "*A hook called when an article is selected."
983 :group 'gnus-summary-choose
984 :options '(gnus-agent-fetch-selected-article)
985 :type 'hook)
987 (defcustom gnus-visual-mark-article-hook
988 (list 'gnus-highlight-selected-summary)
989 "*Hook run after selecting an article in the summary buffer.
990 It is meant to be used for highlighting the article in some way. It
991 is not run if `gnus-visual' is nil."
992 :group 'gnus-summary-visual
993 :type 'hook)
995 (defcustom gnus-parse-headers-hook nil
996 "*A hook called before parsing the headers."
997 :group 'gnus-various
998 :type 'hook)
1000 (defcustom gnus-exit-group-hook nil
1001 "*A hook called when exiting summary mode.
1002 This hook is not called from the non-updating exit commands like `Q'."
1003 :group 'gnus-various
1004 :type 'hook)
1006 (defcustom gnus-summary-update-hook nil
1007 "*A hook called when a summary line is changed.
1008 The hook will not be called if `gnus-visual' is nil.
1010 The default function `gnus-summary-highlight-line' will
1011 highlight the line according to the `gnus-summary-highlight'
1012 variable."
1013 :group 'gnus-summary-visual
1014 :type 'hook)
1016 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1017 "*A hook called when an article is selected for the first time.
1018 The hook is intended to mark an article as read (or unread)
1019 automatically when it is selected."
1020 :group 'gnus-summary-choose
1021 :type 'hook)
1023 (defcustom gnus-group-no-more-groups-hook nil
1024 "*A hook run when returning to group mode having no more (unread) groups."
1025 :group 'gnus-group-select
1026 :type 'hook)
1028 (defcustom gnus-ps-print-hook nil
1029 "*A hook run before ps-printing something from Gnus."
1030 :group 'gnus-summary
1031 :type 'hook)
1033 (defcustom gnus-summary-article-move-hook nil
1034 "*A hook called after an article is moved, copied, respooled, or crossposted."
1035 :version "22.1"
1036 :group 'gnus-summary
1037 :type 'hook)
1039 (defcustom gnus-summary-article-delete-hook nil
1040 "*A hook called after an article is deleted."
1041 :version "22.1"
1042 :group 'gnus-summary
1043 :type 'hook)
1045 (defcustom gnus-summary-article-expire-hook nil
1046 "*A hook called after an article is expired."
1047 :version "22.1"
1048 :group 'gnus-summary
1049 :type 'hook)
1051 (defcustom gnus-summary-display-arrow
1052 (and (fboundp 'display-graphic-p)
1053 (display-graphic-p))
1054 "*If non-nil, display an arrow highlighting the current article."
1055 :version "22.1"
1056 :group 'gnus-summary
1057 :type 'boolean)
1059 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1060 "Face used for highlighting the current article in the summary buffer."
1061 :group 'gnus-summary-visual
1062 :type 'face)
1064 (defvar gnus-tmp-downloaded nil)
1066 (defcustom gnus-summary-highlight
1067 '(((eq mark gnus-canceled-mark)
1068 . gnus-summary-cancelled)
1069 ((and uncached (> score default-high))
1070 . gnus-summary-high-undownloaded)
1071 ((and uncached (< score default-low))
1072 . gnus-summary-low-undownloaded)
1073 (uncached
1074 . gnus-summary-normal-undownloaded)
1075 ((and (> score default-high)
1076 (or (eq mark gnus-dormant-mark)
1077 (eq mark gnus-ticked-mark)))
1078 . gnus-summary-high-ticked)
1079 ((and (< score default-low)
1080 (or (eq mark gnus-dormant-mark)
1081 (eq mark gnus-ticked-mark)))
1082 . gnus-summary-low-ticked)
1083 ((or (eq mark gnus-dormant-mark)
1084 (eq mark gnus-ticked-mark))
1085 . gnus-summary-normal-ticked)
1086 ((and (> score default-high) (eq mark gnus-ancient-mark))
1087 . gnus-summary-high-ancient)
1088 ((and (< score default-low) (eq mark gnus-ancient-mark))
1089 . gnus-summary-low-ancient)
1090 ((eq mark gnus-ancient-mark)
1091 . gnus-summary-normal-ancient)
1092 ((and (> score default-high) (eq mark gnus-unread-mark))
1093 . gnus-summary-high-unread)
1094 ((and (< score default-low) (eq mark gnus-unread-mark))
1095 . gnus-summary-low-unread)
1096 ((eq mark gnus-unread-mark)
1097 . gnus-summary-normal-unread)
1098 ((> score default-high)
1099 . gnus-summary-high-read)
1100 ((< score default-low)
1101 . gnus-summary-low-read)
1103 . gnus-summary-normal-read))
1104 "*Controls the highlighting of summary buffer lines.
1106 A list of (FORM . FACE) pairs. When deciding how a particular
1107 summary line should be displayed, each form is evaluated. The content
1108 of the face field after the first true form is used. You can change
1109 how those summary lines are displayed, by editing the face field.
1111 You can use the following variables in the FORM field.
1113 score: The article's score.
1114 default: The default article score.
1115 default-high: The default score for high scored articles.
1116 default-low: The default score for low scored articles.
1117 below: The score below which articles are automatically marked as read.
1118 mark: The article's mark.
1119 uncached: Non-nil if the article is uncached."
1120 :group 'gnus-summary-visual
1121 :type '(repeat (cons (sexp :tag "Form" nil)
1122 face)))
1123 (put 'gnus-summary-highlight 'risky-local-variable t)
1125 (defcustom gnus-alter-header-function nil
1126 "Function called to allow alteration of article header structures.
1127 The function is called with one parameter, the article header vector,
1128 which it may alter in any way."
1129 :type '(choice (const :tag "None" nil)
1130 function)
1131 :group 'gnus-summary)
1133 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1134 "Function used to decode a string with encoded words.")
1136 (defvar gnus-decode-encoded-address-function
1137 'mail-decode-encoded-address-string
1138 "Function used to decode addresses with encoded words.")
1140 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1141 "*Extra headers to parse."
1142 :version "24.1" ; added Cc Keywords Gcc
1143 :group 'gnus-summary
1144 :type '(repeat symbol))
1146 (defcustom gnus-ignored-from-addresses
1147 (and user-mail-address
1148 (not (string= user-mail-address ""))
1149 (regexp-quote user-mail-address))
1150 "*From headers that may be suppressed in favor of To headers.
1151 This can be a regexp or a list of regexps."
1152 :version "21.1"
1153 :group 'gnus-summary
1154 :type '(choice regexp
1155 (repeat :tag "Regexp List" regexp)))
1157 (defsubst gnus-ignored-from-addresses ()
1158 (gmm-regexp-concat gnus-ignored-from-addresses))
1160 (defcustom gnus-summary-to-prefix "-> "
1161 "*String prefixed to the To field in the summary line when
1162 using `gnus-ignored-from-addresses'."
1163 :version "22.1"
1164 :group 'gnus-summary
1165 :type 'string)
1167 (defcustom gnus-summary-newsgroup-prefix "=> "
1168 "*String prefixed to the Newsgroup field in the summary
1169 line when using `gnus-ignored-from-addresses'."
1170 :version "22.1"
1171 :group 'gnus-summary
1172 :type 'string)
1174 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1175 "List of charsets that should be ignored.
1176 When these charsets are used in the \"charset\" parameter, the
1177 default charset will be used instead."
1178 :version "21.1"
1179 :type '(repeat symbol)
1180 :group 'gnus-charset)
1182 (defcustom gnus-newsgroup-maximum-articles nil
1183 "The maximum number of articles a newsgroup.
1184 If this is a number, old articles in a newsgroup exceeding this number
1185 are silently ignored. If it is nil, no article is ignored. Note that
1186 setting this variable to a number might prevent you from reading very
1187 old articles."
1188 :group 'gnus-group-select
1189 :version "22.2"
1190 :type '(choice (const :tag "No limit" nil)
1191 integer))
1193 (gnus-define-group-parameter
1194 ignored-charsets
1195 :type list
1196 :function-document
1197 "Return the ignored charsets of GROUP."
1198 :variable gnus-group-ignored-charsets-alist
1199 :variable-default
1200 '(("alt\\.chinese\\.text" iso-8859-1))
1201 :variable-document
1202 "Alist of regexps (to match group names) and charsets that should be ignored.
1203 When these charsets are used in the \"charset\" parameter, the
1204 default charset will be used instead."
1205 :variable-group gnus-charset
1206 :variable-type '(repeat (cons (regexp :tag "Group")
1207 (repeat symbol)))
1208 :parameter-type '(choice :tag "Ignored charsets"
1209 :value nil
1210 (repeat (symbol)))
1211 :parameter-document "\
1212 List of charsets that should be ignored.
1214 When these charsets are used in the \"charset\" parameter, the
1215 default charset will be used instead.")
1217 (defcustom gnus-group-highlight-words-alist nil
1218 "Alist of group regexps and highlight regexps.
1219 This variable uses the same syntax as `gnus-emphasis-alist'."
1220 :version "21.1"
1221 :type '(repeat (cons (regexp :tag "Group")
1222 (repeat (list (regexp :tag "Highlight regexp")
1223 (number :tag "Group for entire word" 0)
1224 (number :tag "Group for displayed part" 0)
1225 (symbol :tag "Face"
1226 gnus-emphasis-highlight-words)))))
1227 :group 'gnus-summary-visual)
1229 (defcustom gnus-summary-show-article-charset-alist
1231 "Alist of number and charset.
1232 The article will be shown with the charset corresponding to the
1233 numbered argument.
1234 For example: ((1 . cn-gb-2312) (2 . big5))."
1235 :version "21.1"
1236 :type '(repeat (cons (number :tag "Argument" 1)
1237 (symbol :tag "Charset")))
1238 :group 'gnus-charset)
1240 (defcustom gnus-preserve-marks t
1241 "Whether marks are preserved when moving, copying and respooling messages."
1242 :version "21.1"
1243 :type 'boolean
1244 :group 'gnus-summary-marks)
1246 (defcustom gnus-propagate-marks nil
1247 "If non-nil, Gnus will store and retrieve marks from the backends.
1248 This means that marks will be stored both in .newsrc.eld and in
1249 the backend, and will slow operation down somewhat."
1250 :type 'boolean
1251 :group 'gnus-summary-marks)
1253 (defcustom gnus-alter-articles-to-read-function nil
1254 "Function to be called to alter the list of articles to be selected."
1255 :type '(choice (const nil) function)
1256 :group 'gnus-summary)
1258 (defcustom gnus-orphan-score nil
1259 "*All orphans get this score added. Set in the score file."
1260 :group 'gnus-score-default
1261 :type '(choice (const nil)
1262 integer))
1264 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1265 "*A regexp to match MIME parts when saving multiple parts of a
1266 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1267 This regexp will be used by default when prompting the user for which
1268 type of files to save."
1269 :group 'gnus-summary
1270 :type 'regexp)
1272 (defcustom gnus-read-all-available-headers nil
1273 "Whether Gnus should parse all headers made available to it.
1274 This is mostly relevant for slow back ends where the user may
1275 wish to widen the summary buffer to include all headers
1276 that were fetched."
1277 :version "22.1"
1278 :group 'gnus-summary
1279 :type '(choice boolean regexp))
1281 (defcustom gnus-summary-pipe-output-default-command nil
1282 "Command (and optional arguments) used to pipe article to subprocess.
1283 This will be used as the default command if it is non-nil. The value
1284 will be updated if you modify it when executing the command
1285 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1286 :version "23.1" ;; No Gnus
1287 :group 'gnus-summary
1288 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1290 (defcustom gnus-summary-muttprint-program "muttprint"
1291 "Command (and optional arguments) used to run Muttprint.
1292 The value will be updated if you modify it when executing the command
1293 `gnus-summary-muttprint'."
1294 :version "22.1"
1295 :group 'gnus-summary
1296 :type 'string)
1298 (defcustom gnus-article-loose-mime t
1299 "If non-nil, don't require MIME-Version header.
1300 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1301 supply the MIME-Version header or deliberately strip it from the mail.
1302 If non-nil (the default), Gnus will treat some articles as MIME
1303 even if the MIME-Version header is missing."
1304 :version "22.1"
1305 :type 'boolean
1306 :group 'gnus-article-mime)
1308 (defcustom gnus-article-emulate-mime t
1309 "If non-nil, use MIME emulation for uuencode and the like.
1310 This means that Gnus will search message bodies for text that look
1311 like uuencoded bits, yEncoded bits, and so on, and present that using
1312 the normal Gnus MIME machinery."
1313 :version "22.1"
1314 :type 'boolean
1315 :group 'gnus-article-mime)
1317 ;;; Internal variables
1319 (defvar gnus-summary-display-cache nil)
1320 (defvar gnus-article-mime-handles nil)
1321 (defvar gnus-article-decoded-p nil)
1322 (defvar gnus-article-charset nil)
1323 (defvar gnus-article-ignored-charsets nil)
1324 (defvar gnus-scores-exclude-files nil)
1325 (defvar gnus-page-broken nil)
1327 (defvar gnus-original-article nil)
1328 (defvar gnus-article-internal-prepare-hook nil)
1329 (defvar gnus-newsgroup-process-stack nil)
1331 (defvar gnus-thread-indent-array nil)
1332 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1333 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1334 "Function called to sort the articles within a thread after it has been gathered together.")
1336 (defvar gnus-summary-save-parts-type-history nil)
1337 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1339 ;; Avoid highlighting in kill files.
1340 (defvar gnus-summary-inhibit-highlight nil)
1341 (defvar gnus-newsgroup-selected-overlay nil)
1342 (defvar gnus-inhibit-limiting nil)
1343 (defvar gnus-newsgroup-adaptive-score-file nil)
1344 (defvar gnus-current-score-file nil)
1345 (defvar gnus-current-move-group nil)
1346 (defvar gnus-current-copy-group nil)
1347 (defvar gnus-current-crosspost-group nil)
1348 (defvar gnus-newsgroup-display nil)
1350 (defvar gnus-newsgroup-dependencies nil)
1351 (defvar gnus-newsgroup-adaptive nil)
1352 (defvar gnus-summary-display-article-function nil)
1353 (defvar gnus-summary-highlight-line-function nil
1354 "Function called after highlighting a summary line.")
1356 (defvar gnus-summary-line-format-alist
1357 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1358 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1359 (?s gnus-tmp-subject-or-nil ?s)
1360 (?n gnus-tmp-name ?s)
1361 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1363 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1364 gnus-tmp-from) ?s)
1365 (?F gnus-tmp-from ?s)
1366 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1367 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1368 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1369 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1370 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1371 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1372 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1373 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1374 (?L gnus-tmp-lines ?s)
1375 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1376 0) ?d)
1377 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1378 "") ?s)
1379 (?g (or (gnus-group-short-name
1380 (nnir-article-group (mail-header-number gnus-tmp-header)))
1381 "") ?s)
1382 (?O gnus-tmp-downloaded ?c)
1383 (?I gnus-tmp-indentation ?s)
1384 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1385 (?R gnus-tmp-replied ?c)
1386 (?\[ gnus-tmp-opening-bracket ?c)
1387 (?\] gnus-tmp-closing-bracket ?c)
1388 (?\> (make-string gnus-tmp-level ? ) ?s)
1389 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1390 (?i gnus-tmp-score ?d)
1391 (?z gnus-tmp-score-char ?c)
1392 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1393 (?U gnus-tmp-unread ?c)
1394 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1396 (?t (gnus-summary-number-of-articles-in-thread
1397 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1399 (?e (gnus-summary-number-of-articles-in-thread
1400 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1402 (?u gnus-tmp-user-defined ?s)
1403 (?P (gnus-pick-line-number) ?d)
1404 (?B gnus-tmp-thread-tree-header-string ?s)
1405 (user-date (gnus-user-date
1406 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1407 "An alist of format specifications that can appear in summary lines.
1408 These are paired with what variables they correspond with, along with
1409 the type of the variable (string, integer, character, etc).")
1411 (defvar gnus-summary-dummy-line-format-alist
1412 `((?S gnus-tmp-subject ?s)
1413 (?N gnus-tmp-number ?d)
1414 (?u gnus-tmp-user-defined ?s)))
1416 (defvar gnus-summary-mode-line-format-alist
1417 `((?G gnus-tmp-group-name ?s)
1418 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1419 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1420 (?A gnus-tmp-article-number ?d)
1421 (?Z gnus-tmp-unread-and-unselected ?s)
1422 (?V gnus-version ?s)
1423 (?U gnus-tmp-unread-and-unticked ?d)
1424 (?S gnus-tmp-subject ?s)
1425 (?e gnus-tmp-unselected ?d)
1426 (?u gnus-tmp-user-defined ?s)
1427 (?d (length gnus-newsgroup-dormant) ?d)
1428 (?t (length gnus-newsgroup-marked) ?d)
1429 (?h (length gnus-newsgroup-spam-marked) ?d)
1430 (?r (length gnus-newsgroup-reads) ?d)
1431 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1432 (?E gnus-newsgroup-expunged-tally ?d)
1433 (?s (gnus-current-score-file-nondirectory) ?s)))
1435 ;; This is here rather than in gnus-art for compilation reasons.
1436 (defvar gnus-article-mode-line-format-alist
1437 (nconc '((?w (gnus-article-wash-status) ?s)
1438 (?m (gnus-article-mime-part-status) ?s))
1439 gnus-summary-mode-line-format-alist))
1441 (defvar gnus-last-search-regexp nil
1442 "Default regexp for article search command.")
1444 (defvar gnus-last-shell-command nil
1445 "Default shell command on article.")
1447 (defvar gnus-newsgroup-agentized nil
1448 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1449 (defvar gnus-newsgroup-begin nil)
1450 (defvar gnus-newsgroup-end nil)
1451 (defvar gnus-newsgroup-last-rmail nil)
1452 (defvar gnus-newsgroup-last-mail nil)
1453 (defvar gnus-newsgroup-last-folder nil)
1454 (defvar gnus-newsgroup-last-file nil)
1455 (defvar gnus-newsgroup-last-directory nil)
1456 (defvar gnus-newsgroup-auto-expire nil)
1457 (defvar gnus-newsgroup-active nil)
1458 (defvar gnus-newsgroup-highest nil)
1460 (defvar gnus-newsgroup-data nil)
1461 (defvar gnus-newsgroup-data-reverse nil)
1462 (defvar gnus-newsgroup-limit nil)
1463 (defvar gnus-newsgroup-limits nil)
1464 (defvar gnus-summary-use-undownloaded-faces nil)
1466 (defvar gnus-newsgroup-unreads nil
1467 "Sorted list of unread articles in the current newsgroup.")
1469 (defvar gnus-newsgroup-unselected nil
1470 "Sorted list of unselected unread articles in the current newsgroup.")
1472 (defvar gnus-newsgroup-reads nil
1473 "Alist of read articles and article marks in the current newsgroup.")
1475 (defvar gnus-newsgroup-expunged-tally nil)
1477 (defvar gnus-newsgroup-marked nil
1478 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1480 (defvar gnus-newsgroup-spam-marked nil
1481 "List of ranges of articles that have been marked as spam.")
1483 (defvar gnus-newsgroup-killed nil
1484 "List of ranges of articles that have been through the scoring process.")
1486 (defvar gnus-newsgroup-cached nil
1487 "Sorted list of articles that come from the article cache.")
1489 (defvar gnus-newsgroup-saved nil
1490 "List of articles that have been saved.")
1492 (defvar gnus-newsgroup-kill-headers nil)
1494 (defvar gnus-newsgroup-replied nil
1495 "List of articles that have been replied to in the current newsgroup.")
1497 (defvar gnus-newsgroup-forwarded nil
1498 "List of articles that have been forwarded in the current newsgroup.")
1500 (defvar gnus-newsgroup-expirable nil
1501 "Sorted list of articles in the current newsgroup that can be expired.")
1503 (defvar gnus-newsgroup-processable nil
1504 "List of articles in the current newsgroup that can be processed.")
1506 (defvar gnus-newsgroup-downloadable nil
1507 "Sorted list of articles in the current newsgroup that can be processed.")
1509 (defvar gnus-newsgroup-unfetched nil
1510 "Sorted list of articles in the current newsgroup whose headers have
1511 not been fetched into the agent.
1513 This list will always be a subset of gnus-newsgroup-undownloaded.")
1515 (defvar gnus-newsgroup-undownloaded nil
1516 "List of articles in the current newsgroup that haven't been downloaded.")
1518 (defvar gnus-newsgroup-unsendable nil
1519 "List of articles in the current newsgroup that won't be sent.")
1521 (defvar gnus-newsgroup-bookmarks nil
1522 "List of articles in the current newsgroup that have bookmarks.")
1524 (defvar gnus-newsgroup-dormant nil
1525 "Sorted list of dormant articles in the current newsgroup.")
1527 (defvar gnus-newsgroup-unseen nil
1528 "List of unseen articles in the current newsgroup.")
1530 (defvar gnus-newsgroup-seen nil
1531 "Range of seen articles in the current newsgroup.")
1533 (defvar gnus-newsgroup-articles nil
1534 "List of articles in the current newsgroup.")
1536 (defvar gnus-newsgroup-scored nil
1537 "List of scored articles in the current newsgroup.")
1539 (defvar gnus-newsgroup-headers nil
1540 "List of article headers in the current newsgroup.")
1542 (defvar gnus-newsgroup-threads nil)
1544 (defvar gnus-newsgroup-prepared nil
1545 "Whether the current group has been prepared properly.")
1547 (defvar gnus-newsgroup-ancient nil
1548 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1550 (defvar gnus-newsgroup-sparse nil)
1552 (defvar gnus-current-article nil)
1553 (defvar gnus-article-current nil)
1554 (defvar gnus-current-headers nil)
1555 (defvar gnus-have-all-headers nil)
1556 (defvar gnus-last-article nil)
1557 (defvar gnus-newsgroup-history nil)
1558 (defvar gnus-newsgroup-charset nil)
1559 (defvar gnus-newsgroup-ephemeral-charset nil)
1560 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1562 (defvar gnus-article-before-search nil)
1564 (defvar gnus-summary-local-variables
1565 '(gnus-newsgroup-name
1567 ;; Marks lists
1568 gnus-newsgroup-unreads
1569 gnus-newsgroup-unselected
1570 gnus-newsgroup-marked
1571 gnus-newsgroup-spam-marked
1572 gnus-newsgroup-reads
1573 gnus-newsgroup-saved
1574 gnus-newsgroup-replied
1575 gnus-newsgroup-forwarded
1576 gnus-newsgroup-expirable
1577 gnus-newsgroup-killed
1578 gnus-newsgroup-unseen
1579 gnus-newsgroup-seen
1580 gnus-newsgroup-cached
1581 gnus-newsgroup-downloadable
1582 gnus-newsgroup-undownloaded
1583 gnus-newsgroup-unsendable
1585 gnus-newsgroup-begin gnus-newsgroup-end
1586 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1587 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1588 gnus-newsgroup-last-directory
1589 gnus-newsgroup-auto-expire
1590 gnus-newsgroup-processable
1591 gnus-newsgroup-unfetched
1592 gnus-newsgroup-articles
1593 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1594 gnus-newsgroup-headers gnus-newsgroup-threads
1595 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1596 gnus-current-article gnus-current-headers gnus-have-all-headers
1597 gnus-last-article gnus-article-internal-prepare-hook
1598 (gnus-summary-article-delete-hook . global)
1599 (gnus-summary-article-move-hook . global)
1600 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1601 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1602 gnus-thread-expunge-below
1603 gnus-score-alist gnus-current-score-file
1604 (gnus-summary-expunge-below . global)
1605 (gnus-summary-mark-below . global)
1606 (gnus-orphan-score . global)
1607 gnus-newsgroup-active gnus-scores-exclude-files
1608 gnus-newsgroup-highest
1609 gnus-newsgroup-history gnus-newsgroup-ancient
1610 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1611 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1612 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1613 (gnus-newsgroup-expunged-tally . 0)
1614 gnus-cache-removable-articles
1615 gnus-newsgroup-data gnus-newsgroup-data-reverse
1616 gnus-newsgroup-limit gnus-newsgroup-limits
1617 gnus-newsgroup-charset gnus-newsgroup-display
1618 gnus-summary-use-undownloaded-faces)
1619 "Variables that are buffer-local to the summary buffers.")
1621 (defvar gnus-newsgroup-variables nil
1622 "A list of variables that have separate values in different newsgroups.
1623 A list of newsgroup (summary buffer) local variables, or cons of
1624 variables and their default expressions to be evalled (when the default
1625 values are not nil), that should be made global while the summary buffer
1626 is active.
1628 Note: The default expressions will be evaluated (using function `eval')
1629 before assignment to the local variable rather than just assigned to it.
1630 If the default expression is the symbol `global', that symbol will not
1631 be evaluated but the global value of the local variable will be used
1632 instead.
1634 These variables can be used to set variables in the group parameters
1635 while still allowing them to affect operations done in other buffers.
1636 For example:
1638 \(setq gnus-newsgroup-variables
1639 '(message-use-followup-to
1640 (gnus-visible-headers .
1641 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1644 (eval-when-compile
1645 ;; Bind features so that require will believe that gnus-sum has
1646 ;; already been loaded (avoids infinite recursion)
1647 (let ((features (cons 'gnus-sum features)))
1648 (require 'gnus-art)))
1650 ;; MIME stuff.
1652 (defvar gnus-decode-encoded-word-methods
1653 '(mail-decode-encoded-word-string)
1654 "List of methods used to decode encoded words.
1656 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1657 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1658 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1659 whose names match REGEXP.
1661 For example:
1662 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1663 mail-decode-encoded-word-string
1664 (\"chinese\" . rfc1843-decode-string))")
1666 (defvar gnus-decode-encoded-word-methods-cache nil)
1668 (defun gnus-multi-decode-encoded-word-string (string)
1669 "Apply the functions from `gnus-encoded-word-methods' that match."
1670 (unless (and gnus-decode-encoded-word-methods-cache
1671 (eq gnus-newsgroup-name
1672 (car gnus-decode-encoded-word-methods-cache)))
1673 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1674 (dolist (method gnus-decode-encoded-word-methods)
1675 (if (symbolp method)
1676 (nconc gnus-decode-encoded-word-methods-cache (list method))
1677 (if (and gnus-newsgroup-name
1678 (string-match (car method) gnus-newsgroup-name))
1679 (nconc gnus-decode-encoded-word-methods-cache
1680 (list (cdr method)))))))
1681 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1682 (setq string (funcall method string))))
1684 ;; Subject simplification.
1686 (defun gnus-simplify-whitespace (str)
1687 "Remove excessive whitespace from STR."
1688 ;; Multiple spaces.
1689 (while (string-match "[ \t][ \t]+" str)
1690 (setq str (concat (substring str 0 (match-beginning 0))
1692 (substring str (match-end 0)))))
1693 ;; Leading spaces.
1694 (when (string-match "^[ \t]+" str)
1695 (setq str (substring str (match-end 0))))
1696 ;; Trailing spaces.
1697 (when (string-match "[ \t]+$" str)
1698 (setq str (substring str 0 (match-beginning 0))))
1699 str)
1701 (defun gnus-simplify-all-whitespace (str)
1702 "Remove all whitespace from STR."
1703 (while (string-match "[ \t\n]+" str)
1704 (setq str (replace-match "" nil nil str)))
1705 str)
1707 (defsubst gnus-simplify-subject-re (subject)
1708 "Remove \"Re:\" from subject lines."
1709 (if (string-match message-subject-re-regexp subject)
1710 (substring subject (match-end 0))
1711 subject))
1713 (defun gnus-simplify-subject (subject &optional re-only)
1714 "Remove `Re:' and words in parentheses.
1715 If RE-ONLY is non-nil, strip leading `Re:'s only."
1716 (let ((case-fold-search t)) ;Ignore case.
1717 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1718 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1719 (setq subject (substring subject (match-end 0))))
1720 ;; Remove uninteresting prefixes.
1721 (when (and (not re-only)
1722 gnus-simplify-ignored-prefixes
1723 (string-match gnus-simplify-ignored-prefixes subject))
1724 (setq subject (substring subject (match-end 0))))
1725 ;; Remove words in parentheses from end.
1726 (unless re-only
1727 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1728 (setq subject (substring subject 0 (match-beginning 0)))))
1729 ;; Return subject string.
1730 subject))
1732 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1733 ;; all whitespace.
1734 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1735 (goto-char (point-min))
1736 (while (re-search-forward regexp nil t)
1737 (replace-match (or newtext ""))))
1739 (defun gnus-simplify-buffer-fuzzy (regexp)
1740 "Simplify string in the buffer fuzzily.
1741 The string in the accessible portion of the current buffer is simplified.
1742 It is assumed to be a single-line subject.
1743 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1744 matter is removed. Additional things can be deleted by setting
1745 `gnus-simplify-subject-fuzzy-regexp'."
1746 (let ((case-fold-search t)
1747 (modified-tick))
1748 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1750 (while (not (eq modified-tick (buffer-modified-tick)))
1751 (setq modified-tick (buffer-modified-tick))
1752 (cond
1753 ((listp regexp)
1754 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1755 (regexp
1756 (gnus-simplify-buffer-fuzzy-step regexp)))
1757 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1758 (gnus-simplify-buffer-fuzzy-step
1759 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1760 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1762 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1763 (gnus-simplify-buffer-fuzzy-step " +" " ")
1764 (gnus-simplify-buffer-fuzzy-step " $")
1765 (gnus-simplify-buffer-fuzzy-step "^ +")))
1767 (defun gnus-simplify-subject-fuzzy (subject)
1768 "Simplify a subject string fuzzily.
1769 See `gnus-simplify-buffer-fuzzy' for details."
1770 (save-excursion
1771 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1772 (gnus-set-work-buffer)
1773 (let ((case-fold-search t))
1774 ;; Remove uninteresting prefixes.
1775 (when (and gnus-simplify-ignored-prefixes
1776 (string-match gnus-simplify-ignored-prefixes subject))
1777 (setq subject (substring subject (match-end 0))))
1778 (insert subject)
1779 (inline (gnus-simplify-buffer-fuzzy regexp))
1780 (buffer-string)))))
1782 (defsubst gnus-simplify-subject-fully (subject)
1783 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1784 (cond
1785 (gnus-simplify-subject-functions
1786 (gnus-map-function gnus-simplify-subject-functions subject))
1787 ((null gnus-summary-gather-subject-limit)
1788 (gnus-simplify-subject-re subject))
1789 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1790 (gnus-simplify-subject-fuzzy subject))
1791 ((numberp gnus-summary-gather-subject-limit)
1792 (truncate-string-to-width (gnus-simplify-subject-re subject)
1793 gnus-summary-gather-subject-limit))
1795 subject)))
1797 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1798 "Check whether two subjects are equal.
1799 If optional argument SIMPLE-FIRST is t, first argument is already
1800 simplified."
1801 (cond
1802 ((null simple-first)
1803 (equal (gnus-simplify-subject-fully s1)
1804 (gnus-simplify-subject-fully s2)))
1806 (equal s1
1807 (gnus-simplify-subject-fully s2)))))
1809 (defun gnus-summary-bubble-group ()
1810 "Increase the score of the current group.
1811 This is a handy function to add to `gnus-summary-exit-hook' to
1812 increase the score of each group you read."
1813 (gnus-group-add-score gnus-newsgroup-name))
1817 ;;; Gnus summary mode
1820 (put 'gnus-summary-mode 'mode-class 'special)
1822 (defvar gnus-article-commands-menu)
1824 ;; Non-orthogonal keys
1826 (gnus-define-keys gnus-summary-mode-map
1827 " " gnus-summary-next-page
1828 "\177" gnus-summary-prev-page
1829 [delete] gnus-summary-prev-page
1830 [backspace] gnus-summary-prev-page
1831 "\r" gnus-summary-scroll-up
1832 "\M-\r" gnus-summary-scroll-down
1833 "n" gnus-summary-next-unread-article
1834 "p" gnus-summary-prev-unread-article
1835 "N" gnus-summary-next-article
1836 "P" gnus-summary-prev-article
1837 "\M-\C-n" gnus-summary-next-same-subject
1838 "\M-\C-p" gnus-summary-prev-same-subject
1839 "\M-n" gnus-summary-next-unread-subject
1840 "\M-p" gnus-summary-prev-unread-subject
1841 "." gnus-summary-first-unread-article
1842 "," gnus-summary-best-unread-article
1843 "\M-s" gnus-summary-search-article-forward
1844 "\M-r" gnus-summary-search-article-backward
1845 "\M-S" gnus-summary-repeat-search-article-forward
1846 "\M-R" gnus-summary-repeat-search-article-backward
1847 "<" gnus-summary-beginning-of-article
1848 ">" gnus-summary-end-of-article
1849 "j" gnus-summary-goto-article
1850 "^" gnus-summary-refer-parent-article
1851 "\M-^" gnus-summary-refer-article
1852 "u" gnus-summary-tick-article-forward
1853 "!" gnus-summary-tick-article-forward
1854 "U" gnus-summary-tick-article-backward
1855 "d" gnus-summary-mark-as-read-forward
1856 "D" gnus-summary-mark-as-read-backward
1857 "E" gnus-summary-mark-as-expirable
1858 "\M-u" gnus-summary-clear-mark-forward
1859 "\M-U" gnus-summary-clear-mark-backward
1860 "k" gnus-summary-kill-same-subject-and-select
1861 "\C-k" gnus-summary-kill-same-subject
1862 "\M-\C-k" gnus-summary-kill-thread
1863 "\M-\C-l" gnus-summary-lower-thread
1864 "e" gnus-summary-edit-article
1865 "#" gnus-summary-mark-as-processable
1866 "\M-#" gnus-summary-unmark-as-processable
1867 "\M-\C-t" gnus-summary-toggle-threads
1868 "\M-\C-s" gnus-summary-show-thread
1869 "\M-\C-h" gnus-summary-hide-thread
1870 "\M-\C-f" gnus-summary-next-thread
1871 "\M-\C-b" gnus-summary-prev-thread
1872 [(meta down)] gnus-summary-next-thread
1873 [(meta up)] gnus-summary-prev-thread
1874 "\M-\C-u" gnus-summary-up-thread
1875 "\M-\C-d" gnus-summary-down-thread
1876 "&" gnus-summary-execute-command
1877 "c" gnus-summary-catchup-and-exit
1878 "\C-w" gnus-summary-mark-region-as-read
1879 "\C-t" gnus-summary-toggle-truncation
1880 "?" gnus-summary-mark-as-dormant
1881 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1882 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1883 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1884 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1885 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1886 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1887 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1888 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1889 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1890 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1891 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1892 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1893 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1894 "=" gnus-summary-expand-window
1895 "\C-x\C-s" gnus-summary-reselect-current-group
1896 "\M-g" gnus-summary-rescan-group
1897 "\C-c\C-r" gnus-summary-caesar-message
1898 "f" gnus-summary-followup
1899 "F" gnus-summary-followup-with-original
1900 "C" gnus-summary-cancel-article
1901 "r" gnus-summary-reply
1902 "R" gnus-summary-reply-with-original
1903 "\C-c\C-f" gnus-summary-mail-forward
1904 "o" gnus-summary-save-article
1905 "\C-o" gnus-summary-save-article-mail
1906 "|" gnus-summary-pipe-output
1907 "\M-k" gnus-summary-edit-local-kill
1908 "\M-K" gnus-summary-edit-global-kill
1909 ;; "V" gnus-version
1910 "\C-c\C-d" gnus-summary-describe-group
1911 "q" gnus-summary-exit
1912 "Q" gnus-summary-exit-no-update
1913 "\C-c\C-i" gnus-info-find-node
1914 gnus-mouse-2 gnus-mouse-pick-article
1915 [follow-link] mouse-face
1916 "m" gnus-summary-mail-other-window
1917 "a" gnus-summary-post-news
1918 "x" gnus-summary-limit-to-unread
1919 "s" gnus-summary-isearch-article
1920 [tab] gnus-summary-widget-forward
1921 "t" gnus-summary-toggle-header
1922 "g" gnus-summary-show-article
1923 "l" gnus-summary-goto-last-article
1924 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1925 "\C-d" gnus-summary-enter-digest-group
1926 "\M-\C-d" gnus-summary-read-document
1927 "\M-\C-e" gnus-summary-edit-parameters
1928 "\M-\C-a" gnus-summary-customize-parameters
1929 "\C-c\C-b" gnus-bug
1930 "*" gnus-cache-enter-article
1931 "\M-*" gnus-cache-remove-article
1932 "\M-&" gnus-summary-universal-argument
1933 "\C-l" gnus-recenter
1934 "I" gnus-summary-increase-score
1935 "L" gnus-summary-lower-score
1936 "\M-i" gnus-symbolic-argument
1937 "h" gnus-summary-select-article-buffer
1939 "b" gnus-article-view-part
1940 "\M-t" gnus-summary-toggle-display-buttonized
1942 "V" gnus-summary-score-map
1943 "X" gnus-uu-extract-map
1944 "S" gnus-summary-send-map)
1946 ;; Sort of orthogonal keymap
1947 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1948 "t" gnus-summary-tick-article-forward
1949 "!" gnus-summary-tick-article-forward
1950 "d" gnus-summary-mark-as-read-forward
1951 "r" gnus-summary-mark-as-read-forward
1952 "c" gnus-summary-clear-mark-forward
1953 " " gnus-summary-clear-mark-forward
1954 "e" gnus-summary-mark-as-expirable
1955 "x" gnus-summary-mark-as-expirable
1956 "?" gnus-summary-mark-as-dormant
1957 "b" gnus-summary-set-bookmark
1958 "B" gnus-summary-remove-bookmark
1959 "#" gnus-summary-mark-as-processable
1960 "\M-#" gnus-summary-unmark-as-processable
1961 "S" gnus-summary-limit-include-expunged
1962 "C" gnus-summary-catchup
1963 "H" gnus-summary-catchup-to-here
1964 "h" gnus-summary-catchup-from-here
1965 "\C-c" gnus-summary-catchup-all
1966 "k" gnus-summary-kill-same-subject-and-select
1967 "K" gnus-summary-kill-same-subject
1968 "P" gnus-uu-mark-map)
1970 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1971 "c" gnus-summary-clear-above
1972 "u" gnus-summary-tick-above
1973 "m" gnus-summary-mark-above
1974 "k" gnus-summary-kill-below)
1976 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1977 "/" gnus-summary-limit-to-subject
1978 "n" gnus-summary-limit-to-articles
1979 "b" gnus-summary-limit-to-bodies
1980 "h" gnus-summary-limit-to-headers
1981 "w" gnus-summary-pop-limit
1982 "s" gnus-summary-limit-to-subject
1983 "a" gnus-summary-limit-to-author
1984 "u" gnus-summary-limit-to-unread
1985 "m" gnus-summary-limit-to-marks
1986 "M" gnus-summary-limit-exclude-marks
1987 "v" gnus-summary-limit-to-score
1988 "*" gnus-summary-limit-include-cached
1989 "D" gnus-summary-limit-include-dormant
1990 "T" gnus-summary-limit-include-thread
1991 "d" gnus-summary-limit-exclude-dormant
1992 "t" gnus-summary-limit-to-age
1993 "." gnus-summary-limit-to-unseen
1994 "x" gnus-summary-limit-to-extra
1995 "p" gnus-summary-limit-to-display-predicate
1996 "E" gnus-summary-limit-include-expunged
1997 "c" gnus-summary-limit-exclude-childless-dormant
1998 "C" gnus-summary-limit-mark-excluded-as-read
1999 "o" gnus-summary-insert-old-articles
2000 "N" gnus-summary-insert-new-articles
2001 "S" gnus-summary-limit-to-singletons
2002 "r" gnus-summary-limit-to-replied
2003 "R" gnus-summary-limit-to-recipient
2004 "A" gnus-summary-limit-to-address)
2006 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2007 "n" gnus-summary-next-unread-article
2008 "p" gnus-summary-prev-unread-article
2009 "N" gnus-summary-next-article
2010 "P" gnus-summary-prev-article
2011 "\C-n" gnus-summary-next-same-subject
2012 "\C-p" gnus-summary-prev-same-subject
2013 "\M-n" gnus-summary-next-unread-subject
2014 "\M-p" gnus-summary-prev-unread-subject
2015 "f" gnus-summary-first-unread-article
2016 "b" gnus-summary-best-unread-article
2017 "j" gnus-summary-goto-article
2018 "g" gnus-summary-goto-subject
2019 "l" gnus-summary-goto-last-article
2020 "o" gnus-summary-pop-article)
2022 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2023 "k" gnus-summary-kill-thread
2024 "E" gnus-summary-expire-thread
2025 "l" gnus-summary-lower-thread
2026 "i" gnus-summary-raise-thread
2027 "T" gnus-summary-toggle-threads
2028 "t" gnus-summary-rethread-current
2029 "^" gnus-summary-reparent-thread
2030 "\M-^" gnus-summary-reparent-children
2031 "s" gnus-summary-show-thread
2032 "S" gnus-summary-show-all-threads
2033 "h" gnus-summary-hide-thread
2034 "H" gnus-summary-hide-all-threads
2035 "n" gnus-summary-next-thread
2036 "p" gnus-summary-prev-thread
2037 "u" gnus-summary-up-thread
2038 "o" gnus-summary-top-thread
2039 "d" gnus-summary-down-thread
2040 "#" gnus-uu-mark-thread
2041 "\M-#" gnus-uu-unmark-thread)
2043 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2044 "g" gnus-summary-prepare
2045 "c" gnus-summary-insert-cached-articles
2046 "d" gnus-summary-insert-dormant-articles
2047 "t" gnus-summary-insert-ticked-articles)
2049 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2050 "c" gnus-summary-catchup-and-exit
2051 "C" gnus-summary-catchup-all-and-exit
2052 "E" gnus-summary-exit-no-update
2053 "Q" gnus-summary-exit
2054 "Z" gnus-summary-exit
2055 "n" gnus-summary-catchup-and-goto-next-group
2056 "p" gnus-summary-catchup-and-goto-prev-group
2057 "R" gnus-summary-reselect-current-group
2058 "G" gnus-summary-rescan-group
2059 "N" gnus-summary-next-group
2060 "s" gnus-summary-save-newsrc
2061 "P" gnus-summary-prev-group)
2063 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2064 " " gnus-summary-next-page
2065 "n" gnus-summary-next-page
2066 "\177" gnus-summary-prev-page
2067 [delete] gnus-summary-prev-page
2068 "p" gnus-summary-prev-page
2069 "\r" gnus-summary-scroll-up
2070 "\M-\r" gnus-summary-scroll-down
2071 "<" gnus-summary-beginning-of-article
2072 ">" gnus-summary-end-of-article
2073 "b" gnus-summary-beginning-of-article
2074 "e" gnus-summary-end-of-article
2075 "^" gnus-summary-refer-parent-article
2076 "r" gnus-summary-refer-parent-article
2077 "C" gnus-summary-show-complete-article
2078 "D" gnus-summary-enter-digest-group
2079 "R" gnus-summary-refer-references
2080 "T" gnus-summary-refer-thread
2081 "W" gnus-warp-to-article
2082 "g" gnus-summary-show-article
2083 "s" gnus-summary-isearch-article
2084 [tab] gnus-summary-widget-forward
2085 "P" gnus-summary-print-article
2086 "S" gnus-sticky-article
2087 "M" gnus-mailing-list-insinuate
2088 "t" gnus-article-babel)
2090 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2091 "b" gnus-article-add-buttons
2092 "B" gnus-article-add-buttons-to-head
2093 "o" gnus-article-treat-overstrike
2094 "e" gnus-article-emphasize
2095 "w" gnus-article-fill-cited-article
2096 "Q" gnus-article-fill-long-lines
2097 "L" gnus-article-toggle-truncate-lines
2098 "C" gnus-article-capitalize-sentences
2099 "c" gnus-article-remove-cr
2100 "q" gnus-article-de-quoted-unreadable
2101 "6" gnus-article-de-base64-unreadable
2102 "Z" gnus-article-decode-HZ
2103 "A" gnus-article-treat-ansi-sequences
2104 "h" gnus-article-wash-html
2105 "u" gnus-article-unsplit-urls
2106 "s" gnus-summary-force-verify-and-decrypt
2107 "f" gnus-article-display-x-face
2108 "l" gnus-summary-stop-page-breaking
2109 "r" gnus-summary-caesar-message
2110 "m" gnus-summary-morse-message
2111 "t" gnus-summary-toggle-header
2112 "g" gnus-treat-smiley
2113 "v" gnus-summary-verbose-headers
2114 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2115 "p" gnus-article-verify-x-pgp-sig
2116 "d" gnus-article-treat-dumbquotes
2117 "U" gnus-article-treat-non-ascii
2118 "i" gnus-summary-idna-message)
2120 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2121 ;; mnemonic: deuglif*Y*
2122 "u" gnus-article-outlook-unwrap-lines
2123 "a" gnus-article-outlook-repair-attribution
2124 "c" gnus-article-outlook-rearrange-citation
2125 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2127 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2128 "a" gnus-article-hide
2129 "h" gnus-article-hide-headers
2130 "b" gnus-article-hide-boring-headers
2131 "s" gnus-article-hide-signature
2132 "c" gnus-article-hide-citation
2133 "C" gnus-article-hide-citation-in-followups
2134 "l" gnus-article-hide-list-identifiers
2135 "B" gnus-article-strip-banner
2136 "P" gnus-article-hide-pem
2137 "\C-c" gnus-article-hide-citation-maybe)
2139 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2140 "a" gnus-article-highlight
2141 "h" gnus-article-highlight-headers
2142 "c" gnus-article-highlight-citation
2143 "s" gnus-article-highlight-signature)
2145 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2146 "f" gnus-article-treat-fold-headers
2147 "u" gnus-article-treat-unfold-headers
2148 "n" gnus-article-treat-fold-newsgroups)
2150 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2151 "x" gnus-article-display-x-face
2152 "d" gnus-article-display-face
2153 "s" gnus-treat-smiley
2154 "D" gnus-article-remove-images
2155 "W" gnus-article-show-images
2156 "f" gnus-treat-from-picon
2157 "m" gnus-treat-mail-picon
2158 "n" gnus-treat-newsgroups-picon
2159 "g" gnus-treat-from-gravatar
2160 "h" gnus-treat-mail-gravatar)
2162 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2163 "w" gnus-article-decode-mime-words
2164 "c" gnus-article-decode-charset
2165 "v" gnus-mime-view-all-parts
2166 "b" gnus-article-view-part)
2168 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2169 "z" gnus-article-date-ut
2170 "u" gnus-article-date-ut
2171 "l" gnus-article-date-local
2172 "p" gnus-article-date-english
2173 "e" gnus-article-date-lapsed
2174 "o" gnus-article-date-original
2175 "i" gnus-article-date-iso8601
2176 "s" gnus-article-date-user)
2178 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2179 "t" gnus-article-remove-trailing-blank-lines
2180 "l" gnus-article-strip-leading-blank-lines
2181 "m" gnus-article-strip-multiple-blank-lines
2182 "a" gnus-article-strip-blank-lines
2183 "A" gnus-article-strip-all-blank-lines
2184 "s" gnus-article-strip-leading-space
2185 "e" gnus-article-strip-trailing-space
2186 "w" gnus-article-remove-leading-whitespace)
2188 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2189 "v" gnus-version
2190 "d" gnus-summary-describe-group
2191 "h" gnus-summary-describe-briefly
2192 "i" gnus-info-find-node)
2194 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2195 "e" gnus-summary-expire-articles
2196 "\M-\C-e" gnus-summary-expire-articles-now
2197 "\177" gnus-summary-delete-article
2198 [delete] gnus-summary-delete-article
2199 [backspace] gnus-summary-delete-article
2200 "m" gnus-summary-move-article
2201 "r" gnus-summary-respool-article
2202 "w" gnus-summary-edit-article
2203 "c" gnus-summary-copy-article
2204 "B" gnus-summary-crosspost-article
2205 "q" gnus-summary-respool-query
2206 "t" gnus-summary-respool-trace
2207 "i" gnus-summary-import-article
2208 "I" gnus-summary-create-article
2209 "p" gnus-summary-article-posted-p)
2211 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2212 "o" gnus-summary-save-article
2213 "m" gnus-summary-save-article-mail
2214 "F" gnus-summary-write-article-file
2215 "r" gnus-summary-save-article-rmail
2216 "f" gnus-summary-save-article-file
2217 "b" gnus-summary-save-article-body-file
2218 "B" gnus-summary-write-article-body-file
2219 "h" gnus-summary-save-article-folder
2220 "v" gnus-summary-save-article-vm
2221 "p" gnus-summary-pipe-output
2222 "P" gnus-summary-muttprint)
2224 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2225 "b" gnus-summary-display-buttonized
2226 "m" gnus-summary-repair-multipart
2227 "v" gnus-article-view-part
2228 "o" gnus-article-save-part
2229 "O" gnus-article-save-part-and-strip
2230 "r" gnus-article-replace-part
2231 "d" gnus-article-delete-part
2232 "t" gnus-article-view-part-as-type
2233 "j" gnus-article-jump-to-part
2234 "c" gnus-article-copy-part
2235 "C" gnus-article-view-part-as-charset
2236 "e" gnus-article-view-part-externally
2237 "H" gnus-article-browse-html-article
2238 "E" gnus-article-encrypt-body
2239 "i" gnus-article-inline-part
2240 "|" gnus-article-pipe-part)
2242 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2243 "p" gnus-summary-mark-as-processable
2244 "u" gnus-summary-unmark-as-processable
2245 "U" gnus-summary-unmark-all-processable
2246 "v" gnus-uu-mark-over
2247 "s" gnus-uu-mark-series
2248 "r" gnus-uu-mark-region
2249 "g" gnus-uu-unmark-region
2250 "R" gnus-uu-mark-by-regexp
2251 "G" gnus-uu-unmark-by-regexp
2252 "t" gnus-uu-mark-thread
2253 "T" gnus-uu-unmark-thread
2254 "a" gnus-uu-mark-all
2255 "b" gnus-uu-mark-buffer
2256 "S" gnus-uu-mark-sparse
2257 "k" gnus-summary-kill-process-mark
2258 "y" gnus-summary-yank-process-mark
2259 "w" gnus-summary-save-process-mark
2260 "i" gnus-uu-invert-processable)
2262 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2263 ;;"x" gnus-uu-extract-any
2264 "m" gnus-summary-save-parts
2265 "u" gnus-uu-decode-uu
2266 "U" gnus-uu-decode-uu-and-save
2267 "s" gnus-uu-decode-unshar
2268 "S" gnus-uu-decode-unshar-and-save
2269 "o" gnus-uu-decode-save
2270 "O" gnus-uu-decode-save
2271 "b" gnus-uu-decode-binhex
2272 "B" gnus-uu-decode-binhex
2273 "Y" gnus-uu-decode-yenc
2274 "p" gnus-uu-decode-postscript
2275 "P" gnus-uu-decode-postscript-and-save)
2277 (gnus-define-keys
2278 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2279 "u" gnus-uu-decode-uu-view
2280 "U" gnus-uu-decode-uu-and-save-view
2281 "s" gnus-uu-decode-unshar-view
2282 "S" gnus-uu-decode-unshar-and-save-view
2283 "o" gnus-uu-decode-save-view
2284 "O" gnus-uu-decode-save-view
2285 "b" gnus-uu-decode-binhex-view
2286 "B" gnus-uu-decode-binhex-view
2287 "p" gnus-uu-decode-postscript-view
2288 "P" gnus-uu-decode-postscript-and-save-view)
2290 (defvar gnus-article-post-menu nil)
2292 (defconst gnus-summary-menu-maxlen 20)
2294 (defun gnus-summary-menu-split (menu)
2295 ;; If we have lots of elements, divide them into groups of 20
2296 ;; and make a pane (or submenu) for each one.
2297 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2298 (let ((menu menu) sublists next
2299 (i 1))
2300 (while menu
2301 ;; Pull off the next gnus-summary-menu-maxlen elements
2302 ;; and make them the next element of sublist.
2303 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2304 (if next
2305 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2306 nil))
2307 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2308 (aref (car (last menu)) 0)) menu)
2309 sublists))
2310 (setq i (1+ i))
2311 (setq menu next))
2312 (nreverse sublists))
2313 ;; Few elements--put them all in one pane.
2314 menu))
2316 (defun gnus-summary-make-menu-bar ()
2317 (gnus-turn-off-edit-menu 'summary)
2319 (unless (boundp 'gnus-summary-misc-menu)
2321 (easy-menu-define
2322 gnus-summary-kill-menu gnus-summary-mode-map ""
2323 (cons
2324 "Score"
2325 (nconc
2326 (list
2327 ["Customize" gnus-score-customize t])
2328 (gnus-make-score-map 'increase)
2329 (gnus-make-score-map 'lower)
2330 '(("Mark"
2331 ["Kill below" gnus-summary-kill-below t]
2332 ["Mark above" gnus-summary-mark-above t]
2333 ["Tick above" gnus-summary-tick-above t]
2334 ["Clear above" gnus-summary-clear-above t])
2335 ["Current score" gnus-summary-current-score t]
2336 ["Set score" gnus-summary-set-score t]
2337 ["Switch current score file..." gnus-score-change-score-file t]
2338 ["Set mark below..." gnus-score-set-mark-below t]
2339 ["Set expunge below..." gnus-score-set-expunge-below t]
2340 ["Edit current score file" gnus-score-edit-current-scores t]
2341 ["Edit score file..." gnus-score-edit-file t]
2342 ["Trace score" gnus-score-find-trace t]
2343 ["Find words" gnus-score-find-favourite-words t]
2344 ["Rescore buffer" gnus-summary-rescore t]
2345 ["Increase score..." gnus-summary-increase-score t]
2346 ["Lower score..." gnus-summary-lower-score t]))))
2348 ;; Define both the Article menu in the summary buffer and the
2349 ;; equivalent Commands menu in the article buffer here for
2350 ;; consistency.
2351 (let ((innards
2352 `(("Hide"
2353 ["All" gnus-article-hide t]
2354 ["Headers" gnus-article-hide-headers t]
2355 ["Signature" gnus-article-hide-signature t]
2356 ["Citation" gnus-article-hide-citation t]
2357 ["List identifiers" gnus-article-hide-list-identifiers t]
2358 ["Banner" gnus-article-strip-banner t]
2359 ["Boring headers" gnus-article-hide-boring-headers t])
2360 ("Highlight"
2361 ["All" gnus-article-highlight t]
2362 ["Headers" gnus-article-highlight-headers t]
2363 ["Signature" gnus-article-highlight-signature t]
2364 ["Citation" gnus-article-highlight-citation t])
2365 ("MIME"
2366 ["Words" gnus-article-decode-mime-words t]
2367 ["Charset" gnus-article-decode-charset t]
2368 ["QP" gnus-article-de-quoted-unreadable t]
2369 ["Base64" gnus-article-de-base64-unreadable t]
2370 ["View MIME buttons" gnus-summary-display-buttonized t]
2371 ["View all" gnus-mime-view-all-parts t]
2372 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2373 ["Encrypt body" gnus-article-encrypt-body
2374 :active (not (gnus-group-read-only-p))
2375 ,@(if (featurep 'xemacs) nil
2376 '(:help "Encrypt the message body on disk"))]
2377 ["Extract all parts..." gnus-summary-save-parts t]
2378 ("Multipart"
2379 ["Repair multipart" gnus-summary-repair-multipart t]
2380 ["Pipe part..." gnus-article-pipe-part t]
2381 ["Inline part" gnus-article-inline-part t]
2382 ["View part as type..." gnus-article-view-part-as-type t]
2383 ["Encrypt body" gnus-article-encrypt-body
2384 :active (not (gnus-group-read-only-p))
2385 ,@(if (featurep 'xemacs) nil
2386 '(:help "Encrypt the message body on disk"))]
2387 ["View part externally" gnus-article-view-part-externally t]
2388 ["View HTML parts in browser" gnus-article-browse-html-article t]
2389 ["View part with charset..." gnus-article-view-part-as-charset t]
2390 ["Copy part" gnus-article-copy-part t]
2391 ["Save part..." gnus-article-save-part t]
2392 ["View part" gnus-article-view-part t]))
2393 ("Date"
2394 ["Local" gnus-article-date-local t]
2395 ["ISO8601" gnus-article-date-iso8601 t]
2396 ["UT" gnus-article-date-ut t]
2397 ["Original" gnus-article-date-original t]
2398 ["Lapsed" gnus-article-date-lapsed t]
2399 ["User-defined" gnus-article-date-user t])
2400 ("Display"
2401 ["Remove images" gnus-article-remove-images t]
2402 ["Toggle smiley" gnus-treat-smiley t]
2403 ["Show X-Face" gnus-article-display-x-face t]
2404 ["Show picons in From" gnus-treat-from-picon t]
2405 ["Show picons in mail headers" gnus-treat-mail-picon t]
2406 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2407 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2408 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2409 ("View as different encoding"
2410 ,@(gnus-summary-menu-split
2411 (mapcar
2412 (lambda (cs)
2413 ;; Since easymenu under Emacs doesn't allow
2414 ;; lambda forms for menu commands, we should
2415 ;; provide intern'ed function symbols.
2416 (let ((command (intern (format "\
2417 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2418 (fset command
2419 `(lambda ()
2420 (interactive)
2421 (let ((gnus-summary-show-article-charset-alist
2422 '((1 . ,cs))))
2423 (gnus-summary-show-article 1))))
2424 `[,(symbol-name cs) ,command t]))
2425 (sort (if (fboundp 'coding-system-list)
2426 (coding-system-list)
2427 (mapcar 'car mm-mime-mule-charset-alist))
2428 'string<)))))
2429 ("Washing"
2430 ("Remove Blanks"
2431 ["Leading" gnus-article-strip-leading-blank-lines t]
2432 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2433 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2434 ["All of the above" gnus-article-strip-blank-lines t]
2435 ["All" gnus-article-strip-all-blank-lines t]
2436 ["Leading space" gnus-article-strip-leading-space t]
2437 ["Trailing space" gnus-article-strip-trailing-space t]
2438 ["Leading space in headers"
2439 gnus-article-remove-leading-whitespace t])
2440 ["Overstrike" gnus-article-treat-overstrike t]
2441 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2442 ["Non-ASCII" gnus-article-treat-non-ascii t]
2443 ["Emphasis" gnus-article-emphasize t]
2444 ["Word wrap" gnus-article-fill-cited-article t]
2445 ["Fill long lines" gnus-article-fill-long-lines t]
2446 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2447 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2448 ["Remove CR" gnus-article-remove-cr t]
2449 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2450 ["Base64" gnus-article-de-base64-unreadable t]
2451 ["Rot 13" gnus-summary-caesar-message
2452 ,@(if (featurep 'xemacs) '(t)
2453 '(:help "\"Caesar rotate\" article by 13"))]
2454 ["De-IDNA" gnus-summary-idna-message t]
2455 ["Morse decode" gnus-summary-morse-message t]
2456 ["Unix pipe..." gnus-summary-pipe-message t]
2457 ["Add buttons" gnus-article-add-buttons t]
2458 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2459 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2460 ["Verbose header" gnus-summary-verbose-headers t]
2461 ["Toggle header" gnus-summary-toggle-header t]
2462 ["Unfold headers" gnus-article-treat-unfold-headers t]
2463 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2464 ["Html" gnus-article-wash-html t]
2465 ["Unsplit URLs" gnus-article-unsplit-urls t]
2466 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2467 ["Decode HZ" gnus-article-decode-HZ t]
2468 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2469 ("(Outlook) Deuglify"
2470 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2471 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2472 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2473 ["Full (Outlook) deuglify"
2474 gnus-article-outlook-deuglify-article t])
2476 ("Output"
2477 ["Save in default format..." gnus-summary-save-article
2478 ,@(if (featurep 'xemacs) '(t)
2479 '(:help "Save article using default method"))]
2480 ["Save in file..." gnus-summary-save-article-file
2481 ,@(if (featurep 'xemacs) '(t)
2482 '(:help "Save article in file"))]
2483 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2484 ["Save in MH folder..." gnus-summary-save-article-folder t]
2485 ["Save in VM folder..." gnus-summary-save-article-vm t]
2486 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2487 ["Save body in file..." gnus-summary-save-article-body-file t]
2488 ["Pipe through a filter..." gnus-summary-pipe-output t]
2489 ["Print with Muttprint..." gnus-summary-muttprint t]
2490 ["Print" gnus-summary-print-article
2491 ,@(if (featurep 'xemacs) '(t)
2492 '(:help "Generate and print a PostScript image"))])
2493 ("Copy, move,... (Backend)"
2494 ,@(if (featurep 'xemacs) nil
2495 '(:help "Copying, moving, expiring articles..."))
2496 ["Respool article..." gnus-summary-respool-article t]
2497 ["Move article..." gnus-summary-move-article
2498 (gnus-check-backend-function
2499 'request-move-article gnus-newsgroup-name)]
2500 ["Copy article..." gnus-summary-copy-article t]
2501 ["Crosspost article..." gnus-summary-crosspost-article
2502 (gnus-check-backend-function
2503 'request-replace-article gnus-newsgroup-name)]
2504 ["Import file..." gnus-summary-import-article
2505 (gnus-check-backend-function
2506 'request-accept-article gnus-newsgroup-name)]
2507 ["Create article..." gnus-summary-create-article
2508 (gnus-check-backend-function
2509 'request-accept-article gnus-newsgroup-name)]
2510 ["Check if posted" gnus-summary-article-posted-p t]
2511 ["Edit article" gnus-summary-edit-article
2512 (not (gnus-group-read-only-p))]
2513 ["Delete article" gnus-summary-delete-article
2514 (gnus-check-backend-function
2515 'request-expire-articles gnus-newsgroup-name)]
2516 ["Query respool" gnus-summary-respool-query t]
2517 ["Trace respool" gnus-summary-respool-trace t]
2518 ["Delete expirable articles" gnus-summary-expire-articles-now
2519 (gnus-check-backend-function
2520 'request-expire-articles gnus-newsgroup-name)])
2521 ("Extract"
2522 ["Uudecode" gnus-uu-decode-uu
2523 ,@(if (featurep 'xemacs) '(t)
2524 '(:help "Decode uuencoded article(s)"))]
2525 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2526 ["Unshar" gnus-uu-decode-unshar t]
2527 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2528 ["Save" gnus-uu-decode-save t]
2529 ["Binhex" gnus-uu-decode-binhex t]
2530 ["PostScript" gnus-uu-decode-postscript t]
2531 ["All MIME parts" gnus-summary-save-parts t])
2532 ("Cache"
2533 ["Enter article" gnus-cache-enter-article t]
2534 ["Remove article" gnus-cache-remove-article t])
2535 ["Translate" gnus-article-babel t]
2536 ["Select article buffer" gnus-summary-select-article-buffer t]
2537 ["Make article buffer sticky" gnus-sticky-article t]
2538 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2539 ["Isearch article..." gnus-summary-isearch-article t]
2540 ["Beginning of the article" gnus-summary-beginning-of-article t]
2541 ["End of the article" gnus-summary-end-of-article t]
2542 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2543 ["Fetch referenced articles" gnus-summary-refer-references t]
2544 ["Fetch current thread" gnus-summary-refer-thread t]
2545 ["Fetch article with id..." gnus-summary-refer-article t]
2546 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2547 ["Redisplay" gnus-summary-show-article t]
2548 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2549 (easy-menu-define
2550 gnus-summary-article-menu gnus-summary-mode-map ""
2551 (cons "Article" innards))
2553 (if (not (keymapp gnus-summary-article-menu))
2554 (easy-menu-define
2555 gnus-article-commands-menu gnus-article-mode-map ""
2556 (cons "Commands" innards))
2557 ;; in Emacs, don't share menu.
2558 (setq gnus-article-commands-menu
2559 (copy-keymap gnus-summary-article-menu))
2560 (define-key gnus-article-mode-map [menu-bar commands]
2561 (cons "Commands" gnus-article-commands-menu))))
2563 (easy-menu-define
2564 gnus-summary-thread-menu gnus-summary-mode-map ""
2565 '("Threads"
2566 ["Find all messages in thread" gnus-summary-refer-thread t]
2567 ["Toggle threading" gnus-summary-toggle-threads t]
2568 ["Hide threads" gnus-summary-hide-all-threads t]
2569 ["Show threads" gnus-summary-show-all-threads t]
2570 ["Hide thread" gnus-summary-hide-thread t]
2571 ["Show thread" gnus-summary-show-thread t]
2572 ["Go to next thread" gnus-summary-next-thread t]
2573 ["Go to previous thread" gnus-summary-prev-thread t]
2574 ["Go down thread" gnus-summary-down-thread t]
2575 ["Go up thread" gnus-summary-up-thread t]
2576 ["Top of thread" gnus-summary-top-thread t]
2577 ["Mark thread as read" gnus-summary-kill-thread t]
2578 ["Mark thread as expired" gnus-summary-expire-thread t]
2579 ["Lower thread score" gnus-summary-lower-thread t]
2580 ["Raise thread score" gnus-summary-raise-thread t]
2581 ["Rethread current" gnus-summary-rethread-current t]))
2583 (easy-menu-define
2584 gnus-summary-post-menu gnus-summary-mode-map ""
2585 `("Post"
2586 ["Send a message (mail or news)" gnus-summary-post-news
2587 ,@(if (featurep 'xemacs) '(t)
2588 '(:help "Compose a new message (mail or news)"))]
2589 ["Followup" gnus-summary-followup
2590 ,@(if (featurep 'xemacs) '(t)
2591 '(:help "Post followup to this article"))]
2592 ["Followup and yank" gnus-summary-followup-with-original
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Post followup to this article, quoting its contents"))]
2595 ["Supersede article" gnus-summary-supersede-article t]
2596 ["Cancel article" gnus-summary-cancel-article
2597 ,@(if (featurep 'xemacs) '(t)
2598 '(:help "Cancel an article you posted"))]
2599 ["Reply" gnus-summary-reply t]
2600 ["Reply and yank" gnus-summary-reply-with-original t]
2601 ["Wide reply" gnus-summary-wide-reply t]
2602 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a reply, quoting this article"))]
2605 ["Very wide reply" gnus-summary-very-wide-reply t]
2606 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2607 ,@(if (featurep 'xemacs) '(t)
2608 '(:help "Mail a very wide reply, quoting this article"))]
2609 ["Mail forward" gnus-summary-mail-forward t]
2610 ["Post forward" gnus-summary-post-forward t]
2611 ["Digest and mail" gnus-uu-digest-mail-forward t]
2612 ["Digest and post" gnus-uu-digest-post-forward t]
2613 ["Resend message" gnus-summary-resend-message t]
2614 ["Resend message edit" gnus-summary-resend-message-edit t]
2615 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2616 ["Send a mail" gnus-summary-mail-other-window t]
2617 ["Create a local message" gnus-summary-news-other-window t]
2618 ["Uuencode and post" gnus-uu-post-news
2619 ,@(if (featurep 'xemacs) '(t)
2620 '(:help "Post a uuencoded article"))]
2621 ["Followup via news" gnus-summary-followup-to-mail t]
2622 ["Followup via news and yank"
2623 gnus-summary-followup-to-mail-with-original t]
2624 ["Strip signature on reply"
2625 (lambda ()
2626 (interactive)
2627 (if (not (memq message-cite-function
2628 '(message-cite-original-without-signature
2629 message-cite-original)))
2630 ;; Stupid workaround for XEmacs not honoring :visible.
2631 (message "Can't toggle this value of `message-cite-function'")
2632 (setq message-cite-function
2633 (if (eq message-cite-function
2634 'message-cite-original-without-signature)
2635 'message-cite-original
2636 'message-cite-original-without-signature))))
2637 ;; XEmacs barfs on :visible.
2638 ,@(if (featurep 'xemacs) nil
2639 '(:visible (memq message-cite-function
2640 '(message-cite-original-without-signature
2641 message-cite-original))))
2642 :style toggle
2643 :selected (eq message-cite-function
2644 'message-cite-original-without-signature)
2645 ,@(if (featurep 'xemacs) nil
2646 '(:help "Strip signature from cited article when replying."))]
2647 ;;("Draft"
2648 ;;["Send" gnus-summary-send-draft t]
2649 ;;["Send bounced" gnus-resend-bounced-mail t])
2652 (cond
2653 ((not (keymapp gnus-summary-post-menu))
2654 (setq gnus-article-post-menu gnus-summary-post-menu))
2655 ((not gnus-article-post-menu)
2656 ;; Don't share post menu.
2657 (setq gnus-article-post-menu
2658 (copy-keymap gnus-summary-post-menu))))
2659 (define-key gnus-article-mode-map [menu-bar post]
2660 (cons "Post" gnus-article-post-menu))
2662 (easy-menu-define
2663 gnus-summary-misc-menu gnus-summary-mode-map ""
2664 `("Gnus"
2665 ("Mark Read"
2666 ["Mark as read" gnus-summary-mark-as-read-forward t]
2667 ["Mark same subject and select"
2668 gnus-summary-kill-same-subject-and-select t]
2669 ["Mark same subject" gnus-summary-kill-same-subject t]
2670 ["Catchup" gnus-summary-catchup
2671 ,@(if (featurep 'xemacs) '(t)
2672 '(:help "Mark unread articles in this group as read"))]
2673 ["Catchup all" gnus-summary-catchup-all t]
2674 ["Catchup to here" gnus-summary-catchup-to-here t]
2675 ["Catchup from here" gnus-summary-catchup-from-here t]
2676 ["Catchup region" gnus-summary-mark-region-as-read
2677 (gnus-mark-active-p)]
2678 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2679 ("Mark Various"
2680 ["Tick" gnus-summary-tick-article-forward t]
2681 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2682 ["Remove marks" gnus-summary-clear-mark-forward t]
2683 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2684 ["Set bookmark" gnus-summary-set-bookmark t]
2685 ["Remove bookmark" gnus-summary-remove-bookmark t])
2686 ("Limit to"
2687 ["Marks..." gnus-summary-limit-to-marks t]
2688 ["Subject..." gnus-summary-limit-to-subject t]
2689 ["Author..." gnus-summary-limit-to-author t]
2690 ["Recipient..." gnus-summary-limit-to-recipient t]
2691 ["Address..." gnus-summary-limit-to-address t]
2692 ["Age..." gnus-summary-limit-to-age t]
2693 ["Extra..." gnus-summary-limit-to-extra t]
2694 ["Score..." gnus-summary-limit-to-score t]
2695 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2696 ["Unread" gnus-summary-limit-to-unread t]
2697 ["Unseen" gnus-summary-limit-to-unseen t]
2698 ["Singletons" gnus-summary-limit-to-singletons t]
2699 ["Replied" gnus-summary-limit-to-replied t]
2700 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2701 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2702 ["Pop limit" gnus-summary-pop-limit t]
2703 ["Show dormant" gnus-summary-limit-include-dormant t]
2704 ["Hide childless dormant"
2705 gnus-summary-limit-exclude-childless-dormant t]
2706 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2707 ["Hide marked" gnus-summary-limit-exclude-marks t]
2708 ["Show expunged" gnus-summary-limit-include-expunged t])
2709 ("Process Mark"
2710 ["Set mark" gnus-summary-mark-as-processable t]
2711 ["Remove mark" gnus-summary-unmark-as-processable t]
2712 ["Remove all marks" gnus-summary-unmark-all-processable t]
2713 ["Invert marks" gnus-uu-invert-processable t]
2714 ["Mark above" gnus-uu-mark-over t]
2715 ["Mark series" gnus-uu-mark-series t]
2716 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2717 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2718 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2719 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2720 ["Mark all" gnus-uu-mark-all t]
2721 ["Mark buffer" gnus-uu-mark-buffer t]
2722 ["Mark sparse" gnus-uu-mark-sparse t]
2723 ["Mark thread" gnus-uu-mark-thread t]
2724 ["Unmark thread" gnus-uu-unmark-thread t]
2725 ("Process Mark Sets"
2726 ["Kill" gnus-summary-kill-process-mark t]
2727 ["Yank" gnus-summary-yank-process-mark
2728 gnus-newsgroup-process-stack]
2729 ["Save" gnus-summary-save-process-mark t]
2730 ["Run command on marked..." gnus-summary-universal-argument t]))
2731 ("Registry Marks")
2732 ("Scroll article"
2733 ["Page forward" gnus-summary-next-page
2734 ,@(if (featurep 'xemacs) '(t)
2735 '(:help "Show next page of article"))]
2736 ["Page backward" gnus-summary-prev-page
2737 ,@(if (featurep 'xemacs) '(t)
2738 '(:help "Show previous page of article"))]
2739 ["Line forward" gnus-summary-scroll-up t])
2740 ("Move"
2741 ["Next unread article" gnus-summary-next-unread-article t]
2742 ["Previous unread article" gnus-summary-prev-unread-article t]
2743 ["Next article" gnus-summary-next-article t]
2744 ["Previous article" gnus-summary-prev-article t]
2745 ["Next unread subject" gnus-summary-next-unread-subject t]
2746 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2747 ["Next article same subject" gnus-summary-next-same-subject t]
2748 ["Previous article same subject" gnus-summary-prev-same-subject t]
2749 ["First unread article" gnus-summary-first-unread-article t]
2750 ["Best unread article" gnus-summary-best-unread-article t]
2751 ["Go to subject number..." gnus-summary-goto-subject t]
2752 ["Go to article number..." gnus-summary-goto-article t]
2753 ["Go to the last article" gnus-summary-goto-last-article t]
2754 ["Pop article off history" gnus-summary-pop-article t])
2755 ("Sort"
2756 ["Sort by number" gnus-summary-sort-by-number t]
2757 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2758 ["Sort by author" gnus-summary-sort-by-author t]
2759 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2760 ["Sort by subject" gnus-summary-sort-by-subject t]
2761 ["Sort by date" gnus-summary-sort-by-date t]
2762 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2763 ["Sort by score" gnus-summary-sort-by-score t]
2764 ["Sort by lines" gnus-summary-sort-by-lines t]
2765 ["Sort by characters" gnus-summary-sort-by-chars t]
2766 ["Randomize" gnus-summary-sort-by-random t]
2767 ["Original sort" gnus-summary-sort-by-original t])
2768 ("Help"
2769 ["Describe group" gnus-summary-describe-group t]
2770 ["Read manual" gnus-info-find-node t])
2771 ("Modes"
2772 ["Pick and read" gnus-pick-mode t]
2773 ["Binary" gnus-binary-mode t])
2774 ("Regeneration"
2775 ["Regenerate" gnus-summary-prepare t]
2776 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2777 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2778 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2779 ["Toggle threading" gnus-summary-toggle-threads t])
2780 ["See old articles" gnus-summary-insert-old-articles t]
2781 ["See new articles" gnus-summary-insert-new-articles t]
2782 ["Filter articles..." gnus-summary-execute-command t]
2783 ["Run command on articles..." gnus-summary-universal-argument t]
2784 ["Search articles forward..." gnus-summary-search-article-forward t]
2785 ["Search articles backward..." gnus-summary-search-article-backward t]
2786 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2787 ["Expand window" gnus-summary-expand-window t]
2788 ["Expire expirable articles" gnus-summary-expire-articles
2789 (gnus-check-backend-function
2790 'request-expire-articles gnus-newsgroup-name)]
2791 ["Edit local kill file" gnus-summary-edit-local-kill t]
2792 ["Edit main kill file" gnus-summary-edit-global-kill t]
2793 ["Edit group parameters" gnus-summary-edit-parameters t]
2794 ["Customize group parameters" gnus-summary-customize-parameters t]
2795 ["Send a bug report" gnus-bug t]
2796 ("Exit"
2797 ["Catchup and exit" gnus-summary-catchup-and-exit
2798 ,@(if (featurep 'xemacs) '(t)
2799 '(:help "Mark unread articles in this group as read, then exit"))]
2800 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2801 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2802 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2803 ["Exit group" gnus-summary-exit
2804 ,@(if (featurep 'xemacs) '(t)
2805 '(:help "Exit current group, return to group selection mode"))]
2806 ["Exit group without updating" gnus-summary-exit-no-update t]
2807 ["Exit and goto next group" gnus-summary-next-group t]
2808 ["Exit and goto prev group" gnus-summary-prev-group t]
2809 ["Reselect group" gnus-summary-reselect-current-group t]
2810 ["Rescan group" gnus-summary-rescan-group t]
2811 ["Update dribble" gnus-summary-save-newsrc t])))
2813 (gnus-run-hooks 'gnus-summary-menu-hook)))
2815 (defvar gnus-summary-tool-bar-map nil)
2817 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2818 ;; affect _new_ message buffers. We might add a function that walks thru all
2819 ;; summary-mode buffers and force the update.
2820 (defun gnus-summary-tool-bar-update (&optional symbol value)
2821 "Update summary mode toolbar.
2822 Setter function for custom variables."
2823 (setq-default gnus-summary-tool-bar-map nil)
2824 (when symbol
2825 ;; When used as ":set" function:
2826 (set-default symbol value))
2827 (when (gnus-buffer-live-p gnus-summary-buffer)
2828 (with-current-buffer gnus-summary-buffer
2829 (gnus-summary-make-tool-bar))))
2831 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2832 'gnus-summary-tool-bar-gnome
2833 'gnus-summary-tool-bar-retro)
2834 "Specifies the Gnus summary tool bar.
2836 It can be either a list or a symbol referring to a list. See
2837 `gmm-tool-bar-from-list' for the format of the list. The
2838 default key map is `gnus-summary-mode-map'.
2840 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2841 `gnus-summary-tool-bar-retro'."
2842 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2843 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2844 (repeat :tag "User defined list" gmm-tool-bar-item)
2845 (symbol))
2846 :version "23.1" ;; No Gnus
2847 :initialize 'custom-initialize-default
2848 :set 'gnus-summary-tool-bar-update
2849 :group 'gnus-summary)
2851 (defcustom gnus-summary-tool-bar-gnome
2852 '((gnus-summary-post-news "mail/compose" nil)
2853 (gnus-summary-insert-new-articles "mail/inbox" nil
2854 :visible (or (not gnus-agent)
2855 gnus-plugged))
2856 (gnus-summary-reply-with-original "mail/reply")
2857 (gnus-summary-reply "mail/reply" nil :visible nil)
2858 (gnus-summary-followup-with-original "mail/reply-all")
2859 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2860 (gnus-summary-mail-forward "mail/forward")
2861 (gnus-summary-save-article "mail/save")
2862 (gnus-summary-search-article-forward "search" nil :visible nil)
2863 (gnus-summary-print-article "print")
2864 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2865 ;; Some new commands that may need more suitable icons:
2866 (gnus-summary-save-newsrc "save" nil :visible nil)
2867 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2868 (gnus-summary-prev-article "left-arrow")
2869 (gnus-summary-next-article "right-arrow")
2870 (gnus-summary-next-page "next-page")
2871 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2873 ;; Maybe some sort-by-... could be added:
2874 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2875 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2876 (gnus-summary-mark-as-expirable
2877 "delete" nil
2878 :visible (gnus-check-backend-function 'request-expire-articles
2879 gnus-newsgroup-name))
2880 (gnus-summary-mark-as-spam
2881 "mail/spam" t
2882 :visible (and (fboundp 'spam-group-ham-contents-p)
2883 (spam-group-ham-contents-p gnus-newsgroup-name))
2884 :help "Mark as spam")
2885 (gnus-summary-mark-as-read-forward
2886 "mail/not-spam" nil
2887 :visible (and (fboundp 'spam-group-spam-contents-p)
2888 (spam-group-spam-contents-p gnus-newsgroup-name)))
2890 (gnus-summary-exit "exit")
2891 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2892 (gnus-info-find-node "help"))
2893 "List of functions for the summary tool bar (GNOME style).
2895 See `gmm-tool-bar-from-list' for the format of the list."
2896 :type '(repeat gmm-tool-bar-item)
2897 :version "23.1" ;; No Gnus
2898 :initialize 'custom-initialize-default
2899 :set 'gnus-summary-tool-bar-update
2900 :group 'gnus-summary)
2902 (defcustom gnus-summary-tool-bar-retro
2903 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2904 (gnus-summary-next-unread-article "gnus/next-ur")
2905 (gnus-summary-post-news "gnus/post")
2906 (gnus-summary-followup-with-original "gnus/fuwo")
2907 (gnus-summary-followup "gnus/followup")
2908 (gnus-summary-reply-with-original "gnus/reply-wo")
2909 (gnus-summary-reply "gnus/reply")
2910 (gnus-summary-caesar-message "gnus/rot13")
2911 (gnus-uu-decode-uu "gnus/uu-decode")
2912 (gnus-summary-save-article-file "gnus/save-aif")
2913 (gnus-summary-save-article "gnus/save-art")
2914 (gnus-uu-post-news "gnus/uu-post")
2915 (gnus-summary-catchup "gnus/catchup")
2916 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2917 (gnus-summary-exit "gnus/exit-summ")
2918 ;; Some new command that may need more suitable icons:
2919 (gnus-summary-print-article "gnus/print" nil :visible nil)
2920 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2921 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2922 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2923 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2924 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2925 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2927 (gnus-info-find-node "gnus/help" nil :visible nil))
2928 "List of functions for the summary tool bar (retro look).
2930 See `gmm-tool-bar-from-list' for the format of the list."
2931 :type '(repeat gmm-tool-bar-item)
2932 :version "23.1" ;; No Gnus
2933 :initialize 'custom-initialize-default
2934 :set 'gnus-summary-tool-bar-update
2935 :group 'gnus-summary)
2937 (defcustom gnus-summary-tool-bar-zap-list t
2938 "List of icon items from the global tool bar.
2939 These items are not displayed in the Gnus summary mode tool bar.
2941 See `gmm-tool-bar-from-list' for the format of the list."
2942 :type 'gmm-tool-bar-zap-list
2943 :version "23.1" ;; No Gnus
2944 :initialize 'custom-initialize-default
2945 :set 'gnus-summary-tool-bar-update
2946 :group 'gnus-summary)
2948 (defvar image-load-path)
2949 (defvar tool-bar-map)
2951 (defun gnus-summary-make-tool-bar (&optional force)
2952 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2953 When FORCE, rebuild the tool bar."
2954 (when (and (not (featurep 'xemacs))
2955 (boundp 'tool-bar-mode)
2956 tool-bar-mode
2957 (or (not gnus-summary-tool-bar-map) force))
2958 (let* ((load-path
2959 (gmm-image-load-path-for-library "gnus"
2960 "mail/save.xpm"
2961 nil t))
2962 (image-load-path (cons (car load-path)
2963 (when (boundp 'image-load-path)
2964 image-load-path)))
2965 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2966 gnus-summary-tool-bar-zap-list
2967 'gnus-summary-mode-map)))
2968 (when map
2969 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2970 ;; uses its value.
2971 (setq gnus-summary-tool-bar-map map))))
2972 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2974 (defun gnus-score-set-default (var value)
2975 "A version of set that updates the GNU Emacs menu-bar."
2976 (set var value)
2977 ;; It is the message that forces the active status to be updated.
2978 (message ""))
2980 (defun gnus-make-score-map (type)
2981 "Make a summary score map of type TYPE."
2982 (if t
2984 (let ((headers '(("author" "from" string)
2985 ("subject" "subject" string)
2986 ("article body" "body" string)
2987 ("article head" "head" string)
2988 ("xref" "xref" string)
2989 ("extra header" "extra" string)
2990 ("lines" "lines" number)
2991 ("followups to author" "followup" string)))
2992 (types '((number ("less than" <)
2993 ("greater than" >)
2994 ("equal" =))
2995 (string ("substring" s)
2996 ("exact string" e)
2997 ("fuzzy string" f)
2998 ("regexp" r))))
2999 (perms '(("temporary" (current-time-string))
3000 ("permanent" nil)
3001 ("immediate" now)))
3002 header)
3003 (list
3004 (apply
3005 'nconc
3006 (list
3007 (if (eq type 'lower)
3008 "Lower score"
3009 "Increase score"))
3010 (let (outh)
3011 (while headers
3012 (setq header (car headers))
3013 (setq outh
3014 (cons
3015 (apply
3016 'nconc
3017 (list (car header))
3018 (let ((ts (cdr (assoc (nth 2 header) types)))
3019 outt)
3020 (while ts
3021 (setq outt
3022 (cons
3023 (apply
3024 'nconc
3025 (list (caar ts))
3026 (let ((ps perms)
3027 outp)
3028 (while ps
3029 (setq outp
3030 (cons
3031 (vector
3032 (caar ps)
3033 (list
3034 'gnus-summary-score-entry
3035 (nth 1 header)
3036 (if (or (string= (nth 1 header)
3037 "head")
3038 (string= (nth 1 header)
3039 "body"))
3041 (list 'gnus-summary-header
3042 (nth 1 header)))
3043 (list 'quote (nth 1 (car ts)))
3044 (list 'gnus-score-delta-default
3045 nil)
3046 (nth 1 (car ps))
3049 outp))
3050 (setq ps (cdr ps)))
3051 (list (nreverse outp))))
3052 outt))
3053 (setq ts (cdr ts)))
3054 (list (nreverse outt))))
3055 outh))
3056 (setq headers (cdr headers)))
3057 (list (nreverse outh))))))))
3060 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3061 (defvar bookmark-make-record-function)
3063 (defvar bidi-paragraph-direction)
3065 (defun gnus-summary-mode (&optional group)
3066 "Major mode for reading articles.
3068 All normal editing commands are switched off.
3069 \\<gnus-summary-mode-map>
3070 Each line in this buffer represents one article. To read an
3071 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3072 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3073 respectively.
3075 You can also post articles and send mail from this buffer. To
3076 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3077 of an article, type `\\[gnus-summary-reply]'.
3079 There are approx. one gazillion commands you can execute in this
3080 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3082 The following commands are available:
3084 \\{gnus-summary-mode-map}"
3085 (interactive)
3086 (kill-all-local-variables)
3087 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3088 (gnus-summary-make-local-variables))
3089 (gnus-summary-make-local-variables)
3090 (setq gnus-newsgroup-name group)
3091 (when (gnus-visual-p 'summary-menu 'menu)
3092 (gnus-summary-make-menu-bar)
3093 (gnus-summary-make-tool-bar))
3094 (gnus-make-thread-indent-array)
3095 (gnus-simplify-mode-line)
3096 (setq major-mode 'gnus-summary-mode)
3097 (setq mode-name "Summary")
3098 (use-local-map gnus-summary-mode-map)
3099 (buffer-disable-undo)
3100 (setq buffer-read-only t ;Disable modification
3101 show-trailing-whitespace nil)
3102 (setq truncate-lines t)
3103 ;; Force paragraph direction to be left-to-right. Don't make it
3104 ;; bound globally in old Emacsen and XEmacsen.
3105 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3106 (add-to-invisibility-spec '(gnus-sum . t))
3107 (gnus-summary-set-display-table)
3108 (gnus-set-default-directory)
3109 (make-local-variable 'gnus-summary-line-format)
3110 (make-local-variable 'gnus-summary-line-format-spec)
3111 (make-local-variable 'gnus-summary-dummy-line-format)
3112 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3113 (make-local-variable 'gnus-summary-mark-positions)
3114 (gnus-make-local-hook 'pre-command-hook)
3115 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3116 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3117 (turn-on-gnus-mailing-list-mode)
3118 (mm-enable-multibyte)
3119 (set (make-local-variable 'bookmark-make-record-function)
3120 'gnus-summary-bookmark-make-record)
3121 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3122 (gnus-update-summary-mark-positions))
3124 (defun gnus-summary-make-local-variables ()
3125 "Make all the local summary buffer variables."
3126 (let (global)
3127 (dolist (local gnus-summary-local-variables)
3128 (if (consp local)
3129 (progn
3130 (if (eq (cdr local) 'global)
3131 ;; Copy the global value of the variable.
3132 (setq global (symbol-value (car local)))
3133 ;; Use the value from the list.
3134 (setq global (eval (cdr local))))
3135 (set (make-local-variable (car local)) global))
3136 ;; Simple nil-valued local variable.
3137 (set (make-local-variable local) nil)))))
3139 ;; Summary data functions.
3141 (defmacro gnus-data-number (data)
3142 `(car ,data))
3144 (defmacro gnus-data-set-number (data number)
3145 `(setcar ,data ,number))
3147 (defmacro gnus-data-mark (data)
3148 `(nth 1 ,data))
3150 (defmacro gnus-data-set-mark (data mark)
3151 `(setcar (nthcdr 1 ,data) ,mark))
3153 (defmacro gnus-data-pos (data)
3154 `(nth 2 ,data))
3156 (defmacro gnus-data-set-pos (data pos)
3157 `(setcar (nthcdr 2 ,data) ,pos))
3159 (defmacro gnus-data-header (data)
3160 `(nth 3 ,data))
3162 (defmacro gnus-data-set-header (data header)
3163 `(setf (nth 3 ,data) ,header))
3165 (defmacro gnus-data-level (data)
3166 `(nth 4 ,data))
3168 (defmacro gnus-data-unread-p (data)
3169 `(= (nth 1 ,data) gnus-unread-mark))
3171 (defmacro gnus-data-read-p (data)
3172 `(/= (nth 1 ,data) gnus-unread-mark))
3174 (defmacro gnus-data-pseudo-p (data)
3175 `(consp (nth 3 ,data)))
3177 (defmacro gnus-data-find (number)
3178 `(assq ,number gnus-newsgroup-data))
3180 (defmacro gnus-data-find-list (number &optional data)
3181 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3182 (memq (assq ,number bdata)
3183 bdata)))
3185 (defmacro gnus-data-make (number mark pos header level)
3186 `(list ,number ,mark ,pos ,header ,level))
3188 (defun gnus-data-enter (after-article number mark pos header level offset)
3189 (let ((data (gnus-data-find-list after-article)))
3190 (unless data
3191 (error "No such article: %d" after-article))
3192 (setcdr data (cons (gnus-data-make number mark pos header level)
3193 (cdr data)))
3194 (setq gnus-newsgroup-data-reverse nil)
3195 (gnus-data-update-list (cddr data) offset)))
3197 (defun gnus-data-enter-list (after-article list &optional offset)
3198 (when list
3199 (let ((data (and after-article (gnus-data-find-list after-article)))
3200 (ilist list))
3201 (if (not (or data
3202 after-article))
3203 (let ((odata gnus-newsgroup-data))
3204 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3205 (when offset
3206 (gnus-data-update-list odata offset)))
3207 ;; Find the last element in the list to be spliced into the main
3208 ;; list.
3209 (setq list (last list))
3210 (if (not data)
3211 (progn
3212 (setcdr list gnus-newsgroup-data)
3213 (setq gnus-newsgroup-data ilist)
3214 (when offset
3215 (gnus-data-update-list (cdr list) offset)))
3216 (setcdr list (cdr data))
3217 (setcdr data ilist)
3218 (when offset
3219 (gnus-data-update-list (cdr list) offset))))
3220 (setq gnus-newsgroup-data-reverse nil))))
3222 (defun gnus-data-remove (article &optional offset)
3223 (let ((data gnus-newsgroup-data))
3224 (if (= (gnus-data-number (car data)) article)
3225 (progn
3226 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3227 gnus-newsgroup-data-reverse nil)
3228 (when offset
3229 (gnus-data-update-list gnus-newsgroup-data offset)))
3230 (while (cdr data)
3231 (when (= (gnus-data-number (cadr data)) article)
3232 (setcdr data (cddr data))
3233 (when offset
3234 (gnus-data-update-list (cdr data) offset))
3235 (setq data nil
3236 gnus-newsgroup-data-reverse nil))
3237 (setq data (cdr data))))))
3239 (defmacro gnus-data-list (backward)
3240 `(if ,backward
3241 (or gnus-newsgroup-data-reverse
3242 (setq gnus-newsgroup-data-reverse
3243 (reverse gnus-newsgroup-data)))
3244 gnus-newsgroup-data))
3246 (defun gnus-data-update-list (data offset)
3247 "Add OFFSET to the POS of all data entries in DATA."
3248 (setq gnus-newsgroup-data-reverse nil)
3249 (while data
3250 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3251 (setq data (cdr data))))
3253 (defun gnus-summary-article-pseudo-p (article)
3254 "Say whether this article is a pseudo article or not."
3255 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3257 (defmacro gnus-summary-article-sparse-p (article)
3258 "Say whether this article is a sparse article or not."
3259 `(memq ,article gnus-newsgroup-sparse))
3261 (defmacro gnus-summary-article-ancient-p (article)
3262 "Say whether this article is a sparse article or not."
3263 `(memq ,article gnus-newsgroup-ancient))
3265 (defun gnus-article-parent-p (number)
3266 "Say whether this article is a parent or not."
3267 (let ((data (gnus-data-find-list number)))
3268 (and (cdr data) ; There has to be an article after...
3269 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3270 (gnus-data-level (nth 1 data))))))
3272 (defun gnus-article-children (number)
3273 "Return a list of all children to NUMBER."
3274 (let* ((data (gnus-data-find-list number))
3275 (level (gnus-data-level (car data)))
3276 children)
3277 (setq data (cdr data))
3278 (while (and data
3279 (= (gnus-data-level (car data)) (1+ level)))
3280 (push (gnus-data-number (car data)) children)
3281 (setq data (cdr data)))
3282 children))
3284 (defmacro gnus-summary-skip-intangible ()
3285 "If the current article is intangible, then jump to a different article."
3286 '(let ((to (get-text-property (point) 'gnus-intangible)))
3287 (and to (gnus-summary-goto-subject to))))
3289 (defmacro gnus-summary-article-intangible-p ()
3290 "Say whether this article is intangible or not."
3291 '(get-text-property (point) 'gnus-intangible))
3293 (defun gnus-article-read-p (article)
3294 "Say whether ARTICLE is read or not."
3295 (not (or (memq article gnus-newsgroup-marked)
3296 (memq article gnus-newsgroup-spam-marked)
3297 (memq article gnus-newsgroup-unreads)
3298 (memq article gnus-newsgroup-unselected)
3299 (memq article gnus-newsgroup-dormant))))
3301 ;; Some summary mode macros.
3303 (defmacro gnus-summary-article-number ()
3304 "The article number of the article on the current line.
3305 If there isn't an article number here, then we return the current
3306 article number."
3307 '(progn
3308 (gnus-summary-skip-intangible)
3309 (or (get-text-property (point) 'gnus-number)
3310 (gnus-summary-last-subject))))
3312 (defmacro gnus-summary-article-header (&optional number)
3313 "Return the header of article NUMBER."
3314 `(gnus-data-header (gnus-data-find
3315 ,(or number '(gnus-summary-article-number)))))
3317 (defmacro gnus-summary-thread-level (&optional number)
3318 "Return the level of thread that starts with article NUMBER."
3319 `(if (and (eq gnus-summary-make-false-root 'dummy)
3320 (get-text-property (point) 'gnus-intangible))
3322 (gnus-data-level (gnus-data-find
3323 ,(or number '(gnus-summary-article-number))))))
3325 (defmacro gnus-summary-article-mark (&optional number)
3326 "Return the mark of article NUMBER."
3327 `(gnus-data-mark (gnus-data-find
3328 ,(or number '(gnus-summary-article-number)))))
3330 (defmacro gnus-summary-article-pos (&optional number)
3331 "Return the position of the line of article NUMBER."
3332 `(gnus-data-pos (gnus-data-find
3333 ,(or number '(gnus-summary-article-number)))))
3335 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3336 (defmacro gnus-summary-article-subject (&optional number)
3337 "Return current subject string or nil if nothing."
3338 `(let ((headers
3339 ,(if number
3340 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3341 '(gnus-data-header (assq (gnus-summary-article-number)
3342 gnus-newsgroup-data)))))
3343 (and headers
3344 (vectorp headers)
3345 (mail-header-subject headers))))
3347 (defmacro gnus-summary-article-score (&optional number)
3348 "Return current article score."
3349 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3350 gnus-newsgroup-scored))
3351 gnus-summary-default-score 0))
3353 (defun gnus-summary-article-children (&optional number)
3354 "Return a list of article numbers that are children of article NUMBER."
3355 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3356 (level (gnus-data-level (car data)))
3357 l children)
3358 (while (and (setq data (cdr data))
3359 (> (setq l (gnus-data-level (car data))) level))
3360 (and (= (1+ level) l)
3361 (push (gnus-data-number (car data))
3362 children)))
3363 (nreverse children)))
3365 (defun gnus-summary-article-parent (&optional number)
3366 "Return the article number of the parent of article NUMBER."
3367 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3368 (gnus-data-list t)))
3369 (level (gnus-data-level (car data))))
3370 (if (zerop level)
3371 () ; This is a root.
3372 ;; We search until we find an article with a level less than
3373 ;; this one. That function has to be the parent.
3374 (while (and (setq data (cdr data))
3375 (not (< (gnus-data-level (car data)) level))))
3376 (and data (gnus-data-number (car data))))))
3378 (defun gnus-unread-mark-p (mark)
3379 "Say whether MARK is the unread mark."
3380 (= mark gnus-unread-mark))
3382 (defun gnus-read-mark-p (mark)
3383 "Say whether MARK is one of the marks that mark as read.
3384 This is all marks except unread, ticked, dormant, and expirable."
3385 (not (or (= mark gnus-unread-mark)
3386 (= mark gnus-ticked-mark)
3387 (= mark gnus-spam-mark)
3388 (= mark gnus-dormant-mark)
3389 (= mark gnus-expirable-mark))))
3391 (defmacro gnus-article-mark (number)
3392 "Return the MARK of article NUMBER.
3393 This macro should only be used when computing the mark the \"first\"
3394 time; i.e., when generating the summary lines. After that,
3395 `gnus-summary-article-mark' should be used to examine the
3396 marks of articles."
3397 `(cond
3398 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3399 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3400 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3401 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3402 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3403 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3404 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3405 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3406 gnus-ancient-mark))))
3408 ;; Saving hidden threads.
3410 (defmacro gnus-save-hidden-threads (&rest forms)
3411 "Save hidden threads, eval FORMS, and restore the hidden threads."
3412 (let ((config (make-symbol "config")))
3413 `(let ((,config (gnus-hidden-threads-configuration)))
3414 (unwind-protect
3415 (save-excursion
3416 ,@forms)
3417 (gnus-restore-hidden-threads-configuration ,config)))))
3418 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3419 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3421 (defun gnus-data-compute-positions ()
3422 "Compute the positions of all articles."
3423 (setq gnus-newsgroup-data-reverse nil)
3424 (let ((data gnus-newsgroup-data))
3425 (save-excursion
3426 (gnus-save-hidden-threads
3427 (gnus-summary-show-all-threads)
3428 (goto-char (point-min))
3429 (while data
3430 (while (get-text-property (point) 'gnus-intangible)
3431 (forward-line 1))
3432 (gnus-data-set-pos (car data) (+ (point) 3))
3433 (setq data (cdr data))
3434 (forward-line 1))))))
3436 (defun gnus-hidden-threads-configuration ()
3437 "Return the current hidden threads configuration."
3438 (save-excursion
3439 (let (config)
3440 (goto-char (point-min))
3441 (while (not (eobp))
3442 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3443 (push (save-excursion (forward-line 0) (point)) config))
3444 (forward-line 1))
3445 config)))
3447 (defun gnus-restore-hidden-threads-configuration (config)
3448 "Restore hidden threads configuration from CONFIG."
3449 (save-excursion
3450 (let (point (inhibit-read-only t))
3451 (while (setq point (pop config))
3452 (goto-char point)
3453 (gnus-summary-hide-thread)))))
3455 ;; Various summary mode internalish functions.
3457 (defun gnus-mouse-pick-article (e)
3458 (interactive "e")
3459 (mouse-set-point e)
3460 (gnus-summary-next-page nil t))
3462 (defun gnus-summary-set-display-table ()
3463 "Change the display table.
3464 Odd characters have a tendency to mess
3465 up nicely formatted displays - we make all possible glyphs
3466 display only a single character."
3468 ;; We start from the standard display table, if any.
3469 (let ((table (or (copy-sequence standard-display-table)
3470 (make-display-table)))
3471 (i 32))
3472 ;; Nix out all the control chars...
3473 (while (>= (setq i (1- i)) 0)
3474 (gnus-put-display-table i [??] table))
3475 ;; ... but not newline and cr, of course. (cr is necessary for the
3476 ;; selective display).
3477 (gnus-put-display-table ?\n nil table)
3478 (gnus-put-display-table ?\r nil table)
3479 ;; We keep TAB as well.
3480 (gnus-put-display-table ?\t nil table)
3481 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3482 ;; Emacs 23 (unicode), that are not set already.
3483 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3485 256)))
3486 (while (>= (setq i (1- i)) 127)
3487 ;; Only modify if the entry is nil.
3488 (unless (gnus-get-display-table i table)
3489 (gnus-put-display-table i [??] table))))
3490 (setq buffer-display-table table)))
3492 (defun gnus-summary-set-article-display-arrow (pos)
3493 "Update the overlay arrow to point to line at position POS."
3494 (when gnus-summary-display-arrow
3495 (make-local-variable 'overlay-arrow-position)
3496 (make-local-variable 'overlay-arrow-string)
3497 (save-excursion
3498 (goto-char pos)
3499 (beginning-of-line)
3500 (unless overlay-arrow-position
3501 (setq overlay-arrow-position (make-marker)))
3502 (setq overlay-arrow-string "=>"
3503 overlay-arrow-position (set-marker overlay-arrow-position
3504 (point)
3505 (current-buffer))))))
3507 (defun gnus-summary-setup-buffer (group)
3508 "Initialize summary buffer.
3509 If the setup was successful, non-nil is returned."
3510 (let ((buffer (gnus-summary-buffer-name group))
3511 (dead-name (concat "*Dead Summary "
3512 (gnus-group-decoded-name group) "*")))
3513 ;; If a dead summary buffer exists, we kill it.
3514 (when (gnus-buffer-live-p dead-name)
3515 (gnus-kill-buffer dead-name))
3516 (if (get-buffer buffer)
3517 (progn
3518 (set-buffer buffer)
3519 (setq gnus-summary-buffer (current-buffer))
3520 (not gnus-newsgroup-prepared))
3521 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3522 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3523 (gnus-summary-mode group)
3524 (when (gnus-group-quit-config group)
3525 (set (make-local-variable 'gnus-single-article-buffer) nil))
3526 (make-local-variable 'gnus-article-buffer)
3527 (make-local-variable 'gnus-article-current)
3528 (make-local-variable 'gnus-original-article-buffer)
3529 (setq gnus-newsgroup-name group)
3530 ;; Set any local variables in the group parameters.
3531 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3532 t)))
3534 (defun gnus-set-global-variables ()
3535 "Set the global equivalents of the buffer-local variables.
3536 They are set to the latest values they had. These reflect the summary
3537 buffer that was in action when the last article was fetched."
3538 (when (eq major-mode 'gnus-summary-mode)
3539 (setq gnus-summary-buffer (current-buffer))
3540 (let ((name gnus-newsgroup-name)
3541 (marked gnus-newsgroup-marked)
3542 (spam gnus-newsgroup-spam-marked)
3543 (unread gnus-newsgroup-unreads)
3544 (headers gnus-current-headers)
3545 (data gnus-newsgroup-data)
3546 (summary gnus-summary-buffer)
3547 (article-buffer gnus-article-buffer)
3548 (original gnus-original-article-buffer)
3549 (gac gnus-article-current)
3550 (reffed gnus-reffed-article-number)
3551 (score-file gnus-current-score-file)
3552 (default-charset gnus-newsgroup-charset)
3553 vlist)
3554 (let ((locals gnus-newsgroup-variables))
3555 (while locals
3556 (if (consp (car locals))
3557 (push (eval (caar locals)) vlist)
3558 (push (eval (car locals)) vlist))
3559 (setq locals (cdr locals)))
3560 (setq vlist (nreverse vlist)))
3561 (with-current-buffer gnus-group-buffer
3562 (setq gnus-newsgroup-name name
3563 gnus-newsgroup-marked marked
3564 gnus-newsgroup-spam-marked spam
3565 gnus-newsgroup-unreads unread
3566 gnus-current-headers headers
3567 gnus-newsgroup-data data
3568 gnus-article-current gac
3569 gnus-summary-buffer summary
3570 gnus-article-buffer article-buffer
3571 gnus-original-article-buffer original
3572 gnus-reffed-article-number reffed
3573 gnus-current-score-file score-file
3574 gnus-newsgroup-charset default-charset)
3575 (let ((locals gnus-newsgroup-variables))
3576 (while locals
3577 (if (consp (car locals))
3578 (set (caar locals) (pop vlist))
3579 (set (car locals) (pop vlist)))
3580 (setq locals (cdr locals))))
3581 ;; The article buffer also has local variables.
3582 (when (gnus-buffer-live-p gnus-article-buffer)
3583 (set-buffer gnus-article-buffer)
3584 (setq gnus-summary-buffer summary))))))
3586 (defun gnus-summary-article-unread-p (article)
3587 "Say whether ARTICLE is unread or not."
3588 (memq article gnus-newsgroup-unreads))
3590 (defun gnus-summary-first-article-p (&optional article)
3591 "Return whether ARTICLE is the first article in the buffer."
3592 (if (not (setq article (or article (gnus-summary-article-number))))
3594 (eq article (caar gnus-newsgroup-data))))
3596 (defun gnus-summary-last-article-p (&optional article)
3597 "Return whether ARTICLE is the last article in the buffer."
3598 (if (not (setq article (or article (gnus-summary-article-number))))
3599 ;; All non-existent numbers are the last article. :-)
3601 (not (cdr (gnus-data-find-list article)))))
3603 (defun gnus-make-thread-indent-array (&optional n)
3604 (when (or n
3605 (progn (setq n 200) nil)
3606 (null gnus-thread-indent-array)
3607 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3608 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3609 gnus-thread-indent-array-level gnus-thread-indent-level)
3610 (while (>= n 0)
3611 (aset gnus-thread-indent-array n
3612 (make-string (* n gnus-thread-indent-level) ? ))
3613 (setq n (1- n)))))
3615 (defun gnus-update-summary-mark-positions ()
3616 "Compute where the summary marks are to go."
3617 (save-excursion
3618 (when (gnus-buffer-exists-p gnus-summary-buffer)
3619 (set-buffer gnus-summary-buffer))
3620 (let ((spec gnus-summary-line-format-spec)
3621 pos)
3622 (save-excursion
3623 (gnus-set-work-buffer)
3624 (let ((gnus-tmp-unread ?Z)
3625 (gnus-replied-mark ?Z)
3626 (gnus-score-below-mark ?Z)
3627 (gnus-score-over-mark ?Z)
3628 (gnus-undownloaded-mark ?Z)
3629 (gnus-summary-line-format-spec spec)
3630 (gnus-newsgroup-downloadable '(0))
3631 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3632 case-fold-search ignores)
3633 ;; Here, all marks are bound to Z.
3634 (gnus-summary-insert-line header
3635 0 nil t gnus-tmp-unread t nil "" nil 1)
3636 (goto-char (point-min))
3637 ;; Memorize the positions of the same characters as dummy marks.
3638 (while (re-search-forward "[A-D]" nil t)
3639 (push (point) ignores))
3640 (erase-buffer)
3641 ;; We use A-D as dummy marks in order to know column positions
3642 ;; where marks should be inserted.
3643 (setq gnus-tmp-unread ?A
3644 gnus-replied-mark ?B
3645 gnus-score-below-mark ?C
3646 gnus-score-over-mark ?C
3647 gnus-undownloaded-mark ?D)
3648 (gnus-summary-insert-line header
3649 0 nil t gnus-tmp-unread t nil "" nil 1)
3650 ;; Ignore characters which aren't dummy marks.
3651 (dolist (p ignores)
3652 (delete-region (goto-char (1- p)) p)
3653 (insert ?Z))
3654 (goto-char (point-min))
3655 (setq pos (list (cons 'unread
3656 (and (search-forward "A" nil t)
3657 (- (point) (point-min) 1)))))
3658 (goto-char (point-min))
3659 (push (cons 'replied (and (search-forward "B" nil t)
3660 (- (point) (point-min) 1)))
3661 pos)
3662 (goto-char (point-min))
3663 (push (cons 'score (and (search-forward "C" nil t)
3664 (- (point) (point-min) 1)))
3665 pos)
3666 (goto-char (point-min))
3667 (push (cons 'download (and (search-forward "D" nil t)
3668 (- (point) (point-min) 1)))
3669 pos)))
3670 (setq gnus-summary-mark-positions pos))))
3672 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3673 "Insert a dummy root in the summary buffer."
3674 (beginning-of-line)
3675 (gnus-add-text-properties
3676 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3677 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3679 (defun gnus-summary-extract-address-component (from)
3680 (or (car (funcall gnus-extract-address-components from))
3681 from))
3683 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3684 (let ((mail-parse-charset gnus-newsgroup-charset)
3685 (ignored-from-addresses (gnus-ignored-from-addresses))
3686 ; Is it really necessary to do this next part for each summary line?
3687 ; Luckily, doesn't seem to slow things down much.
3688 (mail-parse-ignored-charsets
3689 (with-current-buffer gnus-summary-buffer
3690 gnus-newsgroup-ignored-charsets)))
3692 (and ignored-from-addresses
3693 (string-match ignored-from-addresses gnus-tmp-from)
3694 (let ((extra-headers (mail-header-extra header))
3696 newsgroups)
3697 (cond
3698 ((setq to (cdr (assq 'To extra-headers)))
3699 (concat gnus-summary-to-prefix
3700 (inline
3701 (gnus-summary-extract-address-component
3702 (funcall gnus-decode-encoded-address-function to)))))
3703 ((setq newsgroups
3705 (cdr (assq 'Newsgroups extra-headers))
3706 (and
3707 (memq 'Newsgroups gnus-extra-headers)
3708 (eq (car (gnus-find-method-for-group
3709 gnus-newsgroup-name)) 'nntp)
3710 (gnus-group-real-name gnus-newsgroup-name))))
3711 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3712 (gnus-string-mark-left-to-right
3713 (inline
3714 (gnus-summary-extract-address-component gnus-tmp-from))))))
3716 (defun gnus-summary-insert-line (gnus-tmp-header
3717 gnus-tmp-level gnus-tmp-current
3718 undownloaded gnus-tmp-unread gnus-tmp-replied
3719 gnus-tmp-expirable gnus-tmp-subject-or-nil
3720 &optional gnus-tmp-dummy gnus-tmp-score
3721 gnus-tmp-process)
3722 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3723 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3724 gnus-tmp-level)))
3725 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3726 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3727 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3728 (gnus-tmp-score-char
3729 (if (or (null gnus-summary-default-score)
3730 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3731 gnus-summary-zcore-fuzz))
3732 ? ;Whitespace
3733 (if (< gnus-tmp-score gnus-summary-default-score)
3734 gnus-score-below-mark gnus-score-over-mark)))
3735 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3736 (gnus-tmp-replied
3737 (cond (gnus-tmp-process gnus-process-mark)
3738 ((memq gnus-tmp-current gnus-newsgroup-cached)
3739 gnus-cached-mark)
3740 (gnus-tmp-replied gnus-replied-mark)
3741 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3742 gnus-forwarded-mark)
3743 ((memq gnus-tmp-current gnus-newsgroup-saved)
3744 gnus-saved-mark)
3745 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3746 gnus-unseen-mark)
3747 (t gnus-no-mark)))
3748 (gnus-tmp-downloaded
3749 (cond (undownloaded
3750 gnus-undownloaded-mark)
3751 (gnus-newsgroup-agentized
3752 gnus-downloaded-mark)
3754 gnus-no-mark)))
3755 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3756 (gnus-tmp-name
3757 (cond
3758 ((string-match "<[^>]+> *$" gnus-tmp-from)
3759 (let ((beg (match-beginning 0)))
3760 (or (and (string-match "^\".+\"" gnus-tmp-from)
3761 (substring gnus-tmp-from 1 (1- (match-end 0))))
3762 (substring gnus-tmp-from 0 beg))))
3763 ((string-match "(.+)" gnus-tmp-from)
3764 (substring gnus-tmp-from
3765 (1+ (match-beginning 0)) (1- (match-end 0))))
3766 (t gnus-tmp-from)))
3767 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3768 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3769 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3770 (inhibit-read-only t))
3771 (when (string= gnus-tmp-name "")
3772 (setq gnus-tmp-name gnus-tmp-from))
3773 (unless (numberp gnus-tmp-lines)
3774 (setq gnus-tmp-lines -1))
3775 (if (= gnus-tmp-lines -1)
3776 (setq gnus-tmp-lines "?")
3777 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3778 (condition-case ()
3779 (gnus-put-text-property
3780 (point)
3781 (progn (eval gnus-summary-line-format-spec) (point))
3782 'gnus-number gnus-tmp-number)
3783 (error (gnus-message 5 "Error updating the summary line")))
3784 (when (gnus-visual-p 'summary-highlight 'highlight)
3785 (forward-line -1)
3786 (gnus-summary-highlight-line)
3787 (gnus-run-hooks 'gnus-summary-update-hook)
3788 (forward-line 1))))
3790 (defun gnus-summary-update-line (&optional dont-update)
3791 "Update summary line after change."
3792 (when (and gnus-summary-default-score
3793 (not gnus-summary-inhibit-highlight))
3794 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3795 (article (gnus-summary-article-number))
3796 (score (gnus-summary-article-score article)))
3797 (unless dont-update
3798 (if (and gnus-summary-mark-below
3799 (< (gnus-summary-article-score)
3800 gnus-summary-mark-below))
3801 ;; This article has a low score, so we mark it as read.
3802 (when (memq article gnus-newsgroup-unreads)
3803 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3804 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3805 ;; This article was previously marked as read on account
3806 ;; of a low score, but now it has risen, so we mark it as
3807 ;; unread.
3808 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3809 (gnus-summary-update-mark
3810 (if (or (null gnus-summary-default-score)
3811 (<= (abs (- score gnus-summary-default-score))
3812 gnus-summary-zcore-fuzz))
3813 ? ;Whitespace
3814 (if (< score gnus-summary-default-score)
3815 gnus-score-below-mark gnus-score-over-mark))
3816 'score))
3817 ;; Do visual highlighting.
3818 (when (gnus-visual-p 'summary-highlight 'highlight)
3819 (gnus-summary-highlight-line)
3820 (gnus-run-hooks 'gnus-summary-update-hook)))))
3822 (defvar gnus-tmp-new-adopts nil)
3824 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3825 "Return the number of articles in THREAD.
3826 This may be 0 in some cases -- if none of the articles in
3827 the thread are to be displayed."
3828 (let* ((number
3829 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3830 (cond
3831 ((not (listp thread))
3833 ((and (consp thread) (cdr thread))
3834 (apply
3835 '+ 1 (mapcar
3836 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3837 ((null thread)
3839 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3841 (t 0))))
3842 (when (and level (zerop level) gnus-tmp-new-adopts)
3843 (incf number
3844 (apply '+ (mapcar
3845 'gnus-summary-number-of-articles-in-thread
3846 gnus-tmp-new-adopts))))
3847 (if char
3848 (if (> number 1) gnus-not-empty-thread-mark
3849 gnus-empty-thread-mark)
3850 number)))
3852 (defsubst gnus-summary-line-message-size (head)
3853 "Return pretty-printed version of message size.
3854 This function is intended to be used in
3855 `gnus-summary-line-format-alist'."
3856 (let ((c (or (mail-header-chars head) -1)))
3857 (cond ((< c 0) "n/a") ; chars not available
3858 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3859 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3860 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3861 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3863 (defcustom gnus-user-date-format-alist
3864 '(((gnus-seconds-today) . "Today, %H:%M")
3865 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3866 (604800 . "%A %H:%M") ; That's one week
3867 ((gnus-seconds-month) . "%A %d")
3868 ((gnus-seconds-year) . "%B %d")
3869 (t . "%b %d %Y")) ; This one is used when no other
3870 ; does match
3871 "Specifies date format depending on age of article.
3872 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3873 seconds) or a Lisp expression evaluating to a number. When the age of
3874 the article is less than this number, then use `format-time-string'
3875 with the corresponding FORMAT for displaying the date of the article.
3876 If AGE is not a number or a Lisp expression evaluating to a
3877 non-number, then the corresponding FORMAT is used as a default value.
3879 Note that the list is processed from the beginning, so it should be
3880 sorted by ascending AGE. Also note that items following the first
3881 non-number AGE will be ignored.
3883 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3884 and `gnus-seconds-year' in the AGE spec. They return the number of
3885 seconds passed since the start of today, of this month, of this year,
3886 respectively."
3887 :version "24.1"
3888 :group 'gnus-summary-format
3889 :type '(alist :key-type sexp :value-type string))
3891 (defun gnus-user-date (messy-date)
3892 "Format the messy-date according to `gnus-user-date-format-alist'.
3893 Returns \" ? \" if there's bad input or if another error occurs.
3894 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3895 (condition-case ()
3896 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3897 (now (gnus-float-time))
3898 ;;If we don't find something suitable we'll use this one
3899 (my-format "%b %d '%y"))
3900 (let* ((difference (- now messy-date))
3901 (templist gnus-user-date-format-alist)
3902 (top (eval (caar templist))))
3903 (while (if (numberp top) (< top difference) (not top))
3904 (progn
3905 (setq templist (cdr templist))
3906 (setq top (eval (caar templist)))))
3907 (if (stringp (cdr (car templist)))
3908 (setq my-format (cdr (car templist)))))
3909 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3910 (error " ? ")))
3912 (defun gnus-summary-set-local-parameters (group)
3913 "Go through the local params of GROUP and set all variable specs in that list."
3914 (let ((vars '(quit-config active))) ; Ignore things that aren't
3915 ; really variables.
3916 (dolist (elem (gnus-group-find-parameter group))
3917 (and (consp elem) ; Has to be a cons.
3918 (consp (cdr elem)) ; The cdr has to be a list.
3919 (symbolp (car elem)) ; Has to be a symbol in there.
3920 (not (memq (car elem) vars))
3921 (ignore-errors
3922 (push (car elem) vars)
3923 ;; Variables like `gnus-show-threads' that are globally
3924 ;; bound, if used as group parameters, need to get to be
3925 ;; buffer-local, whereas just parameters like `gcc-self',
3926 ;; `timestamp', etc. should not be bound as variables.
3927 (if (boundp (car elem))
3928 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3929 (eval (nth 1 elem))))))))
3931 (defun gnus-summary-read-group (group &optional show-all no-article
3932 kill-buffer no-display backward
3933 select-articles)
3934 "Start reading news in newsgroup GROUP.
3935 If SHOW-ALL is non-nil, already read articles are also listed.
3936 If NO-ARTICLE is non-nil, no article is selected initially.
3937 If NO-DISPLAY, don't generate the summary buffer contents.
3938 If KILL-BUFFER, it should be a buffer that's killed once the new
3939 summary buffer has been generated.
3940 If BACKWARD, move point to the previous group in the group buffer
3941 If SELECT-ARTICLES, only select those articles from GROUP."
3942 (let (result)
3943 (while (and group
3944 (null (setq result
3945 (let ((gnus-auto-select-next nil))
3946 (or (gnus-summary-read-group-1
3947 group show-all no-article
3948 kill-buffer no-display
3949 select-articles)
3950 (setq show-all nil
3951 select-articles nil)))))
3952 (eq gnus-auto-select-next 'quietly))
3953 (set-buffer gnus-group-buffer)
3954 ;; The entry function called above goes to the next
3955 ;; group automatically, so we go two groups back
3956 ;; if we are searching for the previous group.
3957 (when backward
3958 (gnus-group-prev-unread-group 2))
3959 (if (not (equal group (gnus-group-group-name)))
3960 (setq group (gnus-group-group-name))
3961 (setq group nil)))
3962 result))
3964 (defun gnus-summary-read-group-1 (group show-all no-article
3965 kill-buffer no-display
3966 &optional select-articles)
3967 ;; Killed foreign groups can't be entered.
3968 ;; (when (and (not (gnus-group-native-p group))
3969 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3970 ;; (error "Dead non-native groups can't be entered"))
3971 (gnus-message 7 "Retrieving newsgroup: %s..."
3972 (gnus-group-decoded-name group))
3973 (let* ((new-group (gnus-summary-setup-buffer group))
3974 (quit-config (gnus-group-quit-config group))
3975 (did-select (and new-group (gnus-select-newsgroup
3976 group show-all select-articles))))
3977 (cond
3978 ;; This summary buffer exists already, so we just select it.
3979 ((not new-group)
3980 (gnus-set-global-variables)
3981 (when kill-buffer
3982 (gnus-kill-or-deaden-summary kill-buffer))
3983 (gnus-configure-windows 'summary 'force)
3984 (gnus-set-mode-line 'summary)
3985 (gnus-summary-position-point)
3986 (message "")
3988 ;; We couldn't select this group.
3989 ((null did-select)
3990 (when (and (eq major-mode 'gnus-summary-mode)
3991 (not (equal (current-buffer) kill-buffer)))
3992 (kill-buffer (current-buffer))
3993 (if (not quit-config)
3994 (progn
3995 ;; Update the info -- marks might need to be removed,
3996 ;; for instance.
3997 (gnus-summary-update-info)
3998 (set-buffer gnus-group-buffer)
3999 (gnus-group-jump-to-group group)
4000 (gnus-group-next-unread-group 1))
4001 (gnus-handle-ephemeral-exit quit-config)))
4002 (if (null (gnus-list-of-unread-articles group))
4003 (gnus-message 3 "Group %s contains no messages" group)
4004 (gnus-message 3 "Can't select group"))
4005 nil)
4006 ;; The user did a `C-g' while prompting for number of articles,
4007 ;; so we exit this group.
4008 ((eq did-select 'quit)
4009 (and (eq major-mode 'gnus-summary-mode)
4010 (not (equal (current-buffer) kill-buffer))
4011 (kill-buffer (current-buffer)))
4012 (when kill-buffer
4013 (gnus-kill-or-deaden-summary kill-buffer))
4014 (if (not quit-config)
4015 (progn
4016 (set-buffer gnus-group-buffer)
4017 (gnus-group-jump-to-group group)
4018 (gnus-configure-windows 'group 'force))
4019 (gnus-handle-ephemeral-exit quit-config))
4020 ;; Finally signal the quit.
4021 (signal 'quit nil))
4022 ;; The group was successfully selected.
4024 (gnus-set-global-variables)
4025 ;; Save the active value in effect when the group was entered.
4026 (setq gnus-newsgroup-active
4027 (gnus-copy-sequence
4028 (gnus-active gnus-newsgroup-name)))
4029 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4030 ;; You can change the summary buffer in some way with this hook.
4031 (gnus-run-hooks 'gnus-select-group-hook)
4032 (when (memq 'summary (gnus-update-format-specifications
4033 nil 'summary 'summary-mode 'summary-dummy))
4034 ;; The format specification for the summary line was updated,
4035 ;; so we need to update the mark positions as well.
4036 (gnus-update-summary-mark-positions))
4037 ;; Do score processing.
4038 (when gnus-use-scoring
4039 (gnus-possibly-score-headers))
4040 ;; Check whether to fill in the gaps in the threads.
4041 (when gnus-build-sparse-threads
4042 (gnus-build-sparse-threads))
4043 ;; Find the initial limit.
4044 (if show-all
4045 (let ((gnus-newsgroup-dormant nil))
4046 (gnus-summary-initial-limit show-all))
4047 (gnus-summary-initial-limit show-all))
4048 ;; Generate the summary buffer.
4049 (unless no-display
4050 (gnus-summary-prepare))
4051 (when gnus-use-trees
4052 (gnus-tree-open group)
4053 (setq gnus-summary-highlight-line-function
4054 'gnus-tree-highlight-article))
4055 ;; If the summary buffer is empty, but there are some low-scored
4056 ;; articles or some excluded dormants, we include these in the
4057 ;; buffer.
4058 (when (and (zerop (buffer-size))
4059 (not no-display))
4060 (cond (gnus-newsgroup-dormant
4061 (gnus-summary-limit-include-dormant))
4062 ((and gnus-newsgroup-scored show-all)
4063 (gnus-summary-limit-include-expunged t))))
4064 ;; Function `gnus-apply-kill-file' must be called in this hook.
4065 (gnus-run-hooks 'gnus-apply-kill-hook)
4066 (if (and (zerop (buffer-size))
4067 (not no-display))
4068 (progn
4069 ;; This newsgroup is empty.
4070 (gnus-summary-catchup-and-exit nil t)
4071 (gnus-message 6 "No unread news")
4072 (when kill-buffer
4073 (gnus-kill-or-deaden-summary kill-buffer))
4074 ;; Return nil from this function.
4075 nil)
4076 ;; Hide conversation thread subtrees. We cannot do this in
4077 ;; gnus-summary-prepare-hook since kill processing may not
4078 ;; work with hidden articles.
4079 (gnus-summary-maybe-hide-threads)
4080 (gnus-configure-windows 'summary)
4081 (when kill-buffer
4082 (gnus-kill-or-deaden-summary kill-buffer))
4083 (gnus-summary-auto-select-subject)
4084 ;; Show first unread article if requested.
4085 (if (and (not no-article)
4086 (not no-display)
4087 gnus-newsgroup-unreads
4088 gnus-auto-select-first)
4089 (progn
4090 (let ((art (gnus-summary-article-number)))
4091 (unless (and (not gnus-plugged)
4092 (or (memq art gnus-newsgroup-undownloaded)
4093 (memq art gnus-newsgroup-downloadable)))
4094 (gnus-summary-goto-article art))))
4095 ;; Don't select any articles.
4096 (gnus-summary-position-point)
4097 (gnus-configure-windows 'summary 'force)
4098 (gnus-set-mode-line 'summary))
4099 (when (and gnus-auto-center-group
4100 (get-buffer-window gnus-group-buffer t))
4101 ;; Gotta use windows, because recenter does weird stuff if
4102 ;; the current buffer ain't the displayed window.
4103 (let ((owin (selected-window)))
4104 (select-window (get-buffer-window gnus-group-buffer t))
4105 (when (gnus-group-goto-group group)
4106 (recenter))
4107 (select-window owin)))
4108 ;; Mark this buffer as "prepared".
4109 (setq gnus-newsgroup-prepared t)
4110 (gnus-run-hooks 'gnus-summary-prepared-hook)
4111 (unless (gnus-ephemeral-group-p group)
4112 (gnus-group-update-group group nil t))
4113 t)))))
4115 (defun gnus-summary-auto-select-subject ()
4116 "Select the subject line on initial group entry."
4117 (goto-char (point-min))
4118 (cond
4119 ((eq gnus-auto-select-subject 'best)
4120 (gnus-summary-best-unread-subject))
4121 ((eq gnus-auto-select-subject 'unread)
4122 (gnus-summary-first-unread-subject))
4123 ((eq gnus-auto-select-subject 'unseen)
4124 (gnus-summary-first-unseen-subject))
4125 ((eq gnus-auto-select-subject 'unseen-or-unread)
4126 (gnus-summary-first-unseen-or-unread-subject))
4127 ((eq gnus-auto-select-subject 'first)
4128 ;; Do nothing.
4130 ((functionp gnus-auto-select-subject)
4131 (funcall gnus-auto-select-subject))))
4133 (defun gnus-summary-prepare ()
4134 "Generate the summary buffer."
4135 (interactive)
4136 (let ((inhibit-read-only t))
4137 (erase-buffer)
4138 (setq gnus-newsgroup-data nil
4139 gnus-newsgroup-data-reverse nil)
4140 (gnus-run-hooks 'gnus-summary-generate-hook)
4141 ;; Generate the buffer, either with threads or without.
4142 (when gnus-newsgroup-headers
4143 (gnus-summary-prepare-threads
4144 (if gnus-show-threads
4145 (gnus-sort-gathered-threads
4146 (funcall gnus-summary-thread-gathering-function
4147 (gnus-sort-threads
4148 (gnus-cut-threads (gnus-make-threads)))))
4149 ;; Unthreaded display.
4150 (gnus-sort-articles gnus-newsgroup-headers))))
4151 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4152 ;; Call hooks for modifying summary buffer.
4153 (goto-char (point-min))
4154 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4156 (defsubst gnus-general-simplify-subject (subject)
4157 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4158 (setq subject
4159 (cond
4160 ;; Truncate the subject.
4161 (gnus-simplify-subject-functions
4162 (gnus-map-function gnus-simplify-subject-functions subject))
4163 ((numberp gnus-summary-gather-subject-limit)
4164 (setq subject (gnus-simplify-subject-re subject))
4165 (if (> (length subject) gnus-summary-gather-subject-limit)
4166 (substring subject 0 gnus-summary-gather-subject-limit)
4167 subject))
4168 ;; Fuzzily simplify it.
4169 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4170 (gnus-simplify-subject-fuzzy subject))
4171 ;; Just remove the leading "Re:".
4173 (gnus-simplify-subject-re subject))))
4175 (if (and gnus-summary-gather-exclude-subject
4176 (string-match gnus-summary-gather-exclude-subject subject))
4177 nil ; This article shouldn't be gathered
4178 subject))
4180 (defun gnus-summary-simplify-subject-query ()
4181 "Query where the respool algorithm would put this article."
4182 (interactive)
4183 (gnus-summary-select-article)
4184 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4186 (defun gnus-gather-threads-by-subject (threads)
4187 "Gather threads by looking at Subject headers."
4188 (if (not gnus-summary-make-false-root)
4189 threads
4190 (let ((hashtb (gnus-make-hashtable 1024))
4191 (prev threads)
4192 (result threads)
4193 subject hthread whole-subject)
4194 (while threads
4195 (setq subject (gnus-general-simplify-subject
4196 (setq whole-subject (mail-header-subject
4197 (caar threads)))))
4198 (when subject
4199 (if (setq hthread (gnus-gethash subject hashtb))
4200 (progn
4201 ;; We enter a dummy root into the thread, if we
4202 ;; haven't done that already.
4203 (unless (stringp (caar hthread))
4204 (setcar hthread (list whole-subject (car hthread))))
4205 ;; We add this new gathered thread to this gathered
4206 ;; thread.
4207 (setcdr (car hthread)
4208 (nconc (cdar hthread) (list (car threads))))
4209 ;; Remove it from the list of threads.
4210 (setcdr prev (cdr threads))
4211 (setq threads prev))
4212 ;; Enter this thread into the hash table.
4213 (gnus-sethash subject
4214 (if gnus-summary-make-false-root-always
4215 (progn
4216 ;; If you want a dummy root above all
4217 ;; threads...
4218 (setcar threads (list whole-subject
4219 (car threads)))
4220 threads)
4221 threads)
4222 hashtb)))
4223 (setq prev threads)
4224 (setq threads (cdr threads)))
4225 result)))
4227 (defun gnus-gather-threads-by-references (threads)
4228 "Gather threads by looking at References headers."
4229 (let ((idhashtb (gnus-make-hashtable 1024))
4230 (thhashtb (gnus-make-hashtable 1024))
4231 (prev threads)
4232 (result threads)
4233 ids references id gthread gid entered ref)
4234 (while threads
4235 (when (setq references (mail-header-references (caar threads)))
4236 (setq id (mail-header-id (caar threads))
4237 ids (inline (gnus-split-references references))
4238 entered nil)
4239 (while (setq ref (pop ids))
4240 (setq ids (delete ref ids))
4241 (if (not (setq gid (gnus-gethash ref idhashtb)))
4242 (progn
4243 (gnus-sethash ref id idhashtb)
4244 (gnus-sethash id threads thhashtb))
4245 (setq gthread (gnus-gethash gid thhashtb))
4246 (unless entered
4247 ;; We enter a dummy root into the thread, if we
4248 ;; haven't done that already.
4249 (unless (stringp (caar gthread))
4250 (setcar gthread (list (mail-header-subject (caar gthread))
4251 (car gthread))))
4252 ;; We add this new gathered thread to this gathered
4253 ;; thread.
4254 (setcdr (car gthread)
4255 (nconc (cdar gthread) (list (car threads)))))
4256 ;; Add it into the thread hash table.
4257 (gnus-sethash id gthread thhashtb)
4258 (setq entered t)
4259 ;; Remove it from the list of threads.
4260 (setcdr prev (cdr threads))
4261 (setq threads prev))))
4262 (setq prev threads)
4263 (setq threads (cdr threads)))
4264 result))
4266 (defun gnus-sort-gathered-threads (threads)
4267 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4268 (let ((result threads))
4269 (while threads
4270 (when (stringp (caar threads))
4271 (setcdr (car threads)
4272 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4273 (setq threads (cdr threads)))
4274 result))
4276 (defun gnus-thread-loop-p (root thread)
4277 "Say whether ROOT is in THREAD."
4278 (let ((stack (list thread))
4279 (infloop 0)
4281 (while (setq thread (pop stack))
4282 (setq th (cdr thread))
4283 (while (and th
4284 (not (eq (caar th) root)))
4285 (pop th))
4286 (if th
4287 ;; We have found a loop.
4288 (let (ref-dep)
4289 (setcdr thread (delq (car th) (cdr thread)))
4290 (if (boundp (setq ref-dep (intern "none"
4291 gnus-newsgroup-dependencies)))
4292 (setcdr (symbol-value ref-dep)
4293 (nconc (cdr (symbol-value ref-dep))
4294 (list (car th))))
4295 (set ref-dep (list nil (car th))))
4296 (setq infloop 1
4297 stack nil))
4298 ;; Push all the subthreads onto the stack.
4299 (push (cdr thread) stack)))
4300 infloop))
4302 (defun gnus-make-threads ()
4303 "Go through the dependency hashtb and find the roots. Return all threads."
4304 (let (threads)
4305 (while (catch 'infloop
4306 (mapatoms
4307 (lambda (refs)
4308 ;; Deal with self-referencing References loops.
4309 (when (and (car (symbol-value refs))
4310 (not (zerop
4311 (apply
4313 (mapcar
4314 (lambda (thread)
4315 (gnus-thread-loop-p
4316 (car (symbol-value refs)) thread))
4317 (cdr (symbol-value refs)))))))
4318 (setq threads nil)
4319 (throw 'infloop t))
4320 (unless (car (symbol-value refs))
4321 ;; These threads do not refer back to any other
4322 ;; articles, so they're roots.
4323 (setq threads (append (cdr (symbol-value refs)) threads))))
4324 gnus-newsgroup-dependencies)))
4325 threads))
4327 ;; Build the thread tree.
4328 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4329 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4331 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4332 if it was already present.
4334 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4335 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4336 Message-IDs will be renamed to a unique Message-ID before being
4337 entered.
4339 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4340 (let* ((id (mail-header-id header))
4341 (id-dep (and id (intern id dependencies)))
4342 parent-id ref ref-dep ref-header replaced)
4343 ;; Enter this `header' in the `dependencies' table.
4344 (cond
4345 ((not id-dep)
4346 (setq header nil))
4347 ;; The first two cases do the normal part: enter a new `header'
4348 ;; in the `dependencies' table.
4349 ((not (boundp id-dep))
4350 (set id-dep (list header)))
4351 ((null (car (symbol-value id-dep)))
4352 (setcar (symbol-value id-dep) header))
4354 ;; From here the `header' was already present in the
4355 ;; `dependencies' table.
4356 (force-new
4357 ;; Overrides an existing entry;
4358 ;; just set the header part of the entry.
4359 (setcar (symbol-value id-dep) header)
4360 (setq replaced t))
4362 ;; Renames the existing `header' to a unique Message-ID.
4363 ((not gnus-summary-ignore-duplicates)
4364 ;; An article with this Message-ID has already been seen.
4365 ;; We rename the Message-ID.
4366 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4367 (list header))
4368 (mail-header-set-id header id))
4370 ;; The last case ignores an existing entry, except it adds any
4371 ;; additional Xrefs (in case the two articles came from different
4372 ;; servers.
4373 ;; Also sets `header' to `nil' meaning that the `dependencies'
4374 ;; table was *not* modified.
4376 (mail-header-set-xref
4377 (car (symbol-value id-dep))
4378 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4380 (or (mail-header-xref header) "")))
4381 (setq header nil)))
4383 (when (and header (not replaced))
4384 ;; First check that we are not creating a References loop.
4385 (setq parent-id (gnus-parent-id (mail-header-references header)))
4386 (setq ref parent-id)
4387 (while (and ref
4388 (setq ref-dep (intern-soft ref dependencies))
4389 (boundp ref-dep)
4390 (setq ref-header (car (symbol-value ref-dep))))
4391 (if (string= id ref)
4392 ;; Yuk! This is a reference loop. Make the article be a
4393 ;; root article.
4394 (progn
4395 (mail-header-set-references (car (symbol-value id-dep)) "none")
4396 (setq ref nil)
4397 (setq parent-id nil))
4398 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4399 (setq ref-dep (intern (or parent-id "none") dependencies))
4400 (if (boundp ref-dep)
4401 (setcdr (symbol-value ref-dep)
4402 (nconc (cdr (symbol-value ref-dep))
4403 (list (symbol-value id-dep))))
4404 (set ref-dep (list nil (symbol-value id-dep)))))
4405 header))
4407 (defun gnus-extract-message-id-from-in-reply-to (string)
4408 (if (string-match "<[^>]+>" string)
4409 (substring string (match-beginning 0) (match-end 0))
4410 nil))
4412 (defun gnus-build-sparse-threads ()
4413 (let ((headers gnus-newsgroup-headers)
4414 (mail-parse-charset gnus-newsgroup-charset)
4415 (gnus-summary-ignore-duplicates t)
4416 header references generation relations
4417 subject child end new-child date)
4418 ;; First we create an alist of generations/relations, where
4419 ;; generations is how much we trust the relation, and the relation
4420 ;; is parent/child.
4421 (gnus-message 7 "Making sparse threads...")
4422 (save-excursion
4423 (nnheader-set-temp-buffer " *gnus sparse threads*")
4424 (while (setq header (pop headers))
4425 (when (and (setq references (mail-header-references header))
4426 (not (string= references "")))
4427 (insert references)
4428 (setq child (mail-header-id header)
4429 subject (mail-header-subject header)
4430 date (mail-header-date header)
4431 generation 0)
4432 (while (search-backward ">" nil t)
4433 (setq end (1+ (point)))
4434 (when (search-backward "<" nil t)
4435 (setq new-child (buffer-substring (point) end))
4436 (push (list (incf generation)
4437 child (setq child new-child)
4438 subject date)
4439 relations)))
4440 (when child
4441 (push (list (1+ generation) child nil subject) relations))
4442 (erase-buffer)))
4443 (kill-buffer (current-buffer)))
4444 ;; Sort over trustworthiness.
4445 (dolist (relation (sort relations 'car-less-than-car))
4446 (when (gnus-dependencies-add-header
4447 (make-full-mail-header
4448 gnus-reffed-article-number
4449 (nth 3 relation) "" (or (nth 4 relation) "")
4450 (nth 1 relation)
4451 (or (nth 2 relation) "") 0 0 "")
4452 gnus-newsgroup-dependencies nil)
4453 (push gnus-reffed-article-number gnus-newsgroup-limit)
4454 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4455 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4456 gnus-newsgroup-reads)
4457 (decf gnus-reffed-article-number)))
4458 (gnus-message 7 "Making sparse threads...done")))
4460 (defun gnus-build-old-threads ()
4461 ;; Look at all the articles that refer back to old articles, and
4462 ;; fetch the headers for the articles that aren't there. This will
4463 ;; build complete threads - if the roots haven't been expired by the
4464 ;; server, that is.
4465 (let ((mail-parse-charset gnus-newsgroup-charset)
4466 id heads)
4467 (mapatoms
4468 (lambda (refs)
4469 (when (not (car (symbol-value refs)))
4470 (setq heads (cdr (symbol-value refs)))
4471 (while heads
4472 (if (memq (mail-header-number (caar heads))
4473 gnus-newsgroup-dormant)
4474 (setq heads (cdr heads))
4475 (setq id (symbol-name refs))
4476 (while (and (setq id (gnus-build-get-header id))
4477 (not (car (gnus-id-to-thread id)))))
4478 (setq heads nil)))))
4479 gnus-newsgroup-dependencies)))
4481 (defsubst gnus-remove-odd-characters (string)
4482 "Translate STRING into something that doesn't contain weird characters."
4483 (mm-subst-char-in-string
4484 ?\r ?\-
4485 (mm-subst-char-in-string ?\n ?\- string t) t))
4487 ;; This function has to be called with point after the article number
4488 ;; on the beginning of the line.
4489 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4490 (let ((eol (point-at-eol))
4491 (buffer (current-buffer))
4492 header references in-reply-to)
4494 ;; overview: [num subject from date id refs chars lines misc]
4495 (unwind-protect
4496 (let (x)
4497 (narrow-to-region (point) eol)
4498 (unless (eobp)
4499 (forward-char))
4501 (setq header
4502 (make-full-mail-header
4503 number ; number
4504 (condition-case () ; subject
4505 (gnus-remove-odd-characters
4506 (funcall gnus-decode-encoded-word-function
4507 (setq x (nnheader-nov-field))))
4508 (error x))
4509 (condition-case () ; from
4510 (gnus-remove-odd-characters
4511 (funcall gnus-decode-encoded-address-function
4512 (setq x (nnheader-nov-field))))
4513 (error x))
4514 (nnheader-nov-field) ; date
4515 (nnheader-nov-read-message-id number) ; id
4516 (setq references (nnheader-nov-field)) ; refs
4517 (nnheader-nov-read-integer) ; chars
4518 (nnheader-nov-read-integer) ; lines
4519 (unless (eobp)
4520 (if (looking-at "Xref: ")
4521 (goto-char (match-end 0)))
4522 (nnheader-nov-field)) ; Xref
4523 (nnheader-nov-parse-extra)))) ; extra
4525 (widen))
4527 (when (and (string= references "")
4528 (setq in-reply-to (mail-header-extra header))
4529 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4530 (mail-header-set-references
4531 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4533 (when gnus-alter-header-function
4534 (funcall gnus-alter-header-function header))
4535 (gnus-dependencies-add-header header dependencies force-new)))
4537 (defun gnus-build-get-header (id)
4538 "Look through the buffer of NOV lines and find the header to ID.
4539 Enter this line into the dependencies hash table, and return
4540 the id of the parent article (if any)."
4541 (let ((deps gnus-newsgroup-dependencies)
4542 found header)
4543 (prog1
4544 (with-current-buffer nntp-server-buffer
4545 (let ((case-fold-search nil))
4546 (goto-char (point-min))
4547 (while (and (not found)
4548 (search-forward id nil t))
4549 (beginning-of-line)
4550 (setq found (looking-at
4551 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4552 (regexp-quote id))))
4553 (or found (beginning-of-line 2)))
4554 (when found
4555 (beginning-of-line)
4556 (and
4557 (setq header (gnus-nov-parse-line
4558 (read (current-buffer)) deps))
4559 (gnus-parent-id (mail-header-references header))))))
4560 (when header
4561 (let ((number (mail-header-number header)))
4562 (push number gnus-newsgroup-limit)
4563 (push header gnus-newsgroup-headers)
4564 (if (memq number gnus-newsgroup-unselected)
4565 (progn
4566 (setq gnus-newsgroup-unreads
4567 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4568 number))
4569 (setq gnus-newsgroup-unselected
4570 (delq number gnus-newsgroup-unselected)))
4571 (push number gnus-newsgroup-ancient)))))))
4573 (defun gnus-build-all-threads ()
4574 "Read all the headers."
4575 (let ((gnus-summary-ignore-duplicates t)
4576 (mail-parse-charset gnus-newsgroup-charset)
4577 (dependencies gnus-newsgroup-dependencies)
4578 header article)
4579 (with-current-buffer nntp-server-buffer
4580 (let ((case-fold-search nil))
4581 (goto-char (point-min))
4582 (while (not (eobp))
4583 (ignore-errors
4584 (setq article (read (current-buffer))
4585 header (gnus-nov-parse-line article dependencies t)))
4586 (when header
4587 (with-current-buffer gnus-summary-buffer
4588 (push header gnus-newsgroup-headers)
4589 (if (memq (setq article (mail-header-number header))
4590 gnus-newsgroup-unselected)
4591 (progn
4592 (setq gnus-newsgroup-unreads
4593 (gnus-add-to-sorted-list
4594 gnus-newsgroup-unreads article))
4595 (setq gnus-newsgroup-unselected
4596 (delq article gnus-newsgroup-unselected)))
4597 (push article gnus-newsgroup-ancient)))
4598 (forward-line 1)))))))
4600 (defun gnus-summary-update-article-line (article header)
4601 "Update the line for ARTICLE using HEADER."
4602 (let* ((id (mail-header-id header))
4603 (thread (gnus-id-to-thread id)))
4604 (unless thread
4605 (error "Article in no thread"))
4606 ;; Update the thread.
4607 (setcar thread header)
4608 (gnus-summary-goto-subject article)
4609 (let* ((datal (gnus-data-find-list article))
4610 (data (car datal))
4611 (inhibit-read-only t)
4612 (level (gnus-summary-thread-level)))
4613 (gnus-delete-line)
4614 (let ((inserted (- (point)
4615 (progn
4616 (gnus-summary-insert-line
4617 header level nil
4618 (memq article gnus-newsgroup-undownloaded)
4619 (gnus-article-mark article)
4620 (memq article gnus-newsgroup-replied)
4621 (memq article gnus-newsgroup-expirable)
4622 ;; Only insert the Subject string when it's different
4623 ;; from the previous Subject string.
4624 (if (and
4625 gnus-show-threads
4626 (gnus-subject-equal
4627 (condition-case ()
4628 (mail-header-subject
4629 (gnus-data-header
4630 (cadr
4631 (gnus-data-find-list
4632 article
4633 (gnus-data-list t)))))
4634 ;; Error on the side of excessive subjects.
4635 (error ""))
4636 (mail-header-subject header)))
4638 (mail-header-subject header))
4639 nil (cdr (assq article gnus-newsgroup-scored))
4640 (memq article gnus-newsgroup-processable))
4641 (point)))))
4642 (when (cdr datal)
4643 (gnus-data-update-list
4644 (cdr datal)
4645 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4647 (defun gnus-summary-update-article (article &optional iheader)
4648 "Update ARTICLE in the summary buffer."
4649 (set-buffer gnus-summary-buffer)
4650 (let* ((header (gnus-summary-article-header article))
4651 (id (mail-header-id header))
4652 (data (gnus-data-find article))
4653 (thread (gnus-id-to-thread id))
4654 (references (mail-header-references header))
4655 (parent
4656 (gnus-id-to-thread
4657 (or (gnus-parent-id
4658 (when (and references
4659 (not (equal "" references)))
4660 references))
4661 "none")))
4662 (inhibit-read-only t)
4663 (old (car thread)))
4664 (when thread
4665 (unless iheader
4666 (setcar thread nil)
4667 (when parent
4668 (delq thread parent)))
4669 (if (gnus-summary-insert-subject id header)
4670 ;; Set the (possibly) new article number in the data structure.
4671 (gnus-data-set-number data (gnus-id-to-article id))
4672 (setcar thread old)
4673 nil))))
4675 (defun gnus-rebuild-thread (id &optional line)
4676 "Rebuild the thread containing ID.
4677 If LINE, insert the rebuilt thread starting on line LINE."
4678 (let ((inhibit-read-only t)
4679 old-pos current thread data)
4680 (if (not gnus-show-threads)
4681 (setq thread (list (car (gnus-id-to-thread id))))
4682 ;; Get the thread this article is part of.
4683 (setq thread (gnus-remove-thread id)))
4684 (setq old-pos (point-at-bol))
4685 (setq current (save-excursion
4686 (and (re-search-backward "[\r\n]" nil t)
4687 (gnus-summary-article-number))))
4688 ;; If this is a gathered thread, we have to go some re-gathering.
4689 (when (stringp (car thread))
4690 (let ((subject (car thread))
4691 roots thr)
4692 (setq thread (cdr thread))
4693 (while thread
4694 (unless (memq (setq thr (gnus-id-to-thread
4695 (gnus-root-id
4696 (mail-header-id (caar thread)))))
4697 roots)
4698 (push thr roots))
4699 (setq thread (cdr thread)))
4700 ;; We now have all (unique) roots.
4701 (if (= (length roots) 1)
4702 ;; All the loose roots are now one solid root.
4703 (setq thread (car roots))
4704 (setq thread (cons subject (gnus-sort-threads roots))))))
4705 (let (threads)
4706 ;; We then insert this thread into the summary buffer.
4707 (when line
4708 (goto-char (point-min))
4709 (forward-line (1- line)))
4710 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4711 (if gnus-show-threads
4712 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4713 (gnus-summary-prepare-unthreaded thread))
4714 (setq data (nreverse gnus-newsgroup-data))
4715 (setq threads gnus-newsgroup-threads))
4716 ;; We splice the new data into the data structure.
4717 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4718 ;;!!! then we want to insert at the beginning of the buffer.
4719 ;;!!! That happens to be true with Gnus now, but that may
4720 ;;!!! change in the future. Perhaps.
4721 (gnus-data-enter-list
4722 (if line nil current) data (- (point) old-pos))
4723 (setq gnus-newsgroup-threads
4724 (nconc threads gnus-newsgroup-threads))
4725 (gnus-data-compute-positions))))
4727 (defun gnus-number-to-header (number)
4728 "Return the header for article NUMBER."
4729 (let ((headers gnus-newsgroup-headers))
4730 (while (and headers
4731 (not (= number (mail-header-number (car headers)))))
4732 (pop headers))
4733 (when headers
4734 (car headers))))
4736 (defun gnus-parent-headers (in-headers &optional generation)
4737 "Return the headers of the GENERATIONth parent of HEADERS."
4738 (unless generation
4739 (setq generation 1))
4740 (let ((parent t)
4741 (headers in-headers)
4742 references)
4743 (while (and parent
4744 (not (zerop generation))
4745 (setq references (mail-header-references headers)))
4746 (setq headers (if (and references
4747 (setq parent (gnus-parent-id references)))
4748 (car (gnus-id-to-thread parent))
4749 nil))
4750 (decf generation))
4751 (and (not (eq headers in-headers))
4752 headers)))
4754 (defun gnus-id-to-thread (id)
4755 "Return the (sub-)thread where ID appears."
4756 (gnus-gethash id gnus-newsgroup-dependencies))
4758 (defun gnus-id-to-article (id)
4759 "Return the article number of ID."
4760 (let ((thread (gnus-id-to-thread id)))
4761 (when (and thread
4762 (car thread))
4763 (mail-header-number (car thread)))))
4765 (defun gnus-id-to-header (id)
4766 "Return the article headers of ID."
4767 (car (gnus-id-to-thread id)))
4769 (defun gnus-article-displayed-root-p (article)
4770 "Say whether ARTICLE is a root(ish) article."
4771 (let ((level (gnus-summary-thread-level article))
4772 (refs (mail-header-references (gnus-summary-article-header article)))
4773 particle)
4774 (cond
4775 ((null level) nil)
4776 ((zerop level) t)
4777 ((null refs) t)
4778 ((null (gnus-parent-id refs)) t)
4779 ((and (= 1 level)
4780 (null (setq particle (gnus-id-to-article
4781 (gnus-parent-id refs))))
4782 (null (gnus-summary-thread-level particle)))))))
4784 (defun gnus-root-id (id)
4785 "Return the id of the root of the thread where ID appears."
4786 (let (last-id prev)
4787 (while (and id (setq prev (car (gnus-id-to-thread id))))
4788 (setq last-id id
4789 id (gnus-parent-id (mail-header-references prev))))
4790 last-id))
4792 (defun gnus-articles-in-thread (thread)
4793 "Return the list of articles in THREAD."
4794 (cons (mail-header-number (car thread))
4795 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4797 (defun gnus-remove-thread (id &optional dont-remove)
4798 "Remove the thread that has ID in it."
4799 (let (headers thread last-id)
4800 ;; First go up in this thread until we find the root.
4801 (setq last-id (gnus-root-id id)
4802 headers (message-flatten-list (gnus-id-to-thread last-id)))
4803 ;; We have now found the real root of this thread. It might have
4804 ;; been gathered into some loose thread, so we have to search
4805 ;; through the threads to find the thread we wanted.
4806 (let ((threads gnus-newsgroup-threads)
4807 sub)
4808 (while threads
4809 (setq sub (car threads))
4810 (if (stringp (car sub))
4811 ;; This is a gathered thread, so we look at the roots
4812 ;; below it to find whether this article is in this
4813 ;; gathered root.
4814 (progn
4815 (setq sub (cdr sub))
4816 (while sub
4817 (when (member (caar sub) headers)
4818 (setq thread (car threads)
4819 threads nil
4820 sub nil))
4821 (setq sub (cdr sub))))
4822 ;; It's an ordinary thread, so we check it.
4823 (when (eq (car sub) (car headers))
4824 (setq thread sub
4825 threads nil)))
4826 (setq threads (cdr threads)))
4827 ;; If this article is in no thread, then it's a root.
4828 (if thread
4829 (unless dont-remove
4830 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4831 (setq thread (gnus-id-to-thread last-id)))
4832 (when thread
4833 (prog1
4834 thread ; We return this thread.
4835 (unless dont-remove
4836 (if (stringp (car thread))
4837 (progn
4838 ;; If we use dummy roots, then we have to remove the
4839 ;; dummy root as well.
4840 (when (eq gnus-summary-make-false-root 'dummy)
4841 ;; We go to the dummy root by going to
4842 ;; the first sub-"thread", and then one line up.
4843 (gnus-summary-goto-article
4844 (mail-header-number (caadr thread)))
4845 (forward-line -1)
4846 (gnus-delete-line)
4847 (gnus-data-compute-positions))
4848 (setq thread (cdr thread))
4849 (while thread
4850 (gnus-remove-thread-1 (car thread))
4851 (setq thread (cdr thread))))
4852 (gnus-remove-thread-1 thread))))))))
4854 (defun gnus-remove-thread-1 (thread)
4855 "Remove the thread THREAD recursively."
4856 (let ((number (mail-header-number (pop thread)))
4858 (setq thread (reverse thread))
4859 (while thread
4860 (gnus-remove-thread-1 (pop thread)))
4861 (when (setq d (gnus-data-find number))
4862 (goto-char (gnus-data-pos d))
4863 (gnus-summary-show-thread)
4864 (gnus-data-remove
4865 number
4866 (- (point-at-bol)
4867 (prog1
4868 (1+ (point-at-eol))
4869 (gnus-delete-line)))))))
4871 (defun gnus-sort-threads-recursive (threads func)
4872 (sort (mapcar (lambda (thread)
4873 (cons (car thread)
4874 (and (cdr thread)
4875 (gnus-sort-threads-recursive (cdr thread) func))))
4876 threads) func))
4878 (defun gnus-sort-threads-loop (threads func)
4879 (let* ((superthread (cons nil threads))
4880 (stack (list (cons superthread threads)))
4881 remaining-threads thread)
4882 (while stack
4883 (setq remaining-threads (cdr (car stack)))
4884 (if remaining-threads
4885 (progn (setq thread (car remaining-threads))
4886 (setcdr (car stack) (cdr remaining-threads))
4887 (if (cdr thread)
4888 (push (cons thread (cdr thread)) stack)))
4889 (setq thread (caar stack))
4890 (setcdr thread (sort (cdr thread) func))
4891 (pop stack)))
4892 (cdr superthread)))
4894 (defun gnus-sort-threads (threads)
4895 "Sort THREADS."
4896 (if (not gnus-thread-sort-functions)
4897 threads
4898 (gnus-message 8 "Sorting threads...")
4899 (prog1
4900 (condition-case nil
4901 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4902 (gnus-sort-threads-recursive
4903 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4904 ;; Even after binding max-lisp-eval-depth, the recursive
4905 ;; sorter might fail for very long threads. In that case,
4906 ;; try using a (less well-tested) non-recursive sorter.
4907 (error (gnus-message 9 "Sorting threads with loop...")
4908 (gnus-sort-threads-loop
4909 threads (gnus-make-sort-function
4910 gnus-thread-sort-functions))))
4911 (gnus-message 8 "Sorting threads...done"))))
4913 (defun gnus-sort-articles (articles)
4914 "Sort ARTICLES."
4915 (when gnus-article-sort-functions
4916 (gnus-message 7 "Sorting articles...")
4917 (prog1
4918 (setq gnus-newsgroup-headers
4919 (sort articles (gnus-make-sort-function
4920 gnus-article-sort-functions)))
4921 (gnus-message 7 "Sorting articles...done"))))
4923 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4924 (defmacro gnus-thread-header (thread)
4925 "Return header of first article in THREAD.
4926 Note that THREAD must never, ever be anything else than a variable -
4927 using some other form will lead to serious barfage."
4928 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4929 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4930 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4931 (vector thread) 2))
4933 (defsubst gnus-article-sort-by-number (h1 h2)
4934 "Sort articles by article number."
4935 (< (mail-header-number h1)
4936 (mail-header-number h2)))
4938 (defun gnus-thread-sort-by-number (h1 h2)
4939 "Sort threads by root article number."
4940 (gnus-article-sort-by-number
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4943 (defsubst gnus-article-sort-by-random (h1 h2)
4944 "Sort articles randomly."
4945 (zerop (random 2)))
4947 (defun gnus-thread-sort-by-random (h1 h2)
4948 "Sort threads randomly."
4949 (gnus-article-sort-by-random
4950 (gnus-thread-header h1) (gnus-thread-header h2)))
4952 (defsubst gnus-article-sort-by-lines (h1 h2)
4953 "Sort articles by article Lines header."
4954 (< (mail-header-lines h1)
4955 (mail-header-lines h2)))
4957 (defun gnus-thread-sort-by-lines (h1 h2)
4958 "Sort threads by root article Lines header."
4959 (gnus-article-sort-by-lines
4960 (gnus-thread-header h1) (gnus-thread-header h2)))
4962 (defsubst gnus-article-sort-by-chars (h1 h2)
4963 "Sort articles by octet length."
4964 (< (mail-header-chars h1)
4965 (mail-header-chars h2)))
4967 (defun gnus-thread-sort-by-chars (h1 h2)
4968 "Sort threads by root article octet length."
4969 (gnus-article-sort-by-chars
4970 (gnus-thread-header h1) (gnus-thread-header h2)))
4972 (defsubst gnus-article-sort-by-author (h1 h2)
4973 "Sort articles by root author."
4974 (gnus-string<
4975 (let ((extract (funcall
4976 gnus-extract-address-components
4977 (mail-header-from h1))))
4978 (or (car extract) (cadr extract) ""))
4979 (let ((extract (funcall
4980 gnus-extract-address-components
4981 (mail-header-from h2))))
4982 (or (car extract) (cadr extract) ""))))
4984 (defun gnus-thread-sort-by-author (h1 h2)
4985 "Sort threads by root author."
4986 (gnus-article-sort-by-author
4987 (gnus-thread-header h1) (gnus-thread-header h2)))
4989 (defsubst gnus-article-sort-by-recipient (h1 h2)
4990 "Sort articles by recipient."
4991 (gnus-string<
4992 (let ((extract (funcall
4993 gnus-extract-address-components
4994 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4995 (or (car extract) (cadr extract)))
4996 (let ((extract (funcall
4997 gnus-extract-address-components
4998 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4999 (or (car extract) (cadr extract)))))
5001 (defun gnus-thread-sort-by-recipient (h1 h2)
5002 "Sort threads by root recipient."
5003 (gnus-article-sort-by-recipient
5004 (gnus-thread-header h1) (gnus-thread-header h2)))
5006 (defsubst gnus-article-sort-by-subject (h1 h2)
5007 "Sort articles by root subject."
5008 (gnus-string<
5009 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5010 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5012 (defun gnus-thread-sort-by-subject (h1 h2)
5013 "Sort threads by root subject."
5014 (gnus-article-sort-by-subject
5015 (gnus-thread-header h1) (gnus-thread-header h2)))
5017 (defsubst gnus-article-sort-by-date (h1 h2)
5018 "Sort articles by root article date."
5019 (time-less-p
5020 (gnus-date-get-time (mail-header-date h1))
5021 (gnus-date-get-time (mail-header-date h2))))
5023 (defun gnus-thread-sort-by-date (h1 h2)
5024 "Sort threads by root article date."
5025 (gnus-article-sort-by-date
5026 (gnus-thread-header h1) (gnus-thread-header h2)))
5028 (defsubst gnus-article-sort-by-score (h1 h2)
5029 "Sort articles by root article score.
5030 Unscored articles will be counted as having a score of zero."
5031 (> (or (cdr (assq (mail-header-number h1)
5032 gnus-newsgroup-scored))
5033 gnus-summary-default-score 0)
5034 (or (cdr (assq (mail-header-number h2)
5035 gnus-newsgroup-scored))
5036 gnus-summary-default-score 0)))
5038 (defun gnus-thread-sort-by-score (h1 h2)
5039 "Sort threads by root article score."
5040 (gnus-article-sort-by-score
5041 (gnus-thread-header h1) (gnus-thread-header h2)))
5043 (defun gnus-thread-sort-by-total-score (h1 h2)
5044 "Sort threads by the sum of all scores in the thread.
5045 Unscored articles will be counted as having a score of zero."
5046 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5048 (defun gnus-thread-total-score (thread)
5049 ;; This function find the total score of THREAD.
5050 (cond
5051 ((null thread)
5053 ((consp thread)
5054 (if (stringp (car thread))
5055 (apply gnus-thread-score-function 0
5056 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5057 (gnus-thread-total-score-1 thread)))
5059 (gnus-thread-total-score-1 (list thread)))))
5061 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5062 "Sort articles by number."
5063 (gnus-article-sort-by-number h1 h2))
5065 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5066 "Sort threads such that the thread with the most recently arrived article comes first."
5067 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5069 (defun gnus-thread-highest-number (thread)
5070 "Return the highest article number in THREAD."
5071 (apply 'max (mapcar (lambda (header)
5072 (mail-header-number header))
5073 (message-flatten-list thread))))
5075 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5076 "Sort articles by number."
5077 (gnus-article-sort-by-date h1 h2))
5079 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5080 "Sort threads such that the thread with the most recently dated article comes first."
5081 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5083 ; Since this is called not only to sort the top-level threads, but
5084 ; also in recursive sorts to order the articles within a thread, each
5085 ; article will be processed many times. Thus it speeds things up
5086 ; quite a bit to use gnus-date-get-time, which caches the time value.
5087 (defun gnus-thread-latest-date (thread)
5088 "Return the highest article date in THREAD."
5089 (apply 'max
5090 (mapcar (lambda (header) (gnus-float-time
5091 (gnus-date-get-time
5092 (mail-header-date header))))
5093 (message-flatten-list thread))))
5095 (defun gnus-thread-total-score-1 (root)
5096 ;; This function find the total score of the thread below ROOT.
5097 (setq root (car root))
5098 (apply gnus-thread-score-function
5099 (or (append
5100 (mapcar 'gnus-thread-total-score
5101 (cdr (gnus-id-to-thread (mail-header-id root))))
5102 (when (> (mail-header-number root) 0)
5103 (list (or (cdr (assq (mail-header-number root)
5104 gnus-newsgroup-scored))
5105 gnus-summary-default-score 0))))
5106 (list gnus-summary-default-score)
5107 '(0))))
5109 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5110 (defvar gnus-tmp-prev-subject nil)
5111 (defvar gnus-tmp-false-parent nil)
5112 (defvar gnus-tmp-root-expunged nil)
5113 (defvar gnus-tmp-dummy-line nil)
5115 (defun gnus-extra-header (type &optional header)
5116 "Return the extra header of TYPE."
5117 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5118 ""))
5120 (defvar gnus-tmp-thread-tree-header-string "")
5122 (defcustom gnus-sum-thread-tree-root "> "
5123 "With %B spec, used for the root of a thread.
5124 If nil, use subject instead."
5125 :version "22.1"
5126 :type '(radio (const :format "%v " nil) string)
5127 :group 'gnus-thread)
5129 (defcustom gnus-sum-thread-tree-false-root "> "
5130 "With %B spec, used for a false root of a thread.
5131 If nil, use subject instead."
5132 :version "22.1"
5133 :type '(radio (const :format "%v " nil) string)
5134 :group 'gnus-thread)
5136 (defcustom gnus-sum-thread-tree-single-indent ""
5137 "With %B spec, used for a thread with just one message.
5138 If nil, use subject instead."
5139 :version "22.1"
5140 :type '(radio (const :format "%v " nil) string)
5141 :group 'gnus-thread)
5143 (defcustom gnus-sum-thread-tree-vertical "| "
5144 "With %B spec, used for drawing a vertical line."
5145 :version "22.1"
5146 :type 'string
5147 :group 'gnus-thread)
5149 (defcustom gnus-sum-thread-tree-indent " "
5150 "With %B spec, used for indenting."
5151 :version "22.1"
5152 :type 'string
5153 :group 'gnus-thread)
5155 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5156 "With %B spec, used for a leaf with brothers."
5157 :version "22.1"
5158 :type 'string
5159 :group 'gnus-thread)
5161 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5162 "With %B spec, used for a leaf without brothers."
5163 :version "22.1"
5164 :type 'string
5165 :group 'gnus-thread)
5167 (defcustom gnus-summary-display-while-building nil
5168 "If non-nil, show and update the summary buffer as it's being built.
5169 If the value is t, update the buffer after every line is inserted. If
5170 the value is an integer (N), update the display every N lines."
5171 :version "22.1"
5172 :group 'gnus-thread
5173 :type '(choice (const :tag "off" nil)
5174 number
5175 (const :tag "frequently" t)))
5177 (defun gnus-summary-prepare-threads (threads)
5178 "Prepare summary buffer from THREADS and indentation LEVEL.
5179 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5180 or a straight list of headers."
5181 (gnus-message 7 "Generating summary...")
5183 (setq gnus-newsgroup-threads threads)
5184 (beginning-of-line)
5186 (let ((gnus-tmp-level 0)
5187 (default-score (or gnus-summary-default-score 0))
5188 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5189 (building-line-count gnus-summary-display-while-building)
5190 (building-count (integerp gnus-summary-display-while-building))
5191 thread number subject stack state gnus-tmp-gathered beg-match
5192 new-roots gnus-tmp-new-adopts thread-end simp-subject
5193 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5194 gnus-tmp-replied gnus-tmp-subject-or-nil
5195 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5196 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5197 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5198 tree-stack)
5200 (setq gnus-tmp-prev-subject nil
5201 gnus-tmp-thread-tree-header-string "")
5203 (if (vectorp (car threads))
5204 ;; If this is a straight (sic) list of headers, then a
5205 ;; threaded summary display isn't required, so we just create
5206 ;; an unthreaded one.
5207 (gnus-summary-prepare-unthreaded threads)
5209 ;; Do the threaded display.
5211 (if gnus-summary-display-while-building
5212 (switch-to-buffer (buffer-name)))
5213 (while (or threads stack gnus-tmp-new-adopts new-roots)
5215 (if (and (= gnus-tmp-level 0)
5216 (or (not stack)
5217 (= (caar stack) 0))
5218 (not gnus-tmp-false-parent)
5219 (or gnus-tmp-new-adopts new-roots))
5220 (if gnus-tmp-new-adopts
5221 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5222 thread (list (car gnus-tmp-new-adopts))
5223 gnus-tmp-header (caar thread)
5224 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5225 (when new-roots
5226 (setq thread (list (car new-roots))
5227 gnus-tmp-header (caar thread)
5228 new-roots (cdr new-roots))))
5230 (if threads
5231 ;; If there are some threads, we do them before the
5232 ;; threads on the stack.
5233 (setq thread threads
5234 gnus-tmp-header (caar thread))
5235 ;; There were no current threads, so we pop something off
5236 ;; the stack.
5237 (setq state (car stack)
5238 gnus-tmp-level (car state)
5239 tree-stack (cadr state)
5240 thread (caddr state)
5241 stack (cdr stack)
5242 gnus-tmp-header (caar thread))))
5244 (setq gnus-tmp-false-parent nil)
5245 (setq gnus-tmp-root-expunged nil)
5246 (setq thread-end nil)
5248 (if (stringp gnus-tmp-header)
5249 ;; The header is a dummy root.
5250 (cond
5251 ((eq gnus-summary-make-false-root 'adopt)
5252 ;; We let the first article adopt the rest.
5253 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5254 (cddar thread)))
5255 (setq gnus-tmp-gathered
5256 (nconc (mapcar
5257 (lambda (h) (mail-header-number (car h)))
5258 (cddar thread))
5259 gnus-tmp-gathered))
5260 (setq thread (cons (list (caar thread)
5261 (cadar thread))
5262 (cdr thread)))
5263 (setq gnus-tmp-level -1
5264 gnus-tmp-false-parent t))
5265 ((eq gnus-summary-make-false-root 'empty)
5266 ;; We print adopted articles with empty subject fields.
5267 (setq gnus-tmp-gathered
5268 (nconc (mapcar
5269 (lambda (h) (mail-header-number (car h)))
5270 (cddar thread))
5271 gnus-tmp-gathered))
5272 (setq gnus-tmp-level -1))
5273 ((eq gnus-summary-make-false-root 'dummy)
5274 ;; We remember that we probably want to output a dummy
5275 ;; root.
5276 (setq gnus-tmp-dummy-line gnus-tmp-header)
5277 (setq gnus-tmp-prev-subject gnus-tmp-header))
5279 ;; We do not make a root for the gathered
5280 ;; sub-threads at all.
5281 (setq gnus-tmp-level -1)))
5283 (setq number (mail-header-number gnus-tmp-header)
5284 subject (mail-header-subject gnus-tmp-header)
5285 simp-subject (gnus-simplify-subject-fully subject))
5287 (cond
5288 ;; If the thread has changed subject, we might want to make
5289 ;; this subthread into a root.
5290 ((and (null gnus-thread-ignore-subject)
5291 (not (zerop gnus-tmp-level))
5292 gnus-tmp-prev-subject
5293 (not (string= gnus-tmp-prev-subject simp-subject)))
5294 (setq new-roots (nconc new-roots (list (car thread)))
5295 thread-end t
5296 gnus-tmp-header nil))
5297 ;; If the article lies outside the current limit,
5298 ;; then we do not display it.
5299 ((not (memq number gnus-newsgroup-limit))
5300 (setq gnus-tmp-gathered
5301 (nconc (mapcar
5302 (lambda (h) (mail-header-number (car h)))
5303 (cdar thread))
5304 gnus-tmp-gathered))
5305 (setq gnus-tmp-new-adopts (if (cdar thread)
5306 (append gnus-tmp-new-adopts
5307 (cdar thread))
5308 gnus-tmp-new-adopts)
5309 thread-end t
5310 gnus-tmp-header nil)
5311 (when (zerop gnus-tmp-level)
5312 (setq gnus-tmp-root-expunged t)))
5313 ;; Perhaps this article is to be marked as read?
5314 ((and gnus-summary-mark-below
5315 (< (or (cdr (assq number gnus-newsgroup-scored))
5316 default-score)
5317 gnus-summary-mark-below)
5318 ;; Don't touch sparse articles.
5319 (not (gnus-summary-article-sparse-p number))
5320 (not (gnus-summary-article-ancient-p number)))
5321 (setq gnus-newsgroup-unreads
5322 (delq number gnus-newsgroup-unreads))
5323 (if gnus-newsgroup-auto-expire
5324 (setq gnus-newsgroup-expirable
5325 (gnus-add-to-sorted-list
5326 gnus-newsgroup-expirable number))
5327 (push (cons number gnus-low-score-mark)
5328 gnus-newsgroup-reads))))
5330 (when gnus-tmp-header
5331 ;; We may have an old dummy line to output before this
5332 ;; article.
5333 (when (and gnus-tmp-dummy-line
5334 (gnus-subject-equal
5335 gnus-tmp-dummy-line
5336 (mail-header-subject gnus-tmp-header)))
5337 (gnus-summary-insert-dummy-line
5338 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5339 (setq gnus-tmp-dummy-line nil))
5341 ;; Compute the mark.
5342 (setq gnus-tmp-unread (gnus-article-mark number))
5344 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5345 gnus-tmp-header gnus-tmp-level)
5346 gnus-newsgroup-data)
5348 ;; Actually insert the line.
5349 (setq
5350 gnus-tmp-subject-or-nil
5351 (cond
5352 ((and gnus-thread-ignore-subject
5353 gnus-tmp-prev-subject
5354 (not (string= gnus-tmp-prev-subject simp-subject)))
5355 subject)
5356 ((zerop gnus-tmp-level)
5357 (if (and (eq gnus-summary-make-false-root 'empty)
5358 (memq number gnus-tmp-gathered)
5359 gnus-tmp-prev-subject
5360 (string= gnus-tmp-prev-subject simp-subject))
5361 gnus-summary-same-subject
5362 subject))
5363 (t gnus-summary-same-subject)))
5364 (if (and (eq gnus-summary-make-false-root 'adopt)
5365 (= gnus-tmp-level 1)
5366 (memq number gnus-tmp-gathered))
5367 (setq gnus-tmp-opening-bracket ?\<
5368 gnus-tmp-closing-bracket ?\>)
5369 (setq gnus-tmp-opening-bracket ?\[
5370 gnus-tmp-closing-bracket ?\]))
5371 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5372 (gnus-make-thread-indent-array
5373 (max (* 2 (length gnus-thread-indent-array))
5374 gnus-tmp-level)))
5375 (setq
5376 gnus-tmp-indentation
5377 (aref gnus-thread-indent-array gnus-tmp-level)
5378 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5379 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5380 gnus-summary-default-score 0)
5381 gnus-tmp-score-char
5382 (if (or (null gnus-summary-default-score)
5383 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5384 gnus-summary-zcore-fuzz))
5385 ? ;Whitespace
5386 (if (< gnus-tmp-score gnus-summary-default-score)
5387 gnus-score-below-mark gnus-score-over-mark))
5388 gnus-tmp-replied
5389 (cond ((memq number gnus-newsgroup-processable)
5390 gnus-process-mark)
5391 ((memq number gnus-newsgroup-cached)
5392 gnus-cached-mark)
5393 ((memq number gnus-newsgroup-replied)
5394 gnus-replied-mark)
5395 ((memq number gnus-newsgroup-forwarded)
5396 gnus-forwarded-mark)
5397 ((memq number gnus-newsgroup-saved)
5398 gnus-saved-mark)
5399 ((memq number gnus-newsgroup-unseen)
5400 gnus-unseen-mark)
5401 (t gnus-no-mark))
5402 gnus-tmp-downloaded
5403 (cond ((memq number gnus-newsgroup-undownloaded)
5404 gnus-undownloaded-mark)
5405 (gnus-newsgroup-agentized
5406 gnus-downloaded-mark)
5408 gnus-no-mark))
5409 gnus-tmp-from (mail-header-from gnus-tmp-header)
5410 gnus-tmp-name
5411 (cond
5412 ((string-match "<[^>]+> *$" gnus-tmp-from)
5413 (setq beg-match (match-beginning 0))
5414 (or (and (string-match "^\".+\"" gnus-tmp-from)
5415 (substring gnus-tmp-from 1 (1- (match-end 0))))
5416 (substring gnus-tmp-from 0 beg-match)))
5417 ((string-match "(.+)" gnus-tmp-from)
5418 (substring gnus-tmp-from
5419 (1+ (match-beginning 0)) (1- (match-end 0))))
5420 (t gnus-tmp-from))
5422 ;; Do the %B string
5423 gnus-tmp-thread-tree-header-string
5424 (cond
5425 ((not gnus-show-threads) "")
5426 ((zerop gnus-tmp-level)
5427 (cond ((cdar thread)
5428 (or gnus-sum-thread-tree-root subject))
5429 (gnus-tmp-new-adopts
5430 (or gnus-sum-thread-tree-false-root subject))
5432 (or gnus-sum-thread-tree-single-indent subject))))
5434 (concat (apply 'concat
5435 (mapcar (lambda (item)
5436 (if (= item 1)
5437 gnus-sum-thread-tree-vertical
5438 gnus-sum-thread-tree-indent))
5439 (cdr (reverse tree-stack))))
5440 (if (nth 1 thread)
5441 gnus-sum-thread-tree-leaf-with-other
5442 gnus-sum-thread-tree-single-leaf)))))
5443 (when (string= gnus-tmp-name "")
5444 (setq gnus-tmp-name gnus-tmp-from))
5445 (unless (numberp gnus-tmp-lines)
5446 (setq gnus-tmp-lines -1))
5447 (if (= gnus-tmp-lines -1)
5448 (setq gnus-tmp-lines "?")
5449 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5450 (gnus-put-text-property
5451 (point)
5452 (progn (eval gnus-summary-line-format-spec) (point))
5453 'gnus-number number)
5454 (when gnus-visual-p
5455 (forward-line -1)
5456 (gnus-summary-highlight-line)
5457 (when gnus-summary-update-hook
5458 (gnus-run-hooks 'gnus-summary-update-hook))
5459 (forward-line 1))
5461 (setq gnus-tmp-prev-subject simp-subject)))
5463 (when (nth 1 thread)
5464 (push (list (max 0 gnus-tmp-level)
5465 (copy-sequence tree-stack)
5466 (nthcdr 1 thread))
5467 stack))
5468 (push (if (nth 1 thread) 1 0) tree-stack)
5469 (incf gnus-tmp-level)
5470 (setq threads (if thread-end nil (cdar thread)))
5471 (if gnus-summary-display-while-building
5472 (if building-count
5473 (progn
5474 ;; use a set frequency
5475 (setq building-line-count (1- building-line-count))
5476 (when (= building-line-count 0)
5477 (sit-for 0)
5478 (setq building-line-count
5479 gnus-summary-display-while-building)))
5480 ;; always
5481 (sit-for 0)))
5482 (unless threads
5483 (setq gnus-tmp-level 0)))))
5484 (gnus-message 7 "Generating summary...done"))
5486 (defun gnus-summary-prepare-unthreaded (headers)
5487 "Generate an unthreaded summary buffer based on HEADERS."
5488 (let (header number mark)
5490 (beginning-of-line)
5492 (while headers
5493 ;; We may have to root out some bad articles...
5494 (when (memq (setq number (mail-header-number
5495 (setq header (pop headers))))
5496 gnus-newsgroup-limit)
5497 ;; Mark article as read when it has a low score.
5498 (when (and gnus-summary-mark-below
5499 (< (or (cdr (assq number gnus-newsgroup-scored))
5500 gnus-summary-default-score 0)
5501 gnus-summary-mark-below)
5502 (not (gnus-summary-article-ancient-p number)))
5503 (setq gnus-newsgroup-unreads
5504 (delq number gnus-newsgroup-unreads))
5505 (if gnus-newsgroup-auto-expire
5506 (push number gnus-newsgroup-expirable)
5507 (push (cons number gnus-low-score-mark)
5508 gnus-newsgroup-reads)))
5510 (setq mark (gnus-article-mark number))
5511 (push (gnus-data-make number mark (1+ (point)) header 0)
5512 gnus-newsgroup-data)
5513 (gnus-summary-insert-line
5514 header 0 number
5515 (memq number gnus-newsgroup-undownloaded)
5516 mark (memq number gnus-newsgroup-replied)
5517 (memq number gnus-newsgroup-expirable)
5518 (mail-header-subject header) nil
5519 (cdr (assq number gnus-newsgroup-scored))
5520 (memq number gnus-newsgroup-processable))))))
5522 (defun gnus-group-get-list-identifiers (group)
5523 "Get list identifier regexp for GROUP."
5524 (or (gnus-parameter-list-identifier group)
5525 (if (consp gnus-list-identifiers)
5526 (mapconcat 'identity gnus-list-identifiers " *\\|")
5527 gnus-list-identifiers)))
5529 (defun gnus-summary-remove-list-identifiers ()
5530 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5531 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5532 changed subject)
5533 (when regexp
5534 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5535 (dolist (header gnus-newsgroup-headers)
5536 (setq subject (mail-header-subject header)
5537 changed nil)
5538 (while (string-match regexp subject)
5539 (setq subject
5540 (concat (substring subject 0 (match-beginning 1))
5541 (substring subject (match-end 0)))
5542 changed t))
5543 (when changed
5544 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5545 (setq subject
5546 (concat (substring subject 0 (match-beginning 1))
5547 (substring subject (match-end 1)))))
5548 (mail-header-set-subject header subject))))))
5550 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5551 "Fetch headers of ARTICLES."
5552 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5553 (gnus-message 7 "Fetching headers for %s..." name)
5554 (prog1
5555 (if (eq 'nov
5556 (setq gnus-headers-retrieved-by
5557 (gnus-retrieve-headers
5558 articles gnus-newsgroup-name
5559 (or limit
5560 ;; We might want to fetch old headers, but
5561 ;; not if there is only 1 article.
5562 (and (or (and
5563 (not (eq gnus-fetch-old-headers 'some))
5564 (not (numberp gnus-fetch-old-headers)))
5565 (> (length articles) 1))
5566 gnus-fetch-old-headers)))))
5567 (gnus-get-newsgroup-headers-xover
5568 articles force-new dependencies gnus-newsgroup-name t)
5569 (gnus-get-newsgroup-headers dependencies force-new))
5570 (gnus-message 7 "Fetching headers for %s...done" name))))
5572 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5573 "Select newsgroup GROUP.
5574 If READ-ALL is non-nil, all articles in the group are selected.
5575 If SELECT-ARTICLES, only select those articles from GROUP."
5576 (let* ((entry (gnus-group-entry group))
5577 ;;!!! Dirty hack; should be removed.
5578 (gnus-summary-ignore-duplicates
5579 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5581 gnus-summary-ignore-duplicates))
5582 (info (nth 2 entry))
5583 charset articles fetched-articles cached)
5585 (unless (gnus-check-server
5586 (set (make-local-variable 'gnus-current-select-method)
5587 (gnus-find-method-for-group group)))
5588 (error "Couldn't open server"))
5589 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5591 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5592 (gnus-activate-group group) ; Or we can activate it...
5593 (progn ; Or we bug out.
5594 (when (equal major-mode 'gnus-summary-mode)
5595 (gnus-kill-buffer (current-buffer)))
5596 (error
5597 "Couldn't activate group %s: %s"
5598 (mm-decode-coding-string group charset)
5599 (mm-decode-coding-string (gnus-status-message group) charset))))
5601 (unless (gnus-request-group group t)
5602 (when (equal major-mode 'gnus-summary-mode)
5603 (gnus-kill-buffer (current-buffer)))
5604 (error "Couldn't request group %s: %s"
5605 (mm-decode-coding-string group charset)
5606 (mm-decode-coding-string (gnus-status-message group) charset)))
5608 (when (and gnus-agent
5609 (gnus-active group))
5610 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5612 (setq gnus-summary-use-undownloaded-faces
5613 (gnus-agent-find-parameter
5614 group
5615 'agent-enable-undownloaded-faces)))
5617 (setq gnus-newsgroup-name group
5618 gnus-newsgroup-unselected nil
5619 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5621 (let ((display (gnus-group-find-parameter group 'display)))
5622 (setq gnus-newsgroup-display
5623 (cond
5624 ((not (zerop (or (car-safe read-all) 0)))
5625 ;; The user entered the group with C-u SPC/RET, let's show
5626 ;; all articles.
5627 'gnus-not-ignore)
5628 ((eq display 'all)
5629 'gnus-not-ignore)
5630 ((arrayp display)
5631 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5632 ((numberp display)
5633 ;; The following is probably the "correct" solution, but
5634 ;; it makes Gnus fetch all headers and then limit the
5635 ;; articles (which is slow), so instead we hack the
5636 ;; select-articles parameter instead. -- Simon Josefsson
5637 ;; <jas@kth.se>
5639 ;; (gnus-byte-compile
5640 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5641 ;; display)))))
5642 (setq select-articles
5643 (gnus-uncompress-range
5644 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5645 (if (> tmp 0)
5648 (cdr (gnus-active group)))))
5649 nil)
5651 nil))))
5653 (gnus-summary-setup-default-charset)
5655 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5656 (when (gnus-virtual-group-p group)
5657 (setq cached gnus-newsgroup-cached))
5659 (setq gnus-newsgroup-unreads
5660 (gnus-sorted-ndifference
5661 (gnus-sorted-ndifference gnus-newsgroup-unreads
5662 gnus-newsgroup-marked)
5663 gnus-newsgroup-dormant))
5665 (setq gnus-newsgroup-processable nil)
5667 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5669 ;; Adjust and set lists of article marks.
5670 (when info
5671 (gnus-adjust-marked-articles info))
5672 (if (setq articles select-articles)
5673 (setq gnus-newsgroup-unselected
5674 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5675 (setq articles (gnus-articles-to-read group read-all)))
5677 (cond
5678 ((null articles)
5679 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5680 'quit)
5681 ((eq articles 0) nil)
5683 ;; Init the dependencies hash table.
5684 (setq gnus-newsgroup-dependencies
5685 (gnus-make-hashtable (length articles)))
5686 (gnus-set-global-variables)
5687 ;; Retrieve the headers and read them in.
5689 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5691 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5692 (when cached
5693 (setq gnus-newsgroup-cached cached))
5695 ;; Suppress duplicates?
5696 (when gnus-suppress-duplicates
5697 (gnus-dup-suppress-articles))
5699 ;; Set the initial limit.
5700 (setq gnus-newsgroup-limit (copy-sequence articles))
5701 ;; Remove canceled articles from the list of unread articles.
5702 (setq fetched-articles
5703 (mapcar (lambda (headers) (mail-header-number headers))
5704 gnus-newsgroup-headers))
5705 (setq gnus-newsgroup-articles fetched-articles)
5706 (setq gnus-newsgroup-unreads
5707 (gnus-sorted-nintersection
5708 gnus-newsgroup-unreads fetched-articles))
5709 (gnus-compute-unseen-list)
5711 ;; Removed marked articles that do not exist.
5712 (gnus-update-missing-marks
5713 (gnus-sorted-difference articles fetched-articles))
5714 ;; We might want to build some more threads first.
5715 (when (and gnus-fetch-old-headers
5716 (eq gnus-headers-retrieved-by 'nov))
5717 (if (eq gnus-fetch-old-headers 'invisible)
5718 (gnus-build-all-threads)
5719 (gnus-build-old-threads)))
5720 ;; Let the Gnus agent mark articles as read.
5721 (when gnus-agent
5722 (gnus-agent-get-undownloaded-list))
5723 ;; Remove list identifiers from subject
5724 (gnus-summary-remove-list-identifiers)
5725 ;; Check whether auto-expire is to be done in this group.
5726 (setq gnus-newsgroup-auto-expire
5727 (and (gnus-group-auto-expirable-p group)
5728 (not (gnus-group-read-only-p group))))
5729 ;; Set up the article buffer now, if necessary.
5730 (unless (and gnus-single-article-buffer
5731 (equal gnus-article-buffer "*Article*"))
5732 (gnus-article-setup-buffer))
5733 ;; First and last article in this newsgroup.
5734 (when gnus-newsgroup-headers
5735 (setq gnus-newsgroup-begin
5736 (mail-header-number (car gnus-newsgroup-headers))
5737 gnus-newsgroup-end
5738 (mail-header-number
5739 (gnus-last-element gnus-newsgroup-headers))))
5740 ;; GROUP is successfully selected.
5741 (or gnus-newsgroup-headers t)))))
5743 (defun gnus-compute-unseen-list ()
5744 ;; The `seen' marks are treated specially.
5745 (if (not gnus-newsgroup-seen)
5746 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5747 (setq gnus-newsgroup-unseen
5748 (gnus-inverse-list-range-intersection
5749 gnus-newsgroup-articles gnus-newsgroup-seen))))
5751 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5753 (defun gnus-summary-display-make-predicate (display)
5754 (require 'gnus-agent)
5755 (when (= (length display) 1)
5756 (setq display (car display)))
5757 (unless gnus-summary-display-cache
5758 (dolist (elem (append '((unread . unread)
5759 (read . read)
5760 (unseen . unseen))
5761 gnus-article-mark-lists))
5762 (push (cons (cdr elem)
5763 (gnus-byte-compile ;Why bother?
5764 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5765 gnus-summary-display-cache)))
5766 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5767 (gnus-category-predicate-cache gnus-summary-display-cache))
5768 (gnus-get-predicate display)))
5770 ;; Uses the dynamically bound `gnus-number' variable.
5771 (defvar gnus-number)
5772 (defun gnus-article-marked-p (type &optional article)
5773 (let ((article (or article gnus-number)))
5774 (cond
5775 ((eq type 'tick)
5776 (memq article gnus-newsgroup-marked))
5777 ((eq type 'spam)
5778 (memq article gnus-newsgroup-spam-marked))
5779 ((eq type 'unsend)
5780 (memq article gnus-newsgroup-unsendable))
5781 ((eq type 'undownload)
5782 (memq article gnus-newsgroup-undownloaded))
5783 ((eq type 'download)
5784 (memq article gnus-newsgroup-downloadable))
5785 ((eq type 'unread)
5786 (memq article gnus-newsgroup-unreads))
5787 ((eq type 'read)
5788 (memq article gnus-newsgroup-reads))
5789 ((eq type 'dormant)
5790 (memq article gnus-newsgroup-dormant) )
5791 ((eq type 'expire)
5792 (memq article gnus-newsgroup-expirable))
5793 ((eq type 'reply)
5794 (memq article gnus-newsgroup-replied))
5795 ((eq type 'killed)
5796 (memq article gnus-newsgroup-killed))
5797 ((eq type 'bookmark)
5798 (assq article gnus-newsgroup-bookmarks))
5799 ((eq type 'score)
5800 (assq article gnus-newsgroup-scored))
5801 ((eq type 'save)
5802 (memq article gnus-newsgroup-saved))
5803 ((eq type 'cache)
5804 (memq article gnus-newsgroup-cached))
5805 ((eq type 'forward)
5806 (memq article gnus-newsgroup-forwarded))
5807 ((eq type 'seen)
5808 (not (memq article gnus-newsgroup-unseen)))
5809 (t t))))
5811 (defun gnus-articles-to-read (group &optional read-all)
5812 "Find out what articles the user wants to read."
5813 (let* ((only-read-p t)
5814 (articles
5815 ;; Select all articles if `read-all' is non-nil, or if there
5816 ;; are no unread articles.
5817 (if (or read-all
5818 (and (zerop (length gnus-newsgroup-marked))
5819 (zerop (length gnus-newsgroup-unreads)))
5820 ;; Fetch all if the predicate is non-nil.
5821 gnus-newsgroup-display)
5822 ;; We want to select the headers for all the articles in
5823 ;; the group, so we select either all the active
5824 ;; articles in the group, or (if that's nil), the
5825 ;; articles in the cache.
5827 (if gnus-newsgroup-maximum-articles
5828 (let ((active (gnus-active group)))
5829 (gnus-uncompress-range
5830 (cons (max (car active)
5831 (- (cdr active)
5832 gnus-newsgroup-maximum-articles
5833 -1))
5834 (cdr active))))
5835 (gnus-uncompress-range (gnus-active group)))
5836 (gnus-cache-articles-in-group group))
5837 ;; Select only the "normal" subset of articles.
5838 (setq only-read-p nil)
5839 (gnus-sorted-nunion
5840 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5841 gnus-newsgroup-unreads)))
5842 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5843 (scored (length scored-list))
5844 (number (length articles))
5845 (marked (+ (length gnus-newsgroup-marked)
5846 (length gnus-newsgroup-dormant)))
5847 (select
5848 (cond
5849 ((numberp read-all)
5850 read-all)
5851 ((numberp gnus-newsgroup-display)
5852 gnus-newsgroup-display)
5854 (condition-case ()
5855 (cond
5856 ((and (or (<= scored marked) (= scored number))
5857 (numberp gnus-large-newsgroup)
5858 (> number gnus-large-newsgroup))
5859 (let* ((cursor-in-echo-area nil)
5860 (initial (gnus-parameter-large-newsgroup-initial
5861 gnus-newsgroup-name))
5862 (default (if only-read-p
5863 (or initial gnus-large-newsgroup)
5864 number))
5865 (input
5866 (read-string
5867 (if only-read-p
5868 (format
5869 "How many articles from %s (available %d, default %d): "
5870 (gnus-group-decoded-name
5871 (gnus-group-real-name gnus-newsgroup-name))
5872 number default)
5873 (format
5874 "How many articles from %s (%d default): "
5875 (gnus-group-decoded-name
5876 (gnus-group-real-name gnus-newsgroup-name))
5877 default))
5880 (number-to-string default))))
5881 (if (string-match "^[ \t]*$" input) number input)))
5882 ((and (> scored marked) (< scored number)
5883 (> (- scored number) 20))
5884 (let ((input
5885 (read-string
5886 (format "%s %s (%d scored, %d total): "
5887 "How many articles from"
5888 (gnus-group-decoded-name
5889 (gnus-group-real-name gnus-newsgroup-name))
5890 scored number))))
5891 (if (string-match "^[ \t]*$" input)
5892 number input)))
5893 (t number))
5894 (quit
5895 (message "Quit getting the articles to read")
5896 nil))))))
5897 (setq select (if (stringp select) (string-to-number select) select))
5898 (if (or (null select) (zerop select))
5899 select
5900 (if (and (not (zerop scored)) (<= (abs select) scored))
5901 (progn
5902 (setq articles (sort scored-list '<))
5903 (setq number (length articles)))
5904 (setq articles (copy-sequence articles)))
5906 (when (< (abs select) number)
5907 (if (< select 0)
5908 ;; Select the N oldest articles.
5909 (setcdr (nthcdr (1- (abs select)) articles) nil)
5910 ;; Select the N most recent articles.
5911 (setq articles (nthcdr (- number select) articles))))
5912 (setq gnus-newsgroup-unselected
5913 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5914 (when gnus-alter-articles-to-read-function
5915 (setq articles
5916 (sort
5917 (funcall gnus-alter-articles-to-read-function
5918 gnus-newsgroup-name articles)
5919 '<)))
5920 articles)))
5922 (defun gnus-killed-articles (killed articles)
5923 (let (out)
5924 (while articles
5925 (when (inline (gnus-member-of-range (car articles) killed))
5926 (push (car articles) out))
5927 (setq articles (cdr articles)))
5928 out))
5930 (defun gnus-uncompress-marks (marks)
5931 "Uncompress the mark ranges in MARKS."
5932 (let ((uncompressed '(score bookmark))
5933 out)
5934 (while marks
5935 (if (memq (caar marks) uncompressed)
5936 (push (car marks) out)
5937 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5938 (setq marks (cdr marks)))
5939 out))
5941 (defun gnus-article-mark-to-type (mark)
5942 "Return the type of MARK."
5943 (or (cadr (assq mark gnus-article-special-mark-lists))
5944 'list))
5946 (defun gnus-article-unpropagatable-p (mark)
5947 "Return whether MARK should be propagated to back end."
5948 (memq mark gnus-article-unpropagated-mark-lists))
5950 (defun gnus-adjust-marked-articles (info)
5951 "Set all article lists and remove all marks that are no longer valid."
5952 (let* ((marked-lists (gnus-info-marks info))
5953 (active (gnus-active (gnus-info-group info)))
5954 (min (car active))
5955 (max (cdr active))
5956 (types gnus-article-mark-lists)
5957 marks var articles article mark mark-type
5958 bgn end)
5959 ;; Hack to avoid adjusting marks for imap.
5960 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5961 'nnimap)
5962 (setq min 1))
5964 (dolist (marks marked-lists)
5965 (setq mark (car marks)
5966 mark-type (gnus-article-mark-to-type mark)
5967 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5969 ;; We set the variable according to the type of the marks list,
5970 ;; and then adjust the marks to a subset of the active articles.
5971 (cond
5972 ;; Adjust "simple" lists - compressed yet unsorted
5973 ((eq mark-type 'list)
5974 ;; Simultaneously uncompress and clip to active range
5975 ;; See gnus-uncompress-range for a description of possible marks
5976 (let (l lh)
5977 (if (not (cadr marks))
5978 (set var nil)
5979 (setq articles (if (numberp (cddr marks))
5980 (list (cdr marks))
5981 (cdr marks))
5982 lh (cons nil nil)
5983 l lh)
5985 (while (setq article (pop articles))
5986 (cond ((consp article)
5987 (setq bgn (max (car article) min)
5988 end (min (cdr article) max))
5989 (while (<= bgn end)
5990 (setq l (setcdr l (cons bgn nil))
5991 bgn (1+ bgn))))
5992 ((and (<= min article)
5993 (>= max article))
5994 (setq l (setcdr l (cons article nil))))))
5995 (set var (cdr lh)))))
5996 ;; Adjust assocs.
5997 ((eq mark-type 'tuple)
5998 (set var (setq articles (cdr marks)))
5999 (when (not (listp (cdr (symbol-value var))))
6000 (set var (list (symbol-value var))))
6001 (when (not (listp (cdr articles)))
6002 (setq articles (list articles)))
6003 (while articles
6004 (when (or (not (consp (setq article (pop articles))))
6005 (< (car article) min)
6006 (> (car article) max))
6007 (set var (delq article (symbol-value var))))))
6008 ;; Adjust ranges (sloppily).
6009 ((eq mark-type 'range)
6010 (cond
6011 ((eq mark 'seen)
6012 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6013 ;; It should be (seen (NUM1 . NUM2)).
6014 (when (numberp (cddr marks))
6015 (setcdr marks (list (cdr marks))))
6016 (setq articles (cdr marks))
6017 (while (and articles
6018 (or (and (consp (car articles))
6019 (> min (cdar articles)))
6020 (and (numberp (car articles))
6021 (> min (car articles)))))
6022 (pop articles))
6023 (set var articles))))))))
6025 (defun gnus-update-missing-marks (missing)
6026 "Go through the list of MISSING articles and remove them from the mark lists."
6027 (when missing
6028 (let (var m)
6029 ;; Go through all types.
6030 (dolist (elem gnus-article-mark-lists)
6031 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6032 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6033 (when (symbol-value var)
6034 ;; This list has articles. So we delete all missing
6035 ;; articles from it.
6036 (setq m missing)
6037 (while m
6038 (set var (delq (pop m) (symbol-value var))))))))))
6040 (defun gnus-update-marks ()
6041 "Enter the various lists of marked articles into the newsgroup info list."
6042 (let ((types gnus-article-mark-lists)
6043 (info (gnus-get-info gnus-newsgroup-name))
6044 type list newmarked symbol delta-marks)
6045 (when info
6046 ;; Add all marks lists to the list of marks lists.
6047 (while (setq type (pop types))
6048 (setq list (symbol-value
6049 (setq symbol
6050 (intern (format "gnus-newsgroup-%s" (car type))))))
6052 (when list
6053 ;; Get rid of the entries of the articles that have the
6054 ;; default score.
6055 (when (and (eq (cdr type) 'score)
6056 gnus-save-score
6057 list)
6058 (let* ((arts list)
6059 (prev (cons nil list))
6060 (all prev))
6061 (while arts
6062 (if (or (not (consp (car arts)))
6063 (= (cdar arts) gnus-summary-default-score))
6064 (setcdr prev (cdr arts))
6065 (setq prev arts))
6066 (setq arts (cdr arts)))
6067 (setq list (cdr all)))))
6069 (when (eq (cdr type) 'seen)
6070 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6072 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6073 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6075 (when (and (gnus-check-backend-function
6076 'request-set-mark gnus-newsgroup-name)
6077 (or gnus-propagate-marks
6078 (gnus-method-option-p
6079 (gnus-find-method-for-group gnus-newsgroup-name)
6080 'server-marks))
6081 (not (gnus-article-unpropagatable-p (cdr type))))
6082 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6083 ;; Don't do anything about marks for articles we
6084 ;; didn't actually get any headers for.
6085 (del
6086 (gnus-list-range-intersection
6087 gnus-newsgroup-articles
6088 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6089 (add
6090 (gnus-list-range-intersection
6091 gnus-newsgroup-articles
6092 (gnus-remove-from-range
6093 (gnus-copy-sequence list) old))))
6094 (when add
6095 (push (list add 'add (list (cdr type))) delta-marks))
6096 (when del
6097 ;; Don't delete marks from outside the active range.
6098 ;; This shouldn't happen, but is a sanity check.
6099 (setq del (gnus-sorted-range-intersection
6100 (gnus-active gnus-newsgroup-name) del))
6101 (push (list del 'del (list (cdr type))) delta-marks))))
6103 (when list
6104 (push (cons (cdr type) list) newmarked)))
6106 (when delta-marks
6107 (unless (gnus-check-group gnus-newsgroup-name)
6108 (error "Can't open server for %s" gnus-newsgroup-name))
6109 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6111 ;; Enter these new marks into the info of the group.
6112 (if (nthcdr 3 info)
6113 (setcar (nthcdr 3 info) newmarked)
6114 ;; Add the marks lists to the end of the info.
6115 (when newmarked
6116 (setcdr (nthcdr 2 info) (list newmarked))))
6118 ;; Cut off the end of the info if there's nothing else there.
6119 (let ((i 5))
6120 (while (and (> i 2)
6121 (not (nth i info)))
6122 (when (nthcdr (decf i) info)
6123 (setcdr (nthcdr i info) nil)))))))
6125 (defun gnus-set-mode-line (where)
6126 "Set the mode line of the article or summary buffers.
6127 If WHERE is `summary', the summary mode line format will be used."
6128 ;; Is this mode line one we keep updated?
6129 (when (and (memq where gnus-updated-mode-lines)
6130 (symbol-value
6131 (intern (format "gnus-%s-mode-line-format-spec" where))))
6132 (let (mode-string)
6133 ;; We evaluate this in the summary buffer since these
6134 ;; variables are buffer-local to that buffer.
6135 (with-current-buffer gnus-summary-buffer
6136 ;; We bind all these variables that are used in the `eval' form
6137 ;; below.
6138 (let* ((mformat (symbol-value
6139 (intern
6140 (format "gnus-%s-mode-line-format-spec" where))))
6141 (gnus-tmp-group-name (gnus-mode-string-quote
6142 (gnus-group-decoded-name
6143 gnus-newsgroup-name)))
6144 (gnus-tmp-article-number (or gnus-current-article 0))
6145 (gnus-tmp-unread gnus-newsgroup-unreads)
6146 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6147 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6148 (gnus-tmp-unread-and-unselected
6149 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6150 (zerop gnus-tmp-unselected))
6152 ((zerop gnus-tmp-unselected)
6153 (format "{%d more}" gnus-tmp-unread-and-unticked))
6154 (t (format "{%d(+%d) more}"
6155 gnus-tmp-unread-and-unticked
6156 gnus-tmp-unselected))))
6157 (gnus-tmp-subject
6158 (if (and gnus-current-headers
6159 (vectorp gnus-current-headers))
6160 (gnus-mode-string-quote
6161 (mail-header-subject gnus-current-headers))
6162 ""))
6163 bufname-length max-len
6164 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6165 (setq mode-string (eval mformat))
6166 (setq bufname-length (if (string-match "%b" mode-string)
6167 (- (length
6168 (buffer-name
6169 (if (eq where 'summary)
6171 (get-buffer gnus-article-buffer))))
6174 (setq max-len (max 4 (if gnus-mode-non-string-length
6175 (- (window-width)
6176 gnus-mode-non-string-length
6177 bufname-length)
6178 (length mode-string))))
6179 ;; We might have to chop a bit of the string off...
6180 (when (> (length mode-string) max-len)
6181 (setq mode-string
6182 (concat (truncate-string-to-width mode-string (- max-len 3))
6183 "...")))))
6184 ;; Update the mode line.
6185 (setq mode-line-buffer-identification
6186 (gnus-mode-line-buffer-identification (list mode-string)))
6187 (set-buffer-modified-p t))))
6189 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6190 "Go through the HEADERS list and add all Xrefs to a hash table.
6191 The resulting hash table is returned, or nil if no Xrefs were found."
6192 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6193 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6194 (xref-hashtb (gnus-make-hashtable))
6195 start group entry number xrefs header)
6196 (while headers
6197 (setq header (pop headers))
6198 (when (and (setq xrefs (mail-header-xref header))
6199 (not (memq (setq number (mail-header-number header))
6200 unreads)))
6201 (setq start 0)
6202 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6203 (setq start (match-end 0))
6204 (setq group (if prefix
6205 (concat prefix (substring xrefs (match-beginning 1)
6206 (match-end 1)))
6207 (substring xrefs (match-beginning 1) (match-end 1))))
6208 (setq number
6209 (string-to-number (substring xrefs (match-beginning 2)
6210 (match-end 2))))
6211 (if (setq entry (gnus-gethash group xref-hashtb))
6212 (setcdr entry (cons number (cdr entry)))
6213 (gnus-sethash group (cons number nil) xref-hashtb)))))
6214 (and start xref-hashtb)))
6216 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6217 "Look through all the headers and mark the Xrefs as read."
6218 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6219 name info xref-hashtb idlist method nth4)
6220 (with-current-buffer gnus-group-buffer
6221 (when (setq xref-hashtb
6222 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6223 (mapatoms
6224 (lambda (group)
6225 (unless (string= from-newsgroup (setq name (symbol-name group)))
6226 (setq idlist (symbol-value group))
6227 ;; Dead groups are not updated.
6228 (and (prog1
6229 (setq info (gnus-get-info name))
6230 (when (stringp (setq nth4 (gnus-info-method info)))
6231 (setq nth4 (gnus-server-to-method nth4))))
6232 ;; Only do the xrefs if the group has the same
6233 ;; select method as the group we have just read.
6234 (or (gnus-methods-equal-p
6235 nth4 (gnus-find-method-for-group from-newsgroup))
6236 virtual
6237 (equal nth4 (setq method (gnus-find-method-for-group
6238 from-newsgroup)))
6239 (and (equal (car nth4) (car method))
6240 (equal (nth 1 nth4) (nth 1 method))))
6241 gnus-use-cross-reference
6242 (or (not (eq gnus-use-cross-reference t))
6243 virtual
6244 ;; Only do cross-references on subscribed
6245 ;; groups, if that is what is wanted.
6246 (<= (gnus-info-level info) gnus-level-subscribed))
6247 (gnus-group-make-articles-read name idlist))))
6248 xref-hashtb)))))
6250 (defun gnus-compute-read-articles (group articles)
6251 (let* ((entry (gnus-group-entry group))
6252 (info (nth 2 entry))
6253 (active (gnus-active group))
6254 ninfo)
6255 (when entry
6256 ;; First peel off all invalid article numbers.
6257 (when active
6258 (let ((ids articles)
6259 id first)
6260 (while (setq id (pop ids))
6261 (when (and first (> id (cdr active)))
6262 ;; We'll end up in this situation in one particular
6263 ;; obscure situation. If you re-scan a group and get
6264 ;; a new article that is cross-posted to a different
6265 ;; group that has not been re-scanned, you might get
6266 ;; crossposted article that has a higher number than
6267 ;; Gnus believes possible. So we re-activate this
6268 ;; group as well. This might mean doing the
6269 ;; crossposting thingy will *increase* the number
6270 ;; of articles in some groups. Tsk, tsk.
6271 (setq active (or (gnus-activate-group group) active)))
6272 (when (or (> id (cdr active))
6273 (< id (car active)))
6274 (setq articles (delq id articles))))))
6275 ;; If the read list is nil, we init it.
6276 (if (and active
6277 (null (gnus-info-read info))
6278 (> (car active) 1))
6279 (setq ninfo (cons 1 (1- (car active))))
6280 (setq ninfo (gnus-info-read info)))
6281 ;; Then we add the read articles to the range.
6282 (gnus-add-to-range
6283 ninfo (setq articles (sort articles '<))))))
6285 (defun gnus-group-make-articles-read (group articles)
6286 "Update the info of GROUP to say that ARTICLES are read."
6287 (let* ((num 0)
6288 (entry (gnus-group-entry group))
6289 (info (nth 2 entry))
6290 (active (gnus-active group))
6291 (set-marks
6292 (or gnus-propagate-marks
6293 (gnus-method-option-p
6294 (gnus-find-method-for-group group)
6295 'server-marks)))
6296 range)
6297 (if (not entry)
6298 ;; Group that Gnus doesn't know exists, but still allow the
6299 ;; backend to set marks.
6300 (when set-marks
6301 (gnus-request-set-mark
6302 group (list (list (gnus-compress-sequence (sort articles #'<))
6303 'add '(read)))))
6304 ;; Normal, subscribed groups.
6305 (setq range (gnus-compute-read-articles group articles))
6306 (with-current-buffer gnus-group-buffer
6307 (gnus-undo-register
6308 `(progn
6309 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6310 (gnus-info-set-read ',info ',(gnus-info-read info))
6311 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6312 (when ,set-marks
6313 (gnus-request-set-mark
6314 ,group (list (list ',range 'del '(read)))))
6315 (gnus-group-update-group ,group t))))
6316 ;; Add the read articles to the range.
6317 (gnus-info-set-read info range)
6318 (when set-marks
6319 (gnus-request-set-mark group (list (list range 'add '(read)))))
6320 ;; Then we have to re-compute how many unread
6321 ;; articles there are in this group.
6322 (when active
6323 (cond
6324 ((not range)
6325 (setq num (- (1+ (cdr active)) (car active))))
6326 ((not (listp (cdr range)))
6327 (setq num (- (cdr active) (- (1+ (cdr range))
6328 (car range)))))
6330 (while range
6331 (if (numberp (car range))
6332 (setq num (1+ num))
6333 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6334 (setq range (cdr range)))
6335 (setq num (- (cdr active) num))))
6336 ;; Update the number of unread articles.
6337 (setcar entry num)
6338 ;; Update the group buffer.
6339 (unless (gnus-ephemeral-group-p group)
6340 (gnus-group-update-group group t))))))
6342 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6343 (let ((cur nntp-server-buffer)
6344 (dependencies
6345 (or dependencies
6346 (with-current-buffer gnus-summary-buffer
6347 gnus-newsgroup-dependencies)))
6348 headers id end ref number
6349 (mail-parse-charset gnus-newsgroup-charset)
6350 (mail-parse-ignored-charsets
6351 (save-current-buffer (condition-case nil
6352 (set-buffer gnus-summary-buffer)
6353 (error))
6354 gnus-newsgroup-ignored-charsets)))
6355 (with-current-buffer nntp-server-buffer
6356 ;; Translate all TAB characters into SPACE characters.
6357 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6358 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6359 (ietf-drums-unfold-fws)
6360 (gnus-run-hooks 'gnus-parse-headers-hook)
6361 (let ((case-fold-search t)
6362 in-reply-to header p lines chars)
6363 (goto-char (point-min))
6364 ;; Search to the beginning of the next header. Error messages
6365 ;; do not begin with 2 or 3.
6366 (while (re-search-forward "^[23][0-9]+ " nil t)
6367 (setq id nil
6368 ref nil)
6369 ;; This implementation of this function, with nine
6370 ;; search-forwards instead of the one re-search-forward and
6371 ;; a case (which basically was the old function) is actually
6372 ;; about twice as fast, even though it looks messier. You
6373 ;; can't have everything, I guess. Speed and elegance
6374 ;; doesn't always go hand in hand.
6375 (setq
6376 header
6377 (vector
6378 ;; Number.
6379 (prog1
6380 (setq number (read cur))
6381 (end-of-line)
6382 (setq p (point))
6383 (narrow-to-region (point)
6384 (or (and (search-forward "\n.\n" nil t)
6385 (- (point) 2))
6386 (point))))
6387 ;; Subject.
6388 (progn
6389 (goto-char p)
6390 (if (search-forward "\nsubject:" nil t)
6391 (funcall gnus-decode-encoded-word-function
6392 (nnheader-header-value))
6393 "(none)"))
6394 ;; From.
6395 (progn
6396 (goto-char p)
6397 (if (search-forward "\nfrom:" nil t)
6398 (funcall gnus-decode-encoded-address-function
6399 (nnheader-header-value))
6400 "(nobody)"))
6401 ;; Date.
6402 (progn
6403 (goto-char p)
6404 (if (search-forward "\ndate:" nil t)
6405 (nnheader-header-value) ""))
6406 ;; Message-ID.
6407 (progn
6408 (goto-char p)
6409 (setq id (if (re-search-forward
6410 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6411 ;; We do it this way to make sure the Message-ID
6412 ;; is (somewhat) syntactically valid.
6413 (buffer-substring (match-beginning 1)
6414 (match-end 1))
6415 ;; If there was no message-id, we just fake one
6416 ;; to make subsequent routines simpler.
6417 (nnheader-generate-fake-message-id number))))
6418 ;; References.
6419 (progn
6420 (goto-char p)
6421 (if (search-forward "\nreferences:" nil t)
6422 (progn
6423 (setq end (point))
6424 (prog1
6425 (nnheader-header-value)
6426 (setq ref
6427 (buffer-substring
6428 (progn
6429 (end-of-line)
6430 (search-backward ">" end t)
6431 (1+ (point)))
6432 (progn
6433 (search-backward "<" end t)
6434 (point))))))
6435 ;; Get the references from the in-reply-to header if there
6436 ;; were no references and the in-reply-to header looks
6437 ;; promising.
6438 (if (and (search-forward "\nin-reply-to:" nil t)
6439 (setq in-reply-to (nnheader-header-value))
6440 (string-match "<[^>]+>" in-reply-to))
6441 (let (ref2)
6442 (setq ref (substring in-reply-to (match-beginning 0)
6443 (match-end 0)))
6444 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6445 (setq ref2 (substring in-reply-to (match-beginning 0)
6446 (match-end 0)))
6447 (when (> (length ref2) (length ref))
6448 (setq ref ref2)))
6449 ref)
6450 (setq ref nil))))
6451 ;; Chars.
6452 (progn
6453 (goto-char p)
6454 (if (search-forward "\nchars: " nil t)
6455 (if (numberp (setq chars (ignore-errors (read cur))))
6456 chars -1)
6457 -1))
6458 ;; Lines.
6459 (progn
6460 (goto-char p)
6461 (if (search-forward "\nlines: " nil t)
6462 (if (numberp (setq lines (ignore-errors (read cur))))
6463 lines -1)
6464 -1))
6465 ;; Xref.
6466 (progn
6467 (goto-char p)
6468 (and (search-forward "\nxref:" nil t)
6469 (nnheader-header-value)))
6470 ;; Extra.
6471 (when gnus-extra-headers
6472 (let ((extra gnus-extra-headers)
6473 out)
6474 (while extra
6475 (goto-char p)
6476 (when (search-forward
6477 (concat "\n" (symbol-name (car extra)) ":") nil t)
6478 (push (cons (car extra) (nnheader-header-value))
6479 out))
6480 (pop extra))
6481 out))))
6482 (when (equal id ref)
6483 (setq ref nil))
6485 (when gnus-alter-header-function
6486 (funcall gnus-alter-header-function header)
6487 (setq id (mail-header-id header)
6488 ref (gnus-parent-id (mail-header-references header))))
6490 (when (setq header
6491 (gnus-dependencies-add-header
6492 header dependencies force-new))
6493 (push header headers))
6494 (goto-char (point-max))
6495 (widen))
6496 (nreverse headers)))))
6498 ;; Goes through the xover lines and returns a list of vectors
6499 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6500 force-new dependencies
6501 group also-fetch-heads)
6502 "Parse the news overview data in the server buffer.
6503 Return a list of headers that match SEQUENCE (see
6504 `nntp-retrieve-headers')."
6505 ;; Get the Xref when the users reads the articles since most/some
6506 ;; NNTP servers do not include Xrefs when using XOVER.
6507 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6508 (let ((mail-parse-charset gnus-newsgroup-charset)
6509 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6510 (cur nntp-server-buffer)
6511 (dependencies (or dependencies gnus-newsgroup-dependencies))
6512 (allp (cond
6513 ((eq gnus-read-all-available-headers t)
6515 ((and (stringp gnus-read-all-available-headers)
6516 group)
6517 (string-match gnus-read-all-available-headers group))
6519 nil)))
6520 number headers header)
6521 (with-current-buffer nntp-server-buffer
6522 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6523 ;; Allow the user to mangle the headers before parsing them.
6524 (gnus-run-hooks 'gnus-parse-headers-hook)
6525 (goto-char (point-min))
6526 (gnus-parse-without-error
6527 (while (and (or sequence allp)
6528 (not (eobp)))
6529 (setq number (read cur))
6530 (when (not allp)
6531 (while (and sequence
6532 (< (car sequence) number))
6533 (setq sequence (cdr sequence))))
6534 (when (and (or allp
6535 (and sequence
6536 (eq number (car sequence))))
6537 (progn
6538 (setq sequence (cdr sequence))
6539 (setq header (inline
6540 (gnus-nov-parse-line
6541 number dependencies force-new)))))
6542 (push header headers))
6543 (forward-line 1)))
6544 ;; A common bug in inn is that if you have posted an article and
6545 ;; then retrieves the active file, it will answer correctly --
6546 ;; the new article is included. However, a NOV entry for the
6547 ;; article may not have been generated yet, so this may fail.
6548 ;; We work around this problem by retrieving the last few
6549 ;; headers using HEAD.
6550 (if (or (not also-fetch-heads)
6551 (not sequence))
6552 ;; We (probably) got all the headers.
6553 (nreverse headers)
6554 (let ((gnus-nov-is-evil t))
6555 (nconc
6556 (nreverse headers)
6557 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6558 (gnus-get-newsgroup-headers))))))))
6560 (defun gnus-article-get-xrefs ()
6561 "Fill in the Xref value in `gnus-current-headers', if necessary.
6562 This is meant to be called in `gnus-article-internal-prepare-hook'."
6563 (let ((headers (with-current-buffer gnus-summary-buffer
6564 gnus-current-headers)))
6565 (or (not gnus-use-cross-reference)
6566 (not headers)
6567 (and (mail-header-xref headers)
6568 (not (string= (mail-header-xref headers) "")))
6569 (let ((case-fold-search t)
6570 xref)
6571 (save-restriction
6572 (nnheader-narrow-to-headers)
6573 (goto-char (point-min))
6574 (when (or (and (not (eobp))
6575 (eq (downcase (char-after)) ?x)
6576 (looking-at "Xref:"))
6577 (search-forward "\nXref:" nil t))
6578 (goto-char (1+ (match-end 0)))
6579 (setq xref (buffer-substring (point) (point-at-eol)))
6580 (mail-header-set-xref headers xref)))))))
6582 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6583 "Find article ID and insert the summary line for that article.
6584 OLD-HEADER can either be a header or a line number to insert
6585 the subject line on.
6586 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6587 and OLD-HEADER will be used when the summary line is inserted,
6588 too, instead of trying to fetch new headers."
6589 (let* ((line (and (numberp old-header) old-header))
6590 (old-header (and (vectorp old-header) old-header))
6591 (header (cond ((and old-header use-old-header)
6592 old-header)
6593 ((and (numberp id)
6594 (gnus-number-to-header id))
6595 (gnus-number-to-header id))
6597 (gnus-read-header id))))
6598 (number (and (numberp id) id))
6600 (when header
6601 ;; Rebuild the thread that this article is part of and go to the
6602 ;; article we have fetched.
6603 (when (and (not gnus-show-threads)
6604 old-header)
6605 (when (and number
6606 (setq d (gnus-data-find (mail-header-number old-header))))
6607 (goto-char (gnus-data-pos d))
6608 (gnus-data-remove
6609 number
6610 (- (point-at-bol)
6611 (prog1
6612 (1+ (point-at-eol))
6613 (gnus-delete-line))))))
6614 ;; Remove list identifiers from subject.
6615 (let ((gnus-newsgroup-headers (list header)))
6616 (gnus-summary-remove-list-identifiers))
6617 (when old-header
6618 (mail-header-set-number header (mail-header-number old-header)))
6619 (setq gnus-newsgroup-sparse
6620 (delq (setq number (mail-header-number header))
6621 gnus-newsgroup-sparse))
6622 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6623 (push number gnus-newsgroup-limit)
6624 (gnus-rebuild-thread (mail-header-id header) line)
6625 (gnus-summary-goto-subject number nil t))
6626 (when (and (numberp number)
6627 (> number 0))
6628 ;; We have to update the boundaries even if we can't fetch the
6629 ;; article if ID is a number -- so that the next `P' or `N'
6630 ;; command will fetch the previous (or next) article even
6631 ;; if the one we tried to fetch this time has been canceled.
6632 (when (> number gnus-newsgroup-end)
6633 (setq gnus-newsgroup-end number))
6634 (when (< number gnus-newsgroup-begin)
6635 (setq gnus-newsgroup-begin number))
6636 (setq gnus-newsgroup-unselected
6637 (delq number gnus-newsgroup-unselected)))
6638 ;; Report back a success?
6639 (and header (mail-header-number header))))
6641 ;;; Process/prefix in the summary buffer
6643 (defun gnus-summary-work-articles (n)
6644 "Return a list of articles to be worked upon.
6645 The prefix argument, the list of process marked articles, and the
6646 current article will be taken into consideration."
6647 (with-current-buffer gnus-summary-buffer
6648 (cond
6650 ;; A numerical prefix has been given.
6651 (setq n (prefix-numeric-value n))
6652 (let ((backward (< n 0))
6653 (n (abs (prefix-numeric-value n)))
6654 articles article)
6655 (save-excursion
6656 (while
6657 (and (> n 0)
6658 (push (setq article (gnus-summary-article-number))
6659 articles)
6660 (if backward
6661 (gnus-summary-find-prev nil article)
6662 (gnus-summary-find-next nil article)))
6663 (decf n)))
6664 (nreverse articles)))
6665 ((and (gnus-region-active-p) (mark))
6666 (message "region active")
6667 ;; Work on the region between point and mark.
6668 (let ((max (max (point) (mark)))
6669 articles article)
6670 (save-excursion
6671 (goto-char (min (point) (mark)))
6672 (while
6673 (and
6674 (push (setq article (gnus-summary-article-number)) articles)
6675 (gnus-summary-find-next nil article)
6676 (< (point) max)))
6677 (nreverse articles))))
6678 (gnus-newsgroup-processable
6679 ;; There are process-marked articles present.
6680 ;; Save current state.
6681 (gnus-summary-save-process-mark)
6682 ;; Return the list.
6683 (reverse gnus-newsgroup-processable))
6685 ;; Just return the current article.
6686 (list (gnus-summary-article-number))))))
6688 (defmacro gnus-summary-iterate (arg &rest forms)
6689 "Iterate over the process/prefixed articles and do FORMS.
6690 ARG is the interactive prefix given to the command. FORMS will be
6691 executed with point over the summary line of the articles."
6692 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6693 `(let ((,articles (gnus-summary-work-articles ,arg)))
6694 (while ,articles
6695 (gnus-summary-goto-subject (car ,articles))
6696 ,@forms
6697 (pop ,articles)))))
6699 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6700 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6702 (defun gnus-summary-save-process-mark ()
6703 "Push the current set of process marked articles on the stack."
6704 (interactive)
6705 (push (copy-sequence gnus-newsgroup-processable)
6706 gnus-newsgroup-process-stack))
6708 (defun gnus-summary-kill-process-mark ()
6709 "Push the current set of process marked articles on the stack and unmark."
6710 (interactive)
6711 (gnus-summary-save-process-mark)
6712 (gnus-summary-unmark-all-processable))
6714 (defun gnus-summary-yank-process-mark ()
6715 "Pop the last process mark state off the stack and restore it."
6716 (interactive)
6717 (unless gnus-newsgroup-process-stack
6718 (error "Empty mark stack"))
6719 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6721 (defun gnus-summary-process-mark-set (set)
6722 "Make SET into the current process marked articles."
6723 (gnus-summary-unmark-all-processable)
6724 (mapc 'gnus-summary-set-process-mark set))
6726 ;;; Searching and stuff
6728 (defun gnus-summary-search-group (&optional backward use-level)
6729 "Search for next unread newsgroup.
6730 If optional argument BACKWARD is non-nil, search backward instead."
6731 (with-current-buffer gnus-group-buffer
6732 (when (gnus-group-search-forward
6733 backward nil (if use-level (gnus-group-group-level) nil))
6734 (gnus-group-group-name))))
6736 (defun gnus-summary-best-group (&optional exclude-group)
6737 "Find the name of the best unread group.
6738 If EXCLUDE-GROUP, do not go to this group."
6739 (with-current-buffer gnus-group-buffer
6740 (save-excursion
6741 (gnus-group-best-unread-group exclude-group))))
6743 (defun gnus-summary-find-next (&optional unread article backward)
6744 (if backward
6745 (gnus-summary-find-prev unread article)
6746 (let* ((dummy (gnus-summary-article-intangible-p))
6747 (article (or article (gnus-summary-article-number)))
6748 (data (gnus-data-find-list article))
6749 result)
6750 (when (and (not dummy)
6751 (or (not gnus-summary-check-current)
6752 (not unread)
6753 (not (gnus-data-unread-p (car data)))))
6754 (setq data (cdr data)))
6755 (when (setq result
6756 (if unread
6757 (progn
6758 (while data
6759 (unless (memq (gnus-data-number (car data))
6760 (cond
6761 ((eq gnus-auto-goto-ignores
6762 'always-undownloaded)
6763 gnus-newsgroup-undownloaded)
6764 (gnus-plugged
6765 nil)
6766 ((eq gnus-auto-goto-ignores
6767 'unfetched)
6768 gnus-newsgroup-unfetched)
6769 ((eq gnus-auto-goto-ignores
6770 'undownloaded)
6771 gnus-newsgroup-undownloaded)))
6772 (when (gnus-data-unread-p (car data))
6773 (setq result (car data)
6774 data nil)))
6775 (setq data (cdr data)))
6776 result)
6777 (car data)))
6778 (goto-char (gnus-data-pos result))
6779 (gnus-data-number result)))))
6781 (defun gnus-summary-find-prev (&optional unread article)
6782 (let* ((eobp (eobp))
6783 (article (or article (gnus-summary-article-number)))
6784 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6785 result)
6786 (when (and (not eobp)
6787 (or (not gnus-summary-check-current)
6788 (not unread)
6789 (not (gnus-data-unread-p (car data)))))
6790 (setq data (cdr data)))
6791 (when (setq result
6792 (if unread
6793 (progn
6794 (while data
6795 (unless (memq (gnus-data-number (car data))
6796 (cond
6797 ((eq gnus-auto-goto-ignores
6798 'always-undownloaded)
6799 gnus-newsgroup-undownloaded)
6800 (gnus-plugged
6801 nil)
6802 ((eq gnus-auto-goto-ignores
6803 'unfetched)
6804 gnus-newsgroup-unfetched)
6805 ((eq gnus-auto-goto-ignores
6806 'undownloaded)
6807 gnus-newsgroup-undownloaded)))
6808 (when (gnus-data-unread-p (car data))
6809 (setq result (car data)
6810 data nil)))
6811 (setq data (cdr data)))
6812 result)
6813 (car data)))
6814 (goto-char (gnus-data-pos result))
6815 (gnus-data-number result))))
6817 (defun gnus-summary-find-subject (subject &optional unread backward article)
6818 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6819 (article (or article (gnus-summary-article-number)))
6820 (articles (gnus-data-list backward))
6821 (arts (gnus-data-find-list article articles))
6822 result)
6823 (when (or (not gnus-summary-check-current)
6824 (not unread)
6825 (not (gnus-data-unread-p (car arts))))
6826 (setq arts (cdr arts)))
6827 (while arts
6828 (and (or (not unread)
6829 (gnus-data-unread-p (car arts)))
6830 (vectorp (gnus-data-header (car arts)))
6831 (gnus-subject-equal
6832 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6833 (setq result (car arts)
6834 arts nil))
6835 (setq arts (cdr arts)))
6836 (and result
6837 (goto-char (gnus-data-pos result))
6838 (gnus-data-number result))))
6840 (defun gnus-summary-search-forward (&optional unread subject backward)
6841 "Search forward for an article.
6842 If UNREAD, look for unread articles. If SUBJECT, look for
6843 articles with that subject. If BACKWARD, search backward instead."
6844 (cond (subject (gnus-summary-find-subject subject unread backward))
6845 (backward (gnus-summary-find-prev unread))
6846 (t (gnus-summary-find-next unread))))
6848 (defun gnus-recenter (&optional n)
6849 "Center point in window and redisplay frame.
6850 Also do horizontal recentering."
6851 (interactive "P")
6852 (when (and gnus-auto-center-summary
6853 (not (eq gnus-auto-center-summary 'vertical)))
6854 (gnus-horizontal-recenter))
6855 (if (fboundp 'recenter-top-bottom)
6856 (recenter-top-bottom n)
6857 (recenter n)))
6859 (put 'gnus-recenter 'isearch-scroll t)
6861 (defun gnus-forward-line-ignore-invisible (n)
6862 "Move N lines forward (backward if N is negative).
6863 Like forward-line, but skip over (and don't count) invisible lines."
6864 (let (done)
6865 (while (and (> n 0) (not done))
6866 ;; If the following character is currently invisible,
6867 ;; skip all characters with that same `invisible' property value.
6868 (while (gnus-invisible-p (point))
6869 (goto-char (gnus-next-char-property-change (point))))
6870 (forward-line 1)
6871 (if (eobp)
6872 (setq done t)
6873 (setq n (1- n))))
6874 (while (and (< n 0) (not done))
6875 (forward-line -1)
6876 (if (bobp) (setq done t)
6877 (setq n (1+ n))
6878 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6879 (goto-char (gnus-previous-char-property-change (point))))))))
6881 (defun gnus-summary-recenter ()
6882 "Center point in the summary window.
6883 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6884 displayed, no centering will be performed."
6885 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6886 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6887 (interactive)
6888 ;; The user has to want it.
6889 (when gnus-auto-center-summary
6890 (let* ((top (cond ((< (window-height) 4) 0)
6891 ((< (window-height) 7) 1)
6892 (t (if (numberp gnus-auto-center-summary)
6893 gnus-auto-center-summary
6894 (/ (1- (window-height)) 2)))))
6895 (height (1- (window-height)))
6896 (bottom (save-excursion
6897 (goto-char (point-max))
6898 (gnus-forward-line-ignore-invisible (- height))
6899 (point)))
6900 (window (get-buffer-window (current-buffer))))
6901 (when (get-buffer-window gnus-article-buffer)
6902 ;; Only do recentering when the article buffer is displayed,
6903 ;; Set the window start to either `bottom', which is the biggest
6904 ;; possible valid number, or the second line from the top,
6905 ;; whichever is the least.
6906 (let ((top-pos (save-excursion
6907 (gnus-forward-line-ignore-invisible (- top))
6908 (point))))
6909 (if (> bottom top-pos)
6910 ;; Keep the second line from the top visible
6911 (set-window-start window top-pos)
6912 ;; Try to keep the bottom line visible; if it's partially
6913 ;; obscured, either scroll one more line to make it fully
6914 ;; visible, or revert to using TOP-POS.
6915 (save-excursion
6916 (goto-char (point-max))
6917 (gnus-forward-line-ignore-invisible -1)
6918 (let ((last-line-start (point)))
6919 (goto-char bottom)
6920 (set-window-start window (point) t)
6921 (when (not (pos-visible-in-window-p last-line-start window))
6922 (gnus-forward-line-ignore-invisible 1)
6923 (set-window-start window (min (point) top-pos) t)))))))
6924 ;; Do horizontal recentering while we're at it.
6925 (when (and (get-buffer-window (current-buffer) t)
6926 (not (eq gnus-auto-center-summary 'vertical)))
6927 (let ((selected (selected-window)))
6928 (select-window (get-buffer-window (current-buffer) t))
6929 (gnus-summary-position-point)
6930 (gnus-horizontal-recenter)
6931 (select-window selected))))))
6933 (defun gnus-summary-jump-to-group (newsgroup)
6934 "Move point to NEWSGROUP in group mode buffer."
6935 ;; Keep update point of group mode buffer if visible.
6936 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6937 (save-window-excursion
6938 ;; Take care of tree window mode.
6939 (when (get-buffer-window gnus-group-buffer)
6940 (pop-to-buffer gnus-group-buffer))
6941 (gnus-group-jump-to-group newsgroup))
6942 (save-excursion
6943 ;; Take care of tree window mode.
6944 (if (get-buffer-window gnus-group-buffer 0)
6945 (pop-to-buffer gnus-group-buffer)
6946 (set-buffer gnus-group-buffer))
6947 (gnus-group-jump-to-group newsgroup))))
6949 ;; This function returns a list of article numbers based on the
6950 ;; difference between the ranges of read articles in this group and
6951 ;; the range of active articles.
6952 (defun gnus-list-of-unread-articles (group)
6953 (let* ((read (gnus-info-read (gnus-get-info group)))
6954 (active (or (gnus-active group) (gnus-activate-group group)))
6955 (last (or (cdr active)
6956 (error "Group %s couldn't be activated " group)))
6957 (bottom (if gnus-newsgroup-maximum-articles
6958 (max (car active)
6959 (- last gnus-newsgroup-maximum-articles -1))
6960 (car active)))
6961 first nlast unread)
6962 ;; If none are read, then all are unread.
6963 (if (not read)
6964 (setq first bottom)
6965 ;; If the range of read articles is a single range, then the
6966 ;; first unread article is the article after the last read
6967 ;; article. Sounds logical, doesn't it?
6968 (if (and (not (listp (cdr read)))
6969 (or (< (car read) bottom)
6970 (progn (setq read (list read))
6971 nil)))
6972 (setq first (max bottom (1+ (cdr read))))
6973 ;; `read' is a list of ranges.
6974 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6975 (caar read)))
6977 (setq first bottom))
6978 (while read
6979 (when first
6980 (while (< first nlast)
6981 (setq unread (cons first unread)
6982 first (1+ first))))
6983 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6984 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6985 (setq read (cdr read)))))
6986 ;; And add the last unread articles.
6987 (while (<= first last)
6988 (setq unread (cons first unread)
6989 first (1+ first)))
6990 ;; Return the list of unread articles.
6991 (delq 0 (nreverse unread))))
6993 (defun gnus-list-of-read-articles (group)
6994 "Return a list of unread, unticked and non-dormant articles."
6995 (let* ((info (gnus-get-info group))
6996 (marked (gnus-info-marks info))
6997 (active (gnus-active group)))
6998 (and info active
6999 (gnus-list-range-difference
7000 (gnus-list-range-difference
7001 (gnus-sorted-complement
7002 (gnus-uncompress-range
7003 (if gnus-newsgroup-maximum-articles
7004 (cons (max (car active)
7005 (- (cdr active)
7006 gnus-newsgroup-maximum-articles
7007 -1))
7008 (cdr active))
7009 active))
7010 (gnus-list-of-unread-articles group))
7011 (cdr (assq 'dormant marked)))
7012 (cdr (assq 'tick marked))))))
7014 ;; This function returns a sequence of article numbers based on the
7015 ;; difference between the ranges of read articles in this group and
7016 ;; the range of active articles.
7017 (defun gnus-sequence-of-unread-articles (group)
7018 (let* ((read (gnus-info-read (gnus-get-info group)))
7019 (active (or (gnus-active group) (gnus-activate-group group)))
7020 (last (cdr active))
7021 (bottom (if gnus-newsgroup-maximum-articles
7022 (max (car active)
7023 (- last gnus-newsgroup-maximum-articles -1))
7024 (car active)))
7025 first nlast unread)
7026 ;; If none are read, then all are unread.
7027 (if (not read)
7028 (setq first bottom)
7029 ;; If the range of read articles is a single range, then the
7030 ;; first unread article is the article after the last read
7031 ;; article. Sounds logical, doesn't it?
7032 (if (and (not (listp (cdr read)))
7033 (or (< (car read) bottom)
7034 (progn (setq read (list read))
7035 nil)))
7036 (setq first (max bottom (1+ (cdr read))))
7037 ;; `read' is a list of ranges.
7038 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7039 (caar read)))
7041 (setq first bottom))
7042 (while read
7043 (when first
7044 (push (cons first nlast) unread))
7045 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7046 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7047 (setq read (cdr read)))))
7048 ;; And add the last unread articles.
7049 (cond ((not (and first last))
7050 nil)
7051 ((< first last)
7052 (push (cons first last) unread))
7053 ((= first last)
7054 (push first unread)))
7055 ;; Return the sequence of unread articles.
7056 (delq 0 (nreverse unread))))
7058 ;; Various summary commands
7060 (defun gnus-summary-select-article-buffer ()
7061 "Reconfigure windows to show the article buffer.
7062 If `gnus-widen-article-window' is set, show only the article
7063 buffer."
7064 (interactive)
7065 (if (not (gnus-buffer-live-p gnus-article-buffer))
7066 (error "There is no article buffer for this summary buffer")
7067 (unless (get-buffer-window gnus-article-buffer)
7068 (gnus-summary-show-article))
7069 (gnus-configure-windows
7070 (if gnus-widen-article-window
7071 'only-article
7072 'article)
7074 (select-window (get-buffer-window gnus-article-buffer))))
7076 (defun gnus-summary-universal-argument (arg)
7077 "Perform any operation on all articles that are process/prefixed."
7078 (interactive "P")
7079 (let ((articles (gnus-summary-work-articles arg))
7080 func article)
7081 (if (eq
7082 (setq
7083 func
7084 (key-binding
7085 (read-key-sequence
7086 (substitute-command-keys
7087 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7088 'undefined)
7089 (gnus-error 1 "Undefined key")
7090 (save-excursion
7091 (while articles
7092 (gnus-summary-goto-subject (setq article (pop articles)))
7093 (let (gnus-newsgroup-processable)
7094 (command-execute func))
7095 (gnus-summary-remove-process-mark article)))))
7096 (gnus-summary-position-point))
7098 (defun gnus-summary-toggle-truncation (&optional arg)
7099 "Toggle truncation of summary lines.
7100 With ARG, turn line truncation on if ARG is positive."
7101 (interactive "P")
7102 (setq truncate-lines
7103 (if (null arg) (not truncate-lines)
7104 (> (prefix-numeric-value arg) 0)))
7105 (redraw-display))
7107 (defun gnus-summary-find-for-reselect ()
7108 "Return the number of an article to stay on across a reselect.
7109 The current article is considered, then following articles, then previous
7110 articles. An article is sought which is not canceled and isn't a temporary
7111 insertion from another group. If there's no such then return a dummy 0."
7112 (let (found)
7113 (dolist (rev '(nil t))
7114 (unless found ; don't demand the reverse list if we don't need it
7115 (let ((data (gnus-data-find-list
7116 (gnus-summary-article-number) (gnus-data-list rev))))
7117 (while (and data (not found))
7118 (if (and (< 0 (gnus-data-number (car data)))
7119 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7120 (setq found (gnus-data-number (car data))))
7121 (setq data (cdr data))))))
7122 (or found 0)))
7124 (defun gnus-summary-reselect-current-group (&optional all rescan)
7125 "Exit and then reselect the current newsgroup.
7126 The prefix argument ALL means to select all articles."
7127 (interactive "P")
7128 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7129 (error "Ephemeral groups can't be reselected"))
7130 (let ((current-subject (gnus-summary-find-for-reselect))
7131 (group gnus-newsgroup-name))
7132 (setq gnus-newsgroup-begin nil)
7133 (gnus-summary-exit nil 'leave-hidden)
7134 ;; We have to adjust the point of group mode buffer because
7135 ;; point was moved to the next unread newsgroup by exiting.
7136 (gnus-summary-jump-to-group group)
7137 (when rescan
7138 (save-excursion
7139 (gnus-group-get-new-news-this-group 1)))
7140 (gnus-group-read-group all t)
7141 (gnus-summary-goto-subject current-subject nil t)))
7143 (defun gnus-summary-rescan-group (&optional all)
7144 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7145 (interactive "P")
7146 (let ((config gnus-current-window-configuration))
7147 (gnus-summary-reselect-current-group all t)
7148 (gnus-configure-windows config)
7149 (when (eq config 'article)
7150 (gnus-summary-select-article))))
7152 (defun gnus-summary-update-info (&optional non-destructive)
7153 (save-excursion
7154 (let ((group gnus-newsgroup-name))
7155 (when group
7156 (when gnus-newsgroup-kill-headers
7157 (setq gnus-newsgroup-killed
7158 (gnus-compress-sequence
7159 (gnus-sorted-union
7160 (gnus-list-range-intersection
7161 gnus-newsgroup-unselected gnus-newsgroup-killed)
7162 gnus-newsgroup-unreads)
7163 t)))
7164 (unless (listp (cdr gnus-newsgroup-killed))
7165 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7166 (let ((headers gnus-newsgroup-headers)
7167 (ephemeral-p (gnus-ephemeral-group-p group))
7168 info)
7169 (unless ephemeral-p
7170 (setq info (copy-sequence (gnus-get-info group))
7171 info (delq (gnus-info-params info) info)))
7172 ;; Set the new ranges of read articles.
7173 (with-current-buffer gnus-group-buffer
7174 (gnus-undo-force-boundary))
7175 (gnus-update-read-articles
7176 group (gnus-sorted-union
7177 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7178 ;; Set the current article marks.
7179 (let ((gnus-newsgroup-scored
7180 (if (and (not gnus-save-score)
7181 (not non-destructive))
7183 gnus-newsgroup-scored)))
7184 (save-excursion
7185 (gnus-update-marks)))
7186 ;; Do the cross-ref thing.
7187 (when gnus-use-cross-reference
7188 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7189 ;; Do not switch windows but change the buffer to work.
7190 (set-buffer gnus-group-buffer)
7191 (unless ephemeral-p
7192 (gnus-group-update-group
7193 group nil
7194 (equal info
7195 (setq info (copy-sequence (gnus-get-info group))
7196 info (delq (gnus-info-params info) info))))))))))
7198 (defun gnus-summary-save-newsrc (&optional force)
7199 "Save the current number of read/marked articles in the dribble buffer.
7200 The dribble buffer will then be saved.
7201 If FORCE (the prefix), also save the .newsrc file(s)."
7202 (interactive "P")
7203 (gnus-summary-update-info t)
7204 (if force
7205 (gnus-save-newsrc-file)
7206 (gnus-dribble-save)))
7208 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7210 (defun gnus-summary-exit (&optional temporary leave-hidden)
7211 "Exit reading current newsgroup, and then return to group selection mode.
7212 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7213 (interactive)
7214 (gnus-set-global-variables)
7215 (when (gnus-buffer-live-p gnus-article-buffer)
7216 (with-current-buffer gnus-article-buffer
7217 (mm-destroy-parts gnus-article-mime-handles)
7218 ;; Set it to nil for safety reason.
7219 (setq gnus-article-mime-handle-alist nil)
7220 (setq gnus-article-mime-handles nil)))
7221 (gnus-kill-save-kill-buffer)
7222 (gnus-async-halt-prefetch)
7223 (let* ((group gnus-newsgroup-name)
7224 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7225 (gnus-group-is-exiting-p t)
7226 (article-buffer gnus-article-buffer)
7227 (original-article-buffer gnus-original-article-buffer)
7228 (mode major-mode)
7229 (group-point nil)
7230 (buf (current-buffer))
7231 ;; `gnus-single-article-buffer' is nil buffer-locally in
7232 ;; ephemeral group of which summary buffer will be killed,
7233 ;; but the global value may be non-nil.
7234 (single-article-buffer gnus-single-article-buffer))
7235 (unless quit-config
7236 ;; Do adaptive scoring, and possibly save score files.
7237 (when gnus-newsgroup-adaptive
7238 (gnus-score-adaptive))
7239 (when gnus-use-scoring
7240 (gnus-score-save)))
7241 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7242 (when gnus-use-cache
7243 (gnus-cache-possibly-remove-articles)
7244 (gnus-cache-save-buffers))
7245 (gnus-async-prefetch-remove-group group)
7246 (when gnus-suppress-duplicates
7247 (gnus-dup-enter-articles))
7248 (when gnus-use-trees
7249 (gnus-tree-close group))
7250 (when gnus-use-cache
7251 (gnus-cache-write-active))
7252 ;; Remove entries for this group.
7253 (nnmail-purge-split-history (gnus-group-real-name group))
7254 ;; Make all changes in this group permanent.
7255 (unless quit-config
7256 (gnus-run-hooks 'gnus-exit-group-hook)
7257 (gnus-summary-update-info))
7258 (gnus-close-group group)
7259 ;; Make sure where we were, and go to next newsgroup.
7260 (set-buffer gnus-group-buffer)
7261 (unless quit-config
7262 (gnus-group-jump-to-group group))
7263 (gnus-run-hooks 'gnus-summary-exit-hook)
7264 (unless (or quit-config
7265 (not gnus-summary-next-group-on-exit)
7266 ;; If this group has disappeared from the summary
7267 ;; buffer, don't skip forwards.
7268 (not (string= group (gnus-group-group-name))))
7269 (gnus-group-next-unread-group 1))
7270 (setq group-point (point))
7271 (if temporary
7272 nil ;Nothing to do.
7273 (set-buffer buf)
7274 (if (not gnus-kill-summary-on-exit)
7275 (progn
7276 (gnus-deaden-summary)
7277 (setq mode nil))
7278 (when (get-buffer gnus-article-buffer)
7279 (bury-buffer gnus-article-buffer))
7280 ;; Return to group mode buffer.
7281 (when (eq mode 'gnus-summary-mode)
7282 (gnus-kill-buffer buf)))
7284 (setq gnus-current-select-method gnus-select-method)
7285 (set-buffer gnus-group-buffer)
7286 (if quit-config
7287 (gnus-handle-ephemeral-exit quit-config)
7288 (goto-char group-point)
7289 ;; If gnus-group-buffer is already displayed, make sure we also move
7290 ;; the cursor in the window that displays it.
7291 (let ((win (get-buffer-window (current-buffer) 0)))
7292 (if win (set-window-point win (point))))
7293 (unless leave-hidden
7294 (gnus-configure-windows 'group 'force)))
7296 ;; If we have several article buffers, we kill them at exit.
7297 (unless single-article-buffer
7298 (when (gnus-buffer-live-p article-buffer)
7299 (with-current-buffer article-buffer
7300 ;; Don't kill sticky article buffers
7301 (unless (eq major-mode 'gnus-sticky-article-mode)
7302 (gnus-kill-buffer article-buffer)
7303 (setq gnus-article-current nil))))
7304 (gnus-kill-buffer original-article-buffer))
7306 ;; Clear the current group name.
7307 (unless quit-config
7308 (setq gnus-newsgroup-name nil)))))
7310 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7311 (defun gnus-summary-exit-no-update (&optional no-questions)
7312 "Quit reading current newsgroup without updating read article info."
7313 (interactive)
7314 (let* ((group gnus-newsgroup-name)
7315 (gnus-group-is-exiting-p t)
7316 (gnus-group-is-exiting-without-update-p t)
7317 (quit-config (gnus-group-quit-config group)))
7318 (when (or no-questions
7319 gnus-expert-user
7320 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7321 (gnus-async-halt-prefetch)
7322 (run-hooks 'gnus-summary-prepare-exit-hook)
7323 (when (gnus-buffer-live-p gnus-article-buffer)
7324 (with-current-buffer gnus-article-buffer
7325 (gnus-article-stop-animations)
7326 (gnus-stop-downloads)
7327 (mm-destroy-parts gnus-article-mime-handles)
7328 ;; Set it to nil for safety reason.
7329 (setq gnus-article-mime-handle-alist nil)
7330 (setq gnus-article-mime-handles nil)))
7331 ;; If we have several article buffers, we kill them at exit.
7332 (unless gnus-single-article-buffer
7333 (gnus-kill-buffer gnus-article-buffer)
7334 (gnus-kill-buffer gnus-original-article-buffer)
7335 (setq gnus-article-current nil))
7336 ;; Return to the group buffer.
7337 (if (not gnus-kill-summary-on-exit)
7338 (progn
7339 (gnus-deaden-summary)
7340 (gnus-configure-windows 'group 'force))
7341 (gnus-configure-windows 'group 'force)
7342 (gnus-close-group group)
7343 (gnus-kill-buffer gnus-summary-buffer))
7344 (unless gnus-single-article-buffer
7345 (setq gnus-article-current nil))
7346 (when gnus-use-trees
7347 (gnus-tree-close group))
7348 (gnus-async-prefetch-remove-group group)
7349 (when (get-buffer gnus-article-buffer)
7350 (bury-buffer gnus-article-buffer))
7351 ;; Clear the current group name.
7352 (setq gnus-newsgroup-name nil)
7353 (unless (gnus-ephemeral-group-p group)
7354 (gnus-group-update-group group nil t))
7355 (when (equal (gnus-group-group-name) group)
7356 (gnus-group-next-unread-group 1))
7357 (when quit-config
7358 (gnus-handle-ephemeral-exit quit-config)))))
7360 (defun gnus-handle-ephemeral-exit (quit-config)
7361 "Handle movement when leaving an ephemeral group.
7362 The state which existed when entering the ephemeral is reset."
7363 (if (not (buffer-live-p (car quit-config)))
7364 (gnus-configure-windows 'group 'force)
7365 (set-buffer (car quit-config))
7366 (unless (eq (cdr quit-config) 'group)
7367 (setq gnus-current-select-method
7368 (gnus-find-method-for-group gnus-newsgroup-name)))
7369 (cond ((eq major-mode 'gnus-summary-mode)
7370 (gnus-set-global-variables))
7371 ((eq major-mode 'gnus-article-mode)
7372 (save-current-buffer
7373 ;; The `gnus-summary-buffer' variable may point
7374 ;; to the old summary buffer when using a single
7375 ;; article buffer.
7376 (unless (gnus-buffer-live-p gnus-summary-buffer)
7377 (set-buffer gnus-group-buffer))
7378 (set-buffer gnus-summary-buffer)
7379 (gnus-set-global-variables))))
7380 (if (or (eq (cdr quit-config) 'article)
7381 (eq (cdr quit-config) 'pick))
7382 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7383 (gnus-configure-windows 'pick 'force)
7384 (gnus-configure-windows (cdr quit-config) 'force))
7385 (gnus-configure-windows (cdr quit-config) 'force))
7386 (when (eq major-mode 'gnus-summary-mode)
7387 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7388 next-unread-noselect))
7389 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7390 'next-noselect)
7391 (gnus-summary-next-subject 1 nil t))
7392 ((eq gnus-auto-select-on-ephemeral-exit
7393 'next-unread-noselect)
7394 (gnus-summary-next-subject 1 t t))))
7395 ;; Hide the article buffer which displays the article different
7396 ;; from the one that the cursor points to in the summary buffer.
7397 (gnus-configure-windows 'summary 'force))
7398 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7399 (gnus-summary-next-subject 1))
7400 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7401 (gnus-summary-next-subject 1 t))))
7402 (gnus-summary-recenter)
7403 (gnus-summary-position-point))))
7405 ;;; Dead summaries.
7407 (defvar gnus-dead-summary-mode-map
7408 (let ((map (make-keymap)))
7409 (suppress-keymap map)
7410 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7411 (dolist (key '("\C-d" "\r" "\177" [delete]))
7412 (define-key map key 'gnus-summary-wake-up-the-dead))
7413 (dolist (key '("q" "Q"))
7414 (define-key map key 'bury-buffer))
7415 map))
7417 (define-minor-mode gnus-dead-summary-mode
7418 "Minor mode for Gnus summary buffers."
7419 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7420 (unless (derived-mode-p 'gnus-summary-mode)
7421 (setq gnus-dead-summary-mode nil)))
7423 (defun gnus-deaden-summary ()
7424 "Make the current summary buffer into a dead summary buffer."
7425 ;; Kill any previous dead summary buffer.
7426 (when (and gnus-dead-summary
7427 (buffer-name gnus-dead-summary))
7428 (with-current-buffer gnus-dead-summary
7429 (when gnus-dead-summary-mode
7430 (kill-buffer (current-buffer)))))
7431 ;; Make this the current dead summary.
7432 (setq gnus-dead-summary (current-buffer))
7433 (gnus-dead-summary-mode 1)
7434 (let ((name (buffer-name)))
7435 (when (string-match "Summary" name)
7436 (rename-buffer
7437 (concat (substring name 0 (match-beginning 0)) "Dead "
7438 (substring name (match-beginning 0)))
7440 (bury-buffer))))
7442 (defun gnus-kill-or-deaden-summary (buffer)
7443 "Kill or deaden the summary BUFFER."
7444 (save-excursion
7445 (when (and (buffer-name buffer)
7446 (not gnus-single-article-buffer))
7447 (with-current-buffer buffer
7448 (gnus-kill-buffer gnus-article-buffer)
7449 (gnus-kill-buffer gnus-original-article-buffer)))
7450 (cond
7451 ;; Kill the buffer.
7452 (gnus-kill-summary-on-exit
7453 (when (and gnus-use-trees
7454 (gnus-buffer-exists-p buffer))
7455 (with-current-buffer buffer
7456 (gnus-tree-close gnus-newsgroup-name)))
7457 (gnus-kill-buffer buffer))
7458 ;; Deaden the buffer.
7459 ((gnus-buffer-exists-p buffer)
7460 (with-current-buffer buffer
7461 (gnus-deaden-summary))))))
7463 (defun gnus-summary-wake-up-the-dead (&rest args)
7464 "Wake up the dead summary buffer."
7465 (interactive)
7466 (gnus-dead-summary-mode -1)
7467 (let ((name (buffer-name)))
7468 (when (string-match "Dead " name)
7469 (rename-buffer
7470 (concat (substring name 0 (match-beginning 0))
7471 (substring name (match-end 0)))
7472 t)))
7473 (gnus-message 3 "This dead summary is now alive again"))
7475 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7476 (defun gnus-summary-describe-group (&optional force)
7477 "Describe the current newsgroup."
7478 (interactive "P")
7479 (gnus-group-describe-group force gnus-newsgroup-name))
7481 (defun gnus-summary-describe-briefly ()
7482 "Describe summary mode commands briefly."
7483 (interactive)
7484 (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")))
7486 ;; Walking around group mode buffer from summary mode.
7488 (defun gnus-summary-next-group (&optional no-article target-group backward)
7489 "Exit current newsgroup and then select next unread newsgroup.
7490 If prefix argument NO-ARTICLE is non-nil, no article is selected
7491 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7492 previous group instead."
7493 (interactive "P")
7494 ;; Stop pre-fetching.
7495 (gnus-async-halt-prefetch)
7496 (let ((current-group gnus-newsgroup-name)
7497 (current-buffer (current-buffer))
7498 entered)
7499 ;; First we semi-exit this group to update Xrefs and all variables.
7500 ;; We can't do a real exit, because the window conf must remain
7501 ;; the same in case the user is prompted for info, and we don't
7502 ;; want the window conf to change before that...
7503 (gnus-summary-exit t)
7504 (while (not entered)
7505 ;; Then we find what group we are supposed to enter.
7506 (set-buffer gnus-group-buffer)
7507 (gnus-group-jump-to-group current-group)
7508 (setq target-group
7509 (or target-group
7510 (if (eq gnus-keep-same-level 'best)
7511 (gnus-summary-best-group gnus-newsgroup-name)
7512 (gnus-summary-search-group backward gnus-keep-same-level))))
7513 (if (not target-group)
7514 ;; There are no further groups, so we return to the group
7515 ;; buffer.
7516 (progn
7517 (gnus-message 5 "Returning to the group buffer")
7518 (setq entered t)
7519 (when (gnus-buffer-live-p current-buffer)
7520 (set-buffer current-buffer)
7521 (gnus-summary-exit))
7522 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7523 ;; We try to enter the target group.
7524 (gnus-group-jump-to-group target-group)
7525 (let ((unreads (gnus-group-group-unread)))
7526 (if (and (or (eq t unreads)
7527 (and unreads (not (zerop unreads))))
7528 (gnus-summary-read-group
7529 target-group nil no-article
7530 (and (buffer-name current-buffer) current-buffer)
7531 nil backward))
7532 (setq entered t)
7533 (setq current-group target-group
7534 target-group nil)))))))
7536 (defun gnus-summary-prev-group (&optional no-article)
7537 "Exit current newsgroup and then select previous unread newsgroup.
7538 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7539 (interactive "P")
7540 (gnus-summary-next-group no-article nil t))
7542 ;; Walking around summary lines.
7544 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7545 "Go to the first subject satisfying any non-nil constraint.
7546 If UNREAD is non-nil, the article should be unread.
7547 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7548 If UNSEEN is non-nil, the article should be unseen as well as unread.
7549 Returns the article selected or nil if there are no matching articles."
7550 (interactive "P")
7551 (cond
7552 ;; Empty summary.
7553 ((null gnus-newsgroup-data)
7554 (gnus-message 3 "No articles in the group")
7555 nil)
7556 ;; Pick the first article.
7557 ((not (or unread undownloaded unseen))
7558 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7559 (gnus-data-number (car gnus-newsgroup-data)))
7560 ;; Find the first unread article.
7562 (let ((data gnus-newsgroup-data))
7563 (while (and data
7564 (let ((num (gnus-data-number (car data))))
7565 (or (memq num gnus-newsgroup-unfetched)
7566 (not (or (and unread
7567 (memq num gnus-newsgroup-unreads))
7568 (and undownloaded
7569 (memq num gnus-newsgroup-undownloaded))
7570 (and unseen
7571 (memq num gnus-newsgroup-unseen)
7572 (memq num gnus-newsgroup-unreads)))))))
7573 (setq data (cdr data)))
7574 (prog1
7575 (if data
7576 (progn
7577 (goto-char (gnus-data-pos (car data)))
7578 (gnus-data-number (car data)))
7579 (gnus-message 3 "No more%s articles"
7580 (let* ((r (when unread " unread"))
7581 (d (when undownloaded " undownloaded"))
7582 (s (when unseen " unseen"))
7583 (l (delq nil (list r d s))))
7584 (cond ((= 3 (length l))
7585 (concat r "," d ", or" s))
7586 ((= 2 (length l))
7587 (concat (car l) ", or" (cadr l)))
7588 ((= 1 (length l))
7589 (car l))
7591 ""))))
7594 (gnus-summary-position-point))))))
7596 (defun gnus-summary-next-subject (n &optional unread dont-display)
7597 "Go to next N'th summary line.
7598 If N is negative, go to the previous N'th subject line.
7599 If UNREAD is non-nil, only unread articles are selected.
7600 The difference between N and the actual number of steps taken is
7601 returned."
7602 (interactive "p")
7603 (let ((backward (< n 0))
7604 (n (abs n)))
7605 (while (and (> n 0)
7606 (if backward
7607 (gnus-summary-find-prev unread)
7608 (gnus-summary-find-next unread)))
7609 (unless (zerop (setq n (1- n)))
7610 (gnus-summary-show-thread)))
7611 (when (/= 0 n)
7612 (gnus-message 7 "No more%s articles"
7613 (if unread " unread" "")))
7614 (unless dont-display
7615 (gnus-summary-recenter)
7616 (gnus-summary-position-point))
7619 (defun gnus-summary-next-unread-subject (n)
7620 "Go to next N'th unread summary line."
7621 (interactive "p")
7622 (gnus-summary-next-subject n t))
7624 (defun gnus-summary-prev-subject (n &optional unread)
7625 "Go to previous N'th summary line.
7626 If optional argument UNREAD is non-nil, only unread article is selected."
7627 (interactive "p")
7628 (gnus-summary-next-subject (- n) unread))
7630 (defun gnus-summary-prev-unread-subject (n)
7631 "Go to previous N'th unread summary line."
7632 (interactive "p")
7633 (gnus-summary-next-subject (- n) t))
7635 (defun gnus-summary-goto-subjects (articles)
7636 "Insert the subject header for ARTICLES in the current buffer."
7637 (save-excursion
7638 (dolist (article articles)
7639 (gnus-summary-goto-subject article t)))
7640 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7641 (gnus-summary-position-point))
7643 (defun gnus-summary-goto-subject (article &optional force silent)
7644 "Go to the subject line of ARTICLE.
7645 If FORCE, also allow jumping to articles not currently shown."
7646 (interactive "nArticle number: ")
7647 (unless (numberp article)
7648 (error "Article %s is not a number" article))
7649 (let ((b (point))
7650 (data (gnus-data-find article)))
7651 ;; We read in the article if we have to.
7652 (and (not data)
7653 force
7654 (gnus-summary-insert-subject
7655 article
7656 (if (or (numberp force) (vectorp force)) force)
7658 (setq data (gnus-data-find article)))
7659 (goto-char b)
7660 (if (not data)
7661 (progn
7662 (unless silent
7663 (gnus-message 3 "Can't find article %d" article))
7664 nil)
7665 (let ((pt (gnus-data-pos data)))
7666 (goto-char pt)
7667 (gnus-summary-set-article-display-arrow pt))
7668 (gnus-summary-position-point)
7669 article)))
7671 ;; Walking around summary lines with displaying articles.
7673 (defun gnus-summary-expand-window (&optional arg)
7674 "Make the summary buffer take up the entire Emacs frame.
7675 Given a prefix, will force an `article' buffer configuration."
7676 (interactive "P")
7677 (if arg
7678 (gnus-configure-windows 'article 'force)
7679 (gnus-configure-windows 'summary 'force)))
7681 (defun gnus-summary-display-article (article &optional all-header)
7682 "Display ARTICLE in article buffer."
7683 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7684 (with-current-buffer gnus-article-buffer
7685 (eq major-mode 'gnus-article-mode)))
7686 (gnus-article-setup-buffer))
7687 (gnus-set-global-variables)
7688 (with-current-buffer gnus-article-buffer
7689 (setq gnus-article-charset gnus-newsgroup-charset)
7690 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7691 (mm-enable-multibyte))
7692 (if (null article)
7694 (prog1
7695 (if gnus-summary-display-article-function
7696 (funcall gnus-summary-display-article-function article all-header)
7697 (gnus-article-prepare article all-header))
7698 (gnus-run-hooks 'gnus-select-article-hook)
7699 (when (and gnus-current-article
7700 (not (zerop gnus-current-article)))
7701 (gnus-summary-goto-subject gnus-current-article))
7702 (gnus-summary-recenter)
7703 (when (and gnus-use-trees gnus-show-threads)
7704 (gnus-possibly-generate-tree article)
7705 (gnus-highlight-selected-tree article))
7706 ;; Successfully display article.
7707 (gnus-article-set-window-start
7708 (cdr (assq article gnus-newsgroup-bookmarks))))))
7710 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7711 "Select the current article.
7712 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7713 non-nil, the article will be re-fetched even if it already present in
7714 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7715 be displayed."
7716 ;; Make sure we are in the summary buffer to work around bbdb bug.
7717 (unless (eq major-mode 'gnus-summary-mode)
7718 (set-buffer gnus-summary-buffer))
7719 (let ((article (or article (gnus-summary-article-number)))
7720 (all-headers (not (not all-headers))) ;Must be t or nil.
7721 gnus-summary-display-article-function)
7722 (and (not pseudo)
7723 (gnus-summary-article-pseudo-p article)
7724 (error "This is a pseudo-article"))
7725 (with-current-buffer gnus-summary-buffer
7726 (if (or (and gnus-single-article-buffer
7727 (or (null gnus-current-article)
7728 (null gnus-article-current)
7729 (null (get-buffer gnus-article-buffer))
7730 (not (eq article (cdr gnus-article-current)))
7731 (not (equal (car gnus-article-current)
7732 gnus-newsgroup-name))
7733 (not (get-buffer gnus-original-article-buffer))))
7734 (and (not gnus-single-article-buffer)
7735 (or (null gnus-current-article)
7736 (not (get-buffer gnus-original-article-buffer))
7737 (not (eq gnus-current-article article))))
7738 force)
7739 ;; The requested article is different from the current article.
7740 (progn
7741 (gnus-summary-display-article article all-headers)
7742 (when (gnus-buffer-live-p gnus-article-buffer)
7743 (with-current-buffer gnus-article-buffer
7744 (if (not gnus-article-decoded-p) ;; a local variable
7745 (mm-disable-multibyte))))
7746 (gnus-article-set-window-start
7747 (cdr (assq article gnus-newsgroup-bookmarks)))
7748 article)
7749 'old))))
7751 (defun gnus-summary-force-verify-and-decrypt ()
7752 "Display buttons for signed/encrypted parts and verify/decrypt them."
7753 (interactive)
7754 (let ((mm-verify-option 'known)
7755 (mm-decrypt-option 'known)
7756 (gnus-article-emulate-mime t)
7757 (gnus-buttonized-mime-types (append (list "multipart/signed"
7758 "multipart/encrypted")
7759 gnus-buttonized-mime-types)))
7760 (gnus-summary-select-article nil 'force)))
7762 (defun gnus-summary-set-current-mark (&optional current-mark)
7763 "Obsolete function."
7764 nil)
7766 (defun gnus-summary-next-article (&optional unread subject backward push)
7767 "Select the next article.
7768 If UNREAD, only unread articles are selected.
7769 If SUBJECT, only articles with SUBJECT are selected.
7770 If BACKWARD, the previous article is selected instead of the next."
7771 (interactive "P")
7772 ;; Make sure we are in the summary buffer.
7773 (unless (eq major-mode 'gnus-summary-mode)
7774 (set-buffer gnus-summary-buffer))
7775 (cond
7776 ;; Is there such an article?
7777 ((and (gnus-summary-search-forward unread subject backward)
7778 (or (gnus-summary-display-article (gnus-summary-article-number))
7779 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7780 (gnus-summary-position-point))
7781 ;; If not, we try the first unread, if that is wanted.
7782 ((and subject
7783 gnus-auto-select-same
7784 (gnus-summary-first-unread-article))
7785 (gnus-summary-position-point)
7786 (gnus-message 6 "Wrapped"))
7787 ;; Try to get next/previous article not displayed in this group.
7788 ((and gnus-auto-extend-newsgroup
7789 (not unread) (not subject))
7790 (gnus-summary-goto-article
7791 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7792 nil (count-lines (point-min) (point))))
7793 ;; Go to next/previous group.
7795 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7796 (gnus-summary-jump-to-group gnus-newsgroup-name))
7797 (let ((cmd (if (featurep 'xemacs)
7798 last-command-char
7799 last-command-event))
7800 (point
7801 (with-current-buffer gnus-group-buffer
7802 (point)))
7803 (current-summary (current-buffer))
7804 (group
7805 (if (eq gnus-keep-same-level 'best)
7806 (gnus-summary-best-group gnus-newsgroup-name)
7807 (gnus-summary-search-group backward gnus-keep-same-level))))
7808 ;; Select next unread newsgroup automagically.
7809 (cond
7810 ((or (not gnus-auto-select-next)
7811 (not cmd))
7812 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7813 ((or (eq gnus-auto-select-next 'quietly)
7814 (and (eq gnus-auto-select-next 'slightly-quietly)
7815 push)
7816 (and (eq gnus-auto-select-next 'almost-quietly)
7817 (gnus-summary-last-article-p)))
7818 ;; Select quietly.
7819 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7820 (gnus-summary-exit)
7821 (gnus-message 7 "No more%s articles (%s)..."
7822 (if unread " unread" "")
7823 (if group (concat "selecting " group)
7824 "exiting"))
7825 (gnus-summary-next-group nil group backward)))
7827 (when (gnus-key-press-event-p last-input-event)
7828 ;; Somehow or other, we may now have selected a different
7829 ;; window. Make point go back to the summary buffer.
7830 (when (eq current-summary (current-buffer))
7831 ;; FIXME: This burps when get-buffer-window returns nil.
7832 (select-window (get-buffer-window current-summary 0)))
7833 (gnus-summary-walk-group-buffer
7834 gnus-newsgroup-name cmd unread backward point))))))))
7836 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7837 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7838 (?\C-p (gnus-group-prev-unread-group 1))))
7839 (cursor-in-echo-area t)
7840 keve key group ended prompt)
7841 (with-current-buffer gnus-group-buffer
7842 (goto-char start)
7843 (setq group
7844 (if (eq gnus-keep-same-level 'best)
7845 (gnus-summary-best-group gnus-newsgroup-name)
7846 (gnus-summary-search-group backward gnus-keep-same-level))))
7847 (while (not ended)
7848 (setq prompt
7849 (format
7850 "No more%s articles%s " (if unread " unread" "")
7851 (if (and group
7852 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7853 (format " (Type %s for %s [%s])"
7854 (single-key-description cmd)
7855 (gnus-group-decoded-name group)
7856 (gnus-group-unread group))
7857 (format " (Type %s to exit %s)"
7858 (single-key-description cmd)
7859 (gnus-group-decoded-name gnus-newsgroup-name)))))
7860 ;; Confirm auto selection.
7861 (setq key (car (setq keve (gnus-read-event-char prompt)))
7862 ended t)
7863 (cond
7864 ((assq key keystrokes)
7865 (let ((obuf (current-buffer)))
7866 (switch-to-buffer gnus-group-buffer)
7867 (when group
7868 (gnus-group-jump-to-group group))
7869 (eval (cadr (assq key keystrokes)))
7870 (setq group (gnus-group-group-name))
7871 (switch-to-buffer obuf))
7872 (setq ended nil))
7873 ((equal key cmd)
7874 (if (or (not group)
7875 (gnus-ephemeral-group-p gnus-newsgroup-name))
7876 (gnus-summary-exit)
7877 (gnus-summary-next-group nil group backward)))
7879 (push (cdr keve) unread-command-events))))))
7881 (defun gnus-summary-next-unread-article ()
7882 "Select unread article after current one."
7883 (interactive)
7884 (gnus-summary-next-article
7885 (or (not (eq gnus-summary-goto-unread 'never))
7886 (gnus-summary-last-article-p (gnus-summary-article-number)))
7887 (and gnus-auto-select-same
7888 (gnus-summary-article-subject))))
7890 (defun gnus-summary-prev-article (&optional unread subject)
7891 "Select the article before the current one.
7892 If UNREAD is non-nil, only unread articles are selected."
7893 (interactive "P")
7894 (gnus-summary-next-article unread subject t))
7896 (defun gnus-summary-prev-unread-article ()
7897 "Select unread article before current one."
7898 (interactive)
7899 (gnus-summary-prev-article
7900 (or (not (eq gnus-summary-goto-unread 'never))
7901 (gnus-summary-first-article-p (gnus-summary-article-number)))
7902 (and gnus-auto-select-same
7903 (gnus-summary-article-subject))))
7905 (defun gnus-summary-next-page (&optional lines circular stop)
7906 "Show next page of the selected article.
7907 If at the end of the current article, select the next article.
7908 LINES says how many lines should be scrolled up.
7910 If CIRCULAR is non-nil, go to the start of the article instead of
7911 selecting the next article when reaching the end of the current
7912 article.
7914 If STOP is non-nil, just stop when reaching the end of the message.
7916 Also see the variable `gnus-article-skip-boring'."
7917 (interactive "P")
7918 (setq gnus-summary-buffer (current-buffer))
7919 (gnus-set-global-variables)
7920 (let ((article (gnus-summary-article-number))
7921 (article-window (get-buffer-window gnus-article-buffer t))
7922 endp)
7923 ;; If the buffer is empty, we have no article.
7924 (unless article
7925 (error "No article to select"))
7926 (gnus-configure-windows 'article)
7927 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7928 (if (and (eq gnus-summary-goto-unread 'never)
7929 (not (gnus-summary-last-article-p article)))
7930 (gnus-summary-next-article)
7931 (gnus-summary-next-unread-article))
7932 (if (or (null gnus-current-article)
7933 (null gnus-article-current)
7934 (/= article (cdr gnus-article-current))
7935 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7936 ;; Selected subject is different from current article's.
7937 (gnus-summary-display-article article)
7938 (when article-window
7939 (gnus-eval-in-buffer-window gnus-article-buffer
7940 (setq endp (or (gnus-article-next-page lines)
7941 (gnus-article-only-boring-p))))
7942 (when endp
7943 (cond ((or stop gnus-summary-stop-at-end-of-message)
7944 (gnus-message 3 "End of message"))
7945 (circular
7946 (gnus-summary-beginning-of-article))
7947 (lines
7948 (gnus-message 3 "End of message"))
7949 ((null lines)
7950 (if (and (eq gnus-summary-goto-unread 'never)
7951 (not (gnus-summary-last-article-p article)))
7952 (gnus-summary-next-article)
7953 (gnus-summary-next-unread-article))))))))
7954 (gnus-summary-recenter)
7955 (gnus-summary-position-point)))
7957 (defun gnus-summary-prev-page (&optional lines move)
7958 "Show previous page of selected article.
7959 Argument LINES specifies lines to be scrolled down.
7960 If MOVE, move to the previous unread article if point is at
7961 the beginning of the buffer."
7962 (interactive "P")
7963 (let ((article (gnus-summary-article-number))
7964 (article-window (get-buffer-window gnus-article-buffer t))
7965 endp)
7966 (gnus-configure-windows 'article)
7967 (if (or (null gnus-current-article)
7968 (null gnus-article-current)
7969 (/= article (cdr gnus-article-current))
7970 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7971 ;; Selected subject is different from current article's.
7972 (gnus-summary-display-article article)
7973 (gnus-summary-recenter)
7974 (when article-window
7975 (gnus-eval-in-buffer-window gnus-article-buffer
7976 (setq endp (gnus-article-prev-page lines)))
7977 (when (and move endp)
7978 (cond (lines
7979 (gnus-message 3 "Beginning of message"))
7980 ((null lines)
7981 (if (and (eq gnus-summary-goto-unread 'never)
7982 (not (gnus-summary-first-article-p article)))
7983 (gnus-summary-prev-article)
7984 (gnus-summary-prev-unread-article))))))))
7985 (gnus-summary-position-point))
7987 (defun gnus-summary-prev-page-or-article (&optional lines)
7988 "Show previous page of selected article.
7989 Argument LINES specifies lines to be scrolled down.
7990 If at the beginning of the article, go to the next article."
7991 (interactive "P")
7992 (gnus-summary-prev-page lines t))
7994 (defun gnus-summary-scroll-up (lines)
7995 "Scroll up (or down) one line current article.
7996 Argument LINES specifies lines to be scrolled up (or down if negative).
7997 If no article is selected, then the current article will be selected first."
7998 (interactive "p")
7999 (gnus-configure-windows 'article)
8000 (gnus-summary-show-thread)
8001 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8002 (gnus-eval-in-buffer-window gnus-article-buffer
8003 (cond ((> lines 0)
8004 (when (gnus-article-next-page lines)
8005 (gnus-message 3 "End of message")))
8006 ((< lines 0)
8007 (gnus-article-prev-page (- lines))))))
8008 (gnus-summary-recenter)
8009 (gnus-summary-position-point))
8011 (defun gnus-summary-scroll-down (lines)
8012 "Scroll down (or up) one line current article.
8013 Argument LINES specifies lines to be scrolled down (or up if negative).
8014 If no article is selected, then the current article will be selected first."
8015 (interactive "p")
8016 (gnus-summary-scroll-up (- lines)))
8018 (defun gnus-summary-next-same-subject ()
8019 "Select next article which has the same subject as current one."
8020 (interactive)
8021 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8023 (defun gnus-summary-prev-same-subject ()
8024 "Select previous article which has the same subject as current one."
8025 (interactive)
8026 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8028 (defun gnus-summary-next-unread-same-subject ()
8029 "Select next unread article which has the same subject as current one."
8030 (interactive)
8031 (gnus-summary-next-article t (gnus-summary-article-subject)))
8033 (defun gnus-summary-prev-unread-same-subject ()
8034 "Select previous unread article which has the same subject as current one."
8035 (interactive)
8036 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8038 (defun gnus-summary-first-unread-article ()
8039 "Select the first unread article.
8040 Return nil if there are no unread articles."
8041 (interactive)
8042 (prog1
8043 (when (gnus-summary-first-subject t)
8044 (gnus-summary-show-thread)
8045 (gnus-summary-first-subject t)
8046 (gnus-summary-display-article (gnus-summary-article-number)))
8047 (gnus-summary-position-point)))
8049 (defun gnus-summary-first-unread-subject ()
8050 "Place the point on the subject line of the first unread article.
8051 Return nil if there are no unread articles."
8052 (interactive)
8053 (prog1
8054 (when (gnus-summary-first-subject t)
8055 (gnus-summary-show-thread)
8056 (gnus-summary-first-subject t))
8057 (gnus-summary-position-point)))
8059 (defun gnus-summary-first-unseen-subject ()
8060 "Place the point on the subject line of the first unseen article.
8061 Return nil if there are no unseen articles."
8062 (interactive)
8063 (prog1
8064 (when (gnus-summary-first-subject nil nil t)
8065 (gnus-summary-show-thread)
8066 (gnus-summary-first-subject nil nil t))
8067 (gnus-summary-position-point)))
8069 (defun gnus-summary-first-unseen-or-unread-subject ()
8070 "Place the point on the subject line of the first unseen and unread article.
8071 If all article have been seen, on the subject line of the first unread
8072 article."
8073 (interactive)
8074 (prog1
8075 (unless (when (gnus-summary-first-subject nil nil t)
8076 (gnus-summary-show-thread)
8077 (gnus-summary-first-subject nil nil t))
8078 (when (gnus-summary-first-subject t)
8079 (gnus-summary-show-thread)
8080 (gnus-summary-first-subject t)))
8081 (gnus-summary-position-point)))
8083 (defun gnus-summary-first-article ()
8084 "Select the first article.
8085 Return nil if there are no articles."
8086 (interactive)
8087 (prog1
8088 (when (gnus-summary-first-subject)
8089 (gnus-summary-show-thread)
8090 (gnus-summary-first-subject)
8091 (gnus-summary-display-article (gnus-summary-article-number)))
8092 (gnus-summary-position-point)))
8094 (defun gnus-summary-best-unread-article (&optional arg)
8095 "Select the unread article with the highest score.
8096 If given a prefix argument, select the next unread article that has a
8097 score higher than the default score."
8098 (interactive "P")
8099 (let ((article (if arg
8100 (gnus-summary-better-unread-subject)
8101 (gnus-summary-best-unread-subject))))
8102 (if article
8103 (gnus-summary-goto-article article)
8104 (error "No unread articles"))))
8106 (defun gnus-summary-best-unread-subject ()
8107 "Select the unread subject with the highest score."
8108 (interactive)
8109 (let ((best -1000000)
8110 (data gnus-newsgroup-data)
8111 article score)
8112 (while data
8113 (and (gnus-data-unread-p (car data))
8114 (> (setq score
8115 (gnus-summary-article-score (gnus-data-number (car data))))
8116 best)
8117 (setq best score
8118 article (gnus-data-number (car data))))
8119 (setq data (cdr data)))
8120 (when article
8121 (gnus-summary-goto-subject article))
8122 (gnus-summary-position-point)
8123 article))
8125 (defun gnus-summary-better-unread-subject ()
8126 "Select the first unread subject that has a score over the default score."
8127 (interactive)
8128 (let ((data gnus-newsgroup-data)
8129 article score)
8130 (while (and (setq article (gnus-data-number (car data)))
8131 (or (gnus-data-read-p (car data))
8132 (not (> (gnus-summary-article-score article)
8133 gnus-summary-default-score))))
8134 (setq data (cdr data)))
8135 (when article
8136 (gnus-summary-goto-subject article))
8137 (gnus-summary-position-point)
8138 article))
8140 (defun gnus-summary-last-subject ()
8141 "Go to the last displayed subject line in the group."
8142 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8143 (when article
8144 (gnus-summary-goto-subject article))))
8146 (defun gnus-summary-goto-article (article &optional all-headers force)
8147 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8148 If ALL-HEADERS is non-nil, no header lines are hidden.
8149 If FORCE, go to the article even if it isn't displayed. If FORCE
8150 is a number, it is the line the article is to be displayed on."
8151 (interactive
8152 (list
8153 (gnus-completing-read
8154 "Article number or Message-ID"
8155 (mapcar 'int-to-string gnus-newsgroup-limit))
8156 current-prefix-arg
8158 (prog1
8159 (if (and (stringp article)
8160 (string-match "@\\|%40" article))
8161 (gnus-summary-refer-article article)
8162 (when (stringp article)
8163 (setq article (string-to-number article)))
8164 (if (gnus-summary-goto-subject article force)
8165 (gnus-summary-display-article article all-headers)
8166 (gnus-message 4 "Couldn't go to article %s" article) nil))
8167 (gnus-summary-position-point)))
8169 (defun gnus-summary-goto-last-article ()
8170 "Go to the previously read article."
8171 (interactive)
8172 (prog1
8173 (when gnus-last-article
8174 (gnus-summary-goto-article gnus-last-article nil t))
8175 (gnus-summary-position-point)))
8177 (defun gnus-summary-pop-article (number)
8178 "Pop one article off the history and go to the previous.
8179 NUMBER articles will be popped off."
8180 (interactive "p")
8181 (let (to)
8182 (setq gnus-newsgroup-history
8183 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8184 (if to
8185 (gnus-summary-goto-article (car to) nil t)
8186 (error "Article history empty")))
8187 (gnus-summary-position-point))
8189 ;; Summary commands and functions for limiting the summary buffer.
8191 (defun gnus-summary-limit-to-articles (n)
8192 "Limit the summary buffer to the next N articles.
8193 If not given a prefix, use the process marked articles instead."
8194 (interactive "P")
8195 (prog1
8196 (let ((articles (gnus-summary-work-articles n)))
8197 (setq gnus-newsgroup-processable nil)
8198 (gnus-summary-limit articles))
8199 (gnus-summary-position-point)))
8201 (defun gnus-summary-pop-limit (&optional total)
8202 "Restore the previous limit.
8203 If given a prefix, remove all limits."
8204 (interactive "P")
8205 (when total
8206 (setq gnus-newsgroup-limits
8207 (list (mapcar (lambda (h) (mail-header-number h))
8208 gnus-newsgroup-headers))))
8209 (unless gnus-newsgroup-limits
8210 (error "No limit to pop"))
8211 (prog1
8212 (gnus-summary-limit nil 'pop)
8213 (gnus-summary-position-point)))
8215 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8216 "Limit the summary buffer to articles that have subjects that match a regexp.
8217 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8218 (interactive
8219 (list (read-string (if current-prefix-arg
8220 "Exclude subject (regexp): "
8221 "Limit to subject (regexp): "))
8222 nil current-prefix-arg))
8223 (unless header
8224 (setq header "subject"))
8225 (when (not (equal "" subject))
8226 (prog1
8227 (let ((articles (gnus-summary-find-matching
8228 (or header "subject") subject 'all nil nil
8229 not-matching)))
8230 (unless articles
8231 (error "Found no matches for \"%s\"" subject))
8232 (gnus-summary-limit articles))
8233 (gnus-summary-position-point))))
8235 (defun gnus-summary-limit-to-author (from &optional not-matching)
8236 "Limit the summary buffer to articles that have authors that match a regexp.
8237 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8238 (interactive
8239 (list (read-string (if current-prefix-arg
8240 "Exclude author (regexp): "
8241 "Limit to author (regexp): "))
8242 current-prefix-arg))
8243 (gnus-summary-limit-to-subject from "from" not-matching))
8245 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8246 "Limit the summary buffer to articles with the given RECIPIENT.
8248 If NOT-MATCHING, exclude RECIPIENT.
8250 To and Cc headers are checked. You need to include them in
8251 `nnmail-extra-headers'."
8252 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8253 (interactive
8254 (list (read-string (format "%s recipient (regexp): "
8255 (if current-prefix-arg "Exclude" "Limit to")))
8256 current-prefix-arg))
8257 (when (not (equal "" recipient))
8258 (prog1 (let* ((to
8259 (if (memq 'To nnmail-extra-headers)
8260 (gnus-summary-find-matching
8261 (cons 'extra 'To) recipient 'all nil nil
8262 not-matching)
8263 (gnus-message
8264 1 "`To' isn't present in `nnmail-extra-headers'")
8265 (sit-for 1)
8266 nil))
8268 (if (memq 'Cc nnmail-extra-headers)
8269 (gnus-summary-find-matching
8270 (cons 'extra 'Cc) recipient 'all nil nil
8271 not-matching)
8272 (gnus-message
8273 1 "`Cc' isn't present in `nnmail-extra-headers'")
8274 (sit-for 1)
8275 nil))
8276 (articles
8277 (if not-matching
8278 ;; We need the numbers that are in both lists:
8279 (mapcar (lambda (a)
8280 (and (memq a to) a))
8282 (nconc to cc))))
8283 (unless articles
8284 (error "Found no matches for \"%s\"" recipient))
8285 (gnus-summary-limit articles))
8286 (gnus-summary-position-point))))
8288 (defun gnus-summary-limit-to-address (address &optional not-matching)
8289 "Limit the summary buffer to articles with the given ADDRESS.
8291 If NOT-MATCHING, exclude ADDRESS.
8293 To, Cc and From headers are checked. You need to include `To' and `Cc'
8294 in `nnmail-extra-headers'."
8295 (interactive
8296 (list (read-string (format "%s address (regexp): "
8297 (if current-prefix-arg "Exclude" "Limit to")))
8298 current-prefix-arg))
8299 (when (not (equal "" address))
8300 (prog1 (let* ((to
8301 (if (memq 'To nnmail-extra-headers)
8302 (gnus-summary-find-matching
8303 (cons 'extra 'To) address 'all nil nil
8304 not-matching)
8305 (gnus-message
8306 1 "`To' isn't present in `nnmail-extra-headers'")
8307 (sit-for 1)
8310 (if (memq 'Cc nnmail-extra-headers)
8311 (gnus-summary-find-matching
8312 (cons 'extra 'Cc) address 'all nil nil
8313 not-matching)
8314 (gnus-message
8315 1 "`Cc' isn't present in `nnmail-extra-headers'")
8316 (sit-for 1)
8318 (from
8319 (gnus-summary-find-matching "from" address
8320 'all nil nil not-matching))
8321 (articles
8322 (if not-matching
8323 ;; We need the numbers that are in all lists:
8324 (if (eq cc t)
8325 (if (eq to t)
8326 from
8327 (mapcar (lambda (a) (car (memq a from))) to))
8328 (if (eq to t)
8329 (mapcar (lambda (a) (car (memq a from))) cc)
8330 (mapcar (lambda (a) (car (memq a from)))
8331 (mapcar (lambda (a) (car (memq a to)))
8332 cc))))
8333 (nconc (if (eq to t) nil to)
8334 (if (eq cc t) nil cc)
8335 from))))
8336 (unless articles
8337 (error "Found no matches for \"%s\"" address))
8338 (gnus-summary-limit articles))
8339 (gnus-summary-position-point))))
8341 (defun gnus-summary-limit-strange-charsets-predicate (header)
8342 (when (fboundp 'char-charset)
8343 (let ((string (concat (mail-header-subject header)
8344 (mail-header-from header)))
8345 charset found)
8346 (dotimes (i (1- (length string)))
8347 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8348 (when (string-match "unicode\\|big\\|japanese" charset)
8349 (setq found t)))
8350 found)))
8352 (defun gnus-summary-limit-to-predicate (predicate)
8353 "Limit to articles where PREDICATE returns non-nil.
8354 PREDICATE will be called with the header structures of the
8355 articles."
8356 (let ((articles nil)
8357 (case-fold-search t))
8358 (dolist (header gnus-newsgroup-headers)
8359 (when (funcall predicate header)
8360 (push (mail-header-number header) articles)))
8361 (gnus-summary-limit (nreverse articles))))
8363 (defun gnus-summary-limit-to-age (age &optional younger-p)
8364 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8365 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8366 articles that are younger than AGE days."
8367 (interactive
8368 (let ((younger current-prefix-arg)
8369 (days-got nil)
8370 days)
8371 (while (not days-got)
8372 (setq days (if younger
8373 (read-string "Limit to articles younger than (in days, older when negative): ")
8374 (read-string
8375 "Limit to articles older than (in days, younger when negative): ")))
8376 (when (> (length days) 0)
8377 (setq days (read days)))
8378 (if (numberp days)
8379 (progn
8380 (setq days-got t)
8381 (when (< days 0)
8382 (setq younger (not younger))
8383 (setq days (* days -1))))
8384 (message "Please enter a number.")
8385 (sleep-for 1)))
8386 (list days younger)))
8387 (prog1
8388 (let ((data gnus-newsgroup-data)
8389 (cutoff (days-to-time age))
8390 articles d date is-younger)
8391 (while (setq d (pop data))
8392 (when (and (vectorp (gnus-data-header d))
8393 (setq date (mail-header-date (gnus-data-header d))))
8394 (setq is-younger (time-less-p
8395 (time-since (gnus-date-get-time date))
8396 cutoff))
8397 (when (if younger-p
8398 is-younger
8399 (not is-younger))
8400 (push (gnus-data-number d) articles))))
8401 (gnus-summary-limit (nreverse articles)))
8402 (gnus-summary-position-point)))
8404 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8405 "Limit the summary buffer to articles that match an 'extra' header."
8406 (interactive
8407 (let ((header
8408 (intern
8409 (gnus-completing-read
8410 (if current-prefix-arg
8411 "Exclude extra header"
8412 "Limit extra header")
8413 (mapcar 'symbol-name gnus-extra-headers)
8414 t nil nil
8415 (symbol-name (car gnus-extra-headers))))))
8416 (list header
8417 (read-string (format "%s header %s (regexp): "
8418 (if current-prefix-arg "Exclude" "Limit to")
8419 header))
8420 current-prefix-arg)))
8421 (when (not (equal "" regexp))
8422 (prog1
8423 (let ((articles (gnus-summary-find-matching
8424 (cons 'extra header) regexp 'all nil nil
8425 not-matching)))
8426 (unless articles
8427 (error "Found no matches for \"%s\"" regexp))
8428 (gnus-summary-limit articles))
8429 (gnus-summary-position-point))))
8431 (defun gnus-summary-limit-to-display-predicate ()
8432 "Limit the summary buffer to the predicated in the `display' group parameter."
8433 (interactive)
8434 (unless gnus-newsgroup-display
8435 (error "There is no `display' group parameter"))
8436 (let (articles)
8437 (dolist (gnus-number gnus-newsgroup-articles)
8438 (when (funcall gnus-newsgroup-display)
8439 (push gnus-number articles)))
8440 (gnus-summary-limit articles))
8441 (gnus-summary-position-point))
8443 (defun gnus-summary-limit-to-unread (&optional all)
8444 "Limit the summary buffer to articles that are not marked as read.
8445 If ALL is non-nil, limit strictly to unread articles."
8446 (interactive "P")
8447 (if all
8448 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8449 (gnus-summary-limit-to-marks
8450 ;; Concat all the marks that say that an article is read and have
8451 ;; those removed.
8452 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8453 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8454 gnus-low-score-mark gnus-expirable-mark
8455 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8456 gnus-duplicate-mark)
8457 'reverse)))
8459 (defun gnus-summary-limit-to-headers (match &optional reverse)
8460 "Limit the summary buffer to articles that have headers that match MATCH.
8461 If REVERSE (the prefix), limit to articles that don't match."
8462 (interactive "sMatch headers (regexp): \nP")
8463 (gnus-summary-limit-to-bodies match reverse t))
8465 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8466 "Limit the summary buffer to articles that have bodies that match MATCH.
8467 If REVERSE (the prefix), limit to articles that don't match."
8468 (interactive "sMatch body (regexp): \nP")
8469 (let ((articles nil)
8470 (gnus-select-article-hook nil) ;Disable hook.
8471 (gnus-article-prepare-hook nil)
8472 (gnus-use-article-prefetch nil)
8473 (gnus-keep-backlog nil)
8474 (gnus-break-pages nil)
8475 (gnus-summary-display-arrow nil)
8476 (gnus-updated-mode-lines nil)
8477 (gnus-auto-center-summary nil)
8478 (gnus-display-mime-function nil))
8479 (dolist (data gnus-newsgroup-data)
8480 (let (gnus-mark-article-hook)
8481 (gnus-summary-select-article t t nil (gnus-data-number data)))
8482 (with-current-buffer gnus-article-buffer
8483 (article-goto-body)
8484 (let* ((case-fold-search t)
8485 (found (if headersp
8486 (re-search-backward match nil t)
8487 (re-search-forward match nil t))))
8488 (when (or (and found
8489 (not reverse))
8490 (and (not found)
8491 reverse))
8492 (push (gnus-data-number data) articles)))))
8493 (if (not articles)
8494 (message "No messages matched")
8495 (gnus-summary-limit articles)))
8496 (gnus-summary-position-point))
8498 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8499 "Limit the summary buffer to articles that aren't part on any thread.
8500 If THREADSP (the prefix), limit to articles that are in threads."
8501 (interactive "P")
8502 (let ((articles nil)
8503 thread-articles
8504 threads)
8505 (dolist (thread gnus-newsgroup-threads)
8506 (if (stringp (car thread))
8507 (dolist (thread (cdr thread))
8508 (push thread threads))
8509 (push thread threads)))
8510 (dolist (thread threads)
8511 (setq thread-articles (gnus-articles-in-thread thread))
8512 (when (or (and threadsp
8513 (> (length thread-articles) 1))
8514 (and (not threadsp)
8515 (= (length thread-articles) 1)))
8516 (setq articles (nconc thread-articles articles))))
8517 (if (not articles)
8518 (message "No messages matched")
8519 (gnus-summary-limit articles))
8520 (gnus-summary-position-point)))
8522 (defun gnus-summary-limit-to-replied (&optional unreplied)
8523 "Limit the summary buffer to replied articles.
8524 If UNREPLIED (the prefix), limit to unreplied articles."
8525 (interactive "P")
8526 (if unreplied
8527 (gnus-summary-limit
8528 (gnus-set-difference gnus-newsgroup-articles
8529 gnus-newsgroup-replied))
8530 (gnus-summary-limit gnus-newsgroup-replied))
8531 (gnus-summary-position-point))
8533 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8534 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8535 If REVERSE, limit the summary buffer to articles that are marked
8536 with MARKS. MARKS can either be a string of marks or a list of marks.
8537 Returns how many articles were removed."
8538 (interactive "sMarks: ")
8539 (gnus-summary-limit-to-marks marks t))
8541 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8542 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8543 If REVERSE (the prefix), limit the summary buffer to articles that are
8544 not marked with MARKS. MARKS can either be a string of marks or a
8545 list of marks.
8546 Returns how many articles were removed."
8547 (interactive "sMarks: \nP")
8548 (prog1
8549 (let ((data gnus-newsgroup-data)
8550 (marks (if (listp marks) marks
8551 (append marks nil))) ; Transform to list.
8552 articles)
8553 (while data
8554 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8555 (memq (gnus-data-mark (car data)) marks))
8556 (push (gnus-data-number (car data)) articles))
8557 (setq data (cdr data)))
8558 (gnus-summary-limit articles))
8559 (gnus-summary-position-point)))
8561 (defun gnus-summary-limit-to-score (score)
8562 "Limit to articles with score at or above SCORE."
8563 (interactive "NLimit to articles with score of at least: ")
8564 (let ((data gnus-newsgroup-data)
8565 articles)
8566 (while data
8567 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8568 score)
8569 (push (gnus-data-number (car data)) articles))
8570 (setq data (cdr data)))
8571 (prog1
8572 (gnus-summary-limit articles)
8573 (gnus-summary-position-point))))
8575 (defun gnus-summary-limit-to-unseen ()
8576 "Limit to unseen articles."
8577 (interactive)
8578 (prog1
8579 (gnus-summary-limit gnus-newsgroup-unseen)
8580 (gnus-summary-position-point)))
8582 (defun gnus-summary-limit-include-thread (id)
8583 "Display all the hidden articles that is in the thread with ID in it.
8584 When called interactively, ID is the Message-ID of the current
8585 article."
8586 (interactive (list (mail-header-id (gnus-summary-article-header))))
8587 (let ((articles (gnus-articles-in-thread
8588 (gnus-id-to-thread (gnus-root-id id))))
8589 ;;we REALLY want the whole thread---this prevents cut-threads
8590 ;;from removing the thread we want to include.
8591 (gnus-fetch-old-headers nil)
8592 (gnus-build-sparse-threads nil))
8593 (prog1
8594 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8595 (gnus-summary-limit-include-matching-articles
8596 "subject"
8597 (regexp-quote (gnus-simplify-subject-re
8598 (mail-header-subject (gnus-id-to-header id)))))
8599 (gnus-summary-position-point))))
8601 (defun gnus-summary-limit-include-matching-articles (header regexp)
8602 "Display all the hidden articles that have HEADERs that match REGEXP."
8603 (interactive (list (read-string "Match on header: ")
8604 (read-string "Regexp: ")))
8605 (let ((articles (gnus-find-matching-articles header regexp)))
8606 (prog1
8607 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8608 (gnus-summary-position-point))))
8610 (defun gnus-summary-insert-dormant-articles ()
8611 "Insert all the dormant articles for this group into the current buffer."
8612 (interactive)
8613 (let ((gnus-verbose (max 6 gnus-verbose)))
8614 (if (not gnus-newsgroup-dormant)
8615 (gnus-message 3 "No dormant articles for this group")
8616 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8618 (defun gnus-summary-insert-ticked-articles ()
8619 "Insert ticked articles for this group into the current buffer."
8620 (interactive)
8621 (let ((gnus-verbose (max 6 gnus-verbose)))
8622 (if (not gnus-newsgroup-marked)
8623 (gnus-message 3 "No ticked articles for this group")
8624 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8626 (defun gnus-summary-limit-include-dormant ()
8627 "Display all the hidden articles that are marked as dormant.
8628 Note that this command only works on a subset of the articles currently
8629 fetched for this group."
8630 (interactive)
8631 (unless gnus-newsgroup-dormant
8632 (error "There are no dormant articles in this group"))
8633 (prog1
8634 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8635 (gnus-summary-position-point)))
8637 (defun gnus-summary-include-articles (articles)
8638 "Fetch the headers for ARTICLES and then display the summary lines."
8639 (let ((gnus-inhibit-demon t)
8640 (gnus-agent nil)
8641 (gnus-read-all-available-headers t))
8642 (setq gnus-newsgroup-headers
8643 (gnus-merge
8644 'list gnus-newsgroup-headers
8645 (gnus-fetch-headers articles nil t)
8646 'gnus-article-sort-by-number))
8647 (setq gnus-newsgroup-articles
8648 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8649 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8651 (defun gnus-summary-limit-exclude-dormant ()
8652 "Hide all dormant articles."
8653 (interactive)
8654 (prog1
8655 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8656 (gnus-summary-position-point)))
8658 (defun gnus-summary-limit-exclude-childless-dormant ()
8659 "Hide all dormant articles that have no children."
8660 (interactive)
8661 (let ((data (gnus-data-list t))
8662 articles d children)
8663 ;; Find all articles that are either not dormant or have
8664 ;; children.
8665 (while (setq d (pop data))
8666 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8667 (and (setq children
8668 (gnus-article-children (gnus-data-number d)))
8669 (let (found)
8670 (while children
8671 (when (memq (car children) articles)
8672 (setq children nil
8673 found t))
8674 (pop children))
8675 found)))
8676 (push (gnus-data-number d) articles)))
8677 ;; Do the limiting.
8678 (prog1
8679 (gnus-summary-limit articles)
8680 (gnus-summary-position-point))))
8682 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8683 "Mark all unread excluded articles as read.
8684 If ALL, mark even excluded ticked and dormants as read."
8685 (interactive "P")
8686 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8687 (let ((articles (gnus-sorted-ndifference
8688 (sort
8689 (mapcar (lambda (h) (mail-header-number h))
8690 gnus-newsgroup-headers)
8692 gnus-newsgroup-limit))
8693 article)
8694 (setq gnus-newsgroup-unreads
8695 (gnus-sorted-intersection gnus-newsgroup-unreads
8696 gnus-newsgroup-limit))
8697 (if all
8698 (setq gnus-newsgroup-dormant nil
8699 gnus-newsgroup-marked nil
8700 gnus-newsgroup-reads
8701 (nconc
8702 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8703 gnus-newsgroup-reads))
8704 (while (setq article (pop articles))
8705 (unless (or (memq article gnus-newsgroup-dormant)
8706 (memq article gnus-newsgroup-marked))
8707 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8709 (defun gnus-summary-limit (articles &optional pop)
8710 (if pop
8711 ;; We pop the previous limit off the stack and use that.
8712 (setq articles (car gnus-newsgroup-limits)
8713 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8714 ;; We use the new limit, so we push the old limit on the stack.
8715 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8716 ;; Set the limit.
8717 (setq gnus-newsgroup-limit articles)
8718 (let ((total (length gnus-newsgroup-data))
8719 (data (gnus-data-find-list (gnus-summary-article-number)))
8720 (gnus-summary-mark-below nil) ; Inhibit this.
8721 found)
8722 ;; This will do all the work of generating the new summary buffer
8723 ;; according to the new limit.
8724 (gnus-summary-prepare)
8725 ;; Hide any threads, possibly.
8726 (gnus-summary-maybe-hide-threads)
8727 ;; Try to return to the article you were at, or one in the
8728 ;; neighborhood.
8729 (when data
8730 ;; We try to find some article after the current one.
8731 (while data
8732 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8733 (setq data nil
8734 found t))
8735 (setq data (cdr data))))
8736 (unless found
8737 ;; If there is no data, that means that we were after the last
8738 ;; article. The same goes when we can't find any articles
8739 ;; after the current one.
8740 (goto-char (point-max))
8741 (gnus-summary-find-prev))
8742 (gnus-set-mode-line 'summary)
8743 ;; We return how many articles were removed from the summary
8744 ;; buffer as a result of the new limit.
8745 (- total (length gnus-newsgroup-data))))
8747 (defsubst gnus-invisible-cut-children (threads)
8748 (let ((num 0))
8749 (while threads
8750 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8751 (incf num))
8752 (pop threads))
8753 (< num 2)))
8755 (defsubst gnus-cut-thread (thread)
8756 "Go forwards in the thread until we find an article that we want to display."
8757 (when (or (eq gnus-fetch-old-headers 'some)
8758 (eq gnus-fetch-old-headers 'invisible)
8759 (numberp gnus-fetch-old-headers)
8760 (eq gnus-build-sparse-threads 'some)
8761 (eq gnus-build-sparse-threads 'more))
8762 ;; Deal with old-fetched headers and sparse threads.
8763 (while (and
8764 thread
8766 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8767 (gnus-summary-article-ancient-p
8768 (mail-header-number (car thread))))
8769 (if (or (<= (length (cdr thread)) 1)
8770 (eq gnus-fetch-old-headers 'invisible))
8771 (setq gnus-newsgroup-limit
8772 (delq (mail-header-number (car thread))
8773 gnus-newsgroup-limit)
8774 thread (cadr thread))
8775 (when (gnus-invisible-cut-children (cdr thread))
8776 (let ((th (cdr thread)))
8777 (while th
8778 (if (memq (mail-header-number (caar th))
8779 gnus-newsgroup-limit)
8780 (setq thread (car th)
8781 th nil)
8782 (setq th (cdr th))))))))))
8783 thread)
8785 (defun gnus-cut-threads (threads)
8786 "Cut off all uninteresting articles from the beginning of THREADS."
8787 (when (or (eq gnus-fetch-old-headers 'some)
8788 (eq gnus-fetch-old-headers 'invisible)
8789 (numberp gnus-fetch-old-headers)
8790 (eq gnus-build-sparse-threads 'some)
8791 (eq gnus-build-sparse-threads 'more))
8792 (let ((th threads))
8793 (while th
8794 (setcar th (gnus-cut-thread (car th)))
8795 (setq th (cdr th)))))
8796 ;; Remove nixed out threads.
8797 (delq nil threads))
8799 (defun gnus-summary-initial-limit (&optional show-if-empty)
8800 "Figure out what the initial limit is supposed to be on group entry.
8801 This entails weeding out unwanted dormants, low-scored articles,
8802 fetch-old-headers verbiage, and so on."
8803 ;; Most groups have nothing to remove.
8804 (unless (or gnus-inhibit-limiting
8805 (and (null gnus-newsgroup-dormant)
8806 (eq gnus-newsgroup-display 'gnus-not-ignore)
8807 (not (eq gnus-fetch-old-headers 'some))
8808 (not (numberp gnus-fetch-old-headers))
8809 (not (eq gnus-fetch-old-headers 'invisible))
8810 (null gnus-summary-expunge-below)
8811 (not (eq gnus-build-sparse-threads 'some))
8812 (not (eq gnus-build-sparse-threads 'more))
8813 (null gnus-thread-expunge-below)))
8814 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8815 (setq gnus-newsgroup-limit nil)
8816 (mapatoms
8817 (lambda (node)
8818 (unless (car (symbol-value node))
8819 ;; These threads have no parents -- they are roots.
8820 (let ((nodes (cdr (symbol-value node)))
8821 thread)
8822 (while nodes
8823 (if (and gnus-thread-expunge-below
8824 (< (gnus-thread-total-score (car nodes))
8825 gnus-thread-expunge-below))
8826 (gnus-expunge-thread (pop nodes))
8827 (setq thread (pop nodes))
8828 (gnus-summary-limit-children thread))))))
8829 gnus-newsgroup-dependencies)
8830 ;; If this limitation resulted in an empty group, we might
8831 ;; pop the previous limit and use it instead.
8832 (when (and (not gnus-newsgroup-limit)
8833 show-if-empty)
8834 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8835 gnus-newsgroup-limit))
8837 (defun gnus-summary-limit-children (thread)
8838 "Return 1 if this subthread is visible and 0 if it is not."
8839 ;; First we get the number of visible children to this thread. This
8840 ;; is done by recursing down the thread using this function, so this
8841 ;; will really go down to a leaf article first, before slowly
8842 ;; working its way up towards the root.
8843 (when thread
8844 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8845 (children
8846 (if (cdr thread)
8847 (apply '+ (mapcar 'gnus-summary-limit-children
8848 (cdr thread)))
8850 (number (mail-header-number (car thread)))
8851 score)
8852 (if (and
8853 (not (memq number gnus-newsgroup-marked))
8855 ;; If this article is dormant and has absolutely no visible
8856 ;; children, then this article isn't visible.
8857 (and (memq number gnus-newsgroup-dormant)
8858 (zerop children))
8859 ;; If this is "fetch-old-headered" and there is no
8860 ;; visible children, then we don't want this article.
8861 (and (or (eq gnus-fetch-old-headers 'some)
8862 (numberp gnus-fetch-old-headers))
8863 (gnus-summary-article-ancient-p number)
8864 (zerop children))
8865 ;; If this is "fetch-old-headered" and `invisible', then
8866 ;; we don't want this article.
8867 (and (eq gnus-fetch-old-headers 'invisible)
8868 (gnus-summary-article-ancient-p number))
8869 ;; If this is a sparsely inserted article with no children,
8870 ;; we don't want it.
8871 (and (eq gnus-build-sparse-threads 'some)
8872 (gnus-summary-article-sparse-p number)
8873 (zerop children))
8874 ;; If we use expunging, and this article is really
8875 ;; low-scored, then we don't want this article.
8876 (when (and gnus-summary-expunge-below
8877 (< (setq score
8878 (or (cdr (assq number gnus-newsgroup-scored))
8879 gnus-summary-default-score))
8880 gnus-summary-expunge-below))
8881 ;; We increase the expunge-tally here, but that has
8882 ;; nothing to do with the limits, really.
8883 (incf gnus-newsgroup-expunged-tally)
8884 ;; We also mark as read here, if that's wanted.
8885 (when (and gnus-summary-mark-below
8886 (< score gnus-summary-mark-below))
8887 (setq gnus-newsgroup-unreads
8888 (delq number gnus-newsgroup-unreads))
8889 (if gnus-newsgroup-auto-expire
8890 (push number gnus-newsgroup-expirable)
8891 (push (cons number gnus-low-score-mark)
8892 gnus-newsgroup-reads)))
8894 ;; Do the `display' group parameter.
8895 (and gnus-newsgroup-display
8896 (let ((gnus-number number))
8897 (not (funcall gnus-newsgroup-display))))))
8898 ;; Nope, invisible article.
8900 ;; Ok, this article is to be visible, so we add it to the limit
8901 ;; and return 1.
8902 (push number gnus-newsgroup-limit)
8903 1))))
8905 (defun gnus-expunge-thread (thread)
8906 "Mark all articles in THREAD as read."
8907 (let* ((number (mail-header-number (car thread))))
8908 (incf gnus-newsgroup-expunged-tally)
8909 ;; We also mark as read here, if that's wanted.
8910 (setq gnus-newsgroup-unreads
8911 (delq number gnus-newsgroup-unreads))
8912 (if gnus-newsgroup-auto-expire
8913 (push number gnus-newsgroup-expirable)
8914 (push (cons number gnus-low-score-mark)
8915 gnus-newsgroup-reads)))
8916 ;; Go recursively through all subthreads.
8917 (mapcar 'gnus-expunge-thread (cdr thread)))
8919 ;; Summary article oriented commands
8921 (defun gnus-summary-refer-parent-article (n)
8922 "Refer parent article N times.
8923 If N is negative, go to ancestor -N instead.
8924 The difference between N and the number of articles fetched is returned."
8925 (interactive "p")
8926 (let ((skip 1)
8927 error header ref)
8928 (when (not (natnump n))
8929 (setq skip (abs n)
8930 n 1))
8931 (while (and (> n 0)
8932 (not error))
8933 (setq header (gnus-summary-article-header))
8934 (if (and (eq (mail-header-number header)
8935 (cdr gnus-article-current))
8936 (equal gnus-newsgroup-name
8937 (car gnus-article-current)))
8938 ;; If we try to find the parent of the currently
8939 ;; displayed article, then we take a look at the actual
8940 ;; References header, since this is slightly more
8941 ;; reliable than the References field we got from the
8942 ;; server.
8943 (with-current-buffer gnus-original-article-buffer
8944 (nnheader-narrow-to-headers)
8945 (unless (setq ref (message-fetch-field "references"))
8946 (when (setq ref (message-fetch-field "in-reply-to"))
8947 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8948 (widen))
8949 (setq ref
8950 ;; It's not the current article, so we take a bet on
8951 ;; the value we got from the server.
8952 (mail-header-references header)))
8953 (if (and ref
8954 (not (equal ref "")))
8955 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8956 (gnus-message 1 "Couldn't find parent"))
8957 (gnus-message 1 "No references in article %d"
8958 (gnus-summary-article-number))
8959 (setq error t))
8960 (decf n))
8961 (gnus-summary-position-point)
8964 (defun gnus-summary-refer-references ()
8965 "Fetch all articles mentioned in the References header.
8966 Return the number of articles fetched."
8967 (interactive)
8968 (let ((ref (mail-header-references (gnus-summary-article-header)))
8969 (current (gnus-summary-article-number))
8970 (n 0))
8971 (if (or (not ref)
8972 (equal ref ""))
8973 (error "No References in the current article")
8974 ;; For each Message-ID in the References header...
8975 (while (string-match "<[^>]*>" ref)
8976 (incf n)
8977 ;; ... fetch that article.
8978 (gnus-summary-refer-article
8979 (prog1 (match-string 0 ref)
8980 (setq ref (substring ref (match-end 0))))))
8981 (gnus-summary-goto-subject current)
8982 (gnus-summary-position-point)
8983 n)))
8985 (defun gnus-delete-duplicate-headers (headers)
8986 ;; First remove leading duplicates.
8987 (while (and (> (length headers) 1)
8988 (= (mail-header-number (car headers))
8989 (mail-header-number (cadr headers))))
8990 (pop headers))
8991 ;; Then the rest.
8992 (let ((result headers))
8993 (while (> (length headers) 1)
8994 (if (= (mail-header-number (car headers))
8995 (mail-header-number (cadr headers)))
8996 (setcdr headers (cddr headers))
8997 (pop headers)))
8998 result))
9000 (defun gnus-summary-refer-thread (&optional limit)
9001 "Fetch all articles in the current thread. For backends that
9002 know how to search for threads (currently only 'nnimap) a
9003 non-numeric prefix arg will use nnir to search the entire
9004 server; without a prefix arg only the current group is
9005 searched. If the variable `gnus-refer-thread-use-nnir' is
9006 non-nil the prefix arg has the reverse meaning. If no
9007 backend-specific 'request-thread function is available fetch
9008 LIMIT (the numerical prefix) old headers. If LIMIT is
9009 non-numeric or nil fetch the number specified by the
9010 `gnus-refer-thread-limit' variable."
9011 (interactive "P")
9012 (gnus-warp-to-article)
9013 (let* ((header (gnus-summary-article-header))
9014 (id (mail-header-id header))
9015 (gnus-inhibit-demon t)
9016 (gnus-summary-ignore-duplicates t)
9017 (gnus-read-all-available-headers t)
9018 (gnus-refer-thread-use-nnir
9019 (if (and (not (null limit)) (listp limit))
9020 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9021 (new-headers
9022 (if (gnus-check-backend-function
9023 'request-thread gnus-newsgroup-name)
9024 (gnus-request-thread header gnus-newsgroup-name)
9025 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9026 gnus-refer-thread-limit))
9027 (last (if (numberp limit)
9028 (min (+ (mail-header-number header)
9029 limit)
9030 gnus-newsgroup-highest)
9031 gnus-newsgroup-highest))
9032 (subject (gnus-simplify-subject
9033 (mail-header-subject header)))
9034 (refs (split-string (or (mail-header-references header)
9035 "")))
9036 (gnus-parse-headers-hook
9037 `(lambda () (goto-char (point-min))
9038 (keep-lines
9039 (regexp-opt ',(append refs (list id subject)))))))
9040 (gnus-fetch-headers (list last) (if (numberp limit)
9041 (* 2 limit) limit) t))))
9042 article-ids)
9043 (when (listp new-headers)
9044 (dolist (header new-headers)
9045 (push (mail-header-number header) article-ids)
9046 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9047 (push (mail-header-number header) gnus-newsgroup-unreads)
9048 (setq gnus-newsgroup-unselected
9049 (delete (mail-header-number header)
9050 gnus-newsgroup-unselected))))
9051 (setq gnus-newsgroup-headers
9052 (gnus-delete-duplicate-headers
9053 (gnus-merge
9054 'list gnus-newsgroup-headers new-headers
9055 'gnus-article-sort-by-number)))
9056 (setq gnus-newsgroup-articles
9057 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9058 (gnus-summary-limit-include-thread id)))
9059 (gnus-summary-show-thread))
9061 (defun gnus-summary-refer-article (message-id)
9062 "Fetch an article specified by MESSAGE-ID."
9063 (interactive "sMessage-ID: ")
9064 (gnus-warp-to-article)
9065 (when (and (stringp message-id)
9066 (not (zerop (length message-id))))
9067 (setq message-id (gnus-replace-in-string message-id " " ""))
9068 ;; Construct the correct Message-ID if necessary.
9069 ;; Suggested by tale@pawl.rpi.edu.
9070 (unless (string-match "^<" message-id)
9071 (setq message-id (concat "<" message-id)))
9072 (unless (string-match ">$" message-id)
9073 (setq message-id (concat message-id ">")))
9074 ;; People often post MIDs from URLs, so unhex it:
9075 (unless (string-match "@" message-id)
9076 (setq message-id (gnus-url-unhex-string message-id)))
9077 (let* ((header (gnus-id-to-header message-id))
9078 (sparse (and header
9079 (gnus-summary-article-sparse-p
9080 (mail-header-number header))
9081 (memq (mail-header-number header)
9082 gnus-newsgroup-limit)))
9083 number)
9084 (cond
9085 ;; If the article is present in the buffer we just go to it.
9086 ((and header
9087 (or (not (gnus-summary-article-sparse-p
9088 (mail-header-number header)))
9089 sparse))
9090 (prog1
9091 (gnus-summary-goto-article
9092 (mail-header-number header) nil t)
9093 (when sparse
9094 (gnus-summary-update-article (mail-header-number header)))))
9096 ;; We fetch the article.
9097 (catch 'found
9098 (dolist (gnus-override-method (gnus-refer-article-methods))
9099 (when (and (gnus-check-server gnus-override-method)
9100 ;; Fetch the header,
9101 (setq number (gnus-summary-insert-subject message-id)))
9102 ;; and display the article.
9103 (gnus-summary-select-article nil nil nil number)
9104 (throw 'found t)))
9105 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9107 (defun gnus-refer-article-methods ()
9108 "Return a list of referable methods."
9109 (cond
9110 ;; No method, so we default to current and native.
9111 ((null gnus-refer-article-method)
9112 (list gnus-current-select-method gnus-select-method))
9113 ;; Current.
9114 ((eq 'current gnus-refer-article-method)
9115 (list gnus-current-select-method))
9116 ;; List of select methods.
9117 ((not (and (symbolp (car gnus-refer-article-method))
9118 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9119 (let (out)
9120 (dolist (method gnus-refer-article-method)
9121 (push (if (eq 'current method)
9122 gnus-current-select-method
9123 (if (eq 'nnir (car method))
9124 (list
9125 'nnir
9126 (or (cadr method)
9127 (gnus-method-to-server gnus-current-select-method)))
9128 method))
9129 out))
9130 (nreverse out)))
9131 ;; One single select method.
9133 (list gnus-refer-article-method))))
9135 (defun gnus-summary-edit-parameters ()
9136 "Edit the group parameters of the current group."
9137 (interactive)
9138 (gnus-group-edit-group gnus-newsgroup-name 'params))
9140 (defun gnus-summary-customize-parameters ()
9141 "Customize the group parameters of the current group."
9142 (interactive)
9143 (gnus-group-customize gnus-newsgroup-name))
9145 (defun gnus-summary-enter-digest-group (&optional force)
9146 "Enter an nndoc group based on the current article.
9147 If FORCE, force a digest interpretation. If not, try to guess
9148 what the document format is.
9150 To control what happens when you exit the group, see the
9151 `gnus-auto-select-on-ephemeral-exit' variable."
9152 (interactive "P")
9153 (let ((conf gnus-current-window-configuration))
9154 (save-window-excursion
9155 (save-excursion
9156 (let (gnus-article-prepare-hook
9157 gnus-display-mime-function
9158 gnus-break-pages)
9159 (gnus-summary-select-article))))
9160 (setq gnus-current-window-configuration conf)
9161 (let* ((name (format "%s-%d"
9162 (gnus-group-prefixed-name
9163 gnus-newsgroup-name (list 'nndoc ""))
9164 (with-current-buffer gnus-summary-buffer
9165 gnus-current-article)))
9166 (ogroup gnus-newsgroup-name)
9167 (params (append (gnus-info-params (gnus-get-info ogroup))
9168 (list (cons 'to-group ogroup))
9169 (list (cons 'parent-group ogroup))
9170 (list (cons 'save-article-group ogroup))))
9171 (case-fold-search t)
9172 (buf (current-buffer))
9173 dig to-address)
9174 (with-current-buffer gnus-original-article-buffer
9175 ;; Have the digest group inherit the main mail address of
9176 ;; the parent article.
9177 (when (setq to-address (or (gnus-fetch-field "reply-to")
9178 (gnus-fetch-field "from")))
9179 (setq params
9180 (append
9181 (list (cons 'to-address
9182 (funcall gnus-decode-encoded-address-function
9183 to-address))))))
9184 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9185 (insert-buffer-substring gnus-original-article-buffer)
9186 ;; Remove lines that may lead nndoc to misinterpret the
9187 ;; document type.
9188 (narrow-to-region
9189 (goto-char (point-min))
9190 (or (search-forward "\n\n" nil t) (point)))
9191 (goto-char (point-min))
9192 (delete-matching-lines "^Path:\\|^From ")
9193 (widen))
9194 (unwind-protect
9195 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9196 (gnus-newsgroup-ephemeral-ignored-charsets
9197 gnus-newsgroup-ignored-charsets))
9198 (gnus-group-read-ephemeral-group
9199 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9200 (nndoc-article-type
9201 ,(if force 'mbox 'guess)))
9202 t nil nil nil
9203 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9204 "ADAPT")))))
9205 ;; Make all postings to this group go to the parent group.
9206 (nconc (gnus-info-params (gnus-get-info name))
9207 params)
9208 ;; Couldn't select this doc group.
9209 (switch-to-buffer buf)
9210 (gnus-set-global-variables)
9211 (gnus-configure-windows 'summary)
9212 (gnus-message 3 "Article couldn't be entered?"))
9213 (kill-buffer dig)))))
9215 (defun gnus-summary-read-document (n)
9216 "Open a new group based on the current article(s).
9217 This will allow you to read digests and other similar
9218 documents as newsgroups.
9219 Obeys the standard process/prefix convention."
9220 (interactive "P")
9221 (let* ((ogroup gnus-newsgroup-name)
9222 (params (append (gnus-info-params (gnus-get-info ogroup))
9223 (list (cons 'to-group ogroup))))
9224 group egroup groups vgroup)
9225 (dolist (article (gnus-summary-work-articles n))
9226 (setq group (format "%s-%d" gnus-newsgroup-name article))
9227 (gnus-summary-remove-process-mark article)
9228 (when (gnus-summary-display-article article)
9229 (save-excursion ;;What for?
9230 (with-temp-buffer
9231 (insert-buffer-substring gnus-original-article-buffer)
9232 ;; Remove some headers that may lead nndoc to make
9233 ;; the wrong guess.
9234 (message-narrow-to-head)
9235 (goto-char (point-min))
9236 (delete-matching-lines "^Path:\\|^From ")
9237 (widen)
9238 (if (setq egroup
9239 (gnus-group-read-ephemeral-group
9240 group `(nndoc ,group (nndoc-address ,(current-buffer))
9241 (nndoc-article-type guess))
9242 t nil t))
9243 (progn
9244 ;; Make all postings to this group go to the parent group.
9245 (nconc (gnus-info-params (gnus-get-info egroup))
9246 params)
9247 (push egroup groups))
9248 ;; Couldn't select this doc group.
9249 (gnus-error 3 "Article couldn't be entered"))))))
9250 ;; Now we have selected all the documents.
9251 (cond
9252 ((not groups)
9253 (error "None of the articles could be interpreted as documents"))
9254 ((gnus-group-read-ephemeral-group
9255 (setq vgroup (format
9256 "nnvirtual:%s-%s" gnus-newsgroup-name
9257 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9258 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9260 (cons (current-buffer) 'summary)))
9262 (error "Couldn't select virtual nndoc group")))))
9264 (defun gnus-summary-widget-forward (arg)
9265 "Move point to the next field or button in the article.
9266 With optional ARG, move across that many fields."
9267 (interactive "p")
9268 (gnus-summary-select-article)
9269 (gnus-configure-windows 'article)
9270 (select-window (gnus-get-buffer-window gnus-article-buffer))
9271 (widget-forward arg))
9273 (defun gnus-summary-isearch-article (&optional regexp-p)
9274 "Do incremental search forward on the current article.
9275 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9276 (interactive "P")
9277 (gnus-summary-select-article)
9278 (gnus-configure-windows 'article)
9279 (gnus-eval-in-buffer-window gnus-article-buffer
9280 (save-restriction
9281 (widen)
9282 (isearch-forward regexp-p))))
9284 (defun gnus-summary-repeat-search-article-forward ()
9285 "Repeat the previous search forwards."
9286 (interactive)
9287 (unless gnus-last-search-regexp
9288 (error "No previous search"))
9289 (gnus-summary-search-article-forward gnus-last-search-regexp))
9291 (defun gnus-summary-repeat-search-article-backward ()
9292 "Repeat the previous search backwards."
9293 (interactive)
9294 (unless gnus-last-search-regexp
9295 (error "No previous search"))
9296 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9298 (defun gnus-summary-search-article-forward (regexp &optional backward)
9299 "Search for an article containing REGEXP forward.
9300 If BACKWARD, search backward instead."
9301 (interactive
9302 (list (read-string
9303 (format "Search article %s (regexp%s): "
9304 (if current-prefix-arg "backward" "forward")
9305 (if gnus-last-search-regexp
9306 (concat ", default " gnus-last-search-regexp)
9307 "")))
9308 current-prefix-arg))
9309 (if (string-equal regexp "")
9310 (setq regexp (or gnus-last-search-regexp ""))
9311 (setq gnus-last-search-regexp regexp)
9312 (setq gnus-article-before-search gnus-current-article))
9313 ;; Intentionally set gnus-last-article.
9314 (setq gnus-last-article gnus-article-before-search)
9315 (let ((gnus-last-article gnus-last-article))
9316 (if (gnus-summary-search-article regexp backward)
9317 (gnus-summary-show-thread)
9318 (signal 'search-failed (list regexp)))))
9320 (defun gnus-summary-search-article-backward (regexp)
9321 "Search for an article containing REGEXP backward."
9322 (interactive
9323 (list (read-string
9324 (format "Search article backward (regexp%s): "
9325 (if gnus-last-search-regexp
9326 (concat ", default " gnus-last-search-regexp)
9327 "")))))
9328 (gnus-summary-search-article-forward regexp 'backward))
9330 (defun gnus-summary-search-article (regexp &optional backward)
9331 "Search for an article containing REGEXP.
9332 Optional argument BACKWARD means do search for backward.
9333 `gnus-select-article-hook' is not called during the search."
9334 ;; We have to require this here to make sure that the following
9335 ;; dynamic binding isn't shadowed by autoloading.
9336 (require 'gnus-async)
9337 (require 'gnus-art)
9338 (let ((gnus-select-article-hook nil) ;Disable hook.
9339 (gnus-article-prepare-hook nil)
9340 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9341 (gnus-use-article-prefetch nil)
9342 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9343 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9344 (gnus-visual nil)
9345 (gnus-keep-backlog nil)
9346 (gnus-break-pages nil)
9347 (gnus-summary-display-arrow nil)
9348 (gnus-updated-mode-lines nil)
9349 (gnus-auto-center-summary nil)
9350 (sum (current-buffer))
9351 (gnus-display-mime-function nil)
9352 (found nil)
9353 point)
9354 (gnus-save-hidden-threads
9355 (gnus-summary-select-article)
9356 (set-buffer gnus-article-buffer)
9357 (goto-char (window-point (get-buffer-window (current-buffer))))
9358 (when backward
9359 (forward-line -1))
9360 (while (not found)
9361 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9362 (if (if backward
9363 (re-search-backward regexp nil t)
9364 (re-search-forward regexp nil t))
9365 ;; We found the regexp.
9366 (progn
9367 (setq found 'found)
9368 (beginning-of-line)
9369 (set-window-start
9370 (get-buffer-window (current-buffer))
9371 (point))
9372 (forward-line 1)
9373 (set-window-point
9374 (get-buffer-window (current-buffer))
9375 (point))
9376 (set-buffer sum)
9377 (setq point (point)))
9378 ;; We didn't find it, so we go to the next article.
9379 (set-buffer sum)
9380 (setq found 'not)
9381 (while (eq found 'not)
9382 (if (not (if backward (gnus-summary-find-prev)
9383 (gnus-summary-find-next)))
9384 ;; No more articles.
9385 (setq found t)
9386 ;; Select the next article and adjust point.
9387 (unless (gnus-summary-article-sparse-p
9388 (gnus-summary-article-number))
9389 (setq found nil)
9390 (gnus-summary-select-article)
9391 (set-buffer gnus-article-buffer)
9392 (widen)
9393 (goto-char (if backward (point-max) (point-min))))))))
9394 (gnus-message 7 ""))
9395 ;; Return whether we found the regexp.
9396 (when (eq found 'found)
9397 (goto-char point)
9398 (gnus-summary-show-thread)
9399 (gnus-summary-goto-subject gnus-current-article)
9400 (gnus-summary-position-point)
9401 t)))
9403 (defun gnus-find-matching-articles (header regexp)
9404 "Return a list of all articles that match REGEXP on HEADER.
9405 This search includes all articles in the current group that Gnus has
9406 fetched headers for, whether they are displayed or not."
9407 (let ((articles nil)
9408 ;; Can't eta-reduce because it's a macro.
9409 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9410 (case-fold-search t))
9411 (dolist (header gnus-newsgroup-headers)
9412 (when (string-match regexp (funcall func header))
9413 (push (mail-header-number header) articles)))
9414 (nreverse articles)))
9416 (defun gnus-summary-find-matching (header regexp &optional backward unread
9417 not-case-fold not-matching)
9418 "Return a list of all articles that match REGEXP on HEADER.
9419 The search stars on the current article and goes forwards unless
9420 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9421 If UNREAD is non-nil, only unread articles will
9422 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9423 in the comparisons. If NOT-MATCHING, return a list of all articles that
9424 not match REGEXP on HEADER."
9425 (let ((case-fold-search (not not-case-fold))
9426 articles d func)
9427 (if (consp header)
9428 (if (eq (car header) 'extra)
9429 (setq func
9430 `(lambda (h)
9431 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9432 "")))
9433 (error "%s is an invalid header" header))
9434 (unless (fboundp (intern (concat "mail-header-" header)))
9435 (error "%s is not a valid header" header))
9436 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9437 (dolist (d (if (eq backward 'all)
9438 gnus-newsgroup-data
9439 (gnus-data-find-list
9440 (gnus-summary-article-number)
9441 (gnus-data-list backward))))
9442 (when (and (or (not unread) ; We want all articles...
9443 (gnus-data-unread-p d)) ; Or just unreads.
9444 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9445 (if not-matching
9446 (not (string-match
9447 regexp
9448 (funcall func (gnus-data-header d))))
9449 (string-match regexp
9450 (funcall func (gnus-data-header d)))))
9451 (push (gnus-data-number d) articles))) ; Success!
9452 (nreverse articles)))
9454 (defun gnus-summary-execute-command (header regexp command &optional backward)
9455 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9456 If HEADER is an empty string (or nil), the match is done on the entire
9457 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9458 (interactive
9459 (list (let ((completion-ignore-case t))
9460 (gnus-completing-read
9461 "Header name"
9462 (mapcar 'symbol-name
9463 (append
9464 '(Number Subject From Lines Date
9465 Message-ID Xref References Body)
9466 gnus-extra-headers))
9467 'require-match))
9468 (read-string "Regexp: ")
9469 (read-key-sequence "Command: ")
9470 current-prefix-arg))
9471 (when (equal header "Body")
9472 (setq header ""))
9473 ;; Hidden thread subtrees must be searched as well.
9474 (gnus-summary-show-all-threads)
9475 ;; We don't want to change current point nor window configuration.
9476 (save-excursion
9477 (save-window-excursion
9478 (let (gnus-visual
9479 gnus-treat-strip-trailing-blank-lines
9480 gnus-treat-strip-leading-blank-lines
9481 gnus-treat-strip-multiple-blank-lines
9482 gnus-treat-hide-boring-headers
9483 gnus-treat-fold-newsgroups
9484 gnus-article-prepare-hook)
9485 (gnus-message 6 "Executing %s..." (key-description command))
9486 ;; We'd like to execute COMMAND interactively so as to give arguments.
9487 (gnus-execute header regexp
9488 `(call-interactively ',(key-binding command))
9489 backward)
9490 (gnus-message 6 "Executing %s...done" (key-description command))))))
9492 (defun gnus-summary-beginning-of-article ()
9493 "Scroll the article back to the beginning."
9494 (interactive)
9495 (gnus-summary-select-article)
9496 (gnus-configure-windows 'article)
9497 (gnus-eval-in-buffer-window gnus-article-buffer
9498 (widen)
9499 (goto-char (point-min))
9500 (when gnus-break-pages
9501 (gnus-narrow-to-page))))
9503 (defun gnus-summary-end-of-article ()
9504 "Scroll to the end of the article."
9505 (interactive)
9506 (gnus-summary-select-article)
9507 (gnus-configure-windows 'article)
9508 (gnus-eval-in-buffer-window gnus-article-buffer
9509 (widen)
9510 (goto-char (point-max))
9511 (recenter -3)
9512 (when gnus-break-pages
9513 (gnus-narrow-to-page))))
9515 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9516 "Truncate to LEN and quote all \"(\"'s in STRING."
9517 (gnus-replace-in-string (if (and len (> (length string) len))
9518 (substring string 0 len)
9519 string)
9520 "[()]" "\\\\\\&"))
9522 (defun gnus-summary-print-article (&optional filename n)
9523 "Generate and print a PostScript image of the process-marked (mail) articles.
9525 If used interactively, print the current article if none are
9526 process-marked. With prefix arg, prompt the user for the name of the
9527 file to save in.
9529 When used from Lisp, accept two optional args FILENAME and N. N means
9530 to print the next N articles. If N is negative, print the N previous
9531 articles. If N is nil and articles have been marked with the process
9532 mark, print these instead.
9534 If the optional first argument FILENAME is nil, send the image to the
9535 printer. If FILENAME is a string, save the PostScript image in a file with
9536 that name. If FILENAME is a number, prompt the user for the name of the file
9537 to save in."
9538 (interactive (list (ps-print-preprint current-prefix-arg)))
9539 (dolist (article (gnus-summary-work-articles n))
9540 (gnus-summary-select-article nil nil 'pseudo article)
9541 (gnus-eval-in-buffer-window gnus-article-buffer
9542 (gnus-print-buffer))
9543 (gnus-summary-remove-process-mark article))
9544 (ps-despool filename))
9546 (defun gnus-print-buffer ()
9547 (let ((ps-left-header
9548 (list
9549 (concat "("
9550 (gnus-summary-print-truncate-and-quote
9551 (mail-header-subject gnus-current-headers)
9552 66) ")")
9553 (concat "("
9554 (gnus-summary-print-truncate-and-quote
9555 (mail-header-from gnus-current-headers)
9556 45) ")")))
9557 (ps-right-header
9558 (list
9559 "/pagenumberstring load"
9560 (concat "("
9561 (mail-header-date gnus-current-headers) ")"))))
9562 (gnus-run-hooks 'gnus-ps-print-hook)
9563 (save-excursion
9564 (if ps-print-color-p
9565 (ps-spool-buffer-with-faces)
9566 (ps-spool-buffer)))))
9568 (defun gnus-summary-show-complete-article ()
9569 "Show a complete version of the current article.
9570 This is only useful if you're looking at a partial version of the
9571 article currently."
9572 (interactive)
9573 (let ((gnus-keep-backlog nil)
9574 (gnus-use-cache nil)
9575 (gnus-agent nil)
9576 (variable (intern
9577 (format "%s-fetch-partial-articles"
9578 (car (gnus-find-method-for-group
9579 gnus-newsgroup-name)))
9580 obarray))
9581 old-val)
9582 (unwind-protect
9583 (progn
9584 (setq old-val (symbol-value variable))
9585 (set variable nil)
9586 (gnus-flush-original-article-buffer)
9587 (gnus-summary-show-article))
9588 (set variable old-val))))
9590 (defun gnus-summary-show-article (&optional arg)
9591 "Force redisplaying of the current article.
9592 If ARG (the prefix) is a number, show the article with the charset
9593 defined in `gnus-summary-show-article-charset-alist', or the charset
9594 input.
9595 If ARG (the prefix) is non-nil and not a number, show the article,
9596 but without running any of the article treatment functions
9597 article. Normally, the keystroke is `C-u g'. When using `C-u
9598 C-u g', show the raw article."
9599 (interactive "P")
9600 (cond
9601 ((numberp arg)
9602 (gnus-summary-show-article t)
9603 (let ((gnus-newsgroup-charset
9604 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9605 (mm-read-coding-system
9606 "View as charset: " ;; actually it is coding system.
9607 (with-current-buffer gnus-article-buffer
9608 (mm-detect-coding-region (point) (point-max))))))
9609 (gnus-newsgroup-ignored-charsets 'gnus-all))
9610 (gnus-summary-select-article nil 'force)
9611 (let ((deps gnus-newsgroup-dependencies)
9612 head header lines)
9613 (with-current-buffer gnus-original-article-buffer
9614 (save-restriction
9615 (message-narrow-to-head)
9616 (setq head (buffer-string))
9617 (goto-char (point-min))
9618 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9619 (goto-char (point-max))
9620 (widen)
9621 (setq lines (1- (count-lines (point) (point-max))))))
9622 (with-temp-buffer
9623 (insert (format "211 %d Article retrieved.\n"
9624 (cdr gnus-article-current)))
9625 (insert head)
9626 (if lines (insert (format "Lines: %d\n" lines)))
9627 (insert ".\n")
9628 (let ((nntp-server-buffer (current-buffer)))
9629 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9630 (gnus-data-set-header
9631 (gnus-data-find (cdr gnus-article-current))
9632 header)
9633 (gnus-summary-update-article-line
9634 (cdr gnus-article-current) header)
9635 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9636 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9637 ((not arg)
9638 ;; Select the article the normal way.
9639 (if (eq mm-text-html-renderer 'shr)
9640 (progn
9641 (require 'shr)
9642 (let ((shr-ignore-cache t))
9643 (gnus-summary-select-article nil 'force)))
9644 (gnus-summary-select-article nil 'force)))
9645 ((equal arg '(16))
9646 ;; C-u C-u g
9647 (let ((gnus-inhibit-article-treatments t))
9648 (gnus-summary-select-article nil 'force)))
9650 ;; We have to require this here to make sure that the following
9651 ;; dynamic binding isn't shadowed by autoloading.
9652 (require 'gnus-async)
9653 (require 'gnus-art)
9654 ;; Bind the article treatment functions to nil.
9655 (let ((gnus-have-all-headers t)
9656 gnus-article-prepare-hook
9657 gnus-article-decode-hook
9658 gnus-display-mime-function
9659 gnus-break-pages)
9660 ;; Destroy any MIME parts.
9661 (when (gnus-buffer-live-p gnus-article-buffer)
9662 (with-current-buffer gnus-article-buffer
9663 (gnus-article-stop-animations)
9664 (gnus-stop-downloads)
9665 (mm-destroy-parts gnus-article-mime-handles)
9666 ;; Set it to nil for safety reason.
9667 (setq gnus-article-mime-handle-alist nil)
9668 (setq gnus-article-mime-handles nil)))
9669 (gnus-summary-select-article nil 'force))))
9670 (gnus-summary-goto-subject gnus-current-article)
9671 (gnus-summary-position-point))
9673 (defun gnus-summary-show-raw-article ()
9674 "Show the raw article without any article massaging functions being run."
9675 (interactive)
9676 (gnus-summary-show-article t))
9678 (defun gnus-summary-verbose-headers (&optional arg)
9679 "Toggle permanent full header display.
9680 If ARG is a positive number, turn header display on.
9681 If ARG is a negative number, turn header display off."
9682 (interactive "P")
9683 (setq gnus-show-all-headers
9684 (cond ((or (not (numberp arg))
9685 (zerop arg))
9686 (not gnus-show-all-headers))
9687 ((natnump arg)
9688 t)))
9689 (gnus-summary-show-article))
9691 (defun gnus-summary-toggle-header (&optional arg)
9692 "Show the headers if they are hidden, or hide them if they are shown.
9693 If ARG is a positive number, show the entire header.
9694 If ARG is a negative number, hide the unwanted header lines."
9695 (interactive "P")
9696 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9697 (get-buffer-window gnus-article-buffer t))))
9698 (with-current-buffer gnus-article-buffer
9699 (widen)
9700 (article-narrow-to-head)
9701 (let* ((inhibit-read-only t)
9702 (inhibit-point-motion-hooks t)
9703 (hidden (if (numberp arg)
9704 (>= arg 0)
9705 (or (not (looking-at "[^ \t\n]+:"))
9706 (gnus-article-hidden-text-p 'headers))))
9707 s e)
9708 (delete-region (point-min) (point-max))
9709 (with-current-buffer gnus-original-article-buffer
9710 (goto-char (setq s (point-min)))
9711 (setq e (if (search-forward "\n\n" nil t)
9712 (1- (point))
9713 (point-max))))
9714 (insert-buffer-substring gnus-original-article-buffer s e)
9715 (run-hooks 'gnus-article-decode-hook)
9716 (if hidden
9717 (let ((gnus-treat-hide-headers nil)
9718 (gnus-treat-hide-boring-headers nil))
9719 (gnus-delete-wash-type 'headers)
9720 (gnus-treat-article 'head))
9721 (gnus-treat-article 'head))
9722 (widen)
9723 (if window
9724 (set-window-start window (goto-char (point-min))))
9725 (if gnus-break-pages
9726 (gnus-narrow-to-page)
9727 (when (gnus-visual-p 'page-marker)
9728 (let ((inhibit-read-only t))
9729 (gnus-remove-text-with-property 'gnus-prev)
9730 (gnus-remove-text-with-property 'gnus-next))))
9731 (gnus-set-mode-line 'article)))))
9733 (defun gnus-summary-show-all-headers ()
9734 "Make all header lines visible."
9735 (interactive)
9736 (gnus-summary-toggle-header 1))
9738 (defun gnus-summary-caesar-message (&optional arg)
9739 "Caesar rotate the current article by 13.
9740 With a non-numerical prefix, also rotate headers. A numerical
9741 prefix specifies how many places to rotate each letter forward."
9742 (interactive "P")
9743 (gnus-summary-select-article)
9744 (let ((mail-header-separator ""))
9745 (gnus-eval-in-buffer-window gnus-article-buffer
9746 (save-restriction
9747 (widen)
9748 (let ((start (window-start))
9749 (inhibit-read-only t))
9750 (if (equal arg '(4))
9751 (message-caesar-buffer-body nil t)
9752 (message-caesar-buffer-body arg))
9753 (set-window-start (get-buffer-window (current-buffer)) start)))))
9754 ;; Create buttons and stuff...
9755 (gnus-treat-article nil))
9757 (declare-function idna-to-unicode "ext:idna" (str))
9759 (defun gnus-summary-idna-message (&optional arg)
9760 "Decode IDNA encoded domain names in the current articles.
9761 IDNA encoded domain names looks like `xn--bar'. If a string
9762 remain unencoded after running this function, it is likely an
9763 invalid IDNA string (`xn--bar' is invalid).
9765 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9766 installed for this command to work."
9767 (interactive "P")
9768 (if (not (and (condition-case nil (require 'idna)
9769 (file-error))
9770 (mm-coding-system-p 'utf-8)
9771 (executable-find (symbol-value 'idna-program))))
9772 (gnus-message
9773 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9774 (gnus-summary-select-article)
9775 (let ((mail-header-separator ""))
9776 (gnus-eval-in-buffer-window gnus-article-buffer
9777 (save-restriction
9778 (widen)
9779 (let ((start (window-start))
9780 buffer-read-only)
9781 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9782 (replace-match (idna-to-unicode (match-string 1))))
9783 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9785 (defun gnus-summary-morse-message (&optional arg)
9786 "Morse decode the current article."
9787 (interactive "P")
9788 (gnus-summary-select-article)
9789 (let ((mail-header-separator ""))
9790 (gnus-eval-in-buffer-window gnus-article-buffer
9791 (save-excursion
9792 (save-restriction
9793 (widen)
9794 (let ((pos (window-start))
9795 (inhibit-read-only t))
9796 (goto-char (point-min))
9797 (when (message-goto-body)
9798 (gnus-narrow-to-body))
9799 (goto-char (point-min))
9800 (while (search-forward "·" (point-max) t)
9801 (replace-match "."))
9802 (unmorse-region (point-min) (point-max))
9803 (widen)
9804 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9806 (defun gnus-summary-stop-page-breaking ()
9807 "Stop page breaking in the current article."
9808 (interactive)
9809 (gnus-summary-select-article)
9810 (gnus-eval-in-buffer-window gnus-article-buffer
9811 (widen)
9812 (when (gnus-visual-p 'page-marker)
9813 (let ((inhibit-read-only t))
9814 (gnus-remove-text-with-property 'gnus-prev)
9815 (gnus-remove-text-with-property 'gnus-next))
9816 (setq gnus-page-broken nil))))
9818 (defun gnus-summary-move-article (&optional n to-newsgroup
9819 select-method action)
9820 "Move the current article to a different newsgroup.
9821 If N is a positive number, move the N next articles.
9822 If N is a negative number, move the N previous articles.
9823 If N is nil and any articles have been marked with the process mark,
9824 move those articles instead.
9825 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9826 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9827 re-spool using this method.
9829 When called interactively with TO-NEWSGROUP being nil, the value of
9830 the variable `gnus-move-split-methods' is used for finding a default
9831 for the target newsgroup.
9833 For this function to work, both the current newsgroup and the
9834 newsgroup that you want to move to have to support the `request-move'
9835 and `request-accept' functions.
9837 ACTION can be either `move' (the default), `crosspost' or `copy'."
9838 (interactive "P")
9839 (unless action
9840 (setq action 'move))
9841 ;; Check whether the source group supports the required functions.
9842 (cond ((and (eq action 'move)
9843 (not (gnus-check-backend-function
9844 'request-move-article gnus-newsgroup-name)))
9845 (error "The current group does not support article moving"))
9846 ((and (eq action 'crosspost)
9847 (not (gnus-check-backend-function
9848 'request-replace-article gnus-newsgroup-name)))
9849 (error "The current group does not support article editing")))
9850 (let ((articles (gnus-summary-work-articles n))
9851 (prefix (if (gnus-check-backend-function
9852 'request-move-article gnus-newsgroup-name)
9853 (funcall gnus-move-group-prefix-function
9854 gnus-newsgroup-name)
9855 ""))
9856 (names '((move "Move" "Moving")
9857 (copy "Copy" "Copying")
9858 (crosspost "Crosspost" "Crossposting")))
9859 (copy-buf (save-excursion
9860 (nnheader-set-temp-buffer " *copy article*")))
9861 art-group to-method new-xref article to-groups
9862 articles-to-update-marks encoded)
9863 (unless (assq action names)
9864 (error "Unknown action %s" action))
9865 ;; Read the newsgroup name.
9866 (when (and (not to-newsgroup)
9867 (not select-method))
9868 (if (and gnus-move-split-methods
9869 (not
9870 (and (memq gnus-current-article articles)
9871 (gnus-buffer-live-p gnus-original-article-buffer))))
9872 ;; When `gnus-move-split-methods' is non-nil, we have to
9873 ;; select an article to give `gnus-read-move-group-name' an
9874 ;; opportunity to suggest an appropriate default. However,
9875 ;; we needn't render or mark the article.
9876 (let ((gnus-display-mime-function nil)
9877 (gnus-article-prepare-hook nil)
9878 (gnus-mark-article-hook nil))
9879 (gnus-summary-select-article nil nil nil (car articles))))
9880 (setq to-newsgroup (gnus-read-move-group-name
9881 (cadr (assq action names))
9882 (symbol-value
9883 (intern (format "gnus-current-%s-group" action)))
9884 articles prefix)
9885 encoded to-newsgroup
9886 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9887 (set (intern (format "gnus-current-%s-group" action))
9888 (mm-decode-coding-string
9889 to-newsgroup
9890 (gnus-group-name-charset to-method to-newsgroup))))
9891 (unless to-method
9892 (setq to-method (or select-method
9893 (gnus-server-to-method
9894 (gnus-group-method to-newsgroup)))))
9895 (setq to-newsgroup
9896 (or encoded
9897 (and to-newsgroup
9898 (mm-encode-coding-string
9899 to-newsgroup
9900 (gnus-group-name-charset to-method to-newsgroup)))))
9901 ;; Check the method we are to move this article to...
9902 (unless (gnus-check-backend-function
9903 'request-accept-article (car to-method))
9904 (error "%s does not support article copying" (car to-method)))
9905 (unless (gnus-check-server to-method)
9906 (error "Can't open server %s" (car to-method)))
9907 (gnus-message 6 "%s to %s: %s..."
9908 (caddr (assq action names))
9909 (or (car select-method)
9910 (gnus-group-decoded-name to-newsgroup))
9911 articles)
9912 (while articles
9913 (setq article (pop articles))
9914 ;; Set any marks that may have changed in the summary buffer.
9915 (when gnus-preserve-marks
9916 (gnus-summary-push-marks-to-backend article))
9917 (setq
9918 art-group
9919 (cond
9920 ;; Move the article.
9921 ((eq action 'move)
9922 ;; Remove this article from future suppression.
9923 (gnus-dup-unsuppress-article article)
9924 (let* ((from-method (gnus-find-method-for-group
9925 gnus-newsgroup-name))
9926 (to-method (or select-method
9927 (gnus-find-method-for-group to-newsgroup)))
9928 (move-is-internal (gnus-server-equal from-method to-method)))
9929 (gnus-request-move-article
9930 article ; Article to move
9931 gnus-newsgroup-name ; From newsgroup
9932 (nth 1 (gnus-find-method-for-group
9933 gnus-newsgroup-name)) ; Server
9934 (list 'gnus-request-accept-article
9935 to-newsgroup (list 'quote select-method)
9936 (not articles) t) ; Accept form
9937 (not articles) ; Only save nov last time
9938 (and move-is-internal
9939 to-newsgroup ; Not respooling
9940 ; Is this move internal?
9941 (gnus-group-real-name to-newsgroup)))))
9942 ;; Copy the article.
9943 ((eq action 'copy)
9944 (with-current-buffer copy-buf
9945 (when (gnus-request-article-this-buffer article
9946 gnus-newsgroup-name)
9947 (save-restriction
9948 (nnheader-narrow-to-headers)
9949 (dolist (hdr gnus-copy-article-ignored-headers)
9950 (message-remove-header hdr t)))
9951 (gnus-request-accept-article
9952 to-newsgroup select-method (not articles) t))))
9953 ;; Crosspost the article.
9954 ((eq action 'crosspost)
9955 (let ((xref (message-tokenize-header
9956 (mail-header-xref (gnus-summary-article-header
9957 article))
9958 " ")))
9959 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9960 ":" (number-to-string article)))
9961 (unless xref
9962 (setq xref (list (system-name))))
9963 (setq new-xref
9964 (concat
9965 (mapconcat 'identity
9966 (delete "Xref:" (delete new-xref xref))
9967 " ")
9968 " " new-xref))
9969 (with-current-buffer copy-buf
9970 ;; First put the article in the destination group.
9971 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9972 (when (consp (setq art-group
9973 (gnus-request-accept-article
9974 to-newsgroup select-method (not articles)
9975 t)))
9976 (setq new-xref (concat new-xref " " (car art-group)
9978 (number-to-string (cdr art-group))))
9979 ;; Now we have the new Xrefs header, so we insert
9980 ;; it and replace the new article.
9981 (nnheader-replace-header "Xref" new-xref)
9982 (gnus-request-replace-article
9983 (cdr art-group) to-newsgroup (current-buffer) t)
9984 art-group))))))
9985 (cond
9986 ((not art-group)
9987 (gnus-message 1 "Couldn't %s article %s: %s"
9988 (cadr (assq action names)) article
9989 (nnheader-get-report (car to-method))))
9990 ((eq art-group 'junk)
9991 (when (eq action 'move)
9992 (gnus-summary-mark-article article gnus-canceled-mark)
9993 (gnus-message 4 "Deleted article %s" article)
9994 ;; run the delete hook
9995 (run-hook-with-args 'gnus-summary-article-delete-hook
9996 action
9997 (gnus-data-header
9998 (assoc article (gnus-data-list nil)))
9999 gnus-newsgroup-name nil
10000 select-method)))
10002 (let* ((pto-group (gnus-group-prefixed-name
10003 (car art-group) to-method))
10004 (info (gnus-get-info pto-group))
10005 (to-group (gnus-info-group info))
10006 to-marks)
10007 ;; Update the group that has been moved to.
10008 (when (and info
10009 (memq action '(move copy)))
10010 (unless (member to-group to-groups)
10011 (push to-group to-groups))
10013 (when (and (not (memq article gnus-newsgroup-unreads))
10014 (cdr art-group))
10015 (push 'read to-marks)
10016 (gnus-info-set-read
10017 info (gnus-add-to-range (gnus-info-read info)
10018 (list (cdr art-group)))))
10020 ;; See whether the article is to be put in the cache.
10021 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10022 (marks (if expirable
10023 gnus-article-mark-lists
10024 (delete '(expirable . expire)
10025 (copy-sequence
10026 gnus-article-mark-lists))))
10027 (to-article (cdr art-group)))
10029 ;; Enter the article into the cache in the new group,
10030 ;; if that is required.
10031 (when (and to-article
10032 gnus-use-cache)
10033 (gnus-cache-possibly-enter-article
10034 to-group to-article
10035 (memq article gnus-newsgroup-marked)
10036 (memq article gnus-newsgroup-dormant)
10037 (memq article gnus-newsgroup-unreads)))
10039 (when (and gnus-preserve-marks
10040 to-article)
10041 ;; Copy any marks over to the new group.
10042 (when (and (equal to-group gnus-newsgroup-name)
10043 (not (memq article gnus-newsgroup-unreads)))
10044 ;; Mark this article as read in this group.
10045 (push (cons to-article gnus-read-mark)
10046 gnus-newsgroup-reads)
10047 ;; Increase the active status of this group.
10048 (setcdr (gnus-active to-group) to-article)
10049 (setcdr gnus-newsgroup-active to-article))
10051 (while marks
10052 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10053 (when (memq article (symbol-value
10054 (intern (format "gnus-newsgroup-%s"
10055 (caar marks)))))
10056 (push (cdar marks) to-marks)
10057 ;; If the other group is the same as this group,
10058 ;; then we have to add the mark to the list.
10059 (when (equal to-group gnus-newsgroup-name)
10060 (set (intern (format "gnus-newsgroup-%s"
10061 (caar marks)))
10062 (cons to-article
10063 (symbol-value
10064 (intern (format "gnus-newsgroup-%s"
10065 (caar marks)))))))
10066 ;; Copy the marks to other group.
10067 (gnus-add-marked-articles
10068 to-group (cdar marks) (list to-article) info)))
10069 (setq marks (cdr marks)))
10071 (when (and expirable
10072 gnus-mark-copied-or-moved-articles-as-expirable
10073 (not (memq 'expire to-marks)))
10074 ;; Mark this article as expirable.
10075 (push 'expire to-marks)
10076 (when (equal to-group gnus-newsgroup-name)
10077 (push to-article gnus-newsgroup-expirable))
10078 ;; Copy the expirable mark to other group.
10079 (gnus-add-marked-articles
10080 to-group 'expire (list to-article) info))
10082 (when (and to-marks
10083 (or gnus-propagate-marks
10084 (gnus-method-option-p
10085 (gnus-find-method-for-group to-group)
10086 'server-marks)))
10087 (gnus-request-set-mark
10088 to-group (list (list (list to-article) 'add to-marks)))))
10090 (gnus-dribble-enter
10091 (concat "(gnus-group-set-info '"
10092 (gnus-prin1-to-string (gnus-get-info to-group))
10093 ")")
10094 (concat "^(gnus-group-set-info '(\""
10095 (regexp-quote to-group) "\""))))
10097 ;; Update the Xref header in this article to point to
10098 ;; the new crossposted article we have just created.
10099 (when (eq action 'crosspost)
10100 (with-current-buffer copy-buf
10101 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10102 (nnheader-replace-header "Xref" new-xref)
10103 (gnus-request-replace-article
10104 article gnus-newsgroup-name (current-buffer) t)))
10106 ;; run the move/copy/crosspost/respool hook
10107 (run-hook-with-args 'gnus-summary-article-move-hook
10108 action
10109 (gnus-data-header
10110 (assoc article (gnus-data-list nil)))
10111 gnus-newsgroup-name
10112 to-newsgroup
10113 select-method))
10115 ;;;!!!Why is this necessary?
10116 (set-buffer gnus-summary-buffer)
10118 (when (eq action 'move)
10119 (save-excursion
10120 (gnus-summary-goto-subject article)
10121 (gnus-summary-mark-article article gnus-canceled-mark)))))
10122 (push article articles-to-update-marks))
10124 (save-excursion
10125 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10126 ;; Re-activate all groups that have been moved to.
10127 (with-current-buffer gnus-group-buffer
10128 (let ((gnus-group-marked to-groups))
10129 (gnus-group-get-new-news-this-group nil t)))
10131 (gnus-kill-buffer copy-buf)
10132 (gnus-summary-position-point)
10133 (gnus-set-mode-line 'summary)))
10135 (defun gnus-summary-push-marks-to-backend (article)
10136 (let ((set nil)
10137 (marks gnus-article-mark-lists))
10138 (unless (memq article gnus-newsgroup-unreads)
10139 (push 'read set))
10140 (while marks
10141 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10142 (memq article (symbol-value
10143 (intern (format "gnus-newsgroup-%s"
10144 (caar marks))))))
10145 (push (cdar marks) set))
10146 (pop marks))
10147 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10149 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10150 "Copy the current article to some other group.
10151 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10152 When called interactively, if TO-NEWSGROUP is nil, use the value of
10153 the variable `gnus-move-split-methods' for finding a default target
10154 newsgroup.
10155 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10156 re-spool using this method."
10157 (interactive "P")
10158 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10160 (defun gnus-summary-crosspost-article (&optional n)
10161 "Crosspost the current article to some other group."
10162 (interactive "P")
10163 (gnus-summary-move-article n nil nil 'crosspost))
10165 (defcustom gnus-summary-respool-default-method nil
10166 "Default method type for respooling an article.
10167 If nil, use to the current newsgroup method."
10168 :type 'symbol
10169 :group 'gnus-summary-mail)
10171 (defun gnus-summary-respool-article (&optional n method)
10172 "Respool the current article.
10173 The article will be squeezed through the mail spooling process again,
10174 which means that it will be put in some mail newsgroup or other
10175 depending on `nnmail-split-methods'.
10176 If N is a positive number, respool the N next articles.
10177 If N is a negative number, respool the N previous articles.
10178 If N is nil and any articles have been marked with the process mark,
10179 respool those articles instead.
10181 Respooling can be done both from mail groups and \"real\" newsgroups.
10182 In the former case, the articles in question will be moved from the
10183 current group into whatever groups they are destined to. In the
10184 latter case, they will be copied into the relevant groups."
10185 (interactive
10186 (list current-prefix-arg
10187 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10188 (methname
10189 (symbol-name (or gnus-summary-respool-default-method
10190 (car (gnus-find-method-for-group
10191 gnus-newsgroup-name)))))
10192 (method
10193 (gnus-completing-read
10194 "Backend to use when respooling"
10195 methods t nil 'gnus-mail-method-history methname))
10197 (cond
10198 ((zerop (length (setq ms (gnus-servers-using-backend
10199 (intern method)))))
10200 (list (intern method) ""))
10201 ((= 1 (length ms))
10202 (car ms))
10204 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10205 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10206 ms-alist))))))))
10207 (unless method
10208 (error "No method given for respooling"))
10209 (if (assoc (symbol-name
10210 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10211 (gnus-methods-using 'respool))
10212 (gnus-summary-move-article n nil method)
10213 (gnus-summary-copy-article n nil method)))
10215 (defun gnus-summary-import-article (file &optional edit)
10216 "Import an arbitrary file into a mail newsgroup."
10217 (interactive "fImport file: \nP")
10218 (let ((group gnus-newsgroup-name)
10219 (now (current-time))
10220 atts lines group-art)
10221 (unless (gnus-check-backend-function 'request-accept-article group)
10222 (error "%s does not support article importing" group))
10223 (or (file-readable-p file)
10224 (not (file-regular-p file))
10225 (error "Can't read %s" file))
10226 (with-current-buffer (gnus-get-buffer-create " *import file*")
10227 (erase-buffer)
10228 (nnheader-insert-file-contents file)
10229 (goto-char (point-min))
10230 (if (nnheader-article-p)
10231 (save-restriction
10232 (goto-char (point-min))
10233 (search-forward "\n\n" nil t)
10234 (narrow-to-region (point-min) (1- (point)))
10235 (goto-char (point-min))
10236 (unless (re-search-forward "^date:" nil t)
10237 (goto-char (point-max))
10238 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10239 ;; This doesn't look like an article, so we fudge some headers.
10240 (setq atts (file-attributes file)
10241 lines (count-lines (point-min) (point-max)))
10242 (insert "From: " (read-string "From: ") "\n"
10243 "Subject: " (read-string "Subject: ") "\n"
10244 "Date: " (message-make-date (nth 5 atts)) "\n"
10245 "Message-ID: " (message-make-message-id) "\n"
10246 "Lines: " (int-to-string lines) "\n"
10247 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10248 (setq group-art (gnus-request-accept-article group nil t))
10249 (kill-buffer (current-buffer)))
10250 (setq gnus-newsgroup-active (gnus-activate-group group))
10251 (forward-line 1)
10252 (gnus-summary-goto-article (cdr group-art) nil t)
10253 (when edit
10254 (gnus-summary-edit-article))))
10256 (defun gnus-summary-create-article ()
10257 "Create an article in a mail newsgroup."
10258 (interactive)
10259 (let ((group gnus-newsgroup-name)
10260 (now (current-time))
10261 group-art)
10262 (unless (gnus-check-backend-function 'request-accept-article group)
10263 (error "%s does not support article importing" group))
10264 (with-current-buffer (gnus-get-buffer-create " *import file*")
10265 (erase-buffer)
10266 (goto-char (point-min))
10267 ;; This doesn't look like an article, so we fudge some headers.
10268 (insert "From: " (read-string "From: ") "\n"
10269 "Subject: " (read-string "Subject: ") "\n"
10270 "Date: " (message-make-date now) "\n"
10271 "Message-ID: " (message-make-message-id) "\n")
10272 (setq group-art (gnus-request-accept-article group nil t))
10273 (kill-buffer (current-buffer)))
10274 (setq gnus-newsgroup-active (gnus-activate-group group))
10275 (forward-line 1)
10276 (gnus-summary-goto-article (cdr group-art) nil t)
10277 (gnus-summary-edit-article)))
10279 (defun gnus-summary-article-posted-p ()
10280 "Say whether the current (mail) article is available from news as well.
10281 This will be the case if the article has both been mailed and posted."
10282 (interactive)
10283 (let ((id (mail-header-references (gnus-summary-article-header)))
10284 (gnus-override-method (car (gnus-refer-article-methods))))
10285 (if (gnus-request-head id "")
10286 (gnus-message 2 "The current message was found on %s"
10287 gnus-override-method)
10288 (gnus-message 2 "The current message couldn't be found on %s"
10289 gnus-override-method)
10290 nil)))
10292 (defun gnus-summary-expire-articles (&optional now)
10293 "Expire all articles that are marked as expirable in the current group."
10294 (interactive)
10295 (when (and (not gnus-group-is-exiting-without-update-p)
10296 (gnus-check-backend-function
10297 'request-expire-articles gnus-newsgroup-name))
10298 ;; This backend supports expiry.
10299 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10300 (expirable (if total
10301 (progn
10302 ;; We need to update the info for
10303 ;; this group for `gnus-list-of-read-articles'
10304 ;; to give us the right answer.
10305 (gnus-run-hooks 'gnus-exit-group-hook)
10306 (gnus-summary-update-info)
10307 (gnus-list-of-read-articles gnus-newsgroup-name))
10308 (setq gnus-newsgroup-expirable
10309 (sort gnus-newsgroup-expirable '<))))
10310 (expiry-wait (if now 'immediate
10311 (gnus-group-find-parameter
10312 gnus-newsgroup-name 'expiry-wait)))
10313 (nnmail-expiry-target
10314 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10315 nnmail-expiry-target))
10317 (when expirable
10318 ;; There are expirable articles in this group, so we run them
10319 ;; through the expiry process.
10320 (gnus-message 6 "Expiring articles...")
10321 (when (gnus-check-group gnus-newsgroup-name)
10322 ;; The list of articles that weren't expired is returned.
10323 (save-excursion
10324 (if expiry-wait
10325 (let ((nnmail-expiry-wait-function nil)
10326 (nnmail-expiry-wait expiry-wait))
10327 (setq es (gnus-request-expire-articles
10328 expirable gnus-newsgroup-name)))
10329 (setq es (gnus-request-expire-articles
10330 expirable gnus-newsgroup-name)))
10331 (unless total
10332 (setq gnus-newsgroup-expirable es))
10333 ;; We go through the old list of expirable, and mark all
10334 ;; really expired articles as nonexistent.
10335 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10336 (let ((gnus-use-cache nil))
10337 (dolist (article expirable)
10338 (when (and (not (memq article es))
10339 (gnus-data-find article))
10340 (gnus-summary-mark-article article gnus-canceled-mark)
10341 (run-hook-with-args 'gnus-summary-article-expire-hook
10342 'delete
10343 (gnus-data-header
10344 (assoc article (gnus-data-list nil)))
10345 gnus-newsgroup-name
10347 nil)))))))
10348 (gnus-message 6 "Expiring articles...done")))))
10350 (defun gnus-summary-expire-articles-now ()
10351 "Expunge all expirable articles in the current group.
10352 This means that *all* articles that are marked as expirable will be
10353 deleted forever, right now."
10354 (interactive)
10355 (or gnus-expert-user
10356 (gnus-yes-or-no-p
10357 "Are you really, really sure you want to delete all expirable messages? ")
10358 (error "Phew!"))
10359 (gnus-summary-expire-articles t))
10361 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10362 (defun gnus-summary-delete-article (&optional n)
10363 "Delete the N next (mail) articles.
10364 This command actually deletes articles. This is not a marking
10365 command. The article will disappear forever from your life, never to
10366 return.
10368 If N is negative, delete backwards.
10369 If N is nil and articles have been marked with the process mark,
10370 delete these instead.
10372 If `gnus-novice-user' is non-nil you will be asked for
10373 confirmation before the articles are deleted."
10374 (interactive "P")
10375 (unless (gnus-check-backend-function 'request-expire-articles
10376 gnus-newsgroup-name)
10377 (error "The current newsgroup does not support article deletion"))
10378 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10379 (error "Couldn't open server"))
10380 ;; Compute the list of articles to delete.
10381 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10382 (nnmail-expiry-target 'delete)
10383 not-deleted)
10384 (if (and gnus-novice-user
10385 (not (gnus-yes-or-no-p
10386 (format "Do you really want to delete %s forever? "
10387 (if (> (length articles) 1)
10388 (format "these %s articles" (length articles))
10389 "this article")))))
10391 ;; Delete the articles.
10392 (setq not-deleted (gnus-request-expire-articles
10393 articles gnus-newsgroup-name 'force))
10394 (save-excursion
10395 (while articles
10396 (gnus-summary-remove-process-mark (car articles))
10397 ;; The backend might not have been able to delete the article
10398 ;; after all.
10399 (unless (memq (car articles) not-deleted)
10400 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10401 (let* ((article (car articles))
10402 (ghead (gnus-data-header
10403 (assoc article (gnus-data-list nil)))))
10404 (run-hook-with-args 'gnus-summary-article-delete-hook
10405 'delete ghead gnus-newsgroup-name nil
10406 nil)))
10407 (setq articles (cdr articles))))
10408 (when not-deleted
10409 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10410 (gnus-summary-position-point)
10411 (gnus-set-mode-line 'summary)
10412 not-deleted))
10414 (defun gnus-summary-edit-article (&optional arg)
10415 "Edit the current article.
10416 This will have permanent effect only in mail groups.
10417 If ARG is nil, edit the decoded articles.
10418 If ARG is 1, edit the raw articles.
10419 If ARG is 2, edit the raw articles even in read-only groups.
10420 If ARG is 3, edit the articles with the current handles.
10421 Otherwise, allow editing of articles even in read-only
10422 groups."
10423 (interactive "P")
10424 (let (force raw current-handles)
10425 (cond
10426 ((null arg))
10427 ((eq arg 1)
10428 (setq raw t))
10429 ((eq arg 2)
10430 (setq raw t
10431 force t))
10432 ((eq arg 3)
10433 (setq current-handles
10434 (and (gnus-buffer-live-p gnus-article-buffer)
10435 (with-current-buffer gnus-article-buffer
10436 (prog1
10437 gnus-article-mime-handles
10438 (setq gnus-article-mime-handles nil))))))
10440 (setq force t)))
10441 (when (and raw (not force)
10442 (member gnus-newsgroup-name '("nndraft:delayed"
10443 "nndraft:drafts"
10444 "nndraft:queue")))
10445 (error "Can't edit the raw article in group %s"
10446 gnus-newsgroup-name))
10447 (with-current-buffer gnus-summary-buffer
10448 (let ((mail-parse-charset gnus-newsgroup-charset)
10449 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10450 (gnus-set-global-variables)
10451 (when (and (not force)
10452 (gnus-group-read-only-p))
10453 (error "The current newsgroup does not support article editing"))
10454 (gnus-summary-show-article t)
10455 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10456 (with-current-buffer gnus-article-buffer
10457 (mm-enable-multibyte)))
10458 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10459 (setq raw t))
10460 (gnus-article-edit-article
10461 (if raw 'ignore
10462 `(lambda ()
10463 (let ((mbl mml-buffer-list))
10464 (setq mml-buffer-list nil)
10465 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10466 (mime-to-mml ,'current-handles))
10467 (let ((mbl1 mml-buffer-list))
10468 (setq mml-buffer-list mbl)
10469 (set (make-local-variable 'mml-buffer-list) mbl1))
10470 (gnus-make-local-hook 'kill-buffer-hook)
10471 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10472 `(lambda (no-highlight)
10473 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10474 (message-options message-options)
10475 (message-options-set-recipient)
10476 (mail-parse-ignored-charsets
10477 ',gnus-newsgroup-ignored-charsets)
10478 (rfc2047-header-encoding-alist
10479 ',(let ((charset (gnus-group-name-charset
10480 (gnus-find-method-for-group
10481 gnus-newsgroup-name)
10482 gnus-newsgroup-name)))
10483 (append (list (cons "Newsgroups" charset)
10484 (cons "Followup-To" charset)
10485 (cons "Xref" charset))
10486 rfc2047-header-encoding-alist))))
10487 ,(if (not raw) '(progn
10488 (mml-to-mime)
10489 (mml-destroy-buffers)
10490 (remove-hook 'kill-buffer-hook
10491 'mml-destroy-buffers t)
10492 (kill-local-variable 'mml-buffer-list)))
10493 (gnus-summary-edit-article-done
10494 ,(or (mail-header-references gnus-current-headers) "")
10495 ,(gnus-group-read-only-p)
10496 ,gnus-summary-buffer no-highlight))))))))
10498 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10500 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10501 no-highlight)
10502 "Make edits to the current article permanent."
10503 (interactive)
10504 (save-excursion
10505 ;; The buffer restriction contains the entire article if it exists.
10506 (when (article-goto-body)
10507 (let ((lines (count-lines (point) (point-max)))
10508 (length (- (point-max) (point)))
10509 (case-fold-search t)
10510 (body (copy-marker (point))))
10511 (goto-char (point-min))
10512 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10513 (delete-region (match-beginning 1) (match-end 1))
10514 (insert (number-to-string length)))
10515 (goto-char (point-min))
10516 (when (re-search-forward
10517 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10518 (delete-region (match-beginning 1) (match-end 1))
10519 (insert (number-to-string length)))
10520 (goto-char (point-min))
10521 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10522 (delete-region (match-beginning 1) (match-end 1))
10523 (insert (number-to-string lines))))))
10524 ;; Replace the article.
10525 (let ((buf (current-buffer))
10526 (article (cdr gnus-article-current))
10527 replace-result)
10528 (with-temp-buffer
10529 (insert-buffer-substring buf)
10530 (if (and (not read-only)
10531 (not (setq replace-result
10532 (gnus-request-replace-article
10533 article (car gnus-article-current)
10534 (current-buffer) t))))
10535 (error "Couldn't replace article")
10536 ;; If we got a number back, then that's the new article number
10537 ;; for this article. Otherwise, the article number didn't change.
10538 (when (numberp replace-result)
10539 (with-current-buffer gnus-summary-buffer
10540 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10541 (gnus-summary-limit gnus-newsgroup-limit)
10542 (setq article replace-result)
10543 (gnus-summary-goto-subject article t)))
10544 ;; Update the summary buffer.
10545 (if (and references
10546 (equal (message-tokenize-header references " ")
10547 (message-tokenize-header
10548 (or (message-fetch-field "references") "") " ")))
10549 ;; We only have to update this line.
10550 (save-excursion
10551 (save-restriction
10552 (message-narrow-to-head)
10553 (let ((head (buffer-substring-no-properties
10554 (point-min) (point-max)))
10555 header)
10556 (with-temp-buffer
10557 (insert (format "211 %d Article retrieved.\n" article))
10558 (insert head)
10559 (insert ".\n")
10560 (let ((nntp-server-buffer (current-buffer)))
10561 (setq header (car (gnus-get-newsgroup-headers nil t))))
10562 (with-current-buffer gnus-summary-buffer
10563 (gnus-data-set-header (gnus-data-find article) header)
10564 (gnus-summary-update-article-line article header)
10565 (if (gnus-summary-goto-subject article nil t)
10566 (gnus-summary-update-secondary-mark article)))))))
10567 ;; Update threads.
10568 (set-buffer (or buffer gnus-summary-buffer))
10569 (gnus-summary-update-article article)
10570 (if (gnus-summary-goto-subject article nil t)
10571 (gnus-summary-update-secondary-mark article)))
10572 ;; Prettify the article buffer again.
10573 (unless no-highlight
10574 (with-current-buffer gnus-article-buffer
10575 ;;!!! Fix this -- article should be rehighlighted.
10576 ;;(gnus-run-hooks 'gnus-article-display-hook)
10577 (set-buffer gnus-original-article-buffer)
10578 (gnus-request-article
10579 article (car gnus-article-current) (current-buffer))))
10580 ;; Prettify the summary buffer line.
10581 (when (gnus-visual-p 'summary-highlight 'highlight)
10582 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10584 (defun gnus-summary-edit-wash (key)
10585 "Perform editing command KEY in the article buffer."
10586 (interactive
10587 (list
10588 (progn
10589 (message "%s" (concat (this-command-keys) "- "))
10590 (read-char))))
10591 (message "")
10592 (gnus-summary-edit-article)
10593 (execute-kbd-macro (concat (this-command-keys) key))
10594 (gnus-article-edit-done))
10596 ;;; Respooling
10598 (defun gnus-summary-respool-query (&optional silent trace)
10599 "Query where the respool algorithm would put this article."
10600 (interactive)
10601 (let (gnus-mark-article-hook)
10602 (gnus-summary-select-article)
10603 (with-current-buffer gnus-original-article-buffer
10604 (let ((groups (nnmail-article-group 'identity trace)))
10605 (unless silent
10606 (if groups
10607 (message "This message would go to %s"
10608 (mapconcat 'car groups ", "))
10609 (message "This message would go to no groups"))
10610 groups)))))
10612 (defun gnus-summary-respool-trace ()
10613 "Trace where the respool algorithm would put this article.
10614 Display a buffer showing all fancy splitting patterns which matched."
10615 (interactive)
10616 (gnus-summary-respool-query nil t))
10618 ;; Summary marking commands.
10620 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10621 "Mark articles which has the same subject as read, and then select the next.
10622 If UNMARK is positive, remove any kind of mark.
10623 If UNMARK is negative, tick articles."
10624 (interactive "P")
10625 (when unmark
10626 (setq unmark (prefix-numeric-value unmark)))
10627 (let ((count
10628 (gnus-summary-mark-same-subject
10629 (gnus-summary-article-subject) unmark)))
10630 ;; Select next unread article. If auto-select-same mode, should
10631 ;; select the first unread article.
10632 (gnus-summary-next-article t (and gnus-auto-select-same
10633 (gnus-summary-article-subject)))
10634 (gnus-message 7 "%d article%s marked as %s"
10635 count (if (= count 1) " is" "s are")
10636 (if unmark "unread" "read"))))
10638 (defun gnus-summary-kill-same-subject (&optional unmark)
10639 "Mark articles which has the same subject as read.
10640 If UNMARK is positive, remove any kind of mark.
10641 If UNMARK is negative, tick articles."
10642 (interactive "P")
10643 (when unmark
10644 (setq unmark (prefix-numeric-value unmark)))
10645 (let ((count
10646 (gnus-summary-mark-same-subject
10647 (gnus-summary-article-subject) unmark)))
10648 ;; If marked as read, go to next unread subject.
10649 (when (null unmark)
10650 ;; Go to next unread subject.
10651 (gnus-summary-next-subject 1 t))
10652 (gnus-message 7 "%d articles are marked as %s"
10653 count (if unmark "unread" "read"))))
10655 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10656 "Mark articles with same SUBJECT as read, and return marked number.
10657 If optional argument UNMARK is positive, remove any kinds of marks.
10658 If optional argument UNMARK is negative, mark articles as unread instead."
10659 (let ((count 1))
10660 (save-excursion
10661 (cond
10662 ((null unmark) ; Mark as read.
10663 (while (and
10664 (progn
10665 (gnus-summary-mark-article-as-read gnus-killed-mark)
10666 (gnus-summary-show-thread) t)
10667 (gnus-summary-find-subject subject))
10668 (setq count (1+ count))))
10669 ((> unmark 0) ; Tick.
10670 (while (and
10671 (progn
10672 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10673 (gnus-summary-show-thread) t)
10674 (gnus-summary-find-subject subject))
10675 (setq count (1+ count))))
10676 (t ; Mark as unread.
10677 (while (and
10678 (progn
10679 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10680 (gnus-summary-show-thread) t)
10681 (gnus-summary-find-subject subject))
10682 (setq count (1+ count)))))
10683 (gnus-set-mode-line 'summary)
10684 ;; Return the number of marked articles.
10685 count)))
10687 (defun gnus-summary-mark-as-processable (n &optional unmark)
10688 "Set the process mark on the next N articles.
10689 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10690 the process mark instead. The difference between N and the actual
10691 number of articles marked is returned."
10692 (interactive "P")
10693 (if (and (null n) (gnus-region-active-p))
10694 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10695 (setq n (prefix-numeric-value n))
10696 (let ((backward (< n 0))
10697 (n (abs n)))
10698 (while (and
10699 (> n 0)
10700 (if unmark
10701 (gnus-summary-remove-process-mark
10702 (gnus-summary-article-number))
10703 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10704 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10705 (setq n (1- n)))
10706 (when (/= 0 n)
10707 (gnus-message 7 "No more articles"))
10708 (gnus-summary-recenter)
10709 (gnus-summary-position-point)
10710 n)))
10712 (defun gnus-summary-unmark-as-processable (n)
10713 "Remove the process mark from the next N articles.
10714 If N is negative, unmark backward instead. The difference between N and
10715 the actual number of articles unmarked is returned."
10716 (interactive "P")
10717 (gnus-summary-mark-as-processable n t))
10719 (defun gnus-summary-unmark-all-processable ()
10720 "Remove the process mark from all articles."
10721 (interactive)
10722 (save-excursion
10723 (while gnus-newsgroup-processable
10724 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10725 (gnus-summary-position-point))
10727 (defun gnus-summary-add-mark (article type)
10728 "Mark ARTICLE with a mark of TYPE."
10729 (let ((vtype (car (assq type gnus-article-mark-lists)))
10730 var)
10731 (if (not vtype)
10732 (error "No such mark type: %s" type)
10733 (setq var (intern (format "gnus-newsgroup-%s" type)))
10734 (set var (cons article (symbol-value var)))
10735 (if (memq type '(processable cached replied forwarded recent saved))
10736 (gnus-summary-update-secondary-mark article)
10737 ;;; !!! This is bogus. We should find out what primary
10738 ;;; !!! mark we want to set.
10739 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10741 (defun gnus-summary-mark-as-expirable (n)
10742 "Mark N articles forward as expirable.
10743 If N is negative, mark backward instead. The difference between N and
10744 the actual number of articles marked is returned."
10745 (interactive "p")
10746 (gnus-summary-mark-forward n gnus-expirable-mark))
10748 (defun gnus-summary-mark-as-spam (n)
10749 "Mark N articles forward as spam.
10750 If N is negative, mark backward instead. The difference between N and
10751 the actual number of articles marked is returned."
10752 (interactive "p")
10753 (gnus-summary-mark-forward n gnus-spam-mark))
10755 (defun gnus-summary-mark-article-as-replied (article)
10756 "Mark ARTICLE as replied to and update the summary line.
10757 ARTICLE can also be a list of articles."
10758 (interactive (list (gnus-summary-article-number)))
10759 (let ((articles (if (listp article) article (list article))))
10760 (dolist (article articles)
10761 (unless (numberp article)
10762 (error "%s is not a number" article))
10763 (push article gnus-newsgroup-replied)
10764 (let ((inhibit-read-only t))
10765 (when (gnus-summary-goto-subject article nil t)
10766 (gnus-summary-update-secondary-mark article))))))
10768 (defun gnus-summary-mark-article-as-forwarded (article)
10769 "Mark ARTICLE as forwarded and update the summary line.
10770 ARTICLE can also be a list of articles."
10771 (let ((articles (if (listp article) article (list article))))
10772 (dolist (article articles)
10773 (push article gnus-newsgroup-forwarded)
10774 (let ((inhibit-read-only t))
10775 (when (gnus-summary-goto-subject article nil t)
10776 (gnus-summary-update-secondary-mark article))))))
10778 (defun gnus-summary-set-bookmark (article)
10779 "Set a bookmark in current article."
10780 (interactive (list (gnus-summary-article-number)))
10781 (when (or (not (get-buffer gnus-article-buffer))
10782 (not gnus-current-article)
10783 (not gnus-article-current)
10784 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10785 (error "No current article selected"))
10786 ;; Remove old bookmark, if one exists.
10787 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10788 ;; Set the new bookmark, which is on the form
10789 ;; (article-number . line-number-in-body).
10790 (push
10791 (cons article
10792 (with-current-buffer gnus-article-buffer
10793 (count-lines
10794 (min (point)
10795 (save-excursion
10796 (article-goto-body)
10797 (point)))
10798 (point))))
10799 gnus-newsgroup-bookmarks)
10800 (gnus-message 6 "A bookmark has been added to the current article."))
10802 (defun gnus-summary-remove-bookmark (article)
10803 "Remove the bookmark from the current article."
10804 (interactive (list (gnus-summary-article-number)))
10805 ;; Remove old bookmark, if one exists.
10806 (if (not (assq article gnus-newsgroup-bookmarks))
10807 (gnus-message 6 "No bookmark in current article.")
10808 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10809 (gnus-message 6 "Removed bookmark.")))
10811 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10812 (defun gnus-summary-mark-as-dormant (n)
10813 "Mark N articles forward as dormant.
10814 If N is negative, mark backward instead. The difference between N and
10815 the actual number of articles marked is returned."
10816 (interactive "p")
10817 (gnus-summary-mark-forward n gnus-dormant-mark))
10819 (defun gnus-summary-set-process-mark (article)
10820 "Set the process mark on ARTICLE and update the summary line."
10821 (setq gnus-newsgroup-processable
10822 (cons article
10823 (delq article gnus-newsgroup-processable)))
10824 (when (gnus-summary-goto-subject article)
10825 (gnus-summary-show-thread)
10826 (gnus-summary-goto-subject article)
10827 (gnus-summary-update-secondary-mark article)))
10829 (defun gnus-summary-remove-process-mark (&rest articles)
10830 "Remove the process mark from ARTICLES and update the summary line."
10831 (dolist (article articles)
10832 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10833 (when (gnus-summary-goto-subject article)
10834 (gnus-summary-show-thread)
10835 (gnus-summary-goto-subject article)
10836 (gnus-summary-update-secondary-mark article)))
10839 (defun gnus-summary-set-saved-mark (article)
10840 "Set the process mark on ARTICLE and update the summary line."
10841 (push article gnus-newsgroup-saved)
10842 (when (gnus-summary-goto-subject article)
10843 (gnus-summary-update-secondary-mark article)))
10845 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10846 "Mark N articles as read forwards.
10847 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10848 The difference between N and the actual number of articles marked is
10849 returned.
10850 If NO-EXPIRE, auto-expiry will be inhibited."
10851 (interactive "p")
10852 (gnus-summary-show-thread)
10853 (let ((backward (< n 0))
10854 (gnus-summary-goto-unread
10855 (and gnus-summary-goto-unread
10856 (not (eq gnus-summary-goto-unread 'never))
10857 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10858 gnus-ticked-mark gnus-dormant-mark)))))
10859 (n (abs n))
10860 (mark (or mark gnus-del-mark)))
10861 (while (and (> n 0)
10862 (gnus-summary-mark-article nil mark no-expire)
10863 (zerop (gnus-summary-next-subject
10864 (if backward -1 1)
10865 (and gnus-summary-goto-unread
10866 (not (eq gnus-summary-goto-unread 'never)))
10867 t)))
10868 (setq n (1- n)))
10869 (when (/= 0 n)
10870 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10871 (gnus-summary-recenter)
10872 (gnus-summary-position-point)
10873 (gnus-set-mode-line 'summary)
10876 (defun gnus-summary-mark-article-as-read (mark)
10877 "Mark the current article quickly as read with MARK."
10878 (let ((article (gnus-summary-article-number)))
10879 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10880 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10881 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10882 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10883 (push (cons article mark) gnus-newsgroup-reads)
10884 ;; Possibly remove from cache, if that is used.
10885 (when gnus-use-cache
10886 (gnus-cache-enter-remove-article article))
10887 ;; Allow the backend to change the mark.
10888 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10889 ;; Check for auto-expiry.
10890 (when (and gnus-newsgroup-auto-expire
10891 (memq mark gnus-auto-expirable-marks))
10892 (setq mark gnus-expirable-mark)
10893 ;; Let the backend know about the mark change.
10894 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10895 (push article gnus-newsgroup-expirable))
10896 ;; Set the mark in the buffer.
10897 (gnus-summary-update-mark mark 'unread)
10900 (defun gnus-summary-mark-article-as-unread (mark)
10901 "Mark the current article quickly as unread with MARK."
10902 (let* ((article (gnus-summary-article-number))
10903 (old-mark (gnus-summary-article-mark article)))
10904 ;; Allow the backend to change the mark.
10905 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10906 (if (eq mark old-mark)
10908 (if (<= article 0)
10909 (progn
10910 (gnus-error 1 "Can't mark negative article numbers")
10911 nil)
10912 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10913 (setq gnus-newsgroup-spam-marked
10914 (delq article gnus-newsgroup-spam-marked))
10915 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10916 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10917 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10918 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10919 (cond ((= mark gnus-ticked-mark)
10920 (setq gnus-newsgroup-marked
10921 (gnus-add-to-sorted-list gnus-newsgroup-marked
10922 article)))
10923 ((= mark gnus-spam-mark)
10924 (setq gnus-newsgroup-spam-marked
10925 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10926 article)))
10927 ((= mark gnus-dormant-mark)
10928 (setq gnus-newsgroup-dormant
10929 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10930 article)))
10932 (setq gnus-newsgroup-unreads
10933 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10934 article))))
10935 (gnus-alist-pull article gnus-newsgroup-reads)
10937 ;; See whether the article is to be put in the cache.
10938 (and gnus-use-cache
10939 (vectorp (gnus-summary-article-header article))
10940 (save-excursion
10941 (gnus-cache-possibly-enter-article
10942 gnus-newsgroup-name article
10943 (= mark gnus-ticked-mark)
10944 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10946 ;; Fix the mark.
10947 (gnus-summary-update-mark mark 'unread)
10948 t))))
10950 (defun gnus-summary-mark-article (&optional article mark no-expire)
10951 "Mark ARTICLE with MARK. MARK can be any character.
10952 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10953 `??' (dormant) and `?E' (expirable).
10954 If MARK is nil, then the default character `?r' is used.
10955 If ARTICLE is nil, then the article on the current line will be
10956 marked.
10957 If NO-EXPIRE, auto-expiry will be inhibited."
10958 ;; The mark might be a string.
10959 (when (stringp mark)
10960 (setq mark (aref mark 0)))
10961 ;; If no mark is given, then we check auto-expiring.
10962 (when (null mark)
10963 (setq mark gnus-del-mark))
10964 (when (and (not no-expire)
10965 gnus-newsgroup-auto-expire
10966 (memq mark gnus-auto-expirable-marks))
10967 (setq mark gnus-expirable-mark))
10968 (let ((article (or article (gnus-summary-article-number)))
10969 (old-mark (gnus-summary-article-mark article)))
10970 ;; Allow the backend to change the mark.
10971 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10972 (if (eq mark old-mark)
10974 (unless article
10975 (error "No article on current line"))
10976 (if (not (if (or (= mark gnus-unread-mark)
10977 (= mark gnus-ticked-mark)
10978 (= mark gnus-spam-mark)
10979 (= mark gnus-dormant-mark))
10980 (gnus-mark-article-as-unread article mark)
10981 (gnus-mark-article-as-read article mark)))
10983 ;; See whether the article is to be put in the cache.
10984 (and gnus-use-cache
10985 (not (= mark gnus-canceled-mark))
10986 (vectorp (gnus-summary-article-header article))
10987 (save-excursion
10988 (gnus-cache-possibly-enter-article
10989 gnus-newsgroup-name article
10990 (= mark gnus-ticked-mark)
10991 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10993 (when (gnus-summary-goto-subject article nil t)
10994 (let ((inhibit-read-only t))
10995 (gnus-summary-show-thread)
10996 ;; Fix the mark.
10997 (gnus-summary-update-mark mark 'unread)
10998 t))))))
11000 (defun gnus-summary-update-secondary-mark (article)
11001 "Update the secondary (read, process, cache) mark."
11002 (gnus-summary-update-mark
11003 (cond ((memq article gnus-newsgroup-processable)
11004 gnus-process-mark)
11005 ((memq article gnus-newsgroup-cached)
11006 gnus-cached-mark)
11007 ((memq article gnus-newsgroup-replied)
11008 gnus-replied-mark)
11009 ((memq article gnus-newsgroup-forwarded)
11010 gnus-forwarded-mark)
11011 ((memq article gnus-newsgroup-saved)
11012 gnus-saved-mark)
11013 ((memq article gnus-newsgroup-unseen)
11014 gnus-unseen-mark)
11015 (t gnus-no-mark))
11016 'replied)
11017 (when (gnus-visual-p 'summary-highlight 'highlight)
11018 (gnus-summary-highlight-line)
11019 (gnus-run-hooks 'gnus-summary-update-hook))
11022 (defun gnus-summary-update-download-mark (article)
11023 "Update the download mark."
11024 (gnus-summary-update-mark
11025 (cond ((memq article gnus-newsgroup-undownloaded)
11026 gnus-undownloaded-mark)
11027 (gnus-newsgroup-agentized
11028 gnus-downloaded-mark)
11030 gnus-no-mark))
11031 'download)
11032 (gnus-summary-update-line t)
11035 (defun gnus-summary-update-mark (mark type)
11036 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11037 (inhibit-read-only t))
11038 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11039 (when forward
11040 (when (looking-at "\r")
11041 (incf forward))
11042 (when (<= (+ forward (point)) (point-max))
11043 ;; Go to the right position on the line.
11044 (goto-char (+ forward (point)))
11045 ;; Replace the old mark with the new mark.
11046 (let ((to-insert
11047 (mm-subst-char-in-string
11048 (char-after) mark
11049 (buffer-substring (point) (1+ (point))))))
11050 (delete-region (point) (1+ (point)))
11051 (insert to-insert))
11052 ;; Optionally update the marks by some user rule.
11053 (when (eq type 'unread)
11054 (gnus-data-set-mark
11055 (gnus-data-find (gnus-summary-article-number)) mark)
11056 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11058 (defun gnus-mark-article-as-read (article &optional mark)
11059 "Enter ARTICLE in the pertinent lists and remove it from others."
11060 ;; Make the article expirable.
11061 (let ((mark (or mark gnus-del-mark)))
11062 (setq gnus-newsgroup-expirable
11063 (if (= mark gnus-expirable-mark)
11064 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11065 (delq article gnus-newsgroup-expirable)))
11066 ;; Remove from unread and marked lists.
11067 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11068 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11069 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11070 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11071 (push (cons article mark) gnus-newsgroup-reads)
11072 ;; Possibly remove from cache, if that is used.
11073 (when gnus-use-cache
11074 (gnus-cache-enter-remove-article article))
11077 (defun gnus-mark-article-as-unread (article &optional mark)
11078 "Enter ARTICLE in the pertinent lists and remove it from others."
11079 (let ((mark (or mark gnus-ticked-mark)))
11080 (if (<= article 0)
11081 (progn
11082 (gnus-error 1 "Can't mark negative article numbers")
11083 nil)
11084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11085 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11086 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11087 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11088 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11090 ;; Unsuppress duplicates?
11091 (when gnus-suppress-duplicates
11092 (gnus-dup-unsuppress-article article))
11094 (cond ((= mark gnus-ticked-mark)
11095 (setq gnus-newsgroup-marked
11096 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11097 ((= mark gnus-spam-mark)
11098 (setq gnus-newsgroup-spam-marked
11099 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11100 article)))
11101 ((= mark gnus-dormant-mark)
11102 (setq gnus-newsgroup-dormant
11103 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11105 (setq gnus-newsgroup-unreads
11106 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11107 (gnus-alist-pull article gnus-newsgroup-reads)
11108 t)))
11110 (defun gnus-summary-tick-article-forward (n)
11111 "Tick N articles forwards.
11112 If N is negative, tick backwards instead.
11113 The difference between N and the number of articles ticked is returned."
11114 (interactive "p")
11115 (gnus-summary-mark-forward n gnus-ticked-mark))
11117 (defun gnus-summary-tick-article-backward (n)
11118 "Tick N articles backwards.
11119 The difference between N and the number of articles ticked is returned."
11120 (interactive "p")
11121 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11123 (defun gnus-summary-tick-article (&optional article clear-mark)
11124 "Mark current article as unread.
11125 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11126 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11127 (interactive)
11128 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11129 gnus-ticked-mark)))
11131 (defun gnus-summary-mark-as-read-forward (n)
11132 "Mark N articles as read forwards.
11133 If N is negative, mark backwards instead.
11134 The difference between N and the actual number of articles marked is
11135 returned."
11136 (interactive "p")
11137 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11139 (defun gnus-summary-mark-as-read-backward (n)
11140 "Mark the N articles as read backwards.
11141 The difference between N and the actual number of articles marked is
11142 returned."
11143 (interactive "p")
11144 (gnus-summary-mark-forward
11145 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11147 (defun gnus-summary-mark-as-read (&optional article mark)
11148 "Mark current article as read.
11149 ARTICLE specifies the article to be marked as read.
11150 MARK specifies a string to be inserted at the beginning of the line."
11151 (gnus-summary-mark-article article mark))
11153 (defun gnus-summary-clear-mark-forward (n)
11154 "Clear marks from N articles forward.
11155 If N is negative, clear backward instead.
11156 The difference between N and the number of marks cleared is returned."
11157 (interactive "p")
11158 (gnus-summary-mark-forward n gnus-unread-mark))
11160 (defun gnus-summary-clear-mark-backward (n)
11161 "Clear marks from N articles backward.
11162 The difference between N and the number of marks cleared is returned."
11163 (interactive "p")
11164 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11166 (defun gnus-summary-mark-unread-as-read ()
11167 "Intended to be used by `gnus-mark-article-hook'."
11168 (when (memq gnus-current-article gnus-newsgroup-unreads)
11169 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11171 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11172 "Intended to be used by `gnus-mark-article-hook'."
11173 (let ((mark (gnus-summary-article-mark)))
11174 (when (or (gnus-unread-mark-p mark)
11175 (gnus-read-mark-p mark))
11176 (gnus-summary-mark-article gnus-current-article
11177 (or new-mark gnus-read-mark)))))
11179 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11180 "Intended to be used by `gnus-mark-article-hook'."
11181 (let ((mark (gnus-summary-article-mark)))
11182 (when (or (gnus-unread-mark-p mark)
11183 (gnus-read-mark-p mark))
11184 (gnus-summary-mark-article (gnus-summary-article-number)
11185 (or new-mark gnus-read-mark)))))
11187 (defun gnus-summary-mark-unread-as-ticked ()
11188 "Intended to be used by `gnus-mark-article-hook'."
11189 (when (memq gnus-current-article gnus-newsgroup-unreads)
11190 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11192 (defun gnus-summary-mark-region-as-read (point mark all)
11193 "Mark all unread articles between point and mark as read.
11194 If given a prefix, mark all articles between point and mark as read,
11195 even ticked and dormant ones."
11196 (interactive "r\nP")
11197 (save-excursion
11198 (let (article)
11199 (goto-char point)
11200 (beginning-of-line)
11201 (while (and
11202 (< (point) mark)
11203 (progn
11204 (when (or all
11205 (memq (setq article (gnus-summary-article-number))
11206 gnus-newsgroup-unreads))
11207 (gnus-summary-mark-article article gnus-del-mark))
11209 (gnus-summary-find-next))))))
11211 (defun gnus-summary-mark-below (score mark)
11212 "Mark articles with score less than SCORE with MARK."
11213 (interactive "P\ncMark: ")
11214 (setq score (if score
11215 (prefix-numeric-value score)
11216 (or gnus-summary-default-score 0)))
11217 (with-current-buffer gnus-summary-buffer
11218 (goto-char (point-min))
11219 (while
11220 (progn
11221 (and (< (gnus-summary-article-score) score)
11222 (gnus-summary-mark-article nil mark))
11223 (gnus-summary-find-next)))))
11225 (defun gnus-summary-kill-below (&optional score)
11226 "Mark articles with score below SCORE as read."
11227 (interactive "P")
11228 (gnus-summary-mark-below score gnus-killed-mark))
11230 (defun gnus-summary-clear-above (&optional score)
11231 "Clear all marks from articles with score above SCORE."
11232 (interactive "P")
11233 (gnus-summary-mark-above score gnus-unread-mark))
11235 (defun gnus-summary-tick-above (&optional score)
11236 "Tick all articles with score above SCORE."
11237 (interactive "P")
11238 (gnus-summary-mark-above score gnus-ticked-mark))
11240 (defun gnus-summary-mark-above (score mark)
11241 "Mark articles with score over SCORE with MARK."
11242 (interactive "P\ncMark: ")
11243 (setq score (if score
11244 (prefix-numeric-value score)
11245 (or gnus-summary-default-score 0)))
11246 (with-current-buffer gnus-summary-buffer
11247 (goto-char (point-min))
11248 (while (and (progn
11249 (when (> (gnus-summary-article-score) score)
11250 (gnus-summary-mark-article nil mark))
11252 (gnus-summary-find-next)))))
11254 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11255 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11256 (defun gnus-summary-limit-include-expunged (&optional no-error)
11257 "Display all the hidden articles that were expunged for low scores."
11258 (interactive)
11259 (let ((inhibit-read-only t))
11260 (let ((scored gnus-newsgroup-scored)
11261 headers h)
11262 (while scored
11263 (unless (gnus-summary-article-header (caar scored))
11264 (and (setq h (gnus-number-to-header (caar scored)))
11265 (< (cdar scored) gnus-summary-expunge-below)
11266 (push h headers)))
11267 (setq scored (cdr scored)))
11268 (if (not headers)
11269 (when (not no-error)
11270 (error "No expunged articles hidden"))
11271 (goto-char (point-min))
11272 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11273 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11274 (dolist (x headers)
11275 (push (mail-header-number x) gnus-newsgroup-limit))
11276 (gnus-summary-prepare-unthreaded (nreverse headers))
11277 (goto-char (point-min))
11278 (gnus-summary-position-point)
11279 t))))
11281 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11282 "Mark all unread articles in this newsgroup as read.
11283 If prefix argument ALL is non-nil, ticked and dormant articles will
11284 also be marked as read.
11285 If QUIETLY is non-nil, no questions will be asked.
11287 If TO-HERE is non-nil, it should be a point in the buffer. All
11288 articles before (after, if REVERSE is set) this point will be marked
11289 as read.
11291 Note that this function will only catch up the unread article
11292 in the current summary buffer limitation.
11294 The number of articles marked as read is returned."
11295 (interactive "P")
11296 (prog1
11297 (save-excursion
11298 (when (or quietly
11299 (not gnus-interactive-catchup) ;Without confirmation?
11300 gnus-expert-user
11301 (gnus-y-or-n-p
11302 (if all
11303 "Mark absolutely all articles as read? "
11304 "Mark all unread articles as read? ")))
11305 (if (and not-mark
11306 (not gnus-newsgroup-adaptive)
11307 (not gnus-newsgroup-auto-expire)
11308 (not gnus-suppress-duplicates)
11309 (or (not gnus-use-cache)
11310 (eq gnus-use-cache 'passive)))
11311 (progn
11312 (when all
11313 (setq gnus-newsgroup-marked nil
11314 gnus-newsgroup-spam-marked nil
11315 gnus-newsgroup-dormant nil))
11316 (setq gnus-newsgroup-unreads
11317 (gnus-sorted-nunion
11318 (gnus-sorted-intersection gnus-newsgroup-unreads
11319 gnus-newsgroup-downloadable)
11320 (gnus-sorted-difference gnus-newsgroup-unfetched
11321 gnus-newsgroup-cached))))
11322 ;; We actually mark all articles as canceled, which we
11323 ;; have to do when using auto-expiry or adaptive scoring.
11324 (gnus-summary-show-all-threads)
11325 (if (and to-here reverse)
11326 (progn
11327 (goto-char to-here)
11328 (gnus-summary-mark-current-read-and-unread-as-read
11329 gnus-catchup-mark)
11330 (while (gnus-summary-find-next (not all))
11331 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11332 (when (gnus-summary-first-subject (not all))
11333 (while (and
11334 (if to-here (< (point) to-here) t)
11335 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11336 (gnus-summary-find-next (not all))))))
11337 (gnus-set-mode-line 'summary))
11339 (gnus-summary-position-point)))
11341 (defun gnus-summary-catchup-to-here (&optional all)
11342 "Mark all unticked articles before the current one as read.
11343 If ALL is non-nil, also mark ticked and dormant articles as read."
11344 (interactive "P")
11345 (save-excursion
11346 (gnus-save-hidden-threads
11347 (let ((beg (point)))
11348 ;; We check that there are unread articles.
11349 (when (or all (gnus-summary-find-prev))
11350 (gnus-summary-catchup all t beg)))))
11351 (gnus-summary-position-point))
11353 (defun gnus-summary-catchup-from-here (&optional all)
11354 "Mark all unticked articles after (and including) the current one as read.
11355 If ALL is non-nil, also mark ticked and dormant articles as read."
11356 (interactive "P")
11357 (save-excursion
11358 (gnus-save-hidden-threads
11359 (let ((beg (point)))
11360 ;; We check that there are unread articles.
11361 (when (or all (gnus-summary-find-next))
11362 (gnus-summary-catchup all t beg nil t)))))
11363 (gnus-summary-position-point))
11365 (defun gnus-summary-catchup-all (&optional quietly)
11366 "Mark all articles in this newsgroup as read.
11367 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11368 instead, which marks only unread articles as read."
11369 (interactive "P")
11370 (gnus-summary-catchup t quietly))
11372 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11373 "Mark all unread articles in this group as read, then exit.
11374 If prefix argument ALL is non-nil, all articles are marked as read.
11375 If QUIETLY is non-nil, no questions will be asked."
11376 (interactive "P")
11377 (when (gnus-summary-catchup all quietly nil 'fast)
11378 ;; Select next newsgroup or exit.
11379 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11380 (eq gnus-auto-select-next 'quietly))
11381 (gnus-summary-next-group nil)
11382 (gnus-summary-exit))))
11384 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11385 "Mark all articles in this newsgroup as read, and then exit.
11386 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11387 instead, which marks only unread articles as read."
11388 (interactive "P")
11389 (gnus-summary-catchup-and-exit t quietly))
11391 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11392 "Mark all articles in this group as read and select the next group.
11393 If given a prefix, mark all articles, unread as well as ticked, as
11394 read."
11395 (interactive "P")
11396 (save-excursion
11397 (gnus-summary-catchup all))
11398 (gnus-summary-next-group))
11400 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11401 "Mark all articles in this group as read and select the previous group.
11402 If given a prefix, mark all articles, unread as well as ticked, as
11403 read."
11404 (interactive "P")
11405 (save-excursion
11406 (gnus-summary-catchup all))
11407 (gnus-summary-next-group nil nil t))
11410 ;;; with article
11413 (defmacro gnus-with-article (article &rest forms)
11414 "Select ARTICLE and perform FORMS in the original article buffer.
11415 Then replace the article with the result."
11416 `(progn
11417 ;; We don't want the article to be marked as read.
11418 (let (gnus-mark-article-hook)
11419 (gnus-summary-select-article t t nil ,article))
11420 (set-buffer gnus-original-article-buffer)
11421 ,@forms
11422 (if (not (gnus-check-backend-function
11423 'request-replace-article (car gnus-article-current)))
11424 (gnus-message 5 "Read-only group; not replacing")
11425 (unless (gnus-request-replace-article
11426 ,article (car gnus-article-current)
11427 (current-buffer) t)
11428 (error "Couldn't replace article")))
11429 ;; The cache and backlog have to be flushed somewhat.
11430 (when gnus-keep-backlog
11431 (gnus-backlog-remove-article
11432 (car gnus-article-current) (cdr gnus-article-current)))
11433 (when gnus-use-cache
11434 (gnus-cache-update-article
11435 (car gnus-article-current) (cdr gnus-article-current)))))
11437 (put 'gnus-with-article 'lisp-indent-function 1)
11438 (put 'gnus-with-article 'edebug-form-spec '(form body))
11440 ;; Thread-based commands.
11442 (defun gnus-summary-articles-in-thread (&optional article)
11443 "Return a list of all articles in the current thread.
11444 If ARTICLE is non-nil, return all articles in the thread that starts
11445 with that article."
11446 (let* ((article (or article (gnus-summary-article-number)))
11447 (data (gnus-data-find-list article))
11448 (top-level (gnus-data-level (car data)))
11449 (top-subject
11450 (cond ((null gnus-thread-operation-ignore-subject)
11451 (gnus-simplify-subject-re
11452 (mail-header-subject (gnus-data-header (car data)))))
11453 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11454 (gnus-simplify-subject-fuzzy
11455 (mail-header-subject (gnus-data-header (car data)))))
11456 (t nil)))
11457 (end-point (save-excursion
11458 (goto-char (gnus-data-pos (car data)))
11459 (if (gnus-summary-go-to-next-thread)
11460 (point) (point-max))))
11461 articles)
11462 (while (and data
11463 (< (gnus-data-pos (car data)) end-point))
11464 (when (or (not top-subject)
11465 (string= top-subject
11466 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11467 (gnus-simplify-subject-fuzzy
11468 (mail-header-subject
11469 (gnus-data-header (car data))))
11470 (gnus-simplify-subject-re
11471 (mail-header-subject
11472 (gnus-data-header (car data)))))))
11473 (push (gnus-data-number (car data)) articles))
11474 (unless (and (setq data (cdr data))
11475 (> (gnus-data-level (car data)) top-level))
11476 (setq data nil)))
11477 ;; Return the list of articles.
11478 (nreverse articles)))
11480 (defun gnus-summary-rethread-current ()
11481 "Rethread the thread the current article is part of."
11482 (interactive)
11483 (let* ((gnus-show-threads t)
11484 (article (gnus-summary-article-number))
11485 (id (mail-header-id (gnus-summary-article-header)))
11486 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11487 (unless id
11488 (error "No article on the current line"))
11489 (gnus-rebuild-thread id)
11490 (gnus-summary-goto-subject article)))
11492 (defun gnus-summary-reparent-thread ()
11493 "Make the current article child of the marked (or previous) article.
11495 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11496 is non-nil or the Subject: of both articles are the same."
11497 (interactive)
11498 (unless (not (gnus-group-read-only-p))
11499 (error "The current newsgroup does not support article editing"))
11500 (unless (<= (length gnus-newsgroup-processable) 1)
11501 (error "No more than one article may be marked"))
11502 (let ((child (gnus-summary-article-number))
11503 ;; First grab the marked article, otherwise one line up.
11504 (parent (if (not (null gnus-newsgroup-processable))
11505 (car gnus-newsgroup-processable)
11506 (save-excursion
11507 (if (eq (forward-line -1) 0)
11508 (gnus-summary-article-number)
11509 (error "Beginning of summary buffer"))))))
11510 (gnus-summary-reparent-children parent (list child))))
11512 (defun gnus-summary-reparent-children (parent children)
11513 "Make PARENT the parent of CHILDREN.
11514 When called interactively, PARENT is the current article and CHILDREN
11515 are the process-marked articles."
11516 (interactive
11517 (list (gnus-summary-article-number)
11518 (gnus-summary-work-articles nil)))
11519 (dolist (child children)
11520 (save-window-excursion
11521 (let ((gnus-article-buffer " *reparent*"))
11522 (unless (not (eq parent child))
11523 (error "An article may not be self-referential"))
11524 (let ((message-id (mail-header-id
11525 (gnus-summary-article-header parent))))
11526 (unless (and message-id (not (equal message-id "")))
11527 (error "No message-id in desired parent"))
11528 (gnus-with-article child
11529 (save-restriction
11530 (goto-char (point-min))
11531 (message-narrow-to-head)
11532 (if (re-search-forward "^References: " nil t)
11533 (progn
11534 (re-search-forward "^[^ \t]" nil t)
11535 (forward-line -1)
11536 (end-of-line)
11537 (insert " " message-id))
11538 (insert "References: " message-id "\n"))))
11539 (set-buffer gnus-summary-buffer)
11540 (gnus-summary-unmark-all-processable)
11541 (gnus-summary-update-article child)
11542 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11543 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11544 (gnus-summary-rethread-current)
11545 (gnus-message 3 "Article %d is now the child of article %d"
11546 child parent))))))
11548 (defun gnus-summary-toggle-threads (&optional arg)
11549 "Toggle showing conversation threads.
11550 If ARG is positive number, turn showing conversation threads on."
11551 (interactive "P")
11552 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11553 (setq gnus-show-threads
11554 (if (null arg) (not gnus-show-threads)
11555 (> (prefix-numeric-value arg) 0)))
11556 (gnus-summary-prepare)
11557 (gnus-summary-goto-subject current)
11558 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11559 (gnus-summary-position-point)))
11561 (eval-and-compile
11562 (if (fboundp 'remove-overlays)
11563 (defalias 'gnus-remove-overlays 'remove-overlays)
11564 (defun gnus-remove-overlays (beg end name val)
11565 "Clear BEG and END of overlays whose property NAME has value VAL.
11566 For compatibility with XEmacs."
11567 (dolist (ov (gnus-overlays-in beg end))
11568 (when (eq (gnus-overlay-get ov name) val)
11569 (gnus-delete-overlay ov))))))
11571 (defun gnus-summary-show-all-threads ()
11572 "Show all threads."
11573 (interactive)
11574 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11575 (gnus-summary-position-point))
11577 (defsubst gnus-summary--inv (p)
11578 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11580 (defun gnus-summary-show-thread ()
11581 "Show thread subtrees.
11582 Returns nil if no thread was there to be shown."
11583 (interactive)
11584 (let* ((orig (point))
11585 (end (point-at-eol))
11586 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11587 ;; Leave point at bol
11588 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11589 (eoi (when end
11590 (if (fboundp 'next-single-char-property-change)
11591 ;; Note: XEmacs version of n-s-c-p-c may return nil
11592 (or (next-single-char-property-change end 'invisible)
11593 (point-max))
11594 (while (progn
11595 (end-of-line 2)
11596 (and (not (eobp))
11597 (eq (get-char-property (point) 'invisible)
11598 'gnus-sum))))
11599 (point)))))
11600 (when eoi
11601 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11602 (goto-char orig)
11603 (gnus-summary-position-point)
11604 eoi)))
11606 (defun gnus-summary-maybe-hide-threads ()
11607 "If requested, hide the threads that should be hidden."
11608 (when (and gnus-show-threads
11609 gnus-thread-hide-subtree)
11610 (gnus-summary-hide-all-threads
11611 (if (or (consp gnus-thread-hide-subtree)
11612 (functionp gnus-thread-hide-subtree))
11613 (gnus-make-predicate gnus-thread-hide-subtree)
11614 nil))))
11616 ;;; Hiding predicates.
11618 (defun gnus-article-unread-p (header)
11619 (memq (mail-header-number header) gnus-newsgroup-unreads))
11621 (defun gnus-article-unseen-p (header)
11622 (memq (mail-header-number header) gnus-newsgroup-unseen))
11624 (defun gnus-map-articles (predicate articles)
11625 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11626 (apply 'gnus-or (mapcar predicate
11627 (mapcar (lambda (number)
11628 (gnus-summary-article-header number))
11629 articles))))
11631 (defun gnus-summary-hide-all-threads (&optional predicate)
11632 "Hide all thread subtrees.
11633 If PREDICATE is supplied, threads that satisfy this predicate
11634 will not be hidden."
11635 (interactive)
11636 (save-excursion
11637 (goto-char (point-min))
11638 (let ((end nil)
11639 (count 0))
11640 (while (not end)
11641 (incf count)
11642 (when (zerop (mod count 1000))
11643 (message "Hiding all threads... %d" count))
11644 (when (or (not predicate)
11645 (gnus-map-articles
11646 predicate (gnus-summary-article-children)))
11647 (gnus-summary-hide-thread))
11648 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11649 (gnus-summary-position-point))
11651 (defun gnus-summary-hide-thread ()
11652 "Hide thread subtrees.
11653 If PREDICATE is supplied, threads that satisfy this predicate
11654 will not be hidden.
11655 Returns nil if no threads were there to be hidden."
11656 (interactive)
11657 (let ((start (point))
11658 (starteol (line-end-position))
11659 (article (gnus-summary-article-number)))
11660 (goto-char start)
11661 ;; Go forward until either the buffer ends or the subthread ends.
11662 (when (and (not (eobp))
11663 (or (zerop (gnus-summary-next-thread 1 t))
11664 (goto-char (point-max))))
11665 (if (and (> (point) start)
11666 ;; FIXME: this should actually search for a non-invisible \n.
11667 (search-backward "\n" start t))
11668 (progn
11669 (when (> (point) starteol)
11670 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11671 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11672 (gnus-overlay-put ol 'invisible 'gnus-sum)
11673 (gnus-overlay-put ol 'evaporate t)))
11674 (gnus-summary-goto-subject article)
11675 (when (> start (point))
11676 (message "Hiding the thread moved us backwards, aborting!")
11677 (goto-char (point-max))))
11678 (goto-char start)
11679 nil))))
11681 (defun gnus-summary-go-to-next-thread (&optional previous)
11682 "Go to the same level (or less) next thread.
11683 If PREVIOUS is non-nil, go to previous thread instead.
11684 Return the article number moved to, or nil if moving was impossible."
11685 (let ((level (gnus-summary-thread-level))
11686 (way (if previous -1 1))
11687 (beg (point)))
11688 (forward-line way)
11689 (while (and (not (eobp))
11690 (< level (gnus-summary-thread-level)))
11691 (forward-line way))
11692 (if (eobp)
11693 (progn
11694 (goto-char beg)
11695 nil)
11696 (setq beg (point))
11697 (prog1
11698 (gnus-summary-article-number)
11699 (goto-char beg)))))
11701 (defun gnus-summary-next-thread (n &optional silent)
11702 "Go to the same level next N'th thread.
11703 If N is negative, search backward instead.
11704 Returns the difference between N and the number of skips actually
11705 done.
11707 If SILENT, don't output messages."
11708 (interactive "p")
11709 (let ((backward (< n 0))
11710 (n (abs n)))
11711 (while (and (> n 0)
11712 (gnus-summary-go-to-next-thread backward))
11713 (decf n))
11714 (unless silent
11715 (gnus-summary-position-point))
11716 (when (and (not silent) (/= 0 n))
11717 (gnus-message 7 "No more threads"))
11720 (defun gnus-summary-prev-thread (n)
11721 "Go to the same level previous N'th thread.
11722 Returns the difference between N and the number of skips actually
11723 done."
11724 (interactive "p")
11725 (gnus-summary-next-thread (- n)))
11727 (defun gnus-summary-go-down-thread ()
11728 "Go down one level in the current thread."
11729 (let ((children (gnus-summary-article-children)))
11730 (when children
11731 (gnus-summary-goto-subject (car children)))))
11733 (defun gnus-summary-go-up-thread ()
11734 "Go up one level in the current thread."
11735 (let ((parent (gnus-summary-article-parent)))
11736 (when parent
11737 (gnus-summary-goto-subject parent))))
11739 (defun gnus-summary-down-thread (n)
11740 "Go down thread N steps.
11741 If N is negative, go up instead.
11742 Returns the difference between N and how many steps down that were
11743 taken."
11744 (interactive "p")
11745 (let ((up (< n 0))
11746 (n (abs n)))
11747 (while (and (> n 0)
11748 (if up (gnus-summary-go-up-thread)
11749 (gnus-summary-go-down-thread)))
11750 (setq n (1- n)))
11751 (gnus-summary-position-point)
11752 (when (/= 0 n)
11753 (gnus-message 7 "Can't go further"))
11756 (defun gnus-summary-up-thread (n)
11757 "Go up thread N steps.
11758 If N is negative, go down instead.
11759 Returns the difference between N and how many steps down that were
11760 taken."
11761 (interactive "p")
11762 (gnus-summary-down-thread (- n)))
11764 (defun gnus-summary-top-thread ()
11765 "Go to the top of the thread."
11766 (interactive)
11767 (while (gnus-summary-go-up-thread))
11768 (gnus-summary-article-number))
11770 (defun gnus-summary-expire-thread ()
11771 "Mark articles under current thread as expired."
11772 (interactive)
11773 (gnus-summary-kill-thread 0))
11775 (defun gnus-summary-kill-thread (&optional unmark)
11776 "Mark articles under current thread as read.
11777 If the prefix argument is positive, remove any kinds of marks.
11778 If the prefix argument is zero, mark thread as expired.
11779 If the prefix argument is negative, tick articles instead."
11780 (interactive "P")
11781 (when unmark
11782 (setq unmark (prefix-numeric-value unmark)))
11783 (let ((articles (gnus-summary-articles-in-thread))
11784 (hide (or (null unmark) (= unmark 0))))
11785 (save-excursion
11786 ;; Expand the thread.
11787 (gnus-summary-show-thread)
11788 ;; Mark all the articles.
11789 (while articles
11790 (gnus-summary-goto-subject (car articles))
11791 (cond ((null unmark)
11792 (gnus-summary-mark-article-as-read gnus-killed-mark))
11793 ((> unmark 0)
11794 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11795 ((= unmark 0)
11796 (gnus-summary-mark-article nil gnus-expirable-mark))
11798 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11799 (setq articles (cdr articles))))
11800 ;; Hide killed subtrees when hide is true.
11801 (and hide
11802 gnus-thread-hide-killed
11803 (gnus-summary-hide-thread))
11804 ;; If hide is t, go to next unread subject.
11805 (when hide
11806 ;; Go to next unread subject.
11807 (gnus-summary-next-subject 1 t)))
11808 (gnus-set-mode-line 'summary))
11810 ;; Summary sorting commands
11812 (defun gnus-summary-sort-by-number (&optional reverse)
11813 "Sort the summary buffer by article number.
11814 Argument REVERSE means reverse order."
11815 (interactive "P")
11816 (gnus-summary-sort 'number reverse))
11818 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11819 "Sort the summary buffer by most recent article number.
11820 Argument REVERSE means reverse order."
11821 (interactive "P")
11822 (gnus-summary-sort 'most-recent-number reverse))
11824 (defun gnus-summary-sort-by-random (&optional reverse)
11825 "Randomize the order in the summary buffer.
11826 Argument REVERSE means to randomize in reverse order."
11827 (interactive "P")
11828 (gnus-summary-sort 'random reverse))
11830 (defun gnus-summary-sort-by-author (&optional reverse)
11831 "Sort the summary buffer by author name alphabetically.
11832 If `case-fold-search' is non-nil, case of letters is ignored.
11833 Argument REVERSE means reverse order."
11834 (interactive "P")
11835 (gnus-summary-sort 'author reverse))
11837 (defun gnus-summary-sort-by-recipient (&optional reverse)
11838 "Sort the summary buffer by recipient name alphabetically.
11839 If `case-fold-search' is non-nil, case of letters is ignored.
11840 Argument REVERSE means reverse order."
11841 (interactive "P")
11842 (gnus-summary-sort 'recipient reverse))
11844 (defun gnus-summary-sort-by-subject (&optional reverse)
11845 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11846 If `case-fold-search' is non-nil, case of letters is ignored.
11847 Argument REVERSE means reverse order."
11848 (interactive "P")
11849 (gnus-summary-sort 'subject reverse))
11851 (defun gnus-summary-sort-by-date (&optional reverse)
11852 "Sort the summary buffer by date.
11853 Argument REVERSE means reverse order."
11854 (interactive "P")
11855 (gnus-summary-sort 'date reverse))
11857 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11858 "Sort the summary buffer by most recent date.
11859 Argument REVERSE means reverse order."
11860 (interactive "P")
11861 (gnus-summary-sort 'most-recent-date reverse))
11863 (defun gnus-summary-sort-by-score (&optional reverse)
11864 "Sort the summary buffer by score.
11865 Argument REVERSE means reverse order."
11866 (interactive "P")
11867 (gnus-summary-sort 'score reverse))
11869 (defun gnus-summary-sort-by-lines (&optional reverse)
11870 "Sort the summary buffer by the number of lines.
11871 Argument REVERSE means reverse order."
11872 (interactive "P")
11873 (gnus-summary-sort 'lines reverse))
11875 (defun gnus-summary-sort-by-chars (&optional reverse)
11876 "Sort the summary buffer by article length.
11877 Argument REVERSE means reverse order."
11878 (interactive "P")
11879 (gnus-summary-sort 'chars reverse))
11881 (defun gnus-summary-sort-by-original (&optional reverse)
11882 "Sort the summary buffer using the default sorting method.
11883 Argument REVERSE means reverse order."
11884 (interactive "P")
11885 (let* ((inhibit-read-only t)
11886 (gnus-summary-prepare-hook nil))
11887 ;; We do the sorting by regenerating the threads.
11888 (gnus-summary-prepare)
11889 ;; Hide subthreads if needed.
11890 (gnus-summary-maybe-hide-threads)))
11892 (defun gnus-summary-sort (predicate reverse)
11893 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11894 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11895 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11896 (gnus-thread-sort-functions
11897 (if (not reverse)
11898 thread
11899 `(lambda (t1 t2)
11900 (,thread t2 t1))))
11901 (gnus-sort-gathered-threads-function
11902 gnus-thread-sort-functions)
11903 (gnus-article-sort-functions
11904 (if (not reverse)
11905 article
11906 `(lambda (t1 t2)
11907 (,article t2 t1))))
11908 (inhibit-read-only t)
11909 (gnus-summary-prepare-hook nil))
11910 ;; We do the sorting by regenerating the threads.
11911 (gnus-summary-prepare)
11912 ;; Hide subthreads if needed.
11913 (gnus-summary-maybe-hide-threads)))
11915 ;; Summary saving commands.
11917 (defun gnus-summary-save-article (&optional n not-saved)
11918 "Save the current article using the default saver function.
11919 If N is a positive number, save the N next articles.
11920 If N is a negative number, save the N previous articles.
11921 If N is nil and any articles have been marked with the process mark,
11922 save those articles instead.
11923 The variable `gnus-default-article-saver' specifies the saver function.
11925 If the optional second argument NOT-SAVED is non-nil, articles saved
11926 will not be marked as saved."
11927 (interactive "P")
11928 (require 'gnus-art)
11929 (let* ((articles (gnus-summary-work-articles n))
11930 (save-buffer (save-excursion
11931 (nnheader-set-temp-buffer " *Gnus Save*")))
11932 (num (length articles))
11933 ;; Whether to save decoded articles or raw articles.
11934 (decode (when gnus-article-save-coding-system
11935 (get gnus-default-article-saver :decode)))
11936 ;; When saving many articles in a single file, use the other
11937 ;; function to save articles other than the first one.
11938 (saver2 (get gnus-default-article-saver :function))
11939 (gnus-prompt-before-saving (if saver2
11941 gnus-prompt-before-saving))
11942 (gnus-default-article-saver gnus-default-article-saver)
11943 header file)
11944 (dolist (article articles)
11945 (setq header (gnus-summary-article-header article))
11946 (if (not (vectorp header))
11947 ;; This is a pseudo-article.
11948 (if (assq 'name header)
11949 (gnus-copy-file (cdr (assq 'name header)))
11950 (gnus-message 1 "Article %d is unsavable" article))
11951 ;; This is a real article.
11952 (save-window-excursion
11953 (gnus-summary-select-article decode decode nil article)
11954 (gnus-summary-goto-subject article))
11955 (with-current-buffer save-buffer
11956 (erase-buffer)
11957 (insert-buffer-substring (if decode
11958 gnus-article-buffer
11959 gnus-original-article-buffer)))
11960 (setq file (gnus-article-save save-buffer file num))
11961 (gnus-summary-remove-process-mark article)
11962 (unless not-saved
11963 (gnus-summary-set-saved-mark article)))
11964 (when saver2
11965 (setq gnus-default-article-saver saver2
11966 saver2 nil)))
11967 (gnus-kill-buffer save-buffer)
11968 (gnus-summary-position-point)
11969 (gnus-set-mode-line 'summary)
11972 (defun gnus-summary-pipe-output (&optional n sym)
11973 "Pipe the current article to a subprocess.
11974 If N is a positive number, pipe the N next articles.
11975 If N is a negative number, pipe the N previous articles.
11976 If N is nil and any articles have been marked with the process mark,
11977 pipe those articles instead.
11978 The default command to which articles are piped is specified by the
11979 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11980 will be prompted for the command.
11982 The properties `:decode' and `:headers' that are put to the function
11983 symbol `gnus-summary-save-in-pipe' control whether this function
11984 decodes articles and what headers to keep (see the doc string for the
11985 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11986 is neither omitted nor the symbol `r', force including all headers
11987 regardless of the `:headers' property. If it is the symbol `r',
11988 articles that are not decoded and include all headers will be piped
11989 no matter what the properties `:decode' and `:headers' are."
11990 (interactive (gnus-interactive "P\ny"))
11991 (require 'gnus-art)
11992 (let* ((articles (gnus-summary-work-articles n))
11993 (result-buffer "*Shell Command Output*")
11994 (all-headers (not (memq sym '(nil r))))
11995 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11996 (raw (eq sym 'r))
11997 (headers (get 'gnus-summary-save-in-pipe :headers))
11998 command result)
11999 (unless (numberp (car articles))
12000 (error "No article to pipe"))
12001 (setq command (gnus-read-shell-command
12002 (concat "Shell command on "
12003 (if (cdr articles)
12004 (format "these %d articles" (length articles))
12005 "this article")
12006 ": ")
12007 gnus-summary-pipe-output-default-command))
12008 (when (string-equal command "")
12009 (error "A command is required"))
12010 (when all-headers
12011 (put 'gnus-summary-save-in-pipe :headers nil))
12012 (unwind-protect
12013 (while articles
12014 (gnus-summary-goto-subject (pop articles))
12015 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12016 (when (and (get-buffer result-buffer)
12017 (not (zerop (buffer-size (get-buffer result-buffer)))))
12018 (setq result (concat result (with-current-buffer result-buffer
12019 (buffer-string))))))
12020 (put 'gnus-summary-save-in-pipe :headers headers))
12021 (unless (zerop (length result))
12022 (if (with-current-buffer (get-buffer-create result-buffer)
12023 (erase-buffer)
12024 (insert result)
12025 (prog1
12026 (and (= (count-lines (point-min) (point)) 1)
12027 (progn
12028 (end-of-line 0)
12029 (<= (current-column)
12030 (window-width (minibuffer-window)))))
12031 (goto-char (point-min))))
12032 (message "%s" (substring result 0 -1))
12033 (message nil)
12034 (gnus-configure-windows 'pipe)))))
12036 (defun gnus-summary-save-article-mail (&optional arg)
12037 "Append the current article to a Unix mail box file.
12038 If N is a positive number, save the N next articles.
12039 If N is a negative number, save the N previous articles.
12040 If N is nil and any articles have been marked with the process mark,
12041 save those articles instead."
12042 (interactive "P")
12043 (require 'gnus-art)
12044 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12045 (gnus-summary-save-article arg)))
12047 (defun gnus-summary-save-article-rmail (&optional arg)
12048 "Append the current article to an rmail file.
12049 If N is a positive number, save the N next articles.
12050 If N is a negative number, save the N previous articles.
12051 If N is nil and any articles have been marked with the process mark,
12052 save those articles instead."
12053 (interactive "P")
12054 (require 'gnus-art)
12055 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12056 (gnus-summary-save-article arg)))
12058 (defun gnus-summary-save-article-file (&optional arg)
12059 "Append the current article to a file.
12060 If N is a positive number, save the N next articles.
12061 If N is a negative number, save the N previous articles.
12062 If N is nil and any articles have been marked with the process mark,
12063 save those articles instead."
12064 (interactive "P")
12065 (require 'gnus-art)
12066 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12067 (gnus-summary-save-article arg)))
12069 (defun gnus-summary-write-article-file (&optional arg)
12070 "Write the current article to a file, deleting the previous file.
12071 If N is a positive number, save the N next articles.
12072 If N is a negative number, save the N previous articles.
12073 If N is nil and any articles have been marked with the process mark,
12074 save those articles instead."
12075 (interactive "P")
12076 (require 'gnus-art)
12077 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12078 (gnus-summary-save-article arg)))
12080 (defun gnus-summary-save-article-body-file (&optional arg)
12081 "Append the current article body to a file.
12082 If N is a positive number, save the N next articles.
12083 If N is a negative number, save the N previous articles.
12084 If N is nil and any articles have been marked with the process mark,
12085 save those articles instead."
12086 (interactive "P")
12087 (require 'gnus-art)
12088 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12089 (gnus-summary-save-article arg)))
12091 (defun gnus-summary-write-article-body-file (&optional arg)
12092 "Write the current article body to a file, deleting the previous file.
12093 If N is a positive number, save the N next articles.
12094 If N is a negative number, save the N previous articles.
12095 If N is nil and any articles have been marked with the process mark,
12096 save those articles instead."
12097 (interactive "P")
12098 (require 'gnus-art)
12099 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12100 (gnus-summary-save-article arg)))
12102 (defun gnus-summary-muttprint (&optional arg)
12103 "Print the current article using Muttprint.
12104 If N is a positive number, save the N next articles.
12105 If N is a negative number, save the N previous articles.
12106 If N is nil and any articles have been marked with the process mark,
12107 save those articles instead."
12108 (interactive "P")
12109 (require 'gnus-art)
12110 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12111 (gnus-summary-save-article arg t)))
12113 (defun gnus-summary-pipe-message (program)
12114 "Pipe the current article through PROGRAM."
12115 (interactive "sProgram: ")
12116 (gnus-summary-select-article)
12117 (let ((mail-header-separator ""))
12118 (gnus-eval-in-buffer-window gnus-article-buffer
12119 (save-restriction
12120 (widen)
12121 (let ((start (window-start))
12122 (inhibit-read-only t))
12123 (message-pipe-buffer-body program)
12124 (set-window-start (get-buffer-window (current-buffer)) start))))))
12126 (defun gnus-get-split-value (methods)
12127 "Return a value based on the split METHODS."
12128 (let (split-name method result match)
12129 (when methods
12130 (with-current-buffer gnus-original-article-buffer
12131 (save-restriction
12132 (nnheader-narrow-to-headers)
12133 (while (and methods (not split-name))
12134 (goto-char (point-min))
12135 (setq method (pop methods))
12136 (setq match (car method))
12137 (when (cond
12138 ((stringp match)
12139 ;; Regular expression.
12140 (ignore-errors
12141 (re-search-forward match nil t)))
12142 ((functionp match)
12143 ;; Function.
12144 (save-restriction
12145 (widen)
12146 (setq result (funcall match gnus-newsgroup-name))))
12147 ((consp match)
12148 ;; Form.
12149 (save-restriction
12150 (widen)
12151 (setq result (eval match)))))
12152 (setq split-name (cdr method))
12153 (cond ((stringp result)
12154 (push (expand-file-name
12155 result gnus-article-save-directory)
12156 split-name))
12157 ((consp result)
12158 (setq split-name (append result split-name)))))))))
12159 (nreverse split-name)))
12161 (defun gnus-valid-move-group-p (group)
12162 (and (symbolp group)
12163 (boundp group)
12164 (symbol-name group)
12165 (symbol-value group)
12166 (gnus-get-function (gnus-find-method-for-group
12167 (symbol-name group)) 'request-accept-article t)))
12169 (defun gnus-read-move-group-name (prompt default articles prefix)
12170 "Read a group name."
12171 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12172 (minibuffer-confirm-incomplete nil) ; XEmacs
12173 (prom
12174 (format "%s %s to"
12175 prompt
12176 (if (> (length articles) 1)
12177 (format "these %d articles" (length articles))
12178 "this article")))
12179 (to-newsgroup
12180 (cond
12181 ((null split-name)
12182 (gnus-group-completing-read
12183 prom
12184 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12185 nil prefix nil default))
12186 ((= 1 (length split-name))
12187 (gnus-group-completing-read
12188 prom
12189 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12190 nil prefix 'gnus-group-history (car split-name)))
12192 (gnus-completing-read
12193 prom (nreverse split-name) nil nil 'gnus-group-history))))
12194 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12195 encoded)
12196 (when to-newsgroup
12197 (if (or (string= to-newsgroup "")
12198 (string= to-newsgroup prefix))
12199 (setq to-newsgroup default))
12200 (unless to-newsgroup
12201 (error "No group name entered"))
12202 (setq encoded (mm-encode-coding-string
12203 to-newsgroup
12204 (gnus-group-name-charset to-method to-newsgroup)))
12205 (or (gnus-active encoded)
12206 (gnus-activate-group encoded nil nil to-method)
12207 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12208 to-newsgroup))
12209 (or (and (gnus-request-create-group encoded to-method)
12210 (gnus-activate-group encoded nil nil to-method)
12211 (gnus-subscribe-group encoded))
12212 (error "Couldn't create group %s" to-newsgroup)))
12213 (error "No such group: %s" to-newsgroup))
12214 encoded)))
12216 (defvar gnus-summary-save-parts-counter)
12217 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12219 (defun gnus-summary-save-parts (type dir n &optional reverse)
12220 "Save parts matching TYPE to DIR.
12221 If REVERSE, save parts that do not match TYPE."
12222 (interactive
12223 (list (read-string "Save parts of type: "
12224 (or (car gnus-summary-save-parts-type-history)
12225 gnus-summary-save-parts-default-mime)
12226 'gnus-summary-save-parts-type-history)
12227 (setq gnus-summary-save-parts-last-directory
12228 (read-directory-name "Save to directory: "
12229 gnus-summary-save-parts-last-directory
12230 nil t))
12231 current-prefix-arg))
12232 (gnus-summary-iterate n
12233 (let ((gnus-display-mime-function nil)
12234 gnus-article-prepare-hook
12235 gnus-article-decode-hook
12236 gnus-display-mime-function
12237 gnus-break-pages
12238 (gnus-inhibit-treatment t))
12239 (gnus-summary-select-article))
12240 (with-current-buffer gnus-article-buffer
12241 (let ((handles (or gnus-article-mime-handles
12242 (mm-dissect-buffer nil gnus-article-loose-mime)
12243 (and gnus-article-emulate-mime
12244 (mm-uu-dissect))))
12245 (gnus-summary-save-parts-counter 1))
12246 (when handles
12247 (gnus-summary-save-parts-1 type dir handles reverse)
12248 (unless gnus-article-mime-handles ;; Don't destroy this case.
12249 (mm-destroy-parts handles)))))))
12251 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12252 (if (stringp (car handle))
12253 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12254 (cdr handle))
12255 (when (if reverse
12256 (not (string-match type (mm-handle-media-type handle)))
12257 (string-match type (mm-handle-media-type handle)))
12258 (let ((file (expand-file-name
12259 (gnus-map-function
12260 mm-file-name-rewrite-functions
12261 (file-name-nondirectory
12263 (mm-handle-filename handle)
12264 (format "%s.%d.%d" gnus-newsgroup-name
12265 (cdr gnus-article-current)
12266 gnus-summary-save-parts-counter))))
12267 dir)))
12268 (incf gnus-summary-save-parts-counter)
12269 (unless (file-exists-p file)
12270 (mm-save-part-to-file handle file))))))
12272 ;; Summary extract commands
12274 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12275 (let ((inhibit-read-only t)
12276 (article (gnus-summary-article-number))
12277 after-article b e)
12278 (unless (gnus-summary-goto-subject article)
12279 (error "No such article: %d" article))
12280 (gnus-summary-position-point)
12281 ;; If all commands are to be bunched up on one line, we collect
12282 ;; them here.
12283 (unless gnus-view-pseudos-separately
12284 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12285 files action)
12286 (while ps
12287 (setq action (cdr (assq 'action (car ps))))
12288 (setq files (list (cdr (assq 'name (car ps)))))
12289 (while (and ps (cdr ps)
12290 (string= (or action "1")
12291 (or (cdr (assq 'action (cadr ps))) "2")))
12292 (push (cdr (assq 'name (cadr ps))) files)
12293 (setcdr ps (cddr ps)))
12294 (when files
12295 (when (not (string-match "%s" action))
12296 (push " " files))
12297 (push " " files)
12298 (when (assq 'execute (car ps))
12299 (setcdr (assq 'execute (car ps))
12300 (funcall (if (string-match "%s" action)
12301 'format 'concat)
12302 action
12303 (mapconcat
12304 (lambda (f)
12305 (if (equal f " ")
12307 (shell-quote-argument f)))
12308 files " ")))))
12309 (setq ps (cdr ps)))))
12310 (if (and gnus-view-pseudos (not not-view))
12311 (while pslist
12312 (when (assq 'execute (car pslist))
12313 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12314 (eq gnus-view-pseudos 'not-confirm)))
12315 (setq pslist (cdr pslist)))
12316 (save-excursion
12317 (while pslist
12318 (setq after-article (or (cdr (assq 'article (car pslist)))
12319 (gnus-summary-article-number)))
12320 (gnus-summary-goto-subject after-article)
12321 (forward-line 1)
12322 (setq b (point))
12323 (insert " " (file-name-nondirectory
12324 (cdr (assq 'name (car pslist))))
12325 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12326 (setq e (point))
12327 (forward-line -1) ; back to `b'
12328 (gnus-add-text-properties
12329 b (1- e) (list 'gnus-number gnus-reffed-article-number
12330 gnus-mouse-face-prop gnus-mouse-face))
12331 (gnus-data-enter
12332 after-article gnus-reffed-article-number
12333 gnus-unread-mark b (car pslist) 0 (- e b))
12334 (setq gnus-newsgroup-unreads
12335 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12336 gnus-reffed-article-number))
12337 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12338 (setq pslist (cdr pslist)))))))
12340 (defun gnus-pseudos< (p1 p2)
12341 (let ((c1 (cdr (assq 'action p1)))
12342 (c2 (cdr (assq 'action p2))))
12343 (and c1 c2 (string< c1 c2))))
12345 (defun gnus-request-pseudo-article (props)
12346 (cond ((assq 'execute props)
12347 (gnus-execute-command (cdr (assq 'execute props)))))
12348 (let ((gnus-current-article (gnus-summary-article-number)))
12349 (gnus-run-hooks 'gnus-mark-article-hook)))
12351 (defun gnus-execute-command (command &optional automatic)
12352 (save-excursion
12353 (gnus-article-setup-buffer)
12354 (set-buffer gnus-article-buffer)
12355 (setq buffer-read-only nil)
12356 (let ((command (if automatic command
12357 (read-string "Command: " (cons command 0)))))
12358 (erase-buffer)
12359 (insert "$ " command "\n\n")
12360 (if gnus-view-pseudo-asynchronously
12361 (start-process "gnus-execute" (current-buffer) shell-file-name
12362 shell-command-switch command)
12363 (call-process shell-file-name nil t nil
12364 shell-command-switch command)))))
12366 ;; Summary kill commands.
12368 (defun gnus-summary-edit-global-kill (article)
12369 "Edit the \"global\" kill file."
12370 (interactive (list (gnus-summary-article-number)))
12371 (gnus-group-edit-global-kill article))
12373 (defun gnus-summary-edit-local-kill ()
12374 "Edit a local kill file applied to the current newsgroup."
12375 (interactive)
12376 (setq gnus-current-headers (gnus-summary-article-header))
12377 (gnus-group-edit-local-kill
12378 (gnus-summary-article-number) gnus-newsgroup-name))
12380 ;;; Header reading.
12382 (defun gnus-read-header (id &optional header)
12383 "Read the headers of article ID and enter them into the Gnus system."
12384 (let ((group gnus-newsgroup-name)
12385 (gnus-override-method
12387 gnus-override-method
12388 (and (gnus-news-group-p gnus-newsgroup-name)
12389 (car (gnus-refer-article-methods)))))
12390 where)
12391 ;; First we check to see whether the header in question is already
12392 ;; fetched.
12393 (if (stringp id)
12394 ;; This is a Message-ID.
12395 (setq header (or header (gnus-id-to-header id)))
12396 ;; This is an article number.
12397 (setq header (or header (gnus-summary-article-header id))))
12398 (if (and header
12399 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12400 ;; We have found the header.
12401 header
12402 ;; We have to really fetch the header to this article.
12403 (with-current-buffer nntp-server-buffer
12404 (when (setq where (gnus-request-head id group))
12405 (nnheader-fold-continuation-lines)
12406 (goto-char (point-max))
12407 (insert ".\n")
12408 (goto-char (point-min))
12409 (insert "211 ")
12410 (princ (cond
12411 ((numberp id) id)
12412 ((cdr where) (cdr where))
12413 (header (mail-header-number header))
12414 (t gnus-reffed-article-number))
12415 (current-buffer))
12416 (insert " Article retrieved.\n"))
12417 (if (or (not where)
12418 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12419 () ; Malformed head.
12420 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12421 (when (and (stringp id)
12423 (not (string= (gnus-group-real-name group)
12424 (car where)))
12425 (not (gnus-server-equal gnus-override-method
12426 (gnus-group-method group)))))
12427 ;; If we fetched by Message-ID and the article came from
12428 ;; a different group (or server), we fudge some bogus
12429 ;; article numbers for this article.
12430 (mail-header-set-number header gnus-reffed-article-number))
12431 (with-current-buffer gnus-summary-buffer
12432 (decf gnus-reffed-article-number)
12433 (gnus-remove-header (mail-header-number header))
12434 (push header gnus-newsgroup-headers)
12435 (setq gnus-current-headers header)
12436 (push (mail-header-number header) gnus-newsgroup-limit)))
12437 header)))))
12439 (defun gnus-remove-header (number)
12440 "Remove header NUMBER from `gnus-newsgroup-headers'."
12441 (if (and gnus-newsgroup-headers
12442 (= number (mail-header-number (car gnus-newsgroup-headers))))
12443 (pop gnus-newsgroup-headers)
12444 (let ((headers gnus-newsgroup-headers))
12445 (while (and (cdr headers)
12446 (not (= number (mail-header-number (cadr headers)))))
12447 (pop headers))
12448 (when (cdr headers)
12449 (setcdr headers (cddr headers))))))
12452 ;;; summary highlights
12455 (defun gnus-highlight-selected-summary ()
12456 "Highlight selected article in summary buffer."
12457 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12458 (when gnus-summary-selected-face
12459 (save-excursion
12460 (let* ((beg (point-at-bol))
12461 (end (point-at-eol))
12462 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12463 (from (if (get-text-property beg gnus-mouse-face-prop)
12465 (or (next-single-property-change
12466 beg gnus-mouse-face-prop nil end)
12467 beg)))
12469 (if (= from end)
12470 (- from 2)
12471 (or (next-single-property-change
12472 from gnus-mouse-face-prop nil end)
12473 end))))
12474 ;; If no mouse-face prop on line we will have to = from = end,
12475 ;; so we highlight the entire line instead.
12476 (when (= (+ to 2) from)
12477 (setq from beg)
12478 (setq to end))
12479 (if gnus-newsgroup-selected-overlay
12480 ;; Move old overlay.
12481 (gnus-move-overlay
12482 gnus-newsgroup-selected-overlay from to (current-buffer))
12483 ;; Create new overlay.
12484 (gnus-overlay-put
12485 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12486 'face gnus-summary-selected-face))))))
12488 (defvar gnus-summary-highlight-line-cached nil)
12489 (defvar gnus-summary-highlight-line-trigger nil)
12491 (defun gnus-summary-highlight-line-0 ()
12492 (if (and (eq gnus-summary-highlight-line-trigger
12493 gnus-summary-highlight)
12494 gnus-summary-highlight-line-cached)
12495 gnus-summary-highlight-line-cached
12496 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12497 gnus-summary-highlight-line-cached
12498 (let* ((cond (list 'cond))
12499 (c cond)
12500 (list gnus-summary-highlight))
12501 (while list
12502 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12503 nil))
12504 (setq c (cdr c)
12505 list (cdr list)))
12506 (gnus-byte-compile (list 'lambda nil cond))))))
12508 (defun gnus-summary-highlight-line ()
12509 "Highlight current line according to `gnus-summary-highlight'."
12510 (let* ((beg (point-at-bol))
12511 (article (or (gnus-summary-article-number) gnus-current-article))
12512 (score (or (cdr (assq article
12513 gnus-newsgroup-scored))
12514 gnus-summary-default-score 0))
12515 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12516 (inhibit-read-only t)
12517 (default gnus-summary-default-score)
12518 (default-high gnus-summary-default-high-score)
12519 (default-low gnus-summary-default-low-score)
12520 (uncached (and gnus-summary-use-undownloaded-faces
12521 (memq article gnus-newsgroup-undownloaded)
12522 (not (memq article gnus-newsgroup-cached)))))
12523 (let ((face (funcall (gnus-summary-highlight-line-0))))
12524 (unless (eq face (get-text-property beg 'face))
12525 (gnus-put-text-property-excluding-characters-with-faces
12526 beg (point-at-eol) 'face
12527 (setq face (if (boundp face) (symbol-value face) face)))
12528 (when gnus-summary-highlight-line-function
12529 (funcall gnus-summary-highlight-line-function article face))))))
12531 (defun gnus-update-read-articles (group unread &optional compute)
12532 "Update the list of read articles in GROUP.
12533 UNREAD is a sorted list."
12534 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12535 (info (gnus-get-info group))
12536 (prev 1)
12537 read)
12538 (if (or (not info) (not active))
12539 ;; There is no info on this group if it was, in fact,
12540 ;; killed. Gnus stores no information on killed groups, so
12541 ;; there's nothing to be done.
12542 ;; One could store the information somewhere temporarily,
12543 ;; perhaps... Hmmm...
12545 ;; Remove any negative articles numbers.
12546 (while (and unread (< (car unread) 0))
12547 (setq unread (cdr unread)))
12548 ;; Remove any expired article numbers
12549 (while (and unread (< (car unread) (car active)))
12550 (setq unread (cdr unread)))
12551 ;; Compute the ranges of read articles by looking at the list of
12552 ;; unread articles.
12553 (while unread
12554 (when (/= (car unread) prev)
12555 (push (if (= prev (1- (car unread))) prev
12556 (cons prev (1- (car unread))))
12557 read))
12558 (setq prev (1+ (car unread)))
12559 (setq unread (cdr unread)))
12560 (when (<= prev (cdr active))
12561 (push (cons prev (cdr active)) read))
12562 (setq read (if (> (length read) 1) (nreverse read) read))
12563 (if compute
12564 read
12565 (save-excursion
12566 (let (setmarkundo)
12567 ;; Propagate the read marks to the backend.
12568 (when (and (or gnus-propagate-marks
12569 (gnus-method-option-p
12570 (gnus-find-method-for-group group)
12571 'server-marks))
12572 (gnus-check-backend-function 'request-set-mark group))
12573 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12574 (add (gnus-remove-from-range read (gnus-info-read info))))
12575 (when (or add del)
12576 (unless (gnus-check-group group)
12577 (error "Can't open server for %s" group))
12578 (gnus-request-set-mark
12579 group (delq nil (list (if add (list add 'add '(read)))
12580 (if del (list del 'del '(read))))))
12581 (setq setmarkundo
12582 `(gnus-request-set-mark
12583 ,group
12584 ',(delq nil (list
12585 (if del (list del 'add '(read)))
12586 (if add (list add 'del '(read))))))))))
12587 (set-buffer gnus-group-buffer)
12588 (gnus-undo-register
12589 `(progn
12590 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12591 (gnus-info-set-read ',info ',(gnus-info-read info))
12592 (gnus-get-unread-articles-in-group ',info
12593 (gnus-active ,group))
12594 (gnus-group-update-group ,group t)
12595 ,setmarkundo))))
12596 ;; Enter this list into the group info.
12597 (gnus-info-set-read info read)
12598 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12599 (gnus-get-unread-articles-in-group info (gnus-active group))
12600 t))))
12602 (defun gnus-offer-save-summaries ()
12603 "Offer to save all active summary buffers."
12604 (let (buffers)
12605 ;; Go through all buffers and find all summaries.
12606 (dolist (buffer (buffer-list))
12607 (when (and (setq buffer (buffer-name buffer))
12608 (string-match "Summary" buffer)
12609 (with-current-buffer buffer
12610 ;; We check that this is, indeed, a summary buffer.
12611 (and (eq major-mode 'gnus-summary-mode)
12612 ;; Also make sure this isn't bogus.
12613 gnus-newsgroup-prepared
12614 ;; Also make sure that this isn't a
12615 ;; dead summary buffer.
12616 (not gnus-dead-summary-mode))))
12617 (push buffer buffers)))
12618 ;; Go through all these summary buffers and offer to save them.
12619 (when buffers
12620 (save-excursion
12621 (if (eq gnus-interactive-exit 'quiet)
12622 (dolist (buffer buffers)
12623 (switch-to-buffer buffer)
12624 (gnus-summary-exit))
12625 (map-y-or-n-p
12626 "Update summary buffer %s? "
12627 (lambda (buf)
12628 (switch-to-buffer buf)
12629 (gnus-summary-exit))
12630 buffers))))))
12632 (defun gnus-summary-setup-default-charset ()
12633 "Setup newsgroup default charset."
12634 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12635 (setq gnus-newsgroup-charset nil)
12636 (let* ((ignored-charsets
12637 (or gnus-newsgroup-ephemeral-ignored-charsets
12638 (append
12639 (and gnus-newsgroup-name
12640 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12641 gnus-newsgroup-ignored-charsets))))
12642 (setq gnus-newsgroup-charset
12643 (or gnus-newsgroup-ephemeral-charset
12644 (and gnus-newsgroup-name
12645 (gnus-parameter-charset gnus-newsgroup-name))
12646 gnus-default-charset))
12647 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12648 ignored-charsets))))
12651 ;;; Mime Commands
12654 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12655 "Display the current article buffer fully MIME-buttonized.
12656 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12657 treated as multipart/mixed."
12658 (interactive "P")
12659 (require 'gnus-art)
12660 (let ((gnus-unbuttonized-mime-types nil)
12661 (gnus-mime-display-multipart-as-mixed show-all-parts))
12662 (gnus-summary-show-article)))
12664 (defun gnus-summary-repair-multipart (article)
12665 "Add a Content-Type header to a multipart article without one."
12666 (interactive (list (gnus-summary-article-number)))
12667 (gnus-with-article article
12668 (message-narrow-to-head)
12669 (message-remove-header "Mime-Version")
12670 (goto-char (point-max))
12671 (insert "Mime-Version: 1.0\n")
12672 (widen)
12673 (when (search-forward "\n--" nil t)
12674 (let ((separator (buffer-substring (point) (point-at-eol))))
12675 (message-narrow-to-head)
12676 (message-remove-header "Content-Type")
12677 (goto-char (point-max))
12678 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12679 separator))
12680 (widen))))
12681 (let (gnus-mark-article-hook)
12682 (gnus-summary-select-article t t nil article)))
12684 (defun gnus-summary-toggle-display-buttonized ()
12685 "Toggle the buttonizing of the article buffer."
12686 (interactive)
12687 (require 'gnus-art)
12688 (if (setq gnus-inhibit-mime-unbuttonizing
12689 (not gnus-inhibit-mime-unbuttonizing))
12690 (let ((gnus-unbuttonized-mime-types nil))
12691 (gnus-summary-show-article))
12692 (gnus-summary-show-article)))
12695 ;;; Generic summary marking commands
12698 (defvar gnus-summary-marking-alist
12699 '((read gnus-del-mark "d")
12700 (unread gnus-unread-mark "u")
12701 (ticked gnus-ticked-mark "!")
12702 (dormant gnus-dormant-mark "?")
12703 (expirable gnus-expirable-mark "e"))
12704 "An alist of names/marks/keystrokes.")
12706 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12707 (defvar gnus-summary-mark-map)
12709 (defun gnus-summary-make-all-marking-commands ()
12710 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12711 (dolist (elem gnus-summary-marking-alist)
12712 (apply 'gnus-summary-make-marking-command elem)))
12714 (defun gnus-summary-make-marking-command (name mark keystroke)
12715 (let ((map (make-sparse-keymap)))
12716 (define-key gnus-summary-generic-mark-map keystroke map)
12717 (dolist (lway `((next "next" next nil "n")
12718 (next-unread "next unread" next t "N")
12719 (prev "previous" prev nil "p")
12720 (prev-unread "previous unread" prev t "P")
12721 (nomove "" nil nil ,keystroke)))
12722 (let ((func (gnus-summary-make-marking-command-1
12723 mark (car lway) lway name)))
12724 (setq func (eval func))
12725 (define-key map (nth 4 lway) func)))))
12727 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12728 `(defun ,(intern
12729 (format "gnus-summary-put-mark-as-%s%s"
12730 name (if (eq way 'nomove)
12732 (concat "-" (symbol-name way)))))
12734 ,(format
12735 "Mark the current article as %s%s.
12736 If N, the prefix, then repeat N times.
12737 If N is negative, move in reverse order.
12738 The difference between N and the actual number of articles marked is
12739 returned."
12740 name (cadr lway))
12741 (interactive "p")
12742 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12744 (defun gnus-summary-generic-mark (n mark move unread)
12745 "Mark N articles with MARK."
12746 (unless (eq major-mode 'gnus-summary-mode)
12747 (error "This command can only be used in the summary buffer"))
12748 (gnus-summary-show-thread)
12749 (let ((nummove
12750 (cond
12751 ((eq move 'next) 1)
12752 ((eq move 'prev) -1)
12753 (t 0))))
12754 (if (zerop nummove)
12755 (setq n 1)
12756 (when (< n 0)
12757 (setq n (abs n)
12758 nummove (* -1 nummove))))
12759 (while (and (> n 0)
12760 (gnus-summary-mark-article nil mark)
12761 (zerop (gnus-summary-next-subject nummove unread t)))
12762 (setq n (1- n)))
12763 (when (/= 0 n)
12764 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12765 (gnus-summary-recenter)
12766 (gnus-summary-position-point)
12767 (gnus-set-mode-line 'summary)
12770 (defun gnus-summary-insert-articles (articles)
12771 (when (setq articles
12772 (gnus-sorted-difference articles
12773 (mapcar (lambda (h)
12774 (mail-header-number h))
12775 gnus-newsgroup-headers)))
12776 (setq gnus-newsgroup-headers
12777 (gnus-merge 'list
12778 gnus-newsgroup-headers
12779 (gnus-fetch-headers articles)
12780 'gnus-article-sort-by-number))
12781 (setq gnus-newsgroup-articles
12782 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12783 ;; Suppress duplicates?
12784 (when gnus-suppress-duplicates
12785 (gnus-dup-suppress-articles))
12787 (if (and gnus-fetch-old-headers
12788 (eq gnus-headers-retrieved-by 'nov))
12789 ;; We might want to build some more threads first.
12790 (if (eq gnus-fetch-old-headers 'invisible)
12791 (gnus-build-all-threads)
12792 (gnus-build-old-threads))
12793 ;; Mark the inserted articles that are unread as unread.
12794 (setq gnus-newsgroup-unreads
12795 (gnus-sorted-nunion
12796 gnus-newsgroup-unreads
12797 (gnus-sorted-nintersection
12798 (gnus-list-of-unread-articles gnus-newsgroup-name)
12799 articles)))
12800 ;; Mark the inserted articles as selected so that the information
12801 ;; of the marks having been changed by a user may be updated when
12802 ;; exiting this group. See `gnus-summary-update-info'.
12803 (dolist (art articles)
12804 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12805 ;; Let the Gnus agent mark articles as read.
12806 (when gnus-agent
12807 (gnus-agent-get-undownloaded-list))
12808 ;; Remove list identifiers from subject
12809 (gnus-summary-remove-list-identifiers)
12810 ;; First and last article in this newsgroup.
12811 (when gnus-newsgroup-headers
12812 (setq gnus-newsgroup-begin
12813 (mail-header-number (car gnus-newsgroup-headers))
12814 gnus-newsgroup-end
12815 (mail-header-number
12816 (gnus-last-element gnus-newsgroup-headers))))
12817 (when gnus-use-scoring
12818 (gnus-possibly-score-headers))))
12820 (defun gnus-summary-insert-old-articles (&optional all)
12821 "Insert all old articles in this group.
12822 If ALL is non-nil, already read articles become readable.
12823 If ALL is a number, fetch this number of articles."
12824 (interactive "P")
12825 (prog1
12826 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12827 older len)
12828 (setq older
12829 ;; Some nntp servers lie about their active range. When
12830 ;; this happens, the active range can be in the millions.
12831 ;; Use a compressed range to avoid creating a huge list.
12832 (gnus-range-difference (list gnus-newsgroup-active) old))
12833 (setq len (gnus-range-length older))
12834 (cond
12835 ((null older) nil)
12836 ((numberp all)
12837 (if (< all len)
12838 (let ((older-range (nreverse older)))
12839 (setq older nil)
12841 (while (> all 0)
12842 (let* ((r (pop older-range))
12843 (min (if (numberp r) r (car r)))
12844 (max (if (numberp r) r (cdr r))))
12845 (while (and (<= min max)
12846 (> all 0))
12847 (push max older)
12848 (setq all (1- all)
12849 max (1- max))))))
12850 (setq older (gnus-uncompress-range older))))
12851 (all
12852 (setq older (gnus-uncompress-range older)))
12854 (when (and (numberp gnus-large-newsgroup)
12855 (> len gnus-large-newsgroup))
12856 (let* ((cursor-in-echo-area nil)
12857 (initial (gnus-parameter-large-newsgroup-initial
12858 gnus-newsgroup-name))
12859 (input
12860 (read-string
12861 (format
12862 "How many articles from %s (%s %d): "
12863 (gnus-group-decoded-name gnus-newsgroup-name)
12864 (if initial "max" "default")
12865 len)
12866 nil nil
12867 (and initial
12868 (number-to-string initial)))))
12869 (unless (string-match "^[ \t]*$" input)
12870 (setq all (string-to-number input))
12871 (if (< all len)
12872 (let ((older-range (nreverse older)))
12873 (setq older nil)
12875 (while (> all 0)
12876 (let* ((r (pop older-range))
12877 (min (if (numberp r) r (car r)))
12878 (max (if (numberp r) r (cdr r))))
12879 (while (and (<= min max)
12880 (> all 0))
12881 (push max older)
12882 (setq all (1- all)
12883 max (1- max))))))))))
12884 (setq older (gnus-uncompress-range older))))
12885 (if (not older)
12886 (message "No old news.")
12887 (gnus-summary-insert-articles older)
12888 (gnus-summary-limit (gnus-sorted-nunion old older))))
12889 (gnus-summary-position-point)))
12891 (defun gnus-summary-insert-new-articles ()
12892 "Insert all new articles in this group."
12893 (interactive)
12894 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12895 (old-high gnus-newsgroup-highest)
12896 (nnmail-fetched-sources (list t))
12897 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12898 i new)
12899 (unless new-active
12900 (error "Couldn't fetch new data"))
12901 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12902 (setq i (cdr gnus-newsgroup-active)
12903 gnus-newsgroup-highest i)
12904 (while (> i old-high)
12905 (push i new)
12906 (decf i))
12907 (if (not new)
12908 (message "No gnus is bad news")
12909 (gnus-summary-insert-articles new)
12910 (setq gnus-newsgroup-unreads
12911 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12912 (gnus-summary-limit (gnus-sorted-nunion old new))))
12913 (gnus-summary-position-point))
12915 ;;; Bookmark support for Gnus.
12916 (declare-function bookmark-make-record-default
12917 "bookmark" (&optional no-file no-context posn))
12918 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12919 (declare-function bookmark-default-handler "bookmark" (bmk))
12920 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12921 (defvar bookmark-yank-point)
12922 (defvar bookmark-current-buffer)
12924 (defun gnus-summary-bookmark-make-record ()
12925 "Make a bookmark entry for a Gnus summary buffer."
12926 (let (pos buf)
12927 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12928 (save-restriction ; FIXME is it necessary to widen?
12929 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12930 (setq buf "art") ; We are recording bookmark from article buffer.
12931 (setq bookmark-yank-point (point))
12932 (setq bookmark-current-buffer (current-buffer))
12933 (gnus-article-show-summary)) ; Go back in summary buffer.
12934 ;; We are now recording bookmark from summary buffer.
12935 (unless buf (setq buf "sum"))
12936 (let* ((subject (elt (gnus-summary-article-header) 1))
12937 (grp (car gnus-article-current))
12938 (art (cdr gnus-article-current))
12939 (head (gnus-summary-article-header art))
12940 (id (mail-header-id head)))
12941 `(,subject
12942 ,@(condition-case nil
12943 (bookmark-make-record-default 'no-file 'no-context pos)
12944 (wrong-number-of-arguments
12945 (bookmark-make-record-default 'point-only)))
12946 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12947 (group . ,grp) (article . ,art)
12948 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12950 ;;;###autoload
12951 (defun gnus-summary-bookmark-jump (bookmark)
12952 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12953 BOOKMARK is a bookmark name or a bookmark record."
12954 (let ((group (bookmark-prop-get bookmark 'group))
12955 (article (bookmark-prop-get bookmark 'article))
12956 (id (bookmark-prop-get bookmark 'message-id))
12957 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12958 (gnus-fetch-group group (list article))
12959 (gnus-summary-insert-cached-articles)
12960 (gnus-summary-goto-article id nil 'force)
12961 ;; FIXME we have to wait article buffer is ready (only large buffer)
12962 ;; Is there a better solution to know that?
12963 ;; If we don't wait `bookmark-default-handler' will have no chance
12964 ;; to set position. However there is no error, just wrong pos.
12965 (sit-for 1)
12966 (when (string= buf "Gnus-art")
12967 (other-window 1))
12968 (bookmark-default-handler
12969 `(""
12970 (buffer . ,(current-buffer))
12971 . ,(bookmark-get-bookmark-record bookmark)))))
12973 (gnus-summary-make-all-marking-commands)
12975 (gnus-ems-redefine)
12977 (provide 'gnus-sum)
12979 (run-hooks 'gnus-sum-load-hook)
12981 ;; Local Variables:
12982 ;; coding: iso-8859-1
12983 ;; End:
12985 ;;; gnus-sum.el ends here