Merge branch 'master' into comment-cache
[emacs.git] / lisp / gnus / gnus-sum.el
blob2631514e425641e869ff2966a16b96a8c90adf96
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 (unless (get-buffer-window gnus-article-buffer)
7049 (gnus-summary-show-article))
7050 (gnus-configure-windows
7051 (if gnus-widen-article-window
7052 'only-article
7053 'article)
7055 (select-window (get-buffer-window gnus-article-buffer))))
7057 (defun gnus-summary-universal-argument (arg)
7058 "Perform any operation on all articles that are process/prefixed."
7059 (interactive "P")
7060 (let ((articles (gnus-summary-work-articles arg))
7061 func article)
7062 (if (eq
7063 (setq
7064 func
7065 (key-binding
7066 (read-key-sequence
7067 (substitute-command-keys
7068 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7069 'undefined)
7070 (gnus-error 1 "Undefined key")
7071 (save-excursion
7072 (while articles
7073 (gnus-summary-goto-subject (setq article (pop articles)))
7074 (let (gnus-newsgroup-processable)
7075 (command-execute func))
7076 (gnus-summary-remove-process-mark article)))))
7077 (gnus-summary-position-point))
7079 (define-obsolete-function-alias
7080 'gnus-summary-toggle-truncation 'toggle-truncate-lines "26.1")
7082 (defun gnus-summary-find-for-reselect ()
7083 "Return the number of an article to stay on across a reselect.
7084 The current article is considered, then following articles, then previous
7085 articles. An article is sought which is not canceled and isn't a temporary
7086 insertion from another group. If there's no such then return a dummy 0."
7087 (let (found)
7088 (dolist (rev '(nil t))
7089 (unless found ; don't demand the reverse list if we don't need it
7090 (let ((data (gnus-data-find-list
7091 (gnus-summary-article-number) (gnus-data-list rev))))
7092 (while (and data (not found))
7093 (if (and (< 0 (gnus-data-number (car data)))
7094 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7095 (setq found (gnus-data-number (car data))))
7096 (setq data (cdr data))))))
7097 (or found 0)))
7099 (defun gnus-summary-reselect-current-group (&optional all rescan)
7100 "Exit and then reselect the current newsgroup.
7101 The prefix argument ALL means to select all articles."
7102 (interactive "P")
7103 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7104 (error "Ephemeral groups can't be reselected"))
7105 (let ((current-subject (gnus-summary-find-for-reselect))
7106 (group gnus-newsgroup-name))
7107 (setq gnus-newsgroup-begin nil)
7108 (gnus-summary-exit nil 'leave-hidden)
7109 ;; We have to adjust the point of group mode buffer because
7110 ;; point was moved to the next unread newsgroup by exiting.
7111 (gnus-summary-jump-to-group group)
7112 (when rescan
7113 (save-excursion
7114 (gnus-group-get-new-news-this-group 1)))
7115 (gnus-group-read-group all t)
7116 (gnus-summary-goto-subject current-subject nil t)))
7118 (defun gnus-summary-rescan-group (&optional all)
7119 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7120 (interactive "P")
7121 (let ((config gnus-current-window-configuration))
7122 (gnus-summary-reselect-current-group all t)
7123 (gnus-configure-windows config)
7124 (when (eq config 'article)
7125 (gnus-summary-select-article))))
7127 (defun gnus-summary-update-info (&optional non-destructive)
7128 (save-excursion
7129 (let ((group gnus-newsgroup-name))
7130 (when group
7131 (when gnus-newsgroup-kill-headers
7132 (setq gnus-newsgroup-killed
7133 (gnus-compress-sequence
7134 (gnus-sorted-union
7135 (gnus-list-range-intersection
7136 gnus-newsgroup-unselected gnus-newsgroup-killed)
7137 gnus-newsgroup-unreads)
7138 t)))
7139 (unless (listp (cdr gnus-newsgroup-killed))
7140 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7141 (let ((headers gnus-newsgroup-headers)
7142 (ephemeral-p (gnus-ephemeral-group-p group))
7143 info)
7144 (unless ephemeral-p
7145 (setq info (copy-sequence (gnus-get-info group))
7146 info (delq (gnus-info-params info) info)))
7147 ;; Set the new ranges of read articles.
7148 (with-current-buffer gnus-group-buffer
7149 (gnus-undo-force-boundary))
7150 (gnus-update-read-articles
7151 group (gnus-sorted-union
7152 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7153 ;; Set the current article marks.
7154 (let ((gnus-newsgroup-scored
7155 (if (and (not gnus-save-score)
7156 (not non-destructive))
7158 gnus-newsgroup-scored)))
7159 (save-excursion
7160 (gnus-update-marks)))
7161 ;; Do the cross-ref thing.
7162 (when gnus-use-cross-reference
7163 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7164 ;; Do not switch windows but change the buffer to work.
7165 (set-buffer gnus-group-buffer)
7166 (unless ephemeral-p
7167 (gnus-group-update-group
7168 group nil
7169 (equal info
7170 (setq info (copy-sequence (gnus-get-info group))
7171 info (delq (gnus-info-params info) info))))))))))
7173 (defun gnus-summary-save-newsrc (&optional force)
7174 "Save the current number of read/marked articles in the dribble buffer.
7175 The dribble buffer will then be saved.
7176 If FORCE (the prefix), also save the .newsrc file(s)."
7177 (interactive "P")
7178 (gnus-summary-update-info t)
7179 (if force
7180 (gnus-save-newsrc-file)
7181 (gnus-dribble-save)))
7183 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7184 (declare-function gnus-article-stop-animations "gnus-art" ())
7186 (defun gnus-summary-exit (&optional temporary leave-hidden)
7187 "Exit reading current newsgroup, and then return to group selection mode.
7188 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7189 (interactive)
7190 (gnus-set-global-variables)
7191 (when (gnus-buffer-live-p gnus-article-buffer)
7192 (with-current-buffer gnus-article-buffer
7193 (mm-destroy-parts gnus-article-mime-handles)
7194 ;; Set it to nil for safety reason.
7195 (setq gnus-article-mime-handle-alist nil)
7196 (setq gnus-article-mime-handles nil)))
7197 (gnus-kill-save-kill-buffer)
7198 (gnus-async-halt-prefetch)
7199 (let* ((group gnus-newsgroup-name)
7200 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7201 (gnus-group-is-exiting-p t)
7202 (article-buffer gnus-article-buffer)
7203 (original-article-buffer gnus-original-article-buffer)
7204 (mode major-mode)
7205 (group-point nil)
7206 (buf (current-buffer))
7207 ;; `gnus-single-article-buffer' is nil buffer-locally in
7208 ;; ephemeral group of which summary buffer will be killed,
7209 ;; but the global value may be non-nil.
7210 (single-article-buffer gnus-single-article-buffer))
7211 (unless quit-config
7212 ;; Do adaptive scoring, and possibly save score files.
7213 (when gnus-newsgroup-adaptive
7214 (gnus-score-adaptive))
7215 (when gnus-use-scoring
7216 (gnus-score-save)))
7217 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7218 (when gnus-use-cache
7219 (gnus-cache-possibly-remove-articles)
7220 (gnus-cache-save-buffers))
7221 (gnus-async-prefetch-remove-group group)
7222 (when gnus-suppress-duplicates
7223 (gnus-dup-enter-articles))
7224 (when gnus-use-trees
7225 (gnus-tree-close))
7226 (when gnus-use-cache
7227 (gnus-cache-write-active))
7228 ;; Remove entries for this group.
7229 (nnmail-purge-split-history (gnus-group-real-name group))
7230 ;; Make all changes in this group permanent.
7231 (unless quit-config
7232 (gnus-run-hooks 'gnus-exit-group-hook)
7233 (gnus-summary-update-info))
7234 (gnus-close-group group)
7235 ;; Make sure where we were, and go to next newsgroup.
7236 (when (buffer-live-p (get-buffer gnus-group-buffer))
7237 (set-buffer gnus-group-buffer))
7238 (unless quit-config
7239 (gnus-group-jump-to-group group))
7240 (gnus-run-hooks 'gnus-summary-exit-hook)
7241 (unless (or quit-config
7242 (not gnus-summary-next-group-on-exit)
7243 ;; If this group has disappeared from the summary
7244 ;; buffer, don't skip forwards.
7245 (not (string= group (gnus-group-group-name))))
7246 (gnus-group-next-unread-group 1))
7247 (setq group-point (point))
7248 (gnus-article-stop-animations)
7249 (if temporary
7250 nil ;Nothing to do.
7251 (set-buffer buf)
7252 (if (not gnus-kill-summary-on-exit)
7253 (progn
7254 (gnus-deaden-summary)
7255 (setq mode nil))
7256 (when (get-buffer gnus-article-buffer)
7257 (bury-buffer gnus-article-buffer))
7258 ;; Return to group mode buffer.
7259 (when (eq mode 'gnus-summary-mode)
7260 (gnus-kill-buffer buf)))
7262 (setq gnus-current-select-method gnus-select-method)
7263 (when (gnus-buffer-live-p gnus-group-buffer)
7264 (set-buffer gnus-group-buffer))
7265 (if quit-config
7266 (gnus-handle-ephemeral-exit quit-config)
7267 (goto-char group-point)
7268 ;; If gnus-group-buffer is already displayed, make sure we also move
7269 ;; the cursor in the window that displays it.
7270 (let ((win (get-buffer-window (current-buffer) 0)))
7271 (if win (set-window-point win (point))))
7272 (unless leave-hidden
7273 (gnus-configure-windows 'group 'force)))
7275 ;; If we have several article buffers, we kill them at exit.
7276 (unless single-article-buffer
7277 (when (gnus-buffer-live-p article-buffer)
7278 (with-current-buffer article-buffer
7279 ;; Don't kill sticky article buffers
7280 (unless (eq major-mode 'gnus-sticky-article-mode)
7281 (gnus-kill-buffer article-buffer)
7282 (setq gnus-article-current nil))))
7283 (gnus-kill-buffer original-article-buffer))
7285 ;; Clear the current group name.
7286 (unless quit-config
7287 (setq gnus-newsgroup-name nil)))))
7289 (declare-function gnus-stop-downloads "gnus-art" ())
7291 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7292 (defun gnus-summary-exit-no-update (&optional no-questions)
7293 "Quit reading current newsgroup without updating read article info."
7294 (interactive)
7295 (let* ((group gnus-newsgroup-name)
7296 (gnus-group-is-exiting-p t)
7297 (gnus-group-is-exiting-without-update-p t)
7298 (quit-config (gnus-group-quit-config group)))
7299 (when (or no-questions
7300 (gnus-ephemeral-group-p group)
7301 gnus-expert-user
7302 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7303 (gnus-async-halt-prefetch)
7304 (run-hooks 'gnus-summary-prepare-exit-hook)
7305 (when (gnus-buffer-live-p gnus-article-buffer)
7306 (with-current-buffer gnus-article-buffer
7307 (gnus-article-stop-animations)
7308 (gnus-stop-downloads)
7309 (mm-destroy-parts gnus-article-mime-handles)
7310 ;; Set it to nil for safety reason.
7311 (setq gnus-article-mime-handle-alist nil)
7312 (setq gnus-article-mime-handles nil)))
7313 ;; If we have several article buffers, we kill them at exit.
7314 (unless gnus-single-article-buffer
7315 (gnus-kill-buffer gnus-article-buffer)
7316 (gnus-kill-buffer gnus-original-article-buffer)
7317 (setq gnus-article-current nil))
7318 ;; Return to the group buffer.
7319 (if (not gnus-kill-summary-on-exit)
7320 (progn
7321 (gnus-deaden-summary)
7322 (gnus-configure-windows 'group 'force))
7323 (gnus-configure-windows 'group 'force)
7324 (gnus-close-group group)
7325 (gnus-kill-buffer gnus-summary-buffer))
7326 (unless gnus-single-article-buffer
7327 (setq gnus-article-current nil))
7328 (when gnus-use-trees
7329 (gnus-tree-close))
7330 (gnus-async-prefetch-remove-group group)
7331 (when (get-buffer gnus-article-buffer)
7332 (bury-buffer gnus-article-buffer))
7333 ;; Clear the current group name.
7334 (setq gnus-newsgroup-name nil)
7335 (unless (gnus-ephemeral-group-p group)
7336 (gnus-group-update-group group nil t))
7337 (when (equal (gnus-group-group-name) group)
7338 (gnus-group-next-unread-group 1))
7339 (gnus-article-stop-animations)
7340 (when quit-config
7341 (gnus-handle-ephemeral-exit quit-config)))))
7343 (defun gnus-handle-ephemeral-exit (quit-config)
7344 "Handle movement when leaving an ephemeral group.
7345 The state which existed when entering the ephemeral is reset."
7346 (if (not (buffer-live-p (car quit-config)))
7347 (when (gnus-buffer-live-p gnus-group-buffer)
7348 (gnus-configure-windows 'group 'force))
7349 (set-buffer (car quit-config))
7350 (unless (eq (cdr quit-config) 'group)
7351 (setq gnus-current-select-method
7352 (gnus-find-method-for-group gnus-newsgroup-name)))
7353 (cond ((derived-mode-p 'gnus-summary-mode)
7354 (gnus-set-global-variables))
7355 ((derived-mode-p 'gnus-article-mode)
7356 (save-current-buffer
7357 ;; The `gnus-summary-buffer' variable may point
7358 ;; to the old summary buffer when using a single
7359 ;; article buffer.
7360 (unless (gnus-buffer-live-p gnus-summary-buffer)
7361 (set-buffer gnus-group-buffer))
7362 (set-buffer gnus-summary-buffer)
7363 (gnus-set-global-variables))))
7364 (if (or (eq (cdr quit-config) 'article)
7365 (eq (cdr quit-config) 'pick))
7366 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7367 (gnus-configure-windows 'pick 'force)
7368 (gnus-configure-windows (cdr quit-config) 'force))
7369 (gnus-configure-windows (cdr quit-config) 'force))
7370 (when (derived-mode-p 'gnus-summary-mode)
7371 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7372 next-unread-noselect))
7373 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7374 'next-noselect)
7375 (gnus-summary-next-subject 1 nil t))
7376 ((eq gnus-auto-select-on-ephemeral-exit
7377 'next-unread-noselect)
7378 (gnus-summary-next-subject 1 t t))))
7379 ;; Hide the article buffer which displays the article different
7380 ;; from the one that the cursor points to in the summary buffer.
7381 (gnus-configure-windows 'summary 'force))
7382 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7383 (gnus-summary-next-subject 1))
7384 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7385 (gnus-summary-next-subject 1 t))))
7386 (gnus-summary-recenter)
7387 (gnus-summary-position-point))))
7389 ;;; Dead summaries.
7391 (defvar gnus-dead-summary-mode-map
7392 (let ((map (make-keymap)))
7393 (suppress-keymap map)
7394 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7395 (dolist (key '("\C-d" "\r" "\177" [delete]))
7396 (define-key map key 'gnus-summary-wake-up-the-dead))
7397 (dolist (key '("q" "Q"))
7398 (define-key map key 'bury-buffer))
7399 map))
7401 (define-minor-mode gnus-dead-summary-mode
7402 "Minor mode for Gnus summary buffers."
7403 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7404 (unless (derived-mode-p 'gnus-summary-mode)
7405 (setq gnus-dead-summary-mode nil)))
7407 (defun gnus-deaden-summary ()
7408 "Make the current summary buffer into a dead summary buffer."
7409 ;; Kill any previous dead summary buffer.
7410 (when (and gnus-dead-summary
7411 (buffer-name gnus-dead-summary))
7412 (with-current-buffer gnus-dead-summary
7413 (when gnus-dead-summary-mode
7414 (kill-buffer (current-buffer)))))
7415 ;; Make this the current dead summary.
7416 (setq gnus-dead-summary (current-buffer))
7417 (gnus-dead-summary-mode 1)
7418 (let ((name (buffer-name)))
7419 (when (string-match "Summary" name)
7420 (rename-buffer
7421 (concat (substring name 0 (match-beginning 0)) "Dead "
7422 (substring name (match-beginning 0)))
7424 (bury-buffer))))
7426 (defun gnus-kill-or-deaden-summary (buffer)
7427 "Kill or deaden the summary BUFFER."
7428 (save-excursion
7429 (when (and (buffer-name buffer)
7430 (not gnus-single-article-buffer))
7431 (with-current-buffer buffer
7432 (gnus-kill-buffer gnus-article-buffer)
7433 (gnus-kill-buffer gnus-original-article-buffer)))
7434 (cond
7435 ;; Kill the buffer.
7436 (gnus-kill-summary-on-exit
7437 (when (and gnus-use-trees
7438 (gnus-buffer-exists-p buffer))
7439 (with-current-buffer buffer
7440 (gnus-tree-close)))
7441 (gnus-kill-buffer buffer))
7442 ;; Deaden the buffer.
7443 ((gnus-buffer-exists-p buffer)
7444 (with-current-buffer buffer
7445 (gnus-deaden-summary))))))
7447 (defun gnus-summary-wake-up-the-dead (&rest args)
7448 "Wake up the dead summary buffer."
7449 (interactive)
7450 (gnus-dead-summary-mode -1)
7451 (let ((name (buffer-name)))
7452 (when (string-match "Dead " name)
7453 (rename-buffer
7454 (concat (substring name 0 (match-beginning 0))
7455 (substring name (match-end 0)))
7456 t)))
7457 (gnus-message 3 "This dead summary is now alive again"))
7459 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7460 (defun gnus-summary-describe-group (&optional force)
7461 "Describe the current newsgroup."
7462 (interactive "P")
7463 (gnus-group-describe-group force gnus-newsgroup-name))
7465 (defun gnus-summary-describe-briefly ()
7466 "Describe summary mode commands briefly."
7467 (interactive)
7468 (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")))
7470 ;; Walking around group mode buffer from summary mode.
7472 (defun gnus-summary-next-group (&optional no-article target-group backward)
7473 "Exit current newsgroup and then select next unread newsgroup.
7474 If prefix argument NO-ARTICLE is non-nil, no article is selected
7475 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7476 previous group instead."
7477 (interactive "P")
7478 ;; Stop pre-fetching.
7479 (gnus-async-halt-prefetch)
7480 (let ((current-group gnus-newsgroup-name)
7481 (current-buffer (current-buffer))
7482 entered)
7483 ;; First we semi-exit this group to update Xrefs and all variables.
7484 ;; We can't do a real exit, because the window conf must remain
7485 ;; the same in case the user is prompted for info, and we don't
7486 ;; want the window conf to change before that...
7487 (gnus-summary-exit t)
7488 (while (not entered)
7489 ;; Then we find what group we are supposed to enter.
7490 (set-buffer gnus-group-buffer)
7491 (gnus-group-jump-to-group current-group)
7492 (setq target-group
7493 (or target-group
7494 (if (eq gnus-keep-same-level 'best)
7495 (gnus-summary-best-group gnus-newsgroup-name)
7496 (gnus-summary-search-group backward gnus-keep-same-level))))
7497 (if (not target-group)
7498 ;; There are no further groups, so we return to the group
7499 ;; buffer.
7500 (progn
7501 (gnus-message 5 "Returning to the group buffer")
7502 (setq entered t)
7503 (when (gnus-buffer-live-p current-buffer)
7504 (set-buffer current-buffer)
7505 (gnus-summary-exit))
7506 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7507 ;; We try to enter the target group.
7508 (gnus-group-jump-to-group target-group)
7509 (let ((unreads (gnus-group-group-unread)))
7510 (if (and (or (eq t unreads)
7511 (and unreads (not (zerop unreads))))
7512 (gnus-summary-read-group
7513 target-group nil no-article
7514 (and (buffer-name current-buffer) current-buffer)
7515 nil backward))
7516 (setq entered t)
7517 (setq current-group target-group
7518 target-group nil)))))))
7520 (defun gnus-summary-prev-group (&optional no-article)
7521 "Exit current newsgroup and then select previous unread newsgroup.
7522 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7523 (interactive "P")
7524 (gnus-summary-next-group no-article nil t))
7526 ;; Walking around summary lines.
7528 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7529 "Go to the first subject satisfying any non-nil constraint.
7530 If UNREAD is non-nil, the article should be unread.
7531 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7532 If UNSEEN is non-nil, the article should be unseen as well as unread.
7533 Returns the article selected or nil if there are no matching articles."
7534 (interactive "P")
7535 (cond
7536 ;; Empty summary.
7537 ((null gnus-newsgroup-data)
7538 (gnus-message 3 "No articles in the group")
7539 nil)
7540 ;; Pick the first article.
7541 ((not (or unread undownloaded unseen))
7542 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7543 (gnus-data-number (car gnus-newsgroup-data)))
7544 ;; Find the first unread article.
7546 (let ((data gnus-newsgroup-data))
7547 (while (and data
7548 (let ((num (gnus-data-number (car data))))
7549 (or (memq num gnus-newsgroup-unfetched)
7550 (not (or (and unread
7551 (memq num gnus-newsgroup-unreads))
7552 (and undownloaded
7553 (memq num gnus-newsgroup-undownloaded))
7554 (and unseen
7555 (memq num gnus-newsgroup-unseen)
7556 (memq num gnus-newsgroup-unreads)))))))
7557 (setq data (cdr data)))
7558 (prog1
7559 (if data
7560 (progn
7561 (goto-char (gnus-data-pos (car data)))
7562 (gnus-data-number (car data)))
7563 (gnus-message 3 "No more%s articles"
7564 (let* ((r (when unread " unread"))
7565 (d (when undownloaded " undownloaded"))
7566 (s (when unseen " unseen"))
7567 (l (delq nil (list r d s))))
7568 (cond ((= 3 (length l))
7569 (concat r "," d ", or" s))
7570 ((= 2 (length l))
7571 (concat (car l) ", or" (cadr l)))
7572 ((= 1 (length l))
7573 (car l))
7575 ""))))
7578 (gnus-summary-position-point))))))
7580 (defun gnus-summary-next-subject (n &optional unread dont-display)
7581 "Go to next N'th summary line.
7582 If N is negative, go to the previous N'th subject line.
7583 If UNREAD is non-nil, only unread articles are selected.
7584 The difference between N and the actual number of steps taken is
7585 returned."
7586 (interactive "p")
7587 (let ((backward (< n 0))
7588 (n (abs n)))
7589 (while (and (> n 0)
7590 (if backward
7591 (gnus-summary-find-prev unread)
7592 (gnus-summary-find-next unread)))
7593 (unless (zerop (setq n (1- n)))
7594 (gnus-summary-show-thread)))
7595 (when (/= 0 n)
7596 (gnus-message 7 "No more%s articles"
7597 (if unread " unread" "")))
7598 (unless dont-display
7599 (gnus-summary-recenter)
7600 (gnus-summary-position-point))
7603 (defun gnus-summary-next-unread-subject (n)
7604 "Go to next N'th unread summary line."
7605 (interactive "p")
7606 (gnus-summary-next-subject n t))
7608 (defun gnus-summary-prev-subject (n &optional unread)
7609 "Go to previous N'th summary line.
7610 If optional argument UNREAD is non-nil, only unread article is selected."
7611 (interactive "p")
7612 (gnus-summary-next-subject (- n) unread))
7614 (defun gnus-summary-prev-unread-subject (n)
7615 "Go to previous N'th unread summary line."
7616 (interactive "p")
7617 (gnus-summary-next-subject (- n) t))
7619 (defun gnus-summary-goto-subjects (articles)
7620 "Insert the subject header for ARTICLES in the current buffer."
7621 (save-excursion
7622 (dolist (article articles)
7623 (gnus-summary-goto-subject article t)))
7624 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7625 (gnus-summary-position-point))
7627 (defun gnus-summary-goto-subject (article &optional force silent)
7628 "Go to the subject line of ARTICLE.
7629 If FORCE, also allow jumping to articles not currently shown."
7630 (interactive "nArticle number: ")
7631 (unless (numberp article)
7632 (error "Article %s is not a number" article))
7633 (let ((b (point))
7634 (data (gnus-data-find article)))
7635 ;; We read in the article if we have to.
7636 (and (not data)
7637 force
7638 (gnus-summary-insert-subject
7639 article
7640 (if (or (numberp force) (vectorp force)) force)
7642 (setq data (gnus-data-find article)))
7643 (goto-char b)
7644 (if (not data)
7645 (progn
7646 (unless silent
7647 (gnus-message 3 "Can't find article %d" article))
7648 nil)
7649 (let ((pt (gnus-data-pos data)))
7650 (goto-char pt)
7651 (gnus-summary-set-article-display-arrow pt))
7652 (gnus-summary-position-point)
7653 article)))
7655 ;; Walking around summary lines with displaying articles.
7657 (defun gnus-summary-expand-window (&optional arg)
7658 "Make the summary buffer take up the entire Emacs frame.
7659 Given a prefix, will force an `article' buffer configuration."
7660 (interactive "P")
7661 (if arg
7662 (gnus-configure-windows 'article 'force)
7663 (gnus-configure-windows 'summary 'force)))
7665 (defun gnus-summary-display-article (article &optional all-header)
7666 "Display ARTICLE in article buffer."
7667 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7668 (with-current-buffer gnus-article-buffer
7669 (derived-mode-p 'gnus-article-mode)))
7670 (gnus-article-setup-buffer))
7671 (gnus-set-global-variables)
7672 (with-current-buffer gnus-article-buffer
7673 (setq gnus-article-charset gnus-newsgroup-charset)
7674 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7675 (mm-enable-multibyte))
7676 (if (null article)
7678 (prog1
7679 (if gnus-summary-display-article-function
7680 (funcall gnus-summary-display-article-function article all-header)
7681 (gnus-article-prepare article all-header))
7682 (gnus-run-hooks 'gnus-select-article-hook)
7683 (when (and gnus-current-article
7684 (not (zerop gnus-current-article)))
7685 (gnus-summary-goto-subject gnus-current-article))
7686 (gnus-summary-recenter)
7687 (when (and gnus-use-trees gnus-show-threads)
7688 (gnus-possibly-generate-tree article)
7689 (gnus-highlight-selected-tree article))
7690 ;; Successfully display article.
7691 (gnus-article-set-window-start
7692 (cdr (assq article gnus-newsgroup-bookmarks))))))
7694 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7695 "Select the current article.
7696 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7697 non-nil, the article will be re-fetched even if it already present in
7698 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7699 be displayed."
7700 ;; Make sure we are in the summary buffer to work around bbdb bug.
7701 (unless (derived-mode-p 'gnus-summary-mode)
7702 (set-buffer gnus-summary-buffer))
7703 (let ((article (or article (gnus-summary-article-number)))
7704 (all-headers (not (not all-headers))) ;Must be t or nil.
7705 gnus-summary-display-article-function)
7706 (and (not pseudo)
7707 (gnus-summary-article-pseudo-p article)
7708 (error "This is a pseudo-article"))
7709 (with-current-buffer gnus-summary-buffer
7710 (if (or (and gnus-single-article-buffer
7711 (or (null gnus-current-article)
7712 (null gnus-article-current)
7713 (null (get-buffer gnus-article-buffer))
7714 (not (eq article (cdr gnus-article-current)))
7715 (not (equal (car gnus-article-current)
7716 gnus-newsgroup-name))
7717 (not (get-buffer gnus-original-article-buffer))))
7718 (and (not gnus-single-article-buffer)
7719 (or (null gnus-current-article)
7720 (not (get-buffer gnus-original-article-buffer))
7721 (not (eq gnus-current-article article))))
7722 force)
7723 ;; The requested article is different from the current article.
7724 (progn
7725 (gnus-summary-display-article article all-headers)
7726 (when (gnus-buffer-live-p gnus-article-buffer)
7727 (with-current-buffer gnus-article-buffer
7728 (if (not gnus-article-decoded-p) ;; a local variable
7729 (mm-disable-multibyte))))
7730 (gnus-article-set-window-start
7731 (cdr (assq article gnus-newsgroup-bookmarks)))
7732 article)
7733 'old))))
7735 (defun gnus-summary-force-verify-and-decrypt ()
7736 "Display buttons for signed/encrypted parts and verify/decrypt them."
7737 (interactive)
7738 (let ((mm-verify-option 'known)
7739 (mm-decrypt-option 'known)
7740 (gnus-article-emulate-mime t)
7741 (gnus-buttonized-mime-types (append (list "multipart/signed"
7742 "multipart/encrypted")
7743 gnus-buttonized-mime-types)))
7744 (gnus-summary-select-article nil 'force)))
7746 (defun gnus-summary-next-article (&optional unread subject backward push)
7747 "Select the next article.
7748 If UNREAD, only unread articles are selected.
7749 If SUBJECT, only articles with SUBJECT are selected.
7750 If BACKWARD, the previous article is selected instead of the next."
7751 (interactive "P")
7752 ;; Make sure we are in the summary buffer.
7753 (unless (derived-mode-p 'gnus-summary-mode)
7754 (set-buffer gnus-summary-buffer))
7755 (cond
7756 ;; Is there such an article?
7757 ((and (gnus-summary-search-forward unread subject backward)
7758 (or (gnus-summary-display-article (gnus-summary-article-number))
7759 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7760 (gnus-summary-position-point))
7761 ;; If not, we try the first unread, if that is wanted.
7762 ((and subject
7763 gnus-auto-select-same
7764 (gnus-summary-first-unread-article))
7765 (gnus-summary-position-point)
7766 (gnus-message 6 "Wrapped"))
7767 ;; Try to get next/previous article not displayed in this group.
7768 ((and gnus-auto-extend-newsgroup
7769 (not unread) (not subject))
7770 (gnus-summary-goto-article
7771 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7772 nil (count-lines (point-min) (point))))
7773 ;; Go to next/previous group.
7775 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7776 (gnus-summary-jump-to-group gnus-newsgroup-name))
7777 (let ((cmd last-command-event)
7778 (point
7779 (with-current-buffer gnus-group-buffer
7780 (point)))
7781 (current-summary (current-buffer))
7782 (group
7783 (if (eq gnus-keep-same-level 'best)
7784 (gnus-summary-best-group gnus-newsgroup-name)
7785 (gnus-summary-search-group backward gnus-keep-same-level))))
7786 ;; Select next unread newsgroup automagically.
7787 (cond
7788 ((or (not gnus-auto-select-next)
7789 (not cmd))
7790 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7791 ((or (eq gnus-auto-select-next 'quietly)
7792 (and (eq gnus-auto-select-next 'slightly-quietly)
7793 push)
7794 (and (eq gnus-auto-select-next 'almost-quietly)
7795 (gnus-summary-last-article-p)))
7796 ;; Select quietly.
7797 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7798 (gnus-summary-exit)
7799 (gnus-message 7 "No more%s articles (%s)..."
7800 (if unread " unread" "")
7801 (if group (concat "selecting " group)
7802 "exiting"))
7803 (gnus-summary-next-group nil group backward)))
7805 (when (numberp last-input-event)
7806 ;; Somehow or other, we may now have selected a different
7807 ;; window. Make point go back to the summary buffer.
7808 (when (eq current-summary (current-buffer))
7809 ;; FIXME: This burps when get-buffer-window returns nil.
7810 (select-window (get-buffer-window current-summary 0)))
7811 (gnus-summary-walk-group-buffer
7812 gnus-newsgroup-name cmd unread backward point))))))))
7814 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7815 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7816 (?\C-p (gnus-group-prev-unread-group 1))))
7817 (cursor-in-echo-area t)
7818 keve key group ended prompt)
7819 (with-current-buffer gnus-group-buffer
7820 (goto-char start)
7821 (setq group
7822 (if (eq gnus-keep-same-level 'best)
7823 (gnus-summary-best-group gnus-newsgroup-name)
7824 (gnus-summary-search-group backward gnus-keep-same-level))))
7825 (while (not ended)
7826 (setq prompt
7827 (format
7828 "No more%s articles%s " (if unread " unread" "")
7829 (if (and group
7830 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7831 (format " (Type %s for %s [%s])"
7832 (single-key-description cmd)
7833 (gnus-group-decoded-name group)
7834 (gnus-group-unread group))
7835 (format " (Type %s to exit %s)"
7836 (single-key-description cmd)
7837 (gnus-group-decoded-name gnus-newsgroup-name)))))
7838 ;; Confirm auto selection.
7839 (setq key (car (setq keve (gnus-read-event-char prompt)))
7840 ended t)
7841 (cond
7842 ((assq key keystrokes)
7843 (let ((obuf (current-buffer)))
7844 (switch-to-buffer gnus-group-buffer)
7845 (when group
7846 (gnus-group-jump-to-group group))
7847 (eval (cadr (assq key keystrokes)))
7848 (setq group (gnus-group-group-name))
7849 (switch-to-buffer obuf))
7850 (setq ended nil))
7851 ((equal key cmd)
7852 (if (or (not group)
7853 (gnus-ephemeral-group-p gnus-newsgroup-name))
7854 (gnus-summary-exit)
7855 (gnus-summary-next-group nil group backward)))
7857 (push (cdr keve) unread-command-events))))))
7859 (defun gnus-summary-next-unread-article ()
7860 "Select unread article after current one."
7861 (interactive)
7862 (gnus-summary-next-article
7863 (or (not (eq gnus-summary-goto-unread 'never))
7864 (gnus-summary-last-article-p (gnus-summary-article-number)))
7865 (and gnus-auto-select-same
7866 (gnus-summary-article-subject))))
7868 (defun gnus-summary-prev-article (&optional unread subject)
7869 "Select the article before the current one.
7870 If UNREAD is non-nil, only unread articles are selected."
7871 (interactive "P")
7872 (gnus-summary-next-article unread subject t))
7874 (defun gnus-summary-prev-unread-article ()
7875 "Select unread article before current one."
7876 (interactive)
7877 (gnus-summary-prev-article
7878 (or (not (eq gnus-summary-goto-unread 'never))
7879 (gnus-summary-first-article-p (gnus-summary-article-number)))
7880 (and gnus-auto-select-same
7881 (gnus-summary-article-subject))))
7883 (declare-function gnus-article-only-boring-p "gnus-art" ())
7885 (defun gnus-summary-next-page (&optional lines circular stop)
7886 "Show next page of the selected article.
7887 If at the end of the current article, select the next article.
7888 LINES says how many lines should be scrolled up.
7890 If CIRCULAR is non-nil, go to the start of the article instead of
7891 selecting the next article when reaching the end of the current
7892 article.
7894 If STOP is non-nil, just stop when reaching the end of the message.
7896 Also see the variable `gnus-article-skip-boring'."
7897 (interactive "P")
7898 (gnus-set-global-variables)
7899 (let ((article (gnus-summary-article-number))
7900 (article-window (get-buffer-window gnus-article-buffer t))
7901 endp)
7902 ;; If the buffer is empty, we have no article.
7903 (unless article
7904 (error "No article to select"))
7905 (gnus-configure-windows 'article)
7906 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7907 (if (and (eq gnus-summary-goto-unread 'never)
7908 (not (gnus-summary-last-article-p article)))
7909 (gnus-summary-next-article)
7910 (gnus-summary-next-unread-article))
7911 (if (or (null gnus-current-article)
7912 (null gnus-article-current)
7913 (/= article (cdr gnus-article-current))
7914 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7915 ;; Selected subject is different from current article's.
7916 (gnus-summary-display-article article)
7917 (when article-window
7918 (gnus-eval-in-buffer-window gnus-article-buffer
7919 (setq endp (or (gnus-article-next-page lines)
7920 (gnus-article-only-boring-p))))
7921 (when endp
7922 (cond ((or stop gnus-summary-stop-at-end-of-message)
7923 (gnus-message 3 "End of message"))
7924 (circular
7925 (gnus-summary-beginning-of-article))
7926 (lines
7927 (gnus-message 3 "End of message"))
7928 ((null lines)
7929 (if (and (eq gnus-summary-goto-unread 'never)
7930 (not (gnus-summary-last-article-p article)))
7931 (gnus-summary-next-article)
7932 (gnus-summary-next-unread-article))))))))
7933 (gnus-summary-recenter)
7934 (gnus-summary-position-point)))
7936 (defun gnus-summary-prev-page (&optional lines move)
7937 "Show previous page of selected article.
7938 Argument LINES specifies lines to be scrolled down.
7939 If MOVE, move to the previous unread article if point is at
7940 the beginning of the buffer."
7941 (interactive "P")
7942 (let ((article (gnus-summary-article-number))
7943 (article-window (get-buffer-window gnus-article-buffer t))
7944 endp)
7945 (gnus-configure-windows 'article)
7946 (if (or (null gnus-current-article)
7947 (null gnus-article-current)
7948 (/= article (cdr gnus-article-current))
7949 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7950 ;; Selected subject is different from current article's.
7951 (gnus-summary-display-article article)
7952 (gnus-summary-recenter)
7953 (when article-window
7954 (gnus-eval-in-buffer-window gnus-article-buffer
7955 (setq endp (gnus-article-prev-page lines)))
7956 (when (and move endp)
7957 (cond (lines
7958 (gnus-message 3 "Beginning of message"))
7959 ((null lines)
7960 (if (and (eq gnus-summary-goto-unread 'never)
7961 (not (gnus-summary-first-article-p article)))
7962 (gnus-summary-prev-article)
7963 (gnus-summary-prev-unread-article))))))))
7964 (gnus-summary-position-point))
7966 (defun gnus-summary-prev-page-or-article (&optional lines)
7967 "Show previous page of selected article.
7968 Argument LINES specifies lines to be scrolled down.
7969 If at the beginning of the article, go to the next article."
7970 (interactive "P")
7971 (gnus-summary-prev-page lines t))
7973 (defun gnus-summary-scroll-up (lines)
7974 "Scroll up (or down) one line current article.
7975 Argument LINES specifies lines to be scrolled up (or down if negative).
7976 If no article is selected, then the current article will be selected first."
7977 (interactive "p")
7978 (gnus-configure-windows 'article)
7979 (gnus-summary-show-thread)
7980 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7981 (gnus-eval-in-buffer-window gnus-article-buffer
7982 (cond ((> lines 0)
7983 (when (gnus-article-next-page lines)
7984 (gnus-message 3 "End of message")))
7985 ((< lines 0)
7986 (gnus-article-prev-page (- lines))))))
7987 (gnus-summary-recenter)
7988 (gnus-summary-position-point))
7990 (defun gnus-summary-scroll-down (lines)
7991 "Scroll down (or up) one line current article.
7992 Argument LINES specifies lines to be scrolled down (or up if negative).
7993 If no article is selected, then the current article will be selected first."
7994 (interactive "p")
7995 (gnus-summary-scroll-up (- lines)))
7997 (defun gnus-summary-next-same-subject ()
7998 "Select next article which has the same subject as current one."
7999 (interactive)
8000 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8002 (defun gnus-summary-prev-same-subject ()
8003 "Select previous article which has the same subject as current one."
8004 (interactive)
8005 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8007 (defun gnus-summary-next-unread-same-subject ()
8008 "Select next unread article which has the same subject as current one."
8009 (interactive)
8010 (gnus-summary-next-article t (gnus-summary-article-subject)))
8012 (defun gnus-summary-prev-unread-same-subject ()
8013 "Select previous unread article which has the same subject as current one."
8014 (interactive)
8015 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8017 (defun gnus-summary-first-unread-article ()
8018 "Select the first unread article.
8019 Return nil if there are no unread articles."
8020 (interactive)
8021 (prog1
8022 (when (gnus-summary-first-subject t)
8023 (gnus-summary-show-thread)
8024 (gnus-summary-first-subject t)
8025 (gnus-summary-display-article (gnus-summary-article-number)))
8026 (gnus-summary-position-point)))
8028 (defun gnus-summary-first-unread-subject ()
8029 "Place the point on the subject line of the first unread article.
8030 Return nil if there are no unread articles."
8031 (interactive)
8032 (prog1
8033 (when (gnus-summary-first-subject t)
8034 (gnus-summary-show-thread)
8035 (gnus-summary-first-subject t))
8036 (gnus-summary-position-point)))
8038 (defun gnus-summary-first-unseen-subject ()
8039 "Place the point on the subject line of the first unseen article.
8040 Return nil if there are no unseen articles."
8041 (interactive)
8042 (prog1
8043 (when (gnus-summary-first-subject nil nil t)
8044 (gnus-summary-show-thread)
8045 (gnus-summary-first-subject nil nil t))
8046 (gnus-summary-position-point)))
8048 (defun gnus-summary-first-unseen-or-unread-subject ()
8049 "Place the point on the subject line of the first unseen and unread article.
8050 If all article have been seen, on the subject line of the first unread
8051 article."
8052 (interactive)
8053 (prog1
8054 (unless (when (gnus-summary-first-subject nil nil t)
8055 (gnus-summary-show-thread)
8056 (gnus-summary-first-subject nil nil t))
8057 (when (gnus-summary-first-subject t)
8058 (gnus-summary-show-thread)
8059 (gnus-summary-first-subject t)))
8060 (gnus-summary-position-point)))
8062 (defun gnus-summary-first-article ()
8063 "Select the first article.
8064 Return nil if there are no articles."
8065 (interactive)
8066 (prog1
8067 (when (gnus-summary-first-subject)
8068 (gnus-summary-show-thread)
8069 (gnus-summary-first-subject)
8070 (gnus-summary-display-article (gnus-summary-article-number)))
8071 (gnus-summary-position-point)))
8073 (defun gnus-summary-best-unread-article (&optional arg)
8074 "Select the unread article with the highest score.
8075 If given a prefix argument, select the next unread article that has a
8076 score higher than the default score."
8077 (interactive "P")
8078 (let ((article (if arg
8079 (gnus-summary-better-unread-subject)
8080 (gnus-summary-best-unread-subject))))
8081 (if article
8082 (gnus-summary-goto-article article)
8083 (error "No unread articles"))))
8085 (defun gnus-summary-best-unread-subject ()
8086 "Select the unread subject with the highest score."
8087 (interactive)
8088 (let ((best -1000000)
8089 (data gnus-newsgroup-data)
8090 article score)
8091 (while data
8092 (and (gnus-data-unread-p (car data))
8093 (> (setq score
8094 (gnus-summary-article-score (gnus-data-number (car data))))
8095 best)
8096 (setq best score
8097 article (gnus-data-number (car data))))
8098 (setq data (cdr data)))
8099 (when article
8100 (gnus-summary-goto-subject article))
8101 (gnus-summary-position-point)
8102 article))
8104 (defun gnus-summary-better-unread-subject ()
8105 "Select the first unread subject that has a score over the default score."
8106 (interactive)
8107 (let ((data gnus-newsgroup-data)
8108 article score)
8109 (while (and (setq article (gnus-data-number (car data)))
8110 (or (gnus-data-read-p (car data))
8111 (not (> (gnus-summary-article-score article)
8112 gnus-summary-default-score))))
8113 (setq data (cdr data)))
8114 (when article
8115 (gnus-summary-goto-subject article))
8116 (gnus-summary-position-point)
8117 article))
8119 (defun gnus-summary-last-subject ()
8120 "Go to the last displayed subject line in the group."
8121 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8122 (when article
8123 (gnus-summary-goto-subject article))))
8125 (defun gnus-summary-goto-article (article &optional all-headers force)
8126 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8127 If ALL-HEADERS is non-nil, no header lines are hidden.
8128 If FORCE, go to the article even if it isn't displayed. If FORCE
8129 is a number, it is the line the article is to be displayed on."
8130 (interactive
8131 (list
8132 (gnus-completing-read
8133 "Article number or Message-ID"
8134 (mapcar 'int-to-string gnus-newsgroup-limit))
8135 current-prefix-arg
8137 (prog1
8138 (if (and (stringp article)
8139 (string-match "@\\|%40" article))
8140 (gnus-summary-refer-article article)
8141 (when (stringp article)
8142 (setq article (string-to-number article)))
8143 (if (gnus-summary-goto-subject article force)
8144 (gnus-summary-display-article article all-headers)
8145 (gnus-message 4 "Couldn't go to article %s" article) nil))
8146 (gnus-summary-position-point)))
8148 (defun gnus-summary-goto-last-article ()
8149 "Go to the previously read article."
8150 (interactive)
8151 (prog1
8152 (when gnus-last-article
8153 (gnus-summary-goto-article gnus-last-article nil t))
8154 (gnus-summary-position-point)))
8156 (defun gnus-summary-pop-article (number)
8157 "Pop one article off the history and go to the previous.
8158 NUMBER articles will be popped off."
8159 (interactive "p")
8160 (let (to)
8161 (setq gnus-newsgroup-history
8162 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8163 (if to
8164 (gnus-summary-goto-article (car to) nil t)
8165 (error "Article history empty")))
8166 (gnus-summary-position-point))
8168 ;; Summary commands and functions for limiting the summary buffer.
8170 (defun gnus-summary-limit-to-articles (n)
8171 "Limit the summary buffer to the next N articles.
8172 If not given a prefix, use the process marked articles instead."
8173 (interactive "P")
8174 (prog1
8175 (let ((articles (gnus-summary-work-articles n)))
8176 (setq gnus-newsgroup-processable nil)
8177 (gnus-summary-limit articles))
8178 (gnus-summary-position-point)))
8180 (defun gnus-summary-pop-limit (&optional total)
8181 "Restore the previous limit.
8182 If given a prefix, remove all limits."
8183 (interactive "P")
8184 (when total
8185 (setq gnus-newsgroup-limits
8186 (list (mapcar (lambda (h) (mail-header-number h))
8187 gnus-newsgroup-headers))))
8188 (unless gnus-newsgroup-limits
8189 (error "No limit to pop"))
8190 (prog1
8191 (gnus-summary-limit nil 'pop)
8192 (gnus-summary-position-point)))
8194 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8195 "Limit the summary buffer to articles that have subjects that match a regexp.
8196 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8197 (interactive
8198 (list (read-string (if current-prefix-arg
8199 "Exclude subject (regexp): "
8200 "Limit to subject (regexp): "))
8201 nil current-prefix-arg))
8202 (unless header
8203 (setq header "subject"))
8204 (when (not (equal "" subject))
8205 (prog1
8206 (let ((articles (gnus-summary-find-matching
8207 (or header "subject") subject 'all nil nil
8208 not-matching)))
8209 (unless articles
8210 (error "Found no matches for \"%s\"" subject))
8211 (gnus-summary-limit articles))
8212 (gnus-summary-position-point))))
8214 (defun gnus-summary-limit-to-author (from &optional not-matching)
8215 "Limit the summary buffer to articles that have authors that match a regexp.
8216 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8217 (interactive
8218 (list (let* ((header (gnus-summary-article-header))
8219 (default (and header (car (mail-header-parse-address
8220 (mail-header-from header))))))
8221 (read-string (concat (if current-prefix-arg
8222 "Exclude author (regexp"
8223 "Limit to author (regexp")
8224 (if default
8225 (concat ", default \"" default "\"): ")
8226 "): "))
8227 nil nil
8228 default))
8229 current-prefix-arg))
8230 (gnus-summary-limit-to-subject from "from" not-matching))
8232 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8233 "Limit the summary buffer to articles with the given RECIPIENT.
8235 If NOT-MATCHING, exclude RECIPIENT.
8237 To and Cc headers are checked. You need to include them in
8238 `nnmail-extra-headers'."
8239 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8240 (interactive
8241 (list (read-string (format "%s recipient (regexp): "
8242 (if current-prefix-arg "Exclude" "Limit to")))
8243 current-prefix-arg))
8244 (when (not (equal "" recipient))
8245 (prog1 (let* ((to
8246 (if (memq 'To nnmail-extra-headers)
8247 (gnus-summary-find-matching
8248 (cons 'extra 'To) recipient 'all nil nil
8249 not-matching)
8250 (gnus-message
8251 1 "`To' isn't present in `nnmail-extra-headers'")
8252 (sit-for 1)
8253 nil))
8255 (if (memq 'Cc nnmail-extra-headers)
8256 (gnus-summary-find-matching
8257 (cons 'extra 'Cc) recipient 'all nil nil
8258 not-matching)
8259 (gnus-message
8260 1 "`Cc' isn't present in `nnmail-extra-headers'")
8261 (sit-for 1)
8262 nil))
8263 (articles
8264 (if not-matching
8265 ;; We need the numbers that are in both lists:
8266 (mapcar (lambda (a)
8267 (and (memq a to) a))
8269 (nconc to cc))))
8270 (unless articles
8271 (error "Found no matches for \"%s\"" recipient))
8272 (gnus-summary-limit articles))
8273 (gnus-summary-position-point))))
8275 (defun gnus-summary-limit-to-address (address &optional not-matching)
8276 "Limit the summary buffer to articles with the given ADDRESS.
8278 If NOT-MATCHING, exclude ADDRESS.
8280 To, Cc and From headers are checked. You need to include `To' and `Cc'
8281 in `nnmail-extra-headers'."
8282 (interactive
8283 (list (read-string (format "%s address (regexp): "
8284 (if current-prefix-arg "Exclude" "Limit to")))
8285 current-prefix-arg))
8286 (when (not (equal "" address))
8287 (prog1 (let* ((to
8288 (if (memq 'To nnmail-extra-headers)
8289 (gnus-summary-find-matching
8290 (cons 'extra 'To) address 'all nil nil
8291 not-matching)
8292 (gnus-message
8293 1 "`To' isn't present in `nnmail-extra-headers'")
8294 (sit-for 1)
8297 (if (memq 'Cc nnmail-extra-headers)
8298 (gnus-summary-find-matching
8299 (cons 'extra 'Cc) address 'all nil nil
8300 not-matching)
8301 (gnus-message
8302 1 "`Cc' isn't present in `nnmail-extra-headers'")
8303 (sit-for 1)
8305 (from
8306 (gnus-summary-find-matching "from" address
8307 'all nil nil not-matching))
8308 (articles
8309 (if not-matching
8310 ;; We need the numbers that are in all lists:
8311 (if (eq cc t)
8312 (if (eq to t)
8313 from
8314 (mapcar (lambda (a) (car (memq a from))) to))
8315 (if (eq to t)
8316 (mapcar (lambda (a) (car (memq a from))) cc)
8317 (mapcar (lambda (a) (car (memq a from)))
8318 (mapcar (lambda (a) (car (memq a to)))
8319 cc))))
8320 (nconc (if (eq to t) nil to)
8321 (if (eq cc t) nil cc)
8322 from))))
8323 (unless articles
8324 (error "Found no matches for \"%s\"" address))
8325 (gnus-summary-limit articles))
8326 (gnus-summary-position-point))))
8328 (defun gnus-summary-limit-strange-charsets-predicate (header)
8329 (let ((string (concat (mail-header-subject header)
8330 (mail-header-from header)))
8331 charset found)
8332 (dotimes (i (1- (length string)))
8333 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8334 (when (string-match "unicode\\|big\\|japanese" charset)
8335 (setq found t)))
8336 found))
8338 (defun gnus-summary-limit-to-predicate (predicate)
8339 "Limit to articles where PREDICATE returns non-nil.
8340 PREDICATE will be called with the header structures of the
8341 articles."
8342 (let ((articles nil)
8343 (case-fold-search t))
8344 (dolist (header gnus-newsgroup-headers)
8345 (when (funcall predicate header)
8346 (push (mail-header-number header) articles)))
8347 (gnus-summary-limit (nreverse articles))))
8349 (defun gnus-summary-limit-to-age (age &optional younger-p)
8350 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8351 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8352 articles that are younger than AGE days."
8353 (interactive
8354 (let ((younger current-prefix-arg)
8355 (days-got nil)
8356 days)
8357 (while (not days-got)
8358 (setq days (if younger
8359 (read-string "Limit to articles younger than (in days, older when negative): ")
8360 (read-string
8361 "Limit to articles older than (in days, younger when negative): ")))
8362 (when (> (length days) 0)
8363 (setq days (read days)))
8364 (if (numberp days)
8365 (progn
8366 (setq days-got t)
8367 (when (< days 0)
8368 (setq younger (not younger))
8369 (setq days (* days -1))))
8370 (message "Please enter a number.")
8371 (sleep-for 1)))
8372 (list days younger)))
8373 (prog1
8374 (let ((data gnus-newsgroup-data)
8375 (cutoff (days-to-time age))
8376 articles d date is-younger)
8377 (while (setq d (pop data))
8378 (when (and (vectorp (gnus-data-header d))
8379 (setq date (mail-header-date (gnus-data-header d))))
8380 (setq is-younger (time-less-p
8381 (time-since (gnus-date-get-time date))
8382 cutoff))
8383 (when (if younger-p
8384 is-younger
8385 (not is-younger))
8386 (push (gnus-data-number d) articles))))
8387 (gnus-summary-limit (nreverse articles)))
8388 (gnus-summary-position-point)))
8390 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8391 "Limit the summary buffer to articles that match an `extra' header."
8392 (interactive
8393 (let ((header
8394 (intern
8395 (gnus-completing-read
8396 (if current-prefix-arg
8397 "Exclude extra header"
8398 "Limit extra header")
8399 (mapcar 'symbol-name gnus-extra-headers)
8400 t nil nil
8401 (symbol-name (car gnus-extra-headers))))))
8402 (list header
8403 (read-string (format "%s header %s (regexp): "
8404 (if current-prefix-arg "Exclude" "Limit to")
8405 header))
8406 current-prefix-arg)))
8407 (when (not (equal "" regexp))
8408 (prog1
8409 (let ((articles (gnus-summary-find-matching
8410 (cons 'extra header) regexp 'all nil nil
8411 not-matching)))
8412 (unless articles
8413 (error "Found no matches for \"%s\"" regexp))
8414 (gnus-summary-limit articles))
8415 (gnus-summary-position-point))))
8417 (defun gnus-summary-limit-to-display-predicate ()
8418 "Limit the summary buffer to the predicated in the `display' group parameter."
8419 (interactive)
8420 (unless gnus-newsgroup-display
8421 (error "There is no `display' group parameter"))
8422 (let (articles)
8423 (dolist (gnus-number gnus-newsgroup-articles)
8424 (when (funcall gnus-newsgroup-display)
8425 (push gnus-number articles)))
8426 (gnus-summary-limit articles))
8427 (gnus-summary-position-point))
8429 (defun gnus-summary-limit-to-unread (&optional all)
8430 "Limit the summary buffer to articles that are not marked as read.
8431 If ALL is non-nil, limit strictly to unread articles."
8432 (interactive "P")
8433 (if all
8434 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8435 (gnus-summary-limit-to-marks
8436 ;; Concat all the marks that say that an article is read and have
8437 ;; those removed.
8438 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8439 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8440 gnus-low-score-mark gnus-expirable-mark
8441 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8442 gnus-duplicate-mark)
8443 'reverse)))
8445 (defun gnus-summary-limit-to-headers (match &optional reverse)
8446 "Limit the summary buffer to articles that have headers that match MATCH.
8447 If REVERSE (the prefix), limit to articles that don't match."
8448 (interactive "sMatch headers (regexp): \nP")
8449 (gnus-summary-limit-to-bodies match reverse t))
8451 (declare-function article-goto-body "gnus-art" ())
8453 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8454 "Limit the summary buffer to articles that have bodies that match MATCH.
8455 If REVERSE (the prefix), limit to articles that don't match."
8456 (interactive "sMatch body (regexp): \nP")
8457 (let ((articles nil)
8458 (gnus-select-article-hook nil) ;Disable hook.
8459 (gnus-article-prepare-hook nil)
8460 (gnus-use-article-prefetch nil)
8461 (gnus-keep-backlog nil)
8462 (gnus-break-pages nil)
8463 (gnus-summary-display-arrow nil)
8464 (gnus-updated-mode-lines nil)
8465 (gnus-auto-center-summary nil)
8466 (gnus-display-mime-function nil))
8467 (dolist (data gnus-newsgroup-data)
8468 (let (gnus-mark-article-hook)
8469 (gnus-summary-select-article t t nil (gnus-data-number data)))
8470 (with-current-buffer gnus-article-buffer
8471 (article-goto-body)
8472 (let* ((case-fold-search t)
8473 (found (if headersp
8474 (re-search-backward match nil t)
8475 (re-search-forward match nil t))))
8476 (when (or (and found
8477 (not reverse))
8478 (and (not found)
8479 reverse))
8480 (push (gnus-data-number data) articles)))))
8481 (if (not articles)
8482 (message "No messages matched")
8483 (gnus-summary-limit articles)))
8484 (gnus-summary-position-point))
8486 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8487 "Limit the summary buffer to articles that aren't part on any thread.
8488 If THREADSP (the prefix), limit to articles that are in threads."
8489 (interactive "P")
8490 (let ((articles nil)
8491 thread-articles
8492 threads)
8493 (dolist (thread gnus-newsgroup-threads)
8494 (if (stringp (car thread))
8495 (dolist (thread (cdr thread))
8496 (push thread threads))
8497 (push thread threads)))
8498 (dolist (thread threads)
8499 (setq thread-articles (gnus-articles-in-thread thread))
8500 (when (or (and threadsp
8501 (> (length thread-articles) 1))
8502 (and (not threadsp)
8503 (= (length thread-articles) 1)))
8504 (setq articles (nconc thread-articles articles))))
8505 (if (not articles)
8506 (message "No messages matched")
8507 (gnus-summary-limit articles))
8508 (gnus-summary-position-point)))
8510 (defun gnus-summary-limit-to-replied (&optional unreplied)
8511 "Limit the summary buffer to replied articles.
8512 If UNREPLIED (the prefix), limit to unreplied articles."
8513 (interactive "P")
8514 (if unreplied
8515 (gnus-summary-limit
8516 (gnus-set-difference gnus-newsgroup-articles
8517 gnus-newsgroup-replied))
8518 (gnus-summary-limit gnus-newsgroup-replied))
8519 (gnus-summary-position-point))
8521 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8522 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8523 If REVERSE, limit the summary buffer to articles that are marked
8524 with MARKS. MARKS can either be a string of marks or a list of marks.
8525 Returns how many articles were removed."
8526 (interactive "sMarks: ")
8527 (gnus-summary-limit-to-marks marks t))
8529 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8530 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8531 If REVERSE (the prefix), limit the summary buffer to articles that are
8532 not marked with MARKS. MARKS can either be a string of marks or a
8533 list of marks.
8534 Returns how many articles were removed."
8535 (interactive "sMarks: \nP")
8536 (prog1
8537 (let ((data gnus-newsgroup-data)
8538 (marks (if (listp marks) marks
8539 (append marks nil))) ; Transform to list.
8540 articles)
8541 (while data
8542 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8543 (memq (gnus-data-mark (car data)) marks))
8544 (push (gnus-data-number (car data)) articles))
8545 (setq data (cdr data)))
8546 (gnus-summary-limit articles))
8547 (gnus-summary-position-point)))
8549 (defun gnus-summary-limit-to-score (score)
8550 "Limit to articles with score at or above SCORE."
8551 (interactive "NLimit to articles with score of at least: ")
8552 (let ((data gnus-newsgroup-data)
8553 articles)
8554 (while data
8555 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8556 score)
8557 (push (gnus-data-number (car data)) articles))
8558 (setq data (cdr data)))
8559 (prog1
8560 (gnus-summary-limit articles)
8561 (gnus-summary-position-point))))
8563 (defun gnus-summary-limit-to-unseen ()
8564 "Limit to unseen articles."
8565 (interactive)
8566 (prog1
8567 (gnus-summary-limit gnus-newsgroup-unseen)
8568 (gnus-summary-position-point)))
8570 (defun gnus-summary-limit-include-thread (id)
8571 "Display all the hidden articles that is in the thread with ID in it.
8572 When called interactively, ID is the Message-ID of the current
8573 article."
8574 (interactive (list (mail-header-id (gnus-summary-article-header))))
8575 (let ((articles (gnus-articles-in-thread
8576 (gnus-id-to-thread (gnus-root-id id))))
8577 ;;we REALLY want the whole thread---this prevents cut-threads
8578 ;;from removing the thread we want to include.
8579 (gnus-fetch-old-headers nil)
8580 (gnus-build-sparse-threads nil))
8581 (prog1
8582 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8583 (gnus-summary-limit-include-matching-articles
8584 "subject"
8585 (regexp-quote (gnus-simplify-subject-re
8586 (mail-header-subject (gnus-id-to-header id)))))
8587 (gnus-summary-position-point))))
8589 (defun gnus-summary-limit-include-matching-articles (header regexp)
8590 "Display all the hidden articles that have HEADERs that match REGEXP."
8591 (interactive (list (read-string "Match on header: ")
8592 (read-string "Regexp: ")))
8593 (let ((articles (gnus-find-matching-articles header regexp)))
8594 (prog1
8595 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8596 (gnus-summary-position-point))))
8598 (defun gnus-summary-insert-dormant-articles ()
8599 "Insert all the dormant articles for this group into the current buffer."
8600 (interactive)
8601 (let ((gnus-verbose (max 6 gnus-verbose)))
8602 (if (not gnus-newsgroup-dormant)
8603 (gnus-message 3 "No dormant articles for this group")
8604 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8606 (defun gnus-summary-insert-ticked-articles ()
8607 "Insert ticked articles for this group into the current buffer."
8608 (interactive)
8609 (let ((gnus-verbose (max 6 gnus-verbose)))
8610 (if (not gnus-newsgroup-marked)
8611 (gnus-message 3 "No ticked articles for this group")
8612 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8614 (defun gnus-summary-limit-include-dormant ()
8615 "Display all the hidden articles that are marked as dormant.
8616 Note that this command only works on a subset of the articles currently
8617 fetched for this group."
8618 (interactive)
8619 (unless gnus-newsgroup-dormant
8620 (error "There are no dormant articles in this group"))
8621 (prog1
8622 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8623 (gnus-summary-position-point)))
8625 (defun gnus-summary-include-articles (articles)
8626 "Fetch the headers for ARTICLES and then display the summary lines."
8627 (let ((gnus-inhibit-demon t)
8628 (gnus-agent nil)
8629 (gnus-read-all-available-headers t))
8630 (setq gnus-newsgroup-headers
8631 (cl-merge
8632 'list gnus-newsgroup-headers
8633 (gnus-fetch-headers articles nil t)
8634 'gnus-article-sort-by-number))
8635 (setq gnus-newsgroup-articles
8636 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8637 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8639 (defun gnus-summary-limit-exclude-dormant ()
8640 "Hide all dormant articles."
8641 (interactive)
8642 (prog1
8643 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8644 (gnus-summary-position-point)))
8646 (defun gnus-summary-limit-exclude-childless-dormant ()
8647 "Hide all dormant articles that have no children."
8648 (interactive)
8649 (let ((data (gnus-data-list t))
8650 articles d children)
8651 ;; Find all articles that are either not dormant or have
8652 ;; children.
8653 (while (setq d (pop data))
8654 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8655 (and (setq children
8656 (gnus-article-children (gnus-data-number d)))
8657 (let (found)
8658 (while children
8659 (when (memq (car children) articles)
8660 (setq children nil
8661 found t))
8662 (pop children))
8663 found)))
8664 (push (gnus-data-number d) articles)))
8665 ;; Do the limiting.
8666 (prog1
8667 (gnus-summary-limit articles)
8668 (gnus-summary-position-point))))
8670 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8671 "Mark all unread excluded articles as read.
8672 If ALL, mark even excluded ticked and dormants as read."
8673 (interactive "P")
8674 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8675 (let ((articles (gnus-sorted-ndifference
8676 (sort
8677 (mapcar (lambda (h) (mail-header-number h))
8678 gnus-newsgroup-headers)
8680 gnus-newsgroup-limit))
8681 article)
8682 (setq gnus-newsgroup-unreads
8683 (gnus-sorted-intersection gnus-newsgroup-unreads
8684 gnus-newsgroup-limit))
8685 (if all
8686 (setq gnus-newsgroup-dormant nil
8687 gnus-newsgroup-marked nil
8688 gnus-newsgroup-reads
8689 (nconc
8690 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8691 gnus-newsgroup-reads))
8692 (while (setq article (pop articles))
8693 (unless (or (memq article gnus-newsgroup-dormant)
8694 (memq article gnus-newsgroup-marked))
8695 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8697 (defun gnus-summary-limit (articles &optional pop)
8698 (if pop
8699 ;; We pop the previous limit off the stack and use that.
8700 (setq articles (car gnus-newsgroup-limits)
8701 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8702 ;; We use the new limit, so we push the old limit on the stack.
8703 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8704 ;; Set the limit.
8705 (setq gnus-newsgroup-limit articles)
8706 (let ((total (length gnus-newsgroup-data))
8707 (data (gnus-data-find-list (gnus-summary-article-number)))
8708 (gnus-summary-mark-below nil) ; Inhibit this.
8709 found)
8710 ;; This will do all the work of generating the new summary buffer
8711 ;; according to the new limit.
8712 (gnus-summary-prepare)
8713 ;; Hide any threads, possibly.
8714 (gnus-summary-maybe-hide-threads)
8715 ;; Try to return to the article you were at, or one in the
8716 ;; neighborhood.
8717 (when data
8718 ;; We try to find some article after the current one.
8719 (while data
8720 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8721 (setq data nil
8722 found t))
8723 (setq data (cdr data))))
8724 (unless found
8725 ;; If there is no data, that means that we were after the last
8726 ;; article. The same goes when we can't find any articles
8727 ;; after the current one.
8728 (goto-char (point-max))
8729 (gnus-summary-find-prev))
8730 (gnus-set-mode-line 'summary)
8731 ;; We return how many articles were removed from the summary
8732 ;; buffer as a result of the new limit.
8733 (- total (length gnus-newsgroup-data))))
8735 (defsubst gnus-invisible-cut-children (threads)
8736 (let ((num 0))
8737 (while threads
8738 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8739 (incf num))
8740 (pop threads))
8741 (< num 2)))
8743 (defsubst gnus-cut-thread (thread)
8744 "Go forwards in the thread until we find an article that we want to display."
8745 (when (or (eq gnus-fetch-old-headers 'some)
8746 (eq gnus-fetch-old-headers 'invisible)
8747 (numberp gnus-fetch-old-headers)
8748 (eq gnus-build-sparse-threads 'some)
8749 (eq gnus-build-sparse-threads 'more))
8750 ;; Deal with old-fetched headers and sparse threads.
8751 (while (and
8752 thread
8754 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8755 (gnus-summary-article-ancient-p
8756 (mail-header-number (car thread))))
8757 (if (or (<= (length (cdr thread)) 1)
8758 (eq gnus-fetch-old-headers 'invisible))
8759 (setq gnus-newsgroup-limit
8760 (delq (mail-header-number (car thread))
8761 gnus-newsgroup-limit)
8762 thread (cadr thread))
8763 (when (gnus-invisible-cut-children (cdr thread))
8764 (let ((th (cdr thread)))
8765 (while th
8766 (if (memq (mail-header-number (caar th))
8767 gnus-newsgroup-limit)
8768 (setq thread (car th)
8769 th nil)
8770 (setq th (cdr th))))))))))
8771 thread)
8773 (defun gnus-cut-threads (threads)
8774 "Cut off all uninteresting articles from the beginning of THREADS."
8775 (when (or (eq gnus-fetch-old-headers 'some)
8776 (eq gnus-fetch-old-headers 'invisible)
8777 (numberp gnus-fetch-old-headers)
8778 (eq gnus-build-sparse-threads 'some)
8779 (eq gnus-build-sparse-threads 'more))
8780 (let ((th threads))
8781 (while th
8782 (setcar th (gnus-cut-thread (car th)))
8783 (setq th (cdr th)))))
8784 ;; Remove nixed out threads.
8785 (delq nil threads))
8787 (defun gnus-summary-initial-limit (&optional show-if-empty)
8788 "Figure out what the initial limit is supposed to be on group entry.
8789 This entails weeding out unwanted dormants, low-scored articles,
8790 fetch-old-headers verbiage, and so on."
8791 ;; Most groups have nothing to remove.
8792 (unless (or gnus-inhibit-limiting
8793 (and (null gnus-newsgroup-dormant)
8794 (eq gnus-newsgroup-display 'gnus-not-ignore)
8795 (not (eq gnus-fetch-old-headers 'some))
8796 (not (numberp gnus-fetch-old-headers))
8797 (not (eq gnus-fetch-old-headers 'invisible))
8798 (null gnus-summary-expunge-below)
8799 (not (eq gnus-build-sparse-threads 'some))
8800 (not (eq gnus-build-sparse-threads 'more))
8801 (null gnus-thread-expunge-below)))
8802 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8803 (setq gnus-newsgroup-limit nil)
8804 (mapatoms
8805 (lambda (node)
8806 (unless (car (symbol-value node))
8807 ;; These threads have no parents -- they are roots.
8808 (let ((nodes (cdr (symbol-value node)))
8809 thread)
8810 (while nodes
8811 (if (and gnus-thread-expunge-below
8812 (< (gnus-thread-total-score (car nodes))
8813 gnus-thread-expunge-below))
8814 (gnus-expunge-thread (pop nodes))
8815 (setq thread (pop nodes))
8816 (gnus-summary-limit-children thread))))))
8817 gnus-newsgroup-dependencies)
8818 ;; If this limitation resulted in an empty group, we might
8819 ;; pop the previous limit and use it instead.
8820 (when (and (not gnus-newsgroup-limit)
8821 show-if-empty)
8822 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8823 gnus-newsgroup-limit))
8825 (defun gnus-summary-limit-children (thread)
8826 "Return 1 if this subthread is visible and 0 if it is not."
8827 ;; First we get the number of visible children to this thread. This
8828 ;; is done by recursing down the thread using this function, so this
8829 ;; will really go down to a leaf article first, before slowly
8830 ;; working its way up towards the root.
8831 (when thread
8832 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8833 (children
8834 (if (cdr thread)
8835 (apply '+ (mapcar 'gnus-summary-limit-children
8836 (cdr thread)))
8838 (number (mail-header-number (car thread)))
8839 score)
8840 (if (and
8841 (not (memq number gnus-newsgroup-marked))
8843 ;; If this article is dormant and has absolutely no visible
8844 ;; children, then this article isn't visible.
8845 (and (memq number gnus-newsgroup-dormant)
8846 (zerop children))
8847 ;; If this is "fetch-old-headered" and there is no
8848 ;; visible children, then we don't want this article.
8849 (and (or (eq gnus-fetch-old-headers 'some)
8850 (numberp gnus-fetch-old-headers))
8851 (gnus-summary-article-ancient-p number)
8852 (zerop children))
8853 ;; If this is "fetch-old-headered" and `invisible', then
8854 ;; we don't want this article.
8855 (and (eq gnus-fetch-old-headers 'invisible)
8856 (gnus-summary-article-ancient-p number))
8857 ;; If this is a sparsely inserted article with no children,
8858 ;; we don't want it.
8859 (and (eq gnus-build-sparse-threads 'some)
8860 (gnus-summary-article-sparse-p number)
8861 (zerop children))
8862 ;; If we use expunging, and this article is really
8863 ;; low-scored, then we don't want this article.
8864 (when (and gnus-summary-expunge-below
8865 (< (setq score
8866 (or (cdr (assq number gnus-newsgroup-scored))
8867 gnus-summary-default-score))
8868 gnus-summary-expunge-below))
8869 ;; We increase the expunge-tally here, but that has
8870 ;; nothing to do with the limits, really.
8871 (incf gnus-newsgroup-expunged-tally)
8872 ;; We also mark as read here, if that's wanted.
8873 (when (and gnus-summary-mark-below
8874 (< score gnus-summary-mark-below))
8875 (setq gnus-newsgroup-unreads
8876 (delq number gnus-newsgroup-unreads))
8877 (if gnus-newsgroup-auto-expire
8878 (push number gnus-newsgroup-expirable)
8879 (push (cons number gnus-low-score-mark)
8880 gnus-newsgroup-reads)))
8882 ;; Do the `display' group parameter.
8883 (and gnus-newsgroup-display
8884 (let ((gnus-number number))
8885 (not (funcall gnus-newsgroup-display))))))
8886 ;; Nope, invisible article.
8888 ;; Ok, this article is to be visible, so we add it to the limit
8889 ;; and return 1.
8890 (push number gnus-newsgroup-limit)
8891 1))))
8893 (defun gnus-expunge-thread (thread)
8894 "Mark all articles in THREAD as read."
8895 (let* ((number (mail-header-number (car thread))))
8896 (incf gnus-newsgroup-expunged-tally)
8897 ;; We also mark as read here, if that's wanted.
8898 (setq gnus-newsgroup-unreads
8899 (delq number gnus-newsgroup-unreads))
8900 (if gnus-newsgroup-auto-expire
8901 (push number gnus-newsgroup-expirable)
8902 (push (cons number gnus-low-score-mark)
8903 gnus-newsgroup-reads)))
8904 ;; Go recursively through all subthreads.
8905 (mapcar 'gnus-expunge-thread (cdr thread)))
8907 ;; Summary article oriented commands
8909 (defun gnus-summary-refer-parent-article (n)
8910 "Refer parent article N times.
8911 If N is negative, go to ancestor -N instead.
8912 The difference between N and the number of articles fetched is returned."
8913 (interactive "p")
8914 (let ((skip 1)
8915 error header ref)
8916 (when (not (natnump n))
8917 (setq skip (abs n)
8918 n 1))
8919 (while (and (> n 0)
8920 (not error))
8921 (setq header (gnus-summary-article-header))
8922 (if (and (eq (mail-header-number header)
8923 (cdr gnus-article-current))
8924 (equal gnus-newsgroup-name
8925 (car gnus-article-current)))
8926 ;; If we try to find the parent of the currently
8927 ;; displayed article, then we take a look at the actual
8928 ;; References header, since this is slightly more
8929 ;; reliable than the References field we got from the
8930 ;; server.
8931 (with-current-buffer gnus-original-article-buffer
8932 (nnheader-narrow-to-headers)
8933 (unless (setq ref (message-fetch-field "references"))
8934 (when (setq ref (message-fetch-field "in-reply-to"))
8935 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8936 (widen))
8937 (setq ref
8938 ;; It's not the current article, so we take a bet on
8939 ;; the value we got from the server.
8940 (mail-header-references header)))
8941 (if (and ref
8942 (not (equal ref "")))
8943 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8944 (gnus-message 1 "Couldn't find parent"))
8945 (gnus-message 1 "No references in article %d"
8946 (gnus-summary-article-number))
8947 (setq error t))
8948 (decf n))
8949 (gnus-summary-position-point)
8952 (defun gnus-summary-refer-references ()
8953 "Fetch all articles mentioned in the References header.
8954 Return the number of articles fetched."
8955 (interactive)
8956 (let ((ref (mail-header-references (gnus-summary-article-header)))
8957 (current (gnus-summary-article-number))
8958 (n 0))
8959 (if (or (not ref)
8960 (equal ref ""))
8961 (error "No References in the current article")
8962 ;; For each Message-ID in the References header...
8963 (while (string-match "<[^>]*>" ref)
8964 (incf n)
8965 ;; ... fetch that article.
8966 (gnus-summary-refer-article
8967 (prog1 (match-string 0 ref)
8968 (setq ref (substring ref (match-end 0))))))
8969 (gnus-summary-goto-subject current)
8970 (gnus-summary-position-point)
8971 n)))
8973 (defun gnus-delete-duplicate-headers (headers)
8974 ;; First remove leading duplicates.
8975 (while (and (> (length headers) 1)
8976 (= (mail-header-number (car headers))
8977 (mail-header-number (cadr headers))))
8978 (pop headers))
8979 ;; Then the rest.
8980 (let ((result headers))
8981 (while (> (length headers) 1)
8982 (if (= (mail-header-number (car headers))
8983 (mail-header-number (cadr headers)))
8984 (setcdr headers (cddr headers))
8985 (pop headers)))
8986 result))
8988 (defun gnus-summary-refer-thread (&optional limit)
8989 "Fetch all articles in the current thread. For backends that
8990 know how to search for threads (currently only 'nnimap) a
8991 non-numeric prefix arg will use nnir to search the entire
8992 server; without a prefix arg only the current group is
8993 searched. If the variable `gnus-refer-thread-use-nnir' is
8994 non-nil the prefix arg has the reverse meaning. If no
8995 backend-specific 'request-thread function is available fetch
8996 LIMIT (the numerical prefix) old headers. If LIMIT is
8997 non-numeric or nil fetch the number specified by the
8998 `gnus-refer-thread-limit' variable."
8999 (interactive "P")
9000 (gnus-warp-to-article)
9001 (let* ((header (gnus-summary-article-header))
9002 (id (mail-header-id header))
9003 (gnus-inhibit-demon t)
9004 (gnus-summary-ignore-duplicates t)
9005 (gnus-read-all-available-headers t)
9006 (gnus-refer-thread-use-nnir
9007 (if (and (not (null limit)) (listp limit))
9008 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9009 (new-headers
9010 (if (gnus-check-backend-function
9011 'request-thread gnus-newsgroup-name)
9012 (gnus-request-thread header gnus-newsgroup-name)
9013 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9014 gnus-refer-thread-limit))
9015 (last (if (numberp limit)
9016 (min (+ (mail-header-number header)
9017 limit)
9018 gnus-newsgroup-highest)
9019 gnus-newsgroup-highest))
9020 (subject (gnus-simplify-subject
9021 (mail-header-subject header)))
9022 (refs (split-string (or (mail-header-references header)
9023 "")))
9024 (gnus-parse-headers-hook
9025 `(lambda () (goto-char (point-min))
9026 (keep-lines
9027 (regexp-opt ',(append refs (list id subject)))))))
9028 (gnus-fetch-headers (list last) (if (numberp limit)
9029 (* 2 limit) limit) t))))
9030 article-ids new-unreads)
9031 (when (listp new-headers)
9032 (dolist (header new-headers)
9033 (push (mail-header-number header) article-ids))
9034 (setq article-ids (nreverse article-ids))
9035 (setq new-unreads
9036 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9037 (setq gnus-newsgroup-unselected
9038 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9039 (setq gnus-newsgroup-unreads
9040 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9041 (setq gnus-newsgroup-headers
9042 (gnus-delete-duplicate-headers
9043 (cl-merge
9044 'list gnus-newsgroup-headers new-headers
9045 'gnus-article-sort-by-number)))
9046 (setq gnus-newsgroup-articles
9047 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9048 (gnus-summary-limit-include-thread id)))
9049 (gnus-summary-show-thread))
9051 (defun gnus-summary-open-group-with-article (message-id)
9052 "Open a group containing the article with the given MESSAGE-ID."
9053 (interactive "sMessage-ID: ")
9054 (require 'nndoc)
9055 (with-temp-buffer
9056 ;; Prepare a dummy article
9057 (erase-buffer)
9058 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9060 ;; Prepare pretty modelines for summary and article buffers
9061 (let ((gnus-summary-mode-line-format "Found %G")
9062 (gnus-article-mode-line-format
9063 ;; Group names just get in the way here, especially the
9064 ;; abbreviated ones
9065 (if (string-match "%[gG]" gnus-article-mode-line-format)
9066 (concat (substring gnus-article-mode-line-format
9067 0 (match-beginning 0))
9068 (substring gnus-article-mode-line-format (match-end 0)))
9069 gnus-article-mode-line-format)))
9071 ;; Build an ephemeral group containing the dummy article (hidden)
9072 (gnus-group-read-ephemeral-group
9073 message-id
9074 `(nndoc ,message-id
9075 (nndoc-address ,(current-buffer))
9076 (nndoc-article-type mbox))
9077 :activate
9078 (cons (current-buffer) gnus-current-window-configuration)
9079 (not :request-only)
9080 '(-1) ; :select-articles
9081 (not :parameters)
9082 0)) ; :number
9083 ;; Fetch the desired article
9084 (gnus-summary-refer-article message-id)))
9086 (defun gnus-summary-refer-article (message-id)
9087 "Fetch an article specified by MESSAGE-ID."
9088 (interactive "sMessage-ID: ")
9089 (gnus-warp-to-article)
9090 (when (and (stringp message-id)
9091 (not (zerop (length message-id))))
9092 (setq message-id (replace-regexp-in-string " " "" message-id))
9093 ;; Construct the correct Message-ID if necessary.
9094 ;; Suggested by tale@pawl.rpi.edu.
9095 (unless (string-match "^<" message-id)
9096 (setq message-id (concat "<" message-id)))
9097 (unless (string-match ">$" message-id)
9098 (setq message-id (concat message-id ">")))
9099 ;; People often post MIDs from URLs, so unhex it:
9100 (unless (string-match "@" message-id)
9101 (setq message-id (gnus-url-unhex-string message-id)))
9102 (let* ((header (gnus-id-to-header message-id))
9103 (sparse (and header
9104 (gnus-summary-article-sparse-p
9105 (mail-header-number header))
9106 (memq (mail-header-number header)
9107 gnus-newsgroup-limit)))
9108 number)
9109 (cond
9110 ;; If the article is present in the buffer we just go to it.
9111 ((and header
9112 (or (not (gnus-summary-article-sparse-p
9113 (mail-header-number header)))
9114 sparse))
9115 (prog1
9116 (gnus-summary-goto-article
9117 (mail-header-number header) nil t)
9118 (when sparse
9119 (gnus-summary-update-article (mail-header-number header)))))
9121 ;; We fetch the article.
9122 (catch 'found
9123 (dolist (gnus-override-method (gnus-refer-article-methods))
9124 (when (and (gnus-check-server gnus-override-method)
9125 ;; Fetch the header,
9126 (setq number (gnus-summary-insert-subject message-id)))
9127 ;; and display the article.
9128 (gnus-summary-select-article nil nil nil number)
9129 (throw 'found t)))
9130 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9132 (defun gnus-refer-article-methods ()
9133 "Return a list of referable methods."
9134 (cond
9135 ;; No method, so we default to current and native.
9136 ((null gnus-refer-article-method)
9137 (list gnus-current-select-method gnus-select-method))
9138 ;; Current.
9139 ((eq 'current gnus-refer-article-method)
9140 (list gnus-current-select-method))
9141 ;; List of select methods.
9142 ((not (and (symbolp (car gnus-refer-article-method))
9143 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9144 (let (out)
9145 (dolist (method gnus-refer-article-method)
9146 (push (if (eq 'current method)
9147 gnus-current-select-method
9148 (if (eq 'nnir (car method))
9149 (list
9150 'nnir
9151 (or (cadr method)
9152 (gnus-method-to-server gnus-current-select-method)))
9153 method))
9154 out))
9155 (nreverse out)))
9156 ;; One single select method.
9158 (list gnus-refer-article-method))))
9160 (defun gnus-summary-edit-parameters ()
9161 "Edit the group parameters of the current group."
9162 (interactive)
9163 (gnus-group-edit-group gnus-newsgroup-name 'params))
9165 (defun gnus-summary-customize-parameters ()
9166 "Customize the group parameters of the current group."
9167 (interactive)
9168 (gnus-group-customize gnus-newsgroup-name))
9170 (defun gnus-summary-enter-digest-group (&optional force)
9171 "Enter an nndoc group based on the current article.
9172 If FORCE, force a digest interpretation. If not, try to guess
9173 what the document format is.
9175 To control what happens when you exit the group, see the
9176 `gnus-auto-select-on-ephemeral-exit' variable."
9177 (interactive "P")
9178 (let ((conf gnus-current-window-configuration))
9179 (save-window-excursion
9180 (save-excursion
9181 (let (gnus-article-prepare-hook
9182 gnus-display-mime-function
9183 gnus-break-pages)
9184 (gnus-summary-select-article))))
9185 (setq gnus-current-window-configuration conf)
9186 (let* ((name (format "%s-%d"
9187 (gnus-group-prefixed-name
9188 gnus-newsgroup-name (list 'nndoc ""))
9189 (with-current-buffer gnus-summary-buffer
9190 gnus-current-article)))
9191 (ogroup gnus-newsgroup-name)
9192 (params (append (gnus-info-params (gnus-get-info ogroup))
9193 (list (cons 'to-group ogroup))
9194 (list (cons 'parent-group ogroup))
9195 (list (cons 'save-article-group ogroup))))
9196 (case-fold-search t)
9197 (buf (current-buffer))
9198 dig to-address charset)
9199 (with-current-buffer gnus-original-article-buffer
9200 ;; Have the digest group inherit the main mail address of
9201 ;; the parent article.
9202 (when (setq to-address (or (gnus-fetch-field "reply-to")
9203 (gnus-fetch-field "from")))
9204 (setq params
9205 (append
9206 params
9207 (list (cons 'to-address
9208 (funcall gnus-decode-encoded-address-function
9209 to-address))))))
9210 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9211 (insert-buffer-substring gnus-original-article-buffer)
9212 (narrow-to-region
9213 (goto-char (point-min))
9214 (or (search-forward "\n\n" nil t) (point)))
9215 ;; Remove lines that may lead nndoc to misinterpret the
9216 ;; document type.
9217 (goto-char (point-min))
9218 (delete-matching-lines "^Path:\\|^From ")
9219 ;; Parse charset, and decode content transfer encoding.
9220 (setq charset (mail-content-type-get
9221 (mail-header-parse-content-type
9222 (or (gnus-fetch-field "content-type") ""))
9223 'charset))
9224 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9225 (when encoding
9226 (message-remove-header "content-transfer-encoding")
9227 (goto-char (point-max))
9228 (widen)
9229 (narrow-to-region (point) (point-max))
9230 (mm-decode-content-transfer-encoding
9231 (intern (downcase (mail-header-strip-cte encoding))))))
9232 (widen))
9233 (unwind-protect
9234 (if (let ((gnus-newsgroup-ephemeral-charset
9235 (if charset
9236 (intern (downcase (gnus-strip-whitespace charset)))
9237 gnus-newsgroup-charset))
9238 (gnus-newsgroup-ephemeral-ignored-charsets
9239 gnus-newsgroup-ignored-charsets))
9240 (gnus-group-read-ephemeral-group
9241 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9242 (nndoc-article-type
9243 ,(if force 'mbox 'guess)))
9244 t nil nil nil
9245 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9246 "ADAPT")))))
9247 ;; Make all postings to this group go to the parent group.
9248 (nconc (gnus-info-params (gnus-get-info name))
9249 params)
9250 ;; Couldn't select this doc group.
9251 (switch-to-buffer buf)
9252 (gnus-set-global-variables)
9253 (gnus-configure-windows 'summary)
9254 (gnus-message 3 "Article couldn't be entered?"))
9255 (kill-buffer dig)))))
9257 (defun gnus-summary-read-document (n)
9258 "Open a new group based on the current article(s).
9259 This will allow you to read digests and other similar
9260 documents as newsgroups.
9261 Obeys the standard process/prefix convention."
9262 (interactive "P")
9263 (let* ((ogroup gnus-newsgroup-name)
9264 (params (append (gnus-info-params (gnus-get-info ogroup))
9265 (list (cons 'to-group ogroup))))
9266 group egroup groups vgroup)
9267 (dolist (article (gnus-summary-work-articles n))
9268 (setq group (format "%s-%d" gnus-newsgroup-name article))
9269 (gnus-summary-remove-process-mark article)
9270 (when (gnus-summary-display-article article)
9271 (save-excursion ;;What for?
9272 (with-temp-buffer
9273 (insert-buffer-substring gnus-original-article-buffer)
9274 ;; Remove some headers that may lead nndoc to make
9275 ;; the wrong guess.
9276 (message-narrow-to-head)
9277 (goto-char (point-min))
9278 (delete-matching-lines "^Path:\\|^From ")
9279 (widen)
9280 (if (setq egroup
9281 (gnus-group-read-ephemeral-group
9282 group `(nndoc ,group (nndoc-address ,(current-buffer))
9283 (nndoc-article-type guess))
9284 t nil t))
9285 (progn
9286 ;; Make all postings to this group go to the parent group.
9287 (nconc (gnus-info-params (gnus-get-info egroup))
9288 params)
9289 (push egroup groups))
9290 ;; Couldn't select this doc group.
9291 (gnus-error 3 "Article couldn't be entered"))))))
9292 ;; Now we have selected all the documents.
9293 (cond
9294 ((not groups)
9295 (error "None of the articles could be interpreted as documents"))
9296 ((gnus-group-read-ephemeral-group
9297 (setq vgroup (format
9298 "nnvirtual:%s-%s" gnus-newsgroup-name
9299 (format-time-string "%Y%m%dT%H%M%S")))
9300 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9302 (cons (current-buffer) 'summary)))
9304 (error "Couldn't select virtual nndoc group")))))
9306 (defun gnus-summary-widget-forward (arg)
9307 "Move point to the next field or button in the article.
9308 With optional ARG, move across that many fields."
9309 (interactive "p")
9310 (gnus-summary-select-article)
9311 (gnus-configure-windows 'article)
9312 (select-window (gnus-get-buffer-window gnus-article-buffer))
9313 (widget-forward arg))
9315 (defun gnus-summary-widget-backward (arg)
9316 "Move point to the previous field or button in the article.
9317 With optional ARG, move across that many fields."
9318 (interactive "p")
9319 (gnus-summary-select-article)
9320 (gnus-configure-windows 'article)
9321 (select-window (gnus-get-buffer-window gnus-article-buffer))
9322 (unless (widget-at (point))
9323 (goto-char (point-max)))
9324 (widget-backward arg))
9326 (defun gnus-summary-isearch-article (&optional regexp-p)
9327 "Do incremental search forward on the current article.
9328 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9329 (interactive "P")
9330 (gnus-summary-select-article)
9331 (gnus-configure-windows 'article)
9332 (gnus-eval-in-buffer-window gnus-article-buffer
9333 (save-restriction
9334 (widen)
9335 (isearch-forward regexp-p))))
9337 (defun gnus-summary-repeat-search-article-forward ()
9338 "Repeat the previous search forwards."
9339 (interactive)
9340 (unless gnus-last-search-regexp
9341 (error "No previous search"))
9342 (gnus-summary-search-article-forward gnus-last-search-regexp))
9344 (defun gnus-summary-repeat-search-article-backward ()
9345 "Repeat the previous search backwards."
9346 (interactive)
9347 (unless gnus-last-search-regexp
9348 (error "No previous search"))
9349 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9351 (defun gnus-summary-search-article-forward (regexp &optional backward)
9352 "Search for an article containing REGEXP forward.
9353 If BACKWARD, search backward instead."
9354 (interactive
9355 (list (read-string
9356 (format "Search article %s (regexp%s): "
9357 (if current-prefix-arg "backward" "forward")
9358 (if gnus-last-search-regexp
9359 (concat ", default " gnus-last-search-regexp)
9360 "")))
9361 current-prefix-arg))
9362 (if (string-equal regexp "")
9363 (setq regexp (or gnus-last-search-regexp ""))
9364 (setq gnus-last-search-regexp regexp)
9365 (setq gnus-article-before-search gnus-current-article))
9366 ;; Intentionally set gnus-last-article.
9367 (setq gnus-last-article gnus-article-before-search)
9368 (let ((gnus-last-article gnus-last-article))
9369 (if (gnus-summary-search-article regexp backward)
9370 (gnus-summary-show-thread)
9371 (signal 'search-failed (list regexp)))))
9373 (defun gnus-summary-search-article-backward (regexp)
9374 "Search for an article containing REGEXP backward."
9375 (interactive
9376 (list (read-string
9377 (format "Search article backward (regexp%s): "
9378 (if gnus-last-search-regexp
9379 (concat ", default " gnus-last-search-regexp)
9380 "")))))
9381 (gnus-summary-search-article-forward regexp 'backward))
9383 (defun gnus-summary-search-article (regexp &optional backward)
9384 "Search for an article containing REGEXP.
9385 Optional argument BACKWARD means do search for backward.
9386 `gnus-select-article-hook' is not called during the search."
9387 ;; We have to require this here to make sure that the following
9388 ;; dynamic binding isn't shadowed by autoloading.
9389 (require 'gnus-async)
9390 (require 'gnus-art)
9391 (let ((gnus-select-article-hook nil) ;Disable hook.
9392 (gnus-article-prepare-hook nil)
9393 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9394 (gnus-use-article-prefetch nil)
9395 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9396 (gnus-visual nil)
9397 (gnus-keep-backlog nil)
9398 (gnus-break-pages nil)
9399 (gnus-summary-display-arrow nil)
9400 (gnus-updated-mode-lines nil)
9401 (gnus-auto-center-summary nil)
9402 (sum (current-buffer))
9403 (gnus-display-mime-function nil)
9404 (found nil)
9405 point)
9406 (gnus-save-hidden-threads
9407 (gnus-summary-select-article)
9408 (set-buffer gnus-article-buffer)
9409 (goto-char (window-point (get-buffer-window (current-buffer))))
9410 (when backward
9411 (forward-line -1))
9412 (while (not found)
9413 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9414 (if (if backward
9415 (re-search-backward regexp nil t)
9416 (re-search-forward regexp nil t))
9417 ;; We found the regexp.
9418 (progn
9419 (setq found 'found)
9420 (beginning-of-line)
9421 (set-window-start
9422 (get-buffer-window (current-buffer))
9423 (point))
9424 (forward-line 1)
9425 (set-window-point
9426 (get-buffer-window (current-buffer))
9427 (point))
9428 (set-buffer sum)
9429 (setq point (point)))
9430 ;; We didn't find it, so we go to the next article.
9431 (set-buffer sum)
9432 (setq found 'not)
9433 (while (eq found 'not)
9434 (if (not (if backward (gnus-summary-find-prev)
9435 (gnus-summary-find-next)))
9436 ;; No more articles.
9437 (setq found t)
9438 ;; Select the next article and adjust point.
9439 (unless (gnus-summary-article-sparse-p
9440 (gnus-summary-article-number))
9441 (setq found nil)
9442 (gnus-summary-select-article)
9443 (set-buffer gnus-article-buffer)
9444 (widen)
9445 (goto-char (if backward (point-max) (point-min))))))))
9446 (gnus-message 7 ""))
9447 ;; Return whether we found the regexp.
9448 (when (eq found 'found)
9449 (goto-char point)
9450 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9451 (gnus-summary-show-thread)
9452 (gnus-summary-goto-subject gnus-current-article)
9453 (gnus-summary-position-point)
9454 t)))
9456 (defun gnus-find-matching-articles (header regexp)
9457 "Return a list of all articles that match REGEXP on HEADER.
9458 This search includes all articles in the current group that Gnus has
9459 fetched headers for, whether they are displayed or not."
9460 (let ((articles nil)
9461 ;; Can't eta-reduce because it's a macro.
9462 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9463 (case-fold-search t))
9464 (dolist (header gnus-newsgroup-headers)
9465 (when (string-match regexp (funcall func header))
9466 (push (mail-header-number header) articles)))
9467 (nreverse articles)))
9469 (defun gnus-summary-find-matching (header regexp &optional backward unread
9470 not-case-fold not-matching)
9471 "Return a list of all articles that match REGEXP on HEADER.
9472 The search stars on the current article and goes forwards unless
9473 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9474 If UNREAD is non-nil, only unread articles will
9475 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9476 in the comparisons. If NOT-MATCHING, return a list of all articles that
9477 not match REGEXP on HEADER."
9478 (let ((case-fold-search (not not-case-fold))
9479 articles d func)
9480 (if (consp header)
9481 (if (eq (car header) 'extra)
9482 (setq func
9483 `(lambda (h)
9484 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9485 "")))
9486 (error "%s is an invalid header" header))
9487 (unless (fboundp (intern (concat "mail-header-" header)))
9488 (error "%s is not a valid header" header))
9489 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9490 (dolist (d (if (eq backward 'all)
9491 gnus-newsgroup-data
9492 (gnus-data-find-list
9493 (gnus-summary-article-number)
9494 (gnus-data-list backward))))
9495 (when (and (or (not unread) ; We want all articles...
9496 (gnus-data-unread-p d)) ; Or just unreads.
9497 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9498 (if not-matching
9499 (not (string-match
9500 regexp
9501 (funcall func (gnus-data-header d))))
9502 (string-match regexp
9503 (funcall func (gnus-data-header d)))))
9504 (push (gnus-data-number d) articles))) ; Success!
9505 (nreverse articles)))
9507 (defun gnus-summary-execute-command (header regexp command &optional backward)
9508 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9509 If HEADER is an empty string (or nil), the match is done on the entire
9510 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9511 (interactive
9512 (list (let ((completion-ignore-case t))
9513 (gnus-completing-read
9514 "Header name"
9515 (mapcar 'symbol-name
9516 (append
9517 '(Number Subject From Lines Date
9518 Message-ID Xref References Body)
9519 gnus-extra-headers))
9520 'require-match))
9521 (read-string "Regexp: ")
9522 (read-key-sequence "Command: ")
9523 current-prefix-arg))
9524 (when (equal header "Body")
9525 (setq header ""))
9526 ;; Hidden thread subtrees must be searched as well.
9527 (gnus-summary-show-all-threads)
9528 ;; We don't want to change current point nor window configuration.
9529 (save-excursion
9530 (save-window-excursion
9531 (let (gnus-visual
9532 gnus-treat-strip-trailing-blank-lines
9533 gnus-treat-strip-leading-blank-lines
9534 gnus-treat-strip-multiple-blank-lines
9535 gnus-treat-hide-boring-headers
9536 gnus-treat-fold-newsgroups
9537 gnus-article-prepare-hook)
9538 (gnus-message 6 "Executing %s..." (key-description command))
9539 ;; We'd like to execute COMMAND interactively so as to give arguments.
9540 (gnus-execute header regexp
9541 `(call-interactively ',(key-binding command))
9542 backward)
9543 (gnus-message 6 "Executing %s...done" (key-description command))))))
9545 (defun gnus-summary-beginning-of-article ()
9546 "Scroll the article back to the beginning."
9547 (interactive)
9548 (gnus-summary-select-article)
9549 (gnus-configure-windows 'article)
9550 (gnus-eval-in-buffer-window gnus-article-buffer
9551 (widen)
9552 (goto-char (point-min))
9553 (when gnus-break-pages
9554 (gnus-narrow-to-page))))
9556 (defun gnus-summary-end-of-article ()
9557 "Scroll to the end of the article."
9558 (interactive)
9559 (gnus-summary-select-article)
9560 (gnus-configure-windows 'article)
9561 (gnus-eval-in-buffer-window gnus-article-buffer
9562 (widen)
9563 (goto-char (point-max))
9564 (recenter -3)
9565 (when gnus-break-pages
9566 (gnus-narrow-to-page))))
9568 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9569 "Truncate to LEN and quote all \"(\"'s in STRING."
9570 (replace-regexp-in-string "[()]" "\\\\\\&"
9571 (if (and len (> (length string) len))
9572 (substring string 0 len)
9573 string)))
9575 (defun gnus-summary-print-article (&optional filename n)
9576 "Generate and print a PostScript image of the process-marked (mail) articles.
9578 If used interactively, print the current article if none are
9579 process-marked. With prefix arg, prompt the user for the name of the
9580 file to save in.
9582 When used from Lisp, accept two optional args FILENAME and N. N means
9583 to print the next N articles. If N is negative, print the N previous
9584 articles. If N is nil and articles have been marked with the process
9585 mark, print these instead.
9587 If the optional first argument FILENAME is nil, send the image to the
9588 printer. If FILENAME is a string, save the PostScript image in a file with
9589 that name. If FILENAME is a number, prompt the user for the name of the file
9590 to save in."
9591 (interactive (list (ps-print-preprint current-prefix-arg)))
9592 (dolist (article (gnus-summary-work-articles n))
9593 (gnus-summary-select-article nil nil 'pseudo article)
9594 (gnus-eval-in-buffer-window gnus-article-buffer
9595 (gnus-print-buffer))
9596 (gnus-summary-remove-process-mark article))
9597 (ps-despool filename))
9599 (defun gnus-print-buffer ()
9600 (let ((ps-left-header
9601 (list
9602 (concat "("
9603 (gnus-summary-print-truncate-and-quote
9604 (mail-header-subject gnus-current-headers)
9605 66) ")")
9606 (concat "("
9607 (gnus-summary-print-truncate-and-quote
9608 (mail-header-from gnus-current-headers)
9609 45) ")")))
9610 (ps-right-header
9611 (list
9612 "/pagenumberstring load"
9613 (concat "("
9614 (mail-header-date gnus-current-headers) ")"))))
9615 (gnus-run-hooks 'gnus-ps-print-hook)
9616 (save-excursion
9617 (if ps-print-color-p
9618 (ps-spool-buffer-with-faces)
9619 (ps-spool-buffer)))))
9621 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9623 (defun gnus-summary-show-complete-article ()
9624 "Show a complete version of the current article.
9625 This is only useful if you're looking at a partial version of the
9626 article currently."
9627 (interactive)
9628 (let ((gnus-keep-backlog nil)
9629 (gnus-use-cache nil)
9630 (gnus-agent nil)
9631 (variable (intern
9632 (format "%s-fetch-partial-articles"
9633 (car (gnus-find-method-for-group
9634 gnus-newsgroup-name)))
9635 obarray))
9636 old-val)
9637 (unwind-protect
9638 (progn
9639 (setq old-val (symbol-value variable))
9640 (set variable nil)
9641 (gnus-flush-original-article-buffer)
9642 (gnus-summary-show-article))
9643 (set variable old-val))))
9645 (defun gnus-summary-show-article (&optional arg)
9646 "Force redisplaying of the current article.
9647 If ARG (the prefix) is a number, show the article with the charset
9648 defined in `gnus-summary-show-article-charset-alist', or the charset
9649 input.
9650 If ARG (the prefix) is non-nil and not a number, show the article,
9651 but without running any of the article treatment functions
9652 article. Normally, the keystroke is `C-u g'. When using `C-u
9653 C-u g', show the raw article."
9654 (interactive "P")
9655 (cond
9656 ((numberp arg)
9657 (gnus-summary-show-article t)
9658 (let ((gnus-newsgroup-charset
9659 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9660 (read-coding-system
9661 "View as charset: " ;; actually it is coding system.
9662 (with-current-buffer gnus-article-buffer
9663 (mm-detect-coding-region (point) (point-max))))))
9664 (gnus-newsgroup-ignored-charsets 'gnus-all))
9665 (gnus-summary-select-article nil 'force)
9666 (let ((deps gnus-newsgroup-dependencies)
9667 head header lines)
9668 (with-current-buffer gnus-original-article-buffer
9669 (save-restriction
9670 (message-narrow-to-head)
9671 (setq head (buffer-string))
9672 (goto-char (point-min))
9673 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9674 (goto-char (point-max))
9675 (widen)
9676 (setq lines (1- (count-lines (point) (point-max))))))
9677 (with-temp-buffer
9678 (insert (format "211 %d Article retrieved.\n"
9679 (cdr gnus-article-current)))
9680 (insert head)
9681 (if lines (insert (format "Lines: %d\n" lines)))
9682 (insert ".\n")
9683 (let ((nntp-server-buffer (current-buffer)))
9684 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9685 (gnus-data-set-header
9686 (gnus-data-find (cdr gnus-article-current))
9687 header)
9688 (gnus-summary-update-article-line
9689 (cdr gnus-article-current) header)
9690 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9691 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9692 ((not arg)
9693 ;; Select the article the normal way.
9694 (if (eq mm-text-html-renderer 'shr)
9695 (progn
9696 (require 'shr)
9697 (let ((shr-ignore-cache t))
9698 (gnus-summary-select-article nil 'force)))
9699 (gnus-summary-select-article nil 'force)))
9700 ((equal arg '(16))
9701 ;; C-u C-u g
9702 (let ((gnus-inhibit-article-treatments t))
9703 (gnus-summary-select-article nil 'force)))
9705 ;; We have to require this here to make sure that the following
9706 ;; dynamic binding isn't shadowed by autoloading.
9707 (require 'gnus-async)
9708 (require 'gnus-art)
9709 ;; Bind the article treatment functions to nil.
9710 (let ((gnus-have-all-headers t)
9711 gnus-article-prepare-hook
9712 gnus-article-decode-hook
9713 gnus-display-mime-function
9714 gnus-break-pages)
9715 ;; Destroy any MIME parts.
9716 (when (gnus-buffer-live-p gnus-article-buffer)
9717 (with-current-buffer gnus-article-buffer
9718 (gnus-article-stop-animations)
9719 (gnus-stop-downloads)
9720 (mm-destroy-parts gnus-article-mime-handles)
9721 ;; Set it to nil for safety reason.
9722 (setq gnus-article-mime-handle-alist nil)
9723 (setq gnus-article-mime-handles nil)))
9724 (gnus-summary-select-article nil 'force))))
9725 (gnus-summary-goto-subject gnus-current-article)
9726 (gnus-summary-position-point))
9728 (defun gnus-summary-show-raw-article ()
9729 "Show the raw article without any article massaging functions being run."
9730 (interactive)
9731 (gnus-summary-show-article t))
9733 (defun gnus-summary-verbose-headers (&optional arg)
9734 "Toggle permanent full header display.
9735 If ARG is a positive number, turn header display on.
9736 If ARG is a negative number, turn header display off."
9737 (interactive "P")
9738 (setq gnus-show-all-headers
9739 (cond ((or (not (numberp arg))
9740 (zerop arg))
9741 (not gnus-show-all-headers))
9742 ((natnump arg)
9743 t)))
9744 (gnus-summary-show-article))
9746 (declare-function article-narrow-to-head "gnus-art" ())
9747 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9748 (declare-function gnus-delete-wash-type "gnus-art" (type))
9749 (declare-function gnus-mime-buttonize-attachments-in-header
9750 "gnus-art" (&optional interactive))
9752 (defun gnus-summary-toggle-header (&optional arg)
9753 "Show the headers if they are hidden, or hide them if they are shown.
9754 If ARG is a positive number, show the entire header.
9755 If ARG is a negative number, hide the unwanted header lines."
9756 (interactive "P")
9757 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9758 (get-buffer-window gnus-article-buffer t))))
9759 (with-current-buffer gnus-article-buffer
9760 (widen)
9761 (article-narrow-to-head)
9762 (let* ((inhibit-read-only t)
9763 (inhibit-point-motion-hooks t)
9764 (hidden (if (numberp arg)
9765 (>= arg 0)
9766 (or (not (looking-at "[^ \t\n]+:"))
9767 (gnus-article-hidden-text-p 'headers))))
9768 s e)
9769 (delete-region (point-min) (point-max))
9770 (with-current-buffer gnus-original-article-buffer
9771 (goto-char (setq s (point-min)))
9772 (setq e (if (search-forward "\n\n" nil t)
9773 (1- (point))
9774 (point-max))))
9775 (insert-buffer-substring gnus-original-article-buffer s e)
9776 (run-hooks 'gnus-article-decode-hook)
9777 (if hidden
9778 (let ((gnus-treat-hide-headers nil)
9779 (gnus-treat-hide-boring-headers nil))
9780 (gnus-delete-wash-type 'headers)
9781 (gnus-treat-article 'head))
9782 (gnus-treat-article 'head)
9783 ;; Add attachment buttons to the header.
9784 (when gnus-mime-display-attachment-buttons-in-header
9785 (gnus-mime-buttonize-attachments-in-header)))
9786 (widen)
9787 (if window
9788 (set-window-start window (goto-char (point-min))))
9789 (if gnus-break-pages
9790 (gnus-narrow-to-page)
9791 (when (gnus-visual-p 'page-marker)
9792 (let ((inhibit-read-only t))
9793 (gnus-remove-text-with-property 'gnus-prev)
9794 (gnus-remove-text-with-property 'gnus-next))))
9795 (gnus-set-mode-line 'article)))))
9797 (defun gnus-summary-show-all-headers ()
9798 "Make all header lines visible."
9799 (interactive)
9800 (gnus-summary-toggle-header 1))
9802 (defun gnus-summary-caesar-message (&optional arg)
9803 "Caesar rotate the current article by 13.
9804 With a non-numerical prefix, also rotate headers. A numerical
9805 prefix specifies how many places to rotate each letter forward."
9806 (interactive "P")
9807 (gnus-summary-select-article)
9808 (let ((mail-header-separator ""))
9809 (gnus-eval-in-buffer-window gnus-article-buffer
9810 (save-restriction
9811 (widen)
9812 (let ((start (window-start))
9813 (inhibit-read-only t))
9814 (if (equal arg '(4))
9815 (message-caesar-buffer-body nil t)
9816 (message-caesar-buffer-body arg))
9817 (set-window-start (get-buffer-window (current-buffer)) start)))))
9818 ;; Create buttons and stuff...
9819 (gnus-treat-article nil))
9821 (defun gnus-summary-idna-message (&optional arg)
9822 "Decode IDNA encoded domain names in the current articles.
9823 IDNA encoded domain names looks like `xn--bar'. If a string
9824 remain unencoded after running this function, it is likely an
9825 invalid IDNA string (`xn--bar' is invalid).
9827 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9828 installed for this command to work."
9829 (interactive "P")
9830 (gnus-summary-select-article)
9831 (let ((mail-header-separator ""))
9832 (gnus-eval-in-buffer-window gnus-article-buffer
9833 (save-restriction
9834 (widen)
9835 (let ((start (window-start))
9836 buffer-read-only)
9837 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9838 (replace-match (puny-decode-domain (match-string 1))))
9839 (set-window-start (get-buffer-window (current-buffer)) start))))))
9841 (defun gnus-summary-morse-message (&optional arg)
9842 "Morse decode the current article."
9843 (interactive "P")
9844 (gnus-summary-select-article)
9845 (let ((mail-header-separator ""))
9846 (gnus-eval-in-buffer-window gnus-article-buffer
9847 (save-excursion
9848 (save-restriction
9849 (widen)
9850 (let ((pos (window-start))
9851 (inhibit-read-only t))
9852 (goto-char (point-min))
9853 (when (message-goto-body)
9854 (gnus-narrow-to-body))
9855 (goto-char (point-min))
9856 (while (search-forward "·" (point-max) t)
9857 (replace-match "."))
9858 (unmorse-region (point-min) (point-max))
9859 (widen)
9860 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9862 (defun gnus-summary-stop-page-breaking ()
9863 "Stop page breaking in the current article."
9864 (interactive)
9865 (gnus-summary-select-article)
9866 (gnus-eval-in-buffer-window gnus-article-buffer
9867 (widen)
9868 (when (gnus-visual-p 'page-marker)
9869 (let ((inhibit-read-only t))
9870 (gnus-remove-text-with-property 'gnus-prev)
9871 (gnus-remove-text-with-property 'gnus-next))
9872 (setq gnus-page-broken nil))))
9874 (defun gnus-summary-move-article (&optional n to-newsgroup
9875 select-method action)
9876 "Move the current article to a different newsgroup.
9877 If N is a positive number, move the N next articles.
9878 If N is a negative number, move the N previous articles.
9879 If N is nil and any articles have been marked with the process mark,
9880 move those articles instead.
9881 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9882 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9883 re-spool using this method.
9885 When called interactively with TO-NEWSGROUP being nil, the value of
9886 the variable `gnus-move-split-methods' is used for finding a default
9887 for the target newsgroup.
9889 For this function to work, both the current newsgroup and the
9890 newsgroup that you want to move to have to support the `request-move'
9891 and `request-accept' functions.
9893 ACTION can be either `move' (the default), `crosspost' or `copy'."
9894 (interactive "P")
9895 (unless action
9896 (setq action 'move))
9897 ;; Check whether the source group supports the required functions.
9898 (cond ((and (eq action 'move)
9899 (not (gnus-check-backend-function
9900 'request-move-article gnus-newsgroup-name)))
9901 (error "The current group does not support article moving"))
9902 ((and (eq action 'crosspost)
9903 (not (gnus-check-backend-function
9904 'request-replace-article gnus-newsgroup-name)))
9905 (error "The current group does not support article editing")))
9906 (let ((articles (gnus-summary-work-articles n))
9907 (prefix (if (gnus-check-backend-function
9908 'request-move-article gnus-newsgroup-name)
9909 (funcall gnus-move-group-prefix-function
9910 gnus-newsgroup-name)
9911 ""))
9912 (names '((move "Move" "Moving")
9913 (copy "Copy" "Copying")
9914 (crosspost "Crosspost" "Crossposting")))
9915 (copy-buf (save-excursion
9916 (nnheader-set-temp-buffer " *copy article*")))
9917 art-group to-method new-xref article to-groups
9918 articles-to-update-marks encoded)
9919 (unless (assq action names)
9920 (error "Unknown action %s" action))
9921 ;; Read the newsgroup name.
9922 (when (and (not to-newsgroup)
9923 (not select-method))
9924 (if (and gnus-move-split-methods
9925 (not
9926 (and (memq gnus-current-article articles)
9927 (gnus-buffer-live-p gnus-original-article-buffer))))
9928 ;; When `gnus-move-split-methods' is non-nil, we have to
9929 ;; select an article to give `gnus-read-move-group-name' an
9930 ;; opportunity to suggest an appropriate default. However,
9931 ;; we needn't render or mark the article.
9932 (let ((gnus-display-mime-function nil)
9933 (gnus-article-prepare-hook nil)
9934 (gnus-mark-article-hook nil))
9935 (gnus-summary-select-article nil nil nil (car articles))))
9936 (setq to-newsgroup (gnus-read-move-group-name
9937 (cadr (assq action names))
9938 (symbol-value
9939 (intern (format "gnus-current-%s-group" action)))
9940 articles prefix)
9941 encoded to-newsgroup
9942 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9943 (set (intern (format "gnus-current-%s-group" action))
9944 (decode-coding-string
9945 to-newsgroup
9946 (gnus-group-name-charset to-method to-newsgroup))))
9947 (unless to-method
9948 (setq to-method (or select-method
9949 (gnus-server-to-method
9950 (gnus-group-method to-newsgroup)))))
9951 (setq to-newsgroup
9952 (or encoded
9953 (and to-newsgroup
9954 (encode-coding-string
9955 to-newsgroup
9956 (gnus-group-name-charset to-method to-newsgroup)))))
9957 ;; Check the method we are to move this article to...
9958 (unless (gnus-check-backend-function
9959 'request-accept-article (car to-method))
9960 (error "%s does not support article copying" (car to-method)))
9961 (unless (gnus-check-server to-method)
9962 (error "Can't open server %s" (car to-method)))
9963 (gnus-message 6 "%s to %s: %s..."
9964 (caddr (assq action names))
9965 (or (car select-method)
9966 (gnus-group-decoded-name to-newsgroup))
9967 articles)
9968 (while articles
9969 (setq article (pop articles))
9970 ;; Set any marks that may have changed in the summary buffer.
9971 (when gnus-preserve-marks
9972 (gnus-summary-push-marks-to-backend article))
9973 (setq
9974 art-group
9975 (cond
9976 ;; Move the article.
9977 ((eq action 'move)
9978 ;; Remove this article from future suppression.
9979 (gnus-dup-unsuppress-article article)
9980 (let* ((from-method (gnus-find-method-for-group
9981 gnus-newsgroup-name))
9982 (to-method (or select-method
9983 (gnus-find-method-for-group to-newsgroup)))
9984 (move-is-internal (gnus-server-equal from-method to-method)))
9985 (gnus-request-move-article
9986 article ; Article to move
9987 gnus-newsgroup-name ; From newsgroup
9988 (nth 1 (gnus-find-method-for-group
9989 gnus-newsgroup-name)) ; Server
9990 (list 'gnus-request-accept-article
9991 to-newsgroup (list 'quote select-method)
9992 (not articles) t) ; Accept form
9993 (not articles) ; Only save nov last time
9994 (and move-is-internal
9995 to-newsgroup ; Not respooling
9996 ; Is this move internal?
9997 (gnus-group-real-name to-newsgroup)))))
9998 ;; Copy the article.
9999 ((eq action 'copy)
10000 (with-current-buffer copy-buf
10001 (when (gnus-request-article-this-buffer article
10002 gnus-newsgroup-name)
10003 (save-restriction
10004 (nnheader-narrow-to-headers)
10005 (dolist (hdr gnus-copy-article-ignored-headers)
10006 (message-remove-header hdr t)))
10007 (gnus-request-accept-article
10008 to-newsgroup select-method (not articles) t))))
10009 ;; Crosspost the article.
10010 ((eq action 'crosspost)
10011 (let ((xref (message-tokenize-header
10012 (mail-header-xref (gnus-summary-article-header
10013 article))
10014 " ")))
10015 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10016 ":" (number-to-string article)))
10017 (unless xref
10018 (setq xref (list (system-name))))
10019 (setq new-xref
10020 (concat
10021 (mapconcat 'identity
10022 (delete "Xref:" (delete new-xref xref))
10023 " ")
10024 " " new-xref))
10025 (with-current-buffer copy-buf
10026 ;; First put the article in the destination group.
10027 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10028 (when (consp (setq art-group
10029 (gnus-request-accept-article
10030 to-newsgroup select-method (not articles)
10031 t)))
10032 (setq new-xref (concat new-xref " " (car art-group)
10034 (number-to-string (cdr art-group))))
10035 ;; Now we have the new Xrefs header, so we insert
10036 ;; it and replace the new article.
10037 (nnheader-replace-header "Xref" new-xref)
10038 (gnus-request-replace-article
10039 (cdr art-group) to-newsgroup (current-buffer) t)
10040 art-group))))))
10041 (cond
10042 ((not art-group)
10043 (gnus-message 1 "Couldn't %s article %s: %s"
10044 (cadr (assq action names)) article
10045 (nnheader-get-report (car to-method))))
10046 ((eq art-group 'junk)
10047 (when (eq action 'move)
10048 (gnus-summary-mark-article article gnus-canceled-mark)
10049 (gnus-message 4 "Deleted article %s" article)
10050 ;; run the delete hook
10051 (run-hook-with-args 'gnus-summary-article-delete-hook
10052 action
10053 (gnus-data-header
10054 (assoc article (gnus-data-list nil)))
10055 gnus-newsgroup-name nil
10056 select-method)))
10058 (let* ((pto-group (gnus-group-prefixed-name
10059 (car art-group) to-method))
10060 (info (gnus-get-info pto-group))
10061 (to-group (gnus-info-group info))
10062 to-marks)
10063 ;; Update the group that has been moved to.
10064 (when (and info
10065 (memq action '(move copy)))
10066 (unless (member to-group to-groups)
10067 (push to-group to-groups))
10069 (when (and (not (memq article gnus-newsgroup-unreads))
10070 (cdr art-group))
10071 (push 'read to-marks)
10072 (gnus-info-set-read
10073 info (gnus-add-to-range (gnus-info-read info)
10074 (list (cdr art-group)))))
10076 ;; See whether the article is to be put in the cache.
10077 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10078 (marks (if expirable
10079 gnus-article-mark-lists
10080 (delete '(expirable . expire)
10081 (copy-sequence
10082 gnus-article-mark-lists))))
10083 (to-article (cdr art-group)))
10085 ;; Enter the article into the cache in the new group,
10086 ;; if that is required.
10087 (when (and to-article
10088 gnus-use-cache)
10089 (gnus-cache-possibly-enter-article
10090 to-group to-article
10091 (memq article gnus-newsgroup-marked)
10092 (memq article gnus-newsgroup-dormant)
10093 (memq article gnus-newsgroup-unreads)))
10095 (when (and gnus-preserve-marks
10096 to-article)
10097 ;; Copy any marks over to the new group.
10098 (when (and (equal to-group gnus-newsgroup-name)
10099 (not (memq article gnus-newsgroup-unreads)))
10100 ;; Mark this article as read in this group.
10101 (push (cons to-article gnus-read-mark)
10102 gnus-newsgroup-reads)
10103 ;; Increase the active status of this group.
10104 (setcdr (gnus-active to-group) to-article)
10105 (setcdr gnus-newsgroup-active to-article))
10107 (while marks
10108 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10109 (when (memq article (symbol-value
10110 (intern (format "gnus-newsgroup-%s"
10111 (caar marks)))))
10112 (push (cdar marks) to-marks)
10113 ;; If the other group is the same as this group,
10114 ;; then we have to add the mark to the list.
10115 (when (equal to-group gnus-newsgroup-name)
10116 (set (intern (format "gnus-newsgroup-%s"
10117 (caar marks)))
10118 (cons to-article
10119 (symbol-value
10120 (intern (format "gnus-newsgroup-%s"
10121 (caar marks)))))))
10122 ;; Copy the marks to other group.
10123 (gnus-add-marked-articles
10124 to-group (cdar marks) (list to-article) info)))
10125 (setq marks (cdr marks)))
10127 (when (and expirable
10128 gnus-mark-copied-or-moved-articles-as-expirable
10129 (not (memq 'expire to-marks)))
10130 ;; Mark this article as expirable.
10131 (push 'expire to-marks)
10132 (when (equal to-group gnus-newsgroup-name)
10133 (push to-article gnus-newsgroup-expirable))
10134 ;; Copy the expirable mark to other group.
10135 (gnus-add-marked-articles
10136 to-group 'expire (list to-article) info))
10138 (when (and to-marks
10139 (gnus-method-option-p
10140 (gnus-find-method-for-group to-group)
10141 'server-marks))
10142 (gnus-request-set-mark
10143 to-group (list (list (list to-article) 'add to-marks)))))
10145 (gnus-dribble-enter
10146 (concat "(gnus-group-set-info '"
10147 (gnus-prin1-to-string (gnus-get-info to-group))
10148 ")")
10149 (concat "^(gnus-group-set-info '(\""
10150 (regexp-quote to-group) "\""))))
10152 ;; Update the Xref header in this article to point to
10153 ;; the new crossposted article we have just created.
10154 (when (eq action 'crosspost)
10155 (with-current-buffer copy-buf
10156 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10157 (nnheader-replace-header "Xref" new-xref)
10158 (gnus-request-replace-article
10159 article gnus-newsgroup-name (current-buffer) t)))
10161 ;; run the move/copy/crosspost/respool hook
10162 (run-hook-with-args 'gnus-summary-article-move-hook
10163 action
10164 (gnus-data-header
10165 (assoc article (gnus-data-list nil)))
10166 gnus-newsgroup-name
10167 to-newsgroup
10168 select-method))
10170 ;;;!!!Why is this necessary?
10171 (set-buffer gnus-summary-buffer)
10173 (when (eq action 'move)
10174 (save-excursion
10175 (gnus-summary-goto-subject article)
10176 (gnus-summary-mark-article article gnus-canceled-mark)))))
10177 (push article articles-to-update-marks))
10179 (save-excursion
10180 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10181 ;; Re-activate all groups that have been moved to.
10182 (with-current-buffer gnus-group-buffer
10183 (let ((gnus-group-marked to-groups))
10184 (gnus-group-get-new-news-this-group nil t)))
10186 (gnus-kill-buffer copy-buf)
10187 (gnus-summary-position-point)
10188 (gnus-set-mode-line 'summary)))
10190 (defun gnus-summary-push-marks-to-backend (article)
10191 (let ((set nil)
10192 (del nil)
10193 (marks gnus-article-mark-lists))
10194 (unless (memq article gnus-newsgroup-unreads)
10195 (push 'read set))
10196 (while marks
10197 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10198 (memq article (symbol-value
10199 (intern (format "gnus-newsgroup-%s"
10200 (caar marks))))))
10201 (push (cdar marks) set)
10202 (push (cdar marks) del))
10203 (pop marks))
10204 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10205 ((,article) del ,del)))))
10207 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10208 "Copy the current article to some other group.
10209 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10210 When called interactively, if TO-NEWSGROUP is nil, use the value of
10211 the variable `gnus-move-split-methods' for finding a default target
10212 newsgroup.
10213 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10214 re-spool using this method."
10215 (interactive "P")
10216 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10218 (defun gnus-summary-crosspost-article (&optional n)
10219 "Crosspost the current article to some other group."
10220 (interactive "P")
10221 (gnus-summary-move-article n nil nil 'crosspost))
10223 (defcustom gnus-summary-respool-default-method nil
10224 "Default method type for respooling an article.
10225 If nil, use to the current newsgroup method."
10226 :type 'symbol
10227 :group 'gnus-summary-mail)
10229 (defun gnus-summary-respool-article (&optional n method)
10230 "Respool the current article.
10231 The article will be squeezed through the mail spooling process again,
10232 which means that it will be put in some mail newsgroup or other
10233 depending on `nnmail-split-methods'.
10234 If N is a positive number, respool the N next articles.
10235 If N is a negative number, respool the N previous articles.
10236 If N is nil and any articles have been marked with the process mark,
10237 respool those articles instead.
10239 Respooling can be done both from mail groups and \"real\" newsgroups.
10240 In the former case, the articles in question will be moved from the
10241 current group into whatever groups they are destined to. In the
10242 latter case, they will be copied into the relevant groups."
10243 (interactive
10244 (list current-prefix-arg
10245 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10246 (methname
10247 (symbol-name (or gnus-summary-respool-default-method
10248 (car (gnus-find-method-for-group
10249 gnus-newsgroup-name)))))
10250 (method
10251 (gnus-completing-read
10252 "Backend to use when respooling"
10253 methods t nil 'gnus-mail-method-history methname))
10255 (cond
10256 ((zerop (length (setq ms (gnus-servers-using-backend
10257 (intern method)))))
10258 (list (intern method) ""))
10259 ((= 1 (length ms))
10260 (car ms))
10262 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10263 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10264 ms-alist))))))))
10265 (unless method
10266 (error "No method given for respooling"))
10267 (if (assoc (symbol-name
10268 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10269 (gnus-methods-using 'respool))
10270 (gnus-summary-move-article n nil method)
10271 (gnus-summary-copy-article n nil method)))
10273 (defun gnus-summary-import-article (file &optional edit)
10274 "Import an arbitrary file into a mail newsgroup."
10275 (interactive "fImport file: \nP")
10276 (let ((group gnus-newsgroup-name)
10277 (now (current-time))
10278 atts lines group-art)
10279 (unless (gnus-check-backend-function 'request-accept-article group)
10280 (error "%s does not support article importing" group))
10281 (or (file-readable-p file)
10282 (not (file-regular-p file))
10283 (error "Can't read %s" file))
10284 (with-current-buffer (gnus-get-buffer-create " *import file*")
10285 (erase-buffer)
10286 (nnheader-insert-file-contents file)
10287 (goto-char (point-min))
10288 (if (nnheader-article-p)
10289 (save-restriction
10290 (goto-char (point-min))
10291 (search-forward "\n\n" nil t)
10292 (narrow-to-region (point-min) (1- (point)))
10293 (goto-char (point-min))
10294 (unless (re-search-forward "^date:" nil t)
10295 (goto-char (point-max))
10296 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10297 ;; This doesn't look like an article, so we fudge some headers.
10298 (setq atts (file-attributes file)
10299 lines (count-lines (point-min) (point-max)))
10300 (insert "From: " (read-string "From: ") "\n"
10301 "Subject: " (read-string "Subject: ") "\n"
10302 "Date: " (message-make-date (nth 5 atts)) "\n"
10303 "Message-ID: " (message-make-message-id) "\n"
10304 "Lines: " (int-to-string lines) "\n"
10305 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10306 (setq group-art (gnus-request-accept-article group nil t))
10307 (kill-buffer (current-buffer)))
10308 (setq gnus-newsgroup-active (gnus-activate-group group))
10309 (forward-line 1)
10310 (gnus-summary-goto-article (cdr group-art) nil t)
10311 (when edit
10312 (gnus-summary-edit-article))))
10314 (defun gnus-summary-create-article ()
10315 "Create an article in a mail newsgroup."
10316 (interactive)
10317 (let ((group gnus-newsgroup-name)
10318 (now (current-time))
10319 group-art)
10320 (unless (gnus-check-backend-function 'request-accept-article group)
10321 (error "%s does not support article importing" group))
10322 (with-current-buffer (gnus-get-buffer-create " *import file*")
10323 (erase-buffer)
10324 (goto-char (point-min))
10325 ;; This doesn't look like an article, so we fudge some headers.
10326 (insert "From: " (read-string "From: ") "\n"
10327 "Subject: " (read-string "Subject: ") "\n"
10328 "Date: " (message-make-date now) "\n"
10329 "Message-ID: " (message-make-message-id) "\n")
10330 (setq group-art (gnus-request-accept-article group nil t))
10331 (kill-buffer (current-buffer)))
10332 (setq gnus-newsgroup-active (gnus-activate-group group))
10333 (forward-line 1)
10334 (gnus-summary-goto-article (cdr group-art) nil t)
10335 (gnus-summary-edit-article)))
10337 (defun gnus-summary-article-posted-p ()
10338 "Say whether the current (mail) article is available from news as well.
10339 This will be the case if the article has both been mailed and posted."
10340 (interactive)
10341 (let ((id (mail-header-references (gnus-summary-article-header)))
10342 (gnus-override-method (car (gnus-refer-article-methods))))
10343 (if (gnus-request-head id "")
10344 (gnus-message 2 "The current message was found on %s"
10345 gnus-override-method)
10346 (gnus-message 2 "The current message couldn't be found on %s"
10347 gnus-override-method)
10348 nil)))
10350 (defun gnus-summary-expire-articles (&optional now)
10351 "Expire all articles that are marked as expirable in the current group."
10352 (interactive)
10353 (when (and (not gnus-group-is-exiting-without-update-p)
10354 (gnus-check-backend-function
10355 'request-expire-articles gnus-newsgroup-name))
10356 ;; This backend supports expiry.
10357 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10358 (expirable
10359 (gnus-list-range-difference
10360 (if total
10361 (progn
10362 ;; We need to update the info for
10363 ;; this group for `gnus-list-of-read-articles'
10364 ;; to give us the right answer.
10365 (gnus-run-hooks 'gnus-exit-group-hook)
10366 (gnus-summary-update-info)
10367 (gnus-list-of-read-articles gnus-newsgroup-name))
10368 (setq gnus-newsgroup-expirable
10369 (sort gnus-newsgroup-expirable '<)))
10370 gnus-newsgroup-unexist))
10371 (expiry-wait (if now 'immediate
10372 (gnus-group-find-parameter
10373 gnus-newsgroup-name 'expiry-wait)))
10374 (nnmail-expiry-target
10375 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10376 nnmail-expiry-target))
10378 (when expirable
10379 ;; There are expirable articles in this group, so we run them
10380 ;; through the expiry process.
10381 (gnus-message 6 "Expiring articles...")
10382 (when (gnus-check-group gnus-newsgroup-name)
10383 ;; The list of articles that weren't expired is returned.
10384 (save-excursion
10385 (if expiry-wait
10386 (let ((nnmail-expiry-wait-function nil)
10387 (nnmail-expiry-wait expiry-wait))
10388 (setq es (gnus-request-expire-articles
10389 expirable gnus-newsgroup-name)))
10390 (setq es (gnus-request-expire-articles
10391 expirable gnus-newsgroup-name)))
10392 (unless total
10393 (setq gnus-newsgroup-expirable es))
10394 ;; We go through the old list of expirable, and mark all
10395 ;; really expired articles as nonexistent.
10396 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10397 (let ((gnus-use-cache nil))
10398 (dolist (article expirable)
10399 (when (and (not (memq article es))
10400 (gnus-data-find article))
10401 (gnus-summary-mark-article article gnus-canceled-mark)
10402 (run-hook-with-args
10403 'gnus-summary-article-expire-hook
10404 'delete
10405 (gnus-data-header (assoc article (gnus-data-list nil)))
10406 gnus-newsgroup-name
10407 (cond
10408 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10409 ((eq nnmail-expiry-target 'delete) nil)
10411 (let ((rescall (funcall nnmail-expiry-target
10412 gnus-newsgroup-name)))
10413 (if (stringp rescall) rescall nil))))
10414 nil)))))))
10415 (gnus-message 6 "Expiring articles...done")))))
10417 (defun gnus-summary-expire-articles-now ()
10418 "Expunge all expirable articles in the current group.
10419 This means that *all* articles that are marked as expirable will be
10420 deleted forever, right now."
10421 (interactive)
10422 (or gnus-expert-user
10423 (gnus-yes-or-no-p
10424 "Are you really, really sure you want to delete all expirable messages? ")
10425 (error "Phew!"))
10426 (gnus-summary-expire-articles t))
10428 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10429 (defun gnus-summary-delete-article (&optional n)
10430 "Delete the N next (mail) articles.
10431 This command actually deletes articles. This is not a marking
10432 command. The article will disappear forever from your life, never to
10433 return.
10435 If N is negative, delete backwards.
10436 If N is nil and articles have been marked with the process mark,
10437 delete these instead.
10439 If `gnus-novice-user' is non-nil you will be asked for
10440 confirmation before the articles are deleted."
10441 (interactive "P")
10442 (unless (gnus-check-backend-function 'request-expire-articles
10443 gnus-newsgroup-name)
10444 (error "The current newsgroup does not support article deletion"))
10445 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10446 (error "Couldn't open server"))
10447 ;; Compute the list of articles to delete.
10448 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10449 (nnmail-expiry-target 'delete)
10450 not-deleted)
10451 (if (and gnus-novice-user
10452 (not (gnus-yes-or-no-p
10453 (format "Do you really want to delete %s forever? "
10454 (if (> (length articles) 1)
10455 (format "these %s articles" (length articles))
10456 "this article")))))
10458 ;; Delete the articles.
10459 (setq not-deleted (gnus-request-expire-articles
10460 articles gnus-newsgroup-name 'force))
10461 (save-excursion
10462 (while articles
10463 (gnus-summary-remove-process-mark (car articles))
10464 ;; The backend might not have been able to delete the article
10465 ;; after all.
10466 (unless (memq (car articles) not-deleted)
10467 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10468 (let* ((article (car articles))
10469 (ghead (gnus-data-header
10470 (assoc article (gnus-data-list nil)))))
10471 (run-hook-with-args 'gnus-summary-article-delete-hook
10472 'delete ghead gnus-newsgroup-name nil
10473 nil)))
10474 (setq articles (cdr articles))))
10475 (when not-deleted
10476 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10477 (gnus-summary-position-point)
10478 (gnus-set-mode-line 'summary)
10479 not-deleted))
10481 (defun gnus-summary-edit-article (&optional arg)
10482 "Edit the current article.
10483 This will have permanent effect only in mail groups.
10484 If ARG is nil, edit the decoded articles.
10485 If ARG is 1, edit the raw articles.
10486 If ARG is 2, edit the raw articles even in read-only groups.
10487 If ARG is 3, edit the articles with the current handles.
10488 Otherwise, allow editing of articles even in read-only
10489 groups."
10490 (interactive "P")
10491 (let (force raw current-handles)
10492 (cond
10493 ((null arg))
10494 ((eq arg 1)
10495 (setq raw t))
10496 ((eq arg 2)
10497 (setq raw t
10498 force t))
10499 ((eq arg 3)
10500 (setq current-handles
10501 (and (gnus-buffer-live-p gnus-article-buffer)
10502 (with-current-buffer gnus-article-buffer
10503 (prog1
10504 gnus-article-mime-handles
10505 (setq gnus-article-mime-handles nil))))))
10507 (setq force t)))
10508 (when (and raw (not force)
10509 (member gnus-newsgroup-name '("nndraft:delayed"
10510 "nndraft:drafts"
10511 "nndraft:queue")))
10512 (error "Can't edit the raw article in group %s"
10513 gnus-newsgroup-name))
10514 (with-current-buffer gnus-summary-buffer
10515 (let ((mail-parse-charset gnus-newsgroup-charset)
10516 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10517 (gnus-set-global-variables)
10518 (when (and (not force)
10519 (gnus-group-read-only-p))
10520 (error "The current newsgroup does not support article editing"))
10521 (gnus-summary-show-article t)
10522 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10523 (with-current-buffer gnus-article-buffer
10524 (mm-enable-multibyte)))
10525 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10526 (setq raw t))
10527 (gnus-article-edit-article
10528 (if raw 'ignore
10529 `(lambda ()
10530 (let ((mbl mml-buffer-list))
10531 (setq mml-buffer-list nil)
10532 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10533 (mime-to-mml ,'current-handles))
10534 (let ((mbl1 mml-buffer-list))
10535 (setq mml-buffer-list mbl)
10536 (set (make-local-variable 'mml-buffer-list) mbl1))
10537 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10538 `(lambda (no-highlight)
10539 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10540 (message-options message-options)
10541 (message-options-set-recipient)
10542 (mail-parse-ignored-charsets
10543 ',gnus-newsgroup-ignored-charsets)
10544 (rfc2047-header-encoding-alist
10545 ',(let ((charset (gnus-group-name-charset
10546 (gnus-find-method-for-group
10547 gnus-newsgroup-name)
10548 gnus-newsgroup-name)))
10549 (append (list (cons "Newsgroups" charset)
10550 (cons "Followup-To" charset)
10551 (cons "Xref" charset))
10552 rfc2047-header-encoding-alist))))
10553 ,(if (not raw) '(progn
10554 (mml-to-mime)
10555 (mml-destroy-buffers)
10556 (remove-hook 'kill-buffer-hook
10557 'mml-destroy-buffers t)
10558 (kill-local-variable 'mml-buffer-list)))
10559 (gnus-summary-edit-article-done
10560 ,(or (mail-header-references gnus-current-headers) "")
10561 ,(gnus-group-read-only-p)
10562 ,gnus-summary-buffer no-highlight))))))))
10564 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10566 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10567 no-highlight)
10568 "Make edits to the current article permanent."
10569 (interactive)
10570 (save-excursion
10571 ;; The buffer restriction contains the entire article if it exists.
10572 (when (article-goto-body)
10573 (let ((lines (count-lines (point) (point-max)))
10574 (length (- (point-max) (point)))
10575 (case-fold-search t)
10576 (body (point-marker)))
10577 (goto-char (point-min))
10578 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10579 (delete-region (match-beginning 1) (match-end 1))
10580 (insert (number-to-string length)))
10581 (goto-char (point-min))
10582 (when (re-search-forward
10583 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10584 (delete-region (match-beginning 1) (match-end 1))
10585 (insert (number-to-string length)))
10586 (goto-char (point-min))
10587 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10588 (delete-region (match-beginning 1) (match-end 1))
10589 (insert (number-to-string lines))))))
10590 ;; Replace the article.
10591 (let ((buf (current-buffer))
10592 (article (cdr gnus-article-current))
10593 replace-result)
10594 (with-temp-buffer
10595 (insert-buffer-substring buf)
10596 (if (and (not read-only)
10597 (not (setq replace-result
10598 (gnus-request-replace-article
10599 article (car gnus-article-current)
10600 (current-buffer) t))))
10601 (error "Couldn't replace article")
10602 ;; If we got a number back, then that's the new article number
10603 ;; for this article. Otherwise, the article number didn't change.
10604 (when (numberp replace-result)
10605 (with-current-buffer gnus-summary-buffer
10606 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10607 (gnus-summary-limit gnus-newsgroup-limit)
10608 (setq article replace-result)
10609 (gnus-summary-goto-subject article t)))
10610 ;; Update the summary buffer.
10611 (if (and references
10612 (equal (message-tokenize-header references " ")
10613 (message-tokenize-header
10614 (or (message-fetch-field "references") "") " ")))
10615 ;; We only have to update this line.
10616 (save-excursion
10617 (save-restriction
10618 (message-narrow-to-head)
10619 (let ((head (buffer-substring-no-properties
10620 (point-min) (point-max)))
10621 header)
10622 (with-temp-buffer
10623 (insert (format "211 %d Article retrieved.\n" article))
10624 (insert head)
10625 (insert ".\n")
10626 (let ((nntp-server-buffer (current-buffer)))
10627 (setq header (car (gnus-get-newsgroup-headers nil t))))
10628 (with-current-buffer gnus-summary-buffer
10629 (gnus-data-set-header (gnus-data-find article) header)
10630 (gnus-summary-update-article-line article header)
10631 (if (gnus-summary-goto-subject article nil t)
10632 (gnus-summary-update-secondary-mark article)))))))
10633 ;; Update threads.
10634 (set-buffer (or buffer gnus-summary-buffer))
10635 (gnus-summary-update-article article)
10636 (if (gnus-summary-goto-subject article nil t)
10637 (gnus-summary-update-secondary-mark article)))
10638 ;; Prettify the article buffer again.
10639 (unless no-highlight
10640 (with-current-buffer gnus-article-buffer
10641 ;;!!! Fix this -- article should be rehighlighted.
10642 ;;(gnus-run-hooks 'gnus-article-display-hook)
10643 (set-buffer gnus-original-article-buffer)
10644 (gnus-request-article
10645 article (car gnus-article-current) (current-buffer))))
10646 ;; Prettify the summary buffer line.
10647 (when (gnus-visual-p 'summary-highlight 'highlight)
10648 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10650 (defun gnus-summary-edit-wash (key)
10651 "Perform editing command KEY in the article buffer."
10652 (interactive
10653 (list
10654 (progn
10655 (message "%s" (concat (this-command-keys) "- "))
10656 (read-char))))
10657 (message "")
10658 (gnus-summary-edit-article)
10659 (execute-kbd-macro (concat (this-command-keys) key))
10660 (gnus-article-edit-done))
10662 ;;; Respooling
10664 (defvar nnimap-split-fancy)
10665 (defvar nnimap-split-methods)
10667 (defun gnus-summary-respool-query (&optional silent trace)
10668 "Query where the respool algorithm would put this article."
10669 (interactive)
10670 (let (gnus-mark-article-hook)
10671 (gnus-summary-select-article)
10672 (with-current-buffer gnus-original-article-buffer
10673 (let ((groups
10674 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10675 'nnimap)
10676 ;; nnimap has its own splitting variables.
10677 (let ((nnmail-split-methods
10678 (cond
10679 ((eq nnimap-split-methods 'default)
10680 nnmail-split-methods)
10681 (nnimap-split-methods
10682 nnimap-split-methods)
10683 (nnimap-split-fancy
10684 'nnmail-split-fancy)))
10685 (nnmail-split-fancy (or nnimap-split-fancy
10686 nnmail-split-fancy)))
10687 (nnmail-article-group 'identity trace))
10688 (nnmail-article-group 'identity trace))))
10689 (unless silent
10690 (if groups
10691 (message "This message would go to %s"
10692 (mapconcat 'car groups ", "))
10693 (message "This message would go to no groups"))
10694 groups)))))
10696 (defun gnus-summary-respool-trace ()
10697 "Trace where the respool algorithm would put this article.
10698 Display a buffer showing all fancy splitting patterns which matched."
10699 (interactive)
10700 (gnus-summary-respool-query nil t))
10702 ;; Summary marking commands.
10704 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10705 "Mark articles which has the same subject as read, and then select the next.
10706 If UNMARK is positive, remove any kind of mark.
10707 If UNMARK is negative, tick articles."
10708 (interactive "P")
10709 (when unmark
10710 (setq unmark (prefix-numeric-value unmark)))
10711 (let ((count
10712 (gnus-summary-mark-same-subject
10713 (gnus-summary-article-subject) unmark)))
10714 ;; Select next unread article. If auto-select-same mode, should
10715 ;; select the first unread article.
10716 (gnus-summary-next-article t (and gnus-auto-select-same
10717 (gnus-summary-article-subject)))
10718 (gnus-message 7 "%d article%s marked as %s"
10719 count (if (= count 1) " is" "s are")
10720 (if unmark "unread" "read"))))
10722 (defun gnus-summary-kill-same-subject (&optional unmark)
10723 "Mark articles which has the same subject as read.
10724 If UNMARK is positive, remove any kind of mark.
10725 If UNMARK is negative, tick articles."
10726 (interactive "P")
10727 (when unmark
10728 (setq unmark (prefix-numeric-value unmark)))
10729 (let ((count
10730 (gnus-summary-mark-same-subject
10731 (gnus-summary-article-subject) unmark)))
10732 ;; If marked as read, go to next unread subject.
10733 (when (null unmark)
10734 ;; Go to next unread subject.
10735 (gnus-summary-next-subject 1 t))
10736 (gnus-message 7 "%d articles are marked as %s"
10737 count (if unmark "unread" "read"))))
10739 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10740 "Mark articles with same SUBJECT as read, and return marked number.
10741 If optional argument UNMARK is positive, remove any kinds of marks.
10742 If optional argument UNMARK is negative, mark articles as unread instead."
10743 (let ((count 1))
10744 (save-excursion
10745 (cond
10746 ((null unmark) ; Mark as read.
10747 (while (and
10748 (progn
10749 (gnus-summary-mark-article-as-read gnus-killed-mark)
10750 (gnus-summary-show-thread) t)
10751 (gnus-summary-find-subject subject))
10752 (setq count (1+ count))))
10753 ((> unmark 0) ; Tick.
10754 (while (and
10755 (progn
10756 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10757 (gnus-summary-show-thread) t)
10758 (gnus-summary-find-subject subject))
10759 (setq count (1+ count))))
10760 (t ; Mark as unread.
10761 (while (and
10762 (progn
10763 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10764 (gnus-summary-show-thread) t)
10765 (gnus-summary-find-subject subject))
10766 (setq count (1+ count)))))
10767 (gnus-set-mode-line 'summary)
10768 ;; Return the number of marked articles.
10769 count)))
10771 (defun gnus-summary-mark-as-processable (n &optional unmark)
10772 "Set the process mark on the next N articles.
10773 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10774 the process mark instead. The difference between N and the actual
10775 number of articles marked is returned."
10776 (interactive "P")
10777 (if (and (null n) (and transient-mark-mode mark-active))
10778 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10779 (setq n (prefix-numeric-value n))
10780 (let ((backward (< n 0))
10781 (n (abs n)))
10782 (while (and
10783 (> n 0)
10784 (if unmark
10785 (gnus-summary-remove-process-mark
10786 (gnus-summary-article-number))
10787 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10788 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10789 (setq n (1- n)))
10790 (when (/= 0 n)
10791 (gnus-message 7 "No more articles"))
10792 (gnus-summary-recenter)
10793 (gnus-summary-position-point)
10794 n)))
10796 (defun gnus-summary-unmark-as-processable (n)
10797 "Remove the process mark from the next N articles.
10798 If N is negative, unmark backward instead. The difference between N and
10799 the actual number of articles unmarked is returned."
10800 (interactive "P")
10801 (gnus-summary-mark-as-processable n t))
10803 (defun gnus-summary-unmark-all-processable ()
10804 "Remove the process mark from all articles."
10805 (interactive)
10806 (save-excursion
10807 (while gnus-newsgroup-processable
10808 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10809 (gnus-summary-position-point))
10811 (defun gnus-summary-add-mark (article type)
10812 "Mark ARTICLE with a mark of TYPE."
10813 (let ((vtype (car (assq type gnus-article-mark-lists)))
10814 var)
10815 (if (not vtype)
10816 (error "No such mark type: %s" type)
10817 (setq var (intern (format "gnus-newsgroup-%s" type)))
10818 (set var (cons article (symbol-value var)))
10819 (if (memq type '(processable cached replied forwarded recent saved))
10820 (gnus-summary-update-secondary-mark article)
10821 ;;; !!! This is bogus. We should find out what primary
10822 ;;; !!! mark we want to set.
10823 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10825 (defun gnus-summary-mark-as-expirable (n)
10826 "Mark N articles forward as expirable.
10827 If N is negative, mark backward instead. The difference between N and
10828 the actual number of articles marked is returned."
10829 (interactive "p")
10830 (gnus-summary-mark-forward n gnus-expirable-mark))
10832 (defun gnus-summary-mark-as-spam (n)
10833 "Mark N articles forward as spam.
10834 If N is negative, mark backward instead. The difference between N and
10835 the actual number of articles marked is returned."
10836 (interactive "p")
10837 (gnus-summary-mark-forward n gnus-spam-mark))
10839 (defun gnus-summary-mark-article-as-replied (article)
10840 "Mark ARTICLE as replied to and update the summary line.
10841 ARTICLE can also be a list of articles."
10842 (interactive (list (gnus-summary-article-number)))
10843 (let ((articles (if (listp article) article (list article))))
10844 (dolist (article articles)
10845 (unless (numberp article)
10846 (error "%s is not a number" article))
10847 (push article gnus-newsgroup-replied)
10848 (let ((inhibit-read-only t))
10849 (when (gnus-summary-goto-subject article nil t)
10850 (gnus-summary-update-secondary-mark article))))))
10852 (defun gnus-summary-mark-article-as-forwarded (article)
10853 "Mark ARTICLE as forwarded and update the summary line.
10854 ARTICLE can also be a list of articles."
10855 (let ((articles (if (listp article) article (list article))))
10856 (dolist (article articles)
10857 (push article gnus-newsgroup-forwarded)
10858 (let ((inhibit-read-only t))
10859 (when (gnus-summary-goto-subject article nil t)
10860 (gnus-summary-update-secondary-mark article))))))
10862 (defun gnus-summary-set-bookmark (article)
10863 "Set a bookmark in current article."
10864 (interactive (list (gnus-summary-article-number)))
10865 (when (or (not (get-buffer gnus-article-buffer))
10866 (not gnus-current-article)
10867 (not gnus-article-current)
10868 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10869 (error "No current article selected"))
10870 ;; Remove old bookmark, if one exists.
10871 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10872 ;; Set the new bookmark, which is on the form
10873 ;; (article-number . line-number-in-body).
10874 (push
10875 (cons article
10876 (with-current-buffer gnus-article-buffer
10877 (count-lines
10878 (min (point)
10879 (save-excursion
10880 (article-goto-body)
10881 (point)))
10882 (point))))
10883 gnus-newsgroup-bookmarks)
10884 (gnus-message 6 "A bookmark has been added to the current article."))
10886 (defun gnus-summary-remove-bookmark (article)
10887 "Remove the bookmark from the current article."
10888 (interactive (list (gnus-summary-article-number)))
10889 ;; Remove old bookmark, if one exists.
10890 (if (not (assq article gnus-newsgroup-bookmarks))
10891 (gnus-message 6 "No bookmark in current article.")
10892 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10893 (gnus-message 6 "Removed bookmark.")))
10895 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10896 (defun gnus-summary-mark-as-dormant (n)
10897 "Mark N articles forward as dormant.
10898 If N is negative, mark backward instead. The difference between N and
10899 the actual number of articles marked is returned."
10900 (interactive "p")
10901 (gnus-summary-mark-forward n gnus-dormant-mark))
10903 (defun gnus-summary-set-process-mark (article)
10904 "Set the process mark on ARTICLE and update the summary line."
10905 (setq gnus-newsgroup-processable
10906 (cons article
10907 (delq article gnus-newsgroup-processable)))
10908 (when (gnus-summary-goto-subject article)
10909 (gnus-summary-show-thread)
10910 (gnus-summary-goto-subject article)
10911 (gnus-summary-update-secondary-mark article)))
10913 (defun gnus-summary-remove-process-mark (&rest articles)
10914 "Remove the process mark from ARTICLES and update the summary line."
10915 (dolist (article articles)
10916 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10917 (when (gnus-summary-goto-subject article)
10918 (gnus-summary-show-thread)
10919 (gnus-summary-goto-subject article)
10920 (gnus-summary-update-secondary-mark article)))
10923 (defun gnus-summary-set-saved-mark (article)
10924 "Set the process mark on ARTICLE and update the summary line."
10925 (push article gnus-newsgroup-saved)
10926 (when (gnus-summary-goto-subject article)
10927 (gnus-summary-update-secondary-mark article)))
10929 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10930 "Mark N articles as read forwards.
10931 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10932 The difference between N and the actual number of articles marked is
10933 returned.
10934 If NO-EXPIRE, auto-expiry will be inhibited."
10935 (interactive "p")
10936 (gnus-summary-show-thread)
10937 (let ((backward (< n 0))
10938 (gnus-summary-goto-unread
10939 (and gnus-summary-goto-unread
10940 (not (eq gnus-summary-goto-unread 'never))
10941 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10942 gnus-ticked-mark gnus-dormant-mark)))))
10943 (n (abs n))
10944 (mark (or mark gnus-del-mark)))
10945 (while (and (> n 0)
10946 (gnus-summary-mark-article nil mark no-expire)
10947 (zerop (gnus-summary-next-subject
10948 (if backward -1 1)
10949 (and gnus-summary-goto-unread
10950 (not (eq gnus-summary-goto-unread 'never)))
10951 t)))
10952 (setq n (1- n)))
10953 (when (/= 0 n)
10954 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10955 (gnus-summary-recenter)
10956 (gnus-summary-position-point)
10957 (gnus-set-mode-line 'summary)
10960 (defun gnus-summary-mark-article-as-read (mark)
10961 "Mark the current article quickly as read with MARK."
10962 (let ((article (gnus-summary-article-number)))
10963 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10964 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10965 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10966 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10967 (push (cons article mark) gnus-newsgroup-reads)
10968 ;; Possibly remove from cache, if that is used.
10969 (when gnus-use-cache
10970 (gnus-cache-enter-remove-article article))
10971 ;; Allow the backend to change the mark.
10972 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10973 ;; Check for auto-expiry.
10974 (when (and gnus-newsgroup-auto-expire
10975 (memq mark gnus-auto-expirable-marks))
10976 (setq mark gnus-expirable-mark)
10977 ;; Let the backend know about the mark change.
10978 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10979 (push article gnus-newsgroup-expirable))
10980 ;; Set the mark in the buffer.
10981 (gnus-summary-update-mark mark 'unread)
10984 (defun gnus-summary-mark-article-as-unread (mark)
10985 "Mark the current article quickly as unread with MARK."
10986 (let* ((article (gnus-summary-article-number))
10987 (old-mark (gnus-summary-article-mark article)))
10988 ;; Allow the backend to change the mark.
10989 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10990 (if (eq mark old-mark)
10992 (if (<= article 0)
10993 (progn
10994 (gnus-error 1 "Can't mark negative article numbers")
10995 nil)
10996 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10997 (setq gnus-newsgroup-spam-marked
10998 (delq article gnus-newsgroup-spam-marked))
10999 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11000 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11001 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11002 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11003 (cond ((= mark gnus-ticked-mark)
11004 (setq gnus-newsgroup-marked
11005 (gnus-add-to-sorted-list gnus-newsgroup-marked
11006 article)))
11007 ((= mark gnus-spam-mark)
11008 (setq gnus-newsgroup-spam-marked
11009 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11010 article)))
11011 ((= mark gnus-dormant-mark)
11012 (setq gnus-newsgroup-dormant
11013 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11014 article)))
11016 (setq gnus-newsgroup-unreads
11017 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11018 article))))
11019 (gnus-alist-pull article gnus-newsgroup-reads)
11021 ;; See whether the article is to be put in the cache.
11022 (and gnus-use-cache
11023 (vectorp (gnus-summary-article-header article))
11024 (save-excursion
11025 (gnus-cache-possibly-enter-article
11026 gnus-newsgroup-name article
11027 (= mark gnus-ticked-mark)
11028 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11030 ;; Fix the mark.
11031 (gnus-summary-update-mark mark 'unread)
11032 t))))
11034 (defun gnus-summary-mark-article (&optional article mark no-expire)
11035 "Mark ARTICLE with MARK. MARK can be any character.
11036 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11037 `??' (dormant) and `?E' (expirable).
11038 If MARK is nil, then the default character `?r' is used.
11039 If ARTICLE is nil, then the article on the current line will be
11040 marked.
11041 If NO-EXPIRE, auto-expiry will be inhibited."
11042 ;; The mark might be a string.
11043 (when (stringp mark)
11044 (setq mark (aref mark 0)))
11045 ;; If no mark is given, then we check auto-expiring.
11046 (when (null mark)
11047 (setq mark gnus-del-mark))
11048 (when (and (not no-expire)
11049 gnus-newsgroup-auto-expire
11050 (memq mark gnus-auto-expirable-marks))
11051 (setq mark gnus-expirable-mark))
11052 (let ((article (or article (gnus-summary-article-number)))
11053 (old-mark (gnus-summary-article-mark article)))
11054 ;; Allow the backend to change the mark.
11055 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11056 (if (eq mark old-mark)
11058 (unless article
11059 (error "No article on current line"))
11060 (if (not (if (or (= mark gnus-unread-mark)
11061 (= mark gnus-ticked-mark)
11062 (= mark gnus-spam-mark)
11063 (= mark gnus-dormant-mark))
11064 (gnus-mark-article-as-unread article mark)
11065 (gnus-mark-article-as-read article mark)))
11067 ;; See whether the article is to be put in the cache.
11068 (and gnus-use-cache
11069 (not (= mark gnus-canceled-mark))
11070 (vectorp (gnus-summary-article-header article))
11071 (save-excursion
11072 (gnus-cache-possibly-enter-article
11073 gnus-newsgroup-name article
11074 (= mark gnus-ticked-mark)
11075 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11077 (when (gnus-summary-goto-subject article nil t)
11078 (let ((inhibit-read-only t))
11079 (gnus-summary-show-thread)
11080 ;; Fix the mark.
11081 (gnus-summary-update-mark mark 'unread)
11082 t))))))
11084 (defun gnus-summary-update-secondary-mark (article)
11085 "Update the secondary (read, process, cache) mark."
11086 (gnus-summary-update-mark
11087 (cond ((memq article gnus-newsgroup-processable)
11088 gnus-process-mark)
11089 ((memq article gnus-newsgroup-cached)
11090 gnus-cached-mark)
11091 ((memq article gnus-newsgroup-replied)
11092 gnus-replied-mark)
11093 ((memq article gnus-newsgroup-forwarded)
11094 gnus-forwarded-mark)
11095 ((memq article gnus-newsgroup-saved)
11096 gnus-saved-mark)
11097 ((memq article gnus-newsgroup-unseen)
11098 gnus-unseen-mark)
11099 (t gnus-no-mark))
11100 'replied)
11101 (when (gnus-visual-p 'summary-highlight 'highlight)
11102 (gnus-summary-highlight-line)
11103 (gnus-run-hooks 'gnus-summary-update-hook))
11106 (defun gnus-summary-update-download-mark (article)
11107 "Update the download mark."
11108 (gnus-summary-update-mark
11109 (cond ((memq article gnus-newsgroup-undownloaded)
11110 gnus-undownloaded-mark)
11111 (gnus-newsgroup-agentized
11112 gnus-downloaded-mark)
11114 gnus-no-mark))
11115 'download)
11116 (gnus-summary-update-line t)
11119 (defun gnus-summary-update-mark (mark type)
11120 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11121 (inhibit-read-only t))
11122 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11123 (when forward
11124 (when (looking-at "\r")
11125 (incf forward))
11126 (when (<= (+ forward (point)) (point-max))
11127 ;; Go to the right position on the line.
11128 (goto-char (+ forward (point)))
11129 ;; Replace the old mark with the new mark.
11130 (let ((to-insert
11131 (subst-char-in-string
11132 (char-after) mark
11133 (buffer-substring (point) (1+ (point))))))
11134 (delete-region (point) (1+ (point)))
11135 (insert to-insert))
11136 ;; Optionally update the marks by some user rule.
11137 (when (eq type 'unread)
11138 (gnus-data-set-mark
11139 (gnus-data-find (gnus-summary-article-number)) mark)
11140 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11142 (defun gnus-mark-article-as-read (article &optional mark)
11143 "Enter ARTICLE in the pertinent lists and remove it from others."
11144 ;; Make the article expirable.
11145 (let ((mark (or mark gnus-del-mark)))
11146 (setq gnus-newsgroup-expirable
11147 (if (= mark gnus-expirable-mark)
11148 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11149 (delq article gnus-newsgroup-expirable)))
11150 ;; Remove from unread and marked lists.
11151 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11152 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11153 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11154 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11155 (push (cons article mark) gnus-newsgroup-reads)
11156 ;; Possibly remove from cache, if that is used.
11157 (when gnus-use-cache
11158 (gnus-cache-enter-remove-article article))
11161 (defun gnus-mark-article-as-unread (article &optional mark)
11162 "Enter ARTICLE in the pertinent lists and remove it from others."
11163 (let ((mark (or mark gnus-ticked-mark)))
11164 (if (<= article 0)
11165 (progn
11166 (gnus-error 1 "Can't mark negative article numbers")
11167 nil)
11168 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11169 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11170 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11171 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11172 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11174 ;; Unsuppress duplicates?
11175 (when gnus-suppress-duplicates
11176 (gnus-dup-unsuppress-article article))
11178 (cond ((= mark gnus-ticked-mark)
11179 (setq gnus-newsgroup-marked
11180 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11181 ((= mark gnus-spam-mark)
11182 (setq gnus-newsgroup-spam-marked
11183 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11184 article)))
11185 ((= mark gnus-dormant-mark)
11186 (setq gnus-newsgroup-dormant
11187 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11189 (setq gnus-newsgroup-unreads
11190 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11191 (gnus-alist-pull article gnus-newsgroup-reads)
11192 t)))
11194 (defun gnus-summary-tick-article-forward (n)
11195 "Tick N articles forwards.
11196 If N is negative, tick backwards instead.
11197 The difference between N and the number of articles ticked is returned."
11198 (interactive "p")
11199 (gnus-summary-mark-forward n gnus-ticked-mark))
11201 (defun gnus-summary-tick-article-backward (n)
11202 "Tick N articles backwards.
11203 The difference between N and the number of articles ticked is returned."
11204 (interactive "p")
11205 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11207 (defun gnus-summary-tick-article (&optional article clear-mark)
11208 "Mark current article as unread.
11209 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11210 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11211 (interactive)
11212 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11213 gnus-ticked-mark)))
11215 (defun gnus-summary-mark-as-read-forward (n)
11216 "Mark N articles as read forwards.
11217 If N is negative, mark backwards instead.
11218 The difference between N and the actual number of articles marked is
11219 returned."
11220 (interactive "p")
11221 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11223 (defun gnus-summary-mark-as-read-backward (n)
11224 "Mark the N articles as read backwards.
11225 The difference between N and the actual number of articles marked is
11226 returned."
11227 (interactive "p")
11228 (gnus-summary-mark-forward
11229 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11231 (defun gnus-summary-mark-as-read (&optional article mark)
11232 "Mark current article as read.
11233 ARTICLE specifies the article to be marked as read.
11234 MARK specifies a string to be inserted at the beginning of the line."
11235 (gnus-summary-mark-article article mark))
11237 (defun gnus-summary-clear-mark-forward (n)
11238 "Clear marks from N articles forward.
11239 If N is negative, clear backward instead.
11240 The difference between N and the number of marks cleared is returned."
11241 (interactive "p")
11242 (gnus-summary-mark-forward n gnus-unread-mark))
11244 (defun gnus-summary-clear-mark-backward (n)
11245 "Clear marks from N articles backward.
11246 The difference between N and the number of marks cleared is returned."
11247 (interactive "p")
11248 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11250 (defun gnus-summary-mark-unread-as-read ()
11251 "Intended to be used by `gnus-mark-article-hook'."
11252 (when (memq gnus-current-article gnus-newsgroup-unreads)
11253 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11255 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11256 "Intended to be used by `gnus-mark-article-hook'."
11257 (let ((mark (gnus-summary-article-mark)))
11258 (when (or (gnus-unread-mark-p mark)
11259 (gnus-read-mark-p mark))
11260 (gnus-summary-mark-article gnus-current-article
11261 (or new-mark gnus-read-mark)))))
11263 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11264 "Intended to be used by `gnus-mark-article-hook'."
11265 (let ((mark (gnus-summary-article-mark)))
11266 (when (or (gnus-unread-mark-p mark)
11267 (gnus-read-mark-p mark))
11268 (gnus-summary-mark-article (gnus-summary-article-number)
11269 (or new-mark gnus-read-mark)))))
11271 (defun gnus-summary-mark-unread-as-ticked ()
11272 "Intended to be used by `gnus-mark-article-hook'."
11273 (when (memq gnus-current-article gnus-newsgroup-unreads)
11274 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11276 (defun gnus-summary-mark-region-as-read (point mark all)
11277 "Mark all unread articles between point and mark as read.
11278 If given a prefix, mark all articles between point and mark as read,
11279 even ticked and dormant ones."
11280 (interactive "r\nP")
11281 (save-excursion
11282 (let (article)
11283 (goto-char point)
11284 (beginning-of-line)
11285 (while (and
11286 (< (point) mark)
11287 (progn
11288 (when (or all
11289 (memq (setq article (gnus-summary-article-number))
11290 gnus-newsgroup-unreads))
11291 (gnus-summary-mark-article article gnus-del-mark))
11293 (gnus-summary-find-next))))))
11295 (defun gnus-summary-mark-below (score mark)
11296 "Mark articles with score less than SCORE with MARK."
11297 (interactive "P\ncMark: ")
11298 (setq score (if score
11299 (prefix-numeric-value score)
11300 (or gnus-summary-default-score 0)))
11301 (with-current-buffer gnus-summary-buffer
11302 (goto-char (point-min))
11303 (while
11304 (progn
11305 (and (< (gnus-summary-article-score) score)
11306 (gnus-summary-mark-article nil mark))
11307 (gnus-summary-find-next)))))
11309 (defun gnus-summary-kill-below (&optional score)
11310 "Mark articles with score below SCORE as read."
11311 (interactive "P")
11312 (gnus-summary-mark-below score gnus-killed-mark))
11314 (defun gnus-summary-clear-above (&optional score)
11315 "Clear all marks from articles with score above SCORE."
11316 (interactive "P")
11317 (gnus-summary-mark-above score gnus-unread-mark))
11319 (defun gnus-summary-tick-above (&optional score)
11320 "Tick all articles with score above SCORE."
11321 (interactive "P")
11322 (gnus-summary-mark-above score gnus-ticked-mark))
11324 (defun gnus-summary-mark-above (score mark)
11325 "Mark articles with score over SCORE with MARK."
11326 (interactive "P\ncMark: ")
11327 (setq score (if score
11328 (prefix-numeric-value score)
11329 (or gnus-summary-default-score 0)))
11330 (with-current-buffer gnus-summary-buffer
11331 (goto-char (point-min))
11332 (while (and (progn
11333 (when (> (gnus-summary-article-score) score)
11334 (gnus-summary-mark-article nil mark))
11336 (gnus-summary-find-next)))))
11338 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11339 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11340 (defun gnus-summary-limit-include-expunged (&optional no-error)
11341 "Display all the hidden articles that were expunged for low scores."
11342 (interactive)
11343 (let ((inhibit-read-only t))
11344 (let ((scored gnus-newsgroup-scored)
11345 headers h)
11346 (while scored
11347 (unless (gnus-summary-article-header (caar scored))
11348 (and (setq h (gnus-number-to-header (caar scored)))
11349 (< (cdar scored) gnus-summary-expunge-below)
11350 (push h headers)))
11351 (setq scored (cdr scored)))
11352 (if (not headers)
11353 (when (not no-error)
11354 (error "No expunged articles hidden"))
11355 (goto-char (point-min))
11356 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11357 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11358 (dolist (x headers)
11359 (push (mail-header-number x) gnus-newsgroup-limit))
11360 (gnus-summary-prepare-unthreaded (nreverse headers))
11361 (goto-char (point-min))
11362 (gnus-summary-position-point)
11363 t))))
11365 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11366 "Mark all unread articles in this newsgroup as read.
11367 If prefix argument ALL is non-nil, ticked and dormant articles will
11368 also be marked as read.
11369 If QUIETLY is non-nil, no questions will be asked.
11371 If TO-HERE is non-nil, it should be a point in the buffer. All
11372 articles before (after, if REVERSE is set) this point will be marked
11373 as read.
11375 Note that this function will only catch up the unread article
11376 in the current summary buffer limitation.
11378 The number of articles marked as read is returned."
11379 (interactive "P")
11380 (prog1
11381 (save-excursion
11382 (when (or quietly
11383 (not gnus-interactive-catchup) ;Without confirmation?
11384 gnus-expert-user
11385 (gnus-y-or-n-p
11386 (if all
11387 "Mark absolutely all articles as read? "
11388 "Mark all unread articles as read? ")))
11389 (if (and not-mark
11390 (not gnus-newsgroup-adaptive)
11391 (not gnus-newsgroup-auto-expire)
11392 (not gnus-suppress-duplicates)
11393 (or (not gnus-use-cache)
11394 (eq gnus-use-cache 'passive)))
11395 (progn
11396 (when all
11397 (setq gnus-newsgroup-marked nil
11398 gnus-newsgroup-spam-marked nil
11399 gnus-newsgroup-dormant nil))
11400 (setq gnus-newsgroup-unreads
11401 (gnus-sorted-nunion
11402 (gnus-sorted-intersection gnus-newsgroup-unreads
11403 gnus-newsgroup-downloadable)
11404 (gnus-sorted-difference gnus-newsgroup-unfetched
11405 gnus-newsgroup-cached))))
11406 ;; We actually mark all articles as canceled, which we
11407 ;; have to do when using auto-expiry or adaptive scoring.
11408 (gnus-summary-show-all-threads)
11409 (if (and to-here reverse)
11410 (progn
11411 (goto-char to-here)
11412 (gnus-summary-mark-current-read-and-unread-as-read
11413 gnus-catchup-mark)
11414 (while (gnus-summary-find-next (not all))
11415 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11416 (when (gnus-summary-first-subject (not all))
11417 (while (and
11418 (if to-here (< (point) to-here) t)
11419 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11420 (gnus-summary-find-next (not all))))))
11421 (gnus-set-mode-line 'summary))
11423 (gnus-summary-position-point)))
11425 (defun gnus-summary-catchup-to-here (&optional all)
11426 "Mark all unticked articles before the current one as read.
11427 If ALL is non-nil, also mark ticked and dormant articles as read."
11428 (interactive "P")
11429 (save-excursion
11430 (gnus-save-hidden-threads
11431 (let ((beg (point)))
11432 ;; We check that there are unread articles.
11433 (when (or all (gnus-summary-find-prev))
11434 (gnus-summary-catchup all t beg)))))
11435 (gnus-summary-position-point))
11437 (defun gnus-summary-catchup-from-here (&optional all)
11438 "Mark all unticked articles after (and including) the current one as read.
11439 If ALL is non-nil, also mark ticked and dormant articles as read."
11440 (interactive "P")
11441 (save-excursion
11442 (gnus-save-hidden-threads
11443 (let ((beg (point)))
11444 ;; We check that there are unread articles.
11445 (when (or all (gnus-summary-find-next))
11446 (gnus-summary-catchup all t beg nil t)))))
11447 (gnus-summary-position-point))
11449 (defun gnus-summary-catchup-all (&optional quietly)
11450 "Mark all articles in this newsgroup as read.
11451 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11452 instead, which marks only unread articles as read."
11453 (interactive "P")
11454 (gnus-summary-catchup t quietly))
11456 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11457 "Mark all unread articles in this group as read, then exit.
11458 If prefix argument ALL is non-nil, all articles are marked as read.
11459 If QUIETLY is non-nil, no questions will be asked."
11460 (interactive "P")
11461 (when (gnus-summary-catchup all quietly nil 'fast)
11462 ;; Select next newsgroup or exit.
11463 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11464 (eq gnus-auto-select-next 'quietly))
11465 (gnus-summary-next-group nil)
11466 (gnus-summary-exit))))
11468 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11469 "Mark all articles in this newsgroup as read, and then exit.
11470 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11471 instead, which marks only unread articles as read."
11472 (interactive "P")
11473 (gnus-summary-catchup-and-exit t quietly))
11475 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11476 "Mark all articles in this group as read and select the next group.
11477 If given a prefix, mark all articles, unread as well as ticked, as
11478 read."
11479 (interactive "P")
11480 (save-excursion
11481 (gnus-summary-catchup all))
11482 (gnus-summary-next-group))
11484 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11485 "Mark all articles in this group as read and select the previous group.
11486 If given a prefix, mark all articles, unread as well as ticked, as
11487 read."
11488 (interactive "P")
11489 (save-excursion
11490 (gnus-summary-catchup all))
11491 (gnus-summary-next-group nil nil t))
11494 ;;; with article
11497 (defmacro gnus-with-article (article &rest forms)
11498 "Select ARTICLE and perform FORMS in the original article buffer.
11499 Then replace the article with the result."
11500 `(progn
11501 ;; We don't want the article to be marked as read.
11502 (let (gnus-mark-article-hook)
11503 (gnus-summary-select-article t t nil ,article))
11504 (set-buffer gnus-original-article-buffer)
11505 ,@forms
11506 (if (not (gnus-check-backend-function
11507 'request-replace-article (car gnus-article-current)))
11508 (gnus-message 5 "Read-only group; not replacing")
11509 (unless (gnus-request-replace-article
11510 ,article (car gnus-article-current)
11511 (current-buffer) t)
11512 (error "Couldn't replace article")))
11513 ;; The cache and backlog have to be flushed somewhat.
11514 (when gnus-keep-backlog
11515 (gnus-backlog-remove-article
11516 (car gnus-article-current) (cdr gnus-article-current)))
11517 (when gnus-use-cache
11518 (gnus-cache-update-article
11519 (car gnus-article-current) (cdr gnus-article-current)))))
11521 (put 'gnus-with-article 'lisp-indent-function 1)
11522 (put 'gnus-with-article 'edebug-form-spec '(form body))
11524 ;; Thread-based commands.
11526 (defun gnus-summary-articles-in-thread (&optional article)
11527 "Return a list of all articles in the current thread.
11528 If ARTICLE is non-nil, return all articles in the thread that starts
11529 with that article."
11530 (let* ((article (or article (gnus-summary-article-number)))
11531 (data (gnus-data-find-list article))
11532 (top-level (gnus-data-level (car data)))
11533 (top-subject
11534 (cond ((null gnus-thread-operation-ignore-subject)
11535 (gnus-simplify-subject-re
11536 (mail-header-subject (gnus-data-header (car data)))))
11537 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11538 (gnus-simplify-subject-fuzzy
11539 (mail-header-subject (gnus-data-header (car data)))))
11540 (t nil)))
11541 (end-point (save-excursion
11542 (goto-char (gnus-data-pos (car data)))
11543 (if (gnus-summary-go-to-next-thread)
11544 (point) (point-max))))
11545 articles)
11546 (while (and data
11547 (< (gnus-data-pos (car data)) end-point))
11548 (when (or (not top-subject)
11549 (string= top-subject
11550 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11551 (gnus-simplify-subject-fuzzy
11552 (mail-header-subject
11553 (gnus-data-header (car data))))
11554 (gnus-simplify-subject-re
11555 (mail-header-subject
11556 (gnus-data-header (car data)))))))
11557 (push (gnus-data-number (car data)) articles))
11558 (unless (and (setq data (cdr data))
11559 (> (gnus-data-level (car data)) top-level))
11560 (setq data nil)))
11561 ;; Return the list of articles.
11562 (nreverse articles)))
11564 (defun gnus-summary-rethread-current ()
11565 "Rethread the thread the current article is part of."
11566 (interactive)
11567 (let* ((gnus-show-threads t)
11568 (article (gnus-summary-article-number))
11569 (id (mail-header-id (gnus-summary-article-header)))
11570 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11571 (unless id
11572 (error "No article on the current line"))
11573 (gnus-rebuild-thread id)
11574 (gnus-summary-goto-subject article)))
11576 (defun gnus-summary-reparent-thread ()
11577 "Make the current article child of the marked (or previous) article.
11579 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11580 is non-nil or the Subject: of both articles are the same."
11581 (interactive)
11582 (unless (not (gnus-group-read-only-p))
11583 (error "The current newsgroup does not support article editing"))
11584 (unless (<= (length gnus-newsgroup-processable) 1)
11585 (error "No more than one article may be marked"))
11586 (let ((child (gnus-summary-article-number))
11587 ;; First grab the marked article, otherwise one line up.
11588 (parent (if (not (null gnus-newsgroup-processable))
11589 (car gnus-newsgroup-processable)
11590 (save-excursion
11591 (if (eq (forward-line -1) 0)
11592 (gnus-summary-article-number)
11593 (error "Beginning of summary buffer"))))))
11594 (gnus-summary-reparent-children parent (list child))))
11596 (defun gnus-summary-reparent-children (parent children)
11597 "Make PARENT the parent of CHILDREN.
11598 When called interactively, PARENT is the current article and CHILDREN
11599 are the process-marked articles."
11600 (interactive
11601 (list (gnus-summary-article-number)
11602 (gnus-summary-work-articles nil)))
11603 (dolist (child children)
11604 (save-window-excursion
11605 (let ((gnus-article-buffer " *reparent*"))
11606 (unless (not (eq parent child))
11607 (error "An article may not be self-referential"))
11608 (let ((message-id (mail-header-id
11609 (gnus-summary-article-header parent))))
11610 (unless (and message-id (not (equal message-id "")))
11611 (error "No message-id in desired parent"))
11612 (gnus-with-article child
11613 (save-restriction
11614 (goto-char (point-min))
11615 (message-narrow-to-head)
11616 (if (re-search-forward "^References: " nil t)
11617 (progn
11618 (re-search-forward "^[^ \t]" nil t)
11619 (forward-line -1)
11620 (end-of-line)
11621 (insert " " message-id))
11622 (insert "References: " message-id "\n"))))
11623 (set-buffer gnus-summary-buffer)
11624 (gnus-summary-unmark-all-processable)
11625 (gnus-summary-update-article child)
11626 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11627 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11628 (gnus-summary-rethread-current)
11629 (gnus-message 3 "Article %d is now the child of article %d"
11630 child parent))))))
11632 (defun gnus-summary-toggle-threads (&optional arg)
11633 "Toggle showing conversation threads.
11634 If ARG is positive number, turn showing conversation threads on."
11635 (interactive "P")
11636 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11637 (setq gnus-show-threads
11638 (if (null arg) (not gnus-show-threads)
11639 (> (prefix-numeric-value arg) 0)))
11640 (gnus-summary-prepare)
11641 (gnus-summary-goto-subject current)
11642 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11643 (gnus-summary-position-point)))
11645 (defun gnus-summary-show-all-threads ()
11646 "Show all threads."
11647 (interactive)
11648 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11649 (gnus-summary-position-point))
11651 (defsubst gnus-summary--inv (p)
11652 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11654 (defun gnus-summary-show-thread ()
11655 "Show thread subtrees.
11656 Returns nil if no thread was there to be shown."
11657 (interactive)
11658 (let* ((orig (point))
11659 (end (point-at-eol))
11660 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11661 ;; Leave point at bol
11662 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11663 (eoi (and end (next-single-char-property-change end 'invisible))))
11664 (when eoi
11665 (remove-overlays beg eoi 'invisible 'gnus-sum)
11666 (goto-char orig)
11667 (gnus-summary-position-point)
11668 eoi)))
11670 (defun gnus-summary-maybe-hide-threads ()
11671 "If requested, hide the threads that should be hidden."
11672 (when (and gnus-show-threads
11673 gnus-thread-hide-subtree)
11674 (gnus-summary-hide-all-threads
11675 (if (or (consp gnus-thread-hide-subtree)
11676 (functionp gnus-thread-hide-subtree))
11677 (gnus-make-predicate gnus-thread-hide-subtree)
11678 nil))))
11680 ;;; Hiding predicates.
11682 (defun gnus-article-unread-p (header)
11683 (memq (mail-header-number header) gnus-newsgroup-unreads))
11685 (defun gnus-article-unseen-p (header)
11686 (memq (mail-header-number header) gnus-newsgroup-unseen))
11688 (defun gnus-map-articles (predicate articles)
11689 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11690 (apply 'gnus-or (mapcar predicate
11691 (mapcar (lambda (number)
11692 (gnus-summary-article-header number))
11693 articles))))
11695 (defun gnus-summary-hide-all-threads (&optional predicate)
11696 "Hide all thread subtrees.
11697 If PREDICATE is supplied, threads that satisfy this predicate
11698 will not be hidden."
11699 (interactive)
11700 (save-excursion
11701 (goto-char (point-min))
11702 (let ((end nil)
11703 (count 0))
11704 (while (not end)
11705 (incf count)
11706 (when (zerop (mod count 1000))
11707 (message "Hiding all threads... %d" count))
11708 (when (or (not predicate)
11709 (gnus-map-articles
11710 predicate (gnus-summary-article-children)))
11711 (gnus-summary-hide-thread))
11712 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11713 (gnus-summary-position-point))
11715 (defun gnus-summary-hide-thread ()
11716 "Hide thread subtrees.
11717 If PREDICATE is supplied, threads that satisfy this predicate
11718 will not be hidden.
11719 Returns nil if no threads were there to be hidden."
11720 (interactive)
11721 (beginning-of-line)
11722 (let ((start (point))
11723 (starteol (line-end-position))
11724 (article (gnus-summary-article-number)))
11725 ;; Go forward until either the buffer ends or the subthread ends.
11726 (when (and (not (eobp))
11727 (or (zerop (gnus-summary-next-thread 1 t))
11728 (goto-char (point-max))))
11729 (if (and (> (point) start)
11730 ;; FIXME: this should actually search for a non-invisible \n.
11731 (search-backward "\n" start t))
11732 (progn
11733 (when (> (point) starteol)
11734 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11735 (let ((ol (make-overlay starteol (point) nil t nil)))
11736 (overlay-put ol 'invisible 'gnus-sum)
11737 (overlay-put ol 'evaporate t)))
11738 (gnus-summary-goto-subject article)
11739 (when (> start (point))
11740 (message "Hiding the thread moved us backwards, aborting!")
11741 (goto-char (point-max))))
11742 (goto-char start)
11743 nil))))
11745 (defun gnus-summary-go-to-next-thread (&optional previous)
11746 "Go to the same level (or less) next thread.
11747 If PREVIOUS is non-nil, go to previous thread instead.
11748 Return the article number moved to, or nil if moving was impossible."
11749 (let ((level (gnus-summary-thread-level))
11750 (way (if previous -1 1))
11751 (beg (point)))
11752 (forward-line way)
11753 (while (and (not (eobp))
11754 (< level (gnus-summary-thread-level)))
11755 (forward-line way))
11756 (if (eobp)
11757 (progn
11758 (goto-char beg)
11759 nil)
11760 (setq beg (point))
11761 (prog1
11762 (gnus-summary-article-number)
11763 (goto-char beg)))))
11765 (defun gnus-summary-next-thread (n &optional silent)
11766 "Go to the same level next N'th thread.
11767 If N is negative, search backward instead.
11768 Returns the difference between N and the number of skips actually
11769 done.
11771 If SILENT, don't output messages."
11772 (interactive "p")
11773 (let ((backward (< n 0))
11774 (n (abs n)))
11775 (while (and (> n 0)
11776 (gnus-summary-go-to-next-thread backward))
11777 (decf n))
11778 (unless silent
11779 (gnus-summary-position-point))
11780 (when (and (not silent) (/= 0 n))
11781 (gnus-message 7 "No more threads"))
11784 (defun gnus-summary-prev-thread (n)
11785 "Go to the same level previous N'th thread.
11786 Returns the difference between N and the number of skips actually
11787 done."
11788 (interactive "p")
11789 (gnus-summary-next-thread (- n)))
11791 (defun gnus-summary-go-down-thread ()
11792 "Go down one level in the current thread."
11793 (let ((children (gnus-summary-article-children)))
11794 (when children
11795 (gnus-summary-goto-subject (car children)))))
11797 (defun gnus-summary-go-up-thread ()
11798 "Go up one level in the current thread."
11799 (let ((parent (gnus-summary-article-parent)))
11800 (when parent
11801 (gnus-summary-goto-subject parent))))
11803 (defun gnus-summary-down-thread (n)
11804 "Go down thread N steps.
11805 If N is negative, go up instead.
11806 Returns the difference between N and how many steps down that were
11807 taken."
11808 (interactive "p")
11809 (let ((up (< n 0))
11810 (n (abs n)))
11811 (while (and (> n 0)
11812 (if up (gnus-summary-go-up-thread)
11813 (gnus-summary-go-down-thread)))
11814 (setq n (1- n)))
11815 (gnus-summary-position-point)
11816 (when (/= 0 n)
11817 (gnus-message 7 "Can't go further"))
11820 (defun gnus-summary-up-thread (n)
11821 "Go up thread N steps.
11822 If N is negative, go down instead.
11823 Returns the difference between N and how many steps down that were
11824 taken."
11825 (interactive "p")
11826 (gnus-summary-down-thread (- n)))
11828 (defun gnus-summary-top-thread ()
11829 "Go to the top of the thread."
11830 (interactive)
11831 (while (gnus-summary-go-up-thread))
11832 (gnus-summary-article-number))
11834 (defun gnus-summary-expire-thread ()
11835 "Mark articles under current thread as expired."
11836 (interactive)
11837 (gnus-summary-kill-thread 0))
11839 (defun gnus-summary-kill-thread (&optional unmark)
11840 "Mark articles under current thread as read.
11841 If the prefix argument is positive, remove any kinds of marks.
11842 If the prefix argument is zero, mark thread as expired.
11843 If the prefix argument is negative, tick articles instead."
11844 (interactive "P")
11845 (when unmark
11846 (setq unmark (prefix-numeric-value unmark)))
11847 (let ((articles (gnus-summary-articles-in-thread))
11848 (hide (or (null unmark) (= unmark 0))))
11849 (save-excursion
11850 ;; Expand the thread.
11851 (gnus-summary-show-thread)
11852 ;; Mark all the articles.
11853 (while articles
11854 (gnus-summary-goto-subject (car articles))
11855 (cond ((null unmark)
11856 (gnus-summary-mark-article-as-read gnus-killed-mark))
11857 ((> unmark 0)
11858 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11859 ((= unmark 0)
11860 (gnus-summary-mark-article nil gnus-expirable-mark))
11862 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11863 (setq articles (cdr articles))))
11864 ;; Hide killed subtrees when hide is true.
11865 (and hide
11866 gnus-thread-hide-killed
11867 (gnus-summary-hide-thread))
11868 ;; If hide is t, go to next unread subject.
11869 (when hide
11870 ;; Go to next unread subject.
11871 (gnus-summary-next-subject 1 t)))
11872 (gnus-set-mode-line 'summary))
11874 ;; Summary sorting commands
11876 (defun gnus-summary-sort-by-number (&optional reverse)
11877 "Sort the summary buffer by article number.
11878 Argument REVERSE means reverse order."
11879 (interactive "P")
11880 (gnus-summary-sort 'number reverse))
11882 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11883 "Sort the summary buffer by most recent article number.
11884 Argument REVERSE means reverse order."
11885 (interactive "P")
11886 (gnus-summary-sort 'most-recent-number reverse))
11888 (defun gnus-summary-sort-by-random (&optional reverse)
11889 "Randomize the order in the summary buffer.
11890 Argument REVERSE means to randomize in reverse order."
11891 (interactive "P")
11892 (gnus-summary-sort 'random reverse))
11894 (defun gnus-summary-sort-by-author (&optional reverse)
11895 "Sort the summary buffer by author name alphabetically.
11896 If `case-fold-search' is non-nil, case of letters is ignored.
11897 Argument REVERSE means reverse order."
11898 (interactive "P")
11899 (gnus-summary-sort 'author reverse))
11901 (defun gnus-summary-sort-by-recipient (&optional reverse)
11902 "Sort the summary buffer by recipient name alphabetically.
11903 If `case-fold-search' is non-nil, case of letters is ignored.
11904 Argument REVERSE means reverse order."
11905 (interactive "P")
11906 (gnus-summary-sort 'recipient reverse))
11908 (defun gnus-summary-sort-by-subject (&optional reverse)
11909 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11910 If `case-fold-search' is non-nil, case of letters is ignored.
11911 Argument REVERSE means reverse order."
11912 (interactive "P")
11913 (gnus-summary-sort 'subject reverse))
11915 (defun gnus-summary-sort-by-date (&optional reverse)
11916 "Sort the summary buffer by date.
11917 Argument REVERSE means reverse order."
11918 (interactive "P")
11919 (gnus-summary-sort 'date reverse))
11921 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11922 "Sort the summary buffer by most recent date.
11923 Argument REVERSE means reverse order."
11924 (interactive "P")
11925 (gnus-summary-sort 'most-recent-date reverse))
11927 (defun gnus-summary-sort-by-score (&optional reverse)
11928 "Sort the summary buffer by score.
11929 Argument REVERSE means reverse order."
11930 (interactive "P")
11931 (gnus-summary-sort 'score reverse))
11933 (defun gnus-summary-sort-by-lines (&optional reverse)
11934 "Sort the summary buffer by the number of lines.
11935 Argument REVERSE means reverse order."
11936 (interactive "P")
11937 (gnus-summary-sort 'lines reverse))
11939 (defun gnus-summary-sort-by-chars (&optional reverse)
11940 "Sort the summary buffer by article length.
11941 Argument REVERSE means reverse order."
11942 (interactive "P")
11943 (gnus-summary-sort 'chars reverse))
11945 (defun gnus-summary-sort-by-mark (&optional reverse)
11946 "Sort the summary buffer by article marks.
11947 Argument REVERSE means reverse order."
11948 (interactive "P")
11949 (gnus-summary-sort 'marks reverse))
11951 (defun gnus-summary-sort-by-original (&optional reverse)
11952 "Sort the summary buffer using the default sorting method.
11953 Argument REVERSE means reverse order."
11954 (interactive "P")
11955 (let* ((inhibit-read-only t)
11956 (gnus-summary-prepare-hook nil))
11957 ;; We do the sorting by regenerating the threads.
11958 (gnus-summary-prepare)
11959 ;; Hide subthreads if needed.
11960 (gnus-summary-maybe-hide-threads)))
11962 (defun gnus-summary-sort (predicate reverse)
11963 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11964 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11965 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11966 (gnus-thread-sort-functions
11967 (if (not reverse)
11968 thread
11969 `(lambda (t1 t2)
11970 (,thread t2 t1))))
11971 (gnus-sort-gathered-threads-function
11972 gnus-thread-sort-functions)
11973 (gnus-article-sort-functions
11974 (if (not reverse)
11975 article
11976 `(lambda (t1 t2)
11977 (,article t2 t1))))
11978 (inhibit-read-only t)
11979 (gnus-summary-prepare-hook nil))
11980 ;; We do the sorting by regenerating the threads.
11981 (gnus-summary-prepare)
11982 ;; Hide subthreads if needed.
11983 (gnus-summary-maybe-hide-threads)))
11985 ;; Summary saving commands.
11987 (defun gnus-summary-save-article (&optional n not-saved)
11988 "Save the current article using the default saver function.
11989 If N is a positive number, save the N next articles.
11990 If N is a negative number, save the N previous articles.
11991 If N is nil and any articles have been marked with the process mark,
11992 save those articles instead.
11993 The variable `gnus-default-article-saver' specifies the saver function.
11995 If the optional second argument NOT-SAVED is non-nil, articles saved
11996 will not be marked as saved.
11998 The `gnus-prompt-before-saving' variable says how prompting is
11999 performed."
12000 (interactive "P")
12001 (require 'gnus-art)
12002 (let* ((articles (gnus-summary-work-articles n))
12003 (save-buffer (save-excursion
12004 (nnheader-set-temp-buffer " *Gnus Save*")))
12005 (num (length articles))
12006 ;; Whether to save decoded articles or raw articles.
12007 (decode (when gnus-article-save-coding-system
12008 (get gnus-default-article-saver :decode)))
12009 ;; When saving many articles in a single file, use the other
12010 ;; function to save articles other than the first one.
12011 (saver2 (get gnus-default-article-saver :function))
12012 (gnus-prompt-before-saving (if saver2
12014 gnus-prompt-before-saving))
12015 (gnus-default-article-saver gnus-default-article-saver)
12016 header file)
12017 (dolist (article articles)
12018 (setq header (gnus-summary-article-header article))
12019 (if (not (vectorp header))
12020 ;; This is a pseudo-article.
12021 (if (assq 'name header)
12022 (gnus-copy-file (cdr (assq 'name header)))
12023 (gnus-message 1 "Article %d is unsavable" article))
12024 ;; This is a real article.
12025 (save-window-excursion
12026 (gnus-summary-select-article decode decode nil article)
12027 (gnus-summary-goto-subject article))
12028 (with-current-buffer save-buffer
12029 (erase-buffer)
12030 (insert-buffer-substring (if decode
12031 gnus-article-buffer
12032 gnus-original-article-buffer)))
12033 (setq file (gnus-article-save save-buffer file num))
12034 (gnus-summary-remove-process-mark article)
12035 (unless not-saved
12036 (gnus-summary-set-saved-mark article)))
12037 (when saver2
12038 (setq gnus-default-article-saver saver2
12039 saver2 nil)))
12040 (gnus-kill-buffer save-buffer)
12041 (gnus-summary-position-point)
12042 (gnus-set-mode-line 'summary)
12045 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12047 (defun gnus-summary-pipe-output (&optional n sym)
12048 "Pipe the current article to a subprocess.
12049 If N is a positive number, pipe the N next articles.
12050 If N is a negative number, pipe the N previous articles.
12051 If N is nil and any articles have been marked with the process mark,
12052 pipe those articles instead.
12053 The default command to which articles are piped is specified by the
12054 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12055 will be prompted for the command.
12057 The properties `:decode' and `:headers' that are put to the function
12058 symbol `gnus-summary-save-in-pipe' control whether this function
12059 decodes articles and what headers to keep (see the doc string for the
12060 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12061 is neither omitted nor the symbol `r', force including all headers
12062 regardless of the `:headers' property. If it is the symbol `r',
12063 articles that are not decoded and include all headers will be piped
12064 no matter what the properties `:decode' and `:headers' are."
12065 (interactive (gnus-interactive "P\ny"))
12066 (require 'gnus-art)
12067 (let* ((articles (gnus-summary-work-articles n))
12068 (result-buffer "*Shell Command Output*")
12069 (all-headers (not (memq sym '(nil r))))
12070 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12071 (raw (eq sym 'r))
12072 (headers (get 'gnus-summary-save-in-pipe :headers))
12073 command result)
12074 (unless (numberp (car articles))
12075 (error "No article to pipe"))
12076 (setq command (read-shell-command
12077 (concat "Shell command on "
12078 (if (cdr articles)
12079 (format "these %d articles" (length articles))
12080 "this article")
12081 ": ")
12082 gnus-summary-pipe-output-default-command))
12083 (when (string-equal command "")
12084 (error "A command is required"))
12085 (when all-headers
12086 (put 'gnus-summary-save-in-pipe :headers nil))
12087 (unwind-protect
12088 (while articles
12089 (gnus-summary-goto-subject (pop articles))
12090 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12091 (when (and (get-buffer result-buffer)
12092 (not (zerop (buffer-size (get-buffer result-buffer)))))
12093 (setq result (concat result (with-current-buffer result-buffer
12094 (buffer-string))))))
12095 (put 'gnus-summary-save-in-pipe :headers headers))
12096 (unless (zerop (length result))
12097 (if (with-current-buffer (get-buffer-create result-buffer)
12098 (erase-buffer)
12099 (insert result)
12100 (prog1
12101 (and (= (count-lines (point-min) (point)) 1)
12102 (progn
12103 (end-of-line 0)
12104 (<= (current-column)
12105 (window-width (minibuffer-window)))))
12106 (goto-char (point-min))))
12107 (message "%s" (substring result 0 -1))
12108 (message nil)
12109 (gnus-configure-windows 'pipe)))))
12111 (defun gnus-summary-save-article-mail (&optional arg)
12112 "Append the current article to a Unix mail box file.
12113 If N is a positive number, save the N next articles.
12114 If N is a negative number, save the N previous articles.
12115 If N is nil and any articles have been marked with the process mark,
12116 save those articles instead."
12117 (interactive "P")
12118 (require 'gnus-art)
12119 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12120 (gnus-summary-save-article arg)))
12122 (defun gnus-summary-save-article-rmail (&optional arg)
12123 "Append the current article to an rmail file.
12124 If N is a positive number, save the N next articles.
12125 If N is a negative number, save the N previous articles.
12126 If N is nil and any articles have been marked with the process mark,
12127 save those articles instead."
12128 (interactive "P")
12129 (require 'gnus-art)
12130 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12131 (gnus-summary-save-article arg)))
12133 (defun gnus-summary-save-article-file (&optional arg)
12134 "Append the current article to a file.
12135 If N is a positive number, save the N next articles.
12136 If N is a negative number, save the N previous articles.
12137 If N is nil and any articles have been marked with the process mark,
12138 save those articles instead."
12139 (interactive "P")
12140 (require 'gnus-art)
12141 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12142 (gnus-summary-save-article arg)))
12144 (defun gnus-summary-write-article-file (&optional arg)
12145 "Write the current article to a file, deleting the previous file.
12146 If N is a positive number, save the N next articles.
12147 If N is a negative number, save the N previous articles.
12148 If N is nil and any articles have been marked with the process mark,
12149 save those articles instead."
12150 (interactive "P")
12151 (require 'gnus-art)
12152 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12153 (gnus-summary-save-article arg)))
12155 (defun gnus-summary-save-article-body-file (&optional arg)
12156 "Append the current article body to a file.
12157 If N is a positive number, save the N next articles.
12158 If N is a negative number, save the N previous articles.
12159 If N is nil and any articles have been marked with the process mark,
12160 save those articles instead."
12161 (interactive "P")
12162 (require 'gnus-art)
12163 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12164 (gnus-summary-save-article arg)))
12166 (defun gnus-summary-write-article-body-file (&optional arg)
12167 "Write the current article body to a file, deleting the previous file.
12168 If N is a positive number, save the N next articles.
12169 If N is a negative number, save the N previous articles.
12170 If N is nil and any articles have been marked with the process mark,
12171 save those articles instead."
12172 (interactive "P")
12173 (require 'gnus-art)
12174 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12175 (gnus-summary-save-article arg)))
12177 (defun gnus-summary-muttprint (&optional arg)
12178 "Print the current article using Muttprint.
12179 If N is a positive number, save the N next articles.
12180 If N is a negative number, save the N previous articles.
12181 If N is nil and any articles have been marked with the process mark,
12182 save those articles instead."
12183 (interactive "P")
12184 (require 'gnus-art)
12185 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12186 (gnus-summary-save-article arg t)))
12188 (defun gnus-summary-pipe-message (program)
12189 "Pipe the current article through PROGRAM."
12190 (interactive "sProgram: ")
12191 (gnus-summary-select-article)
12192 (let ((mail-header-separator ""))
12193 (gnus-eval-in-buffer-window gnus-article-buffer
12194 (save-restriction
12195 (widen)
12196 (let ((start (window-start))
12197 (inhibit-read-only t))
12198 (message-pipe-buffer-body program)
12199 (set-window-start (get-buffer-window (current-buffer)) start))))))
12201 (defun gnus-get-split-value (methods)
12202 "Return a value based on the split METHODS."
12203 (let (split-name method result match)
12204 (when methods
12205 (with-current-buffer gnus-original-article-buffer
12206 (save-restriction
12207 (nnheader-narrow-to-headers)
12208 (while (and methods (not split-name))
12209 (goto-char (point-min))
12210 (setq method (pop methods))
12211 (setq match (car method))
12212 (when (cond
12213 ((stringp match)
12214 ;; Regular expression.
12215 (ignore-errors
12216 (re-search-forward match nil t)))
12217 ((functionp match)
12218 ;; Function.
12219 (save-restriction
12220 (widen)
12221 (setq result (funcall match gnus-newsgroup-name))))
12222 ((consp match)
12223 ;; Form.
12224 (save-restriction
12225 (widen)
12226 (setq result (eval match)))))
12227 (setq split-name (cdr method))
12228 (cond ((stringp result)
12229 (push (expand-file-name
12230 result gnus-article-save-directory)
12231 split-name))
12232 ((consp result)
12233 (setq split-name (append result split-name)))))))))
12234 (nreverse split-name)))
12236 (defun gnus-valid-move-group-p (group)
12237 (and (symbolp group)
12238 (boundp group)
12239 (symbol-name group)
12240 (symbol-value group)
12241 (gnus-get-function (gnus-find-method-for-group
12242 (symbol-name group)) 'request-accept-article t)))
12244 (defun gnus-read-move-group-name (prompt default articles prefix)
12245 "Read a group name."
12246 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12247 (prom
12248 (format "%s %s to"
12249 prompt
12250 (if (> (length articles) 1)
12251 (format "these %d articles" (length articles))
12252 "this article")))
12253 (to-newsgroup
12254 (cond
12255 ((null split-name)
12256 (gnus-group-completing-read
12257 prom
12258 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12259 nil prefix nil default))
12260 ((= 1 (length split-name))
12261 (gnus-group-completing-read
12262 prom
12263 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12264 nil prefix 'gnus-group-history (car split-name)))
12266 (gnus-completing-read
12267 prom (nreverse split-name) nil nil 'gnus-group-history))))
12268 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12269 encoded)
12270 (when to-newsgroup
12271 (if (or (string= to-newsgroup "")
12272 (string= to-newsgroup prefix))
12273 (setq to-newsgroup default))
12274 (unless to-newsgroup
12275 (error "No group name entered"))
12276 (setq encoded (encode-coding-string
12277 to-newsgroup
12278 (gnus-group-name-charset to-method to-newsgroup)))
12279 (or (gnus-active encoded)
12280 (gnus-activate-group encoded nil nil to-method)
12281 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12282 to-newsgroup))
12283 (or (and (gnus-request-create-group encoded to-method)
12284 (gnus-activate-group encoded nil nil to-method)
12285 (gnus-subscribe-group encoded))
12286 (error "Couldn't create group %s" to-newsgroup)))
12287 (error "No such group: %s" to-newsgroup))
12288 encoded)))
12290 (defvar gnus-summary-save-parts-counter)
12291 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12293 (defun gnus-summary-save-parts (type dir n &optional reverse)
12294 "Save parts matching TYPE to DIR.
12295 If REVERSE, save parts that do not match TYPE."
12296 (interactive
12297 (list (read-string "Save parts of type: "
12298 (or (car gnus-summary-save-parts-type-history)
12299 gnus-summary-save-parts-default-mime)
12300 'gnus-summary-save-parts-type-history)
12301 (setq gnus-summary-save-parts-last-directory
12302 (read-directory-name "Save to directory: "
12303 gnus-summary-save-parts-last-directory
12304 nil t))
12305 current-prefix-arg))
12306 (gnus-summary-iterate n
12307 (let ((gnus-display-mime-function nil)
12308 gnus-article-prepare-hook
12309 gnus-article-decode-hook
12310 gnus-display-mime-function
12311 gnus-break-pages
12312 (gnus-inhibit-treatment t))
12313 (gnus-summary-select-article))
12314 (with-current-buffer gnus-article-buffer
12315 (let ((handles (or gnus-article-mime-handles
12316 (mm-dissect-buffer nil gnus-article-loose-mime)
12317 (and gnus-article-emulate-mime
12318 (mm-uu-dissect))))
12319 (gnus-summary-save-parts-counter 1))
12320 (when handles
12321 (gnus-summary-save-parts-1 type dir handles reverse)
12322 (unless gnus-article-mime-handles ;; Don't destroy this case.
12323 (mm-destroy-parts handles)))))))
12325 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12326 (if (stringp (car handle))
12327 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12328 (cdr handle))
12329 (when (if reverse
12330 (not (string-match type (mm-handle-media-type handle)))
12331 (string-match type (mm-handle-media-type handle)))
12332 (let ((file (expand-file-name
12333 (gnus-map-function
12334 mm-file-name-rewrite-functions
12335 (file-name-nondirectory
12337 (mm-handle-filename handle)
12338 (format "%s.%d.%d" gnus-newsgroup-name
12339 (cdr gnus-article-current)
12340 gnus-summary-save-parts-counter))))
12341 dir)))
12342 (incf gnus-summary-save-parts-counter)
12343 (unless (file-exists-p file)
12344 (mm-save-part-to-file handle file))))))
12346 ;; Summary extract commands
12348 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12349 (let ((inhibit-read-only t)
12350 (article (gnus-summary-article-number))
12351 after-article b e)
12352 (unless (gnus-summary-goto-subject article)
12353 (error "No such article: %d" article))
12354 (gnus-summary-position-point)
12355 ;; If all commands are to be bunched up on one line, we collect
12356 ;; them here.
12357 (unless gnus-view-pseudos-separately
12358 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12359 files action)
12360 (while ps
12361 (setq action (cdr (assq 'action (car ps))))
12362 (setq files (list (cdr (assq 'name (car ps)))))
12363 (while (and ps (cdr ps)
12364 (string= (or action "1")
12365 (or (cdr (assq 'action (cadr ps))) "2")))
12366 (push (cdr (assq 'name (cadr ps))) files)
12367 (setcdr ps (cddr ps)))
12368 (when files
12369 (when (not (string-match "%s" action))
12370 (push " " files))
12371 (push " " files)
12372 (when (assq 'execute (car ps))
12373 (setcdr (assq 'execute (car ps))
12374 (funcall (if (string-match "%s" action)
12375 'format 'concat)
12376 action
12377 (mapconcat
12378 (lambda (f)
12379 (if (equal f " ")
12381 (shell-quote-argument f)))
12382 files " ")))))
12383 (setq ps (cdr ps)))))
12384 (if (and gnus-view-pseudos (not not-view))
12385 (while pslist
12386 (when (assq 'execute (car pslist))
12387 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12388 (eq gnus-view-pseudos 'not-confirm)))
12389 (setq pslist (cdr pslist)))
12390 (save-excursion
12391 (while pslist
12392 (setq after-article (or (cdr (assq 'article (car pslist)))
12393 (gnus-summary-article-number)))
12394 (gnus-summary-goto-subject after-article)
12395 (forward-line 1)
12396 (setq b (point))
12397 (insert " " (file-name-nondirectory
12398 (cdr (assq 'name (car pslist))))
12399 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12400 (setq e (point))
12401 (forward-line -1) ; back to `b'
12402 (add-text-properties
12403 b (1- e) (list 'gnus-number gnus-reffed-article-number
12404 'mouse-face gnus-mouse-face))
12405 (gnus-data-enter
12406 after-article gnus-reffed-article-number
12407 gnus-unread-mark b (car pslist) 0 (- e b))
12408 (setq gnus-newsgroup-unreads
12409 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12410 gnus-reffed-article-number))
12411 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12412 (setq pslist (cdr pslist)))))))
12414 (defun gnus-pseudos< (p1 p2)
12415 (let ((c1 (cdr (assq 'action p1)))
12416 (c2 (cdr (assq 'action p2))))
12417 (and c1 c2 (string< c1 c2))))
12419 (defun gnus-request-pseudo-article (props)
12420 (cond ((assq 'execute props)
12421 (gnus-execute-command (cdr (assq 'execute props)))))
12422 (let ((gnus-current-article (gnus-summary-article-number)))
12423 (gnus-run-hooks 'gnus-mark-article-hook)))
12425 (defun gnus-execute-command (command &optional automatic)
12426 (save-excursion
12427 (gnus-article-setup-buffer)
12428 (set-buffer gnus-article-buffer)
12429 (setq buffer-read-only nil)
12430 (let ((command (if automatic command
12431 (read-string "Command: " (cons command 0)))))
12432 (erase-buffer)
12433 (insert "$ " command "\n\n")
12434 (if gnus-view-pseudo-asynchronously
12435 (start-process "gnus-execute" (current-buffer) shell-file-name
12436 shell-command-switch command)
12437 (call-process shell-file-name nil t nil
12438 shell-command-switch command)))))
12440 ;; Summary kill commands.
12442 (defun gnus-summary-edit-global-kill (article)
12443 "Edit the \"global\" kill file."
12444 (interactive (list (gnus-summary-article-number)))
12445 (gnus-group-edit-global-kill article))
12447 (defun gnus-summary-edit-local-kill ()
12448 "Edit a local kill file applied to the current newsgroup."
12449 (interactive)
12450 (setq gnus-current-headers (gnus-summary-article-header))
12451 (gnus-group-edit-local-kill
12452 (gnus-summary-article-number) gnus-newsgroup-name))
12454 ;;; Header reading.
12456 (defun gnus-read-header (id &optional header)
12457 "Read the headers of article ID and enter them into the Gnus system."
12458 (let ((group gnus-newsgroup-name)
12459 (gnus-override-method
12461 gnus-override-method
12462 (and (gnus-news-group-p gnus-newsgroup-name)
12463 (car (gnus-refer-article-methods)))))
12464 where)
12465 ;; First we check to see whether the header in question is already
12466 ;; fetched.
12467 (if (stringp id)
12468 ;; This is a Message-ID.
12469 (setq header (or header (gnus-id-to-header id)))
12470 ;; This is an article number.
12471 (setq header (or header (gnus-summary-article-header id))))
12472 (if (and header
12473 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12474 ;; We have found the header.
12475 header
12476 ;; We have to really fetch the header to this article.
12477 (with-current-buffer nntp-server-buffer
12478 (when (setq where (gnus-request-head id group))
12479 (nnheader-fold-continuation-lines)
12480 (goto-char (point-max))
12481 (insert ".\n")
12482 (goto-char (point-min))
12483 (insert "211 ")
12484 (princ (cond
12485 ((numberp id) id)
12486 ((cdr where) (cdr where))
12487 (header (mail-header-number header))
12488 (t gnus-reffed-article-number))
12489 (current-buffer))
12490 (insert " Article retrieved.\n"))
12491 (if (or (not where)
12492 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12493 () ; Malformed head.
12494 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12495 (when (and (bound-and-true-p gnus-registry-enabled)
12496 (not (gnus-ephemeral-group-p (car where))))
12497 (gnus-registry-handle-action
12498 (mail-header-id header) nil
12499 (gnus-group-prefixed-name
12500 (car where)
12501 (or gnus-override-method (gnus-find-method-for-group group)))
12502 (mail-header-subject header)
12503 (mail-header-from header)))
12504 (when (and (stringp id)
12506 (not (string= (gnus-group-real-name group)
12507 (car where)))
12508 (not (gnus-server-equal gnus-override-method
12509 (gnus-group-method group)))))
12510 ;; If we fetched by Message-ID and the article came from
12511 ;; a different group (or server), we fudge some bogus
12512 ;; article numbers for this article.
12513 (mail-header-set-number header gnus-reffed-article-number))
12514 (with-current-buffer gnus-summary-buffer
12515 (decf gnus-reffed-article-number)
12516 (gnus-remove-header (mail-header-number header))
12517 (push header gnus-newsgroup-headers)
12518 (setq gnus-current-headers header)
12519 (push (mail-header-number header) gnus-newsgroup-limit)))
12520 header)))))
12522 (defun gnus-remove-header (number)
12523 "Remove header NUMBER from `gnus-newsgroup-headers'."
12524 (if (and gnus-newsgroup-headers
12525 (= number (mail-header-number (car gnus-newsgroup-headers))))
12526 (pop gnus-newsgroup-headers)
12527 (let ((headers gnus-newsgroup-headers))
12528 (while (and (cdr headers)
12529 (not (= number (mail-header-number (cadr headers)))))
12530 (pop headers))
12531 (when (cdr headers)
12532 (setcdr headers (cddr headers))))))
12535 ;;; summary highlights
12538 (defun gnus-highlight-selected-summary ()
12539 "Highlight selected article in summary buffer."
12540 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12541 (when gnus-summary-selected-face
12542 (save-excursion
12543 (let* ((beg (point-at-bol))
12544 (end (point-at-eol))
12545 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12546 (from (if (get-text-property beg 'mouse-face)
12548 (or (next-single-property-change
12549 beg 'mouse-face nil end)
12550 beg)))
12552 (if (= from end)
12553 (- from 2)
12554 (or (next-single-property-change
12555 from 'mouse-face nil end)
12556 end))))
12557 ;; If no mouse-face prop on line we will have to = from = end,
12558 ;; so we highlight the entire line instead.
12559 (when (= (+ to 2) from)
12560 (setq from beg)
12561 (setq to end))
12562 (if gnus-newsgroup-selected-overlay
12563 ;; Move old overlay.
12564 (move-overlay
12565 gnus-newsgroup-selected-overlay from to (current-buffer))
12566 ;; Create new overlay.
12567 (overlay-put
12568 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12569 'face gnus-summary-selected-face))))))
12571 (defvar gnus-summary-highlight-line-cached nil)
12572 (defvar gnus-summary-highlight-line-trigger nil)
12574 (defun gnus-summary-highlight-line-0 ()
12575 (if (and (eq gnus-summary-highlight-line-trigger
12576 gnus-summary-highlight)
12577 gnus-summary-highlight-line-cached)
12578 gnus-summary-highlight-line-cached
12579 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12580 gnus-summary-highlight-line-cached
12581 (let* ((cond (list 'cond))
12582 (c cond)
12583 (list gnus-summary-highlight))
12584 (while list
12585 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12586 nil))
12587 (setq c (cdr c)
12588 list (cdr list)))
12589 (gnus-byte-compile (list 'lambda nil cond))))))
12591 (defun gnus-summary-highlight-line ()
12592 "Highlight current line according to `gnus-summary-highlight'."
12593 (let* ((beg (point-at-bol))
12594 (article (or (gnus-summary-article-number) gnus-current-article))
12595 (score (or (cdr (assq article
12596 gnus-newsgroup-scored))
12597 gnus-summary-default-score 0))
12598 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12599 (inhibit-read-only t)
12600 (default gnus-summary-default-score)
12601 (default-high gnus-summary-default-high-score)
12602 (default-low gnus-summary-default-low-score)
12603 (uncached (and gnus-summary-use-undownloaded-faces
12604 (memq article gnus-newsgroup-undownloaded)
12605 (not (memq article gnus-newsgroup-cached)))))
12606 (let ((face (funcall (gnus-summary-highlight-line-0))))
12607 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12608 (gnus-put-text-property-excluding-characters-with-faces
12609 beg (point-at-eol) 'face
12610 (setq face (if (boundp face) (symbol-value face) face)))
12611 (when gnus-summary-highlight-line-function
12612 (funcall gnus-summary-highlight-line-function article face))))))
12614 (defun gnus-update-read-articles (group unread &optional compute)
12615 "Update the list of read articles in GROUP.
12616 UNREAD is a sorted list."
12617 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12618 (info (gnus-get-info group))
12619 (prev 1)
12620 read)
12621 (if (or (not info) (not active))
12622 ;; There is no info on this group if it was, in fact,
12623 ;; killed. Gnus stores no information on killed groups, so
12624 ;; there's nothing to be done.
12625 ;; One could store the information somewhere temporarily,
12626 ;; perhaps... Hmmm...
12628 ;; Remove any negative articles numbers.
12629 (while (and unread (< (car unread) 0))
12630 (setq unread (cdr unread)))
12631 ;; Remove any expired article numbers
12632 (while (and unread (< (car unread) (car active)))
12633 (setq unread (cdr unread)))
12634 ;; Compute the ranges of read articles by looking at the list of
12635 ;; unread articles.
12636 (while unread
12637 (when (/= (car unread) prev)
12638 (push (if (= prev (1- (car unread))) prev
12639 (cons prev (1- (car unread))))
12640 read))
12641 (setq prev (1+ (car unread)))
12642 (setq unread (cdr unread)))
12643 (when (<= prev (cdr active))
12644 (push (cons prev (cdr active)) read))
12645 (setq read (if (> (length read) 1) (nreverse read) read))
12646 (if compute
12647 read
12648 (save-excursion
12649 (let (setmarkundo)
12650 ;; Propagate the read marks to the backend.
12651 (when (and (gnus-method-option-p
12652 (gnus-find-method-for-group group)
12653 'server-marks)
12654 (gnus-check-backend-function 'request-set-mark group))
12655 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12656 (add (gnus-remove-from-range read (gnus-info-read info))))
12657 (when (or add del)
12658 (unless (gnus-check-group group)
12659 (error "Can't open server for %s" group))
12660 (gnus-request-set-mark
12661 group (delq nil (list (if add (list add 'add '(read)))
12662 (if del (list del 'del '(read))))))
12663 (setq setmarkundo
12664 `(gnus-request-set-mark
12665 ,group
12666 ',(delq nil (list
12667 (if del (list del 'add '(read)))
12668 (if add (list add 'del '(read))))))))))
12669 (set-buffer gnus-group-buffer)
12670 (gnus-undo-register
12671 `(progn
12672 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12673 (gnus-info-set-read ',info ',(gnus-info-read info))
12674 (gnus-get-unread-articles-in-group ',info
12675 (gnus-active ,group))
12676 (gnus-group-update-group ,group t)
12677 ,setmarkundo))))
12678 ;; Enter this list into the group info.
12679 (gnus-info-set-read info read)
12680 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12681 (gnus-get-unread-articles-in-group info (gnus-active group))
12682 t))))
12684 (defun gnus-offer-save-summaries ()
12685 "Offer to save all active summary buffers."
12686 (let (buffers)
12687 ;; Go through all buffers and find all summaries.
12688 (dolist (buffer (buffer-list))
12689 (when (and (setq buffer (buffer-name buffer))
12690 (string-match "Summary" buffer)
12691 (with-current-buffer buffer
12692 ;; We check that this is, indeed, a summary buffer.
12693 (and (derived-mode-p 'gnus-summary-mode)
12694 ;; Also make sure this isn't bogus.
12695 gnus-newsgroup-prepared
12696 ;; Also make sure that this isn't a
12697 ;; dead summary buffer.
12698 (not gnus-dead-summary-mode))))
12699 (push buffer buffers)))
12700 ;; Go through all these summary buffers and offer to save them.
12701 (when buffers
12702 (save-excursion
12703 (if (eq gnus-interactive-exit 'quiet)
12704 (dolist (buffer buffers)
12705 (switch-to-buffer buffer)
12706 (gnus-summary-exit))
12707 (map-y-or-n-p
12708 "Update summary buffer %s? "
12709 (lambda (buf)
12710 (switch-to-buffer buf)
12711 (gnus-summary-exit))
12712 buffers))))))
12714 (defun gnus-summary-setup-default-charset ()
12715 "Setup newsgroup default charset."
12716 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12717 (setq gnus-newsgroup-charset nil)
12718 (let* ((ignored-charsets
12719 (or gnus-newsgroup-ephemeral-ignored-charsets
12720 (append
12721 (and gnus-newsgroup-name
12722 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12723 gnus-newsgroup-ignored-charsets))))
12724 (setq gnus-newsgroup-charset
12725 (or gnus-newsgroup-ephemeral-charset
12726 (and gnus-newsgroup-name
12727 (gnus-parameter-charset gnus-newsgroup-name))
12728 gnus-default-charset))
12729 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12730 ignored-charsets))))
12733 ;;; Mime Commands
12736 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12737 "Display the current article buffer fully MIME-buttonized.
12738 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12739 treated as multipart/mixed."
12740 (interactive "P")
12741 (require 'gnus-art)
12742 (let ((gnus-unbuttonized-mime-types nil)
12743 (gnus-mime-display-multipart-as-mixed show-all-parts))
12744 (gnus-summary-show-article)))
12746 (defun gnus-summary-repair-multipart (article)
12747 "Add a Content-Type header to a multipart article without one."
12748 (interactive (list (gnus-summary-article-number)))
12749 (gnus-with-article article
12750 (message-narrow-to-head)
12751 (message-remove-header "Mime-Version")
12752 (goto-char (point-max))
12753 (insert "Mime-Version: 1.0\n")
12754 (widen)
12755 (when (search-forward "\n--" nil t)
12756 (let ((separator (buffer-substring (point) (point-at-eol))))
12757 (message-narrow-to-head)
12758 (message-remove-header "Content-Type")
12759 (goto-char (point-max))
12760 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12761 separator))
12762 (widen))))
12763 (let (gnus-mark-article-hook)
12764 (gnus-summary-select-article t t nil article)))
12766 (defun gnus-summary-toggle-display-buttonized ()
12767 "Toggle the buttonizing of the article buffer."
12768 (interactive)
12769 (require 'gnus-art)
12770 (if (setq gnus-inhibit-mime-unbuttonizing
12771 (not gnus-inhibit-mime-unbuttonizing))
12772 (let ((gnus-unbuttonized-mime-types nil))
12773 (gnus-summary-show-article))
12774 (gnus-summary-show-article)))
12777 ;;; Generic summary marking commands
12780 (defvar gnus-summary-marking-alist
12781 '((read gnus-del-mark "d")
12782 (unread gnus-unread-mark "u")
12783 (ticked gnus-ticked-mark "!")
12784 (dormant gnus-dormant-mark "?")
12785 (expirable gnus-expirable-mark "e"))
12786 "An alist of names/marks/keystrokes.")
12788 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12789 (defvar gnus-summary-mark-map)
12791 (defun gnus-summary-make-all-marking-commands ()
12792 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12793 (dolist (elem gnus-summary-marking-alist)
12794 (apply 'gnus-summary-make-marking-command elem)))
12796 (defun gnus-summary-make-marking-command (name mark keystroke)
12797 (let ((map (make-sparse-keymap)))
12798 (define-key gnus-summary-generic-mark-map keystroke map)
12799 (dolist (lway `((next "next" next nil "n")
12800 (next-unread "next unread" next t "N")
12801 (prev "previous" prev nil "p")
12802 (prev-unread "previous unread" prev t "P")
12803 (nomove "" nil nil ,keystroke)))
12804 (let ((func (gnus-summary-make-marking-command-1
12805 mark (car lway) lway name)))
12806 (setq func (eval func))
12807 (define-key map (nth 4 lway) func)))))
12809 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12810 `(defun ,(intern
12811 (format "gnus-summary-put-mark-as-%s%s"
12812 name (if (eq way 'nomove)
12814 (concat "-" (symbol-name way)))))
12816 ,(format
12817 "Mark the current article as %s%s.
12818 If N, the prefix, then repeat N times.
12819 If N is negative, move in reverse order.
12820 The difference between N and the actual number of articles marked is
12821 returned."
12822 name (cadr lway))
12823 (interactive "p")
12824 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12826 (defun gnus-summary-generic-mark (n mark move unread)
12827 "Mark N articles with MARK."
12828 (unless (derived-mode-p 'gnus-summary-mode)
12829 (error "This command can only be used in the summary buffer"))
12830 (gnus-summary-show-thread)
12831 (let ((nummove
12832 (cond
12833 ((eq move 'next) 1)
12834 ((eq move 'prev) -1)
12835 (t 0))))
12836 (if (zerop nummove)
12837 (setq n 1)
12838 (when (< n 0)
12839 (setq n (abs n)
12840 nummove (* -1 nummove))))
12841 (while (and (> n 0)
12842 (gnus-summary-mark-article nil mark)
12843 (zerop (gnus-summary-next-subject nummove unread t)))
12844 (setq n (1- n)))
12845 (when (/= 0 n)
12846 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12847 (gnus-summary-recenter)
12848 (gnus-summary-position-point)
12849 (gnus-set-mode-line 'summary)
12852 (defun gnus-summary-insert-articles (articles)
12853 (when (setq articles
12854 (gnus-sorted-difference articles
12855 (mapcar (lambda (h)
12856 (mail-header-number h))
12857 gnus-newsgroup-headers)))
12858 (setq gnus-newsgroup-headers
12859 (cl-merge 'list
12860 gnus-newsgroup-headers
12861 (gnus-fetch-headers articles nil t)
12862 'gnus-article-sort-by-number))
12863 (setq gnus-newsgroup-articles
12864 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12865 ;; Suppress duplicates?
12866 (when gnus-suppress-duplicates
12867 (gnus-dup-suppress-articles))
12869 (if (and gnus-fetch-old-headers
12870 (eq gnus-headers-retrieved-by 'nov))
12871 ;; We might want to build some more threads first.
12872 (if (eq gnus-fetch-old-headers 'invisible)
12873 (gnus-build-all-threads)
12874 (gnus-build-old-threads))
12875 ;; Mark the inserted articles that are unread as unread.
12876 (setq gnus-newsgroup-unreads
12877 (gnus-sorted-nunion
12878 gnus-newsgroup-unreads
12879 (gnus-sorted-nintersection
12880 (gnus-list-of-unread-articles gnus-newsgroup-name)
12881 articles)))
12882 ;; Mark the inserted articles as selected so that the information
12883 ;; of the marks having been changed by a user may be updated when
12884 ;; exiting this group. See `gnus-summary-update-info'.
12885 (dolist (art articles)
12886 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12887 ;; Let the Gnus agent mark articles as read.
12888 (when gnus-agent
12889 (gnus-agent-get-undownloaded-list))
12890 ;; Remove list identifiers from subject
12891 (gnus-summary-remove-list-identifiers)
12892 ;; First and last article in this newsgroup.
12893 (when gnus-newsgroup-headers
12894 (setq gnus-newsgroup-begin
12895 (mail-header-number (car gnus-newsgroup-headers))
12896 gnus-newsgroup-end
12897 (mail-header-number
12898 (gnus-last-element gnus-newsgroup-headers))))
12899 (when gnus-use-scoring
12900 (gnus-possibly-score-headers))))
12902 (defun gnus-summary-insert-old-articles (&optional all)
12903 "Insert all old articles in this group.
12904 If ALL is non-nil, already read articles become readable.
12905 If ALL is a number, fetch this number of articles."
12906 (interactive "P")
12907 (prog1
12908 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12909 older len)
12910 (setq older
12911 ;; Some nntp servers lie about their active range. When
12912 ;; this happens, the active range can be in the millions.
12913 ;; Use a compressed range to avoid creating a huge list.
12914 (gnus-range-difference
12915 (gnus-range-difference (list gnus-newsgroup-active) old)
12916 gnus-newsgroup-unexist))
12917 (setq len (gnus-range-length older))
12918 (cond
12919 ((null older) nil)
12920 ((numberp all)
12921 (if (< all len)
12922 (let ((older-range (nreverse older)))
12923 (setq older nil)
12925 (while (> all 0)
12926 (let* ((r (pop older-range))
12927 (min (if (numberp r) r (car r)))
12928 (max (if (numberp r) r (cdr r))))
12929 (while (and (<= min max)
12930 (> all 0))
12931 (push max older)
12932 (setq all (1- all)
12933 max (1- max))))))
12934 (setq older (gnus-uncompress-range older))))
12935 (all
12936 (setq older (gnus-uncompress-range older)))
12938 (when (and (numberp gnus-large-newsgroup)
12939 (> len gnus-large-newsgroup))
12940 (let* ((cursor-in-echo-area nil)
12941 (initial (gnus-parameter-large-newsgroup-initial
12942 gnus-newsgroup-name))
12943 (input
12944 (read-string
12945 (format
12946 "How many articles from %s (%s %d): "
12947 (gnus-group-decoded-name gnus-newsgroup-name)
12948 (if initial "max" "default")
12949 len)
12950 nil nil
12951 (and initial
12952 (number-to-string initial)))))
12953 (unless (string-match "^[ \t]*$" input)
12954 (setq all (string-to-number input))
12955 (if (< all len)
12956 (let ((older-range (nreverse older)))
12957 (setq older nil)
12959 (while (> all 0)
12960 (let* ((r (pop older-range))
12961 (min (if (numberp r) r (car r)))
12962 (max (if (numberp r) r (cdr r))))
12963 (while (and (<= min max)
12964 (> all 0))
12965 (push max older)
12966 (setq all (1- all)
12967 max (1- max))))))))))
12968 (setq older (gnus-uncompress-range older))))
12969 (if (not older)
12970 (message "No old news.")
12971 (gnus-summary-insert-articles older)
12972 (gnus-summary-limit (gnus-sorted-nunion old older))))
12973 (gnus-summary-position-point)))
12975 (defun gnus-summary-insert-new-articles ()
12976 "Insert all new articles in this group."
12977 (interactive)
12978 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12979 (old-high gnus-newsgroup-highest)
12980 (nnmail-fetched-sources (list t))
12981 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12982 i new)
12983 (unless new-active
12984 (error "Couldn't fetch new data"))
12985 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12986 (setq i (cdr gnus-newsgroup-active)
12987 gnus-newsgroup-highest i)
12988 (while (> i old-high)
12989 (push i new)
12990 (decf i))
12991 (if (not new)
12992 (message "No gnus is bad news")
12993 (gnus-summary-insert-articles new)
12994 (setq gnus-newsgroup-unreads
12995 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12996 (gnus-summary-limit (gnus-sorted-nunion old new))))
12997 (gnus-summary-position-point))
12999 ;;; Bookmark support for Gnus.
13000 (declare-function gnus-article-show-summary "gnus-art" ())
13001 (declare-function bookmark-make-record-default
13002 "bookmark" (&optional no-file no-context posn))
13003 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13004 (declare-function bookmark-default-handler "bookmark" (bmk))
13005 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13006 (defvar bookmark-yank-point)
13007 (defvar bookmark-current-buffer)
13009 (defun gnus-summary-bookmark-make-record ()
13010 "Make a bookmark entry for a Gnus summary buffer."
13011 (let (pos buf)
13012 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13013 (save-restriction ; FIXME is it necessary to widen?
13014 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13015 (setq buf "art") ; We are recording bookmark from article buffer.
13016 (setq bookmark-yank-point (point))
13017 (setq bookmark-current-buffer (current-buffer))
13018 (gnus-article-show-summary)) ; Go back in summary buffer.
13019 ;; We are now recording bookmark from summary buffer.
13020 (unless buf (setq buf "sum"))
13021 (let* ((subject (elt (gnus-summary-article-header) 1))
13022 (grp (car gnus-article-current))
13023 (art (cdr gnus-article-current))
13024 (head (gnus-summary-article-header art))
13025 (id (mail-header-id head)))
13026 `(,subject
13027 ,@(condition-case nil
13028 (bookmark-make-record-default 'no-file 'no-context pos)
13029 (wrong-number-of-arguments
13030 (bookmark-make-record-default 'point-only)))
13031 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13032 (group . ,grp) (article . ,art)
13033 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13035 ;;;###autoload
13036 (defun gnus-summary-bookmark-jump (bookmark)
13037 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13038 BOOKMARK is a bookmark name or a bookmark record."
13039 (let ((group (bookmark-prop-get bookmark 'group))
13040 (article (bookmark-prop-get bookmark 'article))
13041 (id (bookmark-prop-get bookmark 'message-id))
13042 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13043 (gnus-fetch-group group (list article))
13044 (gnus-summary-insert-cached-articles)
13045 (gnus-summary-goto-article id nil 'force)
13046 ;; FIXME we have to wait article buffer is ready (only large buffer)
13047 ;; Is there a better solution to know that?
13048 ;; If we don't wait `bookmark-default-handler' will have no chance
13049 ;; to set position. However there is no error, just wrong pos.
13050 (sit-for 1)
13051 (when (string= buf "Gnus-art")
13052 (other-window 1))
13053 (bookmark-default-handler
13054 `(""
13055 (buffer . ,(current-buffer))
13056 . ,(bookmark-get-bookmark-record bookmark)))))
13058 (gnus-summary-make-all-marking-commands)
13060 (provide 'gnus-sum)
13062 (run-hooks 'gnus-sum-load-hook)
13064 ;; Local Variables:
13065 ;; coding: utf-8
13066 ;; End:
13068 ;;; gnus-sum.el ends here