gnus-summary-select-article-buffer: Don't re-render existing article
[emacs.git] / lisp / gnus / gnus-sum.el
blobae13e7157d7aba97f9d53e444f0857b4a20cc3b5
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2017 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 (eval-when-compile (require 'cl))
29 (defvar tool-bar-mode)
30 (defvar gnus-tmp-header)
32 (require 'gnus)
33 (require 'gnus-group)
34 (require 'gnus-spec)
35 (require 'gnus-range)
36 (require 'gnus-int)
37 (require 'gnus-undo)
38 (require 'gnus-util)
39 (require 'gmm-utils)
40 (require 'mm-decode)
41 (require 'nnoo)
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
55 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
56 (autoload 'nnir-article-group "nnir" nil nil 'macro)
58 (defcustom gnus-kill-summary-on-exit t
59 "If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
65 (defcustom gnus-summary-next-group-on-exit t
66 "If non-nil, go to the next unread newsgroup on summary exit.
67 See `gnus-group-goto-unread'."
68 :link '(custom-manual "(gnus)Group Maneuvering")
69 :group 'gnus-summary-exit
70 :version "23.1" ;; No Gnus
71 :type 'boolean)
73 (defcustom gnus-summary-stop-at-end-of-message nil
74 "If non-nil, don't select the next message when using `SPC'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-maneuvering
77 :version "24.1"
78 :type 'boolean)
80 (defcustom gnus-fetch-old-headers nil
81 "Non-nil means that Gnus will try to build threads by grabbing old headers.
82 If an unread article in the group refers to an older, already
83 read (or just marked as read) article, the old article will not
84 normally be displayed in the Summary buffer. If this variable is
85 t, Gnus will attempt to grab the headers to the old articles, and
86 thereby build complete threads. If it has the value `some', all
87 old headers will be fetched but only enough headers to connect
88 otherwise loose threads will be displayed. This variable can
89 also be a number. In that case, no more than that number of old
90 headers will be fetched. If it has the value `invisible', all
91 old headers will be fetched, but none will be displayed.
93 The server has to support NOV for any of this to work.
95 This feature can seriously impact performance it ignores all
96 locally cached header entries. Setting it to t for groups for a
97 server that doesn't expire articles (such as news.gmane.org),
98 leads to very slow summary generation."
99 :group 'gnus-thread
100 :type '(choice (const :tag "off" nil)
101 (const :tag "on" t)
102 (const some)
103 (const invisible)
104 number
105 (sexp :menu-tag "other" t)))
107 (defcustom gnus-refer-thread-limit 500
108 "The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
109 If t, fetch all the available old headers."
110 :group 'gnus-thread
111 :type '(choice number
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-use-nnir nil
115 "Use nnir to search an entire server when referring threads. A
116 nil value will only search for thread-related articles in the
117 current group."
118 :version "24.1"
119 :group 'gnus-thread
120 :type 'boolean)
122 (defcustom gnus-summary-make-false-root 'adopt
123 "nil means that Gnus won't gather loose threads.
124 If the root of a thread has expired or been read in a previous
125 session, the information necessary to build a complete thread has been
126 lost. Instead of having many small sub-threads from this original thread
127 scattered all over the summary buffer, Gnus can gather them.
129 If non-nil, Gnus will try to gather all loose sub-threads from an
130 original thread into one large thread.
132 If this variable is non-nil, it should be one of `none', `adopt',
133 `dummy' or `empty'.
135 If this variable is `none', Gnus will not make a false root, but just
136 present the sub-threads after another.
137 If this variable is `dummy', Gnus will create a dummy root that will
138 have all the sub-threads as children.
139 If this variable is `adopt', Gnus will make one of the \"children\"
140 the parent and mark all the step-children as such.
141 If this variable is `empty', the \"children\" are printed with empty
142 subject fields. (Or rather, they will be printed with a string
143 given by the `gnus-summary-same-subject' variable.)"
144 :group 'gnus-thread
145 :type '(choice (const :tag "off" nil)
146 (const none)
147 (const dummy)
148 (const adopt)
149 (const empty)))
151 (defcustom gnus-summary-make-false-root-always nil
152 "Always make a false dummy root."
153 :version "22.1"
154 :group 'gnus-thread
155 :type 'boolean)
157 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
158 "A regexp to match subjects to be excluded from loose thread gathering.
159 As loose thread gathering is done on subjects only, that means that
160 there can be many false gatherings performed. By rooting out certain
161 common subjects, gathering might become saner."
162 :group 'gnus-thread
163 :type 'regexp)
165 (defcustom gnus-summary-gather-subject-limit nil
166 "Maximum length of subject comparisons when gathering loose threads.
167 Use nil to compare full subjects. Setting this variable to a low
168 number will help gather threads that have been corrupted by
169 newsreaders chopping off subject lines, but it might also mean that
170 unrelated articles that have subject that happen to begin with the
171 same few characters will be incorrectly gathered.
173 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
174 comparing subjects."
175 :group 'gnus-thread
176 :type '(choice (const :tag "off" nil)
177 (const fuzzy)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-simplify-subject-functions nil
181 "List of functions taking a string argument that simplify subjects.
182 The functions are applied recursively.
184 Useful functions to put in this list include:
185 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
186 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
187 :group 'gnus-thread
188 :type '(repeat function))
190 (defcustom gnus-simplify-ignored-prefixes nil
191 "Remove matches for this regexp from subject lines when simplifying fuzzily."
192 :group 'gnus-thread
193 :type '(choice (const :tag "off" nil)
194 regexp))
196 (defcustom gnus-build-sparse-threads nil
197 "If non-nil, fill in the gaps in threads.
198 If `some', only fill in the gaps that are needed to tie loose threads
199 together. If `more', fill in all leaf nodes that Gnus can find. If
200 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
201 :group 'gnus-thread
202 :type '(choice (const :tag "off" nil)
203 (const some)
204 (const more)
205 (sexp :menu-tag "all" t)))
207 (defcustom gnus-summary-thread-gathering-function
208 'gnus-gather-threads-by-subject
209 "Function used for gathering loose threads.
210 There are two pre-defined functions: `gnus-gather-threads-by-subject',
211 which only takes Subjects into consideration; and
212 `gnus-gather-threads-by-references', which compared the References
213 headers of the articles to find matches."
214 :group 'gnus-thread
215 :type '(radio (function-item gnus-gather-threads-by-subject)
216 (function-item gnus-gather-threads-by-references)
217 (function :tag "other")))
219 (defcustom gnus-summary-same-subject ""
220 "String indicating that the current article has the same subject as the previous.
221 This variable will only be used if the value of
222 `gnus-summary-make-false-root' is `empty'."
223 :group 'gnus-summary-format
224 :type 'string)
226 (defcustom gnus-summary-goto-unread nil
227 "If t, many commands will go to the next unread article.
228 This applies to marking commands as well as other commands that
229 \"naturally\" select the next article, like, for instance, `SPC' at
230 the end of an article.
232 If nil, the marking commands do NOT go to the next unread article
233 \(they go to the next article instead). If `never', commands that
234 usually go to the next unread article, will go to the next article,
235 whether it is read or not."
236 :version "24.1"
237 :group 'gnus-summary-marks
238 :link '(custom-manual "(gnus)Setting Marks")
239 :type '(choice (const :tag "off" nil)
240 (const never)
241 (sexp :menu-tag "on" t)))
243 (defcustom gnus-summary-default-score 0
244 "Default article score level.
245 All scores generated by the score files will be added to this score.
246 If this variable is nil, scoring will be disabled."
247 :group 'gnus-score-default
248 :type '(choice (const :tag "disable")
249 integer))
251 (defcustom gnus-summary-default-high-score 0
252 "Default threshold for a high scored article.
253 An article will be highlighted as high scored if its score is greater
254 than this score."
255 :version "22.1"
256 :group 'gnus-score-default
257 :type 'integer)
259 (defcustom gnus-summary-default-low-score 0
260 "Default threshold for a low scored article.
261 An article will be highlighted as low scored if its score is smaller
262 than this score."
263 :version "22.1"
264 :group 'gnus-score-default
265 :type 'integer)
267 (defcustom gnus-summary-zcore-fuzz 0
268 "Fuzziness factor for the zcore in the summary buffer.
269 Articles with scores closer than this to `gnus-summary-default-score'
270 will not be marked."
271 :group 'gnus-summary-format
272 :type 'integer)
274 (defcustom gnus-simplify-subject-fuzzy-regexp nil
275 "Strings to be removed when doing fuzzy matches.
276 This can either be a regular expression or list of regular expressions
277 that will be removed from subject strings if fuzzy subject
278 simplification is selected."
279 :group 'gnus-thread
280 :type '(repeat regexp))
282 (defcustom gnus-show-threads t
283 "If non-nil, display threads in summary mode."
284 :group 'gnus-thread
285 :type 'boolean)
287 (defcustom gnus-thread-hide-subtree nil
288 "If non-nil, hide all threads initially.
289 This can be a predicate specifier which says which threads to hide.
290 If threads are hidden, you have to run the command
291 `gnus-summary-show-thread' by hand or select an article."
292 :group 'gnus-thread
293 :type '(radio (sexp :format "Non-nil\n"
294 :match (lambda (widget value)
295 (not (or (consp value) (functionp value))))
296 :value t)
297 (const nil)
298 (sexp :tag "Predicate specifier")))
300 (defcustom gnus-thread-hide-killed t
301 "If non-nil, hide killed threads automatically."
302 :group 'gnus-thread
303 :type 'boolean)
305 (defcustom gnus-thread-ignore-subject t
306 "If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
307 If nil, articles that have different subjects from their parents will
308 start separate threads."
309 :group 'gnus-thread
310 :type 'boolean)
312 (defcustom gnus-thread-operation-ignore-subject t
313 "If non-nil, subjects will be ignored when doing thread commands.
314 This affects commands like `gnus-summary-kill-thread' and
315 `gnus-summary-lower-thread'.
317 If this variable is nil, articles in the same thread with different
318 subjects will not be included in the operation in question. If this
319 variable is `fuzzy', only articles that have subjects that are fuzzily
320 equal will be included."
321 :group 'gnus-thread
322 :type '(choice (const :tag "off" nil)
323 (const fuzzy)
324 (sexp :tag "on" t)))
326 (defcustom gnus-thread-indent-level 4
327 "Number that says how much each sub-thread should be indented."
328 :group 'gnus-thread
329 :type 'integer)
331 (defcustom gnus-auto-extend-newsgroup t
332 "If non-nil, extend newsgroup forward and backward when requested."
333 :group 'gnus-summary-choose
334 :type 'boolean)
336 (defcustom gnus-auto-select-first t
337 "If non-nil, select an article on group entry.
338 An article is selected automatically when entering a group
339 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
340 `gnus-summary-catchup-and-goto-next-group'.
342 Which article is selected is controlled by the variable
343 `gnus-auto-select-subject'.
345 If you want to prevent automatic selection of articles in some
346 newsgroups, set the variable to nil in `gnus-select-group-hook'."
347 ;; Commands include...
348 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
349 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
350 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
351 :group 'gnus-group-select
352 :type '(choice (const :tag "none" nil)
353 (sexp :menu-tag "first" t)))
355 (defcustom gnus-auto-select-subject 'unseen-or-unread
356 "Says what subject to place under point when entering a group.
358 This variable can either be the symbols `first' (place point on the
359 first subject), `unread' (place point on the subject line of the first
360 unread article), `best' (place point on the subject line of the
361 highest-scored article), `unseen' (place point on the subject line of
362 the first unseen article), `unseen-or-unread' (place point on the subject
363 line of the first unseen article or, if all articles have been seen, on the
364 subject line of the first unread article), or a function to be called to
365 place point on some subject line."
366 :version "24.1"
367 :group 'gnus-group-select
368 :type '(choice (const best)
369 (const unread)
370 (const first)
371 (const unseen)
372 (const unseen-or-unread)
373 (function :tag "Function to call")))
375 (defcustom gnus-auto-select-next t
376 "If non-nil, offer to go to the next group from the end of the previous.
377 If the value is t and the next newsgroup is empty, Gnus will exit
378 summary mode and go back to group mode. If the value is neither nil
379 nor t, Gnus will select the following unread newsgroup. In
380 particular, if the value is the symbol `quietly', the next unread
381 newsgroup will be selected without any confirmation, and if it is
382 `almost-quietly', the next group will be selected without any
383 confirmation if you are located on the last article in the group.
384 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
385 will go to the next group without confirmation."
386 :group 'gnus-summary-maneuvering
387 :type '(choice (const :tag "off" nil)
388 (const quietly)
389 (const almost-quietly)
390 (const slightly-quietly)
391 (sexp :menu-tag "on" t)))
393 (defcustom gnus-auto-select-same nil
394 "If non-nil, select the next article with the same subject.
395 If there are no more articles with the same subject, go to
396 the first unread article."
397 :group 'gnus-summary-maneuvering
398 :type 'boolean)
400 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
401 "What article should be selected after exiting an ephemeral group.
402 Valid values include:
404 `next'
405 Select the next article.
406 `next-unread'
407 Select the next unread article.
408 `next-noselect'
409 Move the cursor to the next article. This is the default.
410 `next-unread-noselect'
411 Move the cursor to the next unread article.
413 If it has any other value or there is no next (unread) article, the
414 article selected before entering to the ephemeral group will appear."
415 :version "23.1" ;; No Gnus
416 :group 'gnus-summary-maneuvering
417 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
418 (const next) (const next-unread)
419 (const next-noselect) (const next-unread-noselect)
420 (sexp :tag "other" :value nil)))
422 (defcustom gnus-auto-goto-ignores 'unfetched
423 "Says how to handle unfetched articles when maneuvering.
425 This variable can either be the symbols nil (maneuver to any
426 article), `undownloaded' (maneuvering while unplugged ignores articles
427 that have not been fetched), `always-undownloaded' (maneuvering always
428 ignores articles that have not been fetched), `unfetched' (maneuvering
429 ignores articles whose headers have not been fetched).
431 NOTE: The list of unfetched articles will always be nil when plugged
432 and, when unplugged, a subset of the undownloaded article list."
433 :version "22.1"
434 :group 'gnus-summary-maneuvering
435 :type '(choice (const :tag "None" nil)
436 (const :tag "Undownloaded when unplugged" undownloaded)
437 (const :tag "Undownloaded" always-undownloaded)
438 (const :tag "Unfetched" unfetched)))
440 (defcustom gnus-summary-check-current nil
441 "If non-nil, consider the current article when moving.
442 The \"unread\" movement commands will stay on the same line if the
443 current article is unread."
444 :group 'gnus-summary-maneuvering
445 :type 'boolean)
447 (defcustom gnus-auto-center-summary
448 (max (or (bound-and-true-p scroll-margin) 0) 2)
449 "If non-nil, always center the current summary buffer.
450 In particular, if `vertical' do only vertical recentering. If non-nil
451 and non-`vertical', do both horizontal and vertical recentering."
452 :group 'gnus-summary-maneuvering
453 :type '(choice (const :tag "none" nil)
454 (const vertical)
455 (integer :tag "height")
456 (sexp :menu-tag "both" t)))
458 (defcustom gnus-auto-center-group t
459 "If non-nil, always center the group buffer."
460 :group 'gnus-summary-maneuvering
461 :type 'boolean)
463 (defcustom gnus-show-all-headers nil
464 "If non-nil, don't hide any headers."
465 :group 'gnus-article-hiding
466 :group 'gnus-article-headers
467 :type 'boolean)
469 (defcustom gnus-summary-ignore-duplicates nil
470 "If non-nil, ignore articles with identical Message-ID headers."
471 :group 'gnus-summary
472 :type 'boolean)
474 (defcustom gnus-single-article-buffer nil
475 "If non-nil, display all articles in the same buffer.
476 If nil, each group will get its own article buffer."
477 :version "24.1"
478 :group 'gnus-article-various
479 :type 'boolean)
481 (defcustom gnus-widen-article-window nil
482 "If non-nil, selecting the article buffer will display only the article buffer."
483 :version "24.1"
484 :group 'gnus-article-various
485 :type 'boolean)
487 (defcustom gnus-break-pages t
488 "If non-nil, do page breaking on articles.
489 The page delimiter is specified by the `gnus-page-delimiter'
490 variable."
491 :group 'gnus-article-various
492 :type 'boolean)
494 (defcustom gnus-move-split-methods nil
495 "Variable used to suggest where articles are to be moved to.
496 It uses the same syntax as the `gnus-split-methods' variable.
497 However, whereas `gnus-split-methods' specifies file names as targets,
498 this variable specifies group names."
499 :group 'gnus-summary-mail
500 :type '(repeat (choice (list :value (fun) function)
501 (cons :value ("" "") regexp (repeat string))
502 (sexp :value nil))))
504 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
505 "Function used to compute default prefix for article move/copy/etc prompts.
506 The function should take one argument, a group name, and return a
507 string with the suggested prefix."
508 :group 'gnus-summary-mail
509 :type 'function)
511 ;; FIXME: Although the custom type is `character' for the following variables,
512 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
514 (defcustom gnus-unread-mark ? ;Whitespace
515 "Mark used for unread articles."
516 :group 'gnus-summary-marks
517 :type 'character)
519 (defcustom gnus-ticked-mark ?!
520 "Mark used for ticked articles."
521 :group 'gnus-summary-marks
522 :type 'character)
524 (defcustom gnus-dormant-mark ??
525 "Mark used for dormant articles."
526 :group 'gnus-summary-marks
527 :type 'character)
529 (defcustom gnus-del-mark ?r
530 "Mark used for del'd articles."
531 :group 'gnus-summary-marks
532 :type 'character)
534 (defcustom gnus-read-mark ?R
535 "Mark used for read articles."
536 :group 'gnus-summary-marks
537 :type 'character)
539 (defcustom gnus-expirable-mark ?E
540 "Mark used for expirable articles."
541 :group 'gnus-summary-marks
542 :type 'character)
544 (defcustom gnus-killed-mark ?K
545 "Mark used for killed articles."
546 :group 'gnus-summary-marks
547 :type 'character)
549 (defcustom gnus-spam-mark ?$
550 "Mark used for spam articles."
551 :version "22.1"
552 :group 'gnus-summary-marks
553 :type 'character)
555 (defcustom gnus-kill-file-mark ?X
556 "Mark used for articles killed by kill files."
557 :group 'gnus-summary-marks
558 :type 'character)
560 (defcustom gnus-low-score-mark ?Y
561 "Mark used for articles with a low score."
562 :group 'gnus-summary-marks
563 :type 'character)
565 (defcustom gnus-catchup-mark ?C
566 "Mark used for articles that are caught up."
567 :group 'gnus-summary-marks
568 :type 'character)
570 (defcustom gnus-replied-mark ?A
571 "Mark used for articles that have been replied to."
572 :group 'gnus-summary-marks
573 :type 'character)
575 (defcustom gnus-forwarded-mark ?F
576 "Mark used for articles that have been forwarded."
577 :version "22.1"
578 :group 'gnus-summary-marks
579 :type 'character)
581 (defcustom gnus-recent-mark ?N
582 "Mark used for articles that are recent."
583 :version "22.1"
584 :group 'gnus-summary-marks
585 :type 'character)
587 (defcustom gnus-cached-mark ?*
588 "Mark used for articles that are in the cache."
589 :group 'gnus-summary-marks
590 :type 'character)
592 (defcustom gnus-saved-mark ?S
593 "Mark used for articles that have been saved."
594 :group 'gnus-summary-marks
595 :type 'character)
597 (defcustom gnus-unseen-mark ?.
598 "Mark used for articles that haven't been seen."
599 :version "22.1"
600 :group 'gnus-summary-marks
601 :type 'character)
603 (defcustom gnus-no-mark ? ;Whitespace
604 "Mark used for articles that have no other secondary mark."
605 :version "22.1"
606 :group 'gnus-summary-marks
607 :type 'character)
609 (defcustom gnus-ancient-mark ?O
610 "Mark used for ancient articles."
611 :group 'gnus-summary-marks
612 :type 'character)
614 (defcustom gnus-sparse-mark ?Q
615 "Mark used for sparsely reffed articles."
616 :group 'gnus-summary-marks
617 :type 'character)
619 (defcustom gnus-canceled-mark ?G
620 "Mark used for canceled articles."
621 :group 'gnus-summary-marks
622 :type 'character)
624 (defcustom gnus-duplicate-mark ?M
625 "Mark used for duplicate articles."
626 :group 'gnus-summary-marks
627 :type 'character)
629 (defcustom gnus-undownloaded-mark ?-
630 "Mark used for articles that weren't downloaded."
631 :version "22.1"
632 :group 'gnus-summary-marks
633 :type 'character)
635 (defcustom gnus-downloaded-mark ?+
636 "Mark used for articles that were downloaded."
637 :group 'gnus-summary-marks
638 :type 'character)
640 (defcustom gnus-downloadable-mark ?%
641 "Mark used for articles that are to be downloaded."
642 :group 'gnus-summary-marks
643 :type 'character)
645 (defcustom gnus-unsendable-mark ?=
646 "Mark used for articles that won't be sent."
647 :group 'gnus-summary-marks
648 :type 'character)
650 (defcustom gnus-score-over-mark ?+
651 "Score mark used for articles with high scores."
652 :group 'gnus-summary-marks
653 :type 'character)
655 (defcustom gnus-score-below-mark ?-
656 "Score mark used for articles with low scores."
657 :group 'gnus-summary-marks
658 :type 'character)
660 (defcustom gnus-empty-thread-mark ? ;Whitespace
661 "There is no thread under the article."
662 :group 'gnus-summary-marks
663 :type 'character)
665 (defcustom gnus-not-empty-thread-mark ?=
666 "There is a thread under the article."
667 :group 'gnus-summary-marks
668 :type 'character)
670 (defcustom gnus-view-pseudo-asynchronously nil
671 "If non-nil, Gnus will view pseudo-articles asynchronously."
672 :group 'gnus-extract-view
673 :type 'boolean)
675 (defcustom gnus-auto-expirable-marks
676 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
677 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
678 gnus-duplicate-mark)
679 "The list of marks converted into expiration if a group is auto-expirable."
680 :version "24.1"
681 :group 'gnus-summary
682 :type '(repeat character))
684 (defcustom gnus-inhibit-user-auto-expire t
685 "If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
686 :version "21.1"
687 :group 'gnus-summary
688 :type 'boolean)
690 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
691 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
692 If nil, the expirable marks will be unchanged except that the marks
693 will be removed when copying or moving articles to a group that has
694 not turned auto-expire on. If non-nil, articles that have been read
695 will be marked as expirable when being copied or moved to a group in
696 which auto-expire is turned on."
697 :version "23.2"
698 :type 'boolean
699 :group 'gnus-summary-marks)
701 (defcustom gnus-view-pseudos nil
702 "If `automatic', pseudo-articles will be viewed automatically.
703 If `not-confirm', pseudos will be viewed automatically, and the user
704 will not be asked to confirm the command."
705 :group 'gnus-extract-view
706 :type '(choice (const :tag "off" nil)
707 (const automatic)
708 (const not-confirm)))
710 (defcustom gnus-view-pseudos-separately t
711 "If non-nil, one pseudo-article will be created for each file to be viewed.
712 If nil, all files that use the same viewing command will be given as a
713 list of parameters to that command."
714 :group 'gnus-extract-view
715 :type 'boolean)
717 (defcustom gnus-insert-pseudo-articles t
718 "If non-nil, insert pseudo-articles when decoding articles."
719 :group 'gnus-extract-view
720 :type 'boolean)
722 (defcustom gnus-summary-dummy-line-format
723 " %(: :%) %S\n"
724 "The format specification for the dummy roots in the summary buffer.
725 It works along the same lines as a normal formatting string,
726 with some simple extensions.
728 %S The subject
730 General format specifiers can also be used.
731 See `(gnus)Formatting Variables'."
732 :link '(custom-manual "(gnus)Formatting Variables")
733 :group 'gnus-threading
734 :type 'string)
736 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
737 "The format specification for the summary mode line.
738 It works along the same lines as a normal formatting string,
739 with some simple extensions:
741 %G Group name
742 %p Unprefixed group name
743 %A Current article number
744 %z Current article score
745 %V Gnus version
746 %U Number of unread articles in the group
747 %e Number of unselected articles in the group
748 %Z A string with unread/unselected article counts
749 %g Shortish group name
750 %S Subject of the current article
751 %u User-defined spec
752 %s Current score file name
753 %d Number of dormant articles
754 %r Number of articles that have been marked as read in this session
755 %E Number of articles expunged by the score files"
756 :group 'gnus-summary-format
757 :type 'string)
759 (defcustom gnus-list-identifiers nil
760 "Regexp that matches list identifiers to be removed from subject.
761 This can also be a list of regexps."
762 :version "21.1"
763 :group 'gnus-summary-format
764 :group 'gnus-article-hiding
765 :type '(choice (const :tag "none" nil)
766 (regexp :value ".*")
767 (repeat :value (".*") regexp)))
769 (defcustom gnus-summary-mark-below 0
770 "Mark all articles with a score below this variable as read.
771 This variable is local to each summary buffer and usually set by the
772 score file."
773 :group 'gnus-score-default
774 :type 'integer)
776 (defun gnus-widget-reversible-match (widget value)
777 "Ignoring WIDGET, convert VALUE to internal form.
778 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
779 ;; (debug value)
780 (or (symbolp value)
781 (and (listp value)
782 (eq (length value) 2)
783 (eq (nth 0 value) 'not)
784 (symbolp (nth 1 value)))))
786 (defun gnus-widget-reversible-to-internal (widget value)
787 "Ignoring WIDGET, convert VALUE to internal form.
788 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
789 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
790 ;; (debug value)
791 (if (atom value)
792 (list value nil)
793 (list (nth 1 value) t)))
795 (defun gnus-widget-reversible-to-external (widget value)
796 "Ignoring WIDGET, convert VALUE to external form.
797 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
798 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
799 ;; (debug value)
800 (if (nth 1 value)
801 (list 'not (nth 0 value))
802 (nth 0 value)))
804 (define-widget 'gnus-widget-reversible 'group
805 "A `group' that convert values."
806 :match 'gnus-widget-reversible-match
807 :value-to-internal 'gnus-widget-reversible-to-internal
808 :value-to-external 'gnus-widget-reversible-to-external)
810 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
811 "List of functions used for sorting articles in the summary buffer.
813 Each function takes two articles and returns non-nil if the first
814 article should be sorted before the other. If you use more than one
815 function, the primary sort function should be the last. You should
816 probably always include `gnus-article-sort-by-number' in the list of
817 sorting functions -- preferably first. Also note that sorting by date
818 is often much slower than sorting by number, and the sorting order is
819 very similar. (Sorting by date means sorting by the time the message
820 was sent, sorting by number means sorting by arrival time.)
822 Each item can also be a list `(not F)' where F is a function;
823 this reverses the sort order.
825 Ready-made functions include `gnus-article-sort-by-number',
826 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
827 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
828 and `gnus-article-sort-by-score'.
830 When threading is turned on, the variable `gnus-thread-sort-functions'
831 controls how articles are sorted."
832 :group 'gnus-summary-sort
833 :type '(repeat (gnus-widget-reversible
834 (choice (function-item gnus-article-sort-by-number)
835 (function-item gnus-article-sort-by-author)
836 (function-item gnus-article-sort-by-subject)
837 (function-item gnus-article-sort-by-date)
838 (function-item gnus-article-sort-by-score)
839 (function-item gnus-article-sort-by-random)
840 (function :tag "other"))
841 (boolean :tag "Reverse order"))))
843 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
844 "List of functions used for sorting threads in the summary buffer.
845 By default, threads are sorted by article number.
847 Each function takes two threads and returns non-nil if the first
848 thread should be sorted before the other. If you use more than one
849 function, the primary sort function should be the last. You should
850 probably always include `gnus-thread-sort-by-number' in the list of
851 sorting functions -- preferably first. Also note that sorting by date
852 is often much slower than sorting by number, and the sorting order is
853 very similar. (Sorting by date means sorting by the time the message
854 was sent, sorting by number means sorting by arrival time.)
856 Each list item can also be a list `(not F)' where F is a
857 function; this specifies reversed sort order.
859 Ready-made functions include `gnus-thread-sort-by-number',
860 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
861 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
862 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
863 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
864 and `gnus-thread-sort-by-total-score' (see
865 `gnus-thread-score-function').
867 When threading is turned off, the variable
868 `gnus-article-sort-functions' controls how articles are sorted.
870 By default, threads and their subthreads are sorted according to
871 the value of this variable. To use a different sorting order for
872 subthreads, customize `gnus-subthread-sort-functions'."
873 :group 'gnus-summary-sort
874 :type '(repeat
875 (gnus-widget-reversible
876 (choice (function-item gnus-thread-sort-by-number)
877 (function-item gnus-thread-sort-by-author)
878 (function-item gnus-thread-sort-by-recipient)
879 (function-item gnus-thread-sort-by-subject)
880 (function-item gnus-thread-sort-by-date)
881 (function-item gnus-thread-sort-by-score)
882 (function-item gnus-thread-sort-by-most-recent-number)
883 (function-item gnus-thread-sort-by-most-recent-date)
884 (function-item gnus-thread-sort-by-random)
885 (function-item gnus-thread-sort-by-total-score)
886 (function :tag "other"))
887 (boolean :tag "Reverse order"))))
889 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
890 "List of functions used for sorting subthreads in the summary buffer.
891 By default, subthreads are sorted the same as threads, i.e.,
892 according to the value of `gnus-thread-sort-functions'."
893 :version "24.4"
894 :group 'gnus-summary-sort
895 :type '(choice
896 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
897 (repeat
898 (gnus-widget-reversible
899 (choice (function-item gnus-thread-sort-by-number)
900 (function-item gnus-thread-sort-by-author)
901 (function-item gnus-thread-sort-by-recipient)
902 (function-item gnus-thread-sort-by-subject)
903 (function-item gnus-thread-sort-by-date)
904 (function-item gnus-thread-sort-by-score)
905 (function-item gnus-thread-sort-by-most-recent-number)
906 (function-item gnus-thread-sort-by-most-recent-date)
907 (function-item gnus-thread-sort-by-random)
908 (function-item gnus-thread-sort-by-total-score)
909 (function :tag "other"))
910 (boolean :tag "Reverse order")))))
912 (defcustom gnus-thread-score-function '+
913 "Function used for calculating the total score of a thread.
915 The function is called with the scores of the article and each
916 subthread and should then return the score of the thread.
918 Some functions you can use are `+', `max', or `min'."
919 :group 'gnus-summary-sort
920 :type 'function)
922 (defcustom gnus-summary-expunge-below nil
923 "All articles that have a score less than this variable will be expunged.
924 This variable is local to the summary buffers."
925 :group 'gnus-score-default
926 :type '(choice (const :tag "off" nil)
927 integer))
929 (defcustom gnus-thread-expunge-below nil
930 "All threads that have a total score less than this variable will be expunged.
931 See `gnus-thread-score-function' for en explanation of what a
932 \"thread score\" is.
934 This variable is local to the summary buffers."
935 :group 'gnus-threading
936 :group 'gnus-score-default
937 :type '(choice (const :tag "off" nil)
938 integer))
940 (defcustom gnus-summary-mode-hook nil
941 "A hook for Gnus summary mode.
942 This hook is run before any variables are set in the summary buffer."
943 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
944 :group 'gnus-summary-various
945 :type 'hook)
947 (defcustom gnus-summary-menu-hook nil
948 "Hook run after the creation of the summary mode menu."
949 :group 'gnus-summary-visual
950 :type 'hook)
952 (defcustom gnus-summary-exit-hook nil
953 "A hook called on exit from the summary buffer.
954 It will be called with point in the group buffer."
955 :group 'gnus-summary-exit
956 :type 'hook)
958 (defcustom gnus-summary-prepare-hook nil
959 "A hook called after the summary buffer has been generated.
960 If you want to modify the summary buffer, you can use this hook."
961 :group 'gnus-summary-various
962 :type 'hook)
964 (defcustom gnus-summary-prepared-hook nil
965 "A hook called as the last thing after the summary buffer has been generated."
966 :group 'gnus-summary-various
967 :type 'hook)
969 (defcustom gnus-summary-generate-hook nil
970 "A hook run just before generating the summary buffer.
971 This hook is commonly used to customize threading variables and the
972 like."
973 :group 'gnus-summary-various
974 :type 'hook)
976 (defcustom gnus-select-group-hook nil
977 "A hook called when a newsgroup is selected.
979 If you'd like to simplify subjects like the
980 `gnus-summary-next-same-subject' command does, you can use the
981 following hook:
983 (add-hook gnus-select-group-hook
984 (lambda ()
985 (mapcar (lambda (header)
986 (mail-header-set-subject
987 header
988 (gnus-simplify-subject
989 (mail-header-subject header) \\='re-only)))
990 gnus-newsgroup-headers)))"
991 :group 'gnus-group-select
992 :type 'hook)
994 (defcustom gnus-select-article-hook nil
995 "A hook called when an article is selected."
996 :group 'gnus-summary-choose
997 :options '(gnus-agent-fetch-selected-article)
998 :type 'hook)
1000 (defcustom gnus-visual-mark-article-hook
1001 (list 'gnus-highlight-selected-summary)
1002 "Hook run after selecting an article in the summary buffer.
1003 It is meant to be used for highlighting the article in some way. It
1004 is not run if `gnus-visual' is nil."
1005 :group 'gnus-summary-visual
1006 :type 'hook)
1008 (defcustom gnus-parse-headers-hook nil
1009 "A hook called before parsing the headers."
1010 :group 'gnus-various
1011 :type 'hook)
1013 (defcustom gnus-exit-group-hook nil
1014 "A hook called when exiting summary mode.
1015 This hook is not called from the non-updating exit commands like `Q'."
1016 :group 'gnus-various
1017 :type 'hook)
1019 (defcustom gnus-summary-update-hook nil
1020 "A hook called when a summary line is changed.
1021 The hook will not be called if `gnus-visual' is nil.
1023 The default function `gnus-summary-highlight-line' will
1024 highlight the line according to the `gnus-summary-highlight'
1025 variable."
1026 :group 'gnus-summary-visual
1027 :type 'hook)
1029 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1030 "A hook called when an article is selected for the first time.
1031 The hook is intended to mark an article as read (or unread)
1032 automatically when it is selected."
1033 :group 'gnus-summary-choose
1034 :type 'hook)
1036 (defcustom gnus-group-no-more-groups-hook nil
1037 "A hook run when returning to group mode having no more (unread) groups."
1038 :group 'gnus-group-select
1039 :type 'hook)
1041 (defcustom gnus-ps-print-hook nil
1042 "A hook run before ps-printing something from Gnus."
1043 :group 'gnus-summary
1044 :type 'hook)
1046 (defcustom gnus-summary-article-move-hook nil
1047 "A hook called after an article is moved, copied, respooled, or crossposted."
1048 :version "22.1"
1049 :group 'gnus-summary
1050 :type 'hook)
1052 (defcustom gnus-summary-article-delete-hook nil
1053 "A hook called after an article is deleted."
1054 :version "22.1"
1055 :group 'gnus-summary
1056 :type 'hook)
1058 (defcustom gnus-summary-article-expire-hook nil
1059 "A hook called after an article is expired."
1060 :version "22.1"
1061 :group 'gnus-summary
1062 :type 'hook)
1064 (defcustom gnus-summary-display-arrow (display-graphic-p)
1065 "If non-nil, display an arrow highlighting the current article."
1066 :version "22.1"
1067 :group 'gnus-summary
1068 :type 'boolean)
1070 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1071 "Face used for highlighting the current article in the summary buffer."
1072 :group 'gnus-summary-visual
1073 :type 'face)
1075 (defvar gnus-tmp-downloaded nil)
1077 (defcustom gnus-summary-highlight
1078 '(((eq mark gnus-canceled-mark)
1079 . gnus-summary-cancelled)
1080 ((and uncached (> score default-high))
1081 . gnus-summary-high-undownloaded)
1082 ((and uncached (< score default-low))
1083 . gnus-summary-low-undownloaded)
1084 (uncached
1085 . gnus-summary-normal-undownloaded)
1086 ((and (> score default-high)
1087 (or (eq mark gnus-dormant-mark)
1088 (eq mark gnus-ticked-mark)))
1089 . gnus-summary-high-ticked)
1090 ((and (< score default-low)
1091 (or (eq mark gnus-dormant-mark)
1092 (eq mark gnus-ticked-mark)))
1093 . gnus-summary-low-ticked)
1094 ((or (eq mark gnus-dormant-mark)
1095 (eq mark gnus-ticked-mark))
1096 . gnus-summary-normal-ticked)
1097 ((and (> score default-high) (eq mark gnus-ancient-mark))
1098 . gnus-summary-high-ancient)
1099 ((and (< score default-low) (eq mark gnus-ancient-mark))
1100 . gnus-summary-low-ancient)
1101 ((eq mark gnus-ancient-mark)
1102 . gnus-summary-normal-ancient)
1103 ((and (> score default-high) (eq mark gnus-unread-mark))
1104 . gnus-summary-high-unread)
1105 ((and (< score default-low) (eq mark gnus-unread-mark))
1106 . gnus-summary-low-unread)
1107 ((eq mark gnus-unread-mark)
1108 . gnus-summary-normal-unread)
1109 ((> score default-high)
1110 . gnus-summary-high-read)
1111 ((< score default-low)
1112 . gnus-summary-low-read)
1114 . gnus-summary-normal-read))
1115 "Controls the highlighting of summary buffer lines.
1117 A list of (FORM . FACE) pairs. When deciding how a particular
1118 summary line should be displayed, each form is evaluated. The content
1119 of the face field after the first true form is used. You can change
1120 how those summary lines are displayed, by editing the face field.
1122 You can use the following variables in the FORM field.
1124 score: The article's score.
1125 default: The default article score.
1126 default-high: The default score for high scored articles.
1127 default-low: The default score for low scored articles.
1128 mark: The article's mark.
1129 uncached: Non-nil if the article is uncached."
1130 :group 'gnus-summary-visual
1131 :type '(repeat (cons (sexp :tag "Form" nil)
1132 face)))
1133 (put 'gnus-summary-highlight 'risky-local-variable t)
1135 (defcustom gnus-alter-header-function nil
1136 "Function called to allow alteration of article header structures.
1137 The function is called with one parameter, the article header vector,
1138 which it may alter in any way."
1139 :type '(choice (const :tag "None" nil)
1140 function)
1141 :group 'gnus-summary)
1143 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1144 "Function used to decode a string with encoded words.")
1146 (defvar gnus-decode-encoded-address-function
1147 'mail-decode-encoded-address-string
1148 "Function used to decode addresses with encoded words.")
1150 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1151 "Extra headers to parse."
1152 :version "25.1"
1153 :group 'gnus-summary
1154 :type '(repeat symbol))
1156 (defcustom gnus-ignored-from-addresses
1157 (and user-mail-address
1158 (not (string= user-mail-address ""))
1159 (regexp-quote user-mail-address))
1160 "From headers that may be suppressed in favor of To headers.
1161 This can be a regexp, a list of regexps or a function.
1163 If a function, an email string is passed as the argument."
1164 :version "21.1"
1165 :group 'gnus-summary
1166 :type '(choice regexp
1167 (repeat :tag "Regexp List" regexp)
1168 function))
1170 (defsubst gnus-ignored-from-addresses ()
1171 (cond ((functionp gnus-ignored-from-addresses)
1172 gnus-ignored-from-addresses)
1173 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1175 (defcustom gnus-summary-to-prefix "-> "
1176 "String prefixed to the To field in the summary line when
1177 using `gnus-ignored-from-addresses'."
1178 :version "22.1"
1179 :group 'gnus-summary
1180 :type 'string)
1182 (defcustom gnus-summary-newsgroup-prefix "=> "
1183 "String prefixed to the Newsgroup field in the summary
1184 line when using the option `gnus-ignored-from-addresses'."
1185 :version "22.1"
1186 :group 'gnus-summary
1187 :type 'string)
1189 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1190 "List of charsets that should be ignored.
1191 When these charsets are used in the \"charset\" parameter, the
1192 default charset will be used instead."
1193 :version "21.1"
1194 :type '(repeat symbol)
1195 :group 'gnus-charset)
1197 (defcustom gnus-newsgroup-maximum-articles nil
1198 "The maximum number of articles a newsgroup.
1199 If this is a number, old articles in a newsgroup exceeding this number
1200 are silently ignored. If it is nil, no article is ignored. Note that
1201 setting this variable to a number might prevent you from reading very
1202 old articles."
1203 :group 'gnus-group-select
1204 :version "22.2"
1205 :type '(choice (const :tag "No limit" nil)
1206 integer))
1208 (gnus-define-group-parameter
1209 ignored-charsets
1210 :type list
1211 :function-document
1212 "Return the ignored charsets of GROUP."
1213 :variable gnus-group-ignored-charsets-alist
1214 :variable-default
1215 '(("alt\\.chinese\\.text" iso-8859-1))
1216 :variable-document
1217 "Alist of regexps (to match group names) and charsets that should be ignored.
1218 When these charsets are used in the \"charset\" parameter, the
1219 default charset will be used instead."
1220 :variable-group gnus-charset
1221 :variable-type '(repeat (cons (regexp :tag "Group")
1222 (repeat symbol)))
1223 :parameter-type '(choice :tag "Ignored charsets"
1224 :value nil
1225 (repeat (symbol)))
1226 :parameter-document "\
1227 List of charsets that should be ignored.
1229 When these charsets are used in the \"charset\" parameter, the
1230 default charset will be used instead.")
1232 (defcustom gnus-group-highlight-words-alist nil
1233 "Alist of group regexps and highlight regexps.
1234 This variable uses the same syntax as `gnus-emphasis-alist'."
1235 :version "21.1"
1236 :type '(repeat (cons (regexp :tag "Group")
1237 (repeat (list (regexp :tag "Highlight regexp")
1238 (number :tag "Group for entire word" 0)
1239 (number :tag "Group for displayed part" 0)
1240 (symbol :tag "Face"
1241 gnus-emphasis-highlight-words)))))
1242 :group 'gnus-summary-visual)
1244 (defcustom gnus-summary-show-article-charset-alist
1246 "Alist of number and charset.
1247 The article will be shown with the charset corresponding to the
1248 numbered argument.
1249 For example: ((1 . cn-gb-2312) (2 . big5))."
1250 :version "21.1"
1251 :type '(repeat (cons (number :tag "Argument" 1)
1252 (symbol :tag "Charset")))
1253 :group 'gnus-charset)
1255 (defcustom gnus-preserve-marks t
1256 "Whether marks are preserved when moving, copying and respooling messages."
1257 :version "21.1"
1258 :type 'boolean
1259 :group 'gnus-summary-marks)
1261 (defcustom gnus-alter-articles-to-read-function nil
1262 "Function to be called to alter the list of articles to be selected."
1263 :type '(choice (const nil) function)
1264 :group 'gnus-summary)
1266 (defcustom gnus-orphan-score nil
1267 "All orphans get this score added. Set in the score file."
1268 :group 'gnus-score-default
1269 :type '(choice (const nil)
1270 integer))
1272 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1273 "A regexp to match MIME parts when saving multiple parts of a
1274 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1275 This regexp will be used by default when prompting the user for which
1276 type of files to save."
1277 :group 'gnus-summary
1278 :type 'regexp)
1280 (defcustom gnus-read-all-available-headers nil
1281 "Whether Gnus should parse all headers made available to it.
1282 This is mostly relevant for slow back ends where the user may
1283 wish to widen the summary buffer to include all headers
1284 that were fetched."
1285 :version "22.1"
1286 :group 'gnus-summary
1287 :type '(choice boolean regexp))
1289 (defcustom gnus-summary-pipe-output-default-command nil
1290 "Command (and optional arguments) used to pipe article to subprocess.
1291 This will be used as the default command if it is non-nil. The value
1292 will be updated if you modify it when executing the command
1293 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1294 :version "23.1" ;; No Gnus
1295 :group 'gnus-summary
1296 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1298 (defcustom gnus-summary-muttprint-program "muttprint"
1299 "Command (and optional arguments) used to run Muttprint.
1300 The value will be updated if you modify it when executing the command
1301 `gnus-summary-muttprint'."
1302 :version "22.1"
1303 :group 'gnus-summary
1304 :type 'string)
1306 (defcustom gnus-article-loose-mime t
1307 "If non-nil, don't require MIME-Version header.
1308 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1309 supply the MIME-Version header or deliberately strip it from the mail.
1310 If non-nil (the default), Gnus will treat some articles as MIME
1311 even if the MIME-Version header is missing."
1312 :version "22.1"
1313 :type 'boolean
1314 :group 'gnus-article-mime)
1316 (defcustom gnus-article-emulate-mime t
1317 "If non-nil, use MIME emulation for uuencode and the like.
1318 This means that Gnus will search message bodies for text that look
1319 like uuencoded bits, yEncoded bits, and so on, and present that using
1320 the normal Gnus MIME machinery."
1321 :version "22.1"
1322 :type 'boolean
1323 :group 'gnus-article-mime)
1325 ;;; Internal variables
1327 (defvar gnus-summary-display-cache nil)
1328 (defvar gnus-article-mime-handles nil)
1329 (defvar gnus-article-decoded-p nil)
1330 (defvar gnus-article-charset nil)
1331 (defvar gnus-article-ignored-charsets nil)
1332 (defvar gnus-scores-exclude-files nil)
1333 (defvar gnus-page-broken nil)
1335 (defvar gnus-original-article nil)
1336 (defvar gnus-article-internal-prepare-hook nil)
1337 (defvar gnus-newsgroup-process-stack nil)
1339 (defvar gnus-thread-indent-array nil)
1340 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1341 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1342 "Function called to sort the articles within a thread after it has been gathered together.")
1344 (defvar gnus-summary-save-parts-type-history nil)
1345 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1347 ;; Avoid highlighting in kill files.
1348 (defvar gnus-summary-inhibit-highlight nil)
1349 (defvar gnus-newsgroup-selected-overlay nil)
1350 (defvar gnus-inhibit-limiting nil)
1351 (defvar gnus-newsgroup-adaptive-score-file nil)
1352 (defvar gnus-current-score-file nil)
1353 (defvar gnus-current-move-group nil)
1354 (defvar gnus-current-copy-group nil)
1355 (defvar gnus-current-crosspost-group nil)
1356 (defvar gnus-newsgroup-display nil)
1358 (defvar gnus-newsgroup-dependencies nil)
1359 (defvar gnus-newsgroup-adaptive nil)
1360 (defvar gnus-summary-display-article-function nil)
1361 (defvar gnus-summary-highlight-line-function nil
1362 "Function called after highlighting a summary line.")
1364 (defvar gnus-summary-line-format-alist
1365 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1366 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1367 (?s gnus-tmp-subject-or-nil ?s)
1368 (?n gnus-tmp-name ?s)
1369 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1371 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1372 gnus-tmp-from) ?s)
1373 (?F gnus-tmp-from ?s)
1374 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1375 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1376 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1377 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1378 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1379 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1380 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1381 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1382 (?L gnus-tmp-lines ?s)
1383 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1384 0) ?d)
1385 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1386 "") ?s)
1387 (?g (or (gnus-group-short-name
1388 (nnir-article-group (mail-header-number gnus-tmp-header)))
1389 "") ?s)
1390 (?O gnus-tmp-downloaded ?c)
1391 (?I gnus-tmp-indentation ?s)
1392 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1393 (?R gnus-tmp-replied ?c)
1394 (?\[ gnus-tmp-opening-bracket ?c)
1395 (?\] gnus-tmp-closing-bracket ?c)
1396 (?\> (make-string gnus-tmp-level ? ) ?s)
1397 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1398 (?i gnus-tmp-score ?d)
1399 (?z gnus-tmp-score-char ?c)
1400 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1401 (?U gnus-tmp-unread ?c)
1402 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1404 (?t (gnus-summary-number-of-articles-in-thread
1405 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1407 (?e (gnus-summary-number-of-articles-in-thread
1408 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1410 (?u gnus-tmp-user-defined ?s)
1411 (?P (gnus-pick-line-number) ?d)
1412 (?B gnus-tmp-thread-tree-header-string ?s)
1413 (user-date (gnus-user-date
1414 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1415 "An alist of format specifications that can appear in summary lines.
1416 These are paired with what variables they correspond with, along with
1417 the type of the variable (string, integer, character, etc).")
1419 (defvar gnus-summary-dummy-line-format-alist
1420 `((?S gnus-tmp-subject ?s)
1421 (?N gnus-tmp-number ?d)
1422 (?u gnus-tmp-user-defined ?s)))
1424 (defvar gnus-summary-mode-line-format-alist
1425 `((?G gnus-tmp-group-name ?s)
1426 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1427 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1428 (?A gnus-tmp-article-number ?d)
1429 (?Z gnus-tmp-unread-and-unselected ?s)
1430 (?V gnus-version ?s)
1431 (?U gnus-tmp-unread-and-unticked ?d)
1432 (?S gnus-tmp-subject ?s)
1433 (?e gnus-tmp-unselected ?d)
1434 (?u gnus-tmp-user-defined ?s)
1435 (?d (length gnus-newsgroup-dormant) ?d)
1436 (?t (length gnus-newsgroup-marked) ?d)
1437 (?h (length gnus-newsgroup-spam-marked) ?d)
1438 (?r (length gnus-newsgroup-reads) ?d)
1439 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1440 (?E gnus-newsgroup-expunged-tally ?d)
1441 (?s (gnus-current-score-file-nondirectory) ?s)))
1443 ;; This is here rather than in gnus-art for compilation reasons.
1444 (defvar gnus-article-mode-line-format-alist
1445 (nconc '((?w (gnus-article-wash-status) ?s)
1446 (?m (gnus-article-mime-part-status) ?s))
1447 gnus-summary-mode-line-format-alist))
1449 (defvar gnus-last-search-regexp nil
1450 "Default regexp for article search command.")
1452 (defvar gnus-last-shell-command nil
1453 "Default shell command on article.")
1455 (defvar gnus-newsgroup-agentized nil
1456 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1457 (defvar gnus-newsgroup-begin nil)
1458 (defvar gnus-newsgroup-end nil)
1459 (defvar gnus-newsgroup-last-rmail nil)
1460 (defvar gnus-newsgroup-last-mail nil)
1461 (defvar gnus-newsgroup-last-folder nil)
1462 (defvar gnus-newsgroup-last-file nil)
1463 (defvar gnus-newsgroup-last-directory nil)
1464 (defvar gnus-newsgroup-auto-expire nil)
1465 (defvar gnus-newsgroup-active nil)
1466 (defvar gnus-newsgroup-highest nil)
1468 (defvar gnus-newsgroup-data nil)
1469 (defvar gnus-newsgroup-data-reverse nil)
1470 (defvar gnus-newsgroup-limit nil)
1471 (defvar gnus-newsgroup-limits nil)
1472 (defvar gnus-summary-use-undownloaded-faces nil)
1474 (defvar gnus-newsgroup-unreads nil
1475 "Sorted list of unread articles in the current newsgroup.")
1477 (defvar gnus-newsgroup-unselected nil
1478 "Sorted list of unselected unread articles in the current newsgroup.")
1480 (defvar gnus-newsgroup-reads nil
1481 "Alist of read articles and article marks in the current newsgroup.")
1483 (defvar gnus-newsgroup-expunged-tally nil)
1485 (defvar gnus-newsgroup-marked nil
1486 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1488 (defvar gnus-newsgroup-spam-marked nil
1489 "List of ranges of articles that have been marked as spam.")
1491 (defvar gnus-newsgroup-killed nil
1492 "List of ranges of articles that have been through the scoring process.")
1494 (defvar gnus-newsgroup-cached nil
1495 "Sorted list of articles that come from the article cache.")
1497 (defvar gnus-newsgroup-saved nil
1498 "List of articles that have been saved.")
1500 (defvar gnus-newsgroup-kill-headers nil)
1502 (defvar gnus-newsgroup-replied nil
1503 "List of articles that have been replied to in the current newsgroup.")
1505 (defvar gnus-newsgroup-forwarded nil
1506 "List of articles that have been forwarded in the current newsgroup.")
1508 (defvar gnus-newsgroup-expirable nil
1509 "Sorted list of articles in the current newsgroup that can be expired.")
1511 (defvar gnus-newsgroup-processable nil
1512 "List of articles in the current newsgroup that can be processed.")
1514 (defvar gnus-newsgroup-downloadable nil
1515 "Sorted list of articles in the current newsgroup that can be processed.")
1517 (defvar gnus-newsgroup-unfetched nil
1518 "Sorted list of articles in the current newsgroup whose headers have
1519 not been fetched into the agent.
1521 This list will always be a subset of gnus-newsgroup-undownloaded.")
1523 (defvar gnus-newsgroup-undownloaded nil
1524 "List of articles in the current newsgroup that haven't been downloaded.")
1526 (defvar gnus-newsgroup-unsendable nil
1527 "List of articles in the current newsgroup that won't be sent.")
1529 (defvar gnus-newsgroup-bookmarks nil
1530 "List of articles in the current newsgroup that have bookmarks.")
1532 (defvar gnus-newsgroup-dormant nil
1533 "Sorted list of dormant articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-unseen nil
1536 "List of unseen articles in the current newsgroup.")
1538 (defvar gnus-newsgroup-seen nil
1539 "Range of seen articles in the current newsgroup.")
1541 (defvar gnus-newsgroup-unexist nil
1542 "Range of unexisting articles in the current newsgroup.")
1544 (defvar gnus-newsgroup-articles nil
1545 "List of articles in the current newsgroup.")
1547 (defvar gnus-newsgroup-scored nil
1548 "List of scored articles in the current newsgroup.")
1550 (defvar gnus-newsgroup-headers nil
1551 "List of article headers in the current newsgroup.")
1553 (defvar gnus-newsgroup-threads nil)
1555 (defvar gnus-newsgroup-prepared nil
1556 "Whether the current group has been prepared properly.")
1558 (defvar gnus-newsgroup-ancient nil
1559 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1561 (defvar gnus-newsgroup-sparse nil)
1563 (defvar gnus-current-article nil)
1564 (defvar gnus-article-current nil)
1565 (defvar gnus-current-headers nil)
1566 (defvar gnus-have-all-headers nil)
1567 (defvar gnus-last-article nil)
1568 (defvar gnus-newsgroup-history nil)
1569 (defvar gnus-newsgroup-charset nil)
1570 (defvar gnus-newsgroup-ephemeral-charset nil)
1571 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1573 (defvar gnus-article-before-search nil)
1575 (defvar gnus-summary-local-variables
1576 '(gnus-newsgroup-name
1578 ;; Marks lists
1579 gnus-newsgroup-unreads
1580 gnus-newsgroup-unselected
1581 gnus-newsgroup-marked
1582 gnus-newsgroup-spam-marked
1583 gnus-newsgroup-reads
1584 gnus-newsgroup-saved
1585 gnus-newsgroup-replied
1586 gnus-newsgroup-forwarded
1587 gnus-newsgroup-expirable
1588 gnus-newsgroup-killed
1589 gnus-newsgroup-unseen
1590 gnus-newsgroup-seen
1591 gnus-newsgroup-unexist
1592 gnus-newsgroup-cached
1593 gnus-newsgroup-downloadable
1594 gnus-newsgroup-undownloaded
1595 gnus-newsgroup-unsendable
1597 gnus-newsgroup-begin gnus-newsgroup-end
1598 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1599 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1600 gnus-newsgroup-last-directory
1601 gnus-newsgroup-auto-expire
1602 gnus-newsgroup-processable
1603 gnus-newsgroup-unfetched
1604 gnus-newsgroup-articles
1605 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1606 gnus-newsgroup-headers gnus-newsgroup-threads
1607 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1608 gnus-current-article gnus-current-headers gnus-have-all-headers
1609 gnus-last-article gnus-article-internal-prepare-hook
1610 (gnus-summary-article-delete-hook . global)
1611 (gnus-summary-article-move-hook . global)
1612 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1613 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1614 gnus-thread-expunge-below
1615 gnus-score-alist gnus-current-score-file
1616 (gnus-summary-expunge-below . global)
1617 (gnus-summary-mark-below . global)
1618 (gnus-orphan-score . global)
1619 gnus-newsgroup-active gnus-scores-exclude-files
1620 gnus-newsgroup-highest
1621 gnus-newsgroup-history gnus-newsgroup-ancient
1622 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1623 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1624 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1625 (gnus-newsgroup-expunged-tally . 0)
1626 gnus-cache-removable-articles
1627 gnus-newsgroup-data gnus-newsgroup-data-reverse
1628 gnus-newsgroup-limit gnus-newsgroup-limits
1629 gnus-newsgroup-charset gnus-newsgroup-display
1630 gnus-summary-use-undownloaded-faces)
1631 "Variables that are buffer-local to the summary buffers.")
1633 (defvar gnus-newsgroup-variables nil
1634 "A list of variables that have separate values in different newsgroups.
1635 A list of newsgroup (summary buffer) local variables, or cons of
1636 variables and their default expressions to be evalled (when the default
1637 values are not nil), that should be made global while the summary buffer
1638 is active.
1640 Note: The default expressions will be evaluated (using function `eval')
1641 before assignment to the local variable rather than just assigned to it.
1642 If the default expression is the symbol `global', that symbol will not
1643 be evaluated but the global value of the local variable will be used
1644 instead.
1646 These variables can be used to set variables in the group parameters
1647 while still allowing them to affect operations done in other buffers.
1648 For example:
1650 \(setq gnus-newsgroup-variables
1651 \\='(message-use-followup-to
1652 (gnus-visible-headers .
1653 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1656 (eval-when-compile
1657 ;; Bind features so that require will believe that gnus-sum has
1658 ;; already been loaded (avoids infinite recursion)
1659 (let ((features (cons 'gnus-sum features)))
1660 (require 'gnus-art)))
1662 ;; MIME stuff.
1664 (defvar gnus-decode-encoded-word-methods
1665 '(mail-decode-encoded-word-string)
1666 "List of methods used to decode encoded words.
1668 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1669 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1670 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1671 whose names match REGEXP.
1673 For example:
1674 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1675 mail-decode-encoded-word-string
1676 (\"chinese\" . rfc1843-decode-string))")
1678 (defvar gnus-decode-encoded-word-methods-cache nil)
1680 (defun gnus-multi-decode-encoded-word-string (string)
1681 "Apply the functions from `gnus-encoded-word-methods' that match."
1682 (unless (and gnus-decode-encoded-word-methods-cache
1683 (eq gnus-newsgroup-name
1684 (car gnus-decode-encoded-word-methods-cache)))
1685 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1686 (dolist (method gnus-decode-encoded-word-methods)
1687 (if (symbolp method)
1688 (nconc gnus-decode-encoded-word-methods-cache (list method))
1689 (if (and gnus-newsgroup-name
1690 (string-match (car method) gnus-newsgroup-name))
1691 (nconc gnus-decode-encoded-word-methods-cache
1692 (list (cdr method)))))))
1693 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1694 (setq string (funcall method string))))
1696 ;; Subject simplification.
1698 (defun gnus-simplify-whitespace (str)
1699 "Remove excessive whitespace from STR."
1700 ;; Multiple spaces.
1701 (while (string-match "[ \t][ \t]+" str)
1702 (setq str (concat (substring str 0 (match-beginning 0))
1704 (substring str (match-end 0)))))
1705 ;; Leading spaces.
1706 (when (string-match "^[ \t]+" str)
1707 (setq str (substring str (match-end 0))))
1708 ;; Trailing spaces.
1709 (when (string-match "[ \t]+$" str)
1710 (setq str (substring str 0 (match-beginning 0))))
1711 str)
1713 (defun gnus-simplify-all-whitespace (str)
1714 "Remove all whitespace from STR."
1715 (while (string-match "[ \t\n]+" str)
1716 (setq str (replace-match "" nil nil str)))
1717 str)
1719 (defsubst gnus-simplify-subject-re (subject)
1720 "Remove \"Re:\" from subject lines."
1721 (if (string-match message-subject-re-regexp subject)
1722 (substring subject (match-end 0))
1723 subject))
1725 (defun gnus-simplify-subject (subject &optional re-only)
1726 "Remove `Re:' and words in parentheses.
1727 If RE-ONLY is non-nil, strip leading `Re:'s only."
1728 (let ((case-fold-search t)) ;Ignore case.
1729 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1730 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1731 (setq subject (substring subject (match-end 0))))
1732 ;; Remove uninteresting prefixes.
1733 (when (and (not re-only)
1734 gnus-simplify-ignored-prefixes
1735 (string-match gnus-simplify-ignored-prefixes subject))
1736 (setq subject (substring subject (match-end 0))))
1737 ;; Remove words in parentheses from end.
1738 (unless re-only
1739 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1740 (setq subject (substring subject 0 (match-beginning 0)))))
1741 ;; Return subject string.
1742 subject))
1744 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1745 ;; all whitespace.
1746 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1747 (goto-char (point-min))
1748 (while (re-search-forward regexp nil t)
1749 (replace-match (or newtext ""))))
1751 (defun gnus-simplify-buffer-fuzzy (regexp)
1752 "Simplify string in the buffer fuzzily.
1753 The string in the accessible portion of the current buffer is simplified.
1754 It is assumed to be a single-line subject.
1755 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1756 matter is removed. Additional things can be deleted by setting
1757 `gnus-simplify-subject-fuzzy-regexp'."
1758 (let ((case-fold-search t)
1759 (modified-tick))
1760 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1762 (while (not (eq modified-tick (buffer-modified-tick)))
1763 (setq modified-tick (buffer-modified-tick))
1764 (cond
1765 ((listp regexp)
1766 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1767 (regexp
1768 (gnus-simplify-buffer-fuzzy-step regexp)))
1769 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1770 (gnus-simplify-buffer-fuzzy-step
1771 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1772 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1774 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1775 (gnus-simplify-buffer-fuzzy-step " +" " ")
1776 (gnus-simplify-buffer-fuzzy-step " $")
1777 (gnus-simplify-buffer-fuzzy-step "^ +")))
1779 (defun gnus-simplify-subject-fuzzy (subject)
1780 "Simplify a subject string fuzzily.
1781 See `gnus-simplify-buffer-fuzzy' for details."
1782 (save-excursion
1783 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1784 (gnus-set-work-buffer)
1785 (let ((case-fold-search t))
1786 ;; Remove uninteresting prefixes.
1787 (when (and gnus-simplify-ignored-prefixes
1788 (string-match gnus-simplify-ignored-prefixes subject))
1789 (setq subject (substring subject (match-end 0))))
1790 (insert subject)
1791 (inline (gnus-simplify-buffer-fuzzy regexp))
1792 (buffer-string)))))
1794 (defsubst gnus-simplify-subject-fully (subject)
1795 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1796 (cond
1797 (gnus-simplify-subject-functions
1798 (gnus-map-function gnus-simplify-subject-functions subject))
1799 ((null gnus-summary-gather-subject-limit)
1800 (gnus-simplify-subject-re subject))
1801 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1802 (gnus-simplify-subject-fuzzy subject))
1803 ((numberp gnus-summary-gather-subject-limit)
1804 (truncate-string-to-width (gnus-simplify-subject-re subject)
1805 gnus-summary-gather-subject-limit))
1807 subject)))
1809 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1810 "Check whether two subjects are equal.
1811 If optional argument SIMPLE-FIRST is t, first argument is already
1812 simplified."
1813 (cond
1814 ((null simple-first)
1815 (equal (gnus-simplify-subject-fully s1)
1816 (gnus-simplify-subject-fully s2)))
1818 (equal s1
1819 (gnus-simplify-subject-fully s2)))))
1821 (defun gnus-summary-bubble-group ()
1822 "Increase the score of the current group.
1823 This is a handy function to add to `gnus-summary-exit-hook' to
1824 increase the score of each group you read."
1825 (gnus-group-add-score gnus-newsgroup-name))
1829 ;;; Gnus summary mode
1832 (put 'gnus-summary-mode 'mode-class 'special)
1834 (defvar gnus-article-commands-menu)
1836 ;; Non-orthogonal keys
1838 (gnus-define-keys gnus-summary-mode-map
1839 " " gnus-summary-next-page
1840 [?\S-\ ] gnus-summary-prev-page
1841 "\177" gnus-summary-prev-page
1842 [delete] gnus-summary-prev-page
1843 "\r" gnus-summary-scroll-up
1844 "\M-\r" gnus-summary-scroll-down
1845 "n" gnus-summary-next-unread-article
1846 "p" gnus-summary-prev-unread-article
1847 "N" gnus-summary-next-article
1848 "P" gnus-summary-prev-article
1849 "\M-\C-n" gnus-summary-next-same-subject
1850 "\M-\C-p" gnus-summary-prev-same-subject
1851 "\M-n" gnus-summary-next-unread-subject
1852 "\M-p" gnus-summary-prev-unread-subject
1853 "." gnus-summary-first-unread-article
1854 "," gnus-summary-best-unread-article
1855 "\M-s" gnus-summary-search-article-forward
1856 "\M-r" gnus-summary-search-article-backward
1857 "\M-S" gnus-summary-repeat-search-article-forward
1858 "\M-R" gnus-summary-repeat-search-article-backward
1859 "<" gnus-summary-beginning-of-article
1860 ">" gnus-summary-end-of-article
1861 "j" gnus-summary-goto-article
1862 "^" gnus-summary-refer-parent-article
1863 "\M-^" gnus-summary-refer-article
1864 "u" gnus-summary-tick-article-forward
1865 "!" gnus-summary-tick-article-forward
1866 "U" gnus-summary-tick-article-backward
1867 "d" gnus-summary-mark-as-read-forward
1868 "D" gnus-summary-mark-as-read-backward
1869 "E" gnus-summary-mark-as-expirable
1870 "\M-u" gnus-summary-clear-mark-forward
1871 "\M-U" gnus-summary-clear-mark-backward
1872 "k" gnus-summary-kill-same-subject-and-select
1873 "\C-k" gnus-summary-kill-same-subject
1874 "\M-\C-k" gnus-summary-kill-thread
1875 "\M-\C-l" gnus-summary-lower-thread
1876 "e" gnus-summary-edit-article
1877 "#" gnus-summary-mark-as-processable
1878 "\M-#" gnus-summary-unmark-as-processable
1879 "\M-\C-t" gnus-summary-toggle-threads
1880 "\M-\C-s" gnus-summary-show-thread
1881 "\M-\C-h" gnus-summary-hide-thread
1882 "\M-\C-f" gnus-summary-next-thread
1883 "\M-\C-b" gnus-summary-prev-thread
1884 [(meta down)] gnus-summary-next-thread
1885 [(meta up)] gnus-summary-prev-thread
1886 "\M-\C-u" gnus-summary-up-thread
1887 "\M-\C-d" gnus-summary-down-thread
1888 "&" gnus-summary-execute-command
1889 "c" gnus-summary-catchup-and-exit
1890 "\C-w" gnus-summary-mark-region-as-read
1891 "\C-t" toggle-truncate-lines
1892 "?" gnus-summary-mark-as-dormant
1893 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1894 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1895 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1896 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1897 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1898 "\C-c\C-s\C-m\C-m" gnus-summary-sort-by-marks
1899 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1900 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1901 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1902 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1903 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1904 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1905 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1906 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1907 "=" gnus-summary-expand-window
1908 "\C-x\C-s" gnus-summary-reselect-current-group
1909 "\M-g" gnus-summary-rescan-group
1910 "\C-c\C-r" gnus-summary-caesar-message
1911 "f" gnus-summary-followup
1912 "F" gnus-summary-followup-with-original
1913 "C" gnus-summary-cancel-article
1914 "r" gnus-summary-reply
1915 "R" gnus-summary-reply-with-original
1916 "\C-c\C-f" gnus-summary-mail-forward
1917 "o" gnus-summary-save-article
1918 "\C-o" gnus-summary-save-article-mail
1919 "|" gnus-summary-pipe-output
1920 "\M-k" gnus-summary-edit-local-kill
1921 "\M-K" gnus-summary-edit-global-kill
1922 ;; "V" gnus-version
1923 "\C-c\C-d" gnus-summary-describe-group
1924 "q" gnus-summary-exit
1925 "Q" gnus-summary-exit-no-update
1926 "\C-c\C-i" gnus-info-find-node
1927 [mouse-2] gnus-mouse-pick-article
1928 [follow-link] mouse-face
1929 "m" gnus-summary-mail-other-window
1930 "a" gnus-summary-post-news
1931 "x" gnus-summary-limit-to-unread
1932 "s" gnus-summary-isearch-article
1933 "\t" gnus-summary-widget-forward
1934 [backtab] gnus-summary-widget-backward
1935 "t" gnus-summary-toggle-header
1936 "g" gnus-summary-show-article
1937 "l" gnus-summary-goto-last-article
1938 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1939 "\C-d" gnus-summary-enter-digest-group
1940 "\M-\C-d" gnus-summary-read-document
1941 "\M-\C-e" gnus-summary-edit-parameters
1942 "\M-\C-a" gnus-summary-customize-parameters
1943 "\C-c\C-b" gnus-bug
1944 "*" gnus-cache-enter-article
1945 "\M-*" gnus-cache-remove-article
1946 "\M-&" gnus-summary-universal-argument
1947 "\C-l" gnus-recenter
1948 "I" gnus-summary-increase-score
1949 "L" gnus-summary-lower-score
1950 "\M-i" gnus-symbolic-argument
1951 "h" gnus-summary-select-article-buffer
1953 "b" gnus-article-view-part
1954 "\M-t" gnus-summary-toggle-display-buttonized
1956 "V" gnus-summary-score-map
1957 "X" gnus-uu-extract-map
1958 "S" gnus-summary-send-map)
1960 ;; Sort of orthogonal keymap
1961 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1962 "t" gnus-summary-tick-article-forward
1963 "!" gnus-summary-tick-article-forward
1964 "d" gnus-summary-mark-as-read-forward
1965 "r" gnus-summary-mark-as-read-forward
1966 "c" gnus-summary-clear-mark-forward
1967 " " gnus-summary-clear-mark-forward
1968 "e" gnus-summary-mark-as-expirable
1969 "x" gnus-summary-mark-as-expirable
1970 "?" gnus-summary-mark-as-dormant
1971 "b" gnus-summary-set-bookmark
1972 "B" gnus-summary-remove-bookmark
1973 "#" gnus-summary-mark-as-processable
1974 "\M-#" gnus-summary-unmark-as-processable
1975 "S" gnus-summary-limit-include-expunged
1976 "C" gnus-summary-catchup
1977 "H" gnus-summary-catchup-to-here
1978 "h" gnus-summary-catchup-from-here
1979 "\C-c" gnus-summary-catchup-all
1980 "k" gnus-summary-kill-same-subject-and-select
1981 "K" gnus-summary-kill-same-subject
1982 "P" gnus-uu-mark-map)
1984 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1985 "c" gnus-summary-clear-above
1986 "u" gnus-summary-tick-above
1987 "m" gnus-summary-mark-above
1988 "k" gnus-summary-kill-below)
1990 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1991 "/" gnus-summary-limit-to-subject
1992 "n" gnus-summary-limit-to-articles
1993 "b" gnus-summary-limit-to-bodies
1994 "h" gnus-summary-limit-to-headers
1995 "w" gnus-summary-pop-limit
1996 "s" gnus-summary-limit-to-subject
1997 "a" gnus-summary-limit-to-author
1998 "u" gnus-summary-limit-to-unread
1999 "m" gnus-summary-limit-to-marks
2000 "M" gnus-summary-limit-exclude-marks
2001 "v" gnus-summary-limit-to-score
2002 "*" gnus-summary-limit-include-cached
2003 "D" gnus-summary-limit-include-dormant
2004 "T" gnus-summary-limit-include-thread
2005 "d" gnus-summary-limit-exclude-dormant
2006 "t" gnus-summary-limit-to-age
2007 "." gnus-summary-limit-to-unseen
2008 "x" gnus-summary-limit-to-extra
2009 "p" gnus-summary-limit-to-display-predicate
2010 "E" gnus-summary-limit-include-expunged
2011 "c" gnus-summary-limit-exclude-childless-dormant
2012 "C" gnus-summary-limit-mark-excluded-as-read
2013 "o" gnus-summary-insert-old-articles
2014 "N" gnus-summary-insert-new-articles
2015 "S" gnus-summary-limit-to-singletons
2016 "r" gnus-summary-limit-to-replied
2017 "R" gnus-summary-limit-to-recipient
2018 "A" gnus-summary-limit-to-address)
2020 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2021 "n" gnus-summary-next-unread-article
2022 "p" gnus-summary-prev-unread-article
2023 "N" gnus-summary-next-article
2024 "P" gnus-summary-prev-article
2025 "\C-n" gnus-summary-next-same-subject
2026 "\C-p" gnus-summary-prev-same-subject
2027 "\M-n" gnus-summary-next-unread-subject
2028 "\M-p" gnus-summary-prev-unread-subject
2029 "f" gnus-summary-first-unread-article
2030 "b" gnus-summary-best-unread-article
2031 "j" gnus-summary-goto-article
2032 "g" gnus-summary-goto-subject
2033 "l" gnus-summary-goto-last-article
2034 "o" gnus-summary-pop-article)
2036 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2037 "k" gnus-summary-kill-thread
2038 "E" gnus-summary-expire-thread
2039 "l" gnus-summary-lower-thread
2040 "i" gnus-summary-raise-thread
2041 "T" gnus-summary-toggle-threads
2042 "t" gnus-summary-rethread-current
2043 "^" gnus-summary-reparent-thread
2044 "\M-^" gnus-summary-reparent-children
2045 "s" gnus-summary-show-thread
2046 "S" gnus-summary-show-all-threads
2047 "h" gnus-summary-hide-thread
2048 "H" gnus-summary-hide-all-threads
2049 "n" gnus-summary-next-thread
2050 "p" gnus-summary-prev-thread
2051 "u" gnus-summary-up-thread
2052 "o" gnus-summary-top-thread
2053 "d" gnus-summary-down-thread
2054 "#" gnus-uu-mark-thread
2055 "\M-#" gnus-uu-unmark-thread)
2057 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2058 "g" gnus-summary-prepare
2059 "c" gnus-summary-insert-cached-articles
2060 "d" gnus-summary-insert-dormant-articles
2061 "t" gnus-summary-insert-ticked-articles)
2063 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2064 "c" gnus-summary-catchup-and-exit
2065 "C" gnus-summary-catchup-all-and-exit
2066 "E" gnus-summary-exit-no-update
2067 "Q" gnus-summary-exit
2068 "Z" gnus-summary-exit
2069 "n" gnus-summary-catchup-and-goto-next-group
2070 "p" gnus-summary-catchup-and-goto-prev-group
2071 "R" gnus-summary-reselect-current-group
2072 "G" gnus-summary-rescan-group
2073 "N" gnus-summary-next-group
2074 "s" gnus-summary-save-newsrc
2075 "P" gnus-summary-prev-group)
2077 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2078 " " gnus-summary-next-page
2079 "n" gnus-summary-next-page
2080 [?\S-\ ] gnus-summary-prev-page
2081 "\177" gnus-summary-prev-page
2082 [delete] gnus-summary-prev-page
2083 "p" gnus-summary-prev-page
2084 "\r" gnus-summary-scroll-up
2085 "\M-\r" gnus-summary-scroll-down
2086 "<" gnus-summary-beginning-of-article
2087 ">" gnus-summary-end-of-article
2088 "b" gnus-summary-beginning-of-article
2089 "e" gnus-summary-end-of-article
2090 "^" gnus-summary-refer-parent-article
2091 "r" gnus-summary-refer-parent-article
2092 "C" gnus-summary-show-complete-article
2093 "D" gnus-summary-enter-digest-group
2094 "R" gnus-summary-refer-references
2095 "T" gnus-summary-refer-thread
2096 "W" gnus-warp-to-article
2097 "g" gnus-summary-show-article
2098 "s" gnus-summary-isearch-article
2099 "\t" gnus-summary-widget-forward
2100 [backtab] gnus-summary-widget-backward
2101 "P" gnus-summary-print-article
2102 "S" gnus-sticky-article
2103 "M" gnus-mailing-list-insinuate
2104 "t" gnus-article-babel)
2106 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2107 "b" gnus-article-add-buttons
2108 "B" gnus-article-add-buttons-to-head
2109 "o" gnus-article-treat-overstrike
2110 "e" gnus-article-emphasize
2111 "w" gnus-article-fill-cited-article
2112 "Q" gnus-article-fill-long-lines
2113 "L" gnus-article-toggle-truncate-lines
2114 "C" gnus-article-capitalize-sentences
2115 "c" gnus-article-remove-cr
2116 "q" gnus-article-de-quoted-unreadable
2117 "6" gnus-article-de-base64-unreadable
2118 "Z" gnus-article-decode-HZ
2119 "A" gnus-article-treat-ansi-sequences
2120 "h" gnus-article-wash-html
2121 "u" gnus-article-unsplit-urls
2122 "s" gnus-summary-force-verify-and-decrypt
2123 "f" gnus-article-display-x-face
2124 "l" gnus-summary-stop-page-breaking
2125 "r" gnus-summary-caesar-message
2126 "m" gnus-summary-morse-message
2127 "t" gnus-summary-toggle-header
2128 "g" gnus-treat-smiley
2129 "v" gnus-summary-verbose-headers
2130 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2131 "p" gnus-article-verify-x-pgp-sig
2132 "d" gnus-article-treat-dumbquotes
2133 "U" gnus-article-treat-non-ascii
2134 "i" gnus-summary-idna-message)
2136 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2137 ;; mnemonic: deuglif*Y*
2138 "u" gnus-article-outlook-unwrap-lines
2139 "a" gnus-article-outlook-repair-attribution
2140 "c" gnus-article-outlook-rearrange-citation
2141 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2143 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2144 "a" gnus-article-hide
2145 "h" gnus-article-hide-headers
2146 "b" gnus-article-hide-boring-headers
2147 "s" gnus-article-hide-signature
2148 "c" gnus-article-hide-citation
2149 "C" gnus-article-hide-citation-in-followups
2150 "l" gnus-article-hide-list-identifiers
2151 "B" gnus-article-strip-banner
2152 "P" gnus-article-hide-pem
2153 "\C-c" gnus-article-hide-citation-maybe)
2155 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2156 "a" gnus-article-highlight
2157 "h" gnus-article-highlight-headers
2158 "c" gnus-article-highlight-citation
2159 "s" gnus-article-highlight-signature)
2161 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2162 "f" gnus-article-treat-fold-headers
2163 "u" gnus-article-treat-unfold-headers
2164 "n" gnus-article-treat-fold-newsgroups)
2166 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2167 "x" gnus-article-display-x-face
2168 "d" gnus-article-display-face
2169 "s" gnus-treat-smiley
2170 "D" gnus-article-remove-images
2171 "W" gnus-article-show-images
2172 "f" gnus-treat-from-picon
2173 "m" gnus-treat-mail-picon
2174 "n" gnus-treat-newsgroups-picon
2175 "g" gnus-treat-from-gravatar
2176 "h" gnus-treat-mail-gravatar)
2178 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2179 "w" gnus-article-decode-mime-words
2180 "c" gnus-article-decode-charset
2181 "h" gnus-mime-buttonize-attachments-in-header
2182 "v" gnus-mime-view-all-parts
2183 "b" gnus-article-view-part)
2185 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2186 "z" gnus-article-date-ut
2187 "u" gnus-article-date-ut
2188 "l" gnus-article-date-local
2189 "p" gnus-article-date-english
2190 "e" gnus-article-date-lapsed
2191 "o" gnus-article-date-original
2192 "i" gnus-article-date-iso8601
2193 "s" gnus-article-date-user)
2195 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2196 "t" gnus-article-remove-trailing-blank-lines
2197 "l" gnus-article-strip-leading-blank-lines
2198 "m" gnus-article-strip-multiple-blank-lines
2199 "a" gnus-article-strip-blank-lines
2200 "A" gnus-article-strip-all-blank-lines
2201 "s" gnus-article-strip-leading-space
2202 "e" gnus-article-strip-trailing-space
2203 "w" gnus-article-remove-leading-whitespace)
2205 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2206 "v" gnus-version
2207 "d" gnus-summary-describe-group
2208 "h" gnus-summary-describe-briefly
2209 "i" gnus-info-find-node)
2211 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2212 "e" gnus-summary-expire-articles
2213 "\M-\C-e" gnus-summary-expire-articles-now
2214 "\177" gnus-summary-delete-article
2215 [delete] gnus-summary-delete-article
2216 [backspace] gnus-summary-delete-article
2217 "m" gnus-summary-move-article
2218 "r" gnus-summary-respool-article
2219 "w" gnus-summary-edit-article
2220 "c" gnus-summary-copy-article
2221 "B" gnus-summary-crosspost-article
2222 "q" gnus-summary-respool-query
2223 "t" gnus-summary-respool-trace
2224 "i" gnus-summary-import-article
2225 "I" gnus-summary-create-article
2226 "p" gnus-summary-article-posted-p)
2228 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2229 "o" gnus-summary-save-article
2230 "m" gnus-summary-save-article-mail
2231 "F" gnus-summary-write-article-file
2232 "r" gnus-summary-save-article-rmail
2233 "f" gnus-summary-save-article-file
2234 "b" gnus-summary-save-article-body-file
2235 "B" gnus-summary-write-article-body-file
2236 "h" gnus-summary-save-article-folder
2237 "v" gnus-summary-save-article-vm
2238 "p" gnus-summary-pipe-output
2239 "P" gnus-summary-muttprint)
2241 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2242 "b" gnus-summary-display-buttonized
2243 "m" gnus-summary-repair-multipart
2244 "v" gnus-article-view-part
2245 "o" gnus-article-save-part
2246 "O" gnus-article-save-part-and-strip
2247 "r" gnus-article-replace-part
2248 "d" gnus-article-delete-part
2249 "t" gnus-article-view-part-as-type
2250 "j" gnus-article-jump-to-part
2251 "c" gnus-article-copy-part
2252 "C" gnus-article-view-part-as-charset
2253 "e" gnus-article-view-part-externally
2254 "H" gnus-article-browse-html-article
2255 "E" gnus-article-encrypt-body
2256 "i" gnus-article-inline-part
2257 "|" gnus-article-pipe-part)
2259 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2260 "p" gnus-summary-mark-as-processable
2261 "u" gnus-summary-unmark-as-processable
2262 "U" gnus-summary-unmark-all-processable
2263 "v" gnus-uu-mark-over
2264 "s" gnus-uu-mark-series
2265 "r" gnus-uu-mark-region
2266 "g" gnus-uu-unmark-region
2267 "R" gnus-uu-mark-by-regexp
2268 "G" gnus-uu-unmark-by-regexp
2269 "t" gnus-uu-mark-thread
2270 "T" gnus-uu-unmark-thread
2271 "a" gnus-uu-mark-all
2272 "b" gnus-uu-mark-buffer
2273 "S" gnus-uu-mark-sparse
2274 "k" gnus-summary-kill-process-mark
2275 "y" gnus-summary-yank-process-mark
2276 "w" gnus-summary-save-process-mark
2277 "i" gnus-uu-invert-processable)
2279 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2280 ;;"x" gnus-uu-extract-any
2281 "m" gnus-summary-save-parts
2282 "u" gnus-uu-decode-uu
2283 "U" gnus-uu-decode-uu-and-save
2284 "s" gnus-uu-decode-unshar
2285 "S" gnus-uu-decode-unshar-and-save
2286 "o" gnus-uu-decode-save
2287 "O" gnus-uu-decode-save
2288 "b" gnus-uu-decode-binhex
2289 "B" gnus-uu-decode-binhex
2290 "Y" gnus-uu-decode-yenc
2291 "p" gnus-uu-decode-postscript
2292 "P" gnus-uu-decode-postscript-and-save)
2294 (gnus-define-keys
2295 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2296 "u" gnus-uu-decode-uu-view
2297 "U" gnus-uu-decode-uu-and-save-view
2298 "s" gnus-uu-decode-unshar-view
2299 "S" gnus-uu-decode-unshar-and-save-view
2300 "o" gnus-uu-decode-save-view
2301 "O" gnus-uu-decode-save-view
2302 "b" gnus-uu-decode-binhex-view
2303 "B" gnus-uu-decode-binhex-view
2304 "p" gnus-uu-decode-postscript-view
2305 "P" gnus-uu-decode-postscript-and-save-view)
2307 (defvar gnus-article-post-menu nil)
2309 (defconst gnus-summary-menu-maxlen 20)
2311 (defun gnus-summary-menu-split (menu)
2312 ;; If we have lots of elements, divide them into groups of 20
2313 ;; and make a pane (or submenu) for each one.
2314 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2315 (let ((menu menu) sublists next
2316 (i 1))
2317 (while menu
2318 ;; Pull off the next gnus-summary-menu-maxlen elements
2319 ;; and make them the next element of sublist.
2320 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2321 (if next
2322 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2323 nil))
2324 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2325 (aref (car (last menu)) 0)) menu)
2326 sublists))
2327 (setq i (1+ i))
2328 (setq menu next))
2329 (nreverse sublists))
2330 ;; Few elements--put them all in one pane.
2331 menu))
2333 (defun gnus-summary-make-menu-bar ()
2334 (gnus-turn-off-edit-menu 'summary)
2336 (unless (boundp 'gnus-summary-misc-menu)
2338 (easy-menu-define
2339 gnus-summary-kill-menu gnus-summary-mode-map ""
2340 (cons
2341 "Score"
2342 (nconc
2343 (list
2344 ["Customize" gnus-score-customize t])
2345 (gnus-make-score-map 'increase)
2346 (gnus-make-score-map 'lower)
2347 '(("Mark"
2348 ["Kill below" gnus-summary-kill-below t]
2349 ["Mark above" gnus-summary-mark-above t]
2350 ["Tick above" gnus-summary-tick-above t]
2351 ["Clear above" gnus-summary-clear-above t])
2352 ["Current article score" gnus-summary-current-score t]
2353 ["Current thread score" (gnus-summary-current-score 'total) t]
2354 ["Set score" gnus-summary-set-score t]
2355 ["Switch current score file..." gnus-score-change-score-file t]
2356 ["Set mark below..." gnus-score-set-mark-below t]
2357 ["Set expunge below..." gnus-score-set-expunge-below t]
2358 ["Edit current score file" gnus-score-edit-current-scores t]
2359 ["Edit score file..." gnus-score-edit-file t]
2360 ["Trace score" gnus-score-find-trace t]
2361 ["Find words" gnus-score-find-favourite-words t]
2362 ["Rescore buffer" gnus-summary-rescore t]
2363 ["Increase score..." gnus-summary-increase-score t]
2364 ["Lower score..." gnus-summary-lower-score t]))))
2366 ;; Define both the Article menu in the summary buffer and the
2367 ;; equivalent Commands menu in the article buffer here for
2368 ;; consistency.
2369 (let ((innards
2370 `(("Hide"
2371 ["All" gnus-article-hide t]
2372 ["Headers" gnus-article-hide-headers t]
2373 ["Signature" gnus-article-hide-signature t]
2374 ["Citation" gnus-article-hide-citation t]
2375 ["List identifiers" gnus-article-hide-list-identifiers t]
2376 ["Banner" gnus-article-strip-banner t]
2377 ["Boring headers" gnus-article-hide-boring-headers t])
2378 ("Highlight"
2379 ["All" gnus-article-highlight t]
2380 ["Headers" gnus-article-highlight-headers t]
2381 ["Signature" gnus-article-highlight-signature t]
2382 ["Citation" gnus-article-highlight-citation t])
2383 ("MIME"
2384 ["Words" gnus-article-decode-mime-words t]
2385 ["Charset" gnus-article-decode-charset t]
2386 ["QP" gnus-article-de-quoted-unreadable t]
2387 ["Base64" gnus-article-de-base64-unreadable t]
2388 ["View MIME buttons" gnus-summary-display-buttonized t]
2389 ["View MIME buttons in header"
2390 gnus-mime-buttonize-attachments-in-header t]
2391 ["View all" gnus-mime-view-all-parts t]
2392 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2393 ["Encrypt body" gnus-article-encrypt-body
2394 :active (not (gnus-group-read-only-p))
2395 :help "Encrypt the message body on disk"]
2396 ["Extract all parts..." gnus-summary-save-parts t]
2397 ("Multipart"
2398 ["Repair multipart" gnus-summary-repair-multipart t]
2399 ["Pipe part..." gnus-article-pipe-part t]
2400 ["Inline part" gnus-article-inline-part t]
2401 ["View part as type..." gnus-article-view-part-as-type t]
2402 ["Encrypt body" gnus-article-encrypt-body
2403 :active (not (gnus-group-read-only-p))
2404 :help "Encrypt the message body on disk"]
2405 ["View part externally" gnus-article-view-part-externally t]
2406 ["View HTML parts in browser" gnus-article-browse-html-article t]
2407 ["View part with charset..." gnus-article-view-part-as-charset t]
2408 ["Copy part" gnus-article-copy-part t]
2409 ["Save part..." gnus-article-save-part t]
2410 ["View part" gnus-article-view-part t]))
2411 ("Date"
2412 ["Local" gnus-article-date-local t]
2413 ["ISO8601" gnus-article-date-iso8601 t]
2414 ["UT" gnus-article-date-ut t]
2415 ["Original" gnus-article-date-original t]
2416 ["Lapsed" gnus-article-date-lapsed t]
2417 ["User-defined" gnus-article-date-user t])
2418 ("Display"
2419 ["Display HTML images" gnus-article-show-images t]
2420 ["Remove images" gnus-article-remove-images t]
2421 ["Toggle smiley" gnus-treat-smiley t]
2422 ["Show X-Face" gnus-article-display-x-face t]
2423 ["Show picons in From" gnus-treat-from-picon t]
2424 ["Show picons in mail headers" gnus-treat-mail-picon t]
2425 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2426 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2427 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2428 ("View as different encoding"
2429 ,@(gnus-summary-menu-split
2430 (mapcar
2431 (lambda (cs)
2432 ;; Since easymenu under Emacs doesn't allow
2433 ;; lambda forms for menu commands, we should
2434 ;; provide intern'ed function symbols.
2435 (let ((command (intern (format "\
2436 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2437 (fset command
2438 `(lambda ()
2439 (interactive)
2440 (let ((gnus-summary-show-article-charset-alist
2441 '((1 . ,cs))))
2442 (gnus-summary-show-article 1))))
2443 `[,(symbol-name cs) ,command t]))
2444 (sort (coding-system-list) 'string<)))))
2445 ("Washing"
2446 ("Remove Blanks"
2447 ["Leading" gnus-article-strip-leading-blank-lines t]
2448 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2449 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2450 ["All of the above" gnus-article-strip-blank-lines t]
2451 ["All" gnus-article-strip-all-blank-lines t]
2452 ["Leading space" gnus-article-strip-leading-space t]
2453 ["Trailing space" gnus-article-strip-trailing-space t]
2454 ["Leading space in headers"
2455 gnus-article-remove-leading-whitespace t])
2456 ["Overstrike" gnus-article-treat-overstrike t]
2457 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2458 ["Non-ASCII" gnus-article-treat-non-ascii t]
2459 ["Emphasis" gnus-article-emphasize t]
2460 ["Word wrap" gnus-article-fill-cited-article t]
2461 ["Fill long lines" gnus-article-fill-long-lines t]
2462 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2463 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2464 ["Remove CR" gnus-article-remove-cr t]
2465 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2466 ["Base64" gnus-article-de-base64-unreadable t]
2467 ["Rot 13" gnus-summary-caesar-message
2468 :help "\"Caesar rotate\" article by 13"]
2469 ["De-IDNA" gnus-summary-idna-message t]
2470 ["Morse decode" gnus-summary-morse-message t]
2471 ["Unix pipe..." gnus-summary-pipe-message t]
2472 ["Add buttons" gnus-article-add-buttons t]
2473 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2474 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2475 ["Verbose header" gnus-summary-verbose-headers t]
2476 ["Toggle header" gnus-summary-toggle-header t]
2477 ["Unfold headers" gnus-article-treat-unfold-headers t]
2478 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2479 ["Html" gnus-article-wash-html t]
2480 ["Unsplit URLs" gnus-article-unsplit-urls t]
2481 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2482 ["Decode HZ" gnus-article-decode-HZ t]
2483 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2484 ("(Outlook) Deuglify"
2485 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2486 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2487 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2488 ["Full (Outlook) deuglify"
2489 gnus-article-outlook-deuglify-article t])
2491 ("Output"
2492 ["Save in default format..." gnus-summary-save-article
2493 :help "Save article using default method"]
2494 ["Save in file..." gnus-summary-save-article-file
2495 :help "Save article in file"]
2496 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2497 ["Save in MH folder..." gnus-summary-save-article-folder t]
2498 ["Save in VM folder..." gnus-summary-save-article-vm t]
2499 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2500 ["Save body in file..." gnus-summary-save-article-body-file t]
2501 ["Pipe through a filter..." gnus-summary-pipe-output t]
2502 ["Print with Muttprint..." gnus-summary-muttprint t]
2503 ["Print" gnus-summary-print-article
2504 :help "Generate and print a PostScript image"])
2505 ("Copy, move,... (Backend)"
2506 :help "Copying, moving, expiring articles..."
2507 ["Respool article..." gnus-summary-respool-article t]
2508 ["Move article..." gnus-summary-move-article
2509 (gnus-check-backend-function
2510 'request-move-article gnus-newsgroup-name)]
2511 ["Copy article..." gnus-summary-copy-article t]
2512 ["Crosspost article..." gnus-summary-crosspost-article
2513 (gnus-check-backend-function
2514 'request-replace-article gnus-newsgroup-name)]
2515 ["Import file..." gnus-summary-import-article
2516 (gnus-check-backend-function
2517 'request-accept-article gnus-newsgroup-name)]
2518 ["Create article..." gnus-summary-create-article
2519 (gnus-check-backend-function
2520 'request-accept-article gnus-newsgroup-name)]
2521 ["Check if posted" gnus-summary-article-posted-p t]
2522 ["Edit article" gnus-summary-edit-article
2523 (not (gnus-group-read-only-p))]
2524 ["Delete article" gnus-summary-delete-article
2525 (gnus-check-backend-function
2526 'request-expire-articles gnus-newsgroup-name)]
2527 ["Query respool" gnus-summary-respool-query t]
2528 ["Trace respool" gnus-summary-respool-trace t]
2529 ["Delete expirable articles" gnus-summary-expire-articles-now
2530 (gnus-check-backend-function
2531 'request-expire-articles gnus-newsgroup-name)])
2532 ("Extract"
2533 ["Uudecode" gnus-uu-decode-uu :help "Decode uuencoded article(s)"]
2534 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2535 ["Unshar" gnus-uu-decode-unshar t]
2536 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2537 ["Save" gnus-uu-decode-save t]
2538 ["Binhex" gnus-uu-decode-binhex t]
2539 ["PostScript" gnus-uu-decode-postscript t]
2540 ["All MIME parts" gnus-summary-save-parts t])
2541 ("Cache"
2542 ["Enter article" gnus-cache-enter-article t]
2543 ["Remove article" gnus-cache-remove-article t])
2544 ["Translate" gnus-article-babel t]
2545 ["Select article buffer" gnus-summary-select-article-buffer t]
2546 ["Make article buffer sticky" gnus-sticky-article t]
2547 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2548 ["Isearch article..." gnus-summary-isearch-article t]
2549 ["Beginning of the article" gnus-summary-beginning-of-article t]
2550 ["End of the article" gnus-summary-end-of-article t]
2551 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2552 ["Fetch referenced articles" gnus-summary-refer-references t]
2553 ["Fetch current thread" gnus-summary-refer-thread t]
2554 ["Fetch article with id..." gnus-summary-refer-article t]
2555 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2556 ["Redisplay" gnus-summary-show-article t]
2557 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2558 (easy-menu-define
2559 gnus-summary-article-menu gnus-summary-mode-map ""
2560 (cons "Article" innards))
2562 (if (not (keymapp gnus-summary-article-menu))
2563 (easy-menu-define
2564 gnus-article-commands-menu gnus-article-mode-map ""
2565 (cons "Commands" innards))
2566 ;; Don't share the menu.
2567 (setq gnus-article-commands-menu
2568 (copy-keymap gnus-summary-article-menu))
2569 (define-key gnus-article-mode-map [menu-bar commands]
2570 (cons "Commands" gnus-article-commands-menu))))
2572 (easy-menu-define
2573 gnus-summary-thread-menu gnus-summary-mode-map ""
2574 '("Threads"
2575 ["Find all messages in thread" gnus-summary-refer-thread t]
2576 ["Toggle threading" gnus-summary-toggle-threads t]
2577 ["Hide threads" gnus-summary-hide-all-threads t]
2578 ["Show threads" gnus-summary-show-all-threads t]
2579 ["Hide thread" gnus-summary-hide-thread t]
2580 ["Show thread" gnus-summary-show-thread t]
2581 ["Go to next thread" gnus-summary-next-thread t]
2582 ["Go to previous thread" gnus-summary-prev-thread t]
2583 ["Go down thread" gnus-summary-down-thread t]
2584 ["Go up thread" gnus-summary-up-thread t]
2585 ["Top of thread" gnus-summary-top-thread t]
2586 ["Mark thread as read" gnus-summary-kill-thread t]
2587 ["Mark thread as expired" gnus-summary-expire-thread t]
2588 ["Lower thread score" gnus-summary-lower-thread t]
2589 ["Raise thread score" gnus-summary-raise-thread t]
2590 ["Rethread current" gnus-summary-rethread-current t]))
2592 (easy-menu-define
2593 gnus-summary-post-menu gnus-summary-mode-map ""
2594 `("Post"
2595 ["Send a message (mail or news)" gnus-summary-post-news
2596 :help "Compose a new message (mail or news)"]
2597 ["Followup" gnus-summary-followup
2598 :help "Post followup to this article"]
2599 ["Followup and yank" gnus-summary-followup-with-original
2600 :help "Post followup to this article, quoting its contents"]
2601 ["Supersede article" gnus-summary-supersede-article t]
2602 ["Cancel article" gnus-summary-cancel-article
2603 :help "Cancel an article you posted"]
2604 ["Reply" gnus-summary-reply t]
2605 ["Reply and yank" gnus-summary-reply-with-original t]
2606 ["Wide reply" gnus-summary-wide-reply t]
2607 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2608 :help "Mail a reply, quoting this article"]
2609 ["Very wide reply" gnus-summary-very-wide-reply t]
2610 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2611 :help "Mail a very wide reply, quoting this article"]
2612 ["Mail forward" gnus-summary-mail-forward t]
2613 ["Post forward" gnus-summary-post-forward t]
2614 ["Digest and mail" gnus-uu-digest-mail-forward t]
2615 ["Digest and post" gnus-uu-digest-post-forward t]
2616 ["Resend message" gnus-summary-resend-message t]
2617 ["Resend message edit" gnus-summary-resend-message-edit t]
2618 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2619 ["Send a mail" gnus-summary-mail-other-window t]
2620 ["Create a local message" gnus-summary-news-other-window t]
2621 ["Uuencode and post" gnus-uu-post-news
2622 :help "Post a uuencoded article"]
2623 ["Followup via news" gnus-summary-followup-to-mail t]
2624 ["Followup via news and yank"
2625 gnus-summary-followup-to-mail-with-original t]
2626 ["Strip signature on reply"
2627 (lambda ()
2628 (interactive)
2629 (setq message-cite-function
2630 (if (eq message-cite-function
2631 'message-cite-original-without-signature)
2632 'message-cite-original
2633 'message-cite-original-without-signature)))
2634 :visible (memq message-cite-function
2635 '(message-cite-original-without-signature
2636 message-cite-original))
2637 :style toggle
2638 :selected (eq message-cite-function
2639 'message-cite-original-without-signature)
2640 :help "Strip signature from cited article when replying."]))
2642 (cond
2643 ((not (keymapp gnus-summary-post-menu))
2644 (setq gnus-article-post-menu gnus-summary-post-menu))
2645 ((not gnus-article-post-menu)
2646 ;; Don't share post menu.
2647 (setq gnus-article-post-menu
2648 (copy-keymap gnus-summary-post-menu))))
2649 (define-key gnus-article-mode-map [menu-bar post]
2650 (cons "Post" gnus-article-post-menu))
2652 (easy-menu-define
2653 gnus-summary-misc-menu gnus-summary-mode-map ""
2654 `("Gnus"
2655 ("Mark Read"
2656 ["Mark as read" gnus-summary-mark-as-read-forward t]
2657 ["Mark same subject and select"
2658 gnus-summary-kill-same-subject-and-select t]
2659 ["Mark same subject" gnus-summary-kill-same-subject t]
2660 ["Catchup" gnus-summary-catchup
2661 :help "Mark unread articles in this group as read"]
2662 ["Catchup all" gnus-summary-catchup-all t]
2663 ["Catchup to here" gnus-summary-catchup-to-here t]
2664 ["Catchup from here" gnus-summary-catchup-from-here t]
2665 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2666 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2667 ("Mark Various"
2668 ["Tick" gnus-summary-tick-article-forward t]
2669 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2670 ["Remove marks" gnus-summary-clear-mark-forward t]
2671 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2672 ["Set bookmark" gnus-summary-set-bookmark t]
2673 ["Remove bookmark" gnus-summary-remove-bookmark t])
2674 ("Limit to"
2675 ["Marks..." gnus-summary-limit-to-marks t]
2676 ["Subject..." gnus-summary-limit-to-subject t]
2677 ["Author..." gnus-summary-limit-to-author t]
2678 ["Recipient..." gnus-summary-limit-to-recipient t]
2679 ["Address..." gnus-summary-limit-to-address t]
2680 ["Age..." gnus-summary-limit-to-age t]
2681 ["Extra..." gnus-summary-limit-to-extra t]
2682 ["Score..." gnus-summary-limit-to-score t]
2683 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2684 ["Unread" gnus-summary-limit-to-unread t]
2685 ["Unseen" gnus-summary-limit-to-unseen t]
2686 ["Singletons" gnus-summary-limit-to-singletons t]
2687 ["Replied" gnus-summary-limit-to-replied t]
2688 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2689 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2690 ["Pop limit" gnus-summary-pop-limit t]
2691 ["Show dormant" gnus-summary-limit-include-dormant t]
2692 ["Hide childless dormant"
2693 gnus-summary-limit-exclude-childless-dormant t]
2694 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2695 ["Hide marked" gnus-summary-limit-exclude-marks t]
2696 ["Show expunged" gnus-summary-limit-include-expunged t])
2697 ("Process Mark"
2698 ["Set mark" gnus-summary-mark-as-processable t]
2699 ["Remove mark" gnus-summary-unmark-as-processable t]
2700 ["Remove all marks" gnus-summary-unmark-all-processable t]
2701 ["Invert marks" gnus-uu-invert-processable t]
2702 ["Mark above" gnus-uu-mark-over t]
2703 ["Mark series" gnus-uu-mark-series t]
2704 ["Mark region" gnus-uu-mark-region mark-active]
2705 ["Unmark region" gnus-uu-unmark-region mark-active]
2706 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2707 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2708 ["Mark all" gnus-uu-mark-all t]
2709 ["Mark buffer" gnus-uu-mark-buffer t]
2710 ["Mark sparse" gnus-uu-mark-sparse t]
2711 ["Mark thread" gnus-uu-mark-thread t]
2712 ["Unmark thread" gnus-uu-unmark-thread t]
2713 ("Process Mark Sets"
2714 ["Kill" gnus-summary-kill-process-mark t]
2715 ["Yank" gnus-summary-yank-process-mark
2716 gnus-newsgroup-process-stack]
2717 ["Save" gnus-summary-save-process-mark t]
2718 ["Run command on marked..." gnus-summary-universal-argument t]))
2719 ("Registry Marks")
2720 ("Scroll article"
2721 ["Page forward" gnus-summary-next-page
2722 :help "Show next page of article"]
2723 ["Page backward" gnus-summary-prev-page
2724 :help "Show previous page of article"]
2725 ["Line forward" gnus-summary-scroll-up t])
2726 ("Move"
2727 ["Next unread article" gnus-summary-next-unread-article t]
2728 ["Previous unread article" gnus-summary-prev-unread-article t]
2729 ["Next article" gnus-summary-next-article t]
2730 ["Previous article" gnus-summary-prev-article t]
2731 ["Next unread subject" gnus-summary-next-unread-subject t]
2732 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2733 ["Next article same subject" gnus-summary-next-same-subject t]
2734 ["Previous article same subject" gnus-summary-prev-same-subject t]
2735 ["First unread article" gnus-summary-first-unread-article t]
2736 ["Best unread article" gnus-summary-best-unread-article t]
2737 ["Go to subject number..." gnus-summary-goto-subject t]
2738 ["Go to article number..." gnus-summary-goto-article t]
2739 ["Go to the last article" gnus-summary-goto-last-article t]
2740 ["Pop article off history" gnus-summary-pop-article t])
2741 ("Sort"
2742 ["Sort by number" gnus-summary-sort-by-number t]
2743 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2744 ["Sort by author" gnus-summary-sort-by-author t]
2745 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2746 ["Sort by subject" gnus-summary-sort-by-subject t]
2747 ["Sort by date" gnus-summary-sort-by-date t]
2748 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2749 ["Sort by score" gnus-summary-sort-by-score t]
2750 ["Sort by lines" gnus-summary-sort-by-lines t]
2751 ["Sort by characters" gnus-summary-sort-by-chars t]
2752 ["Sort by marks" gnus-summary-sort-by-marks t]
2753 ["Randomize" gnus-summary-sort-by-random t]
2754 ["Original sort" gnus-summary-sort-by-original t])
2755 ("Help"
2756 ["Describe group" gnus-summary-describe-group t]
2757 ["Read manual" gnus-info-find-node t])
2758 ("Modes"
2759 ["Pick and read" gnus-pick-mode t]
2760 ["Binary" gnus-binary-mode t])
2761 ("Regeneration"
2762 ["Regenerate" gnus-summary-prepare t]
2763 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2764 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2765 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2766 ["Toggle threading" gnus-summary-toggle-threads t])
2767 ["See old articles" gnus-summary-insert-old-articles t]
2768 ["See new articles" gnus-summary-insert-new-articles t]
2769 ["Filter articles..." gnus-summary-execute-command t]
2770 ["Run command on articles..." gnus-summary-universal-argument t]
2771 ["Search articles forward..." gnus-summary-search-article-forward t]
2772 ["Search articles backward..." gnus-summary-search-article-backward t]
2773 ["Toggle line truncation" toggle-truncate-lines t]
2774 ["Expand window" gnus-summary-expand-window t]
2775 ["Expire expirable articles" gnus-summary-expire-articles
2776 (gnus-check-backend-function
2777 'request-expire-articles gnus-newsgroup-name)]
2778 ["Edit local kill file" gnus-summary-edit-local-kill t]
2779 ["Edit main kill file" gnus-summary-edit-global-kill t]
2780 ["Edit group parameters" gnus-summary-edit-parameters t]
2781 ["Customize group parameters" gnus-summary-customize-parameters t]
2782 ["Send a bug report" gnus-bug t]
2783 ("Exit"
2784 ["Catchup and exit" gnus-summary-catchup-and-exit
2785 :help "Mark unread articles in this group as read, then exit"]
2786 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2787 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2788 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2789 ["Exit group" gnus-summary-exit
2790 :help "Exit current group, return to group selection mode"]
2791 ["Exit group without updating" gnus-summary-exit-no-update t]
2792 ["Exit and goto next group" gnus-summary-next-group t]
2793 ["Exit and goto prev group" gnus-summary-prev-group t]
2794 ["Reselect group" gnus-summary-reselect-current-group t]
2795 ["Rescan group" gnus-summary-rescan-group t]
2796 ["Update dribble" gnus-summary-save-newsrc t])))
2798 (gnus-run-hooks 'gnus-summary-menu-hook)))
2800 (defvar gnus-summary-tool-bar-map nil)
2802 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2803 ;; affect _new_ message buffers. We might add a function that walks thru all
2804 ;; summary-mode buffers and force the update.
2805 (defun gnus-summary-tool-bar-update (&optional symbol value)
2806 "Update summary mode toolbar.
2807 Setter function for custom variables."
2808 (setq-default gnus-summary-tool-bar-map nil)
2809 (when symbol
2810 ;; When used as ":set" function:
2811 (set-default symbol value))
2812 (when (gnus-buffer-live-p gnus-summary-buffer)
2813 (with-current-buffer gnus-summary-buffer
2814 (gnus-summary-make-tool-bar))))
2816 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2817 'gnus-summary-tool-bar-gnome
2818 'gnus-summary-tool-bar-retro)
2819 "Specifies the Gnus summary tool bar.
2821 It can be either a list or a symbol referring to a list. See
2822 `gmm-tool-bar-from-list' for the format of the list. The
2823 default key map is `gnus-summary-mode-map'.
2825 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2826 `gnus-summary-tool-bar-retro'."
2827 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2828 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2829 (repeat :tag "User defined list" gmm-tool-bar-item)
2830 (symbol))
2831 :version "23.1" ;; No Gnus
2832 :initialize 'custom-initialize-default
2833 :set 'gnus-summary-tool-bar-update
2834 :group 'gnus-summary)
2836 (defcustom gnus-summary-tool-bar-gnome
2837 '((gnus-summary-post-news "mail/compose" nil)
2838 (gnus-summary-insert-new-articles "mail/inbox" nil
2839 :visible (or (not gnus-agent)
2840 gnus-plugged))
2841 (gnus-summary-reply-with-original "mail/reply")
2842 (gnus-summary-reply "mail/reply" nil :visible nil)
2843 (gnus-summary-followup-with-original "mail/reply-all")
2844 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2845 (gnus-summary-mail-forward "mail/forward")
2846 (gnus-summary-save-article "mail/save")
2847 (gnus-summary-search-article-forward "search" nil :visible nil)
2848 (gnus-summary-print-article "print")
2849 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2850 ;; Some new commands that may need more suitable icons:
2851 (gnus-summary-save-newsrc "save" nil :visible nil)
2852 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2853 (gnus-summary-prev-article "left-arrow")
2854 (gnus-summary-next-article "right-arrow")
2855 (gnus-summary-next-page "next-page")
2856 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2858 ;; Maybe some sort-by-... could be added:
2859 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2860 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2861 (gnus-summary-mark-as-expirable
2862 "delete" nil
2863 :visible (gnus-check-backend-function 'request-expire-articles
2864 gnus-newsgroup-name))
2865 (gnus-summary-mark-as-spam
2866 "mail/spam" t
2867 :visible (and (fboundp 'spam-group-ham-contents-p)
2868 (spam-group-ham-contents-p gnus-newsgroup-name))
2869 :help "Mark as spam")
2870 (gnus-summary-mark-as-read-forward
2871 "mail/not-spam" nil
2872 :visible (and (fboundp 'spam-group-spam-contents-p)
2873 (spam-group-spam-contents-p gnus-newsgroup-name)))
2875 (gnus-summary-exit "exit")
2876 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2877 (gnus-info-find-node "help"))
2878 "List of functions for the summary tool bar (GNOME style).
2880 See `gmm-tool-bar-from-list' for the format of the list."
2881 :type '(repeat gmm-tool-bar-item)
2882 :version "23.1" ;; No Gnus
2883 :initialize 'custom-initialize-default
2884 :set 'gnus-summary-tool-bar-update
2885 :group 'gnus-summary)
2887 (defcustom gnus-summary-tool-bar-retro
2888 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2889 (gnus-summary-next-unread-article "gnus/next-ur")
2890 (gnus-summary-post-news "gnus/post")
2891 (gnus-summary-followup-with-original "gnus/fuwo")
2892 (gnus-summary-followup "gnus/followup")
2893 (gnus-summary-reply-with-original "gnus/reply-wo")
2894 (gnus-summary-reply "gnus/reply")
2895 (gnus-summary-caesar-message "gnus/rot13")
2896 (gnus-uu-decode-uu "gnus/uu-decode")
2897 (gnus-summary-save-article-file "gnus/save-aif")
2898 (gnus-summary-save-article "gnus/save-art")
2899 (gnus-uu-post-news "gnus/uu-post")
2900 (gnus-summary-catchup "gnus/catchup")
2901 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2902 (gnus-summary-exit "gnus/exit-summ")
2903 ;; Some new command that may need more suitable icons:
2904 (gnus-summary-print-article "gnus/print" nil :visible nil)
2905 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2906 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2907 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2908 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2909 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2910 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2912 (gnus-info-find-node "gnus/help" nil :visible nil))
2913 "List of functions for the summary tool bar (retro look).
2915 See `gmm-tool-bar-from-list' for the format of the list."
2916 :type '(repeat gmm-tool-bar-item)
2917 :version "23.1" ;; No Gnus
2918 :initialize 'custom-initialize-default
2919 :set 'gnus-summary-tool-bar-update
2920 :group 'gnus-summary)
2922 (defcustom gnus-summary-tool-bar-zap-list t
2923 "List of icon items from the global tool bar.
2924 These items are not displayed in the Gnus summary mode tool bar.
2926 See `gmm-tool-bar-from-list' for the format of the list."
2927 :type 'gmm-tool-bar-zap-list
2928 :version "23.1" ;; No Gnus
2929 :initialize 'custom-initialize-default
2930 :set 'gnus-summary-tool-bar-update
2931 :group 'gnus-summary)
2933 (defvar image-load-path)
2934 (defvar tool-bar-map)
2936 (defun gnus-summary-make-tool-bar (&optional force)
2937 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2938 When FORCE, rebuild the tool bar."
2939 (when (and (boundp 'tool-bar-mode)
2940 tool-bar-mode
2941 (or (not gnus-summary-tool-bar-map) force))
2942 (let* ((load-path
2943 (image-load-path-for-library "gnus" "mail/save.xpm" nil t))
2944 (image-load-path (cons (car load-path) image-load-path))
2945 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2946 gnus-summary-tool-bar-zap-list
2947 'gnus-summary-mode-map)))
2948 (when map
2949 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2950 ;; uses its value.
2951 (setq gnus-summary-tool-bar-map map))))
2952 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2954 (defun gnus-make-score-map (type)
2955 "Make a summary score map of type TYPE."
2956 (if t
2958 (let ((headers '(("author" "from" string)
2959 ("subject" "subject" string)
2960 ("article body" "body" string)
2961 ("article head" "head" string)
2962 ("xref" "xref" string)
2963 ("extra header" "extra" string)
2964 ("lines" "lines" number)
2965 ("followups to author" "followup" string)))
2966 (types '((number ("less than" <)
2967 ("greater than" >)
2968 ("equal" =))
2969 (string ("substring" s)
2970 ("exact string" e)
2971 ("fuzzy string" f)
2972 ("regexp" r))))
2973 (perms '(("temporary" (current-time-string))
2974 ("permanent" nil)
2975 ("immediate" now)))
2976 header)
2977 (list
2978 (apply
2979 'nconc
2980 (list
2981 (if (eq type 'lower)
2982 "Lower score"
2983 "Increase score"))
2984 (let (outh)
2985 (while headers
2986 (setq header (car headers))
2987 (setq outh
2988 (cons
2989 (apply
2990 'nconc
2991 (list (car header))
2992 (let ((ts (cdr (assoc (nth 2 header) types)))
2993 outt)
2994 (while ts
2995 (setq outt
2996 (cons
2997 (apply
2998 'nconc
2999 (list (caar ts))
3000 (let ((ps perms)
3001 outp)
3002 (while ps
3003 (setq outp
3004 (cons
3005 (vector
3006 (caar ps)
3007 (list
3008 'gnus-summary-score-entry
3009 (nth 1 header)
3010 (if (or (string= (nth 1 header)
3011 "head")
3012 (string= (nth 1 header)
3013 "body"))
3015 (list 'gnus-summary-header
3016 (nth 1 header)))
3017 (list 'quote (nth 1 (car ts)))
3018 (list 'gnus-score-delta-default
3019 nil)
3020 (nth 1 (car ps))
3023 outp))
3024 (setq ps (cdr ps)))
3025 (list (nreverse outp))))
3026 outt))
3027 (setq ts (cdr ts)))
3028 (list (nreverse outt))))
3029 outh))
3030 (setq headers (cdr headers)))
3031 (list (nreverse outh))))))))
3034 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3035 (defvar bookmark-make-record-function)
3037 (defvar bidi-paragraph-direction)
3039 (defun gnus-summary-mode (&optional group)
3040 "Major mode for reading articles.
3042 All normal editing commands are switched off.
3043 \\<gnus-summary-mode-map>
3044 Each line in this buffer represents one article. To read an
3045 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3046 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3047 respectively.
3049 You can also post articles and send mail from this buffer. To
3050 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3051 of an article, type `\\[gnus-summary-reply]'.
3053 There are approx. one gazillion commands you can execute in this
3054 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3056 The following commands are available:
3058 \\{gnus-summary-mode-map}"
3059 ;; FIXME: Use define-derived-mode.
3060 (interactive)
3061 (kill-all-local-variables)
3062 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3063 (gnus-summary-make-local-variables))
3064 (gnus-summary-make-local-variables)
3065 (setq gnus-newsgroup-name group)
3066 (when (gnus-visual-p 'summary-menu 'menu)
3067 (gnus-summary-make-menu-bar)
3068 (gnus-summary-make-tool-bar))
3069 (gnus-make-thread-indent-array)
3070 (gnus-simplify-mode-line)
3071 (setq major-mode 'gnus-summary-mode)
3072 (setq mode-name "Summary")
3073 (use-local-map gnus-summary-mode-map)
3074 (buffer-disable-undo)
3075 (setq buffer-read-only t
3076 show-trailing-whitespace nil
3077 truncate-lines t
3078 bidi-paragraph-direction 'left-to-right)
3079 (add-to-invisibility-spec '(gnus-sum . t))
3080 (gnus-summary-set-display-table)
3081 (gnus-set-default-directory)
3082 (make-local-variable 'gnus-summary-line-format)
3083 (make-local-variable 'gnus-summary-line-format-spec)
3084 (make-local-variable 'gnus-summary-dummy-line-format)
3085 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3086 (make-local-variable 'gnus-summary-mark-positions)
3087 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3088 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3089 (turn-on-gnus-mailing-list-mode)
3090 (mm-enable-multibyte)
3091 (set (make-local-variable 'bookmark-make-record-function)
3092 'gnus-summary-bookmark-make-record)
3093 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3094 (gnus-update-summary-mark-positions))
3096 (defun gnus-summary-make-local-variables ()
3097 "Make all the local summary buffer variables."
3098 (let (global)
3099 (dolist (local gnus-summary-local-variables)
3100 (if (consp local)
3101 (progn
3102 (if (eq (cdr local) 'global)
3103 ;; Copy the global value of the variable.
3104 (setq global (symbol-value (car local)))
3105 ;; Use the value from the list.
3106 (setq global (eval (cdr local))))
3107 (set (make-local-variable (car local)) global))
3108 ;; Simple nil-valued local variable.
3109 (set (make-local-variable local) nil)))))
3111 ;; Summary data functions.
3113 (defmacro gnus-data-number (data)
3114 `(car ,data))
3116 (defmacro gnus-data-set-number (data number)
3117 `(setcar ,data ,number))
3119 (defmacro gnus-data-mark (data)
3120 `(nth 1 ,data))
3122 (defmacro gnus-data-set-mark (data mark)
3123 `(setcar (nthcdr 1 ,data) ,mark))
3125 (defmacro gnus-data-pos (data)
3126 `(nth 2 ,data))
3128 (defmacro gnus-data-set-pos (data pos)
3129 `(setcar (nthcdr 2 ,data) ,pos))
3131 (defmacro gnus-data-header (data)
3132 `(nth 3 ,data))
3134 (defmacro gnus-data-set-header (data header)
3135 `(setf (nth 3 ,data) ,header))
3137 (defmacro gnus-data-level (data)
3138 `(nth 4 ,data))
3140 (defmacro gnus-data-unread-p (data)
3141 `(= (nth 1 ,data) gnus-unread-mark))
3143 (defmacro gnus-data-read-p (data)
3144 `(/= (nth 1 ,data) gnus-unread-mark))
3146 (defmacro gnus-data-pseudo-p (data)
3147 `(consp (nth 3 ,data)))
3149 (defmacro gnus-data-find (number)
3150 `(assq ,number gnus-newsgroup-data))
3152 (defmacro gnus-data-find-list (number &optional data)
3153 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3154 (memq (assq ,number bdata)
3155 bdata)))
3157 (defmacro gnus-data-make (number mark pos header level)
3158 `(list ,number ,mark ,pos ,header ,level))
3160 (defun gnus-data-enter (after-article number mark pos header level offset)
3161 (let ((data (gnus-data-find-list after-article)))
3162 (unless data
3163 (error "No such article: %d" after-article))
3164 (setcdr data (cons (gnus-data-make number mark pos header level)
3165 (cdr data)))
3166 (setq gnus-newsgroup-data-reverse nil)
3167 (gnus-data-update-list (cddr data) offset)))
3169 (defun gnus-data-enter-list (after-article list &optional offset)
3170 (when list
3171 (let ((data (and after-article (gnus-data-find-list after-article)))
3172 (ilist list))
3173 (if (not (or data
3174 after-article))
3175 (let ((odata gnus-newsgroup-data))
3176 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3177 (when offset
3178 (gnus-data-update-list odata offset)))
3179 ;; Find the last element in the list to be spliced into the main
3180 ;; list.
3181 (setq list (last list))
3182 (if (not data)
3183 (progn
3184 (setcdr list gnus-newsgroup-data)
3185 (setq gnus-newsgroup-data ilist)
3186 (when offset
3187 (gnus-data-update-list (cdr list) offset)))
3188 (setcdr list (cdr data))
3189 (setcdr data ilist)
3190 (when offset
3191 (gnus-data-update-list (cdr list) offset))))
3192 (setq gnus-newsgroup-data-reverse nil))))
3194 (defun gnus-data-remove (article &optional offset)
3195 (let ((data gnus-newsgroup-data))
3196 (if (= (gnus-data-number (car data)) article)
3197 (progn
3198 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3199 gnus-newsgroup-data-reverse nil)
3200 (when offset
3201 (gnus-data-update-list gnus-newsgroup-data offset)))
3202 (while (cdr data)
3203 (when (= (gnus-data-number (cadr data)) article)
3204 (setcdr data (cddr data))
3205 (when offset
3206 (gnus-data-update-list (cdr data) offset))
3207 (setq data nil
3208 gnus-newsgroup-data-reverse nil))
3209 (setq data (cdr data))))))
3211 (defmacro gnus-data-list (backward)
3212 `(if ,backward
3213 (or gnus-newsgroup-data-reverse
3214 (setq gnus-newsgroup-data-reverse
3215 (reverse gnus-newsgroup-data)))
3216 gnus-newsgroup-data))
3218 (defun gnus-data-update-list (data offset)
3219 "Add OFFSET to the POS of all data entries in DATA."
3220 (setq gnus-newsgroup-data-reverse nil)
3221 (while data
3222 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3223 (setq data (cdr data))))
3225 (defun gnus-summary-article-pseudo-p (article)
3226 "Say whether this article is a pseudo article or not."
3227 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3229 (defmacro gnus-summary-article-sparse-p (article)
3230 "Say whether this article is a sparse article or not."
3231 `(memq ,article gnus-newsgroup-sparse))
3233 (defmacro gnus-summary-article-ancient-p (article)
3234 "Say whether this article is a sparse article or not."
3235 `(memq ,article gnus-newsgroup-ancient))
3237 (defun gnus-article-children (number)
3238 "Return a list of all children to NUMBER."
3239 (let* ((data (gnus-data-find-list number))
3240 (level (gnus-data-level (car data)))
3241 children)
3242 (setq data (cdr data))
3243 (while (and data
3244 (= (gnus-data-level (car data)) (1+ level)))
3245 (push (gnus-data-number (car data)) children)
3246 (setq data (cdr data)))
3247 children))
3249 (defmacro gnus-summary-skip-intangible ()
3250 "If the current article is intangible, then jump to a different article."
3251 '(let ((to (get-text-property (point) 'gnus-intangible)))
3252 (and to (gnus-summary-goto-subject to))))
3254 (defmacro gnus-summary-article-intangible-p ()
3255 "Say whether this article is intangible or not."
3256 '(get-text-property (point) 'gnus-intangible))
3258 ;; Some summary mode macros.
3260 (defmacro gnus-summary-article-number ()
3261 "The article number of the article on the current line.
3262 If there isn't an article number here, then we return the current
3263 article number."
3264 '(progn
3265 (gnus-summary-skip-intangible)
3266 (or (get-text-property (point) 'gnus-number)
3267 (gnus-summary-last-subject))))
3269 (defmacro gnus-summary-article-header (&optional number)
3270 "Return the header of article NUMBER."
3271 `(gnus-data-header (gnus-data-find
3272 ,(or number '(gnus-summary-article-number)))))
3274 (defmacro gnus-summary-thread-level (&optional number)
3275 "Return the level of thread that starts with article NUMBER."
3276 `(if (and (eq gnus-summary-make-false-root 'dummy)
3277 (get-text-property (point) 'gnus-intangible))
3279 (gnus-data-level (gnus-data-find
3280 ,(or number '(gnus-summary-article-number))))))
3282 (defmacro gnus-summary-article-mark (&optional number)
3283 "Return the mark of article NUMBER."
3284 `(gnus-data-mark (gnus-data-find
3285 ,(or number '(gnus-summary-article-number)))))
3287 (defmacro gnus-summary-article-pos (&optional number)
3288 "Return the position of the line of article NUMBER."
3289 `(gnus-data-pos (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3292 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3293 (defmacro gnus-summary-article-subject (&optional number)
3294 "Return current subject string or nil if nothing."
3295 `(let ((headers
3296 ,(if number
3297 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3298 '(gnus-data-header (assq (gnus-summary-article-number)
3299 gnus-newsgroup-data)))))
3300 (and headers
3301 (vectorp headers)
3302 (mail-header-subject headers))))
3304 (defmacro gnus-summary-article-score (&optional number)
3305 "Return current article score."
3306 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3307 gnus-newsgroup-scored))
3308 gnus-summary-default-score 0))
3310 (defun gnus-summary-article-children (&optional number)
3311 "Return a list of article numbers that are children of article NUMBER."
3312 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3313 (level (gnus-data-level (car data)))
3314 l children)
3315 (while (and (setq data (cdr data))
3316 (> (setq l (gnus-data-level (car data))) level))
3317 (and (= (1+ level) l)
3318 (push (gnus-data-number (car data))
3319 children)))
3320 (nreverse children)))
3322 (defun gnus-summary-article-parent (&optional number)
3323 "Return the article number of the parent of article NUMBER."
3324 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3325 (gnus-data-list t)))
3326 (level (gnus-data-level (car data))))
3327 (if (zerop level)
3328 () ; This is a root.
3329 ;; We search until we find an article with a level less than
3330 ;; this one. That function has to be the parent.
3331 (while (and (setq data (cdr data))
3332 (not (< (gnus-data-level (car data)) level))))
3333 (and data (gnus-data-number (car data))))))
3335 (defun gnus-unread-mark-p (mark)
3336 "Say whether MARK is the unread mark."
3337 (= mark gnus-unread-mark))
3339 (defun gnus-read-mark-p (mark)
3340 "Say whether MARK is one of the marks that mark as read.
3341 This is all marks except unread, ticked, dormant, and expirable."
3342 (not (or (= mark gnus-unread-mark)
3343 (= mark gnus-ticked-mark)
3344 (= mark gnus-spam-mark)
3345 (= mark gnus-dormant-mark)
3346 (= mark gnus-expirable-mark))))
3348 (defmacro gnus-article-mark (number)
3349 "Return the MARK of article NUMBER.
3350 This macro should only be used when computing the mark the \"first\"
3351 time; i.e., when generating the summary lines. After that,
3352 `gnus-summary-article-mark' should be used to examine the
3353 marks of articles."
3354 `(cond
3355 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3356 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3357 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3358 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3359 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3360 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3361 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3362 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3363 gnus-ancient-mark))))
3365 ;; Saving hidden threads.
3367 (defmacro gnus-save-hidden-threads (&rest forms)
3368 "Save hidden threads, eval FORMS, and restore the hidden threads."
3369 (let ((config (make-symbol "config")))
3370 `(let ((,config (gnus-hidden-threads-configuration)))
3371 (unwind-protect
3372 (save-excursion
3373 ,@forms)
3374 (gnus-restore-hidden-threads-configuration ,config)))))
3375 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3376 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3378 (defun gnus-data-compute-positions ()
3379 "Compute the positions of all articles."
3380 (setq gnus-newsgroup-data-reverse nil)
3381 (let ((data gnus-newsgroup-data))
3382 (save-excursion
3383 (gnus-save-hidden-threads
3384 (gnus-summary-show-all-threads)
3385 (goto-char (point-min))
3386 (while data
3387 (while (get-text-property (point) 'gnus-intangible)
3388 (forward-line 1))
3389 (gnus-data-set-pos (car data) (+ (point) 3))
3390 (setq data (cdr data))
3391 (forward-line 1))))))
3393 (defun gnus-hidden-threads-configuration ()
3394 "Return the current hidden threads configuration."
3395 (save-excursion
3396 (let (config)
3397 (goto-char (point-min))
3398 (while (not (eobp))
3399 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3400 (push (save-excursion (forward-line 0) (point)) config))
3401 (forward-line 1))
3402 config)))
3404 (defun gnus-restore-hidden-threads-configuration (config)
3405 "Restore hidden threads configuration from CONFIG."
3406 (save-excursion
3407 (let (point (inhibit-read-only t))
3408 (while (setq point (pop config))
3409 (goto-char point)
3410 (gnus-summary-hide-thread)))))
3412 ;; Various summary mode internalish functions.
3414 (defun gnus-mouse-pick-article (e)
3415 (interactive "e")
3416 (mouse-set-point e)
3417 (gnus-summary-next-page nil t))
3419 (defun gnus-summary-set-display-table ()
3420 "Change the display table.
3421 Odd characters have a tendency to mess
3422 up nicely formatted displays - we make all possible glyphs
3423 display only a single character."
3425 ;; We start from the standard display table, if any.
3426 (let ((table (or (copy-sequence standard-display-table)
3427 (make-display-table)))
3428 (i 32))
3429 ;; Nix out all the control chars...
3430 (while (>= (setq i (1- i)) 0)
3431 (aset table i [??]))
3432 ;; ... but not newline and cr, of course. (cr is necessary for the
3433 ;; selective display).
3434 (aset table ?\n nil)
3435 (aset table ?\r nil)
3436 ;; We keep TAB as well.
3437 (aset table ?\t nil)
3438 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3439 ;; Emacs 23 (unicode), that are not set already.
3440 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3442 256)))
3443 (while (>= (setq i (1- i)) 127)
3444 ;; Only modify if the entry is nil.
3445 (unless (aref table i)
3446 (aset table i [??]))))
3447 (setq buffer-display-table table)))
3449 (defun gnus-summary-set-article-display-arrow (pos)
3450 "Update the overlay arrow to point to line at position POS."
3451 (when gnus-summary-display-arrow
3452 (make-local-variable 'overlay-arrow-position)
3453 (make-local-variable 'overlay-arrow-string)
3454 (save-excursion
3455 (goto-char pos)
3456 (beginning-of-line)
3457 (unless overlay-arrow-position
3458 (setq overlay-arrow-position (make-marker)))
3459 (setq overlay-arrow-string "=>"
3460 overlay-arrow-position (set-marker overlay-arrow-position
3461 (point)
3462 (current-buffer))))))
3464 (defun gnus-summary-setup-buffer (group)
3465 "Initialize summary buffer.
3466 If the setup was successful, non-nil is returned."
3467 (let ((buffer (gnus-summary-buffer-name group))
3468 (dead-name (concat "*Dead Summary "
3469 (gnus-group-decoded-name group) "*")))
3470 ;; If a dead summary buffer exists, we kill it.
3471 (when (gnus-buffer-live-p dead-name)
3472 (gnus-kill-buffer dead-name))
3473 (if (get-buffer buffer)
3474 (progn
3475 (set-buffer buffer)
3476 (setq gnus-summary-buffer (current-buffer))
3477 (not gnus-newsgroup-prepared))
3478 (set-buffer (gnus-get-buffer-create buffer))
3479 (setq gnus-summary-buffer (current-buffer))
3480 (gnus-summary-mode group)
3481 (when (gnus-group-quit-config group)
3482 (set (make-local-variable 'gnus-single-article-buffer) nil))
3483 (make-local-variable 'gnus-article-buffer)
3484 (make-local-variable 'gnus-article-current)
3485 (make-local-variable 'gnus-original-article-buffer)
3486 (setq gnus-newsgroup-name group)
3487 ;; Set any local variables in the group parameters.
3488 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3489 t)))
3491 (defun gnus-set-global-variables ()
3492 "Set the global equivalents of the buffer-local variables.
3493 They are set to the latest values they had. These reflect the summary
3494 buffer that was in action when the last article was fetched."
3495 (when (derived-mode-p 'gnus-summary-mode)
3496 (setq gnus-summary-buffer (current-buffer))
3497 (let ((name gnus-newsgroup-name)
3498 (marked gnus-newsgroup-marked)
3499 (spam gnus-newsgroup-spam-marked)
3500 (unread gnus-newsgroup-unreads)
3501 (headers gnus-current-headers)
3502 (data gnus-newsgroup-data)
3503 (summary gnus-summary-buffer)
3504 (article-buffer gnus-article-buffer)
3505 (original gnus-original-article-buffer)
3506 (gac gnus-article-current)
3507 (reffed gnus-reffed-article-number)
3508 (score-file gnus-current-score-file)
3509 (default-charset gnus-newsgroup-charset)
3510 vlist)
3511 (let ((locals gnus-newsgroup-variables))
3512 (while locals
3513 (if (consp (car locals))
3514 (push (eval (caar locals)) vlist)
3515 (push (eval (car locals)) vlist))
3516 (setq locals (cdr locals)))
3517 (setq vlist (nreverse vlist)))
3518 (with-temp-buffer
3519 (setq gnus-newsgroup-name name
3520 gnus-newsgroup-marked marked
3521 gnus-newsgroup-spam-marked spam
3522 gnus-newsgroup-unreads unread
3523 gnus-current-headers headers
3524 gnus-newsgroup-data data
3525 gnus-article-current gac
3526 gnus-summary-buffer summary
3527 gnus-article-buffer article-buffer
3528 gnus-original-article-buffer original
3529 gnus-reffed-article-number reffed
3530 gnus-current-score-file score-file
3531 gnus-newsgroup-charset default-charset)
3532 (let ((locals gnus-newsgroup-variables))
3533 (while locals
3534 (if (consp (car locals))
3535 (set (caar locals) (pop vlist))
3536 (set (car locals) (pop vlist)))
3537 (setq locals (cdr locals))))))))
3539 (defun gnus-summary-article-unread-p (article)
3540 "Say whether ARTICLE is unread or not."
3541 (memq article gnus-newsgroup-unreads))
3543 (defun gnus-summary-first-article-p (&optional article)
3544 "Return whether ARTICLE is the first article in the buffer."
3545 (if (not (setq article (or article (gnus-summary-article-number))))
3547 (eq article (caar gnus-newsgroup-data))))
3549 (defun gnus-summary-last-article-p (&optional article)
3550 "Return whether ARTICLE is the last article in the buffer."
3551 (if (not (setq article (or article (gnus-summary-article-number))))
3552 ;; All non-existent numbers are the last article. :-)
3554 (not (cdr (gnus-data-find-list article)))))
3556 (defun gnus-make-thread-indent-array (&optional n)
3557 (when (or n
3558 (progn (setq n 200) nil)
3559 (null gnus-thread-indent-array)
3560 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3561 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3562 gnus-thread-indent-array-level gnus-thread-indent-level)
3563 (while (>= n 0)
3564 (aset gnus-thread-indent-array n
3565 (make-string (* n gnus-thread-indent-level) ? ))
3566 (setq n (1- n)))))
3568 (defun gnus-update-summary-mark-positions ()
3569 "Compute where the summary marks are to go."
3570 (save-excursion
3571 (when (gnus-buffer-exists-p gnus-summary-buffer)
3572 (set-buffer gnus-summary-buffer))
3573 (let ((spec gnus-summary-line-format-spec)
3574 pos)
3575 (save-excursion
3576 (gnus-set-work-buffer)
3577 (let ((gnus-tmp-unread ?Z)
3578 (gnus-replied-mark ?Z)
3579 (gnus-score-below-mark ?Z)
3580 (gnus-score-over-mark ?Z)
3581 (gnus-undownloaded-mark ?Z)
3582 (gnus-summary-line-format-spec spec)
3583 (gnus-newsgroup-downloadable '(0))
3584 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3585 case-fold-search ignores)
3586 ;; Here, all marks are bound to Z.
3587 (gnus-summary-insert-line header
3588 0 nil t gnus-tmp-unread t nil "" nil 1)
3589 (goto-char (point-min))
3590 ;; Memorize the positions of the same characters as dummy marks.
3591 (while (re-search-forward "[A-D]" nil t)
3592 (push (point) ignores))
3593 (erase-buffer)
3594 ;; We use A-D as dummy marks in order to know column positions
3595 ;; where marks should be inserted.
3596 (setq gnus-tmp-unread ?A
3597 gnus-replied-mark ?B
3598 gnus-score-below-mark ?C
3599 gnus-score-over-mark ?C
3600 gnus-undownloaded-mark ?D)
3601 (gnus-summary-insert-line header
3602 0 nil t gnus-tmp-unread t nil "" nil 1)
3603 ;; Ignore characters which aren't dummy marks.
3604 (dolist (p ignores)
3605 (delete-region (goto-char (1- p)) p)
3606 (insert ?Z))
3607 (goto-char (point-min))
3608 (setq pos (list (cons 'unread
3609 (and (search-forward "A" nil t)
3610 (- (point) (point-min) 1)))))
3611 (goto-char (point-min))
3612 (push (cons 'replied (and (search-forward "B" nil t)
3613 (- (point) (point-min) 1)))
3614 pos)
3615 (goto-char (point-min))
3616 (push (cons 'score (and (search-forward "C" nil t)
3617 (- (point) (point-min) 1)))
3618 pos)
3619 (goto-char (point-min))
3620 (push (cons 'download (and (search-forward "D" nil t)
3621 (- (point) (point-min) 1)))
3622 pos)))
3623 (setq gnus-summary-mark-positions pos))))
3625 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3626 "Insert a dummy root in the summary buffer."
3627 (beginning-of-line)
3628 (add-text-properties
3629 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3630 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3632 (defun gnus-summary-extract-address-component (from)
3633 (or (car (funcall gnus-extract-address-components from))
3634 from))
3636 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3637 (let ((mail-parse-charset gnus-newsgroup-charset)
3638 ;; Is it really necessary to do this next part for each summary line?
3639 ;; Luckily, doesn't seem to slow things down much.
3640 (mail-parse-ignored-charsets
3641 (with-current-buffer gnus-summary-buffer
3642 gnus-newsgroup-ignored-charsets)))
3644 (and gnus-ignored-from-addresses
3645 (cond ((functionp gnus-ignored-from-addresses)
3646 (funcall gnus-ignored-from-addresses
3647 (mail-strip-quoted-names gnus-tmp-from)))
3648 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3649 (let ((extra-headers (mail-header-extra header))
3651 newsgroups)
3652 (cond
3653 ((setq to (cdr (assq 'To extra-headers)))
3654 (concat gnus-summary-to-prefix
3655 (inline
3656 (gnus-summary-extract-address-component
3657 (funcall gnus-decode-encoded-address-function to)))))
3658 ((setq newsgroups
3660 (cdr (assq 'Newsgroups extra-headers))
3661 (and
3662 (memq 'Newsgroups gnus-extra-headers)
3663 (eq (car (gnus-find-method-for-group
3664 gnus-newsgroup-name)) 'nntp)
3665 (gnus-group-real-name gnus-newsgroup-name))))
3666 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3667 (bidi-string-mark-left-to-right
3668 (inline
3669 (gnus-summary-extract-address-component gnus-tmp-from))))))
3671 (defun gnus-summary-insert-line (gnus-tmp-header
3672 gnus-tmp-level gnus-tmp-current
3673 undownloaded gnus-tmp-unread gnus-tmp-replied
3674 gnus-tmp-expirable gnus-tmp-subject-or-nil
3675 &optional gnus-tmp-dummy gnus-tmp-score
3676 gnus-tmp-process)
3677 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3678 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3679 gnus-tmp-level)))
3680 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3681 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3682 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3683 (gnus-tmp-score-char
3684 (if (or (null gnus-summary-default-score)
3685 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3686 gnus-summary-zcore-fuzz))
3687 ? ;Whitespace
3688 (if (< gnus-tmp-score gnus-summary-default-score)
3689 gnus-score-below-mark gnus-score-over-mark)))
3690 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3691 (gnus-tmp-replied
3692 (cond (gnus-tmp-process gnus-process-mark)
3693 ((memq gnus-tmp-current gnus-newsgroup-cached)
3694 gnus-cached-mark)
3695 (gnus-tmp-replied gnus-replied-mark)
3696 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3697 gnus-forwarded-mark)
3698 ((memq gnus-tmp-current gnus-newsgroup-saved)
3699 gnus-saved-mark)
3700 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3701 gnus-unseen-mark)
3702 (t gnus-no-mark)))
3703 (gnus-tmp-downloaded
3704 (cond (undownloaded
3705 gnus-undownloaded-mark)
3706 (gnus-newsgroup-agentized
3707 gnus-downloaded-mark)
3709 gnus-no-mark)))
3710 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3711 (gnus-tmp-name
3712 (cond
3713 ((string-match "<[^>]+> *$" gnus-tmp-from)
3714 (let ((beg (match-beginning 0)))
3715 (or (and (string-match "^\".+\"" gnus-tmp-from)
3716 (substring gnus-tmp-from 1 (1- (match-end 0))))
3717 (substring gnus-tmp-from 0 beg))))
3718 ((string-match "(.+)" gnus-tmp-from)
3719 (substring gnus-tmp-from
3720 (1+ (match-beginning 0)) (1- (match-end 0))))
3721 (t gnus-tmp-from)))
3722 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3723 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3724 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3725 (inhibit-read-only t))
3726 (when (string= gnus-tmp-name "")
3727 (setq gnus-tmp-name gnus-tmp-from))
3728 (unless (numberp gnus-tmp-lines)
3729 (setq gnus-tmp-lines -1))
3730 (if (= gnus-tmp-lines -1)
3731 (setq gnus-tmp-lines "?")
3732 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3733 (condition-case ()
3734 (put-text-property
3735 (point)
3736 (progn (eval gnus-summary-line-format-spec) (point))
3737 'gnus-number gnus-tmp-number)
3738 (error (gnus-message 5 "Error updating the summary line")))
3739 (when (gnus-visual-p 'summary-highlight 'highlight)
3740 (forward-line -1)
3741 (gnus-summary-highlight-line)
3742 (gnus-run-hooks 'gnus-summary-update-hook)
3743 (forward-line 1))))
3745 (defun gnus-summary-update-line (&optional dont-update)
3746 "Update summary line after change."
3747 (when (and gnus-summary-default-score
3748 (not gnus-summary-inhibit-highlight))
3749 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3750 (article (gnus-summary-article-number))
3751 (score (gnus-summary-article-score article)))
3752 (unless dont-update
3753 (if (and gnus-summary-mark-below
3754 (< (gnus-summary-article-score)
3755 gnus-summary-mark-below))
3756 ;; This article has a low score, so we mark it as read.
3757 (when (memq article gnus-newsgroup-unreads)
3758 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3759 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3760 ;; This article was previously marked as read on account
3761 ;; of a low score, but now it has risen, so we mark it as
3762 ;; unread.
3763 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3764 (gnus-summary-update-mark
3765 (if (or (null gnus-summary-default-score)
3766 (<= (abs (- score gnus-summary-default-score))
3767 gnus-summary-zcore-fuzz))
3768 ? ;Whitespace
3769 (if (< score gnus-summary-default-score)
3770 gnus-score-below-mark gnus-score-over-mark))
3771 'score))
3772 ;; Do visual highlighting.
3773 (when (gnus-visual-p 'summary-highlight 'highlight)
3774 (gnus-summary-highlight-line)
3775 (gnus-run-hooks 'gnus-summary-update-hook)))))
3777 (defvar gnus-tmp-new-adopts nil)
3779 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3780 "Return the number of articles in THREAD.
3781 This may be 0 in some cases -- if none of the articles in
3782 the thread are to be displayed."
3783 (let* ((number
3784 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3785 (cond
3786 ((not (listp thread))
3788 ((and (consp thread) (cdr thread))
3789 (apply
3790 '+ 1 (mapcar
3791 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3792 ((null thread)
3794 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3796 (t 0))))
3797 (when (and level (zerop level) gnus-tmp-new-adopts)
3798 (incf number
3799 (apply '+ (mapcar
3800 'gnus-summary-number-of-articles-in-thread
3801 gnus-tmp-new-adopts))))
3802 (if char
3803 (if (> number 1) gnus-not-empty-thread-mark
3804 gnus-empty-thread-mark)
3805 number)))
3807 (defsubst gnus-summary-line-message-size (head)
3808 "Return pretty-printed version of message size.
3809 This function is intended to be used in
3810 `gnus-summary-line-format-alist'."
3811 (let ((c (or (mail-header-chars head) -1)))
3812 (cond ((< c 0) "n/a") ; chars not available
3813 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3814 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3815 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3816 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3818 (defcustom gnus-user-date-format-alist
3819 '(((gnus-seconds-today) . "Today, %H:%M")
3820 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3821 (604800 . "%A %H:%M") ; That's one week
3822 ((gnus-seconds-month) . "%A %d")
3823 ((gnus-seconds-year) . "%B %d")
3824 (t . "%b %d %Y")) ; This one is used when no other
3825 ; does match
3826 "Specifies date format depending on age of article.
3827 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3828 seconds) or a Lisp expression evaluating to a number. When the age of
3829 the article is less than this number, then use `format-time-string'
3830 with the corresponding FORMAT for displaying the date of the article.
3831 If AGE is not a number or a Lisp expression evaluating to a
3832 non-number, then the corresponding FORMAT is used as a default value.
3834 Note that the list is processed from the beginning, so it should be
3835 sorted by ascending AGE. Also note that items following the first
3836 non-number AGE will be ignored.
3838 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3839 and `gnus-seconds-year' in the AGE spec. They return the number of
3840 seconds passed since the start of today, of this month, of this year,
3841 respectively."
3842 :version "24.1"
3843 :group 'gnus-summary-format
3844 :type '(alist :key-type sexp :value-type string))
3846 (defun gnus-user-date (messy-date)
3847 "Format the messy-date according to `gnus-user-date-format-alist'.
3848 Returns \" ? \" if there's bad input or if another error occurs.
3849 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3850 (condition-case ()
3851 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3852 (now (float-time))
3853 ;;If we don't find something suitable we'll use this one
3854 (my-format "%b %d '%y"))
3855 (let* ((difference (- now messy-date))
3856 (templist gnus-user-date-format-alist)
3857 (top (eval (caar templist))))
3858 (while (if (numberp top) (< top difference) (not top))
3859 (progn
3860 (setq templist (cdr templist))
3861 (setq top (eval (caar templist)))))
3862 (if (stringp (cdr (car templist)))
3863 (setq my-format (cdr (car templist)))))
3864 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3865 (error " ? ")))
3867 (defun gnus-summary-set-local-parameters (group)
3868 "Go through the local params of GROUP and set all variable specs in that list."
3869 (let ((vars '(quit-config active))) ; Ignore things that aren't
3870 ; really variables.
3871 (dolist (elem (gnus-group-find-parameter group))
3872 (and (consp elem) ; Has to be a cons.
3873 (consp (cdr elem)) ; The cdr has to be a list.
3874 (symbolp (car elem)) ; Has to be a symbol in there.
3875 (not (memq (car elem) vars))
3876 (ignore-errors
3877 (push (car elem) vars)
3878 ;; Variables like `gnus-show-threads' that are globally
3879 ;; bound, if used as group parameters, need to get to be
3880 ;; buffer-local, whereas just parameters like `gcc-self',
3881 ;; `timestamp', etc. should not be bound as variables.
3882 (if (boundp (car elem))
3883 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3884 (eval (nth 1 elem))))))))
3886 (defun gnus-summary-read-group (group &optional show-all no-article
3887 kill-buffer no-display backward
3888 select-articles)
3889 "Start reading news in newsgroup GROUP.
3890 If SHOW-ALL is non-nil, already read articles are also listed.
3891 If NO-ARTICLE is non-nil, no article is selected initially.
3892 If NO-DISPLAY, don't generate the summary buffer contents.
3893 If KILL-BUFFER, it should be a buffer that's killed once the new
3894 summary buffer has been generated.
3895 If BACKWARD, move point to the previous group in the group buffer
3896 If SELECT-ARTICLES, only select those articles from GROUP."
3897 (let (result)
3898 (while (and group
3899 (null (setq result
3900 (let ((gnus-auto-select-next nil))
3901 (or (gnus-summary-read-group-1
3902 group show-all no-article
3903 kill-buffer no-display
3904 select-articles)
3905 (setq show-all nil
3906 select-articles nil)))))
3907 (eq gnus-auto-select-next 'quietly))
3908 (set-buffer gnus-group-buffer)
3909 ;; The entry function called above goes to the next
3910 ;; group automatically, so we go two groups back
3911 ;; if we are searching for the previous group.
3912 (when backward
3913 (gnus-group-prev-unread-group 2))
3914 (if (not (equal group (gnus-group-group-name)))
3915 (setq group (gnus-group-group-name))
3916 (setq group nil)))
3917 result))
3919 (defun gnus-summary-read-group-1 (group show-all no-article
3920 kill-buffer no-display
3921 &optional select-articles)
3922 ;; Killed foreign groups can't be entered.
3923 ;; (when (and (not (gnus-group-native-p group))
3924 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3925 ;; (error "Dead non-native groups can't be entered"))
3926 (gnus-message 7 "Retrieving newsgroup: %s..."
3927 (gnus-group-decoded-name group))
3928 (let* ((new-group (gnus-summary-setup-buffer group))
3929 (quit-config (gnus-group-quit-config group))
3930 (did-select (and new-group (gnus-select-newsgroup
3931 group show-all select-articles))))
3932 (cond
3933 ;; This summary buffer exists already, so we just select it.
3934 ((not new-group)
3935 (gnus-set-global-variables)
3936 (when kill-buffer
3937 (gnus-kill-or-deaden-summary kill-buffer))
3938 (gnus-configure-windows 'summary 'force)
3939 (gnus-set-mode-line 'summary)
3940 (gnus-summary-position-point)
3941 (message "")
3943 ;; We couldn't select this group.
3944 ((null did-select)
3945 (when (and (derived-mode-p 'gnus-summary-mode)
3946 (not (equal (current-buffer) kill-buffer)))
3947 (kill-buffer (current-buffer))
3948 (if (not quit-config)
3949 (progn
3950 ;; Update the info -- marks might need to be removed,
3951 ;; for instance.
3952 (gnus-summary-update-info)
3953 (set-buffer gnus-group-buffer)
3954 (gnus-group-jump-to-group group)
3955 (gnus-group-next-unread-group 1))
3956 (gnus-handle-ephemeral-exit quit-config)))
3957 (if (null (gnus-list-of-unread-articles group))
3958 (gnus-message 3 "Group %s contains no messages"
3959 (gnus-group-decoded-name group))
3960 (gnus-message 3 "Can't select group"))
3961 nil)
3962 ;; The user did a `C-g' while prompting for number of articles,
3963 ;; so we exit this group.
3964 ((eq did-select 'quit)
3965 (and (derived-mode-p 'gnus-summary-mode)
3966 (not (equal (current-buffer) kill-buffer))
3967 (kill-buffer (current-buffer)))
3968 (when kill-buffer
3969 (gnus-kill-or-deaden-summary kill-buffer))
3970 (if (not quit-config)
3971 (progn
3972 (set-buffer gnus-group-buffer)
3973 (gnus-group-jump-to-group group)
3974 (gnus-configure-windows 'group 'force))
3975 (gnus-handle-ephemeral-exit quit-config))
3976 ;; Finally signal the quit.
3977 (signal 'quit nil))
3978 ;; The group was successfully selected.
3980 (gnus-set-global-variables)
3981 (when (boundp 'gnus-pick-line-number)
3982 (setq gnus-pick-line-number 0))
3983 (when (boundp 'spam-install-hooks)
3984 (spam-initialize))
3985 ;; Save the active value in effect when the group was entered.
3986 (setq gnus-newsgroup-active
3987 (gnus-copy-sequence
3988 (gnus-active gnus-newsgroup-name)))
3989 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3990 ;; You can change the summary buffer in some way with this hook.
3991 (gnus-run-hooks 'gnus-select-group-hook)
3992 (when (memq 'summary (gnus-update-format-specifications
3993 nil 'summary 'summary-mode 'summary-dummy))
3994 ;; The format specification for the summary line was updated,
3995 ;; so we need to update the mark positions as well.
3996 (gnus-update-summary-mark-positions))
3997 ;; Do score processing.
3998 (when gnus-use-scoring
3999 (gnus-possibly-score-headers))
4000 ;; Check whether to fill in the gaps in the threads.
4001 (when gnus-build-sparse-threads
4002 (gnus-build-sparse-threads))
4003 ;; Find the initial limit.
4004 (if show-all
4005 (let ((gnus-newsgroup-dormant nil))
4006 (gnus-summary-initial-limit show-all))
4007 (gnus-summary-initial-limit show-all))
4008 ;; Generate the summary buffer.
4009 (unless no-display
4010 (gnus-summary-prepare))
4011 (when gnus-use-trees
4012 (gnus-tree-open)
4013 (setq gnus-summary-highlight-line-function
4014 'gnus-tree-highlight-article))
4015 ;; If the summary buffer is empty, but there are some low-scored
4016 ;; articles or some excluded dormants, we include these in the
4017 ;; buffer.
4018 (when (and (zerop (buffer-size))
4019 (not no-display))
4020 (cond (gnus-newsgroup-dormant
4021 (gnus-summary-limit-include-dormant))
4022 ((and gnus-newsgroup-scored show-all)
4023 (gnus-summary-limit-include-expunged t))))
4024 ;; Function `gnus-apply-kill-file' must be called in this hook.
4025 (gnus-run-hooks 'gnus-apply-kill-hook)
4026 (if (and (zerop (buffer-size))
4027 (not no-display))
4028 (progn
4029 ;; This newsgroup is empty.
4030 (gnus-summary-catchup-and-exit nil t)
4031 (gnus-message 6 "No unread news")
4032 (when kill-buffer
4033 (gnus-kill-or-deaden-summary kill-buffer))
4034 ;; Return nil from this function.
4035 nil)
4036 ;; Hide conversation thread subtrees. We cannot do this in
4037 ;; gnus-summary-prepare-hook since kill processing may not
4038 ;; work with hidden articles.
4039 (gnus-summary-maybe-hide-threads)
4040 (gnus-configure-windows 'summary)
4041 (when kill-buffer
4042 (gnus-kill-or-deaden-summary kill-buffer))
4043 (gnus-summary-auto-select-subject)
4044 ;; Don't mark any articles as selected if we haven't done that.
4045 (when no-article
4046 (setq overlay-arrow-position nil))
4047 ;; Show first unread article if requested.
4048 (if (and (not no-article)
4049 (not no-display)
4050 gnus-newsgroup-unreads
4051 gnus-auto-select-first)
4052 (progn
4053 (let ((art (gnus-summary-article-number)))
4054 (when (and art
4055 gnus-plugged
4056 (not (memq art gnus-newsgroup-undownloaded))
4057 (not (memq art gnus-newsgroup-downloadable)))
4058 (gnus-summary-goto-article art))))
4059 ;; Don't select any articles.
4060 (gnus-summary-position-point)
4061 (gnus-configure-windows 'summary 'force)
4062 (gnus-set-mode-line 'summary))
4063 (when (and gnus-auto-center-group
4064 (get-buffer-window gnus-group-buffer t))
4065 ;; Gotta use windows, because recenter does weird stuff if
4066 ;; the current buffer ain't the displayed window.
4067 (let ((owin (selected-window)))
4068 (select-window (get-buffer-window gnus-group-buffer t))
4069 (when (gnus-group-goto-group group)
4070 (recenter))
4071 (select-window owin)))
4072 ;; Mark this buffer as "prepared".
4073 (setq gnus-newsgroup-prepared t)
4074 (gnus-run-hooks 'gnus-summary-prepared-hook)
4075 (unless (gnus-ephemeral-group-p group)
4076 (gnus-group-update-group group nil t))
4077 t)))))
4079 (defun gnus-summary-auto-select-subject ()
4080 "Select the subject line on initial group entry."
4081 (goto-char (point-min))
4082 (cond
4083 ((eq gnus-auto-select-subject 'best)
4084 (gnus-summary-best-unread-subject))
4085 ((eq gnus-auto-select-subject 'unread)
4086 (gnus-summary-first-unread-subject))
4087 ((eq gnus-auto-select-subject 'unseen)
4088 (gnus-summary-first-unseen-subject))
4089 ((eq gnus-auto-select-subject 'unseen-or-unread)
4090 (gnus-summary-first-unseen-or-unread-subject))
4091 ((eq gnus-auto-select-subject 'first)
4092 ;; Do nothing.
4094 ((functionp gnus-auto-select-subject)
4095 (funcall gnus-auto-select-subject))))
4097 (defun gnus-summary-prepare ()
4098 "Generate the summary buffer."
4099 (interactive)
4100 (let ((inhibit-read-only t))
4101 (erase-buffer)
4102 (setq gnus-newsgroup-data nil
4103 gnus-newsgroup-data-reverse nil)
4104 (gnus-run-hooks 'gnus-summary-generate-hook)
4105 ;; Generate the buffer, either with threads or without.
4106 (when gnus-newsgroup-headers
4107 (gnus-summary-prepare-threads
4108 (if gnus-show-threads
4109 (gnus-sort-gathered-threads
4110 (funcall gnus-summary-thread-gathering-function
4111 (gnus-sort-threads
4112 (gnus-cut-threads (gnus-make-threads)))))
4113 ;; Unthreaded display.
4114 (gnus-sort-articles gnus-newsgroup-headers))))
4115 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4116 ;; Call hooks for modifying summary buffer.
4117 (goto-char (point-min))
4118 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4120 (defsubst gnus-general-simplify-subject (subject)
4121 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4122 (setq subject
4123 (cond
4124 ;; Truncate the subject.
4125 (gnus-simplify-subject-functions
4126 (gnus-map-function gnus-simplify-subject-functions subject))
4127 ((numberp gnus-summary-gather-subject-limit)
4128 (setq subject (gnus-simplify-subject-re subject))
4129 (if (> (length subject) gnus-summary-gather-subject-limit)
4130 (substring subject 0 gnus-summary-gather-subject-limit)
4131 subject))
4132 ;; Fuzzily simplify it.
4133 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4134 (gnus-simplify-subject-fuzzy subject))
4135 ;; Just remove the leading "Re:".
4137 (gnus-simplify-subject-re subject))))
4139 (if (and gnus-summary-gather-exclude-subject
4140 (string-match gnus-summary-gather-exclude-subject subject))
4141 nil ; This article shouldn't be gathered
4142 subject))
4144 (defun gnus-summary-simplify-subject-query ()
4145 "Query where the respool algorithm would put this article."
4146 (interactive)
4147 (gnus-summary-select-article)
4148 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4150 (defun gnus-gather-threads-by-subject (threads)
4151 "Gather threads by looking at Subject headers."
4152 (if (not gnus-summary-make-false-root)
4153 threads
4154 (let ((hashtb (gnus-make-hashtable 1024))
4155 (prev threads)
4156 (result threads)
4157 subject hthread whole-subject)
4158 (while threads
4159 (setq subject (gnus-general-simplify-subject
4160 (setq whole-subject (mail-header-subject
4161 (caar threads)))))
4162 (when subject
4163 (if (setq hthread (gnus-gethash subject hashtb))
4164 (progn
4165 ;; We enter a dummy root into the thread, if we
4166 ;; haven't done that already.
4167 (unless (stringp (caar hthread))
4168 (setcar hthread (list whole-subject (car hthread))))
4169 ;; We add this new gathered thread to this gathered
4170 ;; thread.
4171 (setcdr (car hthread)
4172 (nconc (cdar hthread) (list (car threads))))
4173 ;; Remove it from the list of threads.
4174 (setcdr prev (cdr threads))
4175 (setq threads prev))
4176 ;; Enter this thread into the hash table.
4177 (gnus-sethash subject
4178 (if gnus-summary-make-false-root-always
4179 (progn
4180 ;; If you want a dummy root above all
4181 ;; threads...
4182 (setcar threads (list whole-subject
4183 (car threads)))
4184 threads)
4185 threads)
4186 hashtb)))
4187 (setq prev threads)
4188 (setq threads (cdr threads)))
4189 result)))
4191 (defun gnus-gather-threads-by-references (threads)
4192 "Gather threads by looking at References headers."
4193 (let ((idhashtb (gnus-make-hashtable 1024))
4194 (thhashtb (gnus-make-hashtable 1024))
4195 (prev threads)
4196 (result threads)
4197 ids references id gthread gid entered ref)
4198 (while threads
4199 (when (setq references (mail-header-references (caar threads)))
4200 (setq id (mail-header-id (caar threads))
4201 ids (inline (gnus-split-references references))
4202 entered nil)
4203 (while (setq ref (pop ids))
4204 (setq ids (delete ref ids))
4205 (if (not (setq gid (gnus-gethash ref idhashtb)))
4206 (progn
4207 (gnus-sethash ref id idhashtb)
4208 (gnus-sethash id threads thhashtb))
4209 (setq gthread (gnus-gethash gid thhashtb))
4210 (unless entered
4211 ;; We enter a dummy root into the thread, if we
4212 ;; haven't done that already.
4213 (unless (stringp (caar gthread))
4214 (setcar gthread (list (mail-header-subject (caar gthread))
4215 (car gthread))))
4216 ;; We add this new gathered thread to this gathered
4217 ;; thread.
4218 (setcdr (car gthread)
4219 (nconc (cdar gthread) (list (car threads)))))
4220 ;; Add it into the thread hash table.
4221 (gnus-sethash id gthread thhashtb)
4222 (setq entered t)
4223 ;; Remove it from the list of threads.
4224 (setcdr prev (cdr threads))
4225 (setq threads prev))))
4226 (setq prev threads)
4227 (setq threads (cdr threads)))
4228 result))
4230 (defun gnus-sort-gathered-threads (threads)
4231 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4232 (let ((result threads))
4233 (while threads
4234 (when (stringp (caar threads))
4235 (setcdr (car threads)
4236 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4237 (setq threads (cdr threads)))
4238 result))
4240 (defun gnus-thread-loop-p (root thread)
4241 "Say whether ROOT is in THREAD."
4242 (let ((stack (list thread))
4243 (infloop 0)
4245 (while (setq thread (pop stack))
4246 (setq th (cdr thread))
4247 (while (and th
4248 (not (eq (caar th) root)))
4249 (pop th))
4250 (if th
4251 ;; We have found a loop.
4252 (let (ref-dep)
4253 (setcdr thread (delq (car th) (cdr thread)))
4254 (if (boundp (setq ref-dep (intern "none"
4255 gnus-newsgroup-dependencies)))
4256 (setcdr (symbol-value ref-dep)
4257 (nconc (cdr (symbol-value ref-dep))
4258 (list (car th))))
4259 (set ref-dep (list nil (car th))))
4260 (setq infloop 1
4261 stack nil))
4262 ;; Push all the subthreads onto the stack.
4263 (push (cdr thread) stack)))
4264 infloop))
4266 (defun gnus-make-threads ()
4267 "Go through the dependency hashtb and find the roots. Return all threads."
4268 (let (threads)
4269 (while (catch 'infloop
4270 (mapatoms
4271 (lambda (refs)
4272 ;; Deal with self-referencing References loops.
4273 (when (and (car (symbol-value refs))
4274 (not (zerop
4275 (apply
4277 (mapcar
4278 (lambda (thread)
4279 (gnus-thread-loop-p
4280 (car (symbol-value refs)) thread))
4281 (cdr (symbol-value refs)))))))
4282 (setq threads nil)
4283 (throw 'infloop t))
4284 (unless (car (symbol-value refs))
4285 ;; These threads do not refer back to any other
4286 ;; articles, so they're roots.
4287 (setq threads (append (cdr (symbol-value refs)) threads))))
4288 gnus-newsgroup-dependencies)))
4289 threads))
4291 ;; Build the thread tree.
4292 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4293 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4295 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4296 if it was already present.
4298 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4299 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4300 Message-IDs will be renamed to a unique Message-ID before being
4301 entered.
4303 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4304 (let* ((id (mail-header-id header))
4305 (id-dep (and id (intern id dependencies)))
4306 parent-id ref ref-dep ref-header replaced)
4307 ;; Enter this `header' in the `dependencies' table.
4308 (cond
4309 ((not id-dep)
4310 (setq header nil))
4311 ;; The first two cases do the normal part: enter a new `header'
4312 ;; in the `dependencies' table.
4313 ((not (boundp id-dep))
4314 (set id-dep (list header)))
4315 ((null (car (symbol-value id-dep)))
4316 (setcar (symbol-value id-dep) header))
4318 ;; From here the `header' was already present in the
4319 ;; `dependencies' table.
4320 (force-new
4321 ;; Overrides an existing entry;
4322 ;; just set the header part of the entry.
4323 (setcar (symbol-value id-dep) header)
4324 (setq replaced t))
4326 ;; Renames the existing `header' to a unique Message-ID.
4327 ((not gnus-summary-ignore-duplicates)
4328 ;; An article with this Message-ID has already been seen.
4329 ;; We rename the Message-ID.
4330 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4331 (list header))
4332 (mail-header-set-id header id))
4334 ;; The last case ignores an existing entry, except it adds any
4335 ;; additional Xrefs (in case the two articles came from different
4336 ;; servers.
4337 ;; Also sets `header' to nil meaning that the `dependencies'
4338 ;; table was *not* modified.
4340 (mail-header-set-xref
4341 (car (symbol-value id-dep))
4342 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4344 (or (mail-header-xref header) "")))
4345 (setq header nil)))
4347 (when (and header (not replaced))
4348 ;; First check that we are not creating a References loop.
4349 (setq parent-id (gnus-parent-id (mail-header-references header)))
4350 (setq ref parent-id)
4351 (while (and ref
4352 (setq ref-dep (intern-soft ref dependencies))
4353 (boundp ref-dep)
4354 (setq ref-header (car (symbol-value ref-dep))))
4355 (if (string= id ref)
4356 ;; Yuk! This is a reference loop. Make the article be a
4357 ;; root article.
4358 (progn
4359 (mail-header-set-references (car (symbol-value id-dep)) "none")
4360 (setq ref nil)
4361 (setq parent-id nil))
4362 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4363 (setq ref-dep (intern (or parent-id "none") dependencies))
4364 (if (boundp ref-dep)
4365 (setcdr (symbol-value ref-dep)
4366 (nconc (cdr (symbol-value ref-dep))
4367 (list (symbol-value id-dep))))
4368 (set ref-dep (list nil (symbol-value id-dep)))))
4369 header))
4371 (defun gnus-extract-message-id-from-in-reply-to (string)
4372 (if (string-match "<[^>]+>" string)
4373 (substring string (match-beginning 0) (match-end 0))
4374 nil))
4376 (defun gnus-build-sparse-threads ()
4377 (let ((headers gnus-newsgroup-headers)
4378 (mail-parse-charset gnus-newsgroup-charset)
4379 (gnus-summary-ignore-duplicates t)
4380 header references generation relations
4381 subject child end new-child date)
4382 ;; First we create an alist of generations/relations, where
4383 ;; generations is how much we trust the relation, and the relation
4384 ;; is parent/child.
4385 (gnus-message 7 "Making sparse threads...")
4386 (save-excursion
4387 (nnheader-set-temp-buffer " *gnus sparse threads*")
4388 (while (setq header (pop headers))
4389 (when (and (setq references (mail-header-references header))
4390 (not (string= references "")))
4391 (insert references)
4392 (setq child (mail-header-id header)
4393 subject (mail-header-subject header)
4394 date (mail-header-date header)
4395 generation 0)
4396 (while (search-backward ">" nil t)
4397 (setq end (1+ (point)))
4398 (when (search-backward "<" nil t)
4399 (setq new-child (buffer-substring (point) end))
4400 (push (list (incf generation)
4401 child (setq child new-child)
4402 subject date)
4403 relations)))
4404 (when child
4405 (push (list (1+ generation) child nil subject) relations))
4406 (erase-buffer)))
4407 (kill-buffer (current-buffer)))
4408 ;; Sort over trustworthiness.
4409 (dolist (relation (sort relations 'car-less-than-car))
4410 (when (gnus-dependencies-add-header
4411 (make-full-mail-header
4412 gnus-reffed-article-number
4413 (nth 3 relation) "" (or (nth 4 relation) "")
4414 (nth 1 relation)
4415 (or (nth 2 relation) "") 0 0 "")
4416 gnus-newsgroup-dependencies nil)
4417 (push gnus-reffed-article-number gnus-newsgroup-limit)
4418 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4419 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4420 gnus-newsgroup-reads)
4421 (decf gnus-reffed-article-number)))
4422 (gnus-message 7 "Making sparse threads...done")))
4424 (defun gnus-build-old-threads ()
4425 ;; Look at all the articles that refer back to old articles, and
4426 ;; fetch the headers for the articles that aren't there. This will
4427 ;; build complete threads - if the roots haven't been expired by the
4428 ;; server, that is.
4429 (let ((mail-parse-charset gnus-newsgroup-charset)
4430 id heads)
4431 (mapatoms
4432 (lambda (refs)
4433 (when (not (car (symbol-value refs)))
4434 (setq heads (cdr (symbol-value refs)))
4435 (while heads
4436 (if (memq (mail-header-number (caar heads))
4437 gnus-newsgroup-dormant)
4438 (setq heads (cdr heads))
4439 (setq id (symbol-name refs))
4440 (while (and (setq id (gnus-build-get-header id))
4441 (not (car (gnus-id-to-thread id)))))
4442 (setq heads nil)))))
4443 gnus-newsgroup-dependencies)))
4445 (defsubst gnus-remove-odd-characters (string)
4446 "Translate STRING into something that doesn't contain weird characters."
4447 (subst-char-in-string
4448 ?\r ?\-
4449 (subst-char-in-string ?\n ?\- string t) t))
4451 ;; This function has to be called with point after the article number
4452 ;; on the beginning of the line.
4453 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4454 (let ((eol (point-at-eol))
4455 (buffer (current-buffer))
4456 header references in-reply-to)
4458 ;; overview: [num subject from date id refs chars lines misc]
4459 (unwind-protect
4460 (let (x)
4461 (narrow-to-region (point) eol)
4462 (unless (eobp)
4463 (forward-char))
4465 (setq header
4466 (make-full-mail-header
4467 number ; number
4468 (condition-case () ; subject
4469 (gnus-remove-odd-characters
4470 (funcall gnus-decode-encoded-word-function
4471 (setq x (nnheader-nov-field))))
4472 (error x))
4473 (condition-case () ; from
4474 (gnus-remove-odd-characters
4475 (funcall gnus-decode-encoded-address-function
4476 (setq x (nnheader-nov-field))))
4477 (error x))
4478 (nnheader-nov-field) ; date
4479 (nnheader-nov-read-message-id number) ; id
4480 (setq references (nnheader-nov-field)) ; refs
4481 (nnheader-nov-read-integer) ; chars
4482 (nnheader-nov-read-integer) ; lines
4483 (unless (eobp)
4484 (if (looking-at "Xref: ")
4485 (goto-char (match-end 0)))
4486 (nnheader-nov-field)) ; Xref
4487 (nnheader-nov-parse-extra)))) ; extra
4489 (widen))
4491 (when (and (string= references "")
4492 (setq in-reply-to (mail-header-extra header))
4493 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4494 (mail-header-set-references
4495 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4497 (when gnus-alter-header-function
4498 (funcall gnus-alter-header-function header))
4499 (gnus-dependencies-add-header header dependencies force-new)))
4501 (defun gnus-build-get-header (id)
4502 "Look through the buffer of NOV lines and find the header to ID.
4503 Enter this line into the dependencies hash table, and return
4504 the id of the parent article (if any)."
4505 (let ((deps gnus-newsgroup-dependencies)
4506 found header)
4507 (prog1
4508 (with-current-buffer nntp-server-buffer
4509 (let ((case-fold-search nil))
4510 (goto-char (point-min))
4511 (while (and (not found)
4512 (search-forward id nil t))
4513 (beginning-of-line)
4514 (setq found (looking-at
4515 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4516 (regexp-quote id))))
4517 (or found (beginning-of-line 2)))
4518 (when found
4519 (beginning-of-line)
4520 (and
4521 (setq header (gnus-nov-parse-line
4522 (read (current-buffer)) deps))
4523 (gnus-parent-id (mail-header-references header))))))
4524 (when header
4525 (let ((number (mail-header-number header)))
4526 (push number gnus-newsgroup-limit)
4527 (push header gnus-newsgroup-headers)
4528 (if (memq number gnus-newsgroup-unselected)
4529 (progn
4530 (setq gnus-newsgroup-unreads
4531 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4532 number))
4533 (setq gnus-newsgroup-unselected
4534 (delq number gnus-newsgroup-unselected)))
4535 (push number gnus-newsgroup-ancient)))))))
4537 (defun gnus-build-all-threads ()
4538 "Read all the headers."
4539 (let ((gnus-summary-ignore-duplicates t)
4540 (mail-parse-charset gnus-newsgroup-charset)
4541 (dependencies gnus-newsgroup-dependencies)
4542 header article)
4543 (with-current-buffer nntp-server-buffer
4544 (let ((case-fold-search nil))
4545 (goto-char (point-min))
4546 (while (not (eobp))
4547 (ignore-errors
4548 (setq article (read (current-buffer))
4549 header (gnus-nov-parse-line article dependencies t)))
4550 (when header
4551 (with-current-buffer gnus-summary-buffer
4552 (push header gnus-newsgroup-headers)
4553 (if (memq (setq article (mail-header-number header))
4554 gnus-newsgroup-unselected)
4555 (progn
4556 (setq gnus-newsgroup-unreads
4557 (gnus-add-to-sorted-list
4558 gnus-newsgroup-unreads article))
4559 (setq gnus-newsgroup-unselected
4560 (delq article gnus-newsgroup-unselected)))
4561 (push article gnus-newsgroup-ancient)))
4562 (forward-line 1)))))))
4564 (defun gnus-summary-update-article-line (article header)
4565 "Update the line for ARTICLE using HEADER."
4566 (let* ((id (mail-header-id header))
4567 (thread (gnus-id-to-thread id)))
4568 (unless thread
4569 (error "Article in no thread"))
4570 ;; Update the thread.
4571 (setcar thread header)
4572 (gnus-summary-goto-subject article)
4573 (let* ((datal (gnus-data-find-list article))
4574 (data (car datal))
4575 (inhibit-read-only t)
4576 (level (gnus-summary-thread-level)))
4577 (gnus-delete-line)
4578 (let ((inserted (- (point)
4579 (progn
4580 (gnus-summary-insert-line
4581 header level nil
4582 (memq article gnus-newsgroup-undownloaded)
4583 (gnus-article-mark article)
4584 (memq article gnus-newsgroup-replied)
4585 (memq article gnus-newsgroup-expirable)
4586 ;; Only insert the Subject string when it's different
4587 ;; from the previous Subject string.
4588 (if (and
4589 gnus-show-threads
4590 (gnus-subject-equal
4591 (condition-case ()
4592 (mail-header-subject
4593 (gnus-data-header
4594 (cadr
4595 (gnus-data-find-list
4596 article
4597 (gnus-data-list t)))))
4598 ;; Error on the side of excessive subjects.
4599 (error ""))
4600 (mail-header-subject header)))
4602 (mail-header-subject header))
4603 nil (cdr (assq article gnus-newsgroup-scored))
4604 (memq article gnus-newsgroup-processable))
4605 (point)))))
4606 (when (cdr datal)
4607 (gnus-data-update-list
4608 (cdr datal)
4609 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4611 (defun gnus-summary-update-article (article &optional iheader)
4612 "Update ARTICLE in the summary buffer."
4613 (set-buffer gnus-summary-buffer)
4614 (let* ((header (gnus-summary-article-header article))
4615 (id (mail-header-id header))
4616 (data (gnus-data-find article))
4617 (thread (gnus-id-to-thread id))
4618 (references (mail-header-references header))
4619 (parent
4620 (gnus-id-to-thread
4621 (or (gnus-parent-id
4622 (when (and references
4623 (not (equal "" references)))
4624 references))
4625 "none")))
4626 (inhibit-read-only t)
4627 (old (car thread)))
4628 (when thread
4629 (unless iheader
4630 (setcar thread nil)
4631 (when parent
4632 (delq thread parent)))
4633 (if (gnus-summary-insert-subject id header)
4634 ;; Set the (possibly) new article number in the data structure.
4635 (gnus-data-set-number data (gnus-id-to-article id))
4636 (setcar thread old)
4637 nil))))
4639 (defun gnus-rebuild-thread (id &optional line)
4640 "Rebuild the thread containing ID.
4641 If LINE, insert the rebuilt thread starting on line LINE."
4642 (let ((inhibit-read-only t)
4643 old-pos current thread data)
4644 (if (not gnus-show-threads)
4645 (setq thread (list (car (gnus-id-to-thread id))))
4646 ;; Get the thread this article is part of.
4647 (setq thread (gnus-remove-thread id)))
4648 (setq old-pos (point-at-bol))
4649 (setq current (save-excursion
4650 (and (re-search-backward "[\r\n]" nil t)
4651 (gnus-summary-article-number))))
4652 ;; If this is a gathered thread, we have to go some re-gathering.
4653 (when (stringp (car thread))
4654 (let ((subject (car thread))
4655 roots thr)
4656 (setq thread (cdr thread))
4657 (while thread
4658 (unless (memq (setq thr (gnus-id-to-thread
4659 (gnus-root-id
4660 (mail-header-id (caar thread)))))
4661 roots)
4662 (push thr roots))
4663 (setq thread (cdr thread)))
4664 ;; We now have all (unique) roots.
4665 (if (= (length roots) 1)
4666 ;; All the loose roots are now one solid root.
4667 (setq thread (car roots))
4668 (setq thread (cons subject (gnus-sort-threads roots))))))
4669 (let (threads)
4670 ;; We then insert this thread into the summary buffer.
4671 (when line
4672 (goto-char (point-min))
4673 (forward-line (1- line)))
4674 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4675 (if gnus-show-threads
4676 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4677 (gnus-summary-prepare-unthreaded thread))
4678 (setq data (nreverse gnus-newsgroup-data))
4679 (setq threads gnus-newsgroup-threads))
4680 ;; We splice the new data into the data structure.
4681 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4682 ;;!!! then we want to insert at the beginning of the buffer.
4683 ;;!!! That happens to be true with Gnus now, but that may
4684 ;;!!! change in the future. Perhaps.
4685 (gnus-data-enter-list
4686 (if line nil current) data (- (point) old-pos))
4687 (setq gnus-newsgroup-threads
4688 (nconc threads gnus-newsgroup-threads))
4689 (gnus-data-compute-positions))))
4691 (defun gnus-number-to-header (number)
4692 "Return the header for article NUMBER."
4693 (let ((headers gnus-newsgroup-headers))
4694 (while (and headers
4695 (not (= number (mail-header-number (car headers)))))
4696 (pop headers))
4697 (when headers
4698 (car headers))))
4700 (defun gnus-parent-headers (in-headers &optional generation)
4701 "Return the headers of the GENERATIONth parent of HEADERS."
4702 (unless generation
4703 (setq generation 1))
4704 (let ((parent t)
4705 (headers in-headers)
4706 references)
4707 (while (and parent
4708 (not (zerop generation))
4709 (setq references (mail-header-references headers)))
4710 (setq headers (if (and references
4711 (setq parent (gnus-parent-id references)))
4712 (car (gnus-id-to-thread parent))
4713 nil))
4714 (decf generation))
4715 (and (not (eq headers in-headers))
4716 headers)))
4718 (defun gnus-id-to-thread (id)
4719 "Return the (sub-)thread where ID appears."
4720 (gnus-gethash id gnus-newsgroup-dependencies))
4722 (defun gnus-id-to-article (id)
4723 "Return the article number of ID."
4724 (let ((thread (gnus-id-to-thread id)))
4725 (when (and thread
4726 (car thread))
4727 (mail-header-number (car thread)))))
4729 (defun gnus-id-to-header (id)
4730 "Return the article headers of ID."
4731 (car (gnus-id-to-thread id)))
4733 (defun gnus-article-displayed-root-p (article)
4734 "Say whether ARTICLE is a root(ish) article."
4735 (let ((level (gnus-summary-thread-level article))
4736 (refs (mail-header-references (gnus-summary-article-header article)))
4737 particle)
4738 (cond
4739 ((null level) nil)
4740 ((zerop level) t)
4741 ((null refs) t)
4742 ((null (gnus-parent-id refs)) t)
4743 ((and (= 1 level)
4744 (null (setq particle (gnus-id-to-article
4745 (gnus-parent-id refs))))
4746 (null (gnus-summary-thread-level particle)))))))
4748 (defun gnus-root-id (id)
4749 "Return the id of the root of the thread where ID appears."
4750 (let (last-id prev)
4751 (while (and id (setq prev (car (gnus-id-to-thread id))))
4752 (setq last-id id
4753 id (gnus-parent-id (mail-header-references prev))))
4754 last-id))
4756 (defun gnus-articles-in-thread (thread)
4757 "Return the list of articles in THREAD."
4758 (cons (mail-header-number (car thread))
4759 (mapcan 'gnus-articles-in-thread (cdr thread))))
4761 (defun gnus-remove-thread (id &optional dont-remove)
4762 "Remove the thread that has ID in it."
4763 (let (headers thread last-id)
4764 ;; First go up in this thread until we find the root.
4765 (setq last-id (gnus-root-id id)
4766 headers (message-flatten-list (gnus-id-to-thread last-id)))
4767 ;; We have now found the real root of this thread. It might have
4768 ;; been gathered into some loose thread, so we have to search
4769 ;; through the threads to find the thread we wanted.
4770 (let ((threads gnus-newsgroup-threads)
4771 sub)
4772 (while threads
4773 (setq sub (car threads))
4774 (if (stringp (car sub))
4775 ;; This is a gathered thread, so we look at the roots
4776 ;; below it to find whether this article is in this
4777 ;; gathered root.
4778 (progn
4779 (setq sub (cdr sub))
4780 (while sub
4781 (when (member (caar sub) headers)
4782 (setq thread (car threads)
4783 threads nil
4784 sub nil))
4785 (setq sub (cdr sub))))
4786 ;; It's an ordinary thread, so we check it.
4787 (when (eq (car sub) (car headers))
4788 (setq thread sub
4789 threads nil)))
4790 (setq threads (cdr threads)))
4791 ;; If this article is in no thread, then it's a root.
4792 (if thread
4793 (unless dont-remove
4794 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4795 (setq thread (gnus-id-to-thread last-id)))
4796 (when thread
4797 (prog1
4798 thread ; We return this thread.
4799 (unless dont-remove
4800 (if (stringp (car thread))
4801 (progn
4802 ;; If we use dummy roots, then we have to remove the
4803 ;; dummy root as well.
4804 (when (eq gnus-summary-make-false-root 'dummy)
4805 ;; We go to the dummy root by going to
4806 ;; the first sub-"thread", and then one line up.
4807 (gnus-summary-goto-article
4808 (mail-header-number (caadr thread)))
4809 (forward-line -1)
4810 (gnus-delete-line)
4811 (gnus-data-compute-positions))
4812 (setq thread (cdr thread))
4813 (while thread
4814 (gnus-remove-thread-1 (car thread))
4815 (setq thread (cdr thread))))
4816 (gnus-remove-thread-1 thread))))))))
4818 (defun gnus-remove-thread-1 (thread)
4819 "Remove the thread THREAD recursively."
4820 (let ((number (mail-header-number (pop thread)))
4822 (setq thread (reverse thread))
4823 (while thread
4824 (gnus-remove-thread-1 (pop thread)))
4825 (when (setq d (gnus-data-find number))
4826 (goto-char (gnus-data-pos d))
4827 (gnus-summary-show-thread)
4828 (gnus-data-remove
4829 number
4830 (- (point-at-bol)
4831 (prog1
4832 (1+ (point-at-eol))
4833 (gnus-delete-line)))))))
4835 (defun gnus-sort-threads-recursive (threads func)
4836 ;; Responsible for sorting the root articles of threads.
4837 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4838 'gnus-thread-sort-functions)
4839 func
4840 (gnus-make-sort-function
4841 gnus-subthread-sort-functions))))
4842 (sort (mapcar (lambda (thread)
4843 (cons (car thread)
4844 (and (cdr thread)
4845 (gnus-sort-subthreads-recursive
4846 (cdr thread) subthread-sort-func))))
4847 threads) func)))
4849 (defun gnus-sort-subthreads-recursive (threads func)
4850 ;; Responsible for sorting subthreads.
4851 (sort (mapcar (lambda (thread)
4852 (cons (car thread)
4853 (and (cdr thread)
4854 (gnus-sort-subthreads-recursive (cdr thread) func))))
4855 threads) func))
4857 (defun gnus-sort-threads-loop (threads func)
4858 (let* ((superthread (cons nil threads))
4859 (stack (list (cons superthread threads)))
4860 remaining-threads thread)
4861 (while stack
4862 (setq remaining-threads (cdr (car stack)))
4863 (if remaining-threads
4864 (progn (setq thread (car remaining-threads))
4865 (setcdr (car stack) (cdr remaining-threads))
4866 (if (cdr thread)
4867 (push (cons thread (cdr thread)) stack)))
4868 (setq thread (caar stack))
4869 (setcdr thread (sort (cdr thread) func))
4870 (pop stack)))
4871 (cdr superthread)))
4873 (defun gnus-sort-threads (threads)
4874 "Sort THREADS."
4875 (if (not gnus-thread-sort-functions)
4876 threads
4877 (gnus-message 8 "Sorting threads...")
4878 (prog1
4879 (condition-case nil
4880 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4881 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4882 (gnus-sort-threads-recursive threads sort-func))
4883 ;; Even after binding max-lisp-eval-depth, the recursive
4884 ;; sorter might fail for very long threads. In that case,
4885 ;; try using a (less well-tested) non-recursive sorter.
4886 (error (gnus-message 9 "Sorting threads with loop...")
4887 (gnus-sort-threads-loop
4888 threads (gnus-make-sort-function
4889 gnus-thread-sort-functions))))
4890 (gnus-message 8 "Sorting threads...done"))))
4892 (defun gnus-sort-articles (articles)
4893 "Sort ARTICLES."
4894 (when gnus-article-sort-functions
4895 (gnus-message 7 "Sorting articles...")
4896 (prog1
4897 (setq gnus-newsgroup-headers
4898 (sort articles (gnus-make-sort-function
4899 gnus-article-sort-functions)))
4900 (gnus-message 7 "Sorting articles...done"))))
4902 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4903 (defmacro gnus-thread-header (thread)
4904 "Return header of first article in THREAD.
4905 Note that THREAD must never, ever be anything else than a variable -
4906 using some other form will lead to serious barfage."
4907 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4908 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4909 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4910 (vector thread) 2))
4912 (defsubst gnus-article-sort-by-number (h1 h2)
4913 "Sort articles by article number."
4914 (< (mail-header-number h1)
4915 (mail-header-number h2)))
4917 (defun gnus-thread-sort-by-number (h1 h2)
4918 "Sort threads by root article number."
4919 (gnus-article-sort-by-number
4920 (gnus-thread-header h1) (gnus-thread-header h2)))
4922 (defsubst gnus-article-sort-by-random (h1 h2)
4923 "Sort articles randomly."
4924 (zerop (random 2)))
4926 (defun gnus-thread-sort-by-random (h1 h2)
4927 "Sort threads randomly."
4928 (gnus-article-sort-by-random
4929 (gnus-thread-header h1) (gnus-thread-header h2)))
4931 (defsubst gnus-article-sort-by-lines (h1 h2)
4932 "Sort articles by article Lines header."
4933 (< (mail-header-lines h1)
4934 (mail-header-lines h2)))
4936 (defun gnus-thread-sort-by-lines (h1 h2)
4937 "Sort threads by root article Lines header."
4938 (gnus-article-sort-by-lines
4939 (gnus-thread-header h1) (gnus-thread-header h2)))
4941 (defsubst gnus-article-sort-by-chars (h1 h2)
4942 "Sort articles by octet length."
4943 (< (mail-header-chars h1)
4944 (mail-header-chars h2)))
4946 (defun gnus-thread-sort-by-chars (h1 h2)
4947 "Sort threads by root article octet length."
4948 (gnus-article-sort-by-chars
4949 (gnus-thread-header h1) (gnus-thread-header h2)))
4951 (defsubst gnus-article-sort-by-marks (h1 h2)
4952 "Sort articles by octet length."
4953 (< (gnus-article-mark (mail-header-number h1))
4954 (gnus-article-mark (mail-header-number h2))))
4956 (defun gnus-thread-sort-by-marks (h1 h2)
4957 "Sort threads by root article octet length."
4958 (gnus-article-sort-by-marks
4959 (gnus-thread-header h1) (gnus-thread-header h2)))
4961 (defsubst gnus-article-sort-by-author (h1 h2)
4962 "Sort articles by root author."
4963 (gnus-string<
4964 (let ((extract (funcall
4965 gnus-extract-address-components
4966 (mail-header-from h1))))
4967 (or (car extract) (cadr extract) ""))
4968 (let ((extract (funcall
4969 gnus-extract-address-components
4970 (mail-header-from h2))))
4971 (or (car extract) (cadr extract) ""))))
4973 (defun gnus-thread-sort-by-author (h1 h2)
4974 "Sort threads by root author."
4975 (gnus-article-sort-by-author
4976 (gnus-thread-header h1) (gnus-thread-header h2)))
4978 (defsubst gnus-article-sort-by-recipient (h1 h2)
4979 "Sort articles by recipient."
4980 (gnus-string<
4981 (let ((extract (funcall
4982 gnus-extract-address-components
4983 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4984 (or (car extract) (cadr extract)))
4985 (let ((extract (funcall
4986 gnus-extract-address-components
4987 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4988 (or (car extract) (cadr extract)))))
4990 (defun gnus-thread-sort-by-recipient (h1 h2)
4991 "Sort threads by root recipient."
4992 (gnus-article-sort-by-recipient
4993 (gnus-thread-header h1) (gnus-thread-header h2)))
4995 (defsubst gnus-article-sort-by-subject (h1 h2)
4996 "Sort articles by root subject."
4997 (gnus-string<
4998 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4999 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5001 (defun gnus-thread-sort-by-subject (h1 h2)
5002 "Sort threads by root subject."
5003 (gnus-article-sort-by-subject
5004 (gnus-thread-header h1) (gnus-thread-header h2)))
5006 (defsubst gnus-article-sort-by-date (h1 h2)
5007 "Sort articles by root article date."
5008 (time-less-p
5009 (gnus-date-get-time (mail-header-date h1))
5010 (gnus-date-get-time (mail-header-date h2))))
5012 (defun gnus-thread-sort-by-date (h1 h2)
5013 "Sort threads by root article date."
5014 (gnus-article-sort-by-date
5015 (gnus-thread-header h1) (gnus-thread-header h2)))
5017 (defsubst gnus-article-sort-by-score (h1 h2)
5018 "Sort articles by root article score.
5019 Unscored articles will be counted as having a score of zero."
5020 (> (or (cdr (assq (mail-header-number h1)
5021 gnus-newsgroup-scored))
5022 gnus-summary-default-score 0)
5023 (or (cdr (assq (mail-header-number h2)
5024 gnus-newsgroup-scored))
5025 gnus-summary-default-score 0)))
5027 (defun gnus-thread-sort-by-score (h1 h2)
5028 "Sort threads by root article score."
5029 (gnus-article-sort-by-score
5030 (gnus-thread-header h1) (gnus-thread-header h2)))
5032 (defun gnus-thread-sort-by-total-score (h1 h2)
5033 "Sort threads by the sum of all scores in the thread.
5034 Unscored articles will be counted as having a score of zero."
5035 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5037 (defun gnus-thread-total-score (thread)
5038 ;; This function find the total score of THREAD.
5039 (cond
5040 ((null thread)
5042 ((consp thread)
5043 (if (stringp (car thread))
5044 (apply gnus-thread-score-function 0
5045 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5046 (gnus-thread-total-score-1 thread)))
5048 (gnus-thread-total-score-1 (list thread)))))
5050 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5051 "Sort articles by number."
5052 (gnus-article-sort-by-number h1 h2))
5054 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5055 "Sort threads such that the thread with the most recently arrived article comes first."
5056 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5058 (defun gnus-thread-highest-number (thread)
5059 "Return the highest article number in THREAD."
5060 (apply 'max (mapcar (lambda (header)
5061 (mail-header-number header))
5062 (message-flatten-list thread))))
5064 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5065 "Sort articles by number."
5066 (gnus-article-sort-by-date h1 h2))
5068 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5069 "Sort threads such that the thread with the most recently dated article comes first."
5070 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5072 ; Since this is called not only to sort the top-level threads, but
5073 ; also in recursive sorts to order the articles within a thread, each
5074 ; article will be processed many times. Thus it speeds things up
5075 ; quite a bit to use gnus-date-get-time, which caches the time value.
5076 (defun gnus-thread-latest-date (thread)
5077 "Return the highest article date in THREAD."
5078 (apply 'max
5079 (mapcar (lambda (header) (float-time
5080 (gnus-date-get-time
5081 (mail-header-date header))))
5082 (message-flatten-list thread))))
5084 (defun gnus-thread-total-score-1 (root)
5085 ;; This function find the total score of the thread below ROOT.
5086 (setq root (car root))
5087 (apply gnus-thread-score-function
5088 (or (append
5089 (mapcar 'gnus-thread-total-score
5090 (cdr (gnus-id-to-thread (mail-header-id root))))
5091 (when (> (mail-header-number root) 0)
5092 (list (or (cdr (assq (mail-header-number root)
5093 gnus-newsgroup-scored))
5094 gnus-summary-default-score 0))))
5095 (list gnus-summary-default-score)
5096 '(0))))
5098 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5099 (defvar gnus-tmp-prev-subject nil)
5100 (defvar gnus-tmp-false-parent nil)
5101 (defvar gnus-tmp-root-expunged nil)
5102 (defvar gnus-tmp-dummy-line nil)
5104 (defun gnus-extra-header (type &optional header)
5105 "Return the extra header of TYPE."
5106 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5107 ""))
5109 (defvar gnus-tmp-thread-tree-header-string "")
5111 (defcustom gnus-sum-thread-tree-root "> "
5112 "With %B spec, used for the root of a thread.
5113 If nil, use subject instead."
5114 :version "22.1"
5115 :type '(radio (const :format "%v " nil) string)
5116 :group 'gnus-thread)
5118 (defcustom gnus-sum-thread-tree-false-root "> "
5119 "With %B spec, used for a false root of a thread.
5120 If nil, use subject instead."
5121 :version "22.1"
5122 :type '(radio (const :format "%v " nil) string)
5123 :group 'gnus-thread)
5125 (defcustom gnus-sum-thread-tree-single-indent ""
5126 "With %B spec, used for a thread with just one message.
5127 If nil, use subject instead."
5128 :version "22.1"
5129 :type '(radio (const :format "%v " nil) string)
5130 :group 'gnus-thread)
5132 (defcustom gnus-sum-thread-tree-vertical "| "
5133 "With %B spec, used for drawing a vertical line."
5134 :version "22.1"
5135 :type 'string
5136 :group 'gnus-thread)
5138 (defcustom gnus-sum-thread-tree-indent " "
5139 "With %B spec, used for indenting."
5140 :version "22.1"
5141 :type 'string
5142 :group 'gnus-thread)
5144 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5145 "With %B spec, used for a leaf with brothers."
5146 :version "22.1"
5147 :type 'string
5148 :group 'gnus-thread)
5150 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5151 "With %B spec, used for a leaf without brothers."
5152 :version "22.1"
5153 :type 'string
5154 :group 'gnus-thread)
5156 (defcustom gnus-summary-display-while-building nil
5157 "If non-nil, show and update the summary buffer as it's being built.
5158 If the value is t, update the buffer after every line is inserted. If
5159 the value is an integer (N), update the display every N lines."
5160 :version "22.1"
5161 :group 'gnus-thread
5162 :type '(choice (const :tag "off" nil)
5163 number
5164 (const :tag "frequently" t)))
5166 (defun gnus-summary-prepare-threads (threads)
5167 "Prepare summary buffer from THREADS and indentation LEVEL.
5168 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5169 or a straight list of headers."
5170 (gnus-message 7 "Generating summary...")
5172 (setq gnus-newsgroup-threads threads)
5173 (beginning-of-line)
5175 (let ((gnus-tmp-level 0)
5176 (default-score (or gnus-summary-default-score 0))
5177 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5178 (building-line-count gnus-summary-display-while-building)
5179 (building-count (integerp gnus-summary-display-while-building))
5180 thread number subject stack state gnus-tmp-gathered beg-match
5181 new-roots gnus-tmp-new-adopts thread-end simp-subject
5182 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5183 gnus-tmp-replied gnus-tmp-subject-or-nil
5184 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5185 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5186 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5187 tree-stack)
5189 (setq gnus-tmp-prev-subject nil
5190 gnus-tmp-thread-tree-header-string "")
5192 (if (vectorp (car threads))
5193 ;; If this is a straight (sic) list of headers, then a
5194 ;; threaded summary display isn't required, so we just create
5195 ;; an unthreaded one.
5196 (gnus-summary-prepare-unthreaded threads)
5198 ;; Do the threaded display.
5200 (if gnus-summary-display-while-building
5201 (switch-to-buffer (buffer-name)))
5202 (while (or threads stack gnus-tmp-new-adopts new-roots)
5204 (if (and (= gnus-tmp-level 0)
5205 (or (not stack)
5206 (= (caar stack) 0))
5207 (not gnus-tmp-false-parent)
5208 (or gnus-tmp-new-adopts new-roots))
5209 (if gnus-tmp-new-adopts
5210 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5211 thread (list (car gnus-tmp-new-adopts))
5212 gnus-tmp-header (caar thread)
5213 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5214 (when new-roots
5215 (setq thread (list (car new-roots))
5216 gnus-tmp-header (caar thread)
5217 new-roots (cdr new-roots))))
5219 (if threads
5220 ;; If there are some threads, we do them before the
5221 ;; threads on the stack.
5222 (setq thread threads
5223 gnus-tmp-header (caar thread))
5224 ;; There were no current threads, so we pop something off
5225 ;; the stack.
5226 (setq state (car stack)
5227 gnus-tmp-level (car state)
5228 tree-stack (cadr state)
5229 thread (caddr state)
5230 stack (cdr stack)
5231 gnus-tmp-header (caar thread))))
5233 (setq gnus-tmp-false-parent nil)
5234 (setq gnus-tmp-root-expunged nil)
5235 (setq thread-end nil)
5237 (if (stringp gnus-tmp-header)
5238 ;; The header is a dummy root.
5239 (cond
5240 ((eq gnus-summary-make-false-root 'adopt)
5241 ;; We let the first article adopt the rest.
5242 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5243 (cddar thread)))
5244 (setq gnus-tmp-gathered
5245 (nconc (mapcar
5246 (lambda (h) (mail-header-number (car h)))
5247 (cddar thread))
5248 gnus-tmp-gathered))
5249 (setq thread (cons (list (caar thread)
5250 (cadar thread))
5251 (cdr thread)))
5252 (setq gnus-tmp-level -1
5253 gnus-tmp-false-parent t))
5254 ((eq gnus-summary-make-false-root 'empty)
5255 ;; We print adopted articles with empty subject fields.
5256 (setq gnus-tmp-gathered
5257 (nconc (mapcar
5258 (lambda (h) (mail-header-number (car h)))
5259 (cddar thread))
5260 gnus-tmp-gathered))
5261 (setq gnus-tmp-level -1))
5262 ((eq gnus-summary-make-false-root 'dummy)
5263 ;; We remember that we probably want to output a dummy
5264 ;; root.
5265 (setq gnus-tmp-dummy-line gnus-tmp-header)
5266 (setq gnus-tmp-prev-subject gnus-tmp-header))
5268 ;; We do not make a root for the gathered
5269 ;; sub-threads at all.
5270 (setq gnus-tmp-level -1)))
5272 (setq number (mail-header-number gnus-tmp-header)
5273 subject (mail-header-subject gnus-tmp-header)
5274 simp-subject (gnus-simplify-subject-fully subject))
5276 (cond
5277 ;; If the thread has changed subject, we might want to make
5278 ;; this subthread into a root.
5279 ((and (null gnus-thread-ignore-subject)
5280 (not (zerop gnus-tmp-level))
5281 gnus-tmp-prev-subject
5282 (not (string= gnus-tmp-prev-subject simp-subject)))
5283 (setq new-roots (nconc new-roots (list (car thread)))
5284 thread-end t
5285 gnus-tmp-header nil))
5286 ;; If the article lies outside the current limit,
5287 ;; then we do not display it.
5288 ((not (memq number gnus-newsgroup-limit))
5289 (setq gnus-tmp-gathered
5290 (nconc (mapcar
5291 (lambda (h) (mail-header-number (car h)))
5292 (cdar thread))
5293 gnus-tmp-gathered))
5294 (setq gnus-tmp-new-adopts (if (cdar thread)
5295 (append gnus-tmp-new-adopts
5296 (cdar thread))
5297 gnus-tmp-new-adopts)
5298 thread-end t
5299 gnus-tmp-header nil)
5300 (when (zerop gnus-tmp-level)
5301 (setq gnus-tmp-root-expunged t)))
5302 ;; Perhaps this article is to be marked as read?
5303 ((and gnus-summary-mark-below
5304 (< (or (cdr (assq number gnus-newsgroup-scored))
5305 default-score)
5306 gnus-summary-mark-below)
5307 ;; Don't touch sparse articles.
5308 (not (gnus-summary-article-sparse-p number))
5309 (not (gnus-summary-article-ancient-p number)))
5310 (setq gnus-newsgroup-unreads
5311 (delq number gnus-newsgroup-unreads))
5312 (if gnus-newsgroup-auto-expire
5313 (setq gnus-newsgroup-expirable
5314 (gnus-add-to-sorted-list
5315 gnus-newsgroup-expirable number))
5316 (push (cons number gnus-low-score-mark)
5317 gnus-newsgroup-reads))))
5319 (when gnus-tmp-header
5320 ;; We may have an old dummy line to output before this
5321 ;; article.
5322 (when (and gnus-tmp-dummy-line
5323 (gnus-subject-equal
5324 gnus-tmp-dummy-line
5325 (mail-header-subject gnus-tmp-header)))
5326 (gnus-summary-insert-dummy-line
5327 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5328 (setq gnus-tmp-dummy-line nil))
5330 ;; Compute the mark.
5331 (setq gnus-tmp-unread (gnus-article-mark number))
5333 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5334 gnus-tmp-header gnus-tmp-level)
5335 gnus-newsgroup-data)
5337 ;; Actually insert the line.
5338 (setq
5339 gnus-tmp-subject-or-nil
5340 (cond
5341 ((and gnus-thread-ignore-subject
5342 gnus-tmp-prev-subject
5343 (not (string= gnus-tmp-prev-subject simp-subject)))
5344 subject)
5345 ((zerop gnus-tmp-level)
5346 (if (and (eq gnus-summary-make-false-root 'empty)
5347 (memq number gnus-tmp-gathered)
5348 gnus-tmp-prev-subject
5349 (string= gnus-tmp-prev-subject simp-subject))
5350 gnus-summary-same-subject
5351 subject))
5352 (t gnus-summary-same-subject)))
5353 (if (and (eq gnus-summary-make-false-root 'adopt)
5354 (= gnus-tmp-level 1)
5355 (memq number gnus-tmp-gathered))
5356 (setq gnus-tmp-opening-bracket ?\<
5357 gnus-tmp-closing-bracket ?\>)
5358 (setq gnus-tmp-opening-bracket ?\[
5359 gnus-tmp-closing-bracket ?\]))
5360 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5361 (gnus-make-thread-indent-array
5362 (max (* 2 (length gnus-thread-indent-array))
5363 gnus-tmp-level)))
5364 (setq
5365 gnus-tmp-indentation
5366 (aref gnus-thread-indent-array gnus-tmp-level)
5367 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5368 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5369 gnus-summary-default-score 0)
5370 gnus-tmp-score-char
5371 (if (or (null gnus-summary-default-score)
5372 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5373 gnus-summary-zcore-fuzz))
5374 ? ;Whitespace
5375 (if (< gnus-tmp-score gnus-summary-default-score)
5376 gnus-score-below-mark gnus-score-over-mark))
5377 gnus-tmp-replied
5378 (cond ((memq number gnus-newsgroup-processable)
5379 gnus-process-mark)
5380 ((memq number gnus-newsgroup-cached)
5381 gnus-cached-mark)
5382 ((memq number gnus-newsgroup-replied)
5383 gnus-replied-mark)
5384 ((memq number gnus-newsgroup-forwarded)
5385 gnus-forwarded-mark)
5386 ((memq number gnus-newsgroup-saved)
5387 gnus-saved-mark)
5388 ((memq number gnus-newsgroup-unseen)
5389 gnus-unseen-mark)
5390 (t gnus-no-mark))
5391 gnus-tmp-downloaded
5392 (cond ((memq number gnus-newsgroup-undownloaded)
5393 gnus-undownloaded-mark)
5394 (gnus-newsgroup-agentized
5395 gnus-downloaded-mark)
5397 gnus-no-mark))
5398 gnus-tmp-from (mail-header-from gnus-tmp-header)
5399 gnus-tmp-name
5400 (cond
5401 ((string-match "<[^>]+> *$" gnus-tmp-from)
5402 (setq beg-match (match-beginning 0))
5403 (or (and (string-match "^\".+\"" gnus-tmp-from)
5404 (substring gnus-tmp-from 1 (1- (match-end 0))))
5405 (substring gnus-tmp-from 0 beg-match)))
5406 ((string-match "(.+)" gnus-tmp-from)
5407 (substring gnus-tmp-from
5408 (1+ (match-beginning 0)) (1- (match-end 0))))
5409 (t gnus-tmp-from))
5411 ;; Do the %B string
5412 gnus-tmp-thread-tree-header-string
5413 (cond
5414 ((not gnus-show-threads) "")
5415 ((zerop gnus-tmp-level)
5416 (cond ((cdar thread)
5417 (or gnus-sum-thread-tree-root subject))
5418 (gnus-tmp-new-adopts
5419 (or gnus-sum-thread-tree-false-root subject))
5421 (or gnus-sum-thread-tree-single-indent subject))))
5423 (concat (apply 'concat
5424 (mapcar (lambda (item)
5425 (if (= item 1)
5426 gnus-sum-thread-tree-vertical
5427 gnus-sum-thread-tree-indent))
5428 (cdr (reverse tree-stack))))
5429 (if (nth 1 thread)
5430 gnus-sum-thread-tree-leaf-with-other
5431 gnus-sum-thread-tree-single-leaf)))))
5432 (when (string= gnus-tmp-name "")
5433 (setq gnus-tmp-name gnus-tmp-from))
5434 (unless (numberp gnus-tmp-lines)
5435 (setq gnus-tmp-lines -1))
5436 (if (= gnus-tmp-lines -1)
5437 (setq gnus-tmp-lines "?")
5438 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5439 (put-text-property
5440 (point)
5441 (progn (eval gnus-summary-line-format-spec) (point))
5442 'gnus-number number)
5443 (when gnus-visual-p
5444 (forward-line -1)
5445 (gnus-summary-highlight-line)
5446 (when gnus-summary-update-hook
5447 (gnus-run-hooks 'gnus-summary-update-hook))
5448 (forward-line 1))
5450 (setq gnus-tmp-prev-subject simp-subject)))
5452 (when (nth 1 thread)
5453 (push (list (max 0 gnus-tmp-level)
5454 (copy-sequence tree-stack)
5455 (nthcdr 1 thread))
5456 stack))
5457 (push (if (nth 1 thread) 1 0) tree-stack)
5458 (incf gnus-tmp-level)
5459 (setq threads (if thread-end nil (cdar thread)))
5460 (if gnus-summary-display-while-building
5461 (if building-count
5462 (progn
5463 ;; use a set frequency
5464 (setq building-line-count (1- building-line-count))
5465 (when (= building-line-count 0)
5466 (sit-for 0)
5467 (setq building-line-count
5468 gnus-summary-display-while-building)))
5469 ;; always
5470 (sit-for 0)))
5471 (unless threads
5472 (setq gnus-tmp-level 0)))))
5473 (gnus-message 7 "Generating summary...done"))
5475 (defun gnus-summary-prepare-unthreaded (headers)
5476 "Generate an unthreaded summary buffer based on HEADERS."
5477 (let (header number mark)
5479 (beginning-of-line)
5481 (while headers
5482 ;; We may have to root out some bad articles...
5483 (when (memq (setq number (mail-header-number
5484 (setq header (pop headers))))
5485 gnus-newsgroup-limit)
5486 ;; Mark article as read when it has a low score.
5487 (when (and gnus-summary-mark-below
5488 (< (or (cdr (assq number gnus-newsgroup-scored))
5489 gnus-summary-default-score 0)
5490 gnus-summary-mark-below)
5491 (not (gnus-summary-article-ancient-p number)))
5492 (setq gnus-newsgroup-unreads
5493 (delq number gnus-newsgroup-unreads))
5494 (if gnus-newsgroup-auto-expire
5495 (push number gnus-newsgroup-expirable)
5496 (push (cons number gnus-low-score-mark)
5497 gnus-newsgroup-reads)))
5499 (setq mark (gnus-article-mark number))
5500 (push (gnus-data-make number mark (1+ (point)) header 0)
5501 gnus-newsgroup-data)
5502 (gnus-summary-insert-line
5503 header 0 number
5504 (memq number gnus-newsgroup-undownloaded)
5505 mark (memq number gnus-newsgroup-replied)
5506 (memq number gnus-newsgroup-expirable)
5507 (mail-header-subject header) nil
5508 (cdr (assq number gnus-newsgroup-scored))
5509 (memq number gnus-newsgroup-processable))))))
5511 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5513 (defun gnus-group-get-list-identifiers (group)
5514 "Get list identifier regexp for GROUP."
5515 (or (gnus-parameter-list-identifier group)
5516 (if (consp gnus-list-identifiers)
5517 (mapconcat 'identity gnus-list-identifiers " *\\|")
5518 gnus-list-identifiers)))
5520 (defun gnus-summary-remove-list-identifiers ()
5521 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5522 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5523 changed subject)
5524 (when regexp
5525 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5526 (dolist (header gnus-newsgroup-headers)
5527 (setq subject (mail-header-subject header)
5528 changed nil)
5529 (while (string-match regexp subject)
5530 (setq subject
5531 (concat (substring subject 0 (match-beginning 1))
5532 (substring subject (match-end 0)))
5533 changed t))
5534 (when changed
5535 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5536 (setq subject
5537 (concat (substring subject 0 (match-beginning 1))
5538 (substring subject (match-end 1)))))
5539 (mail-header-set-subject header subject))))))
5541 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5542 "Fetch headers of ARTICLES."
5543 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5544 (gnus-message 7 "Fetching headers for %s..." name)
5545 (prog1
5546 (if (eq 'nov
5547 (setq gnus-headers-retrieved-by
5548 (gnus-retrieve-headers
5549 articles gnus-newsgroup-name
5550 (or limit
5551 ;; We might want to fetch old headers, but
5552 ;; not if there is only 1 article.
5553 (and (or (and
5554 (not (eq gnus-fetch-old-headers 'some))
5555 (not (numberp gnus-fetch-old-headers)))
5556 (> (length articles) 1))
5557 gnus-fetch-old-headers)))))
5558 (gnus-get-newsgroup-headers-xover
5559 articles force-new dependencies gnus-newsgroup-name t)
5560 (gnus-get-newsgroup-headers dependencies force-new))
5561 (gnus-message 7 "Fetching headers for %s...done" name))))
5563 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5564 "Select newsgroup GROUP.
5565 If READ-ALL is non-nil, all articles in the group are selected.
5566 If SELECT-ARTICLES, only select those articles from GROUP."
5567 (let* ((entry (gnus-group-entry group))
5568 ;;!!! Dirty hack; should be removed.
5569 (gnus-summary-ignore-duplicates
5570 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5572 gnus-summary-ignore-duplicates))
5573 (info (nth 2 entry))
5574 charset articles fetched-articles cached)
5576 (unless (gnus-check-server
5577 (set (make-local-variable 'gnus-current-select-method)
5578 (gnus-find-method-for-group group)))
5579 (error "Couldn't open server"))
5580 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5582 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5583 (gnus-activate-group group) ; Or we can activate it...
5584 (progn ; Or we bug out.
5585 (when (derived-mode-p 'gnus-summary-mode)
5586 (gnus-kill-buffer (current-buffer)))
5587 (error
5588 "Couldn't activate group %s: %s"
5589 (decode-coding-string group charset)
5590 (decode-coding-string (gnus-status-message group) charset))))
5592 (unless (gnus-request-group group t nil (gnus-get-info group))
5593 (when (derived-mode-p 'gnus-summary-mode)
5594 (gnus-kill-buffer (current-buffer)))
5595 (error "Couldn't request group %s: %s"
5596 (decode-coding-string group charset)
5597 (decode-coding-string (gnus-status-message group) charset)))
5599 (when (and gnus-agent
5600 (gnus-active group))
5601 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5603 (setq gnus-summary-use-undownloaded-faces
5604 (gnus-agent-find-parameter
5605 group
5606 'agent-enable-undownloaded-faces)))
5608 (setq gnus-newsgroup-name group
5609 gnus-newsgroup-unselected nil
5610 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5612 (let ((display (gnus-group-find-parameter group 'display)))
5613 (setq gnus-newsgroup-display
5614 (cond
5615 ((not (zerop (or (car-safe read-all) 0)))
5616 ;; The user entered the group with C-u SPC/RET, let's show
5617 ;; all articles.
5618 'gnus-not-ignore)
5619 ((eq display 'all)
5620 'gnus-not-ignore)
5621 ((arrayp display)
5622 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5623 ((numberp display)
5624 ;; The following is probably the "correct" solution, but
5625 ;; it makes Gnus fetch all headers and then limit the
5626 ;; articles (which is slow), so instead we hack the
5627 ;; select-articles parameter instead. -- Simon Josefsson
5628 ;; <jas@kth.se>
5630 ;; (gnus-byte-compile
5631 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5632 ;; display)))))
5633 (setq select-articles
5634 (gnus-uncompress-range
5635 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5636 (if (> tmp 0)
5639 (cdr (gnus-active group)))))
5640 nil)
5642 nil))))
5644 (gnus-summary-setup-default-charset)
5646 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5647 (when (gnus-virtual-group-p group)
5648 (setq cached gnus-newsgroup-cached))
5650 (setq gnus-newsgroup-unreads
5651 (gnus-sorted-ndifference
5652 (gnus-sorted-ndifference gnus-newsgroup-unreads
5653 gnus-newsgroup-marked)
5654 gnus-newsgroup-dormant))
5656 (setq gnus-newsgroup-processable nil)
5658 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5660 ;; Adjust and set lists of article marks.
5661 (when info
5662 (gnus-adjust-marked-articles info))
5663 (if (setq articles select-articles)
5664 (setq gnus-newsgroup-unselected
5665 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5666 (setq articles (gnus-articles-to-read group read-all)))
5668 (cond
5669 ((null articles)
5670 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5671 'quit)
5672 ((eq articles 0) nil)
5674 ;; Init the dependencies hash table.
5675 (setq gnus-newsgroup-dependencies
5676 (gnus-make-hashtable (length articles)))
5677 (if (gnus-buffer-live-p gnus-group-buffer)
5678 (gnus-set-global-variables)
5679 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5680 ;; Retrieve the headers and read them in.
5682 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5684 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5685 (when cached
5686 (setq gnus-newsgroup-cached cached))
5688 ;; Suppress duplicates?
5689 (when gnus-suppress-duplicates
5690 (gnus-dup-suppress-articles))
5692 ;; Set the initial limit.
5693 (setq gnus-newsgroup-limit (copy-sequence articles))
5694 ;; Remove canceled articles from the list of unread articles.
5695 (setq fetched-articles
5696 (mapcar (lambda (headers) (mail-header-number headers))
5697 gnus-newsgroup-headers))
5698 (setq gnus-newsgroup-articles fetched-articles)
5699 (setq gnus-newsgroup-unreads
5700 (gnus-sorted-nintersection
5701 gnus-newsgroup-unreads fetched-articles))
5702 (gnus-compute-unseen-list)
5704 ;; Removed marked articles that do not exist.
5705 (gnus-update-missing-marks
5706 (gnus-sorted-difference articles fetched-articles))
5707 ;; We might want to build some more threads first.
5708 (when (and gnus-fetch-old-headers
5709 (eq gnus-headers-retrieved-by 'nov))
5710 (if (eq gnus-fetch-old-headers 'invisible)
5711 (gnus-build-all-threads)
5712 (gnus-build-old-threads)))
5713 ;; Let the Gnus agent mark articles as read.
5714 (when gnus-agent
5715 (gnus-agent-get-undownloaded-list))
5716 ;; Remove list identifiers from subject
5717 (gnus-summary-remove-list-identifiers)
5718 ;; Check whether auto-expire is to be done in this group.
5719 (setq gnus-newsgroup-auto-expire
5720 (and (gnus-group-auto-expirable-p group)
5721 (not (gnus-group-read-only-p group))))
5722 ;; Set up the article buffer now, if necessary.
5723 (unless (and gnus-single-article-buffer
5724 (equal gnus-article-buffer "*Article*"))
5725 (gnus-article-setup-buffer))
5726 ;; First and last article in this newsgroup.
5727 (when gnus-newsgroup-headers
5728 (setq gnus-newsgroup-begin
5729 (mail-header-number (car gnus-newsgroup-headers))
5730 gnus-newsgroup-end
5731 (mail-header-number
5732 (gnus-last-element gnus-newsgroup-headers))))
5733 ;; GROUP is successfully selected.
5734 (or gnus-newsgroup-headers t)))))
5736 (defun gnus-compute-unseen-list ()
5737 ;; The `seen' marks are treated specially.
5738 (if (not gnus-newsgroup-seen)
5739 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5740 (setq gnus-newsgroup-unseen
5741 (gnus-inverse-list-range-intersection
5742 gnus-newsgroup-articles gnus-newsgroup-seen))))
5744 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5746 (defun gnus-summary-display-make-predicate (display)
5747 (require 'gnus-agent)
5748 (when (= (length display) 1)
5749 (setq display (car display)))
5750 (unless gnus-summary-display-cache
5751 (dolist (elem (append '((unread . unread)
5752 (read . read)
5753 (unseen . unseen))
5754 gnus-article-mark-lists))
5755 (push (cons (cdr elem)
5756 (gnus-byte-compile ;Why bother?
5757 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5758 gnus-summary-display-cache)))
5759 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5760 (gnus-category-predicate-cache gnus-summary-display-cache))
5761 (gnus-get-predicate display)))
5763 ;; Uses the dynamically bound `gnus-number' variable.
5764 (defvar gnus-number)
5765 (defun gnus-article-marked-p (type &optional article)
5766 (let ((article (or article gnus-number)))
5767 (cond
5768 ((eq type 'tick)
5769 (memq article gnus-newsgroup-marked))
5770 ((eq type 'spam)
5771 (memq article gnus-newsgroup-spam-marked))
5772 ((eq type 'unsend)
5773 (memq article gnus-newsgroup-unsendable))
5774 ((eq type 'undownload)
5775 (memq article gnus-newsgroup-undownloaded))
5776 ((eq type 'download)
5777 (memq article gnus-newsgroup-downloadable))
5778 ((eq type 'unread)
5779 (memq article gnus-newsgroup-unreads))
5780 ((eq type 'read)
5781 (memq article gnus-newsgroup-reads))
5782 ((eq type 'dormant)
5783 (memq article gnus-newsgroup-dormant) )
5784 ((eq type 'expire)
5785 (memq article gnus-newsgroup-expirable))
5786 ((eq type 'reply)
5787 (memq article gnus-newsgroup-replied))
5788 ((eq type 'killed)
5789 (memq article gnus-newsgroup-killed))
5790 ((eq type 'bookmark)
5791 (assq article gnus-newsgroup-bookmarks))
5792 ((eq type 'score)
5793 (assq article gnus-newsgroup-scored))
5794 ((eq type 'save)
5795 (memq article gnus-newsgroup-saved))
5796 ((eq type 'cache)
5797 (memq article gnus-newsgroup-cached))
5798 ((eq type 'forward)
5799 (memq article gnus-newsgroup-forwarded))
5800 ((eq type 'seen)
5801 (not (memq article gnus-newsgroup-unseen)))
5802 (t t))))
5804 (defun gnus-articles-to-read (group &optional read-all)
5805 "Find out what articles the user wants to read."
5806 (let* ((only-read-p t)
5807 (articles
5808 (gnus-list-range-difference
5809 ;; Select all articles if `read-all' is non-nil, or if there
5810 ;; are no unread articles.
5811 (if (or read-all
5812 (and (zerop (length gnus-newsgroup-marked))
5813 (zerop (length gnus-newsgroup-unreads)))
5814 ;; Fetch all if the predicate is non-nil.
5815 gnus-newsgroup-display)
5816 ;; We want to select the headers for all the articles in
5817 ;; the group, so we select either all the active
5818 ;; articles in the group, or (if that's nil), the
5819 ;; articles in the cache.
5821 (if gnus-newsgroup-maximum-articles
5822 (let ((active (gnus-active group)))
5823 (gnus-uncompress-range
5824 (cons (max (car active)
5825 (- (cdr active)
5826 gnus-newsgroup-maximum-articles
5827 -1))
5828 (cdr active))))
5829 (gnus-uncompress-range (gnus-active group)))
5830 (gnus-cache-articles-in-group group))
5831 ;; Select only the "normal" subset of articles.
5832 (setq only-read-p nil)
5833 (gnus-sorted-nunion
5834 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5835 gnus-newsgroup-unreads))
5836 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5837 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5838 (scored (length scored-list))
5839 (number (length articles))
5840 (marked (+ (length gnus-newsgroup-marked)
5841 (length gnus-newsgroup-dormant)))
5842 (select
5843 (cond
5844 ((numberp read-all)
5845 read-all)
5846 ((numberp gnus-newsgroup-display)
5847 gnus-newsgroup-display)
5849 (condition-case ()
5850 (cond
5851 ((and (or (<= scored marked) (= scored number))
5852 (numberp gnus-large-newsgroup)
5853 (> number gnus-large-newsgroup))
5854 (let* ((cursor-in-echo-area nil)
5855 (initial (gnus-parameter-large-newsgroup-initial
5856 gnus-newsgroup-name))
5857 (default (if only-read-p
5858 (or initial gnus-large-newsgroup)
5859 number))
5860 (input
5861 (read-string
5862 (if only-read-p
5863 (format
5864 "How many articles from %s (available %d, default %d): "
5865 (gnus-group-real-name
5866 (gnus-group-decoded-name gnus-newsgroup-name))
5867 number default)
5868 (format
5869 "How many articles from %s (%d default): "
5870 (gnus-group-real-name
5871 (gnus-group-decoded-name gnus-newsgroup-name))
5872 default))
5875 (number-to-string default))))
5876 (if (string-match "^[ \t]*$" input) number input)))
5877 ((and (> scored marked) (< scored number)
5878 (> (- scored number) 20))
5879 (let ((input
5880 (read-string
5881 (format "%s %s (%d scored, %d total): "
5882 "How many articles from"
5883 (gnus-group-decoded-name
5884 (gnus-group-real-name gnus-newsgroup-name))
5885 scored number))))
5886 (if (string-match "^[ \t]*$" input)
5887 number input)))
5888 (t number))
5889 (quit
5890 (message "Quit getting the articles to read")
5891 nil))))))
5892 (setq select (if (stringp select) (string-to-number select) select))
5893 (if (or (null select) (zerop select))
5894 select
5895 (if (and (not (zerop scored)) (<= (abs select) scored))
5896 (progn
5897 (setq articles (sort scored-list '<))
5898 (setq number (length articles)))
5899 (setq articles (copy-sequence articles)))
5901 (when (< (abs select) number)
5902 (if (< select 0)
5903 ;; Select the N oldest articles.
5904 (setcdr (nthcdr (1- (abs select)) articles) nil)
5905 ;; Select the N most recent articles.
5906 (setq articles (nthcdr (- number select) articles))))
5907 (setq gnus-newsgroup-unselected
5908 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5909 (when gnus-alter-articles-to-read-function
5910 (setq articles
5911 (sort
5912 (funcall gnus-alter-articles-to-read-function
5913 gnus-newsgroup-name articles)
5914 '<)))
5915 articles)))
5917 (defun gnus-killed-articles (killed articles)
5918 (let (out)
5919 (while articles
5920 (when (inline (gnus-member-of-range (car articles) killed))
5921 (push (car articles) out))
5922 (setq articles (cdr articles)))
5923 out))
5925 (defun gnus-article-mark-to-type (mark)
5926 "Return the type of MARK."
5927 (or (cadr (assq mark gnus-article-special-mark-lists))
5928 'list))
5930 (defun gnus-article-unpropagatable-p (mark)
5931 "Return whether MARK should be propagated to back end."
5932 (memq mark gnus-article-unpropagated-mark-lists))
5934 (defun gnus-adjust-marked-articles (info)
5935 "Set all article lists and remove all marks that are no longer valid."
5936 (let* ((marked-lists (gnus-info-marks info))
5937 (active (gnus-active (gnus-info-group info)))
5938 (min (car active))
5939 (max (cdr active))
5940 (types gnus-article-mark-lists)
5941 marks var articles article mark mark-type
5942 bgn end)
5943 ;; Hack to avoid adjusting marks for imap.
5944 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5945 'nnimap)
5946 (setq min 1))
5948 (dolist (marks marked-lists)
5949 (setq mark (car marks)
5950 mark-type (gnus-article-mark-to-type mark)
5951 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5952 ;; We set the variable according to the type of the marks list,
5953 ;; and then adjust the marks to a subset of the active articles.
5954 (cond
5955 ;; Adjust "simple" lists - compressed yet unsorted
5956 ((eq mark-type 'list)
5957 ;; Simultaneously uncompress and clip to active range
5958 ;; See gnus-uncompress-range for a description of possible marks
5959 (let (l lh)
5960 (if (not (cadr marks))
5961 (set var nil)
5962 (setq articles (if (numberp (cddr marks))
5963 (list (cdr marks))
5964 (cdr marks))
5965 lh (cons nil nil)
5966 l lh)
5968 (while (setq article (pop articles))
5969 (cond ((consp article)
5970 (setq bgn (max (car article) min)
5971 end (min (cdr article) max))
5972 (while (<= bgn end)
5973 (setq l (setcdr l (cons bgn nil))
5974 bgn (1+ bgn))))
5975 ((and (<= min article)
5976 (>= max article))
5977 (setq l (setcdr l (cons article nil))))))
5978 (set var (cdr lh)))))
5979 ;; Adjust assocs.
5980 ((eq mark-type 'tuple)
5981 (set var (setq articles (cdr marks)))
5982 (when (not (listp (cdr (symbol-value var))))
5983 (set var (list (symbol-value var))))
5984 (when (not (listp (cdr articles)))
5985 (setq articles (list articles)))
5986 (while articles
5987 (when (or (not (consp (setq article (pop articles))))
5988 (< (car article) min)
5989 (> (car article) max))
5990 (set var (delq article (symbol-value var))))))
5991 ;; Adjust ranges (sloppily).
5992 ((eq mark-type 'range)
5993 (cond
5994 ((eq mark 'seen)
5995 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5996 ;; It should be (seen (NUM1 . NUM2)).
5997 (when (numberp (cddr marks))
5998 (setcdr marks (list (cdr marks))))
5999 (setq articles (cdr marks))
6000 (while (and articles
6001 (or (and (consp (car articles))
6002 (> min (cdar articles)))
6003 (and (numberp (car articles))
6004 (> min (car articles)))))
6005 (pop articles))
6006 (set var articles))
6007 ((eq mark 'unexist)
6008 (set var (cdr marks)))))))))
6010 (defun gnus-update-missing-marks (missing)
6011 "Go through the list of MISSING articles and remove them from the mark lists."
6012 (when missing
6013 (let (var m)
6014 ;; Go through all types.
6015 (dolist (elem gnus-article-mark-lists)
6016 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6017 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6018 (when (symbol-value var)
6019 ;; This list has articles. So we delete all missing
6020 ;; articles from it.
6021 (setq m missing)
6022 (while m
6023 (set var (delq (pop m) (symbol-value var))))))))))
6025 (defun gnus-update-marks ()
6026 "Enter the various lists of marked articles into the newsgroup info list."
6027 (let ((types gnus-article-mark-lists)
6028 (info (gnus-get-info gnus-newsgroup-name))
6029 type list newmarked symbol delta-marks)
6030 (when info
6031 ;; Add all marks lists to the list of marks lists.
6032 (while (setq type (pop types))
6033 (setq list (symbol-value
6034 (setq symbol
6035 (intern (format "gnus-newsgroup-%s" (car type))))))
6037 (when list
6038 ;; Get rid of the entries of the articles that have the
6039 ;; default score.
6040 (when (and (eq (cdr type) 'score)
6041 gnus-save-score
6042 list)
6043 (let* ((arts list)
6044 (prev (cons nil list))
6045 (all prev))
6046 (while arts
6047 (if (or (not (consp (car arts)))
6048 (= (cdar arts) gnus-summary-default-score))
6049 (setcdr prev (cdr arts))
6050 (setq prev arts))
6051 (setq arts (cdr arts)))
6052 (setq list (cdr all)))))
6054 ;; When exiting the group, everything that's previously been
6055 ;; unseen is now seen.
6056 (when (eq (cdr type) 'seen)
6057 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6059 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6060 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6062 (when (and (gnus-check-backend-function
6063 'request-set-mark gnus-newsgroup-name)
6064 (not (gnus-article-unpropagatable-p (cdr type))))
6065 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6066 ;; Don't do anything about marks for articles we
6067 ;; didn't actually get any headers for.
6068 (del
6069 (gnus-list-range-intersection
6070 gnus-newsgroup-articles
6071 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6072 (add
6073 (gnus-list-range-intersection
6074 gnus-newsgroup-articles
6075 (gnus-remove-from-range
6076 (gnus-copy-sequence list) old))))
6077 (when add
6078 (push (list add 'add (list (cdr type))) delta-marks))
6079 (when del
6080 ;; Don't delete marks from outside the active range.
6081 ;; This shouldn't happen, but is a sanity check.
6082 (setq del (gnus-sorted-range-intersection
6083 (gnus-active gnus-newsgroup-name) del))
6084 (push (list del 'del (list (cdr type))) delta-marks))))
6086 (when (or list
6087 (eq (cdr type) 'unexist))
6088 (push (cons (cdr type) list) newmarked)))
6090 (when delta-marks
6091 (unless (gnus-check-group gnus-newsgroup-name)
6092 (error "Can't open server for %s" gnus-newsgroup-name))
6093 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6095 ;; Enter these new marks into the info of the group.
6096 (if (nthcdr 3 info)
6097 (setcar (nthcdr 3 info) newmarked)
6098 ;; Add the marks lists to the end of the info.
6099 (when newmarked
6100 (setcdr (nthcdr 2 info) (list newmarked))))
6102 ;; Cut off the end of the info if there's nothing else there.
6103 (let ((i 5))
6104 (while (and (> i 2)
6105 (not (nth i info)))
6106 (when (nthcdr (decf i) info)
6107 (setcdr (nthcdr i info) nil)))))))
6109 (defun gnus-set-mode-line (where)
6110 "Set the mode line of the article or summary buffers.
6111 If WHERE is `summary', the summary mode line format will be used."
6112 ;; Is this mode line one we keep updated?
6113 (when (and (memq where gnus-updated-mode-lines)
6114 (symbol-value
6115 (intern (format "gnus-%s-mode-line-format-spec" where))))
6116 (let (mode-string)
6117 ;; We evaluate this in the summary buffer since these
6118 ;; variables are buffer-local to that buffer.
6119 (with-current-buffer gnus-summary-buffer
6120 ;; We bind all these variables that are used in the `eval' form
6121 ;; below.
6122 (let* ((mformat (symbol-value
6123 (intern
6124 (format "gnus-%s-mode-line-format-spec" where))))
6125 (gnus-tmp-group-name (gnus-mode-string-quote
6126 (gnus-group-decoded-name
6127 gnus-newsgroup-name)))
6128 (gnus-tmp-article-number (or gnus-current-article 0))
6129 (gnus-tmp-unread gnus-newsgroup-unreads)
6130 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6131 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6132 (gnus-tmp-unread-and-unselected
6133 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6134 (zerop gnus-tmp-unselected))
6136 ((zerop gnus-tmp-unselected)
6137 (format "{%d more}" gnus-tmp-unread-and-unticked))
6138 (t (format "{%d(+%d) more}"
6139 gnus-tmp-unread-and-unticked
6140 gnus-tmp-unselected))))
6141 (gnus-tmp-subject
6142 (if (and gnus-current-headers
6143 (vectorp gnus-current-headers))
6144 (gnus-mode-string-quote
6145 (mail-header-subject gnus-current-headers))
6146 ""))
6147 bufname-length max-len
6148 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6149 (setq mode-string (eval mformat))
6150 (setq bufname-length (if (string-match "%b" mode-string)
6151 (- (length
6152 (buffer-name
6153 (if (eq where 'summary)
6155 (get-buffer gnus-article-buffer))))
6158 (setq max-len (max 4 (if gnus-mode-non-string-length
6159 (- (window-width)
6160 gnus-mode-non-string-length
6161 bufname-length)
6162 (length mode-string))))
6163 ;; We might have to chop a bit of the string off...
6164 (when (> (length mode-string) max-len)
6165 (setq mode-string
6166 (concat (truncate-string-to-width mode-string (- max-len 3))
6167 "...")))))
6168 ;; Update the mode line.
6169 (setq mode-line-buffer-identification
6170 (gnus-mode-line-buffer-identification (list mode-string)))
6171 (set-buffer-modified-p t))))
6173 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6174 "Go through the HEADERS list and add all Xrefs to a hash table.
6175 The resulting hash table is returned, or nil if no Xrefs were found."
6176 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6177 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6178 (xref-hashtb (gnus-make-hashtable))
6179 start group entry number xrefs header)
6180 (while headers
6181 (setq header (pop headers))
6182 (when (and (setq xrefs (mail-header-xref header))
6183 (not (memq (setq number (mail-header-number header))
6184 unreads)))
6185 (setq start 0)
6186 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6187 (setq start (match-end 0))
6188 (setq group (if prefix
6189 (concat prefix (substring xrefs (match-beginning 1)
6190 (match-end 1)))
6191 (substring xrefs (match-beginning 1) (match-end 1))))
6192 (setq number
6193 (string-to-number (substring xrefs (match-beginning 2)
6194 (match-end 2))))
6195 (if (setq entry (gnus-gethash group xref-hashtb))
6196 (setcdr entry (cons number (cdr entry)))
6197 (gnus-sethash group (cons number nil) xref-hashtb)))))
6198 (and start xref-hashtb)))
6200 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6201 "Look through all the headers and mark the Xrefs as read."
6202 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6203 name info xref-hashtb idlist method nth4)
6204 (with-current-buffer gnus-group-buffer
6205 (when (setq xref-hashtb
6206 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6207 (mapatoms
6208 (lambda (group)
6209 (unless (string= from-newsgroup (setq name (symbol-name group)))
6210 (setq idlist (symbol-value group))
6211 ;; Dead groups are not updated.
6212 (and (prog1
6213 (setq info (gnus-get-info name))
6214 (when (stringp (setq nth4 (gnus-info-method info)))
6215 (setq nth4 (gnus-server-to-method nth4))))
6216 ;; Only do the xrefs if the group has the same
6217 ;; select method as the group we have just read.
6218 (or (gnus-methods-equal-p
6219 nth4 (gnus-find-method-for-group from-newsgroup))
6220 virtual
6221 (equal nth4 (setq method (gnus-find-method-for-group
6222 from-newsgroup)))
6223 (and (equal (car nth4) (car method))
6224 (equal (nth 1 nth4) (nth 1 method))))
6225 gnus-use-cross-reference
6226 (or (not (eq gnus-use-cross-reference t))
6227 virtual
6228 ;; Only do cross-references on subscribed
6229 ;; groups, if that is what is wanted.
6230 (<= (gnus-info-level info) gnus-level-subscribed))
6231 (gnus-group-make-articles-read name idlist))))
6232 xref-hashtb)))))
6234 (defun gnus-compute-read-articles (group articles)
6235 (let* ((entry (gnus-group-entry group))
6236 (info (nth 2 entry))
6237 (active (gnus-active group))
6238 ninfo)
6239 (when entry
6240 ;; First peel off all invalid article numbers.
6241 (when active
6242 (let ((ids articles)
6243 id first)
6244 (while (setq id (pop ids))
6245 (when (and first (> id (cdr active)))
6246 ;; We'll end up in this situation in one particular
6247 ;; obscure situation. If you re-scan a group and get
6248 ;; a new article that is cross-posted to a different
6249 ;; group that has not been re-scanned, you might get
6250 ;; crossposted article that has a higher number than
6251 ;; Gnus believes possible. So we re-activate this
6252 ;; group as well. This might mean doing the
6253 ;; crossposting thingy will *increase* the number
6254 ;; of articles in some groups. Tsk, tsk.
6255 (setq active (or (gnus-activate-group group) active)))
6256 (when (or (> id (cdr active))
6257 (< id (car active)))
6258 (setq articles (delq id articles))))))
6259 ;; If the read list is nil, we init it.
6260 (if (and active
6261 (null (gnus-info-read info))
6262 (> (car active) 1))
6263 (setq ninfo (cons 1 (1- (car active))))
6264 (setq ninfo (gnus-info-read info)))
6265 ;; Then we add the read articles to the range.
6266 (gnus-add-to-range
6267 ninfo (setq articles (sort articles '<))))))
6269 (defun gnus-group-make-articles-read (group articles)
6270 "Update the info of GROUP to say that ARTICLES are read."
6271 (let* ((num 0)
6272 (entry (gnus-group-entry group))
6273 (info (nth 2 entry))
6274 (active (gnus-active group))
6275 (set-marks
6276 (gnus-method-option-p
6277 (gnus-find-method-for-group group)
6278 'server-marks))
6279 range)
6280 (if (not entry)
6281 ;; Group that Gnus doesn't know exists, but still allow the
6282 ;; backend to set marks.
6283 (when set-marks
6284 (gnus-request-set-mark
6285 group (list (list (gnus-compress-sequence (sort articles #'<))
6286 'add '(read)))))
6287 ;; Normal, subscribed groups.
6288 (setq range (gnus-compute-read-articles group articles))
6289 (with-current-buffer gnus-group-buffer
6290 (gnus-undo-register
6291 `(progn
6292 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6293 (gnus-info-set-read ',info ',(gnus-info-read info))
6294 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6295 (when ,set-marks
6296 (gnus-request-set-mark
6297 ,group (list (list ',range 'del '(read)))))
6298 (gnus-group-update-group ,group t))))
6299 ;; Add the read articles to the range.
6300 (gnus-info-set-read info range)
6301 (when set-marks
6302 (gnus-request-set-mark group (list (list range 'add '(read)))))
6303 ;; Then we have to re-compute how many unread
6304 ;; articles there are in this group.
6305 (when active
6306 (cond
6307 ((not range)
6308 (setq num (- (1+ (cdr active)) (car active))))
6309 ((not (listp (cdr range)))
6310 (setq num (- (cdr active) (- (1+ (cdr range))
6311 (car range)))))
6313 (while range
6314 (if (numberp (car range))
6315 (setq num (1+ num))
6316 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6317 (setq range (cdr range)))
6318 (setq num (- (cdr active) num))))
6319 ;; Update the number of unread articles.
6320 (setcar entry num)
6321 ;; Update the group buffer.
6322 (unless (gnus-ephemeral-group-p group)
6323 (gnus-group-update-group group t))))))
6325 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6326 (let ((cur nntp-server-buffer)
6327 (dependencies
6328 (or dependencies
6329 (with-current-buffer gnus-summary-buffer
6330 gnus-newsgroup-dependencies)))
6331 headers id end ref number
6332 (mail-parse-charset gnus-newsgroup-charset)
6333 (mail-parse-ignored-charsets
6334 (save-current-buffer (condition-case nil
6335 (set-buffer gnus-summary-buffer)
6336 (error))
6337 gnus-newsgroup-ignored-charsets)))
6338 (with-current-buffer nntp-server-buffer
6339 ;; Translate all TAB characters into SPACE characters.
6340 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6341 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6342 (ietf-drums-unfold-fws)
6343 (gnus-run-hooks 'gnus-parse-headers-hook)
6344 (let ((case-fold-search t)
6345 in-reply-to header p lines chars)
6346 (goto-char (point-min))
6347 ;; Search to the beginning of the next header. Error messages
6348 ;; do not begin with 2 or 3.
6349 (while (re-search-forward "^[23][0-9]+ " nil t)
6350 (setq id nil
6351 ref nil)
6352 ;; This implementation of this function, with nine
6353 ;; search-forwards instead of the one re-search-forward and
6354 ;; a case (which basically was the old function) is actually
6355 ;; about twice as fast, even though it looks messier. You
6356 ;; can't have everything, I guess. Speed and elegance
6357 ;; doesn't always go hand in hand.
6358 (setq
6359 header
6360 (vector
6361 ;; Number.
6362 (prog1
6363 (setq number (read cur))
6364 (end-of-line)
6365 (setq p (point))
6366 (narrow-to-region (point)
6367 (or (and (search-forward "\n.\n" nil t)
6368 (- (point) 2))
6369 (point))))
6370 ;; Subject.
6371 (progn
6372 (goto-char p)
6373 (if (search-forward "\nsubject:" nil t)
6374 (funcall gnus-decode-encoded-word-function
6375 (nnheader-header-value))
6376 "(none)"))
6377 ;; From.
6378 (progn
6379 (goto-char p)
6380 (if (search-forward "\nfrom:" nil t)
6381 (funcall gnus-decode-encoded-address-function
6382 (nnheader-header-value))
6383 "(nobody)"))
6384 ;; Date.
6385 (progn
6386 (goto-char p)
6387 (if (search-forward "\ndate:" nil t)
6388 (nnheader-header-value) ""))
6389 ;; Message-ID.
6390 (progn
6391 (goto-char p)
6392 (setq id (if (re-search-forward
6393 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6394 ;; We do it this way to make sure the Message-ID
6395 ;; is (somewhat) syntactically valid.
6396 (buffer-substring (match-beginning 1)
6397 (match-end 1))
6398 ;; If there was no message-id, we just fake one
6399 ;; to make subsequent routines simpler.
6400 (nnheader-generate-fake-message-id number))))
6401 ;; References.
6402 (progn
6403 (goto-char p)
6404 (if (search-forward "\nreferences:" nil t)
6405 (progn
6406 (setq end (point))
6407 (prog1
6408 (nnheader-header-value)
6409 (setq ref
6410 (buffer-substring
6411 (progn
6412 (end-of-line)
6413 (search-backward ">" end t)
6414 (1+ (point)))
6415 (progn
6416 (search-backward "<" end t)
6417 (point))))))
6418 ;; Get the references from the in-reply-to header if there
6419 ;; were no references and the in-reply-to header looks
6420 ;; promising.
6421 (if (and (search-forward "\nin-reply-to:" nil t)
6422 (setq in-reply-to (nnheader-header-value))
6423 (string-match "<[^>]+>" in-reply-to))
6424 (let (ref2)
6425 (setq ref (substring in-reply-to (match-beginning 0)
6426 (match-end 0)))
6427 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6428 (setq ref2 (substring in-reply-to (match-beginning 0)
6429 (match-end 0)))
6430 (when (> (length ref2) (length ref))
6431 (setq ref ref2)))
6432 ref)
6433 (setq ref nil))))
6434 ;; Chars.
6435 (progn
6436 (goto-char p)
6437 (if (search-forward "\nchars: " nil t)
6438 (if (numberp (setq chars (ignore-errors (read cur))))
6439 chars -1)
6440 -1))
6441 ;; Lines.
6442 (progn
6443 (goto-char p)
6444 (if (search-forward "\nlines: " nil t)
6445 (if (numberp (setq lines (ignore-errors (read cur))))
6446 lines -1)
6447 -1))
6448 ;; Xref.
6449 (progn
6450 (goto-char p)
6451 (and (search-forward "\nxref:" nil t)
6452 (nnheader-header-value)))
6453 ;; Extra.
6454 (when gnus-extra-headers
6455 (let ((extra gnus-extra-headers)
6456 out)
6457 (while extra
6458 (goto-char p)
6459 (when (search-forward
6460 (concat "\n" (symbol-name (car extra)) ":") nil t)
6461 (push (cons (car extra) (nnheader-header-value))
6462 out))
6463 (pop extra))
6464 out))))
6465 (when (equal id ref)
6466 (setq ref nil))
6468 (when gnus-alter-header-function
6469 (funcall gnus-alter-header-function header)
6470 (setq id (mail-header-id header)
6471 ref (gnus-parent-id (mail-header-references header))))
6473 (when (setq header
6474 (gnus-dependencies-add-header
6475 header dependencies force-new))
6476 (push header headers))
6477 (goto-char (point-max))
6478 (widen))
6479 (nreverse headers)))))
6481 ;; Goes through the xover lines and returns a list of vectors
6482 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6483 force-new dependencies
6484 group also-fetch-heads)
6485 "Parse the news overview data in the server buffer.
6486 Return a list of headers that match SEQUENCE (see
6487 `nntp-retrieve-headers')."
6488 ;; Get the Xref when the users reads the articles since most/some
6489 ;; NNTP servers do not include Xrefs when using XOVER.
6490 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6491 (let ((mail-parse-charset gnus-newsgroup-charset)
6492 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6493 (cur nntp-server-buffer)
6494 (dependencies (or dependencies gnus-newsgroup-dependencies))
6495 (allp (cond
6496 ((eq gnus-read-all-available-headers t)
6498 ((and (stringp gnus-read-all-available-headers)
6499 group)
6500 (string-match gnus-read-all-available-headers group))
6502 nil)))
6503 number headers header)
6504 (with-current-buffer nntp-server-buffer
6505 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6506 ;; Allow the user to mangle the headers before parsing them.
6507 (gnus-run-hooks 'gnus-parse-headers-hook)
6508 (goto-char (point-min))
6509 (gnus-parse-without-error
6510 (while (and (or sequence allp)
6511 (not (eobp)))
6512 (setq number (read cur))
6513 (when (not allp)
6514 (while (and sequence
6515 (< (car sequence) number))
6516 (setq sequence (cdr sequence))))
6517 (when (and (or allp
6518 (and sequence
6519 (eq number (car sequence))))
6520 (progn
6521 (setq sequence (cdr sequence))
6522 (setq header (inline
6523 (gnus-nov-parse-line
6524 number dependencies force-new)))))
6525 (push header headers))
6526 (forward-line 1)))
6527 ;; A common bug in inn is that if you have posted an article and
6528 ;; then retrieves the active file, it will answer correctly --
6529 ;; the new article is included. However, a NOV entry for the
6530 ;; article may not have been generated yet, so this may fail.
6531 ;; We work around this problem by retrieving the last few
6532 ;; headers using HEAD.
6533 (if (or (not also-fetch-heads)
6534 (not sequence))
6535 ;; We (probably) got all the headers.
6536 (nreverse headers)
6537 (let ((gnus-nov-is-evil t))
6538 (nconc
6539 (nreverse headers)
6540 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6541 (gnus-get-newsgroup-headers))))))))
6543 (defun gnus-article-get-xrefs ()
6544 "Fill in the Xref value in `gnus-current-headers', if necessary.
6545 This is meant to be called in `gnus-article-internal-prepare-hook'."
6546 (let ((headers (with-current-buffer gnus-summary-buffer
6547 gnus-current-headers)))
6548 (or (not gnus-use-cross-reference)
6549 (not headers)
6550 (and (mail-header-xref headers)
6551 (not (string= (mail-header-xref headers) "")))
6552 (let ((case-fold-search t)
6553 xref)
6554 (save-restriction
6555 (nnheader-narrow-to-headers)
6556 (goto-char (point-min))
6557 (when (or (and (not (eobp))
6558 (eq (downcase (char-after)) ?x)
6559 (looking-at "Xref:"))
6560 (search-forward "\nXref:" nil t))
6561 (goto-char (1+ (match-end 0)))
6562 (setq xref (buffer-substring (point) (point-at-eol)))
6563 (mail-header-set-xref headers xref)))))))
6565 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6566 "Find article ID and insert the summary line for that article.
6567 OLD-HEADER can either be a header or a line number to insert
6568 the subject line on.
6569 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6570 and OLD-HEADER will be used when the summary line is inserted,
6571 too, instead of trying to fetch new headers."
6572 (let* ((line (and (numberp old-header) old-header))
6573 (old-header (and (vectorp old-header) old-header))
6574 (header (cond ((and old-header use-old-header)
6575 old-header)
6576 ((and (numberp id)
6577 (gnus-number-to-header id))
6578 (gnus-number-to-header id))
6580 (gnus-read-header id))))
6581 (number (and (numberp id) id))
6583 (when header
6584 ;; Rebuild the thread that this article is part of and go to the
6585 ;; article we have fetched.
6586 (when (and (not gnus-show-threads)
6587 old-header)
6588 (when (and number
6589 (setq d (gnus-data-find (mail-header-number old-header))))
6590 (goto-char (gnus-data-pos d))
6591 (gnus-data-remove
6592 number
6593 (- (point-at-bol)
6594 (prog1
6595 (1+ (point-at-eol))
6596 (gnus-delete-line))))))
6597 ;; Remove list identifiers from subject.
6598 (let ((gnus-newsgroup-headers (list header)))
6599 (gnus-summary-remove-list-identifiers))
6600 (when old-header
6601 (mail-header-set-number header (mail-header-number old-header)))
6602 (setq gnus-newsgroup-sparse
6603 (delq (setq number (mail-header-number header))
6604 gnus-newsgroup-sparse))
6605 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6606 (push number gnus-newsgroup-limit)
6607 (gnus-rebuild-thread (mail-header-id header) line)
6608 (gnus-summary-goto-subject number nil t))
6609 (when (and (numberp number)
6610 (> number 0))
6611 ;; We have to update the boundaries even if we can't fetch the
6612 ;; article if ID is a number -- so that the next `P' or `N'
6613 ;; command will fetch the previous (or next) article even
6614 ;; if the one we tried to fetch this time has been canceled.
6615 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6616 (setq gnus-newsgroup-end number))
6617 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6618 (setq gnus-newsgroup-begin number))
6619 (setq gnus-newsgroup-unselected
6620 (delq number gnus-newsgroup-unselected)))
6621 ;; Report back a success?
6622 (and header (mail-header-number header))))
6624 ;;; Process/prefix in the summary buffer
6626 (defun gnus-summary-work-articles (n)
6627 "Return a list of articles to be worked upon.
6628 The prefix argument, the list of process marked articles, and the
6629 current article will be taken into consideration."
6630 (with-current-buffer gnus-summary-buffer
6631 (cond
6633 ;; A numerical prefix has been given.
6634 (setq n (prefix-numeric-value n))
6635 (let ((backward (< n 0))
6636 (n (abs (prefix-numeric-value n)))
6637 articles article)
6638 (save-excursion
6639 (while
6640 (and (> n 0)
6641 (push (setq article (gnus-summary-article-number))
6642 articles)
6643 (if backward
6644 (gnus-summary-find-prev nil article)
6645 (gnus-summary-find-next nil article)))
6646 (decf n)))
6647 (nreverse articles)))
6648 ((and (and transient-mark-mode mark-active) (mark))
6649 (message "region active")
6650 ;; Work on the region between point and mark.
6651 (let ((max (max (point) (mark)))
6652 articles article)
6653 (save-excursion
6654 (goto-char (min (point) (mark)))
6655 (while
6656 (and
6657 (push (setq article (gnus-summary-article-number)) articles)
6658 (gnus-summary-find-next nil article)
6659 (< (point) max)))
6660 (nreverse articles))))
6661 (gnus-newsgroup-processable
6662 ;; There are process-marked articles present.
6663 ;; Save current state.
6664 (gnus-summary-save-process-mark)
6665 ;; Return the list.
6666 (reverse gnus-newsgroup-processable))
6668 ;; Just return the current article.
6669 (list (gnus-summary-article-number))))))
6671 (defmacro gnus-summary-iterate (arg &rest forms)
6672 "Iterate over the process/prefixed articles and do FORMS.
6673 ARG is the interactive prefix given to the command. FORMS will be
6674 executed with point over the summary line of the articles."
6675 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6676 `(let ((,articles (gnus-summary-work-articles ,arg)))
6677 (while ,articles
6678 (gnus-summary-goto-subject (car ,articles))
6679 ,@forms
6680 (pop ,articles)))))
6682 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6683 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6685 (defun gnus-summary-save-process-mark ()
6686 "Push the current set of process marked articles on the stack."
6687 (interactive)
6688 (push (copy-sequence gnus-newsgroup-processable)
6689 gnus-newsgroup-process-stack))
6691 (defun gnus-summary-kill-process-mark ()
6692 "Push the current set of process marked articles on the stack and unmark."
6693 (interactive)
6694 (gnus-summary-save-process-mark)
6695 (gnus-summary-unmark-all-processable))
6697 (defun gnus-summary-yank-process-mark ()
6698 "Pop the last process mark state off the stack and restore it."
6699 (interactive)
6700 (unless gnus-newsgroup-process-stack
6701 (error "Empty mark stack"))
6702 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6704 (defun gnus-summary-process-mark-set (set)
6705 "Make SET into the current process marked articles."
6706 (gnus-summary-unmark-all-processable)
6707 (mapc 'gnus-summary-set-process-mark set))
6709 ;;; Searching and stuff
6711 (defun gnus-summary-search-group (&optional backward use-level)
6712 "Search for next unread newsgroup.
6713 If optional argument BACKWARD is non-nil, search backward instead."
6714 (with-current-buffer gnus-group-buffer
6715 (when (gnus-group-search-forward
6716 backward nil (if use-level (gnus-group-group-level) nil))
6717 (gnus-group-group-name))))
6719 (defun gnus-summary-best-group (&optional exclude-group)
6720 "Find the name of the best unread group.
6721 If EXCLUDE-GROUP, do not go to this group."
6722 (with-current-buffer gnus-group-buffer
6723 (save-excursion
6724 (gnus-group-best-unread-group exclude-group))))
6726 (defun gnus-summary-find-next (&optional unread article backward)
6727 (if backward
6728 (gnus-summary-find-prev unread article)
6729 (let* ((dummy (gnus-summary-article-intangible-p))
6730 (article (or article (gnus-summary-article-number)))
6731 (data (gnus-data-find-list article))
6732 result)
6733 (when (and (not dummy)
6734 (or (not gnus-summary-check-current)
6735 (not unread)
6736 (not (gnus-data-unread-p (car data)))))
6737 (setq data (cdr data)))
6738 (when (setq result
6739 (if unread
6740 (progn
6741 (while data
6742 (unless (memq (gnus-data-number (car data))
6743 (cond
6744 ((eq gnus-auto-goto-ignores
6745 'always-undownloaded)
6746 gnus-newsgroup-undownloaded)
6747 (gnus-plugged
6748 nil)
6749 ((eq gnus-auto-goto-ignores
6750 'unfetched)
6751 gnus-newsgroup-unfetched)
6752 ((eq gnus-auto-goto-ignores
6753 'undownloaded)
6754 gnus-newsgroup-undownloaded)))
6755 (when (gnus-data-unread-p (car data))
6756 (setq result (car data)
6757 data nil)))
6758 (setq data (cdr data)))
6759 result)
6760 (car data)))
6761 (goto-char (gnus-data-pos result))
6762 (gnus-data-number result)))))
6764 (defun gnus-summary-find-prev (&optional unread article)
6765 (let* ((eobp (eobp))
6766 (article (or article (gnus-summary-article-number)))
6767 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6768 result)
6769 (when (and (not eobp)
6770 (or (not gnus-summary-check-current)
6771 (not unread)
6772 (not (gnus-data-unread-p (car data)))))
6773 (setq data (cdr data)))
6774 (when (setq result
6775 (if unread
6776 (progn
6777 (while data
6778 (unless (memq (gnus-data-number (car data))
6779 (cond
6780 ((eq gnus-auto-goto-ignores
6781 'always-undownloaded)
6782 gnus-newsgroup-undownloaded)
6783 (gnus-plugged
6784 nil)
6785 ((eq gnus-auto-goto-ignores
6786 'unfetched)
6787 gnus-newsgroup-unfetched)
6788 ((eq gnus-auto-goto-ignores
6789 'undownloaded)
6790 gnus-newsgroup-undownloaded)))
6791 (when (gnus-data-unread-p (car data))
6792 (setq result (car data)
6793 data nil)))
6794 (setq data (cdr data)))
6795 result)
6796 (car data)))
6797 (goto-char (gnus-data-pos result))
6798 (gnus-data-number result))))
6800 (defun gnus-summary-find-subject (subject &optional unread backward article)
6801 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6802 (article (or article (gnus-summary-article-number)))
6803 (articles (gnus-data-list backward))
6804 (arts (gnus-data-find-list article articles))
6805 result)
6806 (when (or (not gnus-summary-check-current)
6807 (not unread)
6808 (not (gnus-data-unread-p (car arts))))
6809 (setq arts (cdr arts)))
6810 (while arts
6811 (and (or (not unread)
6812 (gnus-data-unread-p (car arts)))
6813 (vectorp (gnus-data-header (car arts)))
6814 (gnus-subject-equal
6815 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6816 (setq result (car arts)
6817 arts nil))
6818 (setq arts (cdr arts)))
6819 (and result
6820 (goto-char (gnus-data-pos result))
6821 (gnus-data-number result))))
6823 (defun gnus-summary-search-forward (&optional unread subject backward)
6824 "Search forward for an article.
6825 If UNREAD, look for unread articles. If SUBJECT, look for
6826 articles with that subject. If BACKWARD, search backward instead."
6827 (cond (subject (gnus-summary-find-subject subject unread backward))
6828 (backward (gnus-summary-find-prev unread))
6829 (t (gnus-summary-find-next unread))))
6831 (defun gnus-recenter (&optional n)
6832 "Center point in window and redisplay frame.
6833 Also do horizontal recentering."
6834 (interactive "P")
6835 (when (and gnus-auto-center-summary
6836 (not (eq gnus-auto-center-summary 'vertical)))
6837 (gnus-horizontal-recenter))
6838 (recenter-top-bottom n))
6840 (put 'gnus-recenter 'isearch-scroll t)
6842 (defun gnus-forward-line-ignore-invisible (n)
6843 "Move N lines forward (backward if N is negative).
6844 Like forward-line, but skip over (and don't count) invisible lines."
6845 (let (done)
6846 (while (and (> n 0) (not done))
6847 ;; If the following character is currently invisible,
6848 ;; skip all characters with that same `invisible' property value.
6849 (while (invisible-p (point))
6850 (goto-char (next-char-property-change (point))))
6851 (forward-line 1)
6852 (if (eobp)
6853 (setq done t)
6854 (setq n (1- n))))
6855 (while (and (< n 0) (not done))
6856 (forward-line -1)
6857 (if (bobp) (setq done t)
6858 (setq n (1+ n))
6859 (while (and (not (bobp)) (invisible-p (1- (point))))
6860 (goto-char (previous-char-property-change (point))))))))
6862 (defun gnus-summary-recenter ()
6863 "Center point in the summary window.
6864 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6865 displayed, no centering will be performed."
6866 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6867 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6868 (interactive)
6869 ;; The user has to want it.
6870 (when gnus-auto-center-summary
6871 (let* ((top (cond ((< (window-height) 4) 0)
6872 ((< (window-height) 7) 1)
6873 (t (if (numberp gnus-auto-center-summary)
6874 gnus-auto-center-summary
6875 (/ (1- (window-height)) 2)))))
6876 (height (1- (window-height)))
6877 (bottom (save-excursion
6878 (goto-char (point-max))
6879 (gnus-forward-line-ignore-invisible (- height))
6880 (point)))
6881 (window (get-buffer-window (current-buffer))))
6882 (when (get-buffer-window gnus-article-buffer)
6883 ;; Only do recentering when the article buffer is displayed,
6884 ;; Set the window start to either `bottom', which is the biggest
6885 ;; possible valid number, or the second line from the top,
6886 ;; whichever is the least.
6887 (let ((top-pos (save-excursion
6888 (gnus-forward-line-ignore-invisible (- top))
6889 (point))))
6890 (if (> bottom top-pos)
6891 ;; Keep the second line from the top visible
6892 (set-window-start window top-pos)
6893 ;; Try to keep the bottom line visible; if it's partially
6894 ;; obscured, either scroll one more line to make it fully
6895 ;; visible, or revert to using TOP-POS.
6896 (save-excursion
6897 (goto-char (point-max))
6898 (gnus-forward-line-ignore-invisible -1)
6899 (let ((last-line-start (point)))
6900 (goto-char bottom)
6901 (set-window-start window (point) t)
6902 (when (not (pos-visible-in-window-p last-line-start window))
6903 (gnus-forward-line-ignore-invisible 1)
6904 (set-window-start window (min (point) top-pos) t)))))))
6905 ;; Do horizontal recentering while we're at it.
6906 (when (and (get-buffer-window (current-buffer) t)
6907 (not (eq gnus-auto-center-summary 'vertical)))
6908 (let ((selected (selected-window)))
6909 (select-window (get-buffer-window (current-buffer) t))
6910 (gnus-summary-position-point)
6911 (gnus-horizontal-recenter)
6912 (select-window selected))))))
6914 (defun gnus-summary-jump-to-group (newsgroup)
6915 "Move point to NEWSGROUP in group mode buffer."
6916 ;; Keep update point of group mode buffer if visible.
6917 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6918 (save-window-excursion
6919 ;; Take care of tree window mode.
6920 (when (get-buffer-window gnus-group-buffer)
6921 (pop-to-buffer gnus-group-buffer))
6922 (gnus-group-jump-to-group newsgroup))
6923 (save-excursion
6924 ;; Take care of tree window mode.
6925 (if (get-buffer-window gnus-group-buffer 0)
6926 (pop-to-buffer gnus-group-buffer)
6927 (set-buffer gnus-group-buffer))
6928 (gnus-group-jump-to-group newsgroup))))
6930 ;; This function returns a list of article numbers based on the
6931 ;; difference between the ranges of read articles in this group and
6932 ;; the range of active articles.
6933 (defun gnus-list-of-unread-articles (group)
6934 (let* ((read (gnus-info-read (gnus-get-info group)))
6935 (active (or (gnus-active group) (gnus-activate-group group)))
6936 (last (or (cdr active)
6937 (error "Group %s couldn't be activated " group)))
6938 (bottom (if gnus-newsgroup-maximum-articles
6939 (max (car active)
6940 (- last gnus-newsgroup-maximum-articles -1))
6941 (car active)))
6942 first nlast unread)
6943 ;; If none are read, then all are unread.
6944 (if (not read)
6945 (setq first bottom)
6946 ;; If the range of read articles is a single range, then the
6947 ;; first unread article is the article after the last read
6948 ;; article. Sounds logical, doesn't it?
6949 (if (and (not (listp (cdr read)))
6950 (or (< (car read) bottom)
6951 (progn (setq read (list read))
6952 nil)))
6953 (setq first (max bottom (1+ (cdr read))))
6954 ;; `read' is a list of ranges.
6955 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6956 (caar read)))
6958 (setq first bottom))
6959 (while read
6960 (when first
6961 (while (< first nlast)
6962 (setq unread (cons first unread)
6963 first (1+ first))))
6964 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6965 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6966 (setq read (cdr read)))))
6967 ;; And add the last unread articles.
6968 (while (<= first last)
6969 (setq unread (cons first unread)
6970 first (1+ first)))
6971 ;; Return the list of unread articles.
6972 (delq 0 (nreverse unread))))
6974 (defun gnus-list-of-read-articles (group)
6975 "Return a list of unread, unticked and non-dormant articles."
6976 (let* ((info (gnus-get-info group))
6977 (marked (gnus-info-marks info))
6978 (active (gnus-active group)))
6979 (and info active
6980 (gnus-list-range-difference
6981 (gnus-list-range-difference
6982 (gnus-sorted-complement
6983 (gnus-uncompress-range
6984 (if gnus-newsgroup-maximum-articles
6985 (cons (max (car active)
6986 (- (cdr active)
6987 gnus-newsgroup-maximum-articles
6988 -1))
6989 (cdr active))
6990 active))
6991 (gnus-list-of-unread-articles group))
6992 (cdr (assq 'dormant marked)))
6993 (cdr (assq 'tick marked))))))
6995 ;; This function returns a sequence of article numbers based on the
6996 ;; difference between the ranges of read articles in this group and
6997 ;; the range of active articles.
6998 (defun gnus-sequence-of-unread-articles (group)
6999 (let* ((read (gnus-info-read (gnus-get-info group)))
7000 (active (or (gnus-active group) (gnus-activate-group group)))
7001 (last (cdr active))
7002 (bottom (if gnus-newsgroup-maximum-articles
7003 (max (car active)
7004 (- last gnus-newsgroup-maximum-articles -1))
7005 (car active)))
7006 first nlast unread)
7007 ;; If none are read, then all are unread.
7008 (if (not read)
7009 (setq first bottom)
7010 ;; If the range of read articles is a single range, then the
7011 ;; first unread article is the article after the last read
7012 ;; article. Sounds logical, doesn't it?
7013 (if (and (not (listp (cdr read)))
7014 (or (< (car read) bottom)
7015 (progn (setq read (list read))
7016 nil)))
7017 (setq first (max bottom (1+ (cdr read))))
7018 ;; `read' is a list of ranges.
7019 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7020 (caar read)))
7022 (setq first bottom))
7023 (while read
7024 (when first
7025 (push (cons first nlast) unread))
7026 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7027 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7028 (setq read (cdr read)))))
7029 ;; And add the last unread articles.
7030 (cond ((not (and first last))
7031 nil)
7032 ((< first last)
7033 (push (cons first last) unread))
7034 ((= first last)
7035 (push first unread)))
7036 ;; Return the sequence of unread articles.
7037 (delq 0 (nreverse unread))))
7039 ;; Various summary commands
7041 (defun gnus-summary-select-article-buffer ()
7042 "Reconfigure windows to show the article buffer.
7043 If `gnus-widen-article-window' is set, show only the article
7044 buffer."
7045 (interactive)
7046 (if (not (gnus-buffer-live-p gnus-article-buffer))
7047 (error "There is no article buffer for this summary buffer")
7048 (or (get-buffer-window gnus-article-buffer)
7049 (eq gnus-current-article (gnus-summary-article-number))
7050 (gnus-summary-show-article))
7051 (gnus-configure-windows
7052 (if gnus-widen-article-window
7053 'only-article
7054 'article)
7056 (select-window (get-buffer-window gnus-article-buffer))))
7058 (defun gnus-summary-universal-argument (arg)
7059 "Perform any operation on all articles that are process/prefixed."
7060 (interactive "P")
7061 (let ((articles (gnus-summary-work-articles arg))
7062 func article)
7063 (if (eq
7064 (setq
7065 func
7066 (key-binding
7067 (read-key-sequence
7068 (substitute-command-keys
7069 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7070 'undefined)
7071 (gnus-error 1 "Undefined key")
7072 (save-excursion
7073 (while articles
7074 (gnus-summary-goto-subject (setq article (pop articles)))
7075 (let (gnus-newsgroup-processable)
7076 (command-execute func))
7077 (gnus-summary-remove-process-mark article)))))
7078 (gnus-summary-position-point))
7080 (define-obsolete-function-alias
7081 'gnus-summary-toggle-truncation 'toggle-truncate-lines "26.1")
7083 (defun gnus-summary-find-for-reselect ()
7084 "Return the number of an article to stay on across a reselect.
7085 The current article is considered, then following articles, then previous
7086 articles. An article is sought which is not canceled and isn't a temporary
7087 insertion from another group. If there's no such then return a dummy 0."
7088 (let (found)
7089 (dolist (rev '(nil t))
7090 (unless found ; don't demand the reverse list if we don't need it
7091 (let ((data (gnus-data-find-list
7092 (gnus-summary-article-number) (gnus-data-list rev))))
7093 (while (and data (not found))
7094 (if (and (< 0 (gnus-data-number (car data)))
7095 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7096 (setq found (gnus-data-number (car data))))
7097 (setq data (cdr data))))))
7098 (or found 0)))
7100 (defun gnus-summary-reselect-current-group (&optional all rescan)
7101 "Exit and then reselect the current newsgroup.
7102 The prefix argument ALL means to select all articles."
7103 (interactive "P")
7104 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7105 (error "Ephemeral groups can't be reselected"))
7106 (let ((current-subject (gnus-summary-find-for-reselect))
7107 (group gnus-newsgroup-name))
7108 (setq gnus-newsgroup-begin nil)
7109 (gnus-summary-exit nil 'leave-hidden)
7110 ;; We have to adjust the point of group mode buffer because
7111 ;; point was moved to the next unread newsgroup by exiting.
7112 (gnus-summary-jump-to-group group)
7113 (when rescan
7114 (save-excursion
7115 (gnus-group-get-new-news-this-group 1)))
7116 (gnus-group-read-group all t)
7117 (gnus-summary-goto-subject current-subject nil t)))
7119 (defun gnus-summary-rescan-group (&optional all)
7120 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7121 (interactive "P")
7122 (let ((config gnus-current-window-configuration))
7123 (gnus-summary-reselect-current-group all t)
7124 (gnus-configure-windows config)
7125 (when (eq config 'article)
7126 (gnus-summary-select-article))))
7128 (defun gnus-summary-update-info (&optional non-destructive)
7129 (save-excursion
7130 (let ((group gnus-newsgroup-name))
7131 (when group
7132 (when gnus-newsgroup-kill-headers
7133 (setq gnus-newsgroup-killed
7134 (gnus-compress-sequence
7135 (gnus-sorted-union
7136 (gnus-list-range-intersection
7137 gnus-newsgroup-unselected gnus-newsgroup-killed)
7138 gnus-newsgroup-unreads)
7139 t)))
7140 (unless (listp (cdr gnus-newsgroup-killed))
7141 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7142 (let ((headers gnus-newsgroup-headers)
7143 (ephemeral-p (gnus-ephemeral-group-p group))
7144 info)
7145 (unless ephemeral-p
7146 (setq info (copy-sequence (gnus-get-info group))
7147 info (delq (gnus-info-params info) info)))
7148 ;; Set the new ranges of read articles.
7149 (with-current-buffer gnus-group-buffer
7150 (gnus-undo-force-boundary))
7151 (gnus-update-read-articles
7152 group (gnus-sorted-union
7153 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7154 ;; Set the current article marks.
7155 (let ((gnus-newsgroup-scored
7156 (if (and (not gnus-save-score)
7157 (not non-destructive))
7159 gnus-newsgroup-scored)))
7160 (save-excursion
7161 (gnus-update-marks)))
7162 ;; Do the cross-ref thing.
7163 (when gnus-use-cross-reference
7164 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7165 ;; Do not switch windows but change the buffer to work.
7166 (set-buffer gnus-group-buffer)
7167 (unless ephemeral-p
7168 (gnus-group-update-group
7169 group nil
7170 (equal info
7171 (setq info (copy-sequence (gnus-get-info group))
7172 info (delq (gnus-info-params info) info))))))))))
7174 (defun gnus-summary-save-newsrc (&optional force)
7175 "Save the current number of read/marked articles in the dribble buffer.
7176 The dribble buffer will then be saved.
7177 If FORCE (the prefix), also save the .newsrc file(s)."
7178 (interactive "P")
7179 (gnus-summary-update-info t)
7180 (if force
7181 (gnus-save-newsrc-file)
7182 (gnus-dribble-save)))
7184 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7185 (declare-function gnus-article-stop-animations "gnus-art" ())
7187 (defun gnus-summary-exit (&optional temporary leave-hidden)
7188 "Exit reading current newsgroup, and then return to group selection mode.
7189 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7190 (interactive)
7191 (gnus-set-global-variables)
7192 (when (gnus-buffer-live-p gnus-article-buffer)
7193 (with-current-buffer gnus-article-buffer
7194 (mm-destroy-parts gnus-article-mime-handles)
7195 ;; Set it to nil for safety reason.
7196 (setq gnus-article-mime-handle-alist nil)
7197 (setq gnus-article-mime-handles nil)))
7198 (gnus-kill-save-kill-buffer)
7199 (gnus-async-halt-prefetch)
7200 (let* ((group gnus-newsgroup-name)
7201 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7202 (gnus-group-is-exiting-p t)
7203 (article-buffer gnus-article-buffer)
7204 (original-article-buffer gnus-original-article-buffer)
7205 (mode major-mode)
7206 (group-point nil)
7207 (buf (current-buffer))
7208 ;; `gnus-single-article-buffer' is nil buffer-locally in
7209 ;; ephemeral group of which summary buffer will be killed,
7210 ;; but the global value may be non-nil.
7211 (single-article-buffer gnus-single-article-buffer))
7212 (unless quit-config
7213 ;; Do adaptive scoring, and possibly save score files.
7214 (when gnus-newsgroup-adaptive
7215 (gnus-score-adaptive))
7216 (when gnus-use-scoring
7217 (gnus-score-save)))
7218 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7219 (when gnus-use-cache
7220 (gnus-cache-possibly-remove-articles)
7221 (gnus-cache-save-buffers))
7222 (gnus-async-prefetch-remove-group group)
7223 (when gnus-suppress-duplicates
7224 (gnus-dup-enter-articles))
7225 (when gnus-use-trees
7226 (gnus-tree-close))
7227 (when gnus-use-cache
7228 (gnus-cache-write-active))
7229 ;; Remove entries for this group.
7230 (nnmail-purge-split-history (gnus-group-real-name group))
7231 ;; Make all changes in this group permanent.
7232 (unless quit-config
7233 (gnus-run-hooks 'gnus-exit-group-hook)
7234 (gnus-summary-update-info))
7235 (gnus-close-group group)
7236 ;; Make sure where we were, and go to next newsgroup.
7237 (when (buffer-live-p (get-buffer gnus-group-buffer))
7238 (set-buffer gnus-group-buffer))
7239 (unless quit-config
7240 (gnus-group-jump-to-group group))
7241 (gnus-run-hooks 'gnus-summary-exit-hook)
7242 (unless (or quit-config
7243 (not gnus-summary-next-group-on-exit)
7244 ;; If this group has disappeared from the summary
7245 ;; buffer, don't skip forwards.
7246 (not (string= group (gnus-group-group-name))))
7247 (gnus-group-next-unread-group 1))
7248 (setq group-point (point))
7249 (gnus-article-stop-animations)
7250 (if temporary
7251 nil ;Nothing to do.
7252 (set-buffer buf)
7253 (if (not gnus-kill-summary-on-exit)
7254 (progn
7255 (gnus-deaden-summary)
7256 (setq mode nil))
7257 (when (get-buffer gnus-article-buffer)
7258 (bury-buffer gnus-article-buffer))
7259 ;; Return to group mode buffer.
7260 (when (eq mode 'gnus-summary-mode)
7261 (gnus-kill-buffer buf)))
7263 (setq gnus-current-select-method gnus-select-method)
7264 (when (gnus-buffer-live-p gnus-group-buffer)
7265 (set-buffer gnus-group-buffer))
7266 (if quit-config
7267 (gnus-handle-ephemeral-exit quit-config)
7268 (goto-char group-point)
7269 ;; If gnus-group-buffer is already displayed, make sure we also move
7270 ;; the cursor in the window that displays it.
7271 (let ((win (get-buffer-window (current-buffer) 0)))
7272 (if win (set-window-point win (point))))
7273 (unless leave-hidden
7274 (gnus-configure-windows 'group 'force)))
7276 ;; If we have several article buffers, we kill them at exit.
7277 (unless single-article-buffer
7278 (when (gnus-buffer-live-p article-buffer)
7279 (with-current-buffer article-buffer
7280 ;; Don't kill sticky article buffers
7281 (unless (eq major-mode 'gnus-sticky-article-mode)
7282 (gnus-kill-buffer article-buffer)
7283 (setq gnus-article-current nil))))
7284 (gnus-kill-buffer original-article-buffer))
7286 ;; Clear the current group name.
7287 (unless quit-config
7288 (setq gnus-newsgroup-name nil)))))
7290 (declare-function gnus-stop-downloads "gnus-art" ())
7292 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7293 (defun gnus-summary-exit-no-update (&optional no-questions)
7294 "Quit reading current newsgroup without updating read article info."
7295 (interactive)
7296 (let* ((group gnus-newsgroup-name)
7297 (gnus-group-is-exiting-p t)
7298 (gnus-group-is-exiting-without-update-p t)
7299 (quit-config (gnus-group-quit-config group)))
7300 (when (or no-questions
7301 (gnus-ephemeral-group-p group)
7302 gnus-expert-user
7303 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7304 (gnus-async-halt-prefetch)
7305 (run-hooks 'gnus-summary-prepare-exit-hook)
7306 (when (gnus-buffer-live-p gnus-article-buffer)
7307 (with-current-buffer gnus-article-buffer
7308 (gnus-article-stop-animations)
7309 (gnus-stop-downloads)
7310 (mm-destroy-parts gnus-article-mime-handles)
7311 ;; Set it to nil for safety reason.
7312 (setq gnus-article-mime-handle-alist nil)
7313 (setq gnus-article-mime-handles nil)))
7314 ;; If we have several article buffers, we kill them at exit.
7315 (unless gnus-single-article-buffer
7316 (gnus-kill-buffer gnus-article-buffer)
7317 (gnus-kill-buffer gnus-original-article-buffer)
7318 (setq gnus-article-current nil))
7319 ;; Return to the group buffer.
7320 (if (not gnus-kill-summary-on-exit)
7321 (progn
7322 (gnus-deaden-summary)
7323 (gnus-configure-windows 'group 'force))
7324 (gnus-configure-windows 'group 'force)
7325 (gnus-close-group group)
7326 (gnus-kill-buffer gnus-summary-buffer))
7327 (unless gnus-single-article-buffer
7328 (setq gnus-article-current nil))
7329 (when gnus-use-trees
7330 (gnus-tree-close))
7331 (gnus-async-prefetch-remove-group group)
7332 (when (get-buffer gnus-article-buffer)
7333 (bury-buffer gnus-article-buffer))
7334 ;; Clear the current group name.
7335 (setq gnus-newsgroup-name nil)
7336 (unless (gnus-ephemeral-group-p group)
7337 (gnus-group-update-group group nil t))
7338 (when (equal (gnus-group-group-name) group)
7339 (gnus-group-next-unread-group 1))
7340 (gnus-article-stop-animations)
7341 (when quit-config
7342 (gnus-handle-ephemeral-exit quit-config)))))
7344 (defun gnus-handle-ephemeral-exit (quit-config)
7345 "Handle movement when leaving an ephemeral group.
7346 The state which existed when entering the ephemeral is reset."
7347 (if (not (buffer-live-p (car quit-config)))
7348 (when (gnus-buffer-live-p gnus-group-buffer)
7349 (gnus-configure-windows 'group 'force))
7350 (set-buffer (car quit-config))
7351 (unless (eq (cdr quit-config) 'group)
7352 (setq gnus-current-select-method
7353 (gnus-find-method-for-group gnus-newsgroup-name)))
7354 (cond ((derived-mode-p 'gnus-summary-mode)
7355 (gnus-set-global-variables))
7356 ((derived-mode-p 'gnus-article-mode)
7357 (save-current-buffer
7358 ;; The `gnus-summary-buffer' variable may point
7359 ;; to the old summary buffer when using a single
7360 ;; article buffer.
7361 (unless (gnus-buffer-live-p gnus-summary-buffer)
7362 (set-buffer gnus-group-buffer))
7363 (set-buffer gnus-summary-buffer)
7364 (gnus-set-global-variables))))
7365 (if (or (eq (cdr quit-config) 'article)
7366 (eq (cdr quit-config) 'pick))
7367 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7368 (gnus-configure-windows 'pick 'force)
7369 (gnus-configure-windows (cdr quit-config) 'force))
7370 (gnus-configure-windows (cdr quit-config) 'force))
7371 (when (derived-mode-p 'gnus-summary-mode)
7372 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7373 next-unread-noselect))
7374 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7375 'next-noselect)
7376 (gnus-summary-next-subject 1 nil t))
7377 ((eq gnus-auto-select-on-ephemeral-exit
7378 'next-unread-noselect)
7379 (gnus-summary-next-subject 1 t t))))
7380 ;; Hide the article buffer which displays the article different
7381 ;; from the one that the cursor points to in the summary buffer.
7382 (gnus-configure-windows 'summary 'force))
7383 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7384 (gnus-summary-next-subject 1))
7385 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7386 (gnus-summary-next-subject 1 t))))
7387 (gnus-summary-recenter)
7388 (gnus-summary-position-point))))
7390 ;;; Dead summaries.
7392 (defvar gnus-dead-summary-mode-map
7393 (let ((map (make-keymap)))
7394 (suppress-keymap map)
7395 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7396 (dolist (key '("\C-d" "\r" "\177" [delete]))
7397 (define-key map key 'gnus-summary-wake-up-the-dead))
7398 (dolist (key '("q" "Q"))
7399 (define-key map key 'bury-buffer))
7400 map))
7402 (define-minor-mode gnus-dead-summary-mode
7403 "Minor mode for Gnus summary buffers."
7404 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7405 (unless (derived-mode-p 'gnus-summary-mode)
7406 (setq gnus-dead-summary-mode nil)))
7408 (defun gnus-deaden-summary ()
7409 "Make the current summary buffer into a dead summary buffer."
7410 ;; Kill any previous dead summary buffer.
7411 (when (and gnus-dead-summary
7412 (buffer-name gnus-dead-summary))
7413 (with-current-buffer gnus-dead-summary
7414 (when gnus-dead-summary-mode
7415 (kill-buffer (current-buffer)))))
7416 ;; Make this the current dead summary.
7417 (setq gnus-dead-summary (current-buffer))
7418 (gnus-dead-summary-mode 1)
7419 (let ((name (buffer-name)))
7420 (when (string-match "Summary" name)
7421 (rename-buffer
7422 (concat (substring name 0 (match-beginning 0)) "Dead "
7423 (substring name (match-beginning 0)))
7425 (bury-buffer))))
7427 (defun gnus-kill-or-deaden-summary (buffer)
7428 "Kill or deaden the summary BUFFER."
7429 (save-excursion
7430 (when (and (buffer-name buffer)
7431 (not gnus-single-article-buffer))
7432 (with-current-buffer buffer
7433 (gnus-kill-buffer gnus-article-buffer)
7434 (gnus-kill-buffer gnus-original-article-buffer)))
7435 (cond
7436 ;; Kill the buffer.
7437 (gnus-kill-summary-on-exit
7438 (when (and gnus-use-trees
7439 (gnus-buffer-exists-p buffer))
7440 (with-current-buffer buffer
7441 (gnus-tree-close)))
7442 (gnus-kill-buffer buffer))
7443 ;; Deaden the buffer.
7444 ((gnus-buffer-exists-p buffer)
7445 (with-current-buffer buffer
7446 (gnus-deaden-summary))))))
7448 (defun gnus-summary-wake-up-the-dead (&rest args)
7449 "Wake up the dead summary buffer."
7450 (interactive)
7451 (gnus-dead-summary-mode -1)
7452 (let ((name (buffer-name)))
7453 (when (string-match "Dead " name)
7454 (rename-buffer
7455 (concat (substring name 0 (match-beginning 0))
7456 (substring name (match-end 0)))
7457 t)))
7458 (gnus-message 3 "This dead summary is now alive again"))
7460 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7461 (defun gnus-summary-describe-group (&optional force)
7462 "Describe the current newsgroup."
7463 (interactive "P")
7464 (gnus-group-describe-group force gnus-newsgroup-name))
7466 (defun gnus-summary-describe-briefly ()
7467 "Describe summary mode commands briefly."
7468 (interactive)
7469 (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")))
7471 ;; Walking around group mode buffer from summary mode.
7473 (defun gnus-summary-next-group (&optional no-article target-group backward)
7474 "Exit current newsgroup and then select next unread newsgroup.
7475 If prefix argument NO-ARTICLE is non-nil, no article is selected
7476 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7477 previous group instead."
7478 (interactive "P")
7479 ;; Stop pre-fetching.
7480 (gnus-async-halt-prefetch)
7481 (let ((current-group gnus-newsgroup-name)
7482 (current-buffer (current-buffer))
7483 entered)
7484 ;; First we semi-exit this group to update Xrefs and all variables.
7485 ;; We can't do a real exit, because the window conf must remain
7486 ;; the same in case the user is prompted for info, and we don't
7487 ;; want the window conf to change before that...
7488 (gnus-summary-exit t)
7489 (while (not entered)
7490 ;; Then we find what group we are supposed to enter.
7491 (set-buffer gnus-group-buffer)
7492 (gnus-group-jump-to-group current-group)
7493 (setq target-group
7494 (or target-group
7495 (if (eq gnus-keep-same-level 'best)
7496 (gnus-summary-best-group gnus-newsgroup-name)
7497 (gnus-summary-search-group backward gnus-keep-same-level))))
7498 (if (not target-group)
7499 ;; There are no further groups, so we return to the group
7500 ;; buffer.
7501 (progn
7502 (gnus-message 5 "Returning to the group buffer")
7503 (setq entered t)
7504 (when (gnus-buffer-live-p current-buffer)
7505 (set-buffer current-buffer)
7506 (gnus-summary-exit))
7507 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7508 ;; We try to enter the target group.
7509 (gnus-group-jump-to-group target-group)
7510 (let ((unreads (gnus-group-group-unread)))
7511 (if (and (or (eq t unreads)
7512 (and unreads (not (zerop unreads))))
7513 (gnus-summary-read-group
7514 target-group nil no-article
7515 (and (buffer-name current-buffer) current-buffer)
7516 nil backward))
7517 (setq entered t)
7518 (setq current-group target-group
7519 target-group nil)))))))
7521 (defun gnus-summary-prev-group (&optional no-article)
7522 "Exit current newsgroup and then select previous unread newsgroup.
7523 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7524 (interactive "P")
7525 (gnus-summary-next-group no-article nil t))
7527 ;; Walking around summary lines.
7529 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7530 "Go to the first subject satisfying any non-nil constraint.
7531 If UNREAD is non-nil, the article should be unread.
7532 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7533 If UNSEEN is non-nil, the article should be unseen as well as unread.
7534 Returns the article selected or nil if there are no matching articles."
7535 (interactive "P")
7536 (cond
7537 ;; Empty summary.
7538 ((null gnus-newsgroup-data)
7539 (gnus-message 3 "No articles in the group")
7540 nil)
7541 ;; Pick the first article.
7542 ((not (or unread undownloaded unseen))
7543 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7544 (gnus-data-number (car gnus-newsgroup-data)))
7545 ;; Find the first unread article.
7547 (let ((data gnus-newsgroup-data))
7548 (while (and data
7549 (let ((num (gnus-data-number (car data))))
7550 (or (memq num gnus-newsgroup-unfetched)
7551 (not (or (and unread
7552 (memq num gnus-newsgroup-unreads))
7553 (and undownloaded
7554 (memq num gnus-newsgroup-undownloaded))
7555 (and unseen
7556 (memq num gnus-newsgroup-unseen)
7557 (memq num gnus-newsgroup-unreads)))))))
7558 (setq data (cdr data)))
7559 (prog1
7560 (if data
7561 (progn
7562 (goto-char (gnus-data-pos (car data)))
7563 (gnus-data-number (car data)))
7564 (gnus-message 3 "No more%s articles"
7565 (let* ((r (when unread " unread"))
7566 (d (when undownloaded " undownloaded"))
7567 (s (when unseen " unseen"))
7568 (l (delq nil (list r d s))))
7569 (cond ((= 3 (length l))
7570 (concat r "," d ", or" s))
7571 ((= 2 (length l))
7572 (concat (car l) ", or" (cadr l)))
7573 ((= 1 (length l))
7574 (car l))
7576 ""))))
7579 (gnus-summary-position-point))))))
7581 (defun gnus-summary-next-subject (n &optional unread dont-display)
7582 "Go to next N'th summary line.
7583 If N is negative, go to the previous N'th subject line.
7584 If UNREAD is non-nil, only unread articles are selected.
7585 The difference between N and the actual number of steps taken is
7586 returned."
7587 (interactive "p")
7588 (let ((backward (< n 0))
7589 (n (abs n)))
7590 (while (and (> n 0)
7591 (if backward
7592 (gnus-summary-find-prev unread)
7593 (gnus-summary-find-next unread)))
7594 (unless (zerop (setq n (1- n)))
7595 (gnus-summary-show-thread)))
7596 (when (/= 0 n)
7597 (gnus-message 7 "No more%s articles"
7598 (if unread " unread" "")))
7599 (unless dont-display
7600 (gnus-summary-recenter)
7601 (gnus-summary-position-point))
7604 (defun gnus-summary-next-unread-subject (n)
7605 "Go to next N'th unread summary line."
7606 (interactive "p")
7607 (gnus-summary-next-subject n t))
7609 (defun gnus-summary-prev-subject (n &optional unread)
7610 "Go to previous N'th summary line.
7611 If optional argument UNREAD is non-nil, only unread article is selected."
7612 (interactive "p")
7613 (gnus-summary-next-subject (- n) unread))
7615 (defun gnus-summary-prev-unread-subject (n)
7616 "Go to previous N'th unread summary line."
7617 (interactive "p")
7618 (gnus-summary-next-subject (- n) t))
7620 (defun gnus-summary-goto-subjects (articles)
7621 "Insert the subject header for ARTICLES in the current buffer."
7622 (save-excursion
7623 (dolist (article articles)
7624 (gnus-summary-goto-subject article t)))
7625 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7626 (gnus-summary-position-point))
7628 (defun gnus-summary-goto-subject (article &optional force silent)
7629 "Go to the subject line of ARTICLE.
7630 If FORCE, also allow jumping to articles not currently shown."
7631 (interactive "nArticle number: ")
7632 (unless (numberp article)
7633 (error "Article %s is not a number" article))
7634 (let ((b (point))
7635 (data (gnus-data-find article)))
7636 ;; We read in the article if we have to.
7637 (and (not data)
7638 force
7639 (gnus-summary-insert-subject
7640 article
7641 (if (or (numberp force) (vectorp force)) force)
7643 (setq data (gnus-data-find article)))
7644 (goto-char b)
7645 (if (not data)
7646 (progn
7647 (unless silent
7648 (gnus-message 3 "Can't find article %d" article))
7649 nil)
7650 (let ((pt (gnus-data-pos data)))
7651 (goto-char pt)
7652 (gnus-summary-set-article-display-arrow pt))
7653 (gnus-summary-position-point)
7654 article)))
7656 ;; Walking around summary lines with displaying articles.
7658 (defun gnus-summary-expand-window (&optional arg)
7659 "Make the summary buffer take up the entire Emacs frame.
7660 Given a prefix, will force an `article' buffer configuration."
7661 (interactive "P")
7662 (if arg
7663 (gnus-configure-windows 'article 'force)
7664 (gnus-configure-windows 'summary 'force)))
7666 (defun gnus-summary-display-article (article &optional all-header)
7667 "Display ARTICLE in article buffer."
7668 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7669 (with-current-buffer gnus-article-buffer
7670 (derived-mode-p 'gnus-article-mode)))
7671 (gnus-article-setup-buffer))
7672 (gnus-set-global-variables)
7673 (with-current-buffer gnus-article-buffer
7674 (setq gnus-article-charset gnus-newsgroup-charset)
7675 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7676 (mm-enable-multibyte))
7677 (if (null article)
7679 (prog1
7680 (if gnus-summary-display-article-function
7681 (funcall gnus-summary-display-article-function article all-header)
7682 (gnus-article-prepare article all-header))
7683 (gnus-run-hooks 'gnus-select-article-hook)
7684 (when (and gnus-current-article
7685 (not (zerop gnus-current-article)))
7686 (gnus-summary-goto-subject gnus-current-article))
7687 (gnus-summary-recenter)
7688 (when (and gnus-use-trees gnus-show-threads)
7689 (gnus-possibly-generate-tree article)
7690 (gnus-highlight-selected-tree article))
7691 ;; Successfully display article.
7692 (gnus-article-set-window-start
7693 (cdr (assq article gnus-newsgroup-bookmarks))))))
7695 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7696 "Select the current article.
7697 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7698 non-nil, the article will be re-fetched even if it already present in
7699 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7700 be displayed."
7701 ;; Make sure we are in the summary buffer to work around bbdb bug.
7702 (unless (derived-mode-p 'gnus-summary-mode)
7703 (set-buffer gnus-summary-buffer))
7704 (let ((article (or article (gnus-summary-article-number)))
7705 (all-headers (not (not all-headers))) ;Must be t or nil.
7706 gnus-summary-display-article-function)
7707 (and (not pseudo)
7708 (gnus-summary-article-pseudo-p article)
7709 (error "This is a pseudo-article"))
7710 (with-current-buffer gnus-summary-buffer
7711 (if (or (and gnus-single-article-buffer
7712 (or (null gnus-current-article)
7713 (null gnus-article-current)
7714 (null (get-buffer gnus-article-buffer))
7715 (not (eq article (cdr gnus-article-current)))
7716 (not (equal (car gnus-article-current)
7717 gnus-newsgroup-name))
7718 (not (get-buffer gnus-original-article-buffer))))
7719 (and (not gnus-single-article-buffer)
7720 (or (null gnus-current-article)
7721 (not (get-buffer gnus-original-article-buffer))
7722 (not (eq gnus-current-article article))))
7723 force)
7724 ;; The requested article is different from the current article.
7725 (progn
7726 (gnus-summary-display-article article all-headers)
7727 (when (gnus-buffer-live-p gnus-article-buffer)
7728 (with-current-buffer gnus-article-buffer
7729 (if (not gnus-article-decoded-p) ;; a local variable
7730 (mm-disable-multibyte))))
7731 (gnus-article-set-window-start
7732 (cdr (assq article gnus-newsgroup-bookmarks)))
7733 article)
7734 'old))))
7736 (defun gnus-summary-force-verify-and-decrypt ()
7737 "Display buttons for signed/encrypted parts and verify/decrypt them."
7738 (interactive)
7739 (let ((mm-verify-option 'known)
7740 (mm-decrypt-option 'known)
7741 (gnus-article-emulate-mime t)
7742 (gnus-buttonized-mime-types (append (list "multipart/signed"
7743 "multipart/encrypted")
7744 gnus-buttonized-mime-types)))
7745 (gnus-summary-select-article nil 'force)))
7747 (defun gnus-summary-next-article (&optional unread subject backward push)
7748 "Select the next article.
7749 If UNREAD, only unread articles are selected.
7750 If SUBJECT, only articles with SUBJECT are selected.
7751 If BACKWARD, the previous article is selected instead of the next."
7752 (interactive "P")
7753 ;; Make sure we are in the summary buffer.
7754 (unless (derived-mode-p 'gnus-summary-mode)
7755 (set-buffer gnus-summary-buffer))
7756 (cond
7757 ;; Is there such an article?
7758 ((and (gnus-summary-search-forward unread subject backward)
7759 (or (gnus-summary-display-article (gnus-summary-article-number))
7760 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7761 (gnus-summary-position-point))
7762 ;; If not, we try the first unread, if that is wanted.
7763 ((and subject
7764 gnus-auto-select-same
7765 (gnus-summary-first-unread-article))
7766 (gnus-summary-position-point)
7767 (gnus-message 6 "Wrapped"))
7768 ;; Try to get next/previous article not displayed in this group.
7769 ((and gnus-auto-extend-newsgroup
7770 (not unread) (not subject))
7771 (gnus-summary-goto-article
7772 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7773 nil (count-lines (point-min) (point))))
7774 ;; Go to next/previous group.
7776 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7777 (gnus-summary-jump-to-group gnus-newsgroup-name))
7778 (let ((cmd last-command-event)
7779 (point
7780 (with-current-buffer gnus-group-buffer
7781 (point)))
7782 (current-summary (current-buffer))
7783 (group
7784 (if (eq gnus-keep-same-level 'best)
7785 (gnus-summary-best-group gnus-newsgroup-name)
7786 (gnus-summary-search-group backward gnus-keep-same-level))))
7787 ;; Select next unread newsgroup automagically.
7788 (cond
7789 ((or (not gnus-auto-select-next)
7790 (not cmd))
7791 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7792 ((or (eq gnus-auto-select-next 'quietly)
7793 (and (eq gnus-auto-select-next 'slightly-quietly)
7794 push)
7795 (and (eq gnus-auto-select-next 'almost-quietly)
7796 (gnus-summary-last-article-p)))
7797 ;; Select quietly.
7798 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7799 (gnus-summary-exit)
7800 (gnus-message 7 "No more%s articles (%s)..."
7801 (if unread " unread" "")
7802 (if group (concat "selecting " group)
7803 "exiting"))
7804 (gnus-summary-next-group nil group backward)))
7806 (when (numberp last-input-event)
7807 ;; Somehow or other, we may now have selected a different
7808 ;; window. Make point go back to the summary buffer.
7809 (when (eq current-summary (current-buffer))
7810 ;; FIXME: This burps when get-buffer-window returns nil.
7811 (select-window (get-buffer-window current-summary 0)))
7812 (gnus-summary-walk-group-buffer
7813 gnus-newsgroup-name cmd unread backward point))))))))
7815 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7816 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7817 (?\C-p (gnus-group-prev-unread-group 1))))
7818 (cursor-in-echo-area t)
7819 keve key group ended prompt)
7820 (with-current-buffer gnus-group-buffer
7821 (goto-char start)
7822 (setq group
7823 (if (eq gnus-keep-same-level 'best)
7824 (gnus-summary-best-group gnus-newsgroup-name)
7825 (gnus-summary-search-group backward gnus-keep-same-level))))
7826 (while (not ended)
7827 (setq prompt
7828 (format
7829 "No more%s articles%s " (if unread " unread" "")
7830 (if (and group
7831 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7832 (format " (Type %s for %s [%s])"
7833 (single-key-description cmd)
7834 (gnus-group-decoded-name group)
7835 (gnus-group-unread group))
7836 (format " (Type %s to exit %s)"
7837 (single-key-description cmd)
7838 (gnus-group-decoded-name gnus-newsgroup-name)))))
7839 ;; Confirm auto selection.
7840 (setq key (car (setq keve (gnus-read-event-char prompt)))
7841 ended t)
7842 (cond
7843 ((assq key keystrokes)
7844 (let ((obuf (current-buffer)))
7845 (switch-to-buffer gnus-group-buffer)
7846 (when group
7847 (gnus-group-jump-to-group group))
7848 (eval (cadr (assq key keystrokes)))
7849 (setq group (gnus-group-group-name))
7850 (switch-to-buffer obuf))
7851 (setq ended nil))
7852 ((equal key cmd)
7853 (if (or (not group)
7854 (gnus-ephemeral-group-p gnus-newsgroup-name))
7855 (gnus-summary-exit)
7856 (gnus-summary-next-group nil group backward)))
7858 (push (cdr keve) unread-command-events))))))
7860 (defun gnus-summary-next-unread-article ()
7861 "Select unread article after current one."
7862 (interactive)
7863 (gnus-summary-next-article
7864 (or (not (eq gnus-summary-goto-unread 'never))
7865 (gnus-summary-last-article-p (gnus-summary-article-number)))
7866 (and gnus-auto-select-same
7867 (gnus-summary-article-subject))))
7869 (defun gnus-summary-prev-article (&optional unread subject)
7870 "Select the article before the current one.
7871 If UNREAD is non-nil, only unread articles are selected."
7872 (interactive "P")
7873 (gnus-summary-next-article unread subject t))
7875 (defun gnus-summary-prev-unread-article ()
7876 "Select unread article before current one."
7877 (interactive)
7878 (gnus-summary-prev-article
7879 (or (not (eq gnus-summary-goto-unread 'never))
7880 (gnus-summary-first-article-p (gnus-summary-article-number)))
7881 (and gnus-auto-select-same
7882 (gnus-summary-article-subject))))
7884 (declare-function gnus-article-only-boring-p "gnus-art" ())
7886 (defun gnus-summary-next-page (&optional lines circular stop)
7887 "Show next page of the selected article.
7888 If at the end of the current article, select the next article.
7889 LINES says how many lines should be scrolled up.
7891 If CIRCULAR is non-nil, go to the start of the article instead of
7892 selecting the next article when reaching the end of the current
7893 article.
7895 If STOP is non-nil, just stop when reaching the end of the message.
7897 Also see the variable `gnus-article-skip-boring'."
7898 (interactive "P")
7899 (gnus-set-global-variables)
7900 (let ((article (gnus-summary-article-number))
7901 (article-window (get-buffer-window gnus-article-buffer t))
7902 endp)
7903 ;; If the buffer is empty, we have no article.
7904 (unless article
7905 (error "No article to select"))
7906 (gnus-configure-windows 'article)
7907 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7908 (if (and (eq gnus-summary-goto-unread 'never)
7909 (not (gnus-summary-last-article-p article)))
7910 (gnus-summary-next-article)
7911 (gnus-summary-next-unread-article))
7912 (if (or (null gnus-current-article)
7913 (null gnus-article-current)
7914 (/= article (cdr gnus-article-current))
7915 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7916 ;; Selected subject is different from current article's.
7917 (gnus-summary-display-article article)
7918 (when article-window
7919 (gnus-eval-in-buffer-window gnus-article-buffer
7920 (setq endp (or (gnus-article-next-page lines)
7921 (gnus-article-only-boring-p))))
7922 (when endp
7923 (cond ((or stop gnus-summary-stop-at-end-of-message)
7924 (gnus-message 3 "End of message"))
7925 (circular
7926 (gnus-summary-beginning-of-article))
7927 (lines
7928 (gnus-message 3 "End of message"))
7929 ((null lines)
7930 (if (and (eq gnus-summary-goto-unread 'never)
7931 (not (gnus-summary-last-article-p article)))
7932 (gnus-summary-next-article)
7933 (gnus-summary-next-unread-article))))))))
7934 (gnus-summary-recenter)
7935 (gnus-summary-position-point)))
7937 (defun gnus-summary-prev-page (&optional lines move)
7938 "Show previous page of selected article.
7939 Argument LINES specifies lines to be scrolled down.
7940 If MOVE, move to the previous unread article if point is at
7941 the beginning of the buffer."
7942 (interactive "P")
7943 (let ((article (gnus-summary-article-number))
7944 (article-window (get-buffer-window gnus-article-buffer t))
7945 endp)
7946 (gnus-configure-windows 'article)
7947 (if (or (null gnus-current-article)
7948 (null gnus-article-current)
7949 (/= article (cdr gnus-article-current))
7950 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7951 ;; Selected subject is different from current article's.
7952 (gnus-summary-display-article article)
7953 (gnus-summary-recenter)
7954 (when article-window
7955 (gnus-eval-in-buffer-window gnus-article-buffer
7956 (setq endp (gnus-article-prev-page lines)))
7957 (when (and move endp)
7958 (cond (lines
7959 (gnus-message 3 "Beginning of message"))
7960 ((null lines)
7961 (if (and (eq gnus-summary-goto-unread 'never)
7962 (not (gnus-summary-first-article-p article)))
7963 (gnus-summary-prev-article)
7964 (gnus-summary-prev-unread-article))))))))
7965 (gnus-summary-position-point))
7967 (defun gnus-summary-prev-page-or-article (&optional lines)
7968 "Show previous page of selected article.
7969 Argument LINES specifies lines to be scrolled down.
7970 If at the beginning of the article, go to the next article."
7971 (interactive "P")
7972 (gnus-summary-prev-page lines t))
7974 (defun gnus-summary-scroll-up (lines)
7975 "Scroll up (or down) one line current article.
7976 Argument LINES specifies lines to be scrolled up (or down if negative).
7977 If no article is selected, then the current article will be selected first."
7978 (interactive "p")
7979 (gnus-configure-windows 'article)
7980 (gnus-summary-show-thread)
7981 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7982 (gnus-eval-in-buffer-window gnus-article-buffer
7983 (cond ((> lines 0)
7984 (when (gnus-article-next-page lines)
7985 (gnus-message 3 "End of message")))
7986 ((< lines 0)
7987 (gnus-article-prev-page (- lines))))))
7988 (gnus-summary-recenter)
7989 (gnus-summary-position-point))
7991 (defun gnus-summary-scroll-down (lines)
7992 "Scroll down (or up) one line current article.
7993 Argument LINES specifies lines to be scrolled down (or up if negative).
7994 If no article is selected, then the current article will be selected first."
7995 (interactive "p")
7996 (gnus-summary-scroll-up (- lines)))
7998 (defun gnus-summary-next-same-subject ()
7999 "Select next article which has the same subject as current one."
8000 (interactive)
8001 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8003 (defun gnus-summary-prev-same-subject ()
8004 "Select previous article which has the same subject as current one."
8005 (interactive)
8006 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8008 (defun gnus-summary-next-unread-same-subject ()
8009 "Select next unread article which has the same subject as current one."
8010 (interactive)
8011 (gnus-summary-next-article t (gnus-summary-article-subject)))
8013 (defun gnus-summary-prev-unread-same-subject ()
8014 "Select previous unread article which has the same subject as current one."
8015 (interactive)
8016 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8018 (defun gnus-summary-first-unread-article ()
8019 "Select the first unread article.
8020 Return nil if there are no unread articles."
8021 (interactive)
8022 (prog1
8023 (when (gnus-summary-first-subject t)
8024 (gnus-summary-show-thread)
8025 (gnus-summary-first-subject t)
8026 (gnus-summary-display-article (gnus-summary-article-number)))
8027 (gnus-summary-position-point)))
8029 (defun gnus-summary-first-unread-subject ()
8030 "Place the point on the subject line of the first unread article.
8031 Return nil if there are no unread articles."
8032 (interactive)
8033 (prog1
8034 (when (gnus-summary-first-subject t)
8035 (gnus-summary-show-thread)
8036 (gnus-summary-first-subject t))
8037 (gnus-summary-position-point)))
8039 (defun gnus-summary-first-unseen-subject ()
8040 "Place the point on the subject line of the first unseen article.
8041 Return nil if there are no unseen articles."
8042 (interactive)
8043 (prog1
8044 (when (gnus-summary-first-subject nil nil t)
8045 (gnus-summary-show-thread)
8046 (gnus-summary-first-subject nil nil t))
8047 (gnus-summary-position-point)))
8049 (defun gnus-summary-first-unseen-or-unread-subject ()
8050 "Place the point on the subject line of the first unseen and unread article.
8051 If all article have been seen, on the subject line of the first unread
8052 article."
8053 (interactive)
8054 (prog1
8055 (unless (when (gnus-summary-first-subject nil nil t)
8056 (gnus-summary-show-thread)
8057 (gnus-summary-first-subject nil nil t))
8058 (when (gnus-summary-first-subject t)
8059 (gnus-summary-show-thread)
8060 (gnus-summary-first-subject t)))
8061 (gnus-summary-position-point)))
8063 (defun gnus-summary-first-article ()
8064 "Select the first article.
8065 Return nil if there are no articles."
8066 (interactive)
8067 (prog1
8068 (when (gnus-summary-first-subject)
8069 (gnus-summary-show-thread)
8070 (gnus-summary-first-subject)
8071 (gnus-summary-display-article (gnus-summary-article-number)))
8072 (gnus-summary-position-point)))
8074 (defun gnus-summary-best-unread-article (&optional arg)
8075 "Select the unread article with the highest score.
8076 If given a prefix argument, select the next unread article that has a
8077 score higher than the default score."
8078 (interactive "P")
8079 (let ((article (if arg
8080 (gnus-summary-better-unread-subject)
8081 (gnus-summary-best-unread-subject))))
8082 (if article
8083 (gnus-summary-goto-article article)
8084 (error "No unread articles"))))
8086 (defun gnus-summary-best-unread-subject ()
8087 "Select the unread subject with the highest score."
8088 (interactive)
8089 (let ((best -1000000)
8090 (data gnus-newsgroup-data)
8091 article score)
8092 (while data
8093 (and (gnus-data-unread-p (car data))
8094 (> (setq score
8095 (gnus-summary-article-score (gnus-data-number (car data))))
8096 best)
8097 (setq best score
8098 article (gnus-data-number (car data))))
8099 (setq data (cdr data)))
8100 (when article
8101 (gnus-summary-goto-subject article))
8102 (gnus-summary-position-point)
8103 article))
8105 (defun gnus-summary-better-unread-subject ()
8106 "Select the first unread subject that has a score over the default score."
8107 (interactive)
8108 (let ((data gnus-newsgroup-data)
8109 article score)
8110 (while (and (setq article (gnus-data-number (car data)))
8111 (or (gnus-data-read-p (car data))
8112 (not (> (gnus-summary-article-score article)
8113 gnus-summary-default-score))))
8114 (setq data (cdr data)))
8115 (when article
8116 (gnus-summary-goto-subject article))
8117 (gnus-summary-position-point)
8118 article))
8120 (defun gnus-summary-last-subject ()
8121 "Go to the last displayed subject line in the group."
8122 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8123 (when article
8124 (gnus-summary-goto-subject article))))
8126 (defun gnus-summary-goto-article (article &optional all-headers force)
8127 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8128 If ALL-HEADERS is non-nil, no header lines are hidden.
8129 If FORCE, go to the article even if it isn't displayed. If FORCE
8130 is a number, it is the line the article is to be displayed on."
8131 (interactive
8132 (list
8133 (gnus-completing-read
8134 "Article number or Message-ID"
8135 (mapcar 'int-to-string gnus-newsgroup-limit))
8136 current-prefix-arg
8138 (prog1
8139 (if (and (stringp article)
8140 (string-match "@\\|%40" article))
8141 (gnus-summary-refer-article article)
8142 (when (stringp article)
8143 (setq article (string-to-number article)))
8144 (if (gnus-summary-goto-subject article force)
8145 (gnus-summary-display-article article all-headers)
8146 (gnus-message 4 "Couldn't go to article %s" article) nil))
8147 (gnus-summary-position-point)))
8149 (defun gnus-summary-goto-last-article ()
8150 "Go to the previously read article."
8151 (interactive)
8152 (prog1
8153 (when gnus-last-article
8154 (gnus-summary-goto-article gnus-last-article nil t))
8155 (gnus-summary-position-point)))
8157 (defun gnus-summary-pop-article (number)
8158 "Pop one article off the history and go to the previous.
8159 NUMBER articles will be popped off."
8160 (interactive "p")
8161 (let (to)
8162 (setq gnus-newsgroup-history
8163 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8164 (if to
8165 (gnus-summary-goto-article (car to) nil t)
8166 (error "Article history empty")))
8167 (gnus-summary-position-point))
8169 ;; Summary commands and functions for limiting the summary buffer.
8171 (defun gnus-summary-limit-to-articles (n)
8172 "Limit the summary buffer to the next N articles.
8173 If not given a prefix, use the process marked articles instead."
8174 (interactive "P")
8175 (prog1
8176 (let ((articles (gnus-summary-work-articles n)))
8177 (setq gnus-newsgroup-processable nil)
8178 (gnus-summary-limit articles))
8179 (gnus-summary-position-point)))
8181 (defun gnus-summary-pop-limit (&optional total)
8182 "Restore the previous limit.
8183 If given a prefix, remove all limits."
8184 (interactive "P")
8185 (when total
8186 (setq gnus-newsgroup-limits
8187 (list (mapcar (lambda (h) (mail-header-number h))
8188 gnus-newsgroup-headers))))
8189 (unless gnus-newsgroup-limits
8190 (error "No limit to pop"))
8191 (prog1
8192 (gnus-summary-limit nil 'pop)
8193 (gnus-summary-position-point)))
8195 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8196 "Limit the summary buffer to articles that have subjects that match a regexp.
8197 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8198 (interactive
8199 (list (read-string (if current-prefix-arg
8200 "Exclude subject (regexp): "
8201 "Limit to subject (regexp): "))
8202 nil current-prefix-arg))
8203 (unless header
8204 (setq header "subject"))
8205 (when (not (equal "" subject))
8206 (prog1
8207 (let ((articles (gnus-summary-find-matching
8208 (or header "subject") subject 'all nil nil
8209 not-matching)))
8210 (unless articles
8211 (error "Found no matches for \"%s\"" subject))
8212 (gnus-summary-limit articles))
8213 (gnus-summary-position-point))))
8215 (defun gnus-summary-limit-to-author (from &optional not-matching)
8216 "Limit the summary buffer to articles that have authors that match a regexp.
8217 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8218 (interactive
8219 (list (let* ((header (gnus-summary-article-header))
8220 (default (and header (car (mail-header-parse-address
8221 (mail-header-from header))))))
8222 (read-string (concat (if current-prefix-arg
8223 "Exclude author (regexp"
8224 "Limit to author (regexp")
8225 (if default
8226 (concat ", default \"" default "\"): ")
8227 "): "))
8228 nil nil
8229 default))
8230 current-prefix-arg))
8231 (gnus-summary-limit-to-subject from "from" not-matching))
8233 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8234 "Limit the summary buffer to articles with the given RECIPIENT.
8236 If NOT-MATCHING, exclude RECIPIENT.
8238 To and Cc headers are checked. You need to include them in
8239 `nnmail-extra-headers'."
8240 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8241 (interactive
8242 (list (read-string (format "%s recipient (regexp): "
8243 (if current-prefix-arg "Exclude" "Limit to")))
8244 current-prefix-arg))
8245 (when (not (equal "" recipient))
8246 (prog1 (let* ((to
8247 (if (memq 'To nnmail-extra-headers)
8248 (gnus-summary-find-matching
8249 (cons 'extra 'To) recipient 'all nil nil
8250 not-matching)
8251 (gnus-message
8252 1 "`To' isn't present in `nnmail-extra-headers'")
8253 (sit-for 1)
8254 nil))
8256 (if (memq 'Cc nnmail-extra-headers)
8257 (gnus-summary-find-matching
8258 (cons 'extra 'Cc) recipient 'all nil nil
8259 not-matching)
8260 (gnus-message
8261 1 "`Cc' isn't present in `nnmail-extra-headers'")
8262 (sit-for 1)
8263 nil))
8264 (articles
8265 (if not-matching
8266 ;; We need the numbers that are in both lists:
8267 (mapcar (lambda (a)
8268 (and (memq a to) a))
8270 (nconc to cc))))
8271 (unless articles
8272 (error "Found no matches for \"%s\"" recipient))
8273 (gnus-summary-limit articles))
8274 (gnus-summary-position-point))))
8276 (defun gnus-summary-limit-to-address (address &optional not-matching)
8277 "Limit the summary buffer to articles with the given ADDRESS.
8279 If NOT-MATCHING, exclude ADDRESS.
8281 To, Cc and From headers are checked. You need to include `To' and `Cc'
8282 in `nnmail-extra-headers'."
8283 (interactive
8284 (list (read-string (format "%s address (regexp): "
8285 (if current-prefix-arg "Exclude" "Limit to")))
8286 current-prefix-arg))
8287 (when (not (equal "" address))
8288 (prog1 (let* ((to
8289 (if (memq 'To nnmail-extra-headers)
8290 (gnus-summary-find-matching
8291 (cons 'extra 'To) address 'all nil nil
8292 not-matching)
8293 (gnus-message
8294 1 "`To' isn't present in `nnmail-extra-headers'")
8295 (sit-for 1)
8298 (if (memq 'Cc nnmail-extra-headers)
8299 (gnus-summary-find-matching
8300 (cons 'extra 'Cc) address 'all nil nil
8301 not-matching)
8302 (gnus-message
8303 1 "`Cc' isn't present in `nnmail-extra-headers'")
8304 (sit-for 1)
8306 (from
8307 (gnus-summary-find-matching "from" address
8308 'all nil nil not-matching))
8309 (articles
8310 (if not-matching
8311 ;; We need the numbers that are in all lists:
8312 (if (eq cc t)
8313 (if (eq to t)
8314 from
8315 (mapcar (lambda (a) (car (memq a from))) to))
8316 (if (eq to t)
8317 (mapcar (lambda (a) (car (memq a from))) cc)
8318 (mapcar (lambda (a) (car (memq a from)))
8319 (mapcar (lambda (a) (car (memq a to)))
8320 cc))))
8321 (nconc (if (eq to t) nil to)
8322 (if (eq cc t) nil cc)
8323 from))))
8324 (unless articles
8325 (error "Found no matches for \"%s\"" address))
8326 (gnus-summary-limit articles))
8327 (gnus-summary-position-point))))
8329 (defun gnus-summary-limit-strange-charsets-predicate (header)
8330 (let ((string (concat (mail-header-subject header)
8331 (mail-header-from header)))
8332 charset found)
8333 (dotimes (i (1- (length string)))
8334 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8335 (when (string-match "unicode\\|big\\|japanese" charset)
8336 (setq found t)))
8337 found))
8339 (defun gnus-summary-limit-to-predicate (predicate)
8340 "Limit to articles where PREDICATE returns non-nil.
8341 PREDICATE will be called with the header structures of the
8342 articles."
8343 (let ((articles nil)
8344 (case-fold-search t))
8345 (dolist (header gnus-newsgroup-headers)
8346 (when (funcall predicate header)
8347 (push (mail-header-number header) articles)))
8348 (gnus-summary-limit (nreverse articles))))
8350 (defun gnus-summary-limit-to-age (age &optional younger-p)
8351 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8352 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8353 articles that are younger than AGE days."
8354 (interactive
8355 (let ((younger current-prefix-arg)
8356 (days-got nil)
8357 days)
8358 (while (not days-got)
8359 (setq days (if younger
8360 (read-string "Limit to articles younger than (in days, older when negative): ")
8361 (read-string
8362 "Limit to articles older than (in days, younger when negative): ")))
8363 (when (> (length days) 0)
8364 (setq days (read days)))
8365 (if (numberp days)
8366 (progn
8367 (setq days-got t)
8368 (when (< days 0)
8369 (setq younger (not younger))
8370 (setq days (* days -1))))
8371 (message "Please enter a number.")
8372 (sleep-for 1)))
8373 (list days younger)))
8374 (prog1
8375 (let ((data gnus-newsgroup-data)
8376 (cutoff (days-to-time age))
8377 articles d date is-younger)
8378 (while (setq d (pop data))
8379 (when (and (vectorp (gnus-data-header d))
8380 (setq date (mail-header-date (gnus-data-header d))))
8381 (setq is-younger (time-less-p
8382 (time-since (gnus-date-get-time date))
8383 cutoff))
8384 (when (if younger-p
8385 is-younger
8386 (not is-younger))
8387 (push (gnus-data-number d) articles))))
8388 (gnus-summary-limit (nreverse articles)))
8389 (gnus-summary-position-point)))
8391 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8392 "Limit the summary buffer to articles that match an `extra' header."
8393 (interactive
8394 (let ((header
8395 (intern
8396 (gnus-completing-read
8397 (if current-prefix-arg
8398 "Exclude extra header"
8399 "Limit extra header")
8400 (mapcar 'symbol-name gnus-extra-headers)
8401 t nil nil
8402 (symbol-name (car gnus-extra-headers))))))
8403 (list header
8404 (read-string (format "%s header %s (regexp): "
8405 (if current-prefix-arg "Exclude" "Limit to")
8406 header))
8407 current-prefix-arg)))
8408 (when (not (equal "" regexp))
8409 (prog1
8410 (let ((articles (gnus-summary-find-matching
8411 (cons 'extra header) regexp 'all nil nil
8412 not-matching)))
8413 (unless articles
8414 (error "Found no matches for \"%s\"" regexp))
8415 (gnus-summary-limit articles))
8416 (gnus-summary-position-point))))
8418 (defun gnus-summary-limit-to-display-predicate ()
8419 "Limit the summary buffer to the predicated in the `display' group parameter."
8420 (interactive)
8421 (unless gnus-newsgroup-display
8422 (error "There is no `display' group parameter"))
8423 (let (articles)
8424 (dolist (gnus-number gnus-newsgroup-articles)
8425 (when (funcall gnus-newsgroup-display)
8426 (push gnus-number articles)))
8427 (gnus-summary-limit articles))
8428 (gnus-summary-position-point))
8430 (defun gnus-summary-limit-to-unread (&optional all)
8431 "Limit the summary buffer to articles that are not marked as read.
8432 If ALL is non-nil, limit strictly to unread articles."
8433 (interactive "P")
8434 (if all
8435 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8436 (gnus-summary-limit-to-marks
8437 ;; Concat all the marks that say that an article is read and have
8438 ;; those removed.
8439 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8440 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8441 gnus-low-score-mark gnus-expirable-mark
8442 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8443 gnus-duplicate-mark)
8444 'reverse)))
8446 (defun gnus-summary-limit-to-headers (match &optional reverse)
8447 "Limit the summary buffer to articles that have headers that match MATCH.
8448 If REVERSE (the prefix), limit to articles that don't match."
8449 (interactive "sMatch headers (regexp): \nP")
8450 (gnus-summary-limit-to-bodies match reverse t))
8452 (declare-function article-goto-body "gnus-art" ())
8454 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8455 "Limit the summary buffer to articles that have bodies that match MATCH.
8456 If REVERSE (the prefix), limit to articles that don't match."
8457 (interactive "sMatch body (regexp): \nP")
8458 (let ((articles nil)
8459 (gnus-select-article-hook nil) ;Disable hook.
8460 (gnus-article-prepare-hook nil)
8461 (gnus-use-article-prefetch nil)
8462 (gnus-keep-backlog nil)
8463 (gnus-break-pages nil)
8464 (gnus-summary-display-arrow nil)
8465 (gnus-updated-mode-lines nil)
8466 (gnus-auto-center-summary nil)
8467 (gnus-display-mime-function nil))
8468 (dolist (data gnus-newsgroup-data)
8469 (let (gnus-mark-article-hook)
8470 (gnus-summary-select-article t t nil (gnus-data-number data)))
8471 (with-current-buffer gnus-article-buffer
8472 (article-goto-body)
8473 (let* ((case-fold-search t)
8474 (found (if headersp
8475 (re-search-backward match nil t)
8476 (re-search-forward match nil t))))
8477 (when (or (and found
8478 (not reverse))
8479 (and (not found)
8480 reverse))
8481 (push (gnus-data-number data) articles)))))
8482 (if (not articles)
8483 (message "No messages matched")
8484 (gnus-summary-limit articles)))
8485 (gnus-summary-position-point))
8487 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8488 "Limit the summary buffer to articles that aren't part on any thread.
8489 If THREADSP (the prefix), limit to articles that are in threads."
8490 (interactive "P")
8491 (let ((articles nil)
8492 thread-articles
8493 threads)
8494 (dolist (thread gnus-newsgroup-threads)
8495 (if (stringp (car thread))
8496 (dolist (thread (cdr thread))
8497 (push thread threads))
8498 (push thread threads)))
8499 (dolist (thread threads)
8500 (setq thread-articles (gnus-articles-in-thread thread))
8501 (when (or (and threadsp
8502 (> (length thread-articles) 1))
8503 (and (not threadsp)
8504 (= (length thread-articles) 1)))
8505 (setq articles (nconc thread-articles articles))))
8506 (if (not articles)
8507 (message "No messages matched")
8508 (gnus-summary-limit articles))
8509 (gnus-summary-position-point)))
8511 (defun gnus-summary-limit-to-replied (&optional unreplied)
8512 "Limit the summary buffer to replied articles.
8513 If UNREPLIED (the prefix), limit to unreplied articles."
8514 (interactive "P")
8515 (if unreplied
8516 (gnus-summary-limit
8517 (gnus-set-difference gnus-newsgroup-articles
8518 gnus-newsgroup-replied))
8519 (gnus-summary-limit gnus-newsgroup-replied))
8520 (gnus-summary-position-point))
8522 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8523 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8524 If REVERSE, limit the summary buffer to articles that are marked
8525 with MARKS. MARKS can either be a string of marks or a list of marks.
8526 Returns how many articles were removed."
8527 (interactive "sMarks: ")
8528 (gnus-summary-limit-to-marks marks t))
8530 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8531 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8532 If REVERSE (the prefix), limit the summary buffer to articles that are
8533 not marked with MARKS. MARKS can either be a string of marks or a
8534 list of marks.
8535 Returns how many articles were removed."
8536 (interactive "sMarks: \nP")
8537 (prog1
8538 (let ((data gnus-newsgroup-data)
8539 (marks (if (listp marks) marks
8540 (append marks nil))) ; Transform to list.
8541 articles)
8542 (while data
8543 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8544 (memq (gnus-data-mark (car data)) marks))
8545 (push (gnus-data-number (car data)) articles))
8546 (setq data (cdr data)))
8547 (gnus-summary-limit articles))
8548 (gnus-summary-position-point)))
8550 (defun gnus-summary-limit-to-score (score)
8551 "Limit to articles with score at or above SCORE."
8552 (interactive "NLimit to articles with score of at least: ")
8553 (let ((data gnus-newsgroup-data)
8554 articles)
8555 (while data
8556 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8557 score)
8558 (push (gnus-data-number (car data)) articles))
8559 (setq data (cdr data)))
8560 (prog1
8561 (gnus-summary-limit articles)
8562 (gnus-summary-position-point))))
8564 (defun gnus-summary-limit-to-unseen ()
8565 "Limit to unseen articles."
8566 (interactive)
8567 (prog1
8568 (gnus-summary-limit gnus-newsgroup-unseen)
8569 (gnus-summary-position-point)))
8571 (defun gnus-summary-limit-include-thread (id)
8572 "Display all the hidden articles that is in the thread with ID in it.
8573 When called interactively, ID is the Message-ID of the current
8574 article."
8575 (interactive (list (mail-header-id (gnus-summary-article-header))))
8576 (let ((articles (gnus-articles-in-thread
8577 (gnus-id-to-thread (gnus-root-id id))))
8578 ;;we REALLY want the whole thread---this prevents cut-threads
8579 ;;from removing the thread we want to include.
8580 (gnus-fetch-old-headers nil)
8581 (gnus-build-sparse-threads nil))
8582 (prog1
8583 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8584 (gnus-summary-limit-include-matching-articles
8585 "subject"
8586 (regexp-quote (gnus-simplify-subject-re
8587 (mail-header-subject (gnus-id-to-header id)))))
8588 (gnus-summary-position-point))))
8590 (defun gnus-summary-limit-include-matching-articles (header regexp)
8591 "Display all the hidden articles that have HEADERs that match REGEXP."
8592 (interactive (list (read-string "Match on header: ")
8593 (read-string "Regexp: ")))
8594 (let ((articles (gnus-find-matching-articles header regexp)))
8595 (prog1
8596 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8597 (gnus-summary-position-point))))
8599 (defun gnus-summary-insert-dormant-articles ()
8600 "Insert all the dormant articles for this group into the current buffer."
8601 (interactive)
8602 (let ((gnus-verbose (max 6 gnus-verbose)))
8603 (if (not gnus-newsgroup-dormant)
8604 (gnus-message 3 "No dormant articles for this group")
8605 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8607 (defun gnus-summary-insert-ticked-articles ()
8608 "Insert ticked articles for this group into the current buffer."
8609 (interactive)
8610 (let ((gnus-verbose (max 6 gnus-verbose)))
8611 (if (not gnus-newsgroup-marked)
8612 (gnus-message 3 "No ticked articles for this group")
8613 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8615 (defun gnus-summary-limit-include-dormant ()
8616 "Display all the hidden articles that are marked as dormant.
8617 Note that this command only works on a subset of the articles currently
8618 fetched for this group."
8619 (interactive)
8620 (unless gnus-newsgroup-dormant
8621 (error "There are no dormant articles in this group"))
8622 (prog1
8623 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8624 (gnus-summary-position-point)))
8626 (defun gnus-summary-include-articles (articles)
8627 "Fetch the headers for ARTICLES and then display the summary lines."
8628 (let ((gnus-inhibit-demon t)
8629 (gnus-agent nil)
8630 (gnus-read-all-available-headers t))
8631 (setq gnus-newsgroup-headers
8632 (cl-merge
8633 'list gnus-newsgroup-headers
8634 (gnus-fetch-headers articles nil t)
8635 'gnus-article-sort-by-number))
8636 (setq gnus-newsgroup-articles
8637 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8638 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8640 (defun gnus-summary-limit-exclude-dormant ()
8641 "Hide all dormant articles."
8642 (interactive)
8643 (prog1
8644 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8645 (gnus-summary-position-point)))
8647 (defun gnus-summary-limit-exclude-childless-dormant ()
8648 "Hide all dormant articles that have no children."
8649 (interactive)
8650 (let ((data (gnus-data-list t))
8651 articles d children)
8652 ;; Find all articles that are either not dormant or have
8653 ;; children.
8654 (while (setq d (pop data))
8655 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8656 (and (setq children
8657 (gnus-article-children (gnus-data-number d)))
8658 (let (found)
8659 (while children
8660 (when (memq (car children) articles)
8661 (setq children nil
8662 found t))
8663 (pop children))
8664 found)))
8665 (push (gnus-data-number d) articles)))
8666 ;; Do the limiting.
8667 (prog1
8668 (gnus-summary-limit articles)
8669 (gnus-summary-position-point))))
8671 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8672 "Mark all unread excluded articles as read.
8673 If ALL, mark even excluded ticked and dormants as read."
8674 (interactive "P")
8675 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8676 (let ((articles (gnus-sorted-ndifference
8677 (sort
8678 (mapcar (lambda (h) (mail-header-number h))
8679 gnus-newsgroup-headers)
8681 gnus-newsgroup-limit))
8682 article)
8683 (setq gnus-newsgroup-unreads
8684 (gnus-sorted-intersection gnus-newsgroup-unreads
8685 gnus-newsgroup-limit))
8686 (if all
8687 (setq gnus-newsgroup-dormant nil
8688 gnus-newsgroup-marked nil
8689 gnus-newsgroup-reads
8690 (nconc
8691 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8692 gnus-newsgroup-reads))
8693 (while (setq article (pop articles))
8694 (unless (or (memq article gnus-newsgroup-dormant)
8695 (memq article gnus-newsgroup-marked))
8696 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8698 (defun gnus-summary-limit (articles &optional pop)
8699 (if pop
8700 ;; We pop the previous limit off the stack and use that.
8701 (setq articles (car gnus-newsgroup-limits)
8702 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8703 ;; We use the new limit, so we push the old limit on the stack.
8704 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8705 ;; Set the limit.
8706 (setq gnus-newsgroup-limit articles)
8707 (let ((total (length gnus-newsgroup-data))
8708 (data (gnus-data-find-list (gnus-summary-article-number)))
8709 (gnus-summary-mark-below nil) ; Inhibit this.
8710 found)
8711 ;; This will do all the work of generating the new summary buffer
8712 ;; according to the new limit.
8713 (gnus-summary-prepare)
8714 ;; Hide any threads, possibly.
8715 (gnus-summary-maybe-hide-threads)
8716 ;; Try to return to the article you were at, or one in the
8717 ;; neighborhood.
8718 (when data
8719 ;; We try to find some article after the current one.
8720 (while data
8721 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8722 (setq data nil
8723 found t))
8724 (setq data (cdr data))))
8725 (unless found
8726 ;; If there is no data, that means that we were after the last
8727 ;; article. The same goes when we can't find any articles
8728 ;; after the current one.
8729 (goto-char (point-max))
8730 (gnus-summary-find-prev))
8731 (gnus-set-mode-line 'summary)
8732 ;; We return how many articles were removed from the summary
8733 ;; buffer as a result of the new limit.
8734 (- total (length gnus-newsgroup-data))))
8736 (defsubst gnus-invisible-cut-children (threads)
8737 (let ((num 0))
8738 (while threads
8739 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8740 (incf num))
8741 (pop threads))
8742 (< num 2)))
8744 (defsubst gnus-cut-thread (thread)
8745 "Go forwards in the thread until we find an article that we want to display."
8746 (when (or (eq gnus-fetch-old-headers 'some)
8747 (eq gnus-fetch-old-headers 'invisible)
8748 (numberp gnus-fetch-old-headers)
8749 (eq gnus-build-sparse-threads 'some)
8750 (eq gnus-build-sparse-threads 'more))
8751 ;; Deal with old-fetched headers and sparse threads.
8752 (while (and
8753 thread
8755 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8756 (gnus-summary-article-ancient-p
8757 (mail-header-number (car thread))))
8758 (if (or (<= (length (cdr thread)) 1)
8759 (eq gnus-fetch-old-headers 'invisible))
8760 (setq gnus-newsgroup-limit
8761 (delq (mail-header-number (car thread))
8762 gnus-newsgroup-limit)
8763 thread (cadr thread))
8764 (when (gnus-invisible-cut-children (cdr thread))
8765 (let ((th (cdr thread)))
8766 (while th
8767 (if (memq (mail-header-number (caar th))
8768 gnus-newsgroup-limit)
8769 (setq thread (car th)
8770 th nil)
8771 (setq th (cdr th))))))))))
8772 thread)
8774 (defun gnus-cut-threads (threads)
8775 "Cut off all uninteresting articles from the beginning of THREADS."
8776 (when (or (eq gnus-fetch-old-headers 'some)
8777 (eq gnus-fetch-old-headers 'invisible)
8778 (numberp gnus-fetch-old-headers)
8779 (eq gnus-build-sparse-threads 'some)
8780 (eq gnus-build-sparse-threads 'more))
8781 (let ((th threads))
8782 (while th
8783 (setcar th (gnus-cut-thread (car th)))
8784 (setq th (cdr th)))))
8785 ;; Remove nixed out threads.
8786 (delq nil threads))
8788 (defun gnus-summary-initial-limit (&optional show-if-empty)
8789 "Figure out what the initial limit is supposed to be on group entry.
8790 This entails weeding out unwanted dormants, low-scored articles,
8791 fetch-old-headers verbiage, and so on."
8792 ;; Most groups have nothing to remove.
8793 (unless (or gnus-inhibit-limiting
8794 (and (null gnus-newsgroup-dormant)
8795 (eq gnus-newsgroup-display 'gnus-not-ignore)
8796 (not (eq gnus-fetch-old-headers 'some))
8797 (not (numberp gnus-fetch-old-headers))
8798 (not (eq gnus-fetch-old-headers 'invisible))
8799 (null gnus-summary-expunge-below)
8800 (not (eq gnus-build-sparse-threads 'some))
8801 (not (eq gnus-build-sparse-threads 'more))
8802 (null gnus-thread-expunge-below)))
8803 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8804 (setq gnus-newsgroup-limit nil)
8805 (mapatoms
8806 (lambda (node)
8807 (unless (car (symbol-value node))
8808 ;; These threads have no parents -- they are roots.
8809 (let ((nodes (cdr (symbol-value node)))
8810 thread)
8811 (while nodes
8812 (if (and gnus-thread-expunge-below
8813 (< (gnus-thread-total-score (car nodes))
8814 gnus-thread-expunge-below))
8815 (gnus-expunge-thread (pop nodes))
8816 (setq thread (pop nodes))
8817 (gnus-summary-limit-children thread))))))
8818 gnus-newsgroup-dependencies)
8819 ;; If this limitation resulted in an empty group, we might
8820 ;; pop the previous limit and use it instead.
8821 (when (and (not gnus-newsgroup-limit)
8822 show-if-empty)
8823 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8824 gnus-newsgroup-limit))
8826 (defun gnus-summary-limit-children (thread)
8827 "Return 1 if this subthread is visible and 0 if it is not."
8828 ;; First we get the number of visible children to this thread. This
8829 ;; is done by recursing down the thread using this function, so this
8830 ;; will really go down to a leaf article first, before slowly
8831 ;; working its way up towards the root.
8832 (when thread
8833 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8834 (children
8835 (if (cdr thread)
8836 (apply '+ (mapcar 'gnus-summary-limit-children
8837 (cdr thread)))
8839 (number (mail-header-number (car thread)))
8840 score)
8841 (if (and
8842 (not (memq number gnus-newsgroup-marked))
8844 ;; If this article is dormant and has absolutely no visible
8845 ;; children, then this article isn't visible.
8846 (and (memq number gnus-newsgroup-dormant)
8847 (zerop children))
8848 ;; If this is "fetch-old-headered" and there is no
8849 ;; visible children, then we don't want this article.
8850 (and (or (eq gnus-fetch-old-headers 'some)
8851 (numberp gnus-fetch-old-headers))
8852 (gnus-summary-article-ancient-p number)
8853 (zerop children))
8854 ;; If this is "fetch-old-headered" and `invisible', then
8855 ;; we don't want this article.
8856 (and (eq gnus-fetch-old-headers 'invisible)
8857 (gnus-summary-article-ancient-p number))
8858 ;; If this is a sparsely inserted article with no children,
8859 ;; we don't want it.
8860 (and (eq gnus-build-sparse-threads 'some)
8861 (gnus-summary-article-sparse-p number)
8862 (zerop children))
8863 ;; If we use expunging, and this article is really
8864 ;; low-scored, then we don't want this article.
8865 (when (and gnus-summary-expunge-below
8866 (< (setq score
8867 (or (cdr (assq number gnus-newsgroup-scored))
8868 gnus-summary-default-score))
8869 gnus-summary-expunge-below))
8870 ;; We increase the expunge-tally here, but that has
8871 ;; nothing to do with the limits, really.
8872 (incf gnus-newsgroup-expunged-tally)
8873 ;; We also mark as read here, if that's wanted.
8874 (when (and gnus-summary-mark-below
8875 (< score gnus-summary-mark-below))
8876 (setq gnus-newsgroup-unreads
8877 (delq number gnus-newsgroup-unreads))
8878 (if gnus-newsgroup-auto-expire
8879 (push number gnus-newsgroup-expirable)
8880 (push (cons number gnus-low-score-mark)
8881 gnus-newsgroup-reads)))
8883 ;; Do the `display' group parameter.
8884 (and gnus-newsgroup-display
8885 (let ((gnus-number number))
8886 (not (funcall gnus-newsgroup-display))))))
8887 ;; Nope, invisible article.
8889 ;; Ok, this article is to be visible, so we add it to the limit
8890 ;; and return 1.
8891 (push number gnus-newsgroup-limit)
8892 1))))
8894 (defun gnus-expunge-thread (thread)
8895 "Mark all articles in THREAD as read."
8896 (let* ((number (mail-header-number (car thread))))
8897 (incf gnus-newsgroup-expunged-tally)
8898 ;; We also mark as read here, if that's wanted.
8899 (setq gnus-newsgroup-unreads
8900 (delq number gnus-newsgroup-unreads))
8901 (if gnus-newsgroup-auto-expire
8902 (push number gnus-newsgroup-expirable)
8903 (push (cons number gnus-low-score-mark)
8904 gnus-newsgroup-reads)))
8905 ;; Go recursively through all subthreads.
8906 (mapcar 'gnus-expunge-thread (cdr thread)))
8908 ;; Summary article oriented commands
8910 (defun gnus-summary-refer-parent-article (n)
8911 "Refer parent article N times.
8912 If N is negative, go to ancestor -N instead.
8913 The difference between N and the number of articles fetched is returned."
8914 (interactive "p")
8915 (let ((skip 1)
8916 error header ref)
8917 (when (not (natnump n))
8918 (setq skip (abs n)
8919 n 1))
8920 (while (and (> n 0)
8921 (not error))
8922 (setq header (gnus-summary-article-header))
8923 (if (and (eq (mail-header-number header)
8924 (cdr gnus-article-current))
8925 (equal gnus-newsgroup-name
8926 (car gnus-article-current)))
8927 ;; If we try to find the parent of the currently
8928 ;; displayed article, then we take a look at the actual
8929 ;; References header, since this is slightly more
8930 ;; reliable than the References field we got from the
8931 ;; server.
8932 (with-current-buffer gnus-original-article-buffer
8933 (nnheader-narrow-to-headers)
8934 (unless (setq ref (message-fetch-field "references"))
8935 (when (setq ref (message-fetch-field "in-reply-to"))
8936 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8937 (widen))
8938 (setq ref
8939 ;; It's not the current article, so we take a bet on
8940 ;; the value we got from the server.
8941 (mail-header-references header)))
8942 (if (and ref
8943 (not (equal ref "")))
8944 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8945 (gnus-message 1 "Couldn't find parent"))
8946 (gnus-message 1 "No references in article %d"
8947 (gnus-summary-article-number))
8948 (setq error t))
8949 (decf n))
8950 (gnus-summary-position-point)
8953 (defun gnus-summary-refer-references ()
8954 "Fetch all articles mentioned in the References header.
8955 Return the number of articles fetched."
8956 (interactive)
8957 (let ((ref (mail-header-references (gnus-summary-article-header)))
8958 (current (gnus-summary-article-number))
8959 (n 0))
8960 (if (or (not ref)
8961 (equal ref ""))
8962 (error "No References in the current article")
8963 ;; For each Message-ID in the References header...
8964 (while (string-match "<[^>]*>" ref)
8965 (incf n)
8966 ;; ... fetch that article.
8967 (gnus-summary-refer-article
8968 (prog1 (match-string 0 ref)
8969 (setq ref (substring ref (match-end 0))))))
8970 (gnus-summary-goto-subject current)
8971 (gnus-summary-position-point)
8972 n)))
8974 (defun gnus-delete-duplicate-headers (headers)
8975 ;; First remove leading duplicates.
8976 (while (and (> (length headers) 1)
8977 (= (mail-header-number (car headers))
8978 (mail-header-number (cadr headers))))
8979 (pop headers))
8980 ;; Then the rest.
8981 (let ((result headers))
8982 (while (> (length headers) 1)
8983 (if (= (mail-header-number (car headers))
8984 (mail-header-number (cadr headers)))
8985 (setcdr headers (cddr headers))
8986 (pop headers)))
8987 result))
8989 (defun gnus-summary-refer-thread (&optional limit)
8990 "Fetch all articles in the current thread. For backends that
8991 know how to search for threads (currently only 'nnimap) a
8992 non-numeric prefix arg will use nnir to search the entire
8993 server; without a prefix arg only the current group is
8994 searched. If the variable `gnus-refer-thread-use-nnir' is
8995 non-nil the prefix arg has the reverse meaning. If no
8996 backend-specific 'request-thread function is available fetch
8997 LIMIT (the numerical prefix) old headers. If LIMIT is
8998 non-numeric or nil fetch the number specified by the
8999 `gnus-refer-thread-limit' variable."
9000 (interactive "P")
9001 (gnus-warp-to-article)
9002 (let* ((header (gnus-summary-article-header))
9003 (id (mail-header-id header))
9004 (gnus-inhibit-demon t)
9005 (gnus-summary-ignore-duplicates t)
9006 (gnus-read-all-available-headers t)
9007 (gnus-refer-thread-use-nnir
9008 (if (and (not (null limit)) (listp limit))
9009 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9010 (new-headers
9011 (if (gnus-check-backend-function
9012 'request-thread gnus-newsgroup-name)
9013 (gnus-request-thread header gnus-newsgroup-name)
9014 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9015 gnus-refer-thread-limit))
9016 (last (if (numberp limit)
9017 (min (+ (mail-header-number header)
9018 limit)
9019 gnus-newsgroup-highest)
9020 gnus-newsgroup-highest))
9021 (subject (gnus-simplify-subject
9022 (mail-header-subject header)))
9023 (refs (split-string (or (mail-header-references header)
9024 "")))
9025 (gnus-parse-headers-hook
9026 `(lambda () (goto-char (point-min))
9027 (keep-lines
9028 (regexp-opt ',(append refs (list id subject)))))))
9029 (gnus-fetch-headers (list last) (if (numberp limit)
9030 (* 2 limit) limit) t))))
9031 article-ids new-unreads)
9032 (when (listp new-headers)
9033 (dolist (header new-headers)
9034 (push (mail-header-number header) article-ids))
9035 (setq article-ids (nreverse article-ids))
9036 (setq new-unreads
9037 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9038 (setq gnus-newsgroup-unselected
9039 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9040 (setq gnus-newsgroup-unreads
9041 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9042 (setq gnus-newsgroup-headers
9043 (gnus-delete-duplicate-headers
9044 (cl-merge
9045 'list gnus-newsgroup-headers new-headers
9046 'gnus-article-sort-by-number)))
9047 (setq gnus-newsgroup-articles
9048 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9049 (gnus-summary-limit-include-thread id)))
9050 (gnus-summary-show-thread))
9052 (defun gnus-summary-open-group-with-article (message-id)
9053 "Open a group containing the article with the given MESSAGE-ID."
9054 (interactive "sMessage-ID: ")
9055 (require 'nndoc)
9056 (with-temp-buffer
9057 ;; Prepare a dummy article
9058 (erase-buffer)
9059 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9061 ;; Prepare pretty modelines for summary and article buffers
9062 (let ((gnus-summary-mode-line-format "Found %G")
9063 (gnus-article-mode-line-format
9064 ;; Group names just get in the way here, especially the
9065 ;; abbreviated ones
9066 (if (string-match "%[gG]" gnus-article-mode-line-format)
9067 (concat (substring gnus-article-mode-line-format
9068 0 (match-beginning 0))
9069 (substring gnus-article-mode-line-format (match-end 0)))
9070 gnus-article-mode-line-format)))
9072 ;; Build an ephemeral group containing the dummy article (hidden)
9073 (gnus-group-read-ephemeral-group
9074 message-id
9075 `(nndoc ,message-id
9076 (nndoc-address ,(current-buffer))
9077 (nndoc-article-type mbox))
9078 :activate
9079 (cons (current-buffer) gnus-current-window-configuration)
9080 (not :request-only)
9081 '(-1) ; :select-articles
9082 (not :parameters)
9083 0)) ; :number
9084 ;; Fetch the desired article
9085 (gnus-summary-refer-article message-id)))
9087 (defun gnus-summary-refer-article (message-id)
9088 "Fetch an article specified by MESSAGE-ID."
9089 (interactive "sMessage-ID: ")
9090 (gnus-warp-to-article)
9091 (when (and (stringp message-id)
9092 (not (zerop (length message-id))))
9093 (setq message-id (replace-regexp-in-string " " "" message-id))
9094 ;; Construct the correct Message-ID if necessary.
9095 ;; Suggested by tale@pawl.rpi.edu.
9096 (unless (string-match "^<" message-id)
9097 (setq message-id (concat "<" message-id)))
9098 (unless (string-match ">$" message-id)
9099 (setq message-id (concat message-id ">")))
9100 ;; People often post MIDs from URLs, so unhex it:
9101 (unless (string-match "@" message-id)
9102 (setq message-id (gnus-url-unhex-string message-id)))
9103 (let* ((header (gnus-id-to-header message-id))
9104 (sparse (and header
9105 (gnus-summary-article-sparse-p
9106 (mail-header-number header))
9107 (memq (mail-header-number header)
9108 gnus-newsgroup-limit)))
9109 number)
9110 (cond
9111 ;; If the article is present in the buffer we just go to it.
9112 ((and header
9113 (or (not (gnus-summary-article-sparse-p
9114 (mail-header-number header)))
9115 sparse))
9116 (prog1
9117 (gnus-summary-goto-article
9118 (mail-header-number header) nil t)
9119 (when sparse
9120 (gnus-summary-update-article (mail-header-number header)))))
9122 ;; We fetch the article.
9123 (catch 'found
9124 (dolist (gnus-override-method (gnus-refer-article-methods))
9125 (when (and (gnus-check-server gnus-override-method)
9126 ;; Fetch the header,
9127 (setq number (gnus-summary-insert-subject message-id)))
9128 ;; and display the article.
9129 (gnus-summary-select-article nil nil nil number)
9130 (throw 'found t)))
9131 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9133 (defun gnus-refer-article-methods ()
9134 "Return a list of referable methods."
9135 (cond
9136 ;; No method, so we default to current and native.
9137 ((null gnus-refer-article-method)
9138 (list gnus-current-select-method gnus-select-method))
9139 ;; Current.
9140 ((eq 'current gnus-refer-article-method)
9141 (list gnus-current-select-method))
9142 ;; List of select methods.
9143 ((not (and (symbolp (car gnus-refer-article-method))
9144 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9145 (let (out)
9146 (dolist (method gnus-refer-article-method)
9147 (push (if (eq 'current method)
9148 gnus-current-select-method
9149 (if (eq 'nnir (car method))
9150 (list
9151 'nnir
9152 (or (cadr method)
9153 (gnus-method-to-server gnus-current-select-method)))
9154 method))
9155 out))
9156 (nreverse out)))
9157 ;; One single select method.
9159 (list gnus-refer-article-method))))
9161 (defun gnus-summary-edit-parameters ()
9162 "Edit the group parameters of the current group."
9163 (interactive)
9164 (gnus-group-edit-group gnus-newsgroup-name 'params))
9166 (defun gnus-summary-customize-parameters ()
9167 "Customize the group parameters of the current group."
9168 (interactive)
9169 (gnus-group-customize gnus-newsgroup-name))
9171 (defun gnus-summary-enter-digest-group (&optional force)
9172 "Enter an nndoc group based on the current article.
9173 If FORCE, force a digest interpretation. If not, try to guess
9174 what the document format is.
9176 To control what happens when you exit the group, see the
9177 `gnus-auto-select-on-ephemeral-exit' variable."
9178 (interactive "P")
9179 (let ((conf gnus-current-window-configuration))
9180 (save-window-excursion
9181 (save-excursion
9182 (let (gnus-article-prepare-hook
9183 gnus-display-mime-function
9184 gnus-break-pages)
9185 (gnus-summary-select-article))))
9186 (setq gnus-current-window-configuration conf)
9187 (let* ((name (format "%s-%d"
9188 (gnus-group-prefixed-name
9189 gnus-newsgroup-name (list 'nndoc ""))
9190 (with-current-buffer gnus-summary-buffer
9191 gnus-current-article)))
9192 (ogroup gnus-newsgroup-name)
9193 (params (append (gnus-info-params (gnus-get-info ogroup))
9194 (list (cons 'to-group ogroup))
9195 (list (cons 'parent-group ogroup))
9196 (list (cons 'save-article-group ogroup))))
9197 (case-fold-search t)
9198 (buf (current-buffer))
9199 dig to-address charset)
9200 (with-current-buffer gnus-original-article-buffer
9201 ;; Have the digest group inherit the main mail address of
9202 ;; the parent article.
9203 (when (setq to-address (or (gnus-fetch-field "reply-to")
9204 (gnus-fetch-field "from")))
9205 (setq params
9206 (append
9207 params
9208 (list (cons 'to-address
9209 (funcall gnus-decode-encoded-address-function
9210 to-address))))))
9211 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9212 (insert-buffer-substring gnus-original-article-buffer)
9213 (narrow-to-region
9214 (goto-char (point-min))
9215 (or (search-forward "\n\n" nil t) (point)))
9216 ;; Remove lines that may lead nndoc to misinterpret the
9217 ;; document type.
9218 (goto-char (point-min))
9219 (delete-matching-lines "^Path:\\|^From ")
9220 ;; Parse charset, and decode content transfer encoding.
9221 (setq charset (mail-content-type-get
9222 (mail-header-parse-content-type
9223 (or (gnus-fetch-field "content-type") ""))
9224 'charset))
9225 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9226 (when encoding
9227 (message-remove-header "content-transfer-encoding")
9228 (goto-char (point-max))
9229 (widen)
9230 (narrow-to-region (point) (point-max))
9231 (mm-decode-content-transfer-encoding
9232 (intern (downcase (mail-header-strip-cte encoding))))))
9233 (widen))
9234 (unwind-protect
9235 (if (let ((gnus-newsgroup-ephemeral-charset
9236 (if charset
9237 (intern (downcase (gnus-strip-whitespace charset)))
9238 gnus-newsgroup-charset))
9239 (gnus-newsgroup-ephemeral-ignored-charsets
9240 gnus-newsgroup-ignored-charsets))
9241 (gnus-group-read-ephemeral-group
9242 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9243 (nndoc-article-type
9244 ,(if force 'mbox 'guess)))
9245 t nil nil nil
9246 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9247 "ADAPT")))))
9248 ;; Make all postings to this group go to the parent group.
9249 (nconc (gnus-info-params (gnus-get-info name))
9250 params)
9251 ;; Couldn't select this doc group.
9252 (switch-to-buffer buf)
9253 (gnus-set-global-variables)
9254 (gnus-configure-windows 'summary)
9255 (gnus-message 3 "Article couldn't be entered?"))
9256 (kill-buffer dig)))))
9258 (defun gnus-summary-read-document (n)
9259 "Open a new group based on the current article(s).
9260 This will allow you to read digests and other similar
9261 documents as newsgroups.
9262 Obeys the standard process/prefix convention."
9263 (interactive "P")
9264 (let* ((ogroup gnus-newsgroup-name)
9265 (params (append (gnus-info-params (gnus-get-info ogroup))
9266 (list (cons 'to-group ogroup))))
9267 group egroup groups vgroup)
9268 (dolist (article (gnus-summary-work-articles n))
9269 (setq group (format "%s-%d" gnus-newsgroup-name article))
9270 (gnus-summary-remove-process-mark article)
9271 (when (gnus-summary-display-article article)
9272 (save-excursion ;;What for?
9273 (with-temp-buffer
9274 (insert-buffer-substring gnus-original-article-buffer)
9275 ;; Remove some headers that may lead nndoc to make
9276 ;; the wrong guess.
9277 (message-narrow-to-head)
9278 (goto-char (point-min))
9279 (delete-matching-lines "^Path:\\|^From ")
9280 (widen)
9281 (if (setq egroup
9282 (gnus-group-read-ephemeral-group
9283 group `(nndoc ,group (nndoc-address ,(current-buffer))
9284 (nndoc-article-type guess))
9285 t nil t))
9286 (progn
9287 ;; Make all postings to this group go to the parent group.
9288 (nconc (gnus-info-params (gnus-get-info egroup))
9289 params)
9290 (push egroup groups))
9291 ;; Couldn't select this doc group.
9292 (gnus-error 3 "Article couldn't be entered"))))))
9293 ;; Now we have selected all the documents.
9294 (cond
9295 ((not groups)
9296 (error "None of the articles could be interpreted as documents"))
9297 ((gnus-group-read-ephemeral-group
9298 (setq vgroup (format
9299 "nnvirtual:%s-%s" gnus-newsgroup-name
9300 (format-time-string "%Y%m%dT%H%M%S")))
9301 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9303 (cons (current-buffer) 'summary)))
9305 (error "Couldn't select virtual nndoc group")))))
9307 (defun gnus-summary-widget-forward (arg)
9308 "Move point to the next field or button in the article.
9309 With optional ARG, move across that many fields."
9310 (interactive "p")
9311 (gnus-summary-select-article)
9312 (gnus-configure-windows 'article)
9313 (select-window (gnus-get-buffer-window gnus-article-buffer))
9314 (widget-forward arg))
9316 (defun gnus-summary-widget-backward (arg)
9317 "Move point to the previous field or button in the article.
9318 With optional ARG, move across that many fields."
9319 (interactive "p")
9320 (gnus-summary-select-article)
9321 (gnus-configure-windows 'article)
9322 (select-window (gnus-get-buffer-window gnus-article-buffer))
9323 (unless (widget-at (point))
9324 (goto-char (point-max)))
9325 (widget-backward arg))
9327 (defun gnus-summary-isearch-article (&optional regexp-p)
9328 "Do incremental search forward on the current article.
9329 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9330 (interactive "P")
9331 (gnus-summary-select-article)
9332 (gnus-configure-windows 'article)
9333 (gnus-eval-in-buffer-window gnus-article-buffer
9334 (save-restriction
9335 (widen)
9336 (isearch-forward regexp-p))))
9338 (defun gnus-summary-repeat-search-article-forward ()
9339 "Repeat the previous search forwards."
9340 (interactive)
9341 (unless gnus-last-search-regexp
9342 (error "No previous search"))
9343 (gnus-summary-search-article-forward gnus-last-search-regexp))
9345 (defun gnus-summary-repeat-search-article-backward ()
9346 "Repeat the previous search backwards."
9347 (interactive)
9348 (unless gnus-last-search-regexp
9349 (error "No previous search"))
9350 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9352 (defun gnus-summary-search-article-forward (regexp &optional backward)
9353 "Search for an article containing REGEXP forward.
9354 If BACKWARD, search backward instead."
9355 (interactive
9356 (list (read-string
9357 (format "Search article %s (regexp%s): "
9358 (if current-prefix-arg "backward" "forward")
9359 (if gnus-last-search-regexp
9360 (concat ", default " gnus-last-search-regexp)
9361 "")))
9362 current-prefix-arg))
9363 (if (string-equal regexp "")
9364 (setq regexp (or gnus-last-search-regexp ""))
9365 (setq gnus-last-search-regexp regexp)
9366 (setq gnus-article-before-search gnus-current-article))
9367 ;; Intentionally set gnus-last-article.
9368 (setq gnus-last-article gnus-article-before-search)
9369 (let ((gnus-last-article gnus-last-article))
9370 (if (gnus-summary-search-article regexp backward)
9371 (gnus-summary-show-thread)
9372 (signal 'search-failed (list regexp)))))
9374 (defun gnus-summary-search-article-backward (regexp)
9375 "Search for an article containing REGEXP backward."
9376 (interactive
9377 (list (read-string
9378 (format "Search article backward (regexp%s): "
9379 (if gnus-last-search-regexp
9380 (concat ", default " gnus-last-search-regexp)
9381 "")))))
9382 (gnus-summary-search-article-forward regexp 'backward))
9384 (defun gnus-summary-search-article (regexp &optional backward)
9385 "Search for an article containing REGEXP.
9386 Optional argument BACKWARD means do search for backward.
9387 `gnus-select-article-hook' is not called during the search."
9388 ;; We have to require this here to make sure that the following
9389 ;; dynamic binding isn't shadowed by autoloading.
9390 (require 'gnus-async)
9391 (require 'gnus-art)
9392 (let ((gnus-select-article-hook nil) ;Disable hook.
9393 (gnus-article-prepare-hook nil)
9394 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9395 (gnus-use-article-prefetch nil)
9396 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9397 (gnus-visual nil)
9398 (gnus-keep-backlog nil)
9399 (gnus-break-pages nil)
9400 (gnus-summary-display-arrow nil)
9401 (gnus-updated-mode-lines nil)
9402 (gnus-auto-center-summary nil)
9403 (sum (current-buffer))
9404 (gnus-display-mime-function nil)
9405 (found nil)
9406 point)
9407 (gnus-save-hidden-threads
9408 (gnus-summary-select-article)
9409 (set-buffer gnus-article-buffer)
9410 (goto-char (window-point (get-buffer-window (current-buffer))))
9411 (when backward
9412 (forward-line -1))
9413 (while (not found)
9414 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9415 (if (if backward
9416 (re-search-backward regexp nil t)
9417 (re-search-forward regexp nil t))
9418 ;; We found the regexp.
9419 (progn
9420 (setq found 'found)
9421 (beginning-of-line)
9422 (set-window-start
9423 (get-buffer-window (current-buffer))
9424 (point))
9425 (forward-line 1)
9426 (set-window-point
9427 (get-buffer-window (current-buffer))
9428 (point))
9429 (set-buffer sum)
9430 (setq point (point)))
9431 ;; We didn't find it, so we go to the next article.
9432 (set-buffer sum)
9433 (setq found 'not)
9434 (while (eq found 'not)
9435 (if (not (if backward (gnus-summary-find-prev)
9436 (gnus-summary-find-next)))
9437 ;; No more articles.
9438 (setq found t)
9439 ;; Select the next article and adjust point.
9440 (unless (gnus-summary-article-sparse-p
9441 (gnus-summary-article-number))
9442 (setq found nil)
9443 (gnus-summary-select-article)
9444 (set-buffer gnus-article-buffer)
9445 (widen)
9446 (goto-char (if backward (point-max) (point-min))))))))
9447 (gnus-message 7 ""))
9448 ;; Return whether we found the regexp.
9449 (when (eq found 'found)
9450 (goto-char point)
9451 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9452 (gnus-summary-show-thread)
9453 (gnus-summary-goto-subject gnus-current-article)
9454 (gnus-summary-position-point)
9455 t)))
9457 (defun gnus-find-matching-articles (header regexp)
9458 "Return a list of all articles that match REGEXP on HEADER.
9459 This search includes all articles in the current group that Gnus has
9460 fetched headers for, whether they are displayed or not."
9461 (let ((articles nil)
9462 ;; Can't eta-reduce because it's a macro.
9463 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9464 (case-fold-search t))
9465 (dolist (header gnus-newsgroup-headers)
9466 (when (string-match regexp (funcall func header))
9467 (push (mail-header-number header) articles)))
9468 (nreverse articles)))
9470 (defun gnus-summary-find-matching (header regexp &optional backward unread
9471 not-case-fold not-matching)
9472 "Return a list of all articles that match REGEXP on HEADER.
9473 The search stars on the current article and goes forwards unless
9474 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9475 If UNREAD is non-nil, only unread articles will
9476 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9477 in the comparisons. If NOT-MATCHING, return a list of all articles that
9478 not match REGEXP on HEADER."
9479 (let ((case-fold-search (not not-case-fold))
9480 articles d func)
9481 (if (consp header)
9482 (if (eq (car header) 'extra)
9483 (setq func
9484 `(lambda (h)
9485 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9486 "")))
9487 (error "%s is an invalid header" header))
9488 (unless (fboundp (intern (concat "mail-header-" header)))
9489 (error "%s is not a valid header" header))
9490 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9491 (dolist (d (if (eq backward 'all)
9492 gnus-newsgroup-data
9493 (gnus-data-find-list
9494 (gnus-summary-article-number)
9495 (gnus-data-list backward))))
9496 (when (and (or (not unread) ; We want all articles...
9497 (gnus-data-unread-p d)) ; Or just unreads.
9498 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9499 (if not-matching
9500 (not (string-match
9501 regexp
9502 (funcall func (gnus-data-header d))))
9503 (string-match regexp
9504 (funcall func (gnus-data-header d)))))
9505 (push (gnus-data-number d) articles))) ; Success!
9506 (nreverse articles)))
9508 (defun gnus-summary-execute-command (header regexp command &optional backward)
9509 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9510 If HEADER is an empty string (or nil), the match is done on the entire
9511 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9512 (interactive
9513 (list (let ((completion-ignore-case t))
9514 (gnus-completing-read
9515 "Header name"
9516 (mapcar 'symbol-name
9517 (append
9518 '(Number Subject From Lines Date
9519 Message-ID Xref References Body)
9520 gnus-extra-headers))
9521 'require-match))
9522 (read-string "Regexp: ")
9523 (read-key-sequence "Command: ")
9524 current-prefix-arg))
9525 (when (equal header "Body")
9526 (setq header ""))
9527 ;; Hidden thread subtrees must be searched as well.
9528 (gnus-summary-show-all-threads)
9529 ;; We don't want to change current point nor window configuration.
9530 (save-excursion
9531 (save-window-excursion
9532 (let (gnus-visual
9533 gnus-treat-strip-trailing-blank-lines
9534 gnus-treat-strip-leading-blank-lines
9535 gnus-treat-strip-multiple-blank-lines
9536 gnus-treat-hide-boring-headers
9537 gnus-treat-fold-newsgroups
9538 gnus-article-prepare-hook)
9539 (gnus-message 6 "Executing %s..." (key-description command))
9540 ;; We'd like to execute COMMAND interactively so as to give arguments.
9541 (gnus-execute header regexp
9542 `(call-interactively ',(key-binding command))
9543 backward)
9544 (gnus-message 6 "Executing %s...done" (key-description command))))))
9546 (defun gnus-summary-beginning-of-article ()
9547 "Scroll the article back to the beginning."
9548 (interactive)
9549 (gnus-summary-select-article)
9550 (gnus-configure-windows 'article)
9551 (gnus-eval-in-buffer-window gnus-article-buffer
9552 (widen)
9553 (goto-char (point-min))
9554 (when gnus-break-pages
9555 (gnus-narrow-to-page))))
9557 (defun gnus-summary-end-of-article ()
9558 "Scroll to the end of the article."
9559 (interactive)
9560 (gnus-summary-select-article)
9561 (gnus-configure-windows 'article)
9562 (gnus-eval-in-buffer-window gnus-article-buffer
9563 (widen)
9564 (goto-char (point-max))
9565 (recenter -3)
9566 (when gnus-break-pages
9567 (gnus-narrow-to-page))))
9569 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9570 "Truncate to LEN and quote all \"(\"'s in STRING."
9571 (replace-regexp-in-string "[()]" "\\\\\\&"
9572 (if (and len (> (length string) len))
9573 (substring string 0 len)
9574 string)))
9576 (defun gnus-summary-print-article (&optional filename n)
9577 "Generate and print a PostScript image of the process-marked (mail) articles.
9579 If used interactively, print the current article if none are
9580 process-marked. With prefix arg, prompt the user for the name of the
9581 file to save in.
9583 When used from Lisp, accept two optional args FILENAME and N. N means
9584 to print the next N articles. If N is negative, print the N previous
9585 articles. If N is nil and articles have been marked with the process
9586 mark, print these instead.
9588 If the optional first argument FILENAME is nil, send the image to the
9589 printer. If FILENAME is a string, save the PostScript image in a file with
9590 that name. If FILENAME is a number, prompt the user for the name of the file
9591 to save in."
9592 (interactive (list (ps-print-preprint current-prefix-arg)))
9593 (dolist (article (gnus-summary-work-articles n))
9594 (gnus-summary-select-article nil nil 'pseudo article)
9595 (gnus-eval-in-buffer-window gnus-article-buffer
9596 (gnus-print-buffer))
9597 (gnus-summary-remove-process-mark article))
9598 (ps-despool filename))
9600 (defun gnus-print-buffer ()
9601 (let ((ps-left-header
9602 (list
9603 (concat "("
9604 (gnus-summary-print-truncate-and-quote
9605 (mail-header-subject gnus-current-headers)
9606 66) ")")
9607 (concat "("
9608 (gnus-summary-print-truncate-and-quote
9609 (mail-header-from gnus-current-headers)
9610 45) ")")))
9611 (ps-right-header
9612 (list
9613 "/pagenumberstring load"
9614 (concat "("
9615 (mail-header-date gnus-current-headers) ")"))))
9616 (gnus-run-hooks 'gnus-ps-print-hook)
9617 (save-excursion
9618 (if ps-print-color-p
9619 (ps-spool-buffer-with-faces)
9620 (ps-spool-buffer)))))
9622 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9624 (defun gnus-summary-show-complete-article ()
9625 "Show a complete version of the current article.
9626 This is only useful if you're looking at a partial version of the
9627 article currently."
9628 (interactive)
9629 (let ((gnus-keep-backlog nil)
9630 (gnus-use-cache nil)
9631 (gnus-agent nil)
9632 (variable (intern
9633 (format "%s-fetch-partial-articles"
9634 (car (gnus-find-method-for-group
9635 gnus-newsgroup-name)))
9636 obarray))
9637 old-val)
9638 (unwind-protect
9639 (progn
9640 (setq old-val (symbol-value variable))
9641 (set variable nil)
9642 (gnus-flush-original-article-buffer)
9643 (gnus-summary-show-article))
9644 (set variable old-val))))
9646 (defun gnus-summary-show-article (&optional arg)
9647 "Force redisplaying of the current article.
9648 If ARG (the prefix) is a number, show the article with the charset
9649 defined in `gnus-summary-show-article-charset-alist', or the charset
9650 input.
9651 If ARG (the prefix) is non-nil and not a number, show the article,
9652 but without running any of the article treatment functions
9653 article. Normally, the keystroke is `C-u g'. When using `C-u
9654 C-u g', show the raw article."
9655 (interactive "P")
9656 (cond
9657 ((numberp arg)
9658 (gnus-summary-show-article t)
9659 (let ((gnus-newsgroup-charset
9660 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9661 (read-coding-system
9662 "View as charset: " ;; actually it is coding system.
9663 (with-current-buffer gnus-article-buffer
9664 (mm-detect-coding-region (point) (point-max))))))
9665 (gnus-newsgroup-ignored-charsets 'gnus-all))
9666 (gnus-summary-select-article nil 'force)
9667 (let ((deps gnus-newsgroup-dependencies)
9668 head header lines)
9669 (with-current-buffer gnus-original-article-buffer
9670 (save-restriction
9671 (message-narrow-to-head)
9672 (setq head (buffer-string))
9673 (goto-char (point-min))
9674 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9675 (goto-char (point-max))
9676 (widen)
9677 (setq lines (1- (count-lines (point) (point-max))))))
9678 (with-temp-buffer
9679 (insert (format "211 %d Article retrieved.\n"
9680 (cdr gnus-article-current)))
9681 (insert head)
9682 (if lines (insert (format "Lines: %d\n" lines)))
9683 (insert ".\n")
9684 (let ((nntp-server-buffer (current-buffer)))
9685 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9686 (gnus-data-set-header
9687 (gnus-data-find (cdr gnus-article-current))
9688 header)
9689 (gnus-summary-update-article-line
9690 (cdr gnus-article-current) header)
9691 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9692 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9693 ((not arg)
9694 ;; Select the article the normal way.
9695 (if (eq mm-text-html-renderer 'shr)
9696 (progn
9697 (require 'shr)
9698 (let ((shr-ignore-cache t))
9699 (gnus-summary-select-article nil 'force)))
9700 (gnus-summary-select-article nil 'force)))
9701 ((equal arg '(16))
9702 ;; C-u C-u g
9703 (let ((gnus-inhibit-article-treatments t))
9704 (gnus-summary-select-article nil 'force)))
9706 ;; We have to require this here to make sure that the following
9707 ;; dynamic binding isn't shadowed by autoloading.
9708 (require 'gnus-async)
9709 (require 'gnus-art)
9710 ;; Bind the article treatment functions to nil.
9711 (let ((gnus-have-all-headers t)
9712 gnus-article-prepare-hook
9713 gnus-article-decode-hook
9714 gnus-display-mime-function
9715 gnus-break-pages)
9716 ;; Destroy any MIME parts.
9717 (when (gnus-buffer-live-p gnus-article-buffer)
9718 (with-current-buffer gnus-article-buffer
9719 (gnus-article-stop-animations)
9720 (gnus-stop-downloads)
9721 (mm-destroy-parts gnus-article-mime-handles)
9722 ;; Set it to nil for safety reason.
9723 (setq gnus-article-mime-handle-alist nil)
9724 (setq gnus-article-mime-handles nil)))
9725 (gnus-summary-select-article nil 'force))))
9726 (gnus-summary-goto-subject gnus-current-article)
9727 (gnus-summary-position-point))
9729 (defun gnus-summary-show-raw-article ()
9730 "Show the raw article without any article massaging functions being run."
9731 (interactive)
9732 (gnus-summary-show-article t))
9734 (defun gnus-summary-verbose-headers (&optional arg)
9735 "Toggle permanent full header display.
9736 If ARG is a positive number, turn header display on.
9737 If ARG is a negative number, turn header display off."
9738 (interactive "P")
9739 (setq gnus-show-all-headers
9740 (cond ((or (not (numberp arg))
9741 (zerop arg))
9742 (not gnus-show-all-headers))
9743 ((natnump arg)
9744 t)))
9745 (gnus-summary-show-article))
9747 (declare-function article-narrow-to-head "gnus-art" ())
9748 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9749 (declare-function gnus-delete-wash-type "gnus-art" (type))
9750 (declare-function gnus-mime-buttonize-attachments-in-header
9751 "gnus-art" (&optional interactive))
9753 (defun gnus-summary-toggle-header (&optional arg)
9754 "Show the headers if they are hidden, or hide them if they are shown.
9755 If ARG is a positive number, show the entire header.
9756 If ARG is a negative number, hide the unwanted header lines."
9757 (interactive "P")
9758 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9759 (get-buffer-window gnus-article-buffer t))))
9760 (with-current-buffer gnus-article-buffer
9761 (widen)
9762 (article-narrow-to-head)
9763 (let* ((inhibit-read-only t)
9764 (inhibit-point-motion-hooks t)
9765 (hidden (if (numberp arg)
9766 (>= arg 0)
9767 (or (not (looking-at "[^ \t\n]+:"))
9768 (gnus-article-hidden-text-p 'headers))))
9769 s e)
9770 (delete-region (point-min) (point-max))
9771 (with-current-buffer gnus-original-article-buffer
9772 (goto-char (setq s (point-min)))
9773 (setq e (if (search-forward "\n\n" nil t)
9774 (1- (point))
9775 (point-max))))
9776 (insert-buffer-substring gnus-original-article-buffer s e)
9777 (run-hooks 'gnus-article-decode-hook)
9778 (if hidden
9779 (let ((gnus-treat-hide-headers nil)
9780 (gnus-treat-hide-boring-headers nil))
9781 (gnus-delete-wash-type 'headers)
9782 (gnus-treat-article 'head))
9783 (gnus-treat-article 'head)
9784 ;; Add attachment buttons to the header.
9785 (when gnus-mime-display-attachment-buttons-in-header
9786 (gnus-mime-buttonize-attachments-in-header)))
9787 (widen)
9788 (if window
9789 (set-window-start window (goto-char (point-min))))
9790 (if gnus-break-pages
9791 (gnus-narrow-to-page)
9792 (when (gnus-visual-p 'page-marker)
9793 (let ((inhibit-read-only t))
9794 (gnus-remove-text-with-property 'gnus-prev)
9795 (gnus-remove-text-with-property 'gnus-next))))
9796 (gnus-set-mode-line 'article)))))
9798 (defun gnus-summary-show-all-headers ()
9799 "Make all header lines visible."
9800 (interactive)
9801 (gnus-summary-toggle-header 1))
9803 (defun gnus-summary-caesar-message (&optional arg)
9804 "Caesar rotate the current article by 13.
9805 With a non-numerical prefix, also rotate headers. A numerical
9806 prefix specifies how many places to rotate each letter forward."
9807 (interactive "P")
9808 (gnus-summary-select-article)
9809 (let ((mail-header-separator ""))
9810 (gnus-eval-in-buffer-window gnus-article-buffer
9811 (save-restriction
9812 (widen)
9813 (let ((start (window-start))
9814 (inhibit-read-only t))
9815 (if (equal arg '(4))
9816 (message-caesar-buffer-body nil t)
9817 (message-caesar-buffer-body arg))
9818 (set-window-start (get-buffer-window (current-buffer)) start)))))
9819 ;; Create buttons and stuff...
9820 (gnus-treat-article nil))
9822 (defun gnus-summary-idna-message (&optional arg)
9823 "Decode IDNA encoded domain names in the current articles.
9824 IDNA encoded domain names looks like `xn--bar'. If a string
9825 remain unencoded after running this function, it is likely an
9826 invalid IDNA string (`xn--bar' is invalid).
9828 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9829 installed for this command to work."
9830 (interactive "P")
9831 (gnus-summary-select-article)
9832 (let ((mail-header-separator ""))
9833 (gnus-eval-in-buffer-window gnus-article-buffer
9834 (save-restriction
9835 (widen)
9836 (let ((start (window-start))
9837 buffer-read-only)
9838 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9839 (replace-match (puny-decode-domain (match-string 1))))
9840 (set-window-start (get-buffer-window (current-buffer)) start))))))
9842 (defun gnus-summary-morse-message (&optional arg)
9843 "Morse decode the current article."
9844 (interactive "P")
9845 (gnus-summary-select-article)
9846 (let ((mail-header-separator ""))
9847 (gnus-eval-in-buffer-window gnus-article-buffer
9848 (save-excursion
9849 (save-restriction
9850 (widen)
9851 (let ((pos (window-start))
9852 (inhibit-read-only t))
9853 (goto-char (point-min))
9854 (when (message-goto-body)
9855 (gnus-narrow-to-body))
9856 (goto-char (point-min))
9857 (while (search-forward "·" (point-max) t)
9858 (replace-match "."))
9859 (unmorse-region (point-min) (point-max))
9860 (widen)
9861 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9863 (defun gnus-summary-stop-page-breaking ()
9864 "Stop page breaking in the current article."
9865 (interactive)
9866 (gnus-summary-select-article)
9867 (gnus-eval-in-buffer-window gnus-article-buffer
9868 (widen)
9869 (when (gnus-visual-p 'page-marker)
9870 (let ((inhibit-read-only t))
9871 (gnus-remove-text-with-property 'gnus-prev)
9872 (gnus-remove-text-with-property 'gnus-next))
9873 (setq gnus-page-broken nil))))
9875 (defun gnus-summary-move-article (&optional n to-newsgroup
9876 select-method action)
9877 "Move the current article to a different newsgroup.
9878 If N is a positive number, move the N next articles.
9879 If N is a negative number, move the N previous articles.
9880 If N is nil and any articles have been marked with the process mark,
9881 move those articles instead.
9882 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9883 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9884 re-spool using this method.
9886 When called interactively with TO-NEWSGROUP being nil, the value of
9887 the variable `gnus-move-split-methods' is used for finding a default
9888 for the target newsgroup.
9890 For this function to work, both the current newsgroup and the
9891 newsgroup that you want to move to have to support the `request-move'
9892 and `request-accept' functions.
9894 ACTION can be either `move' (the default), `crosspost' or `copy'."
9895 (interactive "P")
9896 (unless action
9897 (setq action 'move))
9898 ;; Check whether the source group supports the required functions.
9899 (cond ((and (eq action 'move)
9900 (not (gnus-check-backend-function
9901 'request-move-article gnus-newsgroup-name)))
9902 (error "The current group does not support article moving"))
9903 ((and (eq action 'crosspost)
9904 (not (gnus-check-backend-function
9905 'request-replace-article gnus-newsgroup-name)))
9906 (error "The current group does not support article editing")))
9907 (let ((articles (gnus-summary-work-articles n))
9908 (prefix (if (gnus-check-backend-function
9909 'request-move-article gnus-newsgroup-name)
9910 (funcall gnus-move-group-prefix-function
9911 gnus-newsgroup-name)
9912 ""))
9913 (names '((move "Move" "Moving")
9914 (copy "Copy" "Copying")
9915 (crosspost "Crosspost" "Crossposting")))
9916 (copy-buf (save-excursion
9917 (nnheader-set-temp-buffer " *copy article*")))
9918 art-group to-method new-xref article to-groups
9919 articles-to-update-marks encoded)
9920 (unless (assq action names)
9921 (error "Unknown action %s" action))
9922 ;; Read the newsgroup name.
9923 (when (and (not to-newsgroup)
9924 (not select-method))
9925 (if (and gnus-move-split-methods
9926 (not
9927 (and (memq gnus-current-article articles)
9928 (gnus-buffer-live-p gnus-original-article-buffer))))
9929 ;; When `gnus-move-split-methods' is non-nil, we have to
9930 ;; select an article to give `gnus-read-move-group-name' an
9931 ;; opportunity to suggest an appropriate default. However,
9932 ;; we needn't render or mark the article.
9933 (let ((gnus-display-mime-function nil)
9934 (gnus-article-prepare-hook nil)
9935 (gnus-mark-article-hook nil))
9936 (gnus-summary-select-article nil nil nil (car articles))))
9937 (setq to-newsgroup (gnus-read-move-group-name
9938 (cadr (assq action names))
9939 (symbol-value
9940 (intern (format "gnus-current-%s-group" action)))
9941 articles prefix)
9942 encoded to-newsgroup
9943 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9944 (set (intern (format "gnus-current-%s-group" action))
9945 (decode-coding-string
9946 to-newsgroup
9947 (gnus-group-name-charset to-method to-newsgroup))))
9948 (unless to-method
9949 (setq to-method (or select-method
9950 (gnus-server-to-method
9951 (gnus-group-method to-newsgroup)))))
9952 (setq to-newsgroup
9953 (or encoded
9954 (and to-newsgroup
9955 (encode-coding-string
9956 to-newsgroup
9957 (gnus-group-name-charset to-method to-newsgroup)))))
9958 ;; Check the method we are to move this article to...
9959 (unless (gnus-check-backend-function
9960 'request-accept-article (car to-method))
9961 (error "%s does not support article copying" (car to-method)))
9962 (unless (gnus-check-server to-method)
9963 (error "Can't open server %s" (car to-method)))
9964 (gnus-message 6 "%s to %s: %s..."
9965 (caddr (assq action names))
9966 (or (car select-method)
9967 (gnus-group-decoded-name to-newsgroup))
9968 articles)
9969 (while articles
9970 (setq article (pop articles))
9971 ;; Set any marks that may have changed in the summary buffer.
9972 (when gnus-preserve-marks
9973 (gnus-summary-push-marks-to-backend article))
9974 (setq
9975 art-group
9976 (cond
9977 ;; Move the article.
9978 ((eq action 'move)
9979 ;; Remove this article from future suppression.
9980 (gnus-dup-unsuppress-article article)
9981 (let* ((from-method (gnus-find-method-for-group
9982 gnus-newsgroup-name))
9983 (to-method (or select-method
9984 (gnus-find-method-for-group to-newsgroup)))
9985 (move-is-internal (gnus-server-equal from-method to-method)))
9986 (gnus-request-move-article
9987 article ; Article to move
9988 gnus-newsgroup-name ; From newsgroup
9989 (nth 1 (gnus-find-method-for-group
9990 gnus-newsgroup-name)) ; Server
9991 (list 'gnus-request-accept-article
9992 to-newsgroup (list 'quote select-method)
9993 (not articles) t) ; Accept form
9994 (not articles) ; Only save nov last time
9995 (and move-is-internal
9996 to-newsgroup ; Not respooling
9997 ; Is this move internal?
9998 (gnus-group-real-name to-newsgroup)))))
9999 ;; Copy the article.
10000 ((eq action 'copy)
10001 (with-current-buffer copy-buf
10002 (when (gnus-request-article-this-buffer article
10003 gnus-newsgroup-name)
10004 (save-restriction
10005 (nnheader-narrow-to-headers)
10006 (dolist (hdr gnus-copy-article-ignored-headers)
10007 (message-remove-header hdr t)))
10008 (gnus-request-accept-article
10009 to-newsgroup select-method (not articles) t))))
10010 ;; Crosspost the article.
10011 ((eq action 'crosspost)
10012 (let ((xref (message-tokenize-header
10013 (mail-header-xref (gnus-summary-article-header
10014 article))
10015 " ")))
10016 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10017 ":" (number-to-string article)))
10018 (unless xref
10019 (setq xref (list (system-name))))
10020 (setq new-xref
10021 (concat
10022 (mapconcat 'identity
10023 (delete "Xref:" (delete new-xref xref))
10024 " ")
10025 " " new-xref))
10026 (with-current-buffer copy-buf
10027 ;; First put the article in the destination group.
10028 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10029 (when (consp (setq art-group
10030 (gnus-request-accept-article
10031 to-newsgroup select-method (not articles)
10032 t)))
10033 (setq new-xref (concat new-xref " " (car art-group)
10035 (number-to-string (cdr art-group))))
10036 ;; Now we have the new Xrefs header, so we insert
10037 ;; it and replace the new article.
10038 (nnheader-replace-header "Xref" new-xref)
10039 (gnus-request-replace-article
10040 (cdr art-group) to-newsgroup (current-buffer) t)
10041 art-group))))))
10042 (cond
10043 ((not art-group)
10044 (gnus-message 1 "Couldn't %s article %s: %s"
10045 (cadr (assq action names)) article
10046 (nnheader-get-report (car to-method))))
10047 ((eq art-group 'junk)
10048 (when (eq action 'move)
10049 (gnus-summary-mark-article article gnus-canceled-mark)
10050 (gnus-message 4 "Deleted article %s" article)
10051 ;; run the delete hook
10052 (run-hook-with-args 'gnus-summary-article-delete-hook
10053 action
10054 (gnus-data-header
10055 (assoc article (gnus-data-list nil)))
10056 gnus-newsgroup-name nil
10057 select-method)))
10059 (let* ((pto-group (gnus-group-prefixed-name
10060 (car art-group) to-method))
10061 (info (gnus-get-info pto-group))
10062 (to-group (gnus-info-group info))
10063 to-marks)
10064 ;; Update the group that has been moved to.
10065 (when (and info
10066 (memq action '(move copy)))
10067 (unless (member to-group to-groups)
10068 (push to-group to-groups))
10070 (when (and (not (memq article gnus-newsgroup-unreads))
10071 (cdr art-group))
10072 (push 'read to-marks)
10073 (gnus-info-set-read
10074 info (gnus-add-to-range (gnus-info-read info)
10075 (list (cdr art-group)))))
10077 ;; See whether the article is to be put in the cache.
10078 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10079 (marks (if expirable
10080 gnus-article-mark-lists
10081 (delete '(expirable . expire)
10082 (copy-sequence
10083 gnus-article-mark-lists))))
10084 (to-article (cdr art-group)))
10086 ;; Enter the article into the cache in the new group,
10087 ;; if that is required.
10088 (when (and to-article
10089 gnus-use-cache)
10090 (gnus-cache-possibly-enter-article
10091 to-group to-article
10092 (memq article gnus-newsgroup-marked)
10093 (memq article gnus-newsgroup-dormant)
10094 (memq article gnus-newsgroup-unreads)))
10096 (when (and gnus-preserve-marks
10097 to-article)
10098 ;; Copy any marks over to the new group.
10099 (when (and (equal to-group gnus-newsgroup-name)
10100 (not (memq article gnus-newsgroup-unreads)))
10101 ;; Mark this article as read in this group.
10102 (push (cons to-article gnus-read-mark)
10103 gnus-newsgroup-reads)
10104 ;; Increase the active status of this group.
10105 (setcdr (gnus-active to-group) to-article)
10106 (setcdr gnus-newsgroup-active to-article))
10108 (while marks
10109 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10110 (when (memq article (symbol-value
10111 (intern (format "gnus-newsgroup-%s"
10112 (caar marks)))))
10113 (push (cdar marks) to-marks)
10114 ;; If the other group is the same as this group,
10115 ;; then we have to add the mark to the list.
10116 (when (equal to-group gnus-newsgroup-name)
10117 (set (intern (format "gnus-newsgroup-%s"
10118 (caar marks)))
10119 (cons to-article
10120 (symbol-value
10121 (intern (format "gnus-newsgroup-%s"
10122 (caar marks)))))))
10123 ;; Copy the marks to other group.
10124 (gnus-add-marked-articles
10125 to-group (cdar marks) (list to-article) info)))
10126 (setq marks (cdr marks)))
10128 (when (and expirable
10129 gnus-mark-copied-or-moved-articles-as-expirable
10130 (not (memq 'expire to-marks)))
10131 ;; Mark this article as expirable.
10132 (push 'expire to-marks)
10133 (when (equal to-group gnus-newsgroup-name)
10134 (push to-article gnus-newsgroup-expirable))
10135 ;; Copy the expirable mark to other group.
10136 (gnus-add-marked-articles
10137 to-group 'expire (list to-article) info))
10139 (when (and to-marks
10140 (gnus-method-option-p
10141 (gnus-find-method-for-group to-group)
10142 'server-marks))
10143 (gnus-request-set-mark
10144 to-group (list (list (list to-article) 'add to-marks)))))
10146 (gnus-dribble-enter
10147 (concat "(gnus-group-set-info '"
10148 (gnus-prin1-to-string (gnus-get-info to-group))
10149 ")")
10150 (concat "^(gnus-group-set-info '(\""
10151 (regexp-quote to-group) "\""))))
10153 ;; Update the Xref header in this article to point to
10154 ;; the new crossposted article we have just created.
10155 (when (eq action 'crosspost)
10156 (with-current-buffer copy-buf
10157 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10158 (nnheader-replace-header "Xref" new-xref)
10159 (gnus-request-replace-article
10160 article gnus-newsgroup-name (current-buffer) t)))
10162 ;; run the move/copy/crosspost/respool hook
10163 (run-hook-with-args 'gnus-summary-article-move-hook
10164 action
10165 (gnus-data-header
10166 (assoc article (gnus-data-list nil)))
10167 gnus-newsgroup-name
10168 to-newsgroup
10169 select-method))
10171 ;;;!!!Why is this necessary?
10172 (set-buffer gnus-summary-buffer)
10174 (when (eq action 'move)
10175 (save-excursion
10176 (gnus-summary-goto-subject article)
10177 (gnus-summary-mark-article article gnus-canceled-mark)))))
10178 (push article articles-to-update-marks))
10180 (save-excursion
10181 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10182 ;; Re-activate all groups that have been moved to.
10183 (with-current-buffer gnus-group-buffer
10184 (let ((gnus-group-marked to-groups))
10185 (gnus-group-get-new-news-this-group nil t)))
10187 (gnus-kill-buffer copy-buf)
10188 (gnus-summary-position-point)
10189 (gnus-set-mode-line 'summary)))
10191 (defun gnus-summary-push-marks-to-backend (article)
10192 (let ((set nil)
10193 (del nil)
10194 (marks gnus-article-mark-lists))
10195 (unless (memq article gnus-newsgroup-unreads)
10196 (push 'read set))
10197 (while marks
10198 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10199 (memq article (symbol-value
10200 (intern (format "gnus-newsgroup-%s"
10201 (caar marks))))))
10202 (push (cdar marks) set)
10203 (push (cdar marks) del))
10204 (pop marks))
10205 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10206 ((,article) del ,del)))))
10208 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10209 "Copy the current article to some other group.
10210 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10211 When called interactively, if TO-NEWSGROUP is nil, use the value of
10212 the variable `gnus-move-split-methods' for finding a default target
10213 newsgroup.
10214 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10215 re-spool using this method."
10216 (interactive "P")
10217 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10219 (defun gnus-summary-crosspost-article (&optional n)
10220 "Crosspost the current article to some other group."
10221 (interactive "P")
10222 (gnus-summary-move-article n nil nil 'crosspost))
10224 (defcustom gnus-summary-respool-default-method nil
10225 "Default method type for respooling an article.
10226 If nil, use to the current newsgroup method."
10227 :type 'symbol
10228 :group 'gnus-summary-mail)
10230 (defun gnus-summary-respool-article (&optional n method)
10231 "Respool the current article.
10232 The article will be squeezed through the mail spooling process again,
10233 which means that it will be put in some mail newsgroup or other
10234 depending on `nnmail-split-methods'.
10235 If N is a positive number, respool the N next articles.
10236 If N is a negative number, respool the N previous articles.
10237 If N is nil and any articles have been marked with the process mark,
10238 respool those articles instead.
10240 Respooling can be done both from mail groups and \"real\" newsgroups.
10241 In the former case, the articles in question will be moved from the
10242 current group into whatever groups they are destined to. In the
10243 latter case, they will be copied into the relevant groups."
10244 (interactive
10245 (list current-prefix-arg
10246 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10247 (methname
10248 (symbol-name (or gnus-summary-respool-default-method
10249 (car (gnus-find-method-for-group
10250 gnus-newsgroup-name)))))
10251 (method
10252 (gnus-completing-read
10253 "Backend to use when respooling"
10254 methods t nil 'gnus-mail-method-history methname))
10256 (cond
10257 ((zerop (length (setq ms (gnus-servers-using-backend
10258 (intern method)))))
10259 (list (intern method) ""))
10260 ((= 1 (length ms))
10261 (car ms))
10263 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10264 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10265 ms-alist))))))))
10266 (unless method
10267 (error "No method given for respooling"))
10268 (if (assoc (symbol-name
10269 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10270 (gnus-methods-using 'respool))
10271 (gnus-summary-move-article n nil method)
10272 (gnus-summary-copy-article n nil method)))
10274 (defun gnus-summary-import-article (file &optional edit)
10275 "Import an arbitrary file into a mail newsgroup."
10276 (interactive "fImport file: \nP")
10277 (let ((group gnus-newsgroup-name)
10278 (now (current-time))
10279 atts lines group-art)
10280 (unless (gnus-check-backend-function 'request-accept-article group)
10281 (error "%s does not support article importing" group))
10282 (or (file-readable-p file)
10283 (not (file-regular-p file))
10284 (error "Can't read %s" file))
10285 (with-current-buffer (gnus-get-buffer-create " *import file*")
10286 (erase-buffer)
10287 (nnheader-insert-file-contents file)
10288 (goto-char (point-min))
10289 (if (nnheader-article-p)
10290 (save-restriction
10291 (goto-char (point-min))
10292 (search-forward "\n\n" nil t)
10293 (narrow-to-region (point-min) (1- (point)))
10294 (goto-char (point-min))
10295 (unless (re-search-forward "^date:" nil t)
10296 (goto-char (point-max))
10297 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10298 ;; This doesn't look like an article, so we fudge some headers.
10299 (setq atts (file-attributes file)
10300 lines (count-lines (point-min) (point-max)))
10301 (insert "From: " (read-string "From: ") "\n"
10302 "Subject: " (read-string "Subject: ") "\n"
10303 "Date: " (message-make-date (nth 5 atts)) "\n"
10304 "Message-ID: " (message-make-message-id) "\n"
10305 "Lines: " (int-to-string lines) "\n"
10306 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10307 (setq group-art (gnus-request-accept-article group nil t))
10308 (kill-buffer (current-buffer)))
10309 (setq gnus-newsgroup-active (gnus-activate-group group))
10310 (forward-line 1)
10311 (gnus-summary-goto-article (cdr group-art) nil t)
10312 (when edit
10313 (gnus-summary-edit-article))))
10315 (defun gnus-summary-create-article ()
10316 "Create an article in a mail newsgroup."
10317 (interactive)
10318 (let ((group gnus-newsgroup-name)
10319 (now (current-time))
10320 group-art)
10321 (unless (gnus-check-backend-function 'request-accept-article group)
10322 (error "%s does not support article importing" group))
10323 (with-current-buffer (gnus-get-buffer-create " *import file*")
10324 (erase-buffer)
10325 (goto-char (point-min))
10326 ;; This doesn't look like an article, so we fudge some headers.
10327 (insert "From: " (read-string "From: ") "\n"
10328 "Subject: " (read-string "Subject: ") "\n"
10329 "Date: " (message-make-date now) "\n"
10330 "Message-ID: " (message-make-message-id) "\n")
10331 (setq group-art (gnus-request-accept-article group nil t))
10332 (kill-buffer (current-buffer)))
10333 (setq gnus-newsgroup-active (gnus-activate-group group))
10334 (forward-line 1)
10335 (gnus-summary-goto-article (cdr group-art) nil t)
10336 (gnus-summary-edit-article)))
10338 (defun gnus-summary-article-posted-p ()
10339 "Say whether the current (mail) article is available from news as well.
10340 This will be the case if the article has both been mailed and posted."
10341 (interactive)
10342 (let ((id (mail-header-references (gnus-summary-article-header)))
10343 (gnus-override-method (car (gnus-refer-article-methods))))
10344 (if (gnus-request-head id "")
10345 (gnus-message 2 "The current message was found on %s"
10346 gnus-override-method)
10347 (gnus-message 2 "The current message couldn't be found on %s"
10348 gnus-override-method)
10349 nil)))
10351 (defun gnus-summary-expire-articles (&optional now)
10352 "Expire all articles that are marked as expirable in the current group."
10353 (interactive)
10354 (when (and (not gnus-group-is-exiting-without-update-p)
10355 (gnus-check-backend-function
10356 'request-expire-articles gnus-newsgroup-name))
10357 ;; This backend supports expiry.
10358 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10359 (expirable
10360 (gnus-list-range-difference
10361 (if total
10362 (progn
10363 ;; We need to update the info for
10364 ;; this group for `gnus-list-of-read-articles'
10365 ;; to give us the right answer.
10366 (gnus-run-hooks 'gnus-exit-group-hook)
10367 (gnus-summary-update-info)
10368 (gnus-list-of-read-articles gnus-newsgroup-name))
10369 (setq gnus-newsgroup-expirable
10370 (sort gnus-newsgroup-expirable '<)))
10371 gnus-newsgroup-unexist))
10372 (expiry-wait (if now 'immediate
10373 (gnus-group-find-parameter
10374 gnus-newsgroup-name 'expiry-wait)))
10375 (nnmail-expiry-target
10376 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10377 nnmail-expiry-target))
10379 (when expirable
10380 ;; There are expirable articles in this group, so we run them
10381 ;; through the expiry process.
10382 (gnus-message 6 "Expiring articles...")
10383 (when (gnus-check-group gnus-newsgroup-name)
10384 ;; The list of articles that weren't expired is returned.
10385 (save-excursion
10386 (if expiry-wait
10387 (let ((nnmail-expiry-wait-function nil)
10388 (nnmail-expiry-wait expiry-wait))
10389 (setq es (gnus-request-expire-articles
10390 expirable gnus-newsgroup-name)))
10391 (setq es (gnus-request-expire-articles
10392 expirable gnus-newsgroup-name)))
10393 (unless total
10394 (setq gnus-newsgroup-expirable es))
10395 ;; We go through the old list of expirable, and mark all
10396 ;; really expired articles as nonexistent.
10397 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10398 (let ((gnus-use-cache nil))
10399 (dolist (article expirable)
10400 (when (and (not (memq article es))
10401 (gnus-data-find article))
10402 (gnus-summary-mark-article article gnus-canceled-mark)
10403 (run-hook-with-args
10404 'gnus-summary-article-expire-hook
10405 'delete
10406 (gnus-data-header (assoc article (gnus-data-list nil)))
10407 gnus-newsgroup-name
10408 (cond
10409 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10410 ((eq nnmail-expiry-target 'delete) nil)
10412 (let ((rescall (funcall nnmail-expiry-target
10413 gnus-newsgroup-name)))
10414 (if (stringp rescall) rescall nil))))
10415 nil)))))))
10416 (gnus-message 6 "Expiring articles...done")))))
10418 (defun gnus-summary-expire-articles-now ()
10419 "Expunge all expirable articles in the current group.
10420 This means that *all* articles that are marked as expirable will be
10421 deleted forever, right now."
10422 (interactive)
10423 (or gnus-expert-user
10424 (gnus-yes-or-no-p
10425 "Are you really, really sure you want to delete all expirable messages? ")
10426 (error "Phew!"))
10427 (gnus-summary-expire-articles t))
10429 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10430 (defun gnus-summary-delete-article (&optional n)
10431 "Delete the N next (mail) articles.
10432 This command actually deletes articles. This is not a marking
10433 command. The article will disappear forever from your life, never to
10434 return.
10436 If N is negative, delete backwards.
10437 If N is nil and articles have been marked with the process mark,
10438 delete these instead.
10440 If `gnus-novice-user' is non-nil you will be asked for
10441 confirmation before the articles are deleted."
10442 (interactive "P")
10443 (unless (gnus-check-backend-function 'request-expire-articles
10444 gnus-newsgroup-name)
10445 (error "The current newsgroup does not support article deletion"))
10446 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10447 (error "Couldn't open server"))
10448 ;; Compute the list of articles to delete.
10449 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10450 (nnmail-expiry-target 'delete)
10451 not-deleted)
10452 (if (and gnus-novice-user
10453 (not (gnus-yes-or-no-p
10454 (format "Do you really want to delete %s forever? "
10455 (if (> (length articles) 1)
10456 (format "these %s articles" (length articles))
10457 "this article")))))
10459 ;; Delete the articles.
10460 (setq not-deleted (gnus-request-expire-articles
10461 articles gnus-newsgroup-name 'force))
10462 (save-excursion
10463 (while articles
10464 (gnus-summary-remove-process-mark (car articles))
10465 ;; The backend might not have been able to delete the article
10466 ;; after all.
10467 (unless (memq (car articles) not-deleted)
10468 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10469 (let* ((article (car articles))
10470 (ghead (gnus-data-header
10471 (assoc article (gnus-data-list nil)))))
10472 (run-hook-with-args 'gnus-summary-article-delete-hook
10473 'delete ghead gnus-newsgroup-name nil
10474 nil)))
10475 (setq articles (cdr articles))))
10476 (when not-deleted
10477 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10478 (gnus-summary-position-point)
10479 (gnus-set-mode-line 'summary)
10480 not-deleted))
10482 (defun gnus-summary-edit-article (&optional arg)
10483 "Edit the current article.
10484 This will have permanent effect only in mail groups.
10485 If ARG is nil, edit the decoded articles.
10486 If ARG is 1, edit the raw articles.
10487 If ARG is 2, edit the raw articles even in read-only groups.
10488 If ARG is 3, edit the articles with the current handles.
10489 Otherwise, allow editing of articles even in read-only
10490 groups."
10491 (interactive "P")
10492 (let (force raw current-handles)
10493 (cond
10494 ((null arg))
10495 ((eq arg 1)
10496 (setq raw t))
10497 ((eq arg 2)
10498 (setq raw t
10499 force t))
10500 ((eq arg 3)
10501 (setq current-handles
10502 (and (gnus-buffer-live-p gnus-article-buffer)
10503 (with-current-buffer gnus-article-buffer
10504 (prog1
10505 gnus-article-mime-handles
10506 (setq gnus-article-mime-handles nil))))))
10508 (setq force t)))
10509 (when (and raw (not force)
10510 (member gnus-newsgroup-name '("nndraft:delayed"
10511 "nndraft:drafts"
10512 "nndraft:queue")))
10513 (error "Can't edit the raw article in group %s"
10514 gnus-newsgroup-name))
10515 (with-current-buffer gnus-summary-buffer
10516 (let ((mail-parse-charset gnus-newsgroup-charset)
10517 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10518 (gnus-set-global-variables)
10519 (when (and (not force)
10520 (gnus-group-read-only-p))
10521 (error "The current newsgroup does not support article editing"))
10522 (gnus-summary-show-article t)
10523 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10524 (with-current-buffer gnus-article-buffer
10525 (mm-enable-multibyte)))
10526 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10527 (setq raw t))
10528 (gnus-article-edit-article
10529 (if raw 'ignore
10530 `(lambda ()
10531 (let ((mbl mml-buffer-list))
10532 (setq mml-buffer-list nil)
10533 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10534 (mime-to-mml ,'current-handles))
10535 (let ((mbl1 mml-buffer-list))
10536 (setq mml-buffer-list mbl)
10537 (set (make-local-variable 'mml-buffer-list) mbl1))
10538 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10539 `(lambda (no-highlight)
10540 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10541 (message-options message-options)
10542 (message-options-set-recipient)
10543 (mail-parse-ignored-charsets
10544 ',gnus-newsgroup-ignored-charsets)
10545 (rfc2047-header-encoding-alist
10546 ',(let ((charset (gnus-group-name-charset
10547 (gnus-find-method-for-group
10548 gnus-newsgroup-name)
10549 gnus-newsgroup-name)))
10550 (append (list (cons "Newsgroups" charset)
10551 (cons "Followup-To" charset)
10552 (cons "Xref" charset))
10553 rfc2047-header-encoding-alist))))
10554 ,(if (not raw) '(progn
10555 (mml-to-mime)
10556 (mml-destroy-buffers)
10557 (remove-hook 'kill-buffer-hook
10558 'mml-destroy-buffers t)
10559 (kill-local-variable 'mml-buffer-list)))
10560 (gnus-summary-edit-article-done
10561 ,(or (mail-header-references gnus-current-headers) "")
10562 ,(gnus-group-read-only-p)
10563 ,gnus-summary-buffer no-highlight))))))))
10565 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10567 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10568 no-highlight)
10569 "Make edits to the current article permanent."
10570 (interactive)
10571 (save-excursion
10572 ;; The buffer restriction contains the entire article if it exists.
10573 (when (article-goto-body)
10574 (let ((lines (count-lines (point) (point-max)))
10575 (length (- (point-max) (point)))
10576 (case-fold-search t)
10577 (body (point-marker)))
10578 (goto-char (point-min))
10579 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10580 (delete-region (match-beginning 1) (match-end 1))
10581 (insert (number-to-string length)))
10582 (goto-char (point-min))
10583 (when (re-search-forward
10584 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10585 (delete-region (match-beginning 1) (match-end 1))
10586 (insert (number-to-string length)))
10587 (goto-char (point-min))
10588 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10589 (delete-region (match-beginning 1) (match-end 1))
10590 (insert (number-to-string lines))))))
10591 ;; Replace the article.
10592 (let ((buf (current-buffer))
10593 (article (cdr gnus-article-current))
10594 replace-result)
10595 (with-temp-buffer
10596 (insert-buffer-substring buf)
10597 (if (and (not read-only)
10598 (not (setq replace-result
10599 (gnus-request-replace-article
10600 article (car gnus-article-current)
10601 (current-buffer) t))))
10602 (error "Couldn't replace article")
10603 ;; If we got a number back, then that's the new article number
10604 ;; for this article. Otherwise, the article number didn't change.
10605 (when (numberp replace-result)
10606 (with-current-buffer gnus-summary-buffer
10607 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10608 (gnus-summary-limit gnus-newsgroup-limit)
10609 (setq article replace-result)
10610 (gnus-summary-goto-subject article t)))
10611 ;; Update the summary buffer.
10612 (if (and references
10613 (equal (message-tokenize-header references " ")
10614 (message-tokenize-header
10615 (or (message-fetch-field "references") "") " ")))
10616 ;; We only have to update this line.
10617 (save-excursion
10618 (save-restriction
10619 (message-narrow-to-head)
10620 (let ((head (buffer-substring-no-properties
10621 (point-min) (point-max)))
10622 header)
10623 (with-temp-buffer
10624 (insert (format "211 %d Article retrieved.\n" article))
10625 (insert head)
10626 (insert ".\n")
10627 (let ((nntp-server-buffer (current-buffer)))
10628 (setq header (car (gnus-get-newsgroup-headers nil t))))
10629 (with-current-buffer gnus-summary-buffer
10630 (gnus-data-set-header (gnus-data-find article) header)
10631 (gnus-summary-update-article-line article header)
10632 (if (gnus-summary-goto-subject article nil t)
10633 (gnus-summary-update-secondary-mark article)))))))
10634 ;; Update threads.
10635 (set-buffer (or buffer gnus-summary-buffer))
10636 (gnus-summary-update-article article)
10637 (if (gnus-summary-goto-subject article nil t)
10638 (gnus-summary-update-secondary-mark article)))
10639 ;; Prettify the article buffer again.
10640 (unless no-highlight
10641 (with-current-buffer gnus-article-buffer
10642 ;;!!! Fix this -- article should be rehighlighted.
10643 ;;(gnus-run-hooks 'gnus-article-display-hook)
10644 (set-buffer gnus-original-article-buffer)
10645 (gnus-request-article
10646 article (car gnus-article-current) (current-buffer))))
10647 ;; Prettify the summary buffer line.
10648 (when (gnus-visual-p 'summary-highlight 'highlight)
10649 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10651 (defun gnus-summary-edit-wash (key)
10652 "Perform editing command KEY in the article buffer."
10653 (interactive
10654 (list
10655 (progn
10656 (message "%s" (concat (this-command-keys) "- "))
10657 (read-char))))
10658 (message "")
10659 (gnus-summary-edit-article)
10660 (execute-kbd-macro (concat (this-command-keys) key))
10661 (gnus-article-edit-done))
10663 ;;; Respooling
10665 (defvar nnimap-split-fancy)
10666 (defvar nnimap-split-methods)
10668 (defun gnus-summary-respool-query (&optional silent trace)
10669 "Query where the respool algorithm would put this article."
10670 (interactive)
10671 (let (gnus-mark-article-hook)
10672 (gnus-summary-select-article)
10673 (with-current-buffer gnus-original-article-buffer
10674 (let ((groups
10675 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10676 'nnimap)
10677 ;; nnimap has its own splitting variables.
10678 (let ((nnmail-split-methods
10679 (cond
10680 ((eq nnimap-split-methods 'default)
10681 nnmail-split-methods)
10682 (nnimap-split-methods
10683 nnimap-split-methods)
10684 (nnimap-split-fancy
10685 'nnmail-split-fancy)))
10686 (nnmail-split-fancy (or nnimap-split-fancy
10687 nnmail-split-fancy)))
10688 (nnmail-article-group 'identity trace))
10689 (nnmail-article-group 'identity trace))))
10690 (unless silent
10691 (if groups
10692 (message "This message would go to %s"
10693 (mapconcat 'car groups ", "))
10694 (message "This message would go to no groups"))
10695 groups)))))
10697 (defun gnus-summary-respool-trace ()
10698 "Trace where the respool algorithm would put this article.
10699 Display a buffer showing all fancy splitting patterns which matched."
10700 (interactive)
10701 (gnus-summary-respool-query nil t))
10703 ;; Summary marking commands.
10705 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10706 "Mark articles which has the same subject as read, and then select the next.
10707 If UNMARK is positive, remove any kind of mark.
10708 If UNMARK is negative, tick articles."
10709 (interactive "P")
10710 (when unmark
10711 (setq unmark (prefix-numeric-value unmark)))
10712 (let ((count
10713 (gnus-summary-mark-same-subject
10714 (gnus-summary-article-subject) unmark)))
10715 ;; Select next unread article. If auto-select-same mode, should
10716 ;; select the first unread article.
10717 (gnus-summary-next-article t (and gnus-auto-select-same
10718 (gnus-summary-article-subject)))
10719 (gnus-message 7 "%d article%s marked as %s"
10720 count (if (= count 1) " is" "s are")
10721 (if unmark "unread" "read"))))
10723 (defun gnus-summary-kill-same-subject (&optional unmark)
10724 "Mark articles which has the same subject as read.
10725 If UNMARK is positive, remove any kind of mark.
10726 If UNMARK is negative, tick articles."
10727 (interactive "P")
10728 (when unmark
10729 (setq unmark (prefix-numeric-value unmark)))
10730 (let ((count
10731 (gnus-summary-mark-same-subject
10732 (gnus-summary-article-subject) unmark)))
10733 ;; If marked as read, go to next unread subject.
10734 (when (null unmark)
10735 ;; Go to next unread subject.
10736 (gnus-summary-next-subject 1 t))
10737 (gnus-message 7 "%d articles are marked as %s"
10738 count (if unmark "unread" "read"))))
10740 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10741 "Mark articles with same SUBJECT as read, and return marked number.
10742 If optional argument UNMARK is positive, remove any kinds of marks.
10743 If optional argument UNMARK is negative, mark articles as unread instead."
10744 (let ((count 1))
10745 (save-excursion
10746 (cond
10747 ((null unmark) ; Mark as read.
10748 (while (and
10749 (progn
10750 (gnus-summary-mark-article-as-read gnus-killed-mark)
10751 (gnus-summary-show-thread) t)
10752 (gnus-summary-find-subject subject))
10753 (setq count (1+ count))))
10754 ((> unmark 0) ; Tick.
10755 (while (and
10756 (progn
10757 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10758 (gnus-summary-show-thread) t)
10759 (gnus-summary-find-subject subject))
10760 (setq count (1+ count))))
10761 (t ; Mark as unread.
10762 (while (and
10763 (progn
10764 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10765 (gnus-summary-show-thread) t)
10766 (gnus-summary-find-subject subject))
10767 (setq count (1+ count)))))
10768 (gnus-set-mode-line 'summary)
10769 ;; Return the number of marked articles.
10770 count)))
10772 (defun gnus-summary-mark-as-processable (n &optional unmark)
10773 "Set the process mark on the next N articles.
10774 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10775 the process mark instead. The difference between N and the actual
10776 number of articles marked is returned."
10777 (interactive "P")
10778 (if (and (null n) (and transient-mark-mode mark-active))
10779 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10780 (setq n (prefix-numeric-value n))
10781 (let ((backward (< n 0))
10782 (n (abs n)))
10783 (while (and
10784 (> n 0)
10785 (if unmark
10786 (gnus-summary-remove-process-mark
10787 (gnus-summary-article-number))
10788 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10789 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10790 (setq n (1- n)))
10791 (when (/= 0 n)
10792 (gnus-message 7 "No more articles"))
10793 (gnus-summary-recenter)
10794 (gnus-summary-position-point)
10795 n)))
10797 (defun gnus-summary-unmark-as-processable (n)
10798 "Remove the process mark from the next N articles.
10799 If N is negative, unmark backward instead. The difference between N and
10800 the actual number of articles unmarked is returned."
10801 (interactive "P")
10802 (gnus-summary-mark-as-processable n t))
10804 (defun gnus-summary-unmark-all-processable ()
10805 "Remove the process mark from all articles."
10806 (interactive)
10807 (save-excursion
10808 (while gnus-newsgroup-processable
10809 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10810 (gnus-summary-position-point))
10812 (defun gnus-summary-add-mark (article type)
10813 "Mark ARTICLE with a mark of TYPE."
10814 (let ((vtype (car (assq type gnus-article-mark-lists)))
10815 var)
10816 (if (not vtype)
10817 (error "No such mark type: %s" type)
10818 (setq var (intern (format "gnus-newsgroup-%s" type)))
10819 (set var (cons article (symbol-value var)))
10820 (if (memq type '(processable cached replied forwarded recent saved))
10821 (gnus-summary-update-secondary-mark article)
10822 ;;; !!! This is bogus. We should find out what primary
10823 ;;; !!! mark we want to set.
10824 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10826 (defun gnus-summary-mark-as-expirable (n)
10827 "Mark N articles forward as expirable.
10828 If N is negative, mark backward instead. The difference between N and
10829 the actual number of articles marked is returned."
10830 (interactive "p")
10831 (gnus-summary-mark-forward n gnus-expirable-mark))
10833 (defun gnus-summary-mark-as-spam (n)
10834 "Mark N articles forward as spam.
10835 If N is negative, mark backward instead. The difference between N and
10836 the actual number of articles marked is returned."
10837 (interactive "p")
10838 (gnus-summary-mark-forward n gnus-spam-mark))
10840 (defun gnus-summary-mark-article-as-replied (article)
10841 "Mark ARTICLE as replied to and update the summary line.
10842 ARTICLE can also be a list of articles."
10843 (interactive (list (gnus-summary-article-number)))
10844 (let ((articles (if (listp article) article (list article))))
10845 (dolist (article articles)
10846 (unless (numberp article)
10847 (error "%s is not a number" article))
10848 (push article gnus-newsgroup-replied)
10849 (let ((inhibit-read-only t))
10850 (when (gnus-summary-goto-subject article nil t)
10851 (gnus-summary-update-secondary-mark article))))))
10853 (defun gnus-summary-mark-article-as-forwarded (article)
10854 "Mark ARTICLE as forwarded and update the summary line.
10855 ARTICLE can also be a list of articles."
10856 (let ((articles (if (listp article) article (list article))))
10857 (dolist (article articles)
10858 (push article gnus-newsgroup-forwarded)
10859 (let ((inhibit-read-only t))
10860 (when (gnus-summary-goto-subject article nil t)
10861 (gnus-summary-update-secondary-mark article))))))
10863 (defun gnus-summary-set-bookmark (article)
10864 "Set a bookmark in current article."
10865 (interactive (list (gnus-summary-article-number)))
10866 (when (or (not (get-buffer gnus-article-buffer))
10867 (not gnus-current-article)
10868 (not gnus-article-current)
10869 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10870 (error "No current article selected"))
10871 ;; Remove old bookmark, if one exists.
10872 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10873 ;; Set the new bookmark, which is on the form
10874 ;; (article-number . line-number-in-body).
10875 (push
10876 (cons article
10877 (with-current-buffer gnus-article-buffer
10878 (count-lines
10879 (min (point)
10880 (save-excursion
10881 (article-goto-body)
10882 (point)))
10883 (point))))
10884 gnus-newsgroup-bookmarks)
10885 (gnus-message 6 "A bookmark has been added to the current article."))
10887 (defun gnus-summary-remove-bookmark (article)
10888 "Remove the bookmark from the current article."
10889 (interactive (list (gnus-summary-article-number)))
10890 ;; Remove old bookmark, if one exists.
10891 (if (not (assq article gnus-newsgroup-bookmarks))
10892 (gnus-message 6 "No bookmark in current article.")
10893 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10894 (gnus-message 6 "Removed bookmark.")))
10896 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10897 (defun gnus-summary-mark-as-dormant (n)
10898 "Mark N articles forward as dormant.
10899 If N is negative, mark backward instead. The difference between N and
10900 the actual number of articles marked is returned."
10901 (interactive "p")
10902 (gnus-summary-mark-forward n gnus-dormant-mark))
10904 (defun gnus-summary-set-process-mark (article)
10905 "Set the process mark on ARTICLE and update the summary line."
10906 (setq gnus-newsgroup-processable
10907 (cons article
10908 (delq article gnus-newsgroup-processable)))
10909 (when (gnus-summary-goto-subject article)
10910 (gnus-summary-show-thread)
10911 (gnus-summary-goto-subject article)
10912 (gnus-summary-update-secondary-mark article)))
10914 (defun gnus-summary-remove-process-mark (&rest articles)
10915 "Remove the process mark from ARTICLES and update the summary line."
10916 (dolist (article articles)
10917 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10918 (when (gnus-summary-goto-subject article)
10919 (gnus-summary-show-thread)
10920 (gnus-summary-goto-subject article)
10921 (gnus-summary-update-secondary-mark article)))
10924 (defun gnus-summary-set-saved-mark (article)
10925 "Set the process mark on ARTICLE and update the summary line."
10926 (push article gnus-newsgroup-saved)
10927 (when (gnus-summary-goto-subject article)
10928 (gnus-summary-update-secondary-mark article)))
10930 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10931 "Mark N articles as read forwards.
10932 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10933 The difference between N and the actual number of articles marked is
10934 returned.
10935 If NO-EXPIRE, auto-expiry will be inhibited."
10936 (interactive "p")
10937 (gnus-summary-show-thread)
10938 (let ((backward (< n 0))
10939 (gnus-summary-goto-unread
10940 (and gnus-summary-goto-unread
10941 (not (eq gnus-summary-goto-unread 'never))
10942 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10943 gnus-ticked-mark gnus-dormant-mark)))))
10944 (n (abs n))
10945 (mark (or mark gnus-del-mark)))
10946 (while (and (> n 0)
10947 (gnus-summary-mark-article nil mark no-expire)
10948 (zerop (gnus-summary-next-subject
10949 (if backward -1 1)
10950 (and gnus-summary-goto-unread
10951 (not (eq gnus-summary-goto-unread 'never)))
10952 t)))
10953 (setq n (1- n)))
10954 (when (/= 0 n)
10955 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10956 (gnus-summary-recenter)
10957 (gnus-summary-position-point)
10958 (gnus-set-mode-line 'summary)
10961 (defun gnus-summary-mark-article-as-read (mark)
10962 "Mark the current article quickly as read with MARK."
10963 (let ((article (gnus-summary-article-number)))
10964 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10965 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10966 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10967 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10968 (push (cons article mark) gnus-newsgroup-reads)
10969 ;; Possibly remove from cache, if that is used.
10970 (when gnus-use-cache
10971 (gnus-cache-enter-remove-article article))
10972 ;; Allow the backend to change the mark.
10973 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10974 ;; Check for auto-expiry.
10975 (when (and gnus-newsgroup-auto-expire
10976 (memq mark gnus-auto-expirable-marks))
10977 (setq mark gnus-expirable-mark)
10978 ;; Let the backend know about the mark change.
10979 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10980 (push article gnus-newsgroup-expirable))
10981 ;; Set the mark in the buffer.
10982 (gnus-summary-update-mark mark 'unread)
10985 (defun gnus-summary-mark-article-as-unread (mark)
10986 "Mark the current article quickly as unread with MARK."
10987 (let* ((article (gnus-summary-article-number))
10988 (old-mark (gnus-summary-article-mark article)))
10989 ;; Allow the backend to change the mark.
10990 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10991 (if (eq mark old-mark)
10993 (if (<= article 0)
10994 (progn
10995 (gnus-error 1 "Can't mark negative article numbers")
10996 nil)
10997 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10998 (setq gnus-newsgroup-spam-marked
10999 (delq article gnus-newsgroup-spam-marked))
11000 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11001 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11002 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11003 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11004 (cond ((= mark gnus-ticked-mark)
11005 (setq gnus-newsgroup-marked
11006 (gnus-add-to-sorted-list gnus-newsgroup-marked
11007 article)))
11008 ((= mark gnus-spam-mark)
11009 (setq gnus-newsgroup-spam-marked
11010 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11011 article)))
11012 ((= mark gnus-dormant-mark)
11013 (setq gnus-newsgroup-dormant
11014 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11015 article)))
11017 (setq gnus-newsgroup-unreads
11018 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11019 article))))
11020 (gnus-alist-pull article gnus-newsgroup-reads)
11022 ;; See whether the article is to be put in the cache.
11023 (and gnus-use-cache
11024 (vectorp (gnus-summary-article-header article))
11025 (save-excursion
11026 (gnus-cache-possibly-enter-article
11027 gnus-newsgroup-name article
11028 (= mark gnus-ticked-mark)
11029 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11031 ;; Fix the mark.
11032 (gnus-summary-update-mark mark 'unread)
11033 t))))
11035 (defun gnus-summary-mark-article (&optional article mark no-expire)
11036 "Mark ARTICLE with MARK. MARK can be any character.
11037 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11038 `??' (dormant) and `?E' (expirable).
11039 If MARK is nil, then the default character `?r' is used.
11040 If ARTICLE is nil, then the article on the current line will be
11041 marked.
11042 If NO-EXPIRE, auto-expiry will be inhibited."
11043 ;; The mark might be a string.
11044 (when (stringp mark)
11045 (setq mark (aref mark 0)))
11046 ;; If no mark is given, then we check auto-expiring.
11047 (when (null mark)
11048 (setq mark gnus-del-mark))
11049 (when (and (not no-expire)
11050 gnus-newsgroup-auto-expire
11051 (memq mark gnus-auto-expirable-marks))
11052 (setq mark gnus-expirable-mark))
11053 (let ((article (or article (gnus-summary-article-number)))
11054 (old-mark (gnus-summary-article-mark article)))
11055 ;; Allow the backend to change the mark.
11056 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11057 (if (eq mark old-mark)
11059 (unless article
11060 (error "No article on current line"))
11061 (if (not (if (or (= mark gnus-unread-mark)
11062 (= mark gnus-ticked-mark)
11063 (= mark gnus-spam-mark)
11064 (= mark gnus-dormant-mark))
11065 (gnus-mark-article-as-unread article mark)
11066 (gnus-mark-article-as-read article mark)))
11068 ;; See whether the article is to be put in the cache.
11069 (and gnus-use-cache
11070 (not (= mark gnus-canceled-mark))
11071 (vectorp (gnus-summary-article-header article))
11072 (save-excursion
11073 (gnus-cache-possibly-enter-article
11074 gnus-newsgroup-name article
11075 (= mark gnus-ticked-mark)
11076 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11078 (when (gnus-summary-goto-subject article nil t)
11079 (let ((inhibit-read-only t))
11080 (gnus-summary-show-thread)
11081 ;; Fix the mark.
11082 (gnus-summary-update-mark mark 'unread)
11083 t))))))
11085 (defun gnus-summary-update-secondary-mark (article)
11086 "Update the secondary (read, process, cache) mark."
11087 (gnus-summary-update-mark
11088 (cond ((memq article gnus-newsgroup-processable)
11089 gnus-process-mark)
11090 ((memq article gnus-newsgroup-cached)
11091 gnus-cached-mark)
11092 ((memq article gnus-newsgroup-replied)
11093 gnus-replied-mark)
11094 ((memq article gnus-newsgroup-forwarded)
11095 gnus-forwarded-mark)
11096 ((memq article gnus-newsgroup-saved)
11097 gnus-saved-mark)
11098 ((memq article gnus-newsgroup-unseen)
11099 gnus-unseen-mark)
11100 (t gnus-no-mark))
11101 'replied)
11102 (when (gnus-visual-p 'summary-highlight 'highlight)
11103 (gnus-summary-highlight-line)
11104 (gnus-run-hooks 'gnus-summary-update-hook))
11107 (defun gnus-summary-update-download-mark (article)
11108 "Update the download mark."
11109 (gnus-summary-update-mark
11110 (cond ((memq article gnus-newsgroup-undownloaded)
11111 gnus-undownloaded-mark)
11112 (gnus-newsgroup-agentized
11113 gnus-downloaded-mark)
11115 gnus-no-mark))
11116 'download)
11117 (gnus-summary-update-line t)
11120 (defun gnus-summary-update-mark (mark type)
11121 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11122 (inhibit-read-only t))
11123 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11124 (when forward
11125 (when (looking-at "\r")
11126 (incf forward))
11127 (when (<= (+ forward (point)) (point-max))
11128 ;; Go to the right position on the line.
11129 (goto-char (+ forward (point)))
11130 ;; Replace the old mark with the new mark.
11131 (let ((to-insert
11132 (subst-char-in-string
11133 (char-after) mark
11134 (buffer-substring (point) (1+ (point))))))
11135 (delete-region (point) (1+ (point)))
11136 (insert to-insert))
11137 ;; Optionally update the marks by some user rule.
11138 (when (eq type 'unread)
11139 (gnus-data-set-mark
11140 (gnus-data-find (gnus-summary-article-number)) mark)
11141 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11143 (defun gnus-mark-article-as-read (article &optional mark)
11144 "Enter ARTICLE in the pertinent lists and remove it from others."
11145 ;; Make the article expirable.
11146 (let ((mark (or mark gnus-del-mark)))
11147 (setq gnus-newsgroup-expirable
11148 (if (= mark gnus-expirable-mark)
11149 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11150 (delq article gnus-newsgroup-expirable)))
11151 ;; Remove from unread and marked lists.
11152 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11153 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11154 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11155 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11156 (push (cons article mark) gnus-newsgroup-reads)
11157 ;; Possibly remove from cache, if that is used.
11158 (when gnus-use-cache
11159 (gnus-cache-enter-remove-article article))
11162 (defun gnus-mark-article-as-unread (article &optional mark)
11163 "Enter ARTICLE in the pertinent lists and remove it from others."
11164 (let ((mark (or mark gnus-ticked-mark)))
11165 (if (<= article 0)
11166 (progn
11167 (gnus-error 1 "Can't mark negative article numbers")
11168 nil)
11169 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11170 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11171 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11172 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11173 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11175 ;; Unsuppress duplicates?
11176 (when gnus-suppress-duplicates
11177 (gnus-dup-unsuppress-article article))
11179 (cond ((= mark gnus-ticked-mark)
11180 (setq gnus-newsgroup-marked
11181 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11182 ((= mark gnus-spam-mark)
11183 (setq gnus-newsgroup-spam-marked
11184 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11185 article)))
11186 ((= mark gnus-dormant-mark)
11187 (setq gnus-newsgroup-dormant
11188 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11190 (setq gnus-newsgroup-unreads
11191 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11192 (gnus-alist-pull article gnus-newsgroup-reads)
11193 t)))
11195 (defun gnus-summary-tick-article-forward (n)
11196 "Tick N articles forwards.
11197 If N is negative, tick backwards instead.
11198 The difference between N and the number of articles ticked is returned."
11199 (interactive "p")
11200 (gnus-summary-mark-forward n gnus-ticked-mark))
11202 (defun gnus-summary-tick-article-backward (n)
11203 "Tick N articles backwards.
11204 The difference between N and the number of articles ticked is returned."
11205 (interactive "p")
11206 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11208 (defun gnus-summary-tick-article (&optional article clear-mark)
11209 "Mark current article as unread.
11210 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11211 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11212 (interactive)
11213 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11214 gnus-ticked-mark)))
11216 (defun gnus-summary-mark-as-read-forward (n)
11217 "Mark N articles as read forwards.
11218 If N is negative, mark backwards instead.
11219 The difference between N and the actual number of articles marked is
11220 returned."
11221 (interactive "p")
11222 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11224 (defun gnus-summary-mark-as-read-backward (n)
11225 "Mark the N articles as read backwards.
11226 The difference between N and the actual number of articles marked is
11227 returned."
11228 (interactive "p")
11229 (gnus-summary-mark-forward
11230 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11232 (defun gnus-summary-mark-as-read (&optional article mark)
11233 "Mark current article as read.
11234 ARTICLE specifies the article to be marked as read.
11235 MARK specifies a string to be inserted at the beginning of the line."
11236 (gnus-summary-mark-article article mark))
11238 (defun gnus-summary-clear-mark-forward (n)
11239 "Clear marks from N articles forward.
11240 If N is negative, clear backward instead.
11241 The difference between N and the number of marks cleared is returned."
11242 (interactive "p")
11243 (gnus-summary-mark-forward n gnus-unread-mark))
11245 (defun gnus-summary-clear-mark-backward (n)
11246 "Clear marks from N articles backward.
11247 The difference between N and the number of marks cleared is returned."
11248 (interactive "p")
11249 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11251 (defun gnus-summary-mark-unread-as-read ()
11252 "Intended to be used by `gnus-mark-article-hook'."
11253 (when (memq gnus-current-article gnus-newsgroup-unreads)
11254 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11256 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11257 "Intended to be used by `gnus-mark-article-hook'."
11258 (let ((mark (gnus-summary-article-mark)))
11259 (when (or (gnus-unread-mark-p mark)
11260 (gnus-read-mark-p mark))
11261 (gnus-summary-mark-article gnus-current-article
11262 (or new-mark gnus-read-mark)))))
11264 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11265 "Intended to be used by `gnus-mark-article-hook'."
11266 (let ((mark (gnus-summary-article-mark)))
11267 (when (or (gnus-unread-mark-p mark)
11268 (gnus-read-mark-p mark))
11269 (gnus-summary-mark-article (gnus-summary-article-number)
11270 (or new-mark gnus-read-mark)))))
11272 (defun gnus-summary-mark-unread-as-ticked ()
11273 "Intended to be used by `gnus-mark-article-hook'."
11274 (when (memq gnus-current-article gnus-newsgroup-unreads)
11275 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11277 (defun gnus-summary-mark-region-as-read (point mark all)
11278 "Mark all unread articles between point and mark as read.
11279 If given a prefix, mark all articles between point and mark as read,
11280 even ticked and dormant ones."
11281 (interactive "r\nP")
11282 (save-excursion
11283 (let (article)
11284 (goto-char point)
11285 (beginning-of-line)
11286 (while (and
11287 (< (point) mark)
11288 (progn
11289 (when (or all
11290 (memq (setq article (gnus-summary-article-number))
11291 gnus-newsgroup-unreads))
11292 (gnus-summary-mark-article article gnus-del-mark))
11294 (gnus-summary-find-next))))))
11296 (defun gnus-summary-mark-below (score mark)
11297 "Mark articles with score less than SCORE with MARK."
11298 (interactive "P\ncMark: ")
11299 (setq score (if score
11300 (prefix-numeric-value score)
11301 (or gnus-summary-default-score 0)))
11302 (with-current-buffer gnus-summary-buffer
11303 (goto-char (point-min))
11304 (while
11305 (progn
11306 (and (< (gnus-summary-article-score) score)
11307 (gnus-summary-mark-article nil mark))
11308 (gnus-summary-find-next)))))
11310 (defun gnus-summary-kill-below (&optional score)
11311 "Mark articles with score below SCORE as read."
11312 (interactive "P")
11313 (gnus-summary-mark-below score gnus-killed-mark))
11315 (defun gnus-summary-clear-above (&optional score)
11316 "Clear all marks from articles with score above SCORE."
11317 (interactive "P")
11318 (gnus-summary-mark-above score gnus-unread-mark))
11320 (defun gnus-summary-tick-above (&optional score)
11321 "Tick all articles with score above SCORE."
11322 (interactive "P")
11323 (gnus-summary-mark-above score gnus-ticked-mark))
11325 (defun gnus-summary-mark-above (score mark)
11326 "Mark articles with score over SCORE with MARK."
11327 (interactive "P\ncMark: ")
11328 (setq score (if score
11329 (prefix-numeric-value score)
11330 (or gnus-summary-default-score 0)))
11331 (with-current-buffer gnus-summary-buffer
11332 (goto-char (point-min))
11333 (while (and (progn
11334 (when (> (gnus-summary-article-score) score)
11335 (gnus-summary-mark-article nil mark))
11337 (gnus-summary-find-next)))))
11339 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11340 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11341 (defun gnus-summary-limit-include-expunged (&optional no-error)
11342 "Display all the hidden articles that were expunged for low scores."
11343 (interactive)
11344 (let ((inhibit-read-only t))
11345 (let ((scored gnus-newsgroup-scored)
11346 headers h)
11347 (while scored
11348 (unless (gnus-summary-article-header (caar scored))
11349 (and (setq h (gnus-number-to-header (caar scored)))
11350 (< (cdar scored) gnus-summary-expunge-below)
11351 (push h headers)))
11352 (setq scored (cdr scored)))
11353 (if (not headers)
11354 (when (not no-error)
11355 (error "No expunged articles hidden"))
11356 (goto-char (point-min))
11357 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11358 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11359 (dolist (x headers)
11360 (push (mail-header-number x) gnus-newsgroup-limit))
11361 (gnus-summary-prepare-unthreaded (nreverse headers))
11362 (goto-char (point-min))
11363 (gnus-summary-position-point)
11364 t))))
11366 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11367 "Mark all unread articles in this newsgroup as read.
11368 If prefix argument ALL is non-nil, ticked and dormant articles will
11369 also be marked as read.
11370 If QUIETLY is non-nil, no questions will be asked.
11372 If TO-HERE is non-nil, it should be a point in the buffer. All
11373 articles before (after, if REVERSE is set) this point will be marked
11374 as read.
11376 Note that this function will only catch up the unread article
11377 in the current summary buffer limitation.
11379 The number of articles marked as read is returned."
11380 (interactive "P")
11381 (prog1
11382 (save-excursion
11383 (when (or quietly
11384 (not gnus-interactive-catchup) ;Without confirmation?
11385 gnus-expert-user
11386 (gnus-y-or-n-p
11387 (if all
11388 "Mark absolutely all articles as read? "
11389 "Mark all unread articles as read? ")))
11390 (if (and not-mark
11391 (not gnus-newsgroup-adaptive)
11392 (not gnus-newsgroup-auto-expire)
11393 (not gnus-suppress-duplicates)
11394 (or (not gnus-use-cache)
11395 (eq gnus-use-cache 'passive)))
11396 (progn
11397 (when all
11398 (setq gnus-newsgroup-marked nil
11399 gnus-newsgroup-spam-marked nil
11400 gnus-newsgroup-dormant nil))
11401 (setq gnus-newsgroup-unreads
11402 (gnus-sorted-nunion
11403 (gnus-sorted-intersection gnus-newsgroup-unreads
11404 gnus-newsgroup-downloadable)
11405 (gnus-sorted-difference gnus-newsgroup-unfetched
11406 gnus-newsgroup-cached))))
11407 ;; We actually mark all articles as canceled, which we
11408 ;; have to do when using auto-expiry or adaptive scoring.
11409 (gnus-summary-show-all-threads)
11410 (if (and to-here reverse)
11411 (progn
11412 (goto-char to-here)
11413 (gnus-summary-mark-current-read-and-unread-as-read
11414 gnus-catchup-mark)
11415 (while (gnus-summary-find-next (not all))
11416 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11417 (when (gnus-summary-first-subject (not all))
11418 (while (and
11419 (if to-here (< (point) to-here) t)
11420 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11421 (gnus-summary-find-next (not all))))))
11422 (gnus-set-mode-line 'summary))
11424 (gnus-summary-position-point)))
11426 (defun gnus-summary-catchup-to-here (&optional all)
11427 "Mark all unticked articles before the current one as read.
11428 If ALL is non-nil, also mark ticked and dormant articles as read."
11429 (interactive "P")
11430 (save-excursion
11431 (gnus-save-hidden-threads
11432 (let ((beg (point)))
11433 ;; We check that there are unread articles.
11434 (when (or all (gnus-summary-find-prev))
11435 (gnus-summary-catchup all t beg)))))
11436 (gnus-summary-position-point))
11438 (defun gnus-summary-catchup-from-here (&optional all)
11439 "Mark all unticked articles after (and including) the current one as read.
11440 If ALL is non-nil, also mark ticked and dormant articles as read."
11441 (interactive "P")
11442 (save-excursion
11443 (gnus-save-hidden-threads
11444 (let ((beg (point)))
11445 ;; We check that there are unread articles.
11446 (when (or all (gnus-summary-find-next))
11447 (gnus-summary-catchup all t beg nil t)))))
11448 (gnus-summary-position-point))
11450 (defun gnus-summary-catchup-all (&optional quietly)
11451 "Mark all articles in this newsgroup as read.
11452 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11453 instead, which marks only unread articles as read."
11454 (interactive "P")
11455 (gnus-summary-catchup t quietly))
11457 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11458 "Mark all unread articles in this group as read, then exit.
11459 If prefix argument ALL is non-nil, all articles are marked as read.
11460 If QUIETLY is non-nil, no questions will be asked."
11461 (interactive "P")
11462 (when (gnus-summary-catchup all quietly nil 'fast)
11463 ;; Select next newsgroup or exit.
11464 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11465 (eq gnus-auto-select-next 'quietly))
11466 (gnus-summary-next-group nil)
11467 (gnus-summary-exit))))
11469 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11470 "Mark all articles in this newsgroup as read, and then exit.
11471 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11472 instead, which marks only unread articles as read."
11473 (interactive "P")
11474 (gnus-summary-catchup-and-exit t quietly))
11476 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11477 "Mark all articles in this group as read and select the next group.
11478 If given a prefix, mark all articles, unread as well as ticked, as
11479 read."
11480 (interactive "P")
11481 (save-excursion
11482 (gnus-summary-catchup all))
11483 (gnus-summary-next-group))
11485 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11486 "Mark all articles in this group as read and select the previous group.
11487 If given a prefix, mark all articles, unread as well as ticked, as
11488 read."
11489 (interactive "P")
11490 (save-excursion
11491 (gnus-summary-catchup all))
11492 (gnus-summary-next-group nil nil t))
11495 ;;; with article
11498 (defmacro gnus-with-article (article &rest forms)
11499 "Select ARTICLE and perform FORMS in the original article buffer.
11500 Then replace the article with the result."
11501 `(progn
11502 ;; We don't want the article to be marked as read.
11503 (let (gnus-mark-article-hook)
11504 (gnus-summary-select-article t t nil ,article))
11505 (set-buffer gnus-original-article-buffer)
11506 ,@forms
11507 (if (not (gnus-check-backend-function
11508 'request-replace-article (car gnus-article-current)))
11509 (gnus-message 5 "Read-only group; not replacing")
11510 (unless (gnus-request-replace-article
11511 ,article (car gnus-article-current)
11512 (current-buffer) t)
11513 (error "Couldn't replace article")))
11514 ;; The cache and backlog have to be flushed somewhat.
11515 (when gnus-keep-backlog
11516 (gnus-backlog-remove-article
11517 (car gnus-article-current) (cdr gnus-article-current)))
11518 (when gnus-use-cache
11519 (gnus-cache-update-article
11520 (car gnus-article-current) (cdr gnus-article-current)))))
11522 (put 'gnus-with-article 'lisp-indent-function 1)
11523 (put 'gnus-with-article 'edebug-form-spec '(form body))
11525 ;; Thread-based commands.
11527 (defun gnus-summary-articles-in-thread (&optional article)
11528 "Return a list of all articles in the current thread.
11529 If ARTICLE is non-nil, return all articles in the thread that starts
11530 with that article."
11531 (let* ((article (or article (gnus-summary-article-number)))
11532 (data (gnus-data-find-list article))
11533 (top-level (gnus-data-level (car data)))
11534 (top-subject
11535 (cond ((null gnus-thread-operation-ignore-subject)
11536 (gnus-simplify-subject-re
11537 (mail-header-subject (gnus-data-header (car data)))))
11538 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11539 (gnus-simplify-subject-fuzzy
11540 (mail-header-subject (gnus-data-header (car data)))))
11541 (t nil)))
11542 (end-point (save-excursion
11543 (goto-char (gnus-data-pos (car data)))
11544 (if (gnus-summary-go-to-next-thread)
11545 (point) (point-max))))
11546 articles)
11547 (while (and data
11548 (< (gnus-data-pos (car data)) end-point))
11549 (when (or (not top-subject)
11550 (string= top-subject
11551 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11552 (gnus-simplify-subject-fuzzy
11553 (mail-header-subject
11554 (gnus-data-header (car data))))
11555 (gnus-simplify-subject-re
11556 (mail-header-subject
11557 (gnus-data-header (car data)))))))
11558 (push (gnus-data-number (car data)) articles))
11559 (unless (and (setq data (cdr data))
11560 (> (gnus-data-level (car data)) top-level))
11561 (setq data nil)))
11562 ;; Return the list of articles.
11563 (nreverse articles)))
11565 (defun gnus-summary-rethread-current ()
11566 "Rethread the thread the current article is part of."
11567 (interactive)
11568 (let* ((gnus-show-threads t)
11569 (article (gnus-summary-article-number))
11570 (id (mail-header-id (gnus-summary-article-header)))
11571 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11572 (unless id
11573 (error "No article on the current line"))
11574 (gnus-rebuild-thread id)
11575 (gnus-summary-goto-subject article)))
11577 (defun gnus-summary-reparent-thread ()
11578 "Make the current article child of the marked (or previous) article.
11580 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11581 is non-nil or the Subject: of both articles are the same."
11582 (interactive)
11583 (unless (not (gnus-group-read-only-p))
11584 (error "The current newsgroup does not support article editing"))
11585 (unless (<= (length gnus-newsgroup-processable) 1)
11586 (error "No more than one article may be marked"))
11587 (let ((child (gnus-summary-article-number))
11588 ;; First grab the marked article, otherwise one line up.
11589 (parent (if (not (null gnus-newsgroup-processable))
11590 (car gnus-newsgroup-processable)
11591 (save-excursion
11592 (if (eq (forward-line -1) 0)
11593 (gnus-summary-article-number)
11594 (error "Beginning of summary buffer"))))))
11595 (gnus-summary-reparent-children parent (list child))))
11597 (defun gnus-summary-reparent-children (parent children)
11598 "Make PARENT the parent of CHILDREN.
11599 When called interactively, PARENT is the current article and CHILDREN
11600 are the process-marked articles."
11601 (interactive
11602 (list (gnus-summary-article-number)
11603 (gnus-summary-work-articles nil)))
11604 (dolist (child children)
11605 (save-window-excursion
11606 (let ((gnus-article-buffer " *reparent*"))
11607 (unless (not (eq parent child))
11608 (error "An article may not be self-referential"))
11609 (let ((message-id (mail-header-id
11610 (gnus-summary-article-header parent))))
11611 (unless (and message-id (not (equal message-id "")))
11612 (error "No message-id in desired parent"))
11613 (gnus-with-article child
11614 (save-restriction
11615 (goto-char (point-min))
11616 (message-narrow-to-head)
11617 (if (re-search-forward "^References: " nil t)
11618 (progn
11619 (re-search-forward "^[^ \t]" nil t)
11620 (forward-line -1)
11621 (end-of-line)
11622 (insert " " message-id))
11623 (insert "References: " message-id "\n"))))
11624 (set-buffer gnus-summary-buffer)
11625 (gnus-summary-unmark-all-processable)
11626 (gnus-summary-update-article child)
11627 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11628 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11629 (gnus-summary-rethread-current)
11630 (gnus-message 3 "Article %d is now the child of article %d"
11631 child parent))))))
11633 (defun gnus-summary-toggle-threads (&optional arg)
11634 "Toggle showing conversation threads.
11635 If ARG is positive number, turn showing conversation threads on."
11636 (interactive "P")
11637 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11638 (setq gnus-show-threads
11639 (if (null arg) (not gnus-show-threads)
11640 (> (prefix-numeric-value arg) 0)))
11641 (gnus-summary-prepare)
11642 (gnus-summary-goto-subject current)
11643 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11644 (gnus-summary-position-point)))
11646 (defun gnus-summary-show-all-threads ()
11647 "Show all threads."
11648 (interactive)
11649 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11650 (gnus-summary-position-point))
11652 (defsubst gnus-summary--inv (p)
11653 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11655 (defun gnus-summary-show-thread ()
11656 "Show thread subtrees.
11657 Returns nil if no thread was there to be shown."
11658 (interactive)
11659 (let* ((orig (point))
11660 (end (point-at-eol))
11661 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11662 ;; Leave point at bol
11663 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11664 (eoi (and end (next-single-char-property-change end 'invisible))))
11665 (when eoi
11666 (remove-overlays beg eoi 'invisible 'gnus-sum)
11667 (goto-char orig)
11668 (gnus-summary-position-point)
11669 eoi)))
11671 (defun gnus-summary-maybe-hide-threads ()
11672 "If requested, hide the threads that should be hidden."
11673 (when (and gnus-show-threads
11674 gnus-thread-hide-subtree)
11675 (gnus-summary-hide-all-threads
11676 (if (or (consp gnus-thread-hide-subtree)
11677 (functionp gnus-thread-hide-subtree))
11678 (gnus-make-predicate gnus-thread-hide-subtree)
11679 nil))))
11681 ;;; Hiding predicates.
11683 (defun gnus-article-unread-p (header)
11684 (memq (mail-header-number header) gnus-newsgroup-unreads))
11686 (defun gnus-article-unseen-p (header)
11687 (memq (mail-header-number header) gnus-newsgroup-unseen))
11689 (defun gnus-map-articles (predicate articles)
11690 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11691 (apply 'gnus-or (mapcar predicate
11692 (mapcar (lambda (number)
11693 (gnus-summary-article-header number))
11694 articles))))
11696 (defun gnus-summary-hide-all-threads (&optional predicate)
11697 "Hide all thread subtrees.
11698 If PREDICATE is supplied, threads that satisfy this predicate
11699 will not be hidden."
11700 (interactive)
11701 (save-excursion
11702 (goto-char (point-min))
11703 (let ((end nil)
11704 (count 0))
11705 (while (not end)
11706 (incf count)
11707 (when (zerop (mod count 1000))
11708 (message "Hiding all threads... %d" count))
11709 (when (or (not predicate)
11710 (gnus-map-articles
11711 predicate (gnus-summary-article-children)))
11712 (gnus-summary-hide-thread))
11713 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11714 (gnus-summary-position-point))
11716 (defun gnus-summary-hide-thread ()
11717 "Hide thread subtrees.
11718 If PREDICATE is supplied, threads that satisfy this predicate
11719 will not be hidden.
11720 Returns nil if no threads were there to be hidden."
11721 (interactive)
11722 (beginning-of-line)
11723 (let ((start (point))
11724 (starteol (line-end-position))
11725 (article (gnus-summary-article-number)))
11726 ;; Go forward until either the buffer ends or the subthread ends.
11727 (when (and (not (eobp))
11728 (or (zerop (gnus-summary-next-thread 1 t))
11729 (goto-char (point-max))))
11730 (if (and (> (point) start)
11731 ;; FIXME: this should actually search for a non-invisible \n.
11732 (search-backward "\n" start t))
11733 (progn
11734 (when (> (point) starteol)
11735 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11736 (let ((ol (make-overlay starteol (point) nil t nil)))
11737 (overlay-put ol 'invisible 'gnus-sum)
11738 (overlay-put ol 'evaporate t)))
11739 (gnus-summary-goto-subject article)
11740 (when (> start (point))
11741 (message "Hiding the thread moved us backwards, aborting!")
11742 (goto-char (point-max))))
11743 (goto-char start)
11744 nil))))
11746 (defun gnus-summary-go-to-next-thread (&optional previous)
11747 "Go to the same level (or less) next thread.
11748 If PREVIOUS is non-nil, go to previous thread instead.
11749 Return the article number moved to, or nil if moving was impossible."
11750 (let ((level (gnus-summary-thread-level))
11751 (way (if previous -1 1))
11752 (beg (point)))
11753 (forward-line way)
11754 (while (and (not (eobp))
11755 (< level (gnus-summary-thread-level)))
11756 (forward-line way))
11757 (if (eobp)
11758 (progn
11759 (goto-char beg)
11760 nil)
11761 (setq beg (point))
11762 (prog1
11763 (gnus-summary-article-number)
11764 (goto-char beg)))))
11766 (defun gnus-summary-next-thread (n &optional silent)
11767 "Go to the same level next N'th thread.
11768 If N is negative, search backward instead.
11769 Returns the difference between N and the number of skips actually
11770 done.
11772 If SILENT, don't output messages."
11773 (interactive "p")
11774 (let ((backward (< n 0))
11775 (n (abs n)))
11776 (while (and (> n 0)
11777 (gnus-summary-go-to-next-thread backward))
11778 (decf n))
11779 (unless silent
11780 (gnus-summary-position-point))
11781 (when (and (not silent) (/= 0 n))
11782 (gnus-message 7 "No more threads"))
11785 (defun gnus-summary-prev-thread (n)
11786 "Go to the same level previous N'th thread.
11787 Returns the difference between N and the number of skips actually
11788 done."
11789 (interactive "p")
11790 (gnus-summary-next-thread (- n)))
11792 (defun gnus-summary-go-down-thread ()
11793 "Go down one level in the current thread."
11794 (let ((children (gnus-summary-article-children)))
11795 (when children
11796 (gnus-summary-goto-subject (car children)))))
11798 (defun gnus-summary-go-up-thread ()
11799 "Go up one level in the current thread."
11800 (let ((parent (gnus-summary-article-parent)))
11801 (when parent
11802 (gnus-summary-goto-subject parent))))
11804 (defun gnus-summary-down-thread (n)
11805 "Go down thread N steps.
11806 If N is negative, go up instead.
11807 Returns the difference between N and how many steps down that were
11808 taken."
11809 (interactive "p")
11810 (let ((up (< n 0))
11811 (n (abs n)))
11812 (while (and (> n 0)
11813 (if up (gnus-summary-go-up-thread)
11814 (gnus-summary-go-down-thread)))
11815 (setq n (1- n)))
11816 (gnus-summary-position-point)
11817 (when (/= 0 n)
11818 (gnus-message 7 "Can't go further"))
11821 (defun gnus-summary-up-thread (n)
11822 "Go up thread N steps.
11823 If N is negative, go down instead.
11824 Returns the difference between N and how many steps down that were
11825 taken."
11826 (interactive "p")
11827 (gnus-summary-down-thread (- n)))
11829 (defun gnus-summary-top-thread ()
11830 "Go to the top of the thread."
11831 (interactive)
11832 (while (gnus-summary-go-up-thread))
11833 (gnus-summary-article-number))
11835 (defun gnus-summary-expire-thread ()
11836 "Mark articles under current thread as expired."
11837 (interactive)
11838 (gnus-summary-kill-thread 0))
11840 (defun gnus-summary-kill-thread (&optional unmark)
11841 "Mark articles under current thread as read.
11842 If the prefix argument is positive, remove any kinds of marks.
11843 If the prefix argument is zero, mark thread as expired.
11844 If the prefix argument is negative, tick articles instead."
11845 (interactive "P")
11846 (when unmark
11847 (setq unmark (prefix-numeric-value unmark)))
11848 (let ((articles (gnus-summary-articles-in-thread))
11849 (hide (or (null unmark) (= unmark 0))))
11850 (save-excursion
11851 ;; Expand the thread.
11852 (gnus-summary-show-thread)
11853 ;; Mark all the articles.
11854 (while articles
11855 (gnus-summary-goto-subject (car articles))
11856 (cond ((null unmark)
11857 (gnus-summary-mark-article-as-read gnus-killed-mark))
11858 ((> unmark 0)
11859 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11860 ((= unmark 0)
11861 (gnus-summary-mark-article nil gnus-expirable-mark))
11863 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11864 (setq articles (cdr articles))))
11865 ;; Hide killed subtrees when hide is true.
11866 (and hide
11867 gnus-thread-hide-killed
11868 (gnus-summary-hide-thread))
11869 ;; If hide is t, go to next unread subject.
11870 (when hide
11871 ;; Go to next unread subject.
11872 (gnus-summary-next-subject 1 t)))
11873 (gnus-set-mode-line 'summary))
11875 ;; Summary sorting commands
11877 (defun gnus-summary-sort-by-number (&optional reverse)
11878 "Sort the summary buffer by article number.
11879 Argument REVERSE means reverse order."
11880 (interactive "P")
11881 (gnus-summary-sort 'number reverse))
11883 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11884 "Sort the summary buffer by most recent article number.
11885 Argument REVERSE means reverse order."
11886 (interactive "P")
11887 (gnus-summary-sort 'most-recent-number reverse))
11889 (defun gnus-summary-sort-by-random (&optional reverse)
11890 "Randomize the order in the summary buffer.
11891 Argument REVERSE means to randomize in reverse order."
11892 (interactive "P")
11893 (gnus-summary-sort 'random reverse))
11895 (defun gnus-summary-sort-by-author (&optional reverse)
11896 "Sort the summary buffer by author name alphabetically.
11897 If `case-fold-search' is non-nil, case of letters is ignored.
11898 Argument REVERSE means reverse order."
11899 (interactive "P")
11900 (gnus-summary-sort 'author reverse))
11902 (defun gnus-summary-sort-by-recipient (&optional reverse)
11903 "Sort the summary buffer by recipient name alphabetically.
11904 If `case-fold-search' is non-nil, case of letters is ignored.
11905 Argument REVERSE means reverse order."
11906 (interactive "P")
11907 (gnus-summary-sort 'recipient reverse))
11909 (defun gnus-summary-sort-by-subject (&optional reverse)
11910 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11911 If `case-fold-search' is non-nil, case of letters is ignored.
11912 Argument REVERSE means reverse order."
11913 (interactive "P")
11914 (gnus-summary-sort 'subject reverse))
11916 (defun gnus-summary-sort-by-date (&optional reverse)
11917 "Sort the summary buffer by date.
11918 Argument REVERSE means reverse order."
11919 (interactive "P")
11920 (gnus-summary-sort 'date reverse))
11922 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11923 "Sort the summary buffer by most recent date.
11924 Argument REVERSE means reverse order."
11925 (interactive "P")
11926 (gnus-summary-sort 'most-recent-date reverse))
11928 (defun gnus-summary-sort-by-score (&optional reverse)
11929 "Sort the summary buffer by score.
11930 Argument REVERSE means reverse order."
11931 (interactive "P")
11932 (gnus-summary-sort 'score reverse))
11934 (defun gnus-summary-sort-by-lines (&optional reverse)
11935 "Sort the summary buffer by the number of lines.
11936 Argument REVERSE means reverse order."
11937 (interactive "P")
11938 (gnus-summary-sort 'lines reverse))
11940 (defun gnus-summary-sort-by-chars (&optional reverse)
11941 "Sort the summary buffer by article length.
11942 Argument REVERSE means reverse order."
11943 (interactive "P")
11944 (gnus-summary-sort 'chars reverse))
11946 (defun gnus-summary-sort-by-mark (&optional reverse)
11947 "Sort the summary buffer by article marks.
11948 Argument REVERSE means reverse order."
11949 (interactive "P")
11950 (gnus-summary-sort 'marks reverse))
11952 (defun gnus-summary-sort-by-original (&optional reverse)
11953 "Sort the summary buffer using the default sorting method.
11954 Argument REVERSE means reverse order."
11955 (interactive "P")
11956 (let* ((inhibit-read-only t)
11957 (gnus-summary-prepare-hook nil))
11958 ;; We do the sorting by regenerating the threads.
11959 (gnus-summary-prepare)
11960 ;; Hide subthreads if needed.
11961 (gnus-summary-maybe-hide-threads)))
11963 (defun gnus-summary-sort (predicate reverse)
11964 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11965 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11966 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11967 (gnus-thread-sort-functions
11968 (if (not reverse)
11969 thread
11970 `(lambda (t1 t2)
11971 (,thread t2 t1))))
11972 (gnus-sort-gathered-threads-function
11973 gnus-thread-sort-functions)
11974 (gnus-article-sort-functions
11975 (if (not reverse)
11976 article
11977 `(lambda (t1 t2)
11978 (,article t2 t1))))
11979 (inhibit-read-only t)
11980 (gnus-summary-prepare-hook nil))
11981 ;; We do the sorting by regenerating the threads.
11982 (gnus-summary-prepare)
11983 ;; Hide subthreads if needed.
11984 (gnus-summary-maybe-hide-threads)))
11986 ;; Summary saving commands.
11988 (defun gnus-summary-save-article (&optional n not-saved)
11989 "Save the current article using the default saver function.
11990 If N is a positive number, save the N next articles.
11991 If N is a negative number, save the N previous articles.
11992 If N is nil and any articles have been marked with the process mark,
11993 save those articles instead.
11994 The variable `gnus-default-article-saver' specifies the saver function.
11996 If the optional second argument NOT-SAVED is non-nil, articles saved
11997 will not be marked as saved.
11999 The `gnus-prompt-before-saving' variable says how prompting is
12000 performed."
12001 (interactive "P")
12002 (require 'gnus-art)
12003 (let* ((articles (gnus-summary-work-articles n))
12004 (save-buffer (save-excursion
12005 (nnheader-set-temp-buffer " *Gnus Save*")))
12006 (num (length articles))
12007 ;; Whether to save decoded articles or raw articles.
12008 (decode (when gnus-article-save-coding-system
12009 (get gnus-default-article-saver :decode)))
12010 ;; When saving many articles in a single file, use the other
12011 ;; function to save articles other than the first one.
12012 (saver2 (get gnus-default-article-saver :function))
12013 (gnus-prompt-before-saving (if saver2
12015 gnus-prompt-before-saving))
12016 (gnus-default-article-saver gnus-default-article-saver)
12017 header file)
12018 (dolist (article articles)
12019 (setq header (gnus-summary-article-header article))
12020 (if (not (vectorp header))
12021 ;; This is a pseudo-article.
12022 (if (assq 'name header)
12023 (gnus-copy-file (cdr (assq 'name header)))
12024 (gnus-message 1 "Article %d is unsavable" article))
12025 ;; This is a real article.
12026 (save-window-excursion
12027 (gnus-summary-select-article decode decode nil article)
12028 (gnus-summary-goto-subject article))
12029 (with-current-buffer save-buffer
12030 (erase-buffer)
12031 (insert-buffer-substring (if decode
12032 gnus-article-buffer
12033 gnus-original-article-buffer)))
12034 (setq file (gnus-article-save save-buffer file num))
12035 (gnus-summary-remove-process-mark article)
12036 (unless not-saved
12037 (gnus-summary-set-saved-mark article)))
12038 (when saver2
12039 (setq gnus-default-article-saver saver2
12040 saver2 nil)))
12041 (gnus-kill-buffer save-buffer)
12042 (gnus-summary-position-point)
12043 (gnus-set-mode-line 'summary)
12046 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12048 (defun gnus-summary-pipe-output (&optional n sym)
12049 "Pipe the current article to a subprocess.
12050 If N is a positive number, pipe the N next articles.
12051 If N is a negative number, pipe the N previous articles.
12052 If N is nil and any articles have been marked with the process mark,
12053 pipe those articles instead.
12054 The default command to which articles are piped is specified by the
12055 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12056 will be prompted for the command.
12058 The properties `:decode' and `:headers' that are put to the function
12059 symbol `gnus-summary-save-in-pipe' control whether this function
12060 decodes articles and what headers to keep (see the doc string for the
12061 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12062 is neither omitted nor the symbol `r', force including all headers
12063 regardless of the `:headers' property. If it is the symbol `r',
12064 articles that are not decoded and include all headers will be piped
12065 no matter what the properties `:decode' and `:headers' are."
12066 (interactive (gnus-interactive "P\ny"))
12067 (require 'gnus-art)
12068 (let* ((articles (gnus-summary-work-articles n))
12069 (result-buffer "*Shell Command Output*")
12070 (all-headers (not (memq sym '(nil r))))
12071 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12072 (raw (eq sym 'r))
12073 (headers (get 'gnus-summary-save-in-pipe :headers))
12074 command result)
12075 (unless (numberp (car articles))
12076 (error "No article to pipe"))
12077 (setq command (read-shell-command
12078 (concat "Shell command on "
12079 (if (cdr articles)
12080 (format "these %d articles" (length articles))
12081 "this article")
12082 ": ")
12083 gnus-summary-pipe-output-default-command))
12084 (when (string-equal command "")
12085 (error "A command is required"))
12086 (when all-headers
12087 (put 'gnus-summary-save-in-pipe :headers nil))
12088 (unwind-protect
12089 (while articles
12090 (gnus-summary-goto-subject (pop articles))
12091 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12092 (when (and (get-buffer result-buffer)
12093 (not (zerop (buffer-size (get-buffer result-buffer)))))
12094 (setq result (concat result (with-current-buffer result-buffer
12095 (buffer-string))))))
12096 (put 'gnus-summary-save-in-pipe :headers headers))
12097 (unless (zerop (length result))
12098 (if (with-current-buffer (get-buffer-create result-buffer)
12099 (erase-buffer)
12100 (insert result)
12101 (prog1
12102 (and (= (count-lines (point-min) (point)) 1)
12103 (progn
12104 (end-of-line 0)
12105 (<= (current-column)
12106 (window-width (minibuffer-window)))))
12107 (goto-char (point-min))))
12108 (message "%s" (substring result 0 -1))
12109 (message nil)
12110 (gnus-configure-windows 'pipe)))))
12112 (defun gnus-summary-save-article-mail (&optional arg)
12113 "Append the current article to a Unix mail box file.
12114 If N is a positive number, save the N next articles.
12115 If N is a negative number, save the N previous articles.
12116 If N is nil and any articles have been marked with the process mark,
12117 save those articles instead."
12118 (interactive "P")
12119 (require 'gnus-art)
12120 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12121 (gnus-summary-save-article arg)))
12123 (defun gnus-summary-save-article-rmail (&optional arg)
12124 "Append the current article to an rmail file.
12125 If N is a positive number, save the N next articles.
12126 If N is a negative number, save the N previous articles.
12127 If N is nil and any articles have been marked with the process mark,
12128 save those articles instead."
12129 (interactive "P")
12130 (require 'gnus-art)
12131 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12132 (gnus-summary-save-article arg)))
12134 (defun gnus-summary-save-article-file (&optional arg)
12135 "Append the current article to a file.
12136 If N is a positive number, save the N next articles.
12137 If N is a negative number, save the N previous articles.
12138 If N is nil and any articles have been marked with the process mark,
12139 save those articles instead."
12140 (interactive "P")
12141 (require 'gnus-art)
12142 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12143 (gnus-summary-save-article arg)))
12145 (defun gnus-summary-write-article-file (&optional arg)
12146 "Write the current article to a file, deleting the previous file.
12147 If N is a positive number, save the N next articles.
12148 If N is a negative number, save the N previous articles.
12149 If N is nil and any articles have been marked with the process mark,
12150 save those articles instead."
12151 (interactive "P")
12152 (require 'gnus-art)
12153 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12154 (gnus-summary-save-article arg)))
12156 (defun gnus-summary-save-article-body-file (&optional arg)
12157 "Append the current article body to a file.
12158 If N is a positive number, save the N next articles.
12159 If N is a negative number, save the N previous articles.
12160 If N is nil and any articles have been marked with the process mark,
12161 save those articles instead."
12162 (interactive "P")
12163 (require 'gnus-art)
12164 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12165 (gnus-summary-save-article arg)))
12167 (defun gnus-summary-write-article-body-file (&optional arg)
12168 "Write the current article body to a file, deleting the previous file.
12169 If N is a positive number, save the N next articles.
12170 If N is a negative number, save the N previous articles.
12171 If N is nil and any articles have been marked with the process mark,
12172 save those articles instead."
12173 (interactive "P")
12174 (require 'gnus-art)
12175 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12176 (gnus-summary-save-article arg)))
12178 (defun gnus-summary-muttprint (&optional arg)
12179 "Print the current article using Muttprint.
12180 If N is a positive number, save the N next articles.
12181 If N is a negative number, save the N previous articles.
12182 If N is nil and any articles have been marked with the process mark,
12183 save those articles instead."
12184 (interactive "P")
12185 (require 'gnus-art)
12186 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12187 (gnus-summary-save-article arg t)))
12189 (defun gnus-summary-pipe-message (program)
12190 "Pipe the current article through PROGRAM."
12191 (interactive "sProgram: ")
12192 (gnus-summary-select-article)
12193 (let ((mail-header-separator ""))
12194 (gnus-eval-in-buffer-window gnus-article-buffer
12195 (save-restriction
12196 (widen)
12197 (let ((start (window-start))
12198 (inhibit-read-only t))
12199 (message-pipe-buffer-body program)
12200 (set-window-start (get-buffer-window (current-buffer)) start))))))
12202 (defun gnus-get-split-value (methods)
12203 "Return a value based on the split METHODS."
12204 (let (split-name method result match)
12205 (when methods
12206 (with-current-buffer gnus-original-article-buffer
12207 (save-restriction
12208 (nnheader-narrow-to-headers)
12209 (while (and methods (not split-name))
12210 (goto-char (point-min))
12211 (setq method (pop methods))
12212 (setq match (car method))
12213 (when (cond
12214 ((stringp match)
12215 ;; Regular expression.
12216 (ignore-errors
12217 (re-search-forward match nil t)))
12218 ((functionp match)
12219 ;; Function.
12220 (save-restriction
12221 (widen)
12222 (setq result (funcall match gnus-newsgroup-name))))
12223 ((consp match)
12224 ;; Form.
12225 (save-restriction
12226 (widen)
12227 (setq result (eval match)))))
12228 (setq split-name (cdr method))
12229 (cond ((stringp result)
12230 (push (expand-file-name
12231 result gnus-article-save-directory)
12232 split-name))
12233 ((consp result)
12234 (setq split-name (append result split-name)))))))))
12235 (nreverse split-name)))
12237 (defun gnus-valid-move-group-p (group)
12238 (and (symbolp group)
12239 (boundp group)
12240 (symbol-name group)
12241 (symbol-value group)
12242 (gnus-get-function (gnus-find-method-for-group
12243 (symbol-name group)) 'request-accept-article t)))
12245 (defun gnus-read-move-group-name (prompt default articles prefix)
12246 "Read a group name."
12247 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12248 (prom
12249 (format "%s %s to"
12250 prompt
12251 (if (> (length articles) 1)
12252 (format "these %d articles" (length articles))
12253 "this article")))
12254 (to-newsgroup
12255 (cond
12256 ((null split-name)
12257 (gnus-group-completing-read
12258 prom
12259 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12260 nil prefix nil default))
12261 ((= 1 (length split-name))
12262 (gnus-group-completing-read
12263 prom
12264 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12265 nil prefix 'gnus-group-history (car split-name)))
12267 (gnus-completing-read
12268 prom (nreverse split-name) nil nil 'gnus-group-history))))
12269 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12270 encoded)
12271 (when to-newsgroup
12272 (if (or (string= to-newsgroup "")
12273 (string= to-newsgroup prefix))
12274 (setq to-newsgroup default))
12275 (unless to-newsgroup
12276 (error "No group name entered"))
12277 (setq encoded (encode-coding-string
12278 to-newsgroup
12279 (gnus-group-name-charset to-method to-newsgroup)))
12280 (or (gnus-active encoded)
12281 (gnus-activate-group encoded nil nil to-method)
12282 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12283 to-newsgroup))
12284 (or (and (gnus-request-create-group encoded to-method)
12285 (gnus-activate-group encoded nil nil to-method)
12286 (gnus-subscribe-group encoded))
12287 (error "Couldn't create group %s" to-newsgroup)))
12288 (error "No such group: %s" to-newsgroup))
12289 encoded)))
12291 (defvar gnus-summary-save-parts-counter)
12292 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12294 (defun gnus-summary-save-parts (type dir n &optional reverse)
12295 "Save parts matching TYPE to DIR.
12296 If REVERSE, save parts that do not match TYPE."
12297 (interactive
12298 (list (read-string "Save parts of type: "
12299 (or (car gnus-summary-save-parts-type-history)
12300 gnus-summary-save-parts-default-mime)
12301 'gnus-summary-save-parts-type-history)
12302 (setq gnus-summary-save-parts-last-directory
12303 (read-directory-name "Save to directory: "
12304 gnus-summary-save-parts-last-directory
12305 nil t))
12306 current-prefix-arg))
12307 (gnus-summary-iterate n
12308 (let ((gnus-display-mime-function nil)
12309 gnus-article-prepare-hook
12310 gnus-article-decode-hook
12311 gnus-display-mime-function
12312 gnus-break-pages
12313 (gnus-inhibit-treatment t))
12314 (gnus-summary-select-article))
12315 (with-current-buffer gnus-article-buffer
12316 (let ((handles (or gnus-article-mime-handles
12317 (mm-dissect-buffer nil gnus-article-loose-mime)
12318 (and gnus-article-emulate-mime
12319 (mm-uu-dissect))))
12320 (gnus-summary-save-parts-counter 1))
12321 (when handles
12322 (gnus-summary-save-parts-1 type dir handles reverse)
12323 (unless gnus-article-mime-handles ;; Don't destroy this case.
12324 (mm-destroy-parts handles)))))))
12326 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12327 (if (stringp (car handle))
12328 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12329 (cdr handle))
12330 (when (if reverse
12331 (not (string-match type (mm-handle-media-type handle)))
12332 (string-match type (mm-handle-media-type handle)))
12333 (let ((file (expand-file-name
12334 (gnus-map-function
12335 mm-file-name-rewrite-functions
12336 (file-name-nondirectory
12338 (mm-handle-filename handle)
12339 (format "%s.%d.%d" gnus-newsgroup-name
12340 (cdr gnus-article-current)
12341 gnus-summary-save-parts-counter))))
12342 dir)))
12343 (incf gnus-summary-save-parts-counter)
12344 (unless (file-exists-p file)
12345 (mm-save-part-to-file handle file))))))
12347 ;; Summary extract commands
12349 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12350 (let ((inhibit-read-only t)
12351 (article (gnus-summary-article-number))
12352 after-article b e)
12353 (unless (gnus-summary-goto-subject article)
12354 (error "No such article: %d" article))
12355 (gnus-summary-position-point)
12356 ;; If all commands are to be bunched up on one line, we collect
12357 ;; them here.
12358 (unless gnus-view-pseudos-separately
12359 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12360 files action)
12361 (while ps
12362 (setq action (cdr (assq 'action (car ps))))
12363 (setq files (list (cdr (assq 'name (car ps)))))
12364 (while (and ps (cdr ps)
12365 (string= (or action "1")
12366 (or (cdr (assq 'action (cadr ps))) "2")))
12367 (push (cdr (assq 'name (cadr ps))) files)
12368 (setcdr ps (cddr ps)))
12369 (when files
12370 (when (not (string-match "%s" action))
12371 (push " " files))
12372 (push " " files)
12373 (when (assq 'execute (car ps))
12374 (setcdr (assq 'execute (car ps))
12375 (funcall (if (string-match "%s" action)
12376 'format 'concat)
12377 action
12378 (mapconcat
12379 (lambda (f)
12380 (if (equal f " ")
12382 (shell-quote-argument f)))
12383 files " ")))))
12384 (setq ps (cdr ps)))))
12385 (if (and gnus-view-pseudos (not not-view))
12386 (while pslist
12387 (when (assq 'execute (car pslist))
12388 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12389 (eq gnus-view-pseudos 'not-confirm)))
12390 (setq pslist (cdr pslist)))
12391 (save-excursion
12392 (while pslist
12393 (setq after-article (or (cdr (assq 'article (car pslist)))
12394 (gnus-summary-article-number)))
12395 (gnus-summary-goto-subject after-article)
12396 (forward-line 1)
12397 (setq b (point))
12398 (insert " " (file-name-nondirectory
12399 (cdr (assq 'name (car pslist))))
12400 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12401 (setq e (point))
12402 (forward-line -1) ; back to `b'
12403 (add-text-properties
12404 b (1- e) (list 'gnus-number gnus-reffed-article-number
12405 'mouse-face gnus-mouse-face))
12406 (gnus-data-enter
12407 after-article gnus-reffed-article-number
12408 gnus-unread-mark b (car pslist) 0 (- e b))
12409 (setq gnus-newsgroup-unreads
12410 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12411 gnus-reffed-article-number))
12412 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12413 (setq pslist (cdr pslist)))))))
12415 (defun gnus-pseudos< (p1 p2)
12416 (let ((c1 (cdr (assq 'action p1)))
12417 (c2 (cdr (assq 'action p2))))
12418 (and c1 c2 (string< c1 c2))))
12420 (defun gnus-request-pseudo-article (props)
12421 (cond ((assq 'execute props)
12422 (gnus-execute-command (cdr (assq 'execute props)))))
12423 (let ((gnus-current-article (gnus-summary-article-number)))
12424 (gnus-run-hooks 'gnus-mark-article-hook)))
12426 (defun gnus-execute-command (command &optional automatic)
12427 (save-excursion
12428 (gnus-article-setup-buffer)
12429 (set-buffer gnus-article-buffer)
12430 (setq buffer-read-only nil)
12431 (let ((command (if automatic command
12432 (read-string "Command: " (cons command 0)))))
12433 (erase-buffer)
12434 (insert "$ " command "\n\n")
12435 (if gnus-view-pseudo-asynchronously
12436 (start-process "gnus-execute" (current-buffer) shell-file-name
12437 shell-command-switch command)
12438 (call-process shell-file-name nil t nil
12439 shell-command-switch command)))))
12441 ;; Summary kill commands.
12443 (defun gnus-summary-edit-global-kill (article)
12444 "Edit the \"global\" kill file."
12445 (interactive (list (gnus-summary-article-number)))
12446 (gnus-group-edit-global-kill article))
12448 (defun gnus-summary-edit-local-kill ()
12449 "Edit a local kill file applied to the current newsgroup."
12450 (interactive)
12451 (setq gnus-current-headers (gnus-summary-article-header))
12452 (gnus-group-edit-local-kill
12453 (gnus-summary-article-number) gnus-newsgroup-name))
12455 ;;; Header reading.
12457 (defun gnus-read-header (id &optional header)
12458 "Read the headers of article ID and enter them into the Gnus system."
12459 (let ((group gnus-newsgroup-name)
12460 (gnus-override-method
12462 gnus-override-method
12463 (and (gnus-news-group-p gnus-newsgroup-name)
12464 (car (gnus-refer-article-methods)))))
12465 where)
12466 ;; First we check to see whether the header in question is already
12467 ;; fetched.
12468 (if (stringp id)
12469 ;; This is a Message-ID.
12470 (setq header (or header (gnus-id-to-header id)))
12471 ;; This is an article number.
12472 (setq header (or header (gnus-summary-article-header id))))
12473 (if (and header
12474 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12475 ;; We have found the header.
12476 header
12477 ;; We have to really fetch the header to this article.
12478 (with-current-buffer nntp-server-buffer
12479 (when (setq where (gnus-request-head id group))
12480 (nnheader-fold-continuation-lines)
12481 (goto-char (point-max))
12482 (insert ".\n")
12483 (goto-char (point-min))
12484 (insert "211 ")
12485 (princ (cond
12486 ((numberp id) id)
12487 ((cdr where) (cdr where))
12488 (header (mail-header-number header))
12489 (t gnus-reffed-article-number))
12490 (current-buffer))
12491 (insert " Article retrieved.\n"))
12492 (if (or (not where)
12493 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12494 () ; Malformed head.
12495 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12496 (when (and (bound-and-true-p gnus-registry-enabled)
12497 (not (gnus-ephemeral-group-p (car where))))
12498 (gnus-registry-handle-action
12499 (mail-header-id header) nil
12500 (gnus-group-prefixed-name
12501 (car where)
12502 (or gnus-override-method (gnus-find-method-for-group group)))
12503 (mail-header-subject header)
12504 (mail-header-from header)))
12505 (when (and (stringp id)
12507 (not (string= (gnus-group-real-name group)
12508 (car where)))
12509 (not (gnus-server-equal gnus-override-method
12510 (gnus-group-method group)))))
12511 ;; If we fetched by Message-ID and the article came from
12512 ;; a different group (or server), we fudge some bogus
12513 ;; article numbers for this article.
12514 (mail-header-set-number header gnus-reffed-article-number))
12515 (with-current-buffer gnus-summary-buffer
12516 (decf gnus-reffed-article-number)
12517 (gnus-remove-header (mail-header-number header))
12518 (push header gnus-newsgroup-headers)
12519 (setq gnus-current-headers header)
12520 (push (mail-header-number header) gnus-newsgroup-limit)))
12521 header)))))
12523 (defun gnus-remove-header (number)
12524 "Remove header NUMBER from `gnus-newsgroup-headers'."
12525 (if (and gnus-newsgroup-headers
12526 (= number (mail-header-number (car gnus-newsgroup-headers))))
12527 (pop gnus-newsgroup-headers)
12528 (let ((headers gnus-newsgroup-headers))
12529 (while (and (cdr headers)
12530 (not (= number (mail-header-number (cadr headers)))))
12531 (pop headers))
12532 (when (cdr headers)
12533 (setcdr headers (cddr headers))))))
12536 ;;; summary highlights
12539 (defun gnus-highlight-selected-summary ()
12540 "Highlight selected article in summary buffer."
12541 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12542 (when gnus-summary-selected-face
12543 (save-excursion
12544 (let* ((beg (point-at-bol))
12545 (end (point-at-eol))
12546 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12547 (from (if (get-text-property beg 'mouse-face)
12549 (or (next-single-property-change
12550 beg 'mouse-face nil end)
12551 beg)))
12553 (if (= from end)
12554 (- from 2)
12555 (or (next-single-property-change
12556 from 'mouse-face nil end)
12557 end))))
12558 ;; If no mouse-face prop on line we will have to = from = end,
12559 ;; so we highlight the entire line instead.
12560 (when (= (+ to 2) from)
12561 (setq from beg)
12562 (setq to end))
12563 (if gnus-newsgroup-selected-overlay
12564 ;; Move old overlay.
12565 (move-overlay
12566 gnus-newsgroup-selected-overlay from to (current-buffer))
12567 ;; Create new overlay.
12568 (overlay-put
12569 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12570 'face gnus-summary-selected-face))))))
12572 (defvar gnus-summary-highlight-line-cached nil)
12573 (defvar gnus-summary-highlight-line-trigger nil)
12575 (defun gnus-summary-highlight-line-0 ()
12576 (if (and (eq gnus-summary-highlight-line-trigger
12577 gnus-summary-highlight)
12578 gnus-summary-highlight-line-cached)
12579 gnus-summary-highlight-line-cached
12580 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12581 gnus-summary-highlight-line-cached
12582 (let* ((cond (list 'cond))
12583 (c cond)
12584 (list gnus-summary-highlight))
12585 (while list
12586 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12587 nil))
12588 (setq c (cdr c)
12589 list (cdr list)))
12590 (gnus-byte-compile (list 'lambda nil cond))))))
12592 (defun gnus-summary-highlight-line ()
12593 "Highlight current line according to `gnus-summary-highlight'."
12594 (let* ((beg (point-at-bol))
12595 (article (or (gnus-summary-article-number) gnus-current-article))
12596 (score (or (cdr (assq article
12597 gnus-newsgroup-scored))
12598 gnus-summary-default-score 0))
12599 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12600 (inhibit-read-only t)
12601 (default gnus-summary-default-score)
12602 (default-high gnus-summary-default-high-score)
12603 (default-low gnus-summary-default-low-score)
12604 (uncached (and gnus-summary-use-undownloaded-faces
12605 (memq article gnus-newsgroup-undownloaded)
12606 (not (memq article gnus-newsgroup-cached)))))
12607 (let ((face (funcall (gnus-summary-highlight-line-0))))
12608 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12609 (gnus-put-text-property-excluding-characters-with-faces
12610 beg (point-at-eol) 'face
12611 (setq face (if (boundp face) (symbol-value face) face)))
12612 (when gnus-summary-highlight-line-function
12613 (funcall gnus-summary-highlight-line-function article face))))))
12615 (defun gnus-update-read-articles (group unread &optional compute)
12616 "Update the list of read articles in GROUP.
12617 UNREAD is a sorted list."
12618 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12619 (info (gnus-get-info group))
12620 (prev 1)
12621 read)
12622 (if (or (not info) (not active))
12623 ;; There is no info on this group if it was, in fact,
12624 ;; killed. Gnus stores no information on killed groups, so
12625 ;; there's nothing to be done.
12626 ;; One could store the information somewhere temporarily,
12627 ;; perhaps... Hmmm...
12629 ;; Remove any negative articles numbers.
12630 (while (and unread (< (car unread) 0))
12631 (setq unread (cdr unread)))
12632 ;; Remove any expired article numbers
12633 (while (and unread (< (car unread) (car active)))
12634 (setq unread (cdr unread)))
12635 ;; Compute the ranges of read articles by looking at the list of
12636 ;; unread articles.
12637 (while unread
12638 (when (/= (car unread) prev)
12639 (push (if (= prev (1- (car unread))) prev
12640 (cons prev (1- (car unread))))
12641 read))
12642 (setq prev (1+ (car unread)))
12643 (setq unread (cdr unread)))
12644 (when (<= prev (cdr active))
12645 (push (cons prev (cdr active)) read))
12646 (setq read (if (> (length read) 1) (nreverse read) read))
12647 (if compute
12648 read
12649 (save-excursion
12650 (let (setmarkundo)
12651 ;; Propagate the read marks to the backend.
12652 (when (and (gnus-method-option-p
12653 (gnus-find-method-for-group group)
12654 'server-marks)
12655 (gnus-check-backend-function 'request-set-mark group))
12656 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12657 (add (gnus-remove-from-range read (gnus-info-read info))))
12658 (when (or add del)
12659 (unless (gnus-check-group group)
12660 (error "Can't open server for %s" group))
12661 (gnus-request-set-mark
12662 group (delq nil (list (if add (list add 'add '(read)))
12663 (if del (list del 'del '(read))))))
12664 (setq setmarkundo
12665 `(gnus-request-set-mark
12666 ,group
12667 ',(delq nil (list
12668 (if del (list del 'add '(read)))
12669 (if add (list add 'del '(read))))))))))
12670 (set-buffer gnus-group-buffer)
12671 (gnus-undo-register
12672 `(progn
12673 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12674 (gnus-info-set-read ',info ',(gnus-info-read info))
12675 (gnus-get-unread-articles-in-group ',info
12676 (gnus-active ,group))
12677 (gnus-group-update-group ,group t)
12678 ,setmarkundo))))
12679 ;; Enter this list into the group info.
12680 (gnus-info-set-read info read)
12681 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12682 (gnus-get-unread-articles-in-group info (gnus-active group))
12683 t))))
12685 (defun gnus-offer-save-summaries ()
12686 "Offer to save all active summary buffers."
12687 (let (buffers)
12688 ;; Go through all buffers and find all summaries.
12689 (dolist (buffer (buffer-list))
12690 (when (and (setq buffer (buffer-name buffer))
12691 (string-match "Summary" buffer)
12692 (with-current-buffer buffer
12693 ;; We check that this is, indeed, a summary buffer.
12694 (and (derived-mode-p 'gnus-summary-mode)
12695 ;; Also make sure this isn't bogus.
12696 gnus-newsgroup-prepared
12697 ;; Also make sure that this isn't a
12698 ;; dead summary buffer.
12699 (not gnus-dead-summary-mode))))
12700 (push buffer buffers)))
12701 ;; Go through all these summary buffers and offer to save them.
12702 (when buffers
12703 (save-excursion
12704 (if (eq gnus-interactive-exit 'quiet)
12705 (dolist (buffer buffers)
12706 (switch-to-buffer buffer)
12707 (gnus-summary-exit))
12708 (map-y-or-n-p
12709 "Update summary buffer %s? "
12710 (lambda (buf)
12711 (switch-to-buffer buf)
12712 (gnus-summary-exit))
12713 buffers))))))
12715 (defun gnus-summary-setup-default-charset ()
12716 "Setup newsgroup default charset."
12717 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12718 (setq gnus-newsgroup-charset nil)
12719 (let* ((ignored-charsets
12720 (or gnus-newsgroup-ephemeral-ignored-charsets
12721 (append
12722 (and gnus-newsgroup-name
12723 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12724 gnus-newsgroup-ignored-charsets))))
12725 (setq gnus-newsgroup-charset
12726 (or gnus-newsgroup-ephemeral-charset
12727 (and gnus-newsgroup-name
12728 (gnus-parameter-charset gnus-newsgroup-name))
12729 gnus-default-charset))
12730 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12731 ignored-charsets))))
12734 ;;; Mime Commands
12737 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12738 "Display the current article buffer fully MIME-buttonized.
12739 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12740 treated as multipart/mixed."
12741 (interactive "P")
12742 (require 'gnus-art)
12743 (let ((gnus-unbuttonized-mime-types nil)
12744 (gnus-mime-display-multipart-as-mixed show-all-parts))
12745 (gnus-summary-show-article)))
12747 (defun gnus-summary-repair-multipart (article)
12748 "Add a Content-Type header to a multipart article without one."
12749 (interactive (list (gnus-summary-article-number)))
12750 (gnus-with-article article
12751 (message-narrow-to-head)
12752 (message-remove-header "Mime-Version")
12753 (goto-char (point-max))
12754 (insert "Mime-Version: 1.0\n")
12755 (widen)
12756 (when (search-forward "\n--" nil t)
12757 (let ((separator (buffer-substring (point) (point-at-eol))))
12758 (message-narrow-to-head)
12759 (message-remove-header "Content-Type")
12760 (goto-char (point-max))
12761 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12762 separator))
12763 (widen))))
12764 (let (gnus-mark-article-hook)
12765 (gnus-summary-select-article t t nil article)))
12767 (defun gnus-summary-toggle-display-buttonized ()
12768 "Toggle the buttonizing of the article buffer."
12769 (interactive)
12770 (require 'gnus-art)
12771 (if (setq gnus-inhibit-mime-unbuttonizing
12772 (not gnus-inhibit-mime-unbuttonizing))
12773 (let ((gnus-unbuttonized-mime-types nil))
12774 (gnus-summary-show-article))
12775 (gnus-summary-show-article)))
12778 ;;; Generic summary marking commands
12781 (defvar gnus-summary-marking-alist
12782 '((read gnus-del-mark "d")
12783 (unread gnus-unread-mark "u")
12784 (ticked gnus-ticked-mark "!")
12785 (dormant gnus-dormant-mark "?")
12786 (expirable gnus-expirable-mark "e"))
12787 "An alist of names/marks/keystrokes.")
12789 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12790 (defvar gnus-summary-mark-map)
12792 (defun gnus-summary-make-all-marking-commands ()
12793 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12794 (dolist (elem gnus-summary-marking-alist)
12795 (apply 'gnus-summary-make-marking-command elem)))
12797 (defun gnus-summary-make-marking-command (name mark keystroke)
12798 (let ((map (make-sparse-keymap)))
12799 (define-key gnus-summary-generic-mark-map keystroke map)
12800 (dolist (lway `((next "next" next nil "n")
12801 (next-unread "next unread" next t "N")
12802 (prev "previous" prev nil "p")
12803 (prev-unread "previous unread" prev t "P")
12804 (nomove "" nil nil ,keystroke)))
12805 (let ((func (gnus-summary-make-marking-command-1
12806 mark (car lway) lway name)))
12807 (setq func (eval func))
12808 (define-key map (nth 4 lway) func)))))
12810 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12811 `(defun ,(intern
12812 (format "gnus-summary-put-mark-as-%s%s"
12813 name (if (eq way 'nomove)
12815 (concat "-" (symbol-name way)))))
12817 ,(format
12818 "Mark the current article as %s%s.
12819 If N, the prefix, then repeat N times.
12820 If N is negative, move in reverse order.
12821 The difference between N and the actual number of articles marked is
12822 returned."
12823 name (cadr lway))
12824 (interactive "p")
12825 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12827 (defun gnus-summary-generic-mark (n mark move unread)
12828 "Mark N articles with MARK."
12829 (unless (derived-mode-p 'gnus-summary-mode)
12830 (error "This command can only be used in the summary buffer"))
12831 (gnus-summary-show-thread)
12832 (let ((nummove
12833 (cond
12834 ((eq move 'next) 1)
12835 ((eq move 'prev) -1)
12836 (t 0))))
12837 (if (zerop nummove)
12838 (setq n 1)
12839 (when (< n 0)
12840 (setq n (abs n)
12841 nummove (* -1 nummove))))
12842 (while (and (> n 0)
12843 (gnus-summary-mark-article nil mark)
12844 (zerop (gnus-summary-next-subject nummove unread t)))
12845 (setq n (1- n)))
12846 (when (/= 0 n)
12847 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12848 (gnus-summary-recenter)
12849 (gnus-summary-position-point)
12850 (gnus-set-mode-line 'summary)
12853 (defun gnus-summary-insert-articles (articles)
12854 (when (setq articles
12855 (gnus-sorted-difference articles
12856 (mapcar (lambda (h)
12857 (mail-header-number h))
12858 gnus-newsgroup-headers)))
12859 (setq gnus-newsgroup-headers
12860 (cl-merge 'list
12861 gnus-newsgroup-headers
12862 (gnus-fetch-headers articles nil t)
12863 'gnus-article-sort-by-number))
12864 (setq gnus-newsgroup-articles
12865 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12866 ;; Suppress duplicates?
12867 (when gnus-suppress-duplicates
12868 (gnus-dup-suppress-articles))
12870 (if (and gnus-fetch-old-headers
12871 (eq gnus-headers-retrieved-by 'nov))
12872 ;; We might want to build some more threads first.
12873 (if (eq gnus-fetch-old-headers 'invisible)
12874 (gnus-build-all-threads)
12875 (gnus-build-old-threads))
12876 ;; Mark the inserted articles that are unread as unread.
12877 (setq gnus-newsgroup-unreads
12878 (gnus-sorted-nunion
12879 gnus-newsgroup-unreads
12880 (gnus-sorted-nintersection
12881 (gnus-list-of-unread-articles gnus-newsgroup-name)
12882 articles)))
12883 ;; Mark the inserted articles as selected so that the information
12884 ;; of the marks having been changed by a user may be updated when
12885 ;; exiting this group. See `gnus-summary-update-info'.
12886 (dolist (art articles)
12887 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12888 ;; Let the Gnus agent mark articles as read.
12889 (when gnus-agent
12890 (gnus-agent-get-undownloaded-list))
12891 ;; Remove list identifiers from subject
12892 (gnus-summary-remove-list-identifiers)
12893 ;; First and last article in this newsgroup.
12894 (when gnus-newsgroup-headers
12895 (setq gnus-newsgroup-begin
12896 (mail-header-number (car gnus-newsgroup-headers))
12897 gnus-newsgroup-end
12898 (mail-header-number
12899 (gnus-last-element gnus-newsgroup-headers))))
12900 (when gnus-use-scoring
12901 (gnus-possibly-score-headers))))
12903 (defun gnus-summary-insert-old-articles (&optional all)
12904 "Insert all old articles in this group.
12905 If ALL is non-nil, already read articles become readable.
12906 If ALL is a number, fetch this number of articles."
12907 (interactive "P")
12908 (prog1
12909 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12910 older len)
12911 (setq older
12912 ;; Some nntp servers lie about their active range. When
12913 ;; this happens, the active range can be in the millions.
12914 ;; Use a compressed range to avoid creating a huge list.
12915 (gnus-range-difference
12916 (gnus-range-difference (list gnus-newsgroup-active) old)
12917 gnus-newsgroup-unexist))
12918 (setq len (gnus-range-length older))
12919 (cond
12920 ((null older) nil)
12921 ((numberp all)
12922 (if (< all len)
12923 (let ((older-range (nreverse older)))
12924 (setq older nil)
12926 (while (> all 0)
12927 (let* ((r (pop older-range))
12928 (min (if (numberp r) r (car r)))
12929 (max (if (numberp r) r (cdr r))))
12930 (while (and (<= min max)
12931 (> all 0))
12932 (push max older)
12933 (setq all (1- all)
12934 max (1- max))))))
12935 (setq older (gnus-uncompress-range older))))
12936 (all
12937 (setq older (gnus-uncompress-range older)))
12939 (when (and (numberp gnus-large-newsgroup)
12940 (> len gnus-large-newsgroup))
12941 (let* ((cursor-in-echo-area nil)
12942 (initial (gnus-parameter-large-newsgroup-initial
12943 gnus-newsgroup-name))
12944 (input
12945 (read-string
12946 (format
12947 "How many articles from %s (%s %d): "
12948 (gnus-group-decoded-name gnus-newsgroup-name)
12949 (if initial "max" "default")
12950 len)
12951 nil nil
12952 (and initial
12953 (number-to-string initial)))))
12954 (unless (string-match "^[ \t]*$" input)
12955 (setq all (string-to-number input))
12956 (if (< all len)
12957 (let ((older-range (nreverse older)))
12958 (setq older nil)
12960 (while (> all 0)
12961 (let* ((r (pop older-range))
12962 (min (if (numberp r) r (car r)))
12963 (max (if (numberp r) r (cdr r))))
12964 (while (and (<= min max)
12965 (> all 0))
12966 (push max older)
12967 (setq all (1- all)
12968 max (1- max))))))))))
12969 (setq older (gnus-uncompress-range older))))
12970 (if (not older)
12971 (message "No old news.")
12972 (gnus-summary-insert-articles older)
12973 (gnus-summary-limit (gnus-sorted-nunion old older))))
12974 (gnus-summary-position-point)))
12976 (defun gnus-summary-insert-new-articles ()
12977 "Insert all new articles in this group."
12978 (interactive)
12979 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12980 (old-high gnus-newsgroup-highest)
12981 (nnmail-fetched-sources (list t))
12982 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12983 i new)
12984 (unless new-active
12985 (error "Couldn't fetch new data"))
12986 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12987 (setq i (cdr gnus-newsgroup-active)
12988 gnus-newsgroup-highest i)
12989 (while (> i old-high)
12990 (push i new)
12991 (decf i))
12992 (if (not new)
12993 (message "No gnus is bad news")
12994 (gnus-summary-insert-articles new)
12995 (setq gnus-newsgroup-unreads
12996 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12997 (gnus-summary-limit (gnus-sorted-nunion old new))))
12998 (gnus-summary-position-point))
13000 ;;; Bookmark support for Gnus.
13001 (declare-function gnus-article-show-summary "gnus-art" ())
13002 (declare-function bookmark-make-record-default
13003 "bookmark" (&optional no-file no-context posn))
13004 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13005 (declare-function bookmark-default-handler "bookmark" (bmk))
13006 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13007 (defvar bookmark-yank-point)
13008 (defvar bookmark-current-buffer)
13010 (defun gnus-summary-bookmark-make-record ()
13011 "Make a bookmark entry for a Gnus summary buffer."
13012 (let (pos buf)
13013 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13014 (save-restriction ; FIXME is it necessary to widen?
13015 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13016 (setq buf "art") ; We are recording bookmark from article buffer.
13017 (setq bookmark-yank-point (point))
13018 (setq bookmark-current-buffer (current-buffer))
13019 (gnus-article-show-summary)) ; Go back in summary buffer.
13020 ;; We are now recording bookmark from summary buffer.
13021 (unless buf (setq buf "sum"))
13022 (let* ((subject (elt (gnus-summary-article-header) 1))
13023 (grp (car gnus-article-current))
13024 (art (cdr gnus-article-current))
13025 (head (gnus-summary-article-header art))
13026 (id (mail-header-id head)))
13027 `(,subject
13028 ,@(condition-case nil
13029 (bookmark-make-record-default 'no-file 'no-context pos)
13030 (wrong-number-of-arguments
13031 (bookmark-make-record-default 'point-only)))
13032 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13033 (group . ,grp) (article . ,art)
13034 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13036 ;;;###autoload
13037 (defun gnus-summary-bookmark-jump (bookmark)
13038 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13039 BOOKMARK is a bookmark name or a bookmark record."
13040 (let ((group (bookmark-prop-get bookmark 'group))
13041 (article (bookmark-prop-get bookmark 'article))
13042 (id (bookmark-prop-get bookmark 'message-id))
13043 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13044 (gnus-fetch-group group (list article))
13045 (gnus-summary-insert-cached-articles)
13046 (gnus-summary-goto-article id nil 'force)
13047 ;; FIXME we have to wait article buffer is ready (only large buffer)
13048 ;; Is there a better solution to know that?
13049 ;; If we don't wait `bookmark-default-handler' will have no chance
13050 ;; to set position. However there is no error, just wrong pos.
13051 (sit-for 1)
13052 (when (string= buf "Gnus-art")
13053 (other-window 1))
13054 (bookmark-default-handler
13055 `(""
13056 (buffer . ,(current-buffer))
13057 . ,(bookmark-get-bookmark-record bookmark)))))
13059 (gnus-summary-make-all-marking-commands)
13061 (provide 'gnus-sum)
13063 (run-hooks 'gnus-sum-load-hook)
13065 ;; Local Variables:
13066 ;; coding: utf-8
13067 ;; End:
13069 ;;; gnus-sum.el ends here