Document reserved keys
[emacs.git] / lisp / gnus / gnus-sum.el
bloba39af45e92e7dc8f0a55a9414528577bbb78fc17
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2018 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 <https://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-refer-thread-limit-to-thread nil
123 "If non-nil referring a thread will limit the summary buffer to
124 articles in the thread. A nil value will add the thread articles
125 to the summary buffer."
126 :version "25.1"
127 :group 'gnus-thread
128 :type 'boolean)
130 (defcustom gnus-summary-make-false-root 'adopt
131 "nil means that Gnus won't gather loose threads.
132 If the root of a thread has expired or been read in a previous
133 session, the information necessary to build a complete thread has been
134 lost. Instead of having many small sub-threads from this original thread
135 scattered all over the summary buffer, Gnus can gather them.
137 If non-nil, Gnus will try to gather all loose sub-threads from an
138 original thread into one large thread.
140 If this variable is non-nil, it should be one of `none', `adopt',
141 `dummy' or `empty'.
143 If this variable is `none', Gnus will not make a false root, but just
144 present the sub-threads after another.
145 If this variable is `dummy', Gnus will create a dummy root that will
146 have all the sub-threads as children.
147 If this variable is `adopt', Gnus will make one of the \"children\"
148 the parent and mark all the step-children as such.
149 If this variable is `empty', the \"children\" are printed with empty
150 subject fields. (Or rather, they will be printed with a string
151 given by the `gnus-summary-same-subject' variable.)"
152 :group 'gnus-thread
153 :type '(choice (const :tag "off" nil)
154 (const none)
155 (const dummy)
156 (const adopt)
157 (const empty)))
159 (defcustom gnus-summary-make-false-root-always nil
160 "Always make a false dummy root."
161 :version "22.1"
162 :group 'gnus-thread
163 :type 'boolean)
165 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
166 "A regexp to match subjects to be excluded from loose thread gathering.
167 As loose thread gathering is done on subjects only, that means that
168 there can be many false gatherings performed. By rooting out certain
169 common subjects, gathering might become saner."
170 :group 'gnus-thread
171 :type 'regexp)
173 (defcustom gnus-summary-gather-subject-limit nil
174 "Maximum length of subject comparisons when gathering loose threads.
175 Use nil to compare full subjects. Setting this variable to a low
176 number will help gather threads that have been corrupted by
177 newsreaders chopping off subject lines, but it might also mean that
178 unrelated articles that have subject that happen to begin with the
179 same few characters will be incorrectly gathered.
181 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
182 comparing subjects."
183 :group 'gnus-thread
184 :type '(choice (const :tag "off" nil)
185 (const fuzzy)
186 (sexp :menu-tag "on" t)))
188 (defcustom gnus-simplify-subject-functions nil
189 "List of functions taking a string argument that simplify subjects.
190 The functions are applied recursively.
192 Useful functions to put in this list include:
193 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
194 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
195 :group 'gnus-thread
196 :type '(repeat function))
198 (defcustom gnus-simplify-ignored-prefixes nil
199 "Remove matches for this regexp from subject lines when simplifying fuzzily."
200 :group 'gnus-thread
201 :type '(choice (const :tag "off" nil)
202 regexp))
204 (defcustom gnus-build-sparse-threads nil
205 "If non-nil, fill in the gaps in threads.
206 If `some', only fill in the gaps that are needed to tie loose threads
207 together. If `more', fill in all leaf nodes that Gnus can find. If
208 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
209 :group 'gnus-thread
210 :type '(choice (const :tag "off" nil)
211 (const some)
212 (const more)
213 (sexp :menu-tag "all" t)))
215 (defcustom gnus-summary-thread-gathering-function
216 'gnus-gather-threads-by-subject
217 "Function used for gathering loose threads.
218 There are two pre-defined functions: `gnus-gather-threads-by-subject',
219 which only takes Subjects into consideration; and
220 `gnus-gather-threads-by-references', which compared the References
221 headers of the articles to find matches."
222 :group 'gnus-thread
223 :type '(radio (function-item gnus-gather-threads-by-subject)
224 (function-item gnus-gather-threads-by-references)
225 (function :tag "other")))
227 (defcustom gnus-summary-same-subject ""
228 "String indicating that the current article has the same subject as the previous.
229 This variable will only be used if the value of
230 `gnus-summary-make-false-root' is `empty'."
231 :group 'gnus-summary-format
232 :type 'string)
234 (defcustom gnus-summary-goto-unread nil
235 "If t, many commands will go to the next unread article.
236 This applies to marking commands as well as other commands that
237 \"naturally\" select the next article, like, for instance, `SPC' at
238 the end of an article.
240 If nil, the marking commands do NOT go to the next unread article
241 \(they go to the next article instead). If `never', commands that
242 usually go to the next unread article, will go to the next article,
243 whether it is read or not."
244 :version "24.1"
245 :group 'gnus-summary-marks
246 :link '(custom-manual "(gnus)Setting Marks")
247 :type '(choice (const :tag "off" nil)
248 (const never)
249 (sexp :menu-tag "on" t)))
251 (defcustom gnus-summary-default-score 0
252 "Default article score level.
253 All scores generated by the score files will be added to this score.
254 If this variable is nil, scoring will be disabled."
255 :group 'gnus-score-default
256 :type '(choice (const :tag "disable")
257 integer))
259 (defcustom gnus-summary-default-high-score 0
260 "Default threshold for a high scored article.
261 An article will be highlighted as high scored if its score is greater
262 than this score."
263 :version "22.1"
264 :group 'gnus-score-default
265 :type 'integer)
267 (defcustom gnus-summary-default-low-score 0
268 "Default threshold for a low scored article.
269 An article will be highlighted as low scored if its score is smaller
270 than this score."
271 :version "22.1"
272 :group 'gnus-score-default
273 :type 'integer)
275 (defcustom gnus-summary-zcore-fuzz 0
276 "Fuzziness factor for the zcore in the summary buffer.
277 Articles with scores closer than this to `gnus-summary-default-score'
278 will not be marked."
279 :group 'gnus-summary-format
280 :type 'integer)
282 (defcustom gnus-simplify-subject-fuzzy-regexp nil
283 "Strings to be removed when doing fuzzy matches.
284 This can either be a regular expression or list of regular expressions
285 that will be removed from subject strings if fuzzy subject
286 simplification is selected."
287 :group 'gnus-thread
288 :type '(repeat regexp))
290 (defcustom gnus-show-threads t
291 "If non-nil, display threads in summary mode."
292 :group 'gnus-thread
293 :type 'boolean)
295 (defcustom gnus-thread-hide-subtree nil
296 "If non-nil, hide all threads initially.
297 This can be a predicate specifier which says which threads to hide.
298 If threads are hidden, you have to run the command
299 `gnus-summary-show-thread' by hand or select an article."
300 :group 'gnus-thread
301 :type '(radio (sexp :format "Non-nil\n"
302 :match (lambda (widget value)
303 (not (or (consp value) (functionp value))))
304 :value t)
305 (const nil)
306 (sexp :tag "Predicate specifier")))
308 (defcustom gnus-thread-hide-killed t
309 "If non-nil, hide killed threads automatically."
310 :group 'gnus-thread
311 :type 'boolean)
313 (defcustom gnus-thread-ignore-subject t
314 "If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
315 If nil, articles that have different subjects from their parents will
316 start separate threads."
317 :group 'gnus-thread
318 :type 'boolean)
320 (defcustom gnus-thread-operation-ignore-subject t
321 "If non-nil, subjects will be ignored when doing thread commands.
322 This affects commands like `gnus-summary-kill-thread' and
323 `gnus-summary-lower-thread'.
325 If this variable is nil, articles in the same thread with different
326 subjects will not be included in the operation in question. If this
327 variable is `fuzzy', only articles that have subjects that are fuzzily
328 equal will be included."
329 :group 'gnus-thread
330 :type '(choice (const :tag "off" nil)
331 (const fuzzy)
332 (sexp :tag "on" t)))
334 (defcustom gnus-thread-indent-level 4
335 "Number that says how much each sub-thread should be indented."
336 :group 'gnus-thread
337 :type 'integer)
339 (defcustom gnus-auto-extend-newsgroup t
340 "If non-nil, extend newsgroup forward and backward when requested."
341 :group 'gnus-summary-choose
342 :type 'boolean)
344 (defcustom gnus-auto-select-first t
345 "If non-nil, select an article on group entry.
346 An article is selected automatically when entering a group
347 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
348 `gnus-summary-catchup-and-goto-next-group'.
350 Which article is selected is controlled by the variable
351 `gnus-auto-select-subject'.
353 If you want to prevent automatic selection of articles in some
354 newsgroups, set the variable to nil in `gnus-select-group-hook'."
355 ;; Commands include...
356 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
358 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
359 :group 'gnus-group-select
360 :type '(choice (const :tag "none" nil)
361 (sexp :menu-tag "first" t)))
363 (defcustom gnus-auto-select-subject 'unseen-or-unread
364 "Says what subject to place under point when entering a group.
366 This variable can either be the symbols `first' (place point on the
367 first subject), `unread' (place point on the subject line of the first
368 unread article), `best' (place point on the subject line of the
369 highest-scored article), `unseen' (place point on the subject line of
370 the first unseen article), `unseen-or-unread' (place point on the subject
371 line of the first unseen article or, if all articles have been seen, on the
372 subject line of the first unread article), or a function to be called to
373 place point on some subject line."
374 :version "24.1"
375 :group 'gnus-group-select
376 :type '(choice (const best)
377 (const unread)
378 (const first)
379 (const unseen)
380 (const unseen-or-unread)
381 (function :tag "Function to call")))
383 (defcustom gnus-auto-select-next t
384 "If non-nil, offer to go to the next group from the end of the previous.
385 If the value is t and the next newsgroup is empty, Gnus will exit
386 summary mode and go back to group mode. If the value is neither nil
387 nor t, Gnus will select the following unread newsgroup. In
388 particular, if the value is the symbol `quietly', the next unread
389 newsgroup will be selected without any confirmation, and if it is
390 `almost-quietly', the next group will be selected without any
391 confirmation if you are located on the last article in the group.
392 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
393 will go to the next group without confirmation."
394 :group 'gnus-summary-maneuvering
395 :type '(choice (const :tag "off" nil)
396 (const quietly)
397 (const almost-quietly)
398 (const slightly-quietly)
399 (sexp :menu-tag "on" t)))
401 (defcustom gnus-auto-select-same nil
402 "If non-nil, select the next article with the same subject.
403 If there are no more articles with the same subject, go to
404 the first unread article."
405 :group 'gnus-summary-maneuvering
406 :type 'boolean)
408 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
409 "What article should be selected after exiting an ephemeral group.
410 Valid values include:
412 `next'
413 Select the next article.
414 `next-unread'
415 Select the next unread article.
416 `next-noselect'
417 Move the cursor to the next article. This is the default.
418 `next-unread-noselect'
419 Move the cursor to the next unread article.
421 If it has any other value or there is no next (unread) article, the
422 article selected before entering to the ephemeral group will appear."
423 :version "23.1" ;; No Gnus
424 :group 'gnus-summary-maneuvering
425 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
426 (const next) (const next-unread)
427 (const next-noselect) (const next-unread-noselect)
428 (sexp :tag "other" :value nil)))
430 (defcustom gnus-auto-goto-ignores 'unfetched
431 "Says how to handle unfetched articles when maneuvering.
433 This variable can either be the symbols nil (maneuver to any
434 article), `undownloaded' (maneuvering while unplugged ignores articles
435 that have not been fetched), `always-undownloaded' (maneuvering always
436 ignores articles that have not been fetched), `unfetched' (maneuvering
437 ignores articles whose headers have not been fetched).
439 NOTE: The list of unfetched articles will always be nil when plugged
440 and, when unplugged, a subset of the undownloaded article list."
441 :version "22.1"
442 :group 'gnus-summary-maneuvering
443 :type '(choice (const :tag "None" nil)
444 (const :tag "Undownloaded when unplugged" undownloaded)
445 (const :tag "Undownloaded" always-undownloaded)
446 (const :tag "Unfetched" unfetched)))
448 (defcustom gnus-summary-check-current nil
449 "If non-nil, consider the current article when moving.
450 The \"unread\" movement commands will stay on the same line if the
451 current article is unread."
452 :group 'gnus-summary-maneuvering
453 :type 'boolean)
455 (defcustom gnus-auto-center-summary
456 (max (or (bound-and-true-p scroll-margin) 0) 2)
457 "If non-nil, always center the current summary buffer.
458 In particular, if `vertical' do only vertical recentering. If non-nil
459 and non-`vertical', do both horizontal and vertical recentering."
460 :group 'gnus-summary-maneuvering
461 :type '(choice (const :tag "none" nil)
462 (const vertical)
463 (integer :tag "height")
464 (sexp :menu-tag "both" t)))
466 (defcustom gnus-auto-center-group t
467 "If non-nil, always center the group buffer."
468 :group 'gnus-summary-maneuvering
469 :type 'boolean)
471 (defcustom gnus-show-all-headers nil
472 "If non-nil, don't hide any headers."
473 :group 'gnus-article-hiding
474 :group 'gnus-article-headers
475 :type 'boolean)
477 (defcustom gnus-summary-ignore-duplicates nil
478 "If non-nil, ignore articles with identical Message-ID headers."
479 :group 'gnus-summary
480 :type 'boolean)
482 (defcustom gnus-single-article-buffer nil
483 "If non-nil, display all articles in the same buffer.
484 If nil, each group will get its own article buffer."
485 :version "24.1"
486 :group 'gnus-article-various
487 :type 'boolean)
489 (defcustom gnus-widen-article-window nil
490 "If non-nil, selecting the article buffer will display only the article buffer."
491 :version "24.1"
492 :group 'gnus-article-various
493 :type 'boolean)
495 (defcustom gnus-break-pages t
496 "If non-nil, do page breaking on articles.
497 The page delimiter is specified by the `gnus-page-delimiter'
498 variable."
499 :group 'gnus-article-various
500 :type 'boolean)
502 (defcustom gnus-move-split-methods nil
503 "Variable used to suggest where articles are to be moved to.
504 It uses the same syntax as the `gnus-split-methods' variable.
505 However, whereas `gnus-split-methods' specifies file names as targets,
506 this variable specifies group names."
507 :group 'gnus-summary-mail
508 :type '(repeat (choice (list :value (fun) function)
509 (cons :value ("" "") regexp (repeat string))
510 (sexp :value nil))))
512 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
513 "Function used to compute default prefix for article move/copy/etc prompts.
514 The function should take one argument, a group name, and return a
515 string with the suggested prefix."
516 :group 'gnus-summary-mail
517 :type 'function)
519 ;; FIXME: Although the custom type is `character' for the following variables,
520 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
522 (defcustom gnus-unread-mark ? ;Whitespace
523 "Mark used for unread articles."
524 :group 'gnus-summary-marks
525 :type 'character)
527 (defcustom gnus-ticked-mark ?!
528 "Mark used for ticked articles."
529 :group 'gnus-summary-marks
530 :type 'character)
532 (defcustom gnus-dormant-mark ??
533 "Mark used for dormant articles."
534 :group 'gnus-summary-marks
535 :type 'character)
537 (defcustom gnus-del-mark ?r
538 "Mark used for del'd articles."
539 :group 'gnus-summary-marks
540 :type 'character)
542 (defcustom gnus-read-mark ?R
543 "Mark used for read articles."
544 :group 'gnus-summary-marks
545 :type 'character)
547 (defcustom gnus-expirable-mark ?E
548 "Mark used for expirable articles."
549 :group 'gnus-summary-marks
550 :type 'character)
552 (defcustom gnus-killed-mark ?K
553 "Mark used for killed articles."
554 :group 'gnus-summary-marks
555 :type 'character)
557 (defcustom gnus-spam-mark ?$
558 "Mark used for spam articles."
559 :version "22.1"
560 :group 'gnus-summary-marks
561 :type 'character)
563 (defcustom gnus-kill-file-mark ?X
564 "Mark used for articles killed by kill files."
565 :group 'gnus-summary-marks
566 :type 'character)
568 (defcustom gnus-low-score-mark ?Y
569 "Mark used for articles with a low score."
570 :group 'gnus-summary-marks
571 :type 'character)
573 (defcustom gnus-catchup-mark ?C
574 "Mark used for articles that are caught up."
575 :group 'gnus-summary-marks
576 :type 'character)
578 (defcustom gnus-replied-mark ?A
579 "Mark used for articles that have been replied to."
580 :group 'gnus-summary-marks
581 :type 'character)
583 (defcustom gnus-forwarded-mark ?F
584 "Mark used for articles that have been forwarded."
585 :version "22.1"
586 :group 'gnus-summary-marks
587 :type 'character)
589 (defcustom gnus-recent-mark ?N
590 "Mark used for articles that are recent."
591 :version "22.1"
592 :group 'gnus-summary-marks
593 :type 'character)
595 (defcustom gnus-cached-mark ?*
596 "Mark used for articles that are in the cache."
597 :group 'gnus-summary-marks
598 :type 'character)
600 (defcustom gnus-saved-mark ?S
601 "Mark used for articles that have been saved."
602 :group 'gnus-summary-marks
603 :type 'character)
605 (defcustom gnus-unseen-mark ?.
606 "Mark used for articles that haven't been seen."
607 :version "22.1"
608 :group 'gnus-summary-marks
609 :type 'character)
611 (defcustom gnus-no-mark ? ;Whitespace
612 "Mark used for articles that have no other secondary mark."
613 :version "22.1"
614 :group 'gnus-summary-marks
615 :type 'character)
617 (defcustom gnus-ancient-mark ?O
618 "Mark used for ancient articles."
619 :group 'gnus-summary-marks
620 :type 'character)
622 (defcustom gnus-sparse-mark ?Q
623 "Mark used for sparsely reffed articles."
624 :group 'gnus-summary-marks
625 :type 'character)
627 (defcustom gnus-canceled-mark ?G
628 "Mark used for canceled articles."
629 :group 'gnus-summary-marks
630 :type 'character)
632 (defcustom gnus-duplicate-mark ?M
633 "Mark used for duplicate articles."
634 :group 'gnus-summary-marks
635 :type 'character)
637 (defcustom gnus-undownloaded-mark ?-
638 "Mark used for articles that weren't downloaded."
639 :version "22.1"
640 :group 'gnus-summary-marks
641 :type 'character)
643 (defcustom gnus-downloaded-mark ?+
644 "Mark used for articles that were downloaded."
645 :group 'gnus-summary-marks
646 :type 'character)
648 (defcustom gnus-downloadable-mark ?%
649 "Mark used for articles that are to be downloaded."
650 :group 'gnus-summary-marks
651 :type 'character)
653 (defcustom gnus-unsendable-mark ?=
654 "Mark used for articles that won't be sent."
655 :group 'gnus-summary-marks
656 :type 'character)
658 (defcustom gnus-score-over-mark ?+
659 "Score mark used for articles with high scores."
660 :group 'gnus-summary-marks
661 :type 'character)
663 (defcustom gnus-score-below-mark ?-
664 "Score mark used for articles with low scores."
665 :group 'gnus-summary-marks
666 :type 'character)
668 (defcustom gnus-empty-thread-mark ? ;Whitespace
669 "There is no thread under the article."
670 :group 'gnus-summary-marks
671 :type 'character)
673 (defcustom gnus-not-empty-thread-mark ?=
674 "There is a thread under the article."
675 :group 'gnus-summary-marks
676 :type 'character)
678 (defcustom gnus-view-pseudo-asynchronously nil
679 "If non-nil, Gnus will view pseudo-articles asynchronously."
680 :group 'gnus-extract-view
681 :type 'boolean)
683 (defcustom gnus-auto-expirable-marks
684 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
685 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
686 gnus-duplicate-mark)
687 "The list of marks converted into expiration if a group is auto-expirable."
688 :version "24.1"
689 :group 'gnus-summary
690 :type '(repeat character))
692 (defcustom gnus-inhibit-user-auto-expire t
693 "If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
694 :version "21.1"
695 :group 'gnus-summary
696 :type 'boolean)
698 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
699 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
700 If nil, the expirable marks will be unchanged except that the marks
701 will be removed when copying or moving articles to a group that has
702 not turned auto-expire on. If non-nil, articles that have been read
703 will be marked as expirable when being copied or moved to a group in
704 which auto-expire is turned on."
705 :version "23.2"
706 :type 'boolean
707 :group 'gnus-summary-marks)
709 (defcustom gnus-view-pseudos nil
710 "If `automatic', pseudo-articles will be viewed automatically.
711 If `not-confirm', pseudos will be viewed automatically, and the user
712 will not be asked to confirm the command."
713 :group 'gnus-extract-view
714 :type '(choice (const :tag "off" nil)
715 (const automatic)
716 (const not-confirm)))
718 (defcustom gnus-view-pseudos-separately t
719 "If non-nil, one pseudo-article will be created for each file to be viewed.
720 If nil, all files that use the same viewing command will be given as a
721 list of parameters to that command."
722 :group 'gnus-extract-view
723 :type 'boolean)
725 (defcustom gnus-insert-pseudo-articles t
726 "If non-nil, insert pseudo-articles when decoding articles."
727 :group 'gnus-extract-view
728 :type 'boolean)
730 (defcustom gnus-summary-dummy-line-format
731 " %(: :%) %S\n"
732 "The format specification for the dummy roots in the summary buffer.
733 It works along the same lines as a normal formatting string,
734 with some simple extensions.
736 %S The subject
738 General format specifiers can also be used.
739 See `(gnus)Formatting Variables'."
740 :link '(custom-manual "(gnus)Formatting Variables")
741 :group 'gnus-threading
742 :type 'string)
744 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
745 "The format specification for the summary mode line.
746 It works along the same lines as a normal formatting string,
747 with some simple extensions:
749 %G Group name
750 %p Unprefixed group name
751 %A Current article number
752 %z Current article score
753 %V Gnus version
754 %U Number of unread articles in the group
755 %e Number of unselected articles in the group
756 %Z A string with unread/unselected article counts
757 %g Shortish group name
758 %S Subject of the current article
759 %u User-defined spec
760 %s Current score file name
761 %d Number of dormant articles
762 %r Number of articles that have been marked as read in this session
763 %E Number of articles expunged by the score files"
764 :group 'gnus-summary-format
765 :type 'string)
767 (defcustom gnus-list-identifiers nil
768 "Regexp that matches list identifiers to be removed from subject.
769 This can also be a list of regexps."
770 :version "21.1"
771 :group 'gnus-summary-format
772 :group 'gnus-article-hiding
773 :type '(choice (const :tag "none" nil)
774 (regexp :value ".*")
775 (repeat :value (".*") regexp)))
777 (defcustom gnus-summary-mark-below 0
778 "Mark all articles with a score below this variable as read.
779 This variable is local to each summary buffer and usually set by the
780 score file."
781 :group 'gnus-score-default
782 :type 'integer)
784 (defun gnus-widget-reversible-match (widget value)
785 "Ignoring WIDGET, convert VALUE to internal form.
786 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
787 ;; (debug value)
788 (or (symbolp value)
789 (and (listp value)
790 (eq (length value) 2)
791 (eq (nth 0 value) 'not)
792 (symbolp (nth 1 value)))))
794 (defun gnus-widget-reversible-to-internal (widget value)
795 "Ignoring WIDGET, convert VALUE to internal form.
796 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
797 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
798 ;; (debug value)
799 (if (atom value)
800 (list value nil)
801 (list (nth 1 value) t)))
803 (defun gnus-widget-reversible-to-external (widget value)
804 "Ignoring WIDGET, convert VALUE to external form.
805 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
806 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
807 ;; (debug value)
808 (if (nth 1 value)
809 (list 'not (nth 0 value))
810 (nth 0 value)))
812 (define-widget 'gnus-widget-reversible 'group
813 "A `group' that convert values."
814 :match 'gnus-widget-reversible-match
815 :value-to-internal 'gnus-widget-reversible-to-internal
816 :value-to-external 'gnus-widget-reversible-to-external)
818 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
819 "List of functions used for sorting articles in the summary buffer.
821 Each function takes two articles and returns non-nil if the first
822 article should be sorted before the other. If you use more than one
823 function, the primary sort function should be the last. You should
824 probably always include `gnus-article-sort-by-number' in the list of
825 sorting functions -- preferably first. Also note that sorting by date
826 is often much slower than sorting by number, and the sorting order is
827 very similar. (Sorting by date means sorting by the time the message
828 was sent, sorting by number means sorting by arrival time.)
830 Each item can also be a list `(not F)' where F is a function;
831 this reverses the sort order.
833 Ready-made functions include `gnus-article-sort-by-number',
834 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
835 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
836 and `gnus-article-sort-by-score'.
838 When threading is turned on, the variable `gnus-thread-sort-functions'
839 controls how articles are sorted."
840 :group 'gnus-summary-sort
841 :type '(repeat (gnus-widget-reversible
842 (choice (function-item gnus-article-sort-by-number)
843 (function-item gnus-article-sort-by-author)
844 (function-item gnus-article-sort-by-subject)
845 (function-item gnus-article-sort-by-date)
846 (function-item gnus-article-sort-by-score)
847 (function-item gnus-article-sort-by-random)
848 (function :tag "other"))
849 (boolean :tag "Reverse order"))))
851 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted.
878 By default, threads and their subthreads are sorted according to
879 the value of this variable. To use a different sorting order for
880 subthreads, customize `gnus-subthread-sort-functions'."
881 :group 'gnus-summary-sort
882 :type '(repeat
883 (gnus-widget-reversible
884 (choice (function-item gnus-thread-sort-by-number)
885 (function-item gnus-thread-sort-by-author)
886 (function-item gnus-thread-sort-by-recipient)
887 (function-item gnus-thread-sort-by-subject)
888 (function-item gnus-thread-sort-by-date)
889 (function-item gnus-thread-sort-by-score)
890 (function-item gnus-thread-sort-by-most-recent-number)
891 (function-item gnus-thread-sort-by-most-recent-date)
892 (function-item gnus-thread-sort-by-random)
893 (function-item gnus-thread-sort-by-total-score)
894 (function :tag "other"))
895 (boolean :tag "Reverse order"))))
897 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
898 "List of functions used for sorting subthreads in the summary buffer.
899 By default, subthreads are sorted the same as threads, i.e.,
900 according to the value of `gnus-thread-sort-functions'."
901 :version "24.4"
902 :group 'gnus-summary-sort
903 :type '(choice
904 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
905 (repeat
906 (gnus-widget-reversible
907 (choice (function-item gnus-thread-sort-by-number)
908 (function-item gnus-thread-sort-by-author)
909 (function-item gnus-thread-sort-by-recipient)
910 (function-item gnus-thread-sort-by-subject)
911 (function-item gnus-thread-sort-by-date)
912 (function-item gnus-thread-sort-by-score)
913 (function-item gnus-thread-sort-by-most-recent-number)
914 (function-item gnus-thread-sort-by-most-recent-date)
915 (function-item gnus-thread-sort-by-random)
916 (function-item gnus-thread-sort-by-total-score)
917 (function :tag "other"))
918 (boolean :tag "Reverse order")))))
920 (defcustom gnus-thread-score-function '+
921 "Function used for calculating the total score of a thread.
923 The function is called with the scores of the article and each
924 subthread and should then return the score of the thread.
926 Some functions you can use are `+', `max', or `min'."
927 :group 'gnus-summary-sort
928 :type 'function)
930 (defcustom gnus-summary-expunge-below nil
931 "All articles that have a score less than this variable will be expunged.
932 This variable is local to the summary buffers."
933 :group 'gnus-score-default
934 :type '(choice (const :tag "off" nil)
935 integer))
937 (defcustom gnus-thread-expunge-below nil
938 "All threads that have a total score less than this variable will be expunged.
939 See `gnus-thread-score-function' for en explanation of what a
940 \"thread score\" is.
942 This variable is local to the summary buffers."
943 :group 'gnus-threading
944 :group 'gnus-score-default
945 :type '(choice (const :tag "off" nil)
946 integer))
948 (defcustom gnus-summary-mode-hook nil
949 "A hook for Gnus summary mode.
950 This hook is run before any variables are set in the summary buffer."
951 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
952 :group 'gnus-summary-various
953 :type 'hook)
955 (defcustom gnus-summary-menu-hook nil
956 "Hook run after the creation of the summary mode menu."
957 :group 'gnus-summary-visual
958 :type 'hook)
960 (defcustom gnus-summary-exit-hook nil
961 "A hook called on exit from the summary buffer.
962 It will be called with point in the group buffer."
963 :group 'gnus-summary-exit
964 :type 'hook)
966 (defcustom gnus-summary-prepare-hook nil
967 "A hook called after the summary buffer has been generated.
968 If you want to modify the summary buffer, you can use this hook."
969 :group 'gnus-summary-various
970 :type 'hook)
972 (defcustom gnus-summary-prepared-hook nil
973 "A hook called as the last thing after the summary buffer has been generated."
974 :group 'gnus-summary-various
975 :type 'hook)
977 (defcustom gnus-summary-generate-hook nil
978 "A hook run just before generating the summary buffer.
979 This hook is commonly used to customize threading variables and the
980 like."
981 :group 'gnus-summary-various
982 :type 'hook)
984 (defcustom gnus-select-group-hook nil
985 "A hook called when a newsgroup is selected.
987 If you'd like to simplify subjects like the
988 `gnus-summary-next-same-subject' command does, you can use the
989 following hook:
991 (add-hook gnus-select-group-hook
992 (lambda ()
993 (mapcar (lambda (header)
994 (mail-header-set-subject
995 header
996 (gnus-simplify-subject
997 (mail-header-subject header) \\='re-only)))
998 gnus-newsgroup-headers)))"
999 :group 'gnus-group-select
1000 :type 'hook)
1002 (defcustom gnus-select-article-hook nil
1003 "A hook called when an article is selected."
1004 :group 'gnus-summary-choose
1005 :options '(gnus-agent-fetch-selected-article)
1006 :type 'hook)
1008 (defcustom gnus-visual-mark-article-hook
1009 (list 'gnus-highlight-selected-summary)
1010 "Hook run after selecting an article in the summary buffer.
1011 It is meant to be used for highlighting the article in some way. It
1012 is not run if `gnus-visual' is nil."
1013 :group 'gnus-summary-visual
1014 :type 'hook)
1016 (defcustom gnus-parse-headers-hook nil
1017 "A hook called before parsing the headers."
1018 :group 'gnus-various
1019 :type 'hook)
1021 (defcustom gnus-exit-group-hook nil
1022 "A hook called when exiting summary mode.
1023 This hook is not called from the non-updating exit commands like `Q'."
1024 :group 'gnus-various
1025 :type 'hook)
1027 (defcustom gnus-summary-update-hook nil
1028 "A hook called when a summary line is changed.
1029 The hook will not be called if `gnus-visual' is nil.
1031 The default function `gnus-summary-highlight-line' will
1032 highlight the line according to the `gnus-summary-highlight'
1033 variable."
1034 :group 'gnus-summary-visual
1035 :type 'hook)
1037 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1038 "A hook called when an article is selected for the first time.
1039 The hook is intended to mark an article as read (or unread)
1040 automatically when it is selected."
1041 :group 'gnus-summary-choose
1042 :type 'hook)
1044 (defcustom gnus-group-no-more-groups-hook nil
1045 "A hook run when returning to group mode having no more (unread) groups."
1046 :group 'gnus-group-select
1047 :type 'hook)
1049 (defcustom gnus-ps-print-hook nil
1050 "A hook run before ps-printing something from Gnus."
1051 :group 'gnus-summary
1052 :type 'hook)
1054 (defcustom gnus-summary-article-move-hook nil
1055 "A hook called after an article is moved, copied, respooled, or crossposted."
1056 :version "22.1"
1057 :group 'gnus-summary
1058 :type 'hook)
1060 (defcustom gnus-summary-article-delete-hook nil
1061 "A hook called after an article is deleted."
1062 :version "22.1"
1063 :group 'gnus-summary
1064 :type 'hook)
1066 (defcustom gnus-summary-article-expire-hook nil
1067 "A hook called after an article is expired."
1068 :version "22.1"
1069 :group 'gnus-summary
1070 :type 'hook)
1072 (defcustom gnus-summary-display-arrow (display-graphic-p)
1073 "If non-nil, display an arrow highlighting the current article."
1074 :version "22.1"
1075 :group 'gnus-summary
1076 :type 'boolean)
1078 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1079 "Face used for highlighting the current article in the summary buffer."
1080 :group 'gnus-summary-visual
1081 :type 'face)
1083 (defvar gnus-tmp-downloaded nil)
1085 (defcustom gnus-summary-highlight
1086 '(((eq mark gnus-canceled-mark)
1087 . gnus-summary-cancelled)
1088 ((and uncached (> score default-high))
1089 . gnus-summary-high-undownloaded)
1090 ((and uncached (< score default-low))
1091 . gnus-summary-low-undownloaded)
1092 (uncached
1093 . gnus-summary-normal-undownloaded)
1094 ((and (> score default-high)
1095 (or (eq mark gnus-dormant-mark)
1096 (eq mark gnus-ticked-mark)))
1097 . gnus-summary-high-ticked)
1098 ((and (< score default-low)
1099 (or (eq mark gnus-dormant-mark)
1100 (eq mark gnus-ticked-mark)))
1101 . gnus-summary-low-ticked)
1102 ((or (eq mark gnus-dormant-mark)
1103 (eq mark gnus-ticked-mark))
1104 . gnus-summary-normal-ticked)
1105 ((and (> score default-high) (eq mark gnus-ancient-mark))
1106 . gnus-summary-high-ancient)
1107 ((and (< score default-low) (eq mark gnus-ancient-mark))
1108 . gnus-summary-low-ancient)
1109 ((eq mark gnus-ancient-mark)
1110 . gnus-summary-normal-ancient)
1111 ((and (> score default-high) (eq mark gnus-unread-mark))
1112 . gnus-summary-high-unread)
1113 ((and (< score default-low) (eq mark gnus-unread-mark))
1114 . gnus-summary-low-unread)
1115 ((eq mark gnus-unread-mark)
1116 . gnus-summary-normal-unread)
1117 ((> score default-high)
1118 . gnus-summary-high-read)
1119 ((< score default-low)
1120 . gnus-summary-low-read)
1122 . gnus-summary-normal-read))
1123 "Controls the highlighting of summary buffer lines.
1125 A list of (FORM . FACE) pairs. When deciding how a particular
1126 summary line should be displayed, each form is evaluated. The content
1127 of the face field after the first true form is used. You can change
1128 how those summary lines are displayed, by editing the face field.
1130 You can use the following variables in the FORM field.
1132 score: The article's score.
1133 default: The default article score.
1134 default-high: The default score for high scored articles.
1135 default-low: The default score for low scored articles.
1136 mark: The article's mark.
1137 uncached: Non-nil if the article is uncached."
1138 :group 'gnus-summary-visual
1139 :type '(repeat (cons (sexp :tag "Form" nil)
1140 face)))
1141 (put 'gnus-summary-highlight 'risky-local-variable t)
1143 (defcustom gnus-alter-header-function nil
1144 "Function called to allow alteration of article header structures.
1145 The function is called with one parameter, the article header vector,
1146 which it may alter in any way."
1147 :type '(choice (const :tag "None" nil)
1148 function)
1149 :group 'gnus-summary)
1151 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1152 "Function used to decode a string with encoded words.")
1154 (defvar gnus-decode-encoded-address-function
1155 'mail-decode-encoded-address-string
1156 "Function used to decode addresses with encoded words.")
1158 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1159 "Extra headers to parse."
1160 :version "25.1"
1161 :group 'gnus-summary
1162 :type '(repeat symbol))
1164 (defcustom gnus-ignored-from-addresses
1165 (and user-mail-address
1166 (not (string= user-mail-address ""))
1167 (regexp-quote user-mail-address))
1168 "From headers that may be suppressed in favor of To headers.
1169 This can be a regexp, a list of regexps or a function.
1171 If a function, an email string is passed as the argument."
1172 :version "21.1"
1173 :group 'gnus-summary
1174 :type '(choice regexp
1175 (repeat :tag "Regexp List" regexp)
1176 function))
1178 (defsubst gnus-ignored-from-addresses ()
1179 (cond ((functionp gnus-ignored-from-addresses)
1180 gnus-ignored-from-addresses)
1181 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1183 (defcustom gnus-summary-to-prefix "-> "
1184 "String prefixed to the To field in the summary line when
1185 using `gnus-ignored-from-addresses'."
1186 :version "22.1"
1187 :group 'gnus-summary
1188 :type 'string)
1190 (defcustom gnus-summary-newsgroup-prefix "=> "
1191 "String prefixed to the Newsgroup field in the summary
1192 line when using the option `gnus-ignored-from-addresses'."
1193 :version "22.1"
1194 :group 'gnus-summary
1195 :type 'string)
1197 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1198 "List of charsets that should be ignored.
1199 When these charsets are used in the \"charset\" parameter, the
1200 default charset will be used instead."
1201 :version "21.1"
1202 :type '(repeat symbol)
1203 :group 'gnus-charset)
1205 (defcustom gnus-newsgroup-maximum-articles nil
1206 "The maximum number of articles a newsgroup.
1207 If this is a number, old articles in a newsgroup exceeding this number
1208 are silently ignored. If it is nil, no article is ignored. Note that
1209 setting this variable to a number might prevent you from reading very
1210 old articles."
1211 :group 'gnus-group-select
1212 :version "22.2"
1213 :type '(choice (const :tag "No limit" nil)
1214 integer))
1216 (gnus-define-group-parameter
1217 ignored-charsets
1218 :type list
1219 :function-document
1220 "Return the ignored charsets of GROUP."
1221 :variable gnus-group-ignored-charsets-alist
1222 :variable-default
1223 '(("alt\\.chinese\\.text" iso-8859-1))
1224 :variable-document
1225 "Alist of regexps (to match group names) and charsets that should be ignored.
1226 When these charsets are used in the \"charset\" parameter, the
1227 default charset will be used instead."
1228 :variable-group gnus-charset
1229 :variable-type '(repeat (cons (regexp :tag "Group")
1230 (repeat symbol)))
1231 :parameter-type '(choice :tag "Ignored charsets"
1232 :value nil
1233 (repeat (symbol)))
1234 :parameter-document "\
1235 List of charsets that should be ignored.
1237 When these charsets are used in the \"charset\" parameter, the
1238 default charset will be used instead.")
1240 (defcustom gnus-group-highlight-words-alist nil
1241 "Alist of group regexps and highlight regexps.
1242 This variable uses the same syntax as `gnus-emphasis-alist'."
1243 :version "21.1"
1244 :type '(repeat (cons (regexp :tag "Group")
1245 (repeat (list (regexp :tag "Highlight regexp")
1246 (number :tag "Group for entire word" 0)
1247 (number :tag "Group for displayed part" 0)
1248 (symbol :tag "Face"
1249 gnus-emphasis-highlight-words)))))
1250 :group 'gnus-summary-visual)
1252 (defcustom gnus-summary-show-article-charset-alist
1254 "Alist of number and charset.
1255 The article will be shown with the charset corresponding to the
1256 numbered argument.
1257 For example: ((1 . cn-gb-2312) (2 . big5))."
1258 :version "21.1"
1259 :type '(repeat (cons (number :tag "Argument" 1)
1260 (symbol :tag "Charset")))
1261 :group 'gnus-charset)
1263 (defcustom gnus-preserve-marks t
1264 "Whether marks are preserved when moving, copying and respooling messages."
1265 :version "21.1"
1266 :type 'boolean
1267 :group 'gnus-summary-marks)
1269 (defcustom gnus-alter-articles-to-read-function nil
1270 "Function to be called to alter the list of articles to be selected."
1271 :type '(choice (const nil) function)
1272 :group 'gnus-summary)
1274 (defcustom gnus-orphan-score nil
1275 "All orphans get this score added. Set in the score file."
1276 :group 'gnus-score-default
1277 :type '(choice (const nil)
1278 integer))
1280 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1281 "A regexp to match MIME parts when saving multiple parts of a
1282 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1283 This regexp will be used by default when prompting the user for which
1284 type of files to save."
1285 :group 'gnus-summary
1286 :type 'regexp)
1288 (defcustom gnus-read-all-available-headers nil
1289 "Whether Gnus should parse all headers made available to it.
1290 This is mostly relevant for slow back ends where the user may
1291 wish to widen the summary buffer to include all headers
1292 that were fetched."
1293 :version "22.1"
1294 :group 'gnus-summary
1295 :type '(choice boolean regexp))
1297 (defcustom gnus-summary-pipe-output-default-command nil
1298 "Command (and optional arguments) used to pipe article to subprocess.
1299 This will be used as the default command if it is non-nil. The value
1300 will be updated if you modify it when executing the command
1301 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1302 :version "23.1" ;; No Gnus
1303 :group 'gnus-summary
1304 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1306 (defcustom gnus-summary-muttprint-program "muttprint"
1307 "Command (and optional arguments) used to run Muttprint.
1308 The value will be updated if you modify it when executing the command
1309 `gnus-summary-muttprint'."
1310 :version "22.1"
1311 :group 'gnus-summary
1312 :type 'string)
1314 (defcustom gnus-article-loose-mime t
1315 "If non-nil, don't require MIME-Version header.
1316 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1317 supply the MIME-Version header or deliberately strip it from the mail.
1318 If non-nil (the default), Gnus will treat some articles as MIME
1319 even if the MIME-Version header is missing."
1320 :version "22.1"
1321 :type 'boolean
1322 :group 'gnus-article-mime)
1324 (defcustom gnus-article-emulate-mime t
1325 "If non-nil, use MIME emulation for uuencode and the like.
1326 This means that Gnus will search message bodies for text that look
1327 like uuencoded bits, yEncoded bits, and so on, and present that using
1328 the normal Gnus MIME machinery."
1329 :version "22.1"
1330 :type 'boolean
1331 :group 'gnus-article-mime)
1333 ;;; Internal variables
1335 (defvar gnus-summary-display-cache nil)
1336 (defvar gnus-article-mime-handles nil)
1337 (defvar gnus-article-decoded-p nil)
1338 (defvar gnus-article-charset nil)
1339 (defvar gnus-article-ignored-charsets nil)
1340 (defvar gnus-scores-exclude-files nil)
1341 (defvar gnus-page-broken nil)
1343 (defvar gnus-original-article nil)
1344 (defvar gnus-article-internal-prepare-hook nil)
1345 (defvar gnus-newsgroup-process-stack nil)
1347 (defvar gnus-thread-indent-array nil)
1348 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1349 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1350 "Function called to sort the articles within a thread after it has been gathered together.")
1352 (defvar gnus-summary-save-parts-type-history nil)
1353 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1355 ;; Avoid highlighting in kill files.
1356 (defvar gnus-summary-inhibit-highlight nil)
1357 (defvar gnus-newsgroup-selected-overlay nil)
1358 (defvar gnus-inhibit-limiting nil)
1359 (defvar gnus-newsgroup-adaptive-score-file nil)
1360 (defvar gnus-current-score-file nil)
1361 (defvar gnus-current-move-group nil)
1362 (defvar gnus-current-copy-group nil)
1363 (defvar gnus-current-crosspost-group nil)
1364 (defvar gnus-newsgroup-display nil)
1366 (defvar gnus-newsgroup-dependencies nil)
1367 (defvar gnus-newsgroup-adaptive nil)
1368 (defvar gnus-summary-display-article-function nil)
1369 (defvar gnus-summary-highlight-line-function nil
1370 "Function called after highlighting a summary line.")
1372 (defvar gnus-summary-line-format-alist
1373 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1374 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1375 (?s gnus-tmp-subject-or-nil ?s)
1376 (?n gnus-tmp-name ?s)
1377 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1379 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1380 gnus-tmp-from) ?s)
1381 (?F gnus-tmp-from ?s)
1382 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1383 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1384 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1385 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1386 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1387 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1388 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1389 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1390 (?L gnus-tmp-lines ?s)
1391 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1392 0) ?d)
1393 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1394 "") ?s)
1395 (?g (or (gnus-group-short-name
1396 (nnir-article-group (mail-header-number gnus-tmp-header)))
1397 "") ?s)
1398 (?O gnus-tmp-downloaded ?c)
1399 (?I gnus-tmp-indentation ?s)
1400 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1401 (?R gnus-tmp-replied ?c)
1402 (?\[ gnus-tmp-opening-bracket ?c)
1403 (?\] gnus-tmp-closing-bracket ?c)
1404 (?\> (make-string gnus-tmp-level ? ) ?s)
1405 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1406 (?i gnus-tmp-score ?d)
1407 (?z gnus-tmp-score-char ?c)
1408 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1409 (?U gnus-tmp-unread ?c)
1410 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1412 (?t (gnus-summary-number-of-articles-in-thread
1413 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1415 (?e (gnus-summary-number-of-articles-in-thread
1416 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1418 (?u gnus-tmp-user-defined ?s)
1419 (?P (gnus-pick-line-number) ?d)
1420 (?B gnus-tmp-thread-tree-header-string ?s)
1421 (user-date (gnus-user-date
1422 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1423 "An alist of format specifications that can appear in summary lines.
1424 These are paired with what variables they correspond with, along with
1425 the type of the variable (string, integer, character, etc).")
1427 (defvar gnus-summary-dummy-line-format-alist
1428 `((?S gnus-tmp-subject ?s)
1429 (?N gnus-tmp-number ?d)
1430 (?u gnus-tmp-user-defined ?s)))
1432 (defvar gnus-summary-mode-line-format-alist
1433 `((?G gnus-tmp-group-name ?s)
1434 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1435 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1436 (?A gnus-tmp-article-number ?d)
1437 (?Z gnus-tmp-unread-and-unselected ?s)
1438 (?V gnus-version ?s)
1439 (?U gnus-tmp-unread-and-unticked ?d)
1440 (?S gnus-tmp-subject ?s)
1441 (?e gnus-tmp-unselected ?d)
1442 (?u gnus-tmp-user-defined ?s)
1443 (?d (length gnus-newsgroup-dormant) ?d)
1444 (?t (length gnus-newsgroup-marked) ?d)
1445 (?h (length gnus-newsgroup-spam-marked) ?d)
1446 (?r (length gnus-newsgroup-reads) ?d)
1447 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1448 (?E gnus-newsgroup-expunged-tally ?d)
1449 (?s (gnus-current-score-file-nondirectory) ?s)))
1451 ;; This is here rather than in gnus-art for compilation reasons.
1452 (defvar gnus-article-mode-line-format-alist
1453 (nconc '((?w (gnus-article-wash-status) ?s)
1454 (?m (gnus-article-mime-part-status) ?s))
1455 gnus-summary-mode-line-format-alist))
1457 (defvar gnus-last-search-regexp nil
1458 "Default regexp for article search command.")
1460 (defvar gnus-last-shell-command nil
1461 "Default shell command on article.")
1463 (defvar gnus-newsgroup-agentized nil
1464 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1465 (defvar gnus-newsgroup-begin nil)
1466 (defvar gnus-newsgroup-end nil)
1467 (defvar gnus-newsgroup-last-rmail nil)
1468 (defvar gnus-newsgroup-last-mail nil)
1469 (defvar gnus-newsgroup-last-folder nil)
1470 (defvar gnus-newsgroup-last-file nil)
1471 (defvar gnus-newsgroup-last-directory nil)
1472 (defvar gnus-newsgroup-auto-expire nil)
1473 (defvar gnus-newsgroup-active nil)
1474 (defvar gnus-newsgroup-highest nil)
1476 (defvar gnus-newsgroup-data nil)
1477 (defvar gnus-newsgroup-data-reverse nil)
1478 (defvar gnus-newsgroup-limit nil)
1479 (defvar gnus-newsgroup-limits nil)
1480 (defvar gnus-summary-use-undownloaded-faces nil)
1482 (defvar gnus-newsgroup-unreads nil
1483 "Sorted list of unread articles in the current newsgroup.")
1485 (defvar gnus-newsgroup-unselected nil
1486 "Sorted list of unselected unread articles in the current newsgroup.")
1488 (defvar gnus-newsgroup-reads nil
1489 "Alist of read articles and article marks in the current newsgroup.")
1491 (defvar gnus-newsgroup-expunged-tally nil)
1493 (defvar gnus-newsgroup-marked nil
1494 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1496 (defvar gnus-newsgroup-spam-marked nil
1497 "List of ranges of articles that have been marked as spam.")
1499 (defvar gnus-newsgroup-killed nil
1500 "List of ranges of articles that have been through the scoring process.")
1502 (defvar gnus-newsgroup-cached nil
1503 "Sorted list of articles that come from the article cache.")
1505 (defvar gnus-newsgroup-saved nil
1506 "List of articles that have been saved.")
1508 (defvar gnus-newsgroup-kill-headers nil)
1510 (defvar gnus-newsgroup-replied nil
1511 "List of articles that have been replied to in the current newsgroup.")
1513 (defvar gnus-newsgroup-forwarded nil
1514 "List of articles that have been forwarded in the current newsgroup.")
1516 (defvar gnus-newsgroup-expirable nil
1517 "Sorted list of articles in the current newsgroup that can be expired.")
1519 (defvar gnus-newsgroup-processable nil
1520 "List of articles in the current newsgroup that can be processed.")
1522 (defvar gnus-newsgroup-downloadable nil
1523 "Sorted list of articles in the current newsgroup that can be processed.")
1525 (defvar gnus-newsgroup-unfetched nil
1526 "Sorted list of articles in the current newsgroup whose headers have
1527 not been fetched into the agent.
1529 This list will always be a subset of gnus-newsgroup-undownloaded.")
1531 (defvar gnus-newsgroup-undownloaded nil
1532 "List of articles in the current newsgroup that haven't been downloaded.")
1534 (defvar gnus-newsgroup-unsendable nil
1535 "List of articles in the current newsgroup that won't be sent.")
1537 (defvar gnus-newsgroup-bookmarks nil
1538 "List of articles in the current newsgroup that have bookmarks.")
1540 (defvar gnus-newsgroup-dormant nil
1541 "Sorted list of dormant articles in the current newsgroup.")
1543 (defvar gnus-newsgroup-unseen nil
1544 "List of unseen articles in the current newsgroup.")
1546 (defvar gnus-newsgroup-seen nil
1547 "Range of seen articles in the current newsgroup.")
1549 (defvar gnus-newsgroup-unexist nil
1550 "Range of unexisting articles in the current newsgroup.")
1552 (defvar gnus-newsgroup-articles nil
1553 "List of articles in the current newsgroup.")
1555 (defvar gnus-newsgroup-scored nil
1556 "List of scored articles in the current newsgroup.")
1558 (defvar gnus-newsgroup-headers nil
1559 "List of article headers in the current newsgroup.")
1561 (defvar gnus-newsgroup-threads nil)
1563 (defvar gnus-newsgroup-prepared nil
1564 "Whether the current group has been prepared properly.")
1566 (defvar gnus-newsgroup-ancient nil
1567 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1569 (defvar gnus-newsgroup-sparse nil)
1571 (defvar gnus-current-article nil)
1572 (defvar gnus-article-current nil)
1573 (defvar gnus-current-headers nil)
1574 (defvar gnus-have-all-headers nil)
1575 (defvar gnus-last-article nil)
1576 (defvar gnus-newsgroup-history nil)
1577 (defvar gnus-newsgroup-charset nil)
1578 (defvar gnus-newsgroup-ephemeral-charset nil)
1579 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1581 (defvar gnus-article-before-search nil)
1583 (defvar gnus-summary-local-variables
1584 '(gnus-newsgroup-name
1586 ;; Marks lists
1587 gnus-newsgroup-unreads
1588 gnus-newsgroup-unselected
1589 gnus-newsgroup-marked
1590 gnus-newsgroup-spam-marked
1591 gnus-newsgroup-reads
1592 gnus-newsgroup-saved
1593 gnus-newsgroup-replied
1594 gnus-newsgroup-forwarded
1595 gnus-newsgroup-expirable
1596 gnus-newsgroup-killed
1597 gnus-newsgroup-unseen
1598 gnus-newsgroup-seen
1599 gnus-newsgroup-unexist
1600 gnus-newsgroup-cached
1601 gnus-newsgroup-downloadable
1602 gnus-newsgroup-undownloaded
1603 gnus-newsgroup-unsendable
1605 gnus-newsgroup-begin gnus-newsgroup-end
1606 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1607 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1608 gnus-newsgroup-last-directory
1609 gnus-newsgroup-auto-expire
1610 gnus-newsgroup-processable
1611 gnus-newsgroup-unfetched
1612 gnus-newsgroup-articles
1613 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1614 gnus-newsgroup-headers gnus-newsgroup-threads
1615 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1616 gnus-current-article gnus-current-headers gnus-have-all-headers
1617 gnus-last-article gnus-article-internal-prepare-hook
1618 (gnus-summary-article-delete-hook . global)
1619 (gnus-summary-article-move-hook . global)
1620 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1621 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1622 gnus-thread-expunge-below
1623 gnus-score-alist gnus-current-score-file
1624 (gnus-summary-expunge-below . global)
1625 (gnus-summary-mark-below . global)
1626 (gnus-orphan-score . global)
1627 gnus-newsgroup-active gnus-scores-exclude-files
1628 gnus-newsgroup-highest
1629 gnus-newsgroup-history gnus-newsgroup-ancient
1630 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1631 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1632 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1633 (gnus-newsgroup-expunged-tally . 0)
1634 gnus-cache-removable-articles
1635 gnus-newsgroup-data gnus-newsgroup-data-reverse
1636 gnus-newsgroup-limit gnus-newsgroup-limits
1637 gnus-newsgroup-charset gnus-newsgroup-display
1638 gnus-summary-use-undownloaded-faces)
1639 "Variables that are buffer-local to the summary buffers.")
1641 (defvar gnus-newsgroup-variables nil
1642 "A list of variables that have separate values in different newsgroups.
1643 A list of newsgroup (summary buffer) local variables, or cons of
1644 variables and their default expressions to be evalled (when the default
1645 values are not nil), that should be made global while the summary buffer
1646 is active.
1648 Note: The default expressions will be evaluated (using function `eval')
1649 before assignment to the local variable rather than just assigned to it.
1650 If the default expression is the symbol `global', that symbol will not
1651 be evaluated but the global value of the local variable will be used
1652 instead.
1654 These variables can be used to set variables in the group parameters
1655 while still allowing them to affect operations done in other buffers.
1656 For example:
1658 \(setq gnus-newsgroup-variables
1659 \\='(message-use-followup-to
1660 (gnus-visible-headers .
1661 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1664 (eval-when-compile
1665 ;; Bind features so that require will believe that gnus-sum has
1666 ;; already been loaded (avoids infinite recursion)
1667 (let ((features (cons 'gnus-sum features)))
1668 (require 'gnus-art)))
1670 ;; MIME stuff.
1672 (defvar gnus-decode-encoded-word-methods
1673 '(mail-decode-encoded-word-string)
1674 "List of methods used to decode encoded words.
1676 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1677 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1678 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1679 whose names match REGEXP.
1681 For example:
1682 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1683 mail-decode-encoded-word-string
1684 (\"chinese\" . rfc1843-decode-string))")
1686 (defvar gnus-decode-encoded-word-methods-cache nil)
1688 (defun gnus-multi-decode-encoded-word-string (string)
1689 "Apply the functions from `gnus-encoded-word-methods' that match."
1690 (unless (and gnus-decode-encoded-word-methods-cache
1691 (eq gnus-newsgroup-name
1692 (car gnus-decode-encoded-word-methods-cache)))
1693 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1694 (dolist (method gnus-decode-encoded-word-methods)
1695 (if (symbolp method)
1696 (nconc gnus-decode-encoded-word-methods-cache (list method))
1697 (if (and gnus-newsgroup-name
1698 (string-match (car method) gnus-newsgroup-name))
1699 (nconc gnus-decode-encoded-word-methods-cache
1700 (list (cdr method)))))))
1701 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1702 (setq string (funcall method string))))
1704 ;; Subject simplification.
1706 (defun gnus-simplify-whitespace (str)
1707 "Remove excessive whitespace from STR."
1708 ;; Multiple spaces.
1709 (while (string-match "[ \t][ \t]+" str)
1710 (setq str (concat (substring str 0 (match-beginning 0))
1712 (substring str (match-end 0)))))
1713 ;; Leading spaces.
1714 (when (string-match "^[ \t]+" str)
1715 (setq str (substring str (match-end 0))))
1716 ;; Trailing spaces.
1717 (when (string-match "[ \t]+$" str)
1718 (setq str (substring str 0 (match-beginning 0))))
1719 str)
1721 (defun gnus-simplify-all-whitespace (str)
1722 "Remove all whitespace from STR."
1723 (while (string-match "[ \t\n]+" str)
1724 (setq str (replace-match "" nil nil str)))
1725 str)
1727 (defsubst gnus-simplify-subject-re (subject)
1728 "Remove \"Re:\" from subject lines."
1729 (if (string-match message-subject-re-regexp subject)
1730 (substring subject (match-end 0))
1731 subject))
1733 (defun gnus-simplify-subject (subject &optional re-only)
1734 "Remove `Re:' and words in parentheses.
1735 If RE-ONLY is non-nil, strip leading `Re:'s only."
1736 (let ((case-fold-search t)) ;Ignore case.
1737 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1738 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1739 (setq subject (substring subject (match-end 0))))
1740 ;; Remove uninteresting prefixes.
1741 (when (and (not re-only)
1742 gnus-simplify-ignored-prefixes
1743 (string-match gnus-simplify-ignored-prefixes subject))
1744 (setq subject (substring subject (match-end 0))))
1745 ;; Remove words in parentheses from end.
1746 (unless re-only
1747 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1748 (setq subject (substring subject 0 (match-beginning 0)))))
1749 ;; Return subject string.
1750 subject))
1752 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1753 ;; all whitespace.
1754 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1755 (goto-char (point-min))
1756 (while (re-search-forward regexp nil t)
1757 (replace-match (or newtext ""))))
1759 (defun gnus-simplify-buffer-fuzzy (regexp)
1760 "Simplify string in the buffer fuzzily.
1761 The string in the accessible portion of the current buffer is simplified.
1762 It is assumed to be a single-line subject.
1763 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1764 matter is removed. Additional things can be deleted by setting
1765 `gnus-simplify-subject-fuzzy-regexp'."
1766 (let ((case-fold-search t)
1767 (modified-tick))
1768 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1770 (while (not (eq modified-tick (buffer-modified-tick)))
1771 (setq modified-tick (buffer-modified-tick))
1772 (cond
1773 ((listp regexp)
1774 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1775 (regexp
1776 (gnus-simplify-buffer-fuzzy-step regexp)))
1777 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1778 (gnus-simplify-buffer-fuzzy-step
1779 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1780 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1782 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1783 (gnus-simplify-buffer-fuzzy-step " +" " ")
1784 (gnus-simplify-buffer-fuzzy-step " $")
1785 (gnus-simplify-buffer-fuzzy-step "^ +")))
1787 (defun gnus-simplify-subject-fuzzy (subject)
1788 "Simplify a subject string fuzzily.
1789 See `gnus-simplify-buffer-fuzzy' for details."
1790 (save-excursion
1791 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1792 (gnus-set-work-buffer)
1793 (let ((case-fold-search t))
1794 ;; Remove uninteresting prefixes.
1795 (when (and gnus-simplify-ignored-prefixes
1796 (string-match gnus-simplify-ignored-prefixes subject))
1797 (setq subject (substring subject (match-end 0))))
1798 (insert subject)
1799 (inline (gnus-simplify-buffer-fuzzy regexp))
1800 (buffer-string)))))
1802 (defsubst gnus-simplify-subject-fully (subject)
1803 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1804 (cond
1805 (gnus-simplify-subject-functions
1806 (gnus-map-function gnus-simplify-subject-functions subject))
1807 ((null gnus-summary-gather-subject-limit)
1808 (gnus-simplify-subject-re subject))
1809 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1810 (gnus-simplify-subject-fuzzy subject))
1811 ((numberp gnus-summary-gather-subject-limit)
1812 (truncate-string-to-width (gnus-simplify-subject-re subject)
1813 gnus-summary-gather-subject-limit))
1815 subject)))
1817 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1818 "Check whether two subjects are equal.
1819 If optional argument SIMPLE-FIRST is t, first argument is already
1820 simplified."
1821 (cond
1822 ((null simple-first)
1823 (equal (gnus-simplify-subject-fully s1)
1824 (gnus-simplify-subject-fully s2)))
1826 (equal s1
1827 (gnus-simplify-subject-fully s2)))))
1829 (defun gnus-summary-bubble-group ()
1830 "Increase the score of the current group.
1831 This is a handy function to add to `gnus-summary-exit-hook' to
1832 increase the score of each group you read."
1833 (gnus-group-add-score gnus-newsgroup-name))
1837 ;;; Gnus summary mode
1840 (put 'gnus-summary-mode 'mode-class 'special)
1842 (defvar gnus-article-commands-menu)
1844 ;; Non-orthogonal keys
1846 (gnus-define-keys gnus-summary-mode-map
1847 " " gnus-summary-next-page
1848 [?\S-\ ] gnus-summary-prev-page
1849 "\177" gnus-summary-prev-page
1850 [delete] gnus-summary-prev-page
1851 "\r" gnus-summary-scroll-up
1852 "\M-\r" gnus-summary-scroll-down
1853 "n" gnus-summary-next-unread-article
1854 "p" gnus-summary-prev-unread-article
1855 "N" gnus-summary-next-article
1856 "P" gnus-summary-prev-article
1857 "\M-\C-n" gnus-summary-next-same-subject
1858 "\M-\C-p" gnus-summary-prev-same-subject
1859 "\M-n" gnus-summary-next-unread-subject
1860 "\M-p" gnus-summary-prev-unread-subject
1861 "." gnus-summary-first-unread-article
1862 "," gnus-summary-best-unread-article
1863 "\M-s" gnus-summary-search-article-forward
1864 "\M-r" gnus-summary-search-article-backward
1865 "\M-S" gnus-summary-repeat-search-article-forward
1866 "\M-R" gnus-summary-repeat-search-article-backward
1867 "<" gnus-summary-beginning-of-article
1868 ">" gnus-summary-end-of-article
1869 "j" gnus-summary-goto-article
1870 "^" gnus-summary-refer-parent-article
1871 "\M-^" gnus-summary-refer-article
1872 "u" gnus-summary-tick-article-forward
1873 "!" gnus-summary-tick-article-forward
1874 "U" gnus-summary-tick-article-backward
1875 "d" gnus-summary-mark-as-read-forward
1876 "D" gnus-summary-mark-as-read-backward
1877 "E" gnus-summary-mark-as-expirable
1878 "\M-u" gnus-summary-clear-mark-forward
1879 "\M-U" gnus-summary-clear-mark-backward
1880 "k" gnus-summary-kill-same-subject-and-select
1881 "\C-k" gnus-summary-kill-same-subject
1882 "\M-\C-k" gnus-summary-kill-thread
1883 "\M-\C-l" gnus-summary-lower-thread
1884 "e" gnus-summary-edit-article
1885 "#" gnus-summary-mark-as-processable
1886 "\M-#" gnus-summary-unmark-as-processable
1887 "\M-\C-t" gnus-summary-toggle-threads
1888 "\M-\C-s" gnus-summary-show-thread
1889 "\M-\C-h" gnus-summary-hide-thread
1890 "\M-\C-f" gnus-summary-next-thread
1891 "\M-\C-b" gnus-summary-prev-thread
1892 [(meta down)] gnus-summary-next-thread
1893 [(meta up)] gnus-summary-prev-thread
1894 "\M-\C-u" gnus-summary-up-thread
1895 "\M-\C-d" gnus-summary-down-thread
1896 "&" gnus-summary-execute-command
1897 "c" gnus-summary-catchup-and-exit
1898 "\C-w" gnus-summary-mark-region-as-read
1899 "\C-t" toggle-truncate-lines
1900 "?" gnus-summary-mark-as-dormant
1901 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1902 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1903 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1904 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1905 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1906 "\C-c\C-s\C-m\C-m" gnus-summary-sort-by-marks
1907 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1908 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1909 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1910 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1911 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1912 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1913 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1914 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1915 "=" gnus-summary-expand-window
1916 "\C-x\C-s" gnus-summary-reselect-current-group
1917 "\M-g" gnus-summary-rescan-group
1918 "\C-c\C-r" gnus-summary-caesar-message
1919 "f" gnus-summary-followup
1920 "F" gnus-summary-followup-with-original
1921 "C" gnus-summary-cancel-article
1922 "r" gnus-summary-reply
1923 "R" gnus-summary-reply-with-original
1924 "\C-c\C-f" gnus-summary-mail-forward
1925 "o" gnus-summary-save-article
1926 "\C-o" gnus-summary-save-article-mail
1927 "|" gnus-summary-pipe-output
1928 "\M-k" gnus-summary-edit-local-kill
1929 "\M-K" gnus-summary-edit-global-kill
1930 ;; "V" gnus-version
1931 "\C-c\C-d" gnus-summary-describe-group
1932 "q" gnus-summary-exit
1933 "Q" gnus-summary-exit-no-update
1934 "\C-c\C-i" gnus-info-find-node
1935 [mouse-2] gnus-mouse-pick-article
1936 [follow-link] mouse-face
1937 "m" gnus-summary-mail-other-window
1938 "a" gnus-summary-post-news
1939 "x" gnus-summary-limit-to-unread
1940 "s" gnus-summary-isearch-article
1941 "\t" gnus-summary-widget-forward
1942 [backtab] gnus-summary-widget-backward
1943 "t" gnus-summary-toggle-header
1944 "g" gnus-summary-show-article
1945 "l" gnus-summary-goto-last-article
1946 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1947 "\C-d" gnus-summary-enter-digest-group
1948 "\M-\C-d" gnus-summary-read-document
1949 "\M-\C-e" gnus-summary-edit-parameters
1950 "\M-\C-a" gnus-summary-customize-parameters
1951 "\C-c\C-b" gnus-bug
1952 "*" gnus-cache-enter-article
1953 "\M-*" gnus-cache-remove-article
1954 "\M-&" gnus-summary-universal-argument
1955 "\C-l" gnus-recenter
1956 "I" gnus-summary-increase-score
1957 "L" gnus-summary-lower-score
1958 "\M-i" gnus-symbolic-argument
1959 "h" gnus-summary-select-article-buffer
1961 "b" gnus-article-view-part
1962 "\M-t" gnus-summary-toggle-display-buttonized
1964 "V" gnus-summary-score-map
1965 "X" gnus-uu-extract-map
1966 "S" gnus-summary-send-map)
1968 ;; Sort of orthogonal keymap
1969 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1970 "t" gnus-summary-tick-article-forward
1971 "!" gnus-summary-tick-article-forward
1972 "d" gnus-summary-mark-as-read-forward
1973 "r" gnus-summary-mark-as-read-forward
1974 "c" gnus-summary-clear-mark-forward
1975 " " gnus-summary-clear-mark-forward
1976 "e" gnus-summary-mark-as-expirable
1977 "x" gnus-summary-mark-as-expirable
1978 "?" gnus-summary-mark-as-dormant
1979 "b" gnus-summary-set-bookmark
1980 "B" gnus-summary-remove-bookmark
1981 "#" gnus-summary-mark-as-processable
1982 "\M-#" gnus-summary-unmark-as-processable
1983 "S" gnus-summary-limit-include-expunged
1984 "C" gnus-summary-catchup
1985 "H" gnus-summary-catchup-to-here
1986 "h" gnus-summary-catchup-from-here
1987 "\C-c" gnus-summary-catchup-all
1988 "k" gnus-summary-kill-same-subject-and-select
1989 "K" gnus-summary-kill-same-subject
1990 "P" gnus-uu-mark-map)
1992 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1993 "c" gnus-summary-clear-above
1994 "u" gnus-summary-tick-above
1995 "m" gnus-summary-mark-above
1996 "k" gnus-summary-kill-below)
1998 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1999 "/" gnus-summary-limit-to-subject
2000 "n" gnus-summary-limit-to-articles
2001 "b" gnus-summary-limit-to-bodies
2002 "h" gnus-summary-limit-to-headers
2003 "w" gnus-summary-pop-limit
2004 "s" gnus-summary-limit-to-subject
2005 "a" gnus-summary-limit-to-author
2006 "u" gnus-summary-limit-to-unread
2007 "m" gnus-summary-limit-to-marks
2008 "M" gnus-summary-limit-exclude-marks
2009 "v" gnus-summary-limit-to-score
2010 "*" gnus-summary-limit-include-cached
2011 "D" gnus-summary-limit-include-dormant
2012 "T" gnus-summary-limit-include-thread
2013 "d" gnus-summary-limit-exclude-dormant
2014 "t" gnus-summary-limit-to-age
2015 "." gnus-summary-limit-to-unseen
2016 "x" gnus-summary-limit-to-extra
2017 "p" gnus-summary-limit-to-display-predicate
2018 "E" gnus-summary-limit-include-expunged
2019 "c" gnus-summary-limit-exclude-childless-dormant
2020 "C" gnus-summary-limit-mark-excluded-as-read
2021 "o" gnus-summary-insert-old-articles
2022 "N" gnus-summary-insert-new-articles
2023 "S" gnus-summary-limit-to-singletons
2024 "r" gnus-summary-limit-to-replied
2025 "R" gnus-summary-limit-to-recipient
2026 "A" gnus-summary-limit-to-address)
2028 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2029 "n" gnus-summary-next-unread-article
2030 "p" gnus-summary-prev-unread-article
2031 "N" gnus-summary-next-article
2032 "P" gnus-summary-prev-article
2033 "\C-n" gnus-summary-next-same-subject
2034 "\C-p" gnus-summary-prev-same-subject
2035 "\M-n" gnus-summary-next-unread-subject
2036 "\M-p" gnus-summary-prev-unread-subject
2037 "f" gnus-summary-first-unread-article
2038 "b" gnus-summary-best-unread-article
2039 "j" gnus-summary-goto-article
2040 "g" gnus-summary-goto-subject
2041 "l" gnus-summary-goto-last-article
2042 "o" gnus-summary-pop-article)
2044 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2045 "k" gnus-summary-kill-thread
2046 "E" gnus-summary-expire-thread
2047 "l" gnus-summary-lower-thread
2048 "i" gnus-summary-raise-thread
2049 "T" gnus-summary-toggle-threads
2050 "t" gnus-summary-rethread-current
2051 "^" gnus-summary-reparent-thread
2052 "\M-^" gnus-summary-reparent-children
2053 "s" gnus-summary-show-thread
2054 "S" gnus-summary-show-all-threads
2055 "h" gnus-summary-hide-thread
2056 "H" gnus-summary-hide-all-threads
2057 "n" gnus-summary-next-thread
2058 "p" gnus-summary-prev-thread
2059 "u" gnus-summary-up-thread
2060 "o" gnus-summary-top-thread
2061 "d" gnus-summary-down-thread
2062 "#" gnus-uu-mark-thread
2063 "\M-#" gnus-uu-unmark-thread)
2065 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2066 "g" gnus-summary-prepare
2067 "c" gnus-summary-insert-cached-articles
2068 "d" gnus-summary-insert-dormant-articles
2069 "t" gnus-summary-insert-ticked-articles)
2071 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2072 "c" gnus-summary-catchup-and-exit
2073 "C" gnus-summary-catchup-all-and-exit
2074 "E" gnus-summary-exit-no-update
2075 "Q" gnus-summary-exit
2076 "Z" gnus-summary-exit
2077 "n" gnus-summary-catchup-and-goto-next-group
2078 "p" gnus-summary-catchup-and-goto-prev-group
2079 "R" gnus-summary-reselect-current-group
2080 "G" gnus-summary-rescan-group
2081 "N" gnus-summary-next-group
2082 "s" gnus-summary-save-newsrc
2083 "P" gnus-summary-prev-group)
2085 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2086 " " gnus-summary-next-page
2087 "n" gnus-summary-next-page
2088 [?\S-\ ] gnus-summary-prev-page
2089 "\177" gnus-summary-prev-page
2090 [delete] gnus-summary-prev-page
2091 "p" gnus-summary-prev-page
2092 "\r" gnus-summary-scroll-up
2093 "\M-\r" gnus-summary-scroll-down
2094 "<" gnus-summary-beginning-of-article
2095 ">" gnus-summary-end-of-article
2096 "b" gnus-summary-beginning-of-article
2097 "e" gnus-summary-end-of-article
2098 "^" gnus-summary-refer-parent-article
2099 "r" gnus-summary-refer-parent-article
2100 "C" gnus-summary-show-complete-article
2101 "D" gnus-summary-enter-digest-group
2102 "R" gnus-summary-refer-references
2103 "T" gnus-summary-refer-thread
2104 "W" gnus-warp-to-article
2105 "g" gnus-summary-show-article
2106 "s" gnus-summary-isearch-article
2107 "\t" gnus-summary-widget-forward
2108 [backtab] gnus-summary-widget-backward
2109 "P" gnus-summary-print-article
2110 "S" gnus-sticky-article
2111 "M" gnus-mailing-list-insinuate
2112 "t" gnus-article-babel)
2114 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2115 "b" gnus-article-add-buttons
2116 "B" gnus-article-add-buttons-to-head
2117 "o" gnus-article-treat-overstrike
2118 "e" gnus-article-emphasize
2119 "w" gnus-article-fill-cited-article
2120 "Q" gnus-article-fill-long-lines
2121 "L" gnus-article-toggle-truncate-lines
2122 "C" gnus-article-capitalize-sentences
2123 "c" gnus-article-remove-cr
2124 "q" gnus-article-de-quoted-unreadable
2125 "6" gnus-article-de-base64-unreadable
2126 "Z" gnus-article-decode-HZ
2127 "A" gnus-article-treat-ansi-sequences
2128 "h" gnus-article-wash-html
2129 "u" gnus-article-unsplit-urls
2130 "s" gnus-summary-force-verify-and-decrypt
2131 "f" gnus-article-display-x-face
2132 "l" gnus-summary-stop-page-breaking
2133 "r" gnus-summary-caesar-message
2134 "m" gnus-summary-morse-message
2135 "t" gnus-summary-toggle-header
2136 "g" gnus-treat-smiley
2137 "v" gnus-summary-verbose-headers
2138 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2139 "p" gnus-article-verify-x-pgp-sig
2140 "d" gnus-article-treat-dumbquotes
2141 "U" gnus-article-treat-non-ascii
2142 "i" gnus-summary-idna-message)
2144 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2145 ;; mnemonic: deuglif*Y*
2146 "u" gnus-article-outlook-unwrap-lines
2147 "a" gnus-article-outlook-repair-attribution
2148 "c" gnus-article-outlook-rearrange-citation
2149 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2151 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2152 "a" gnus-article-hide
2153 "h" gnus-article-hide-headers
2154 "b" gnus-article-hide-boring-headers
2155 "s" gnus-article-hide-signature
2156 "c" gnus-article-hide-citation
2157 "C" gnus-article-hide-citation-in-followups
2158 "l" gnus-article-hide-list-identifiers
2159 "B" gnus-article-strip-banner
2160 "P" gnus-article-hide-pem
2161 "\C-c" gnus-article-hide-citation-maybe)
2163 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2164 "a" gnus-article-highlight
2165 "h" gnus-article-highlight-headers
2166 "c" gnus-article-highlight-citation
2167 "s" gnus-article-highlight-signature)
2169 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2170 "f" gnus-article-treat-fold-headers
2171 "u" gnus-article-treat-unfold-headers
2172 "n" gnus-article-treat-fold-newsgroups)
2174 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2175 "x" gnus-article-display-x-face
2176 "d" gnus-article-display-face
2177 "s" gnus-treat-smiley
2178 "D" gnus-article-remove-images
2179 "W" gnus-article-show-images
2180 "f" gnus-treat-from-picon
2181 "m" gnus-treat-mail-picon
2182 "n" gnus-treat-newsgroups-picon
2183 "g" gnus-treat-from-gravatar
2184 "h" gnus-treat-mail-gravatar)
2186 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2187 "w" gnus-article-decode-mime-words
2188 "c" gnus-article-decode-charset
2189 "h" gnus-mime-buttonize-attachments-in-header
2190 "v" gnus-mime-view-all-parts
2191 "b" gnus-article-view-part)
2193 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2194 "z" gnus-article-date-ut
2195 "u" gnus-article-date-ut
2196 "l" gnus-article-date-local
2197 "p" gnus-article-date-english
2198 "e" gnus-article-date-lapsed
2199 "o" gnus-article-date-original
2200 "i" gnus-article-date-iso8601
2201 "s" gnus-article-date-user)
2203 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2204 "t" gnus-article-remove-trailing-blank-lines
2205 "l" gnus-article-strip-leading-blank-lines
2206 "m" gnus-article-strip-multiple-blank-lines
2207 "a" gnus-article-strip-blank-lines
2208 "A" gnus-article-strip-all-blank-lines
2209 "s" gnus-article-strip-leading-space
2210 "e" gnus-article-strip-trailing-space
2211 "w" gnus-article-remove-leading-whitespace)
2213 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2214 "v" gnus-version
2215 "d" gnus-summary-describe-group
2216 "h" gnus-summary-describe-briefly
2217 "i" gnus-info-find-node)
2219 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2220 "e" gnus-summary-expire-articles
2221 "\M-\C-e" gnus-summary-expire-articles-now
2222 "\177" gnus-summary-delete-article
2223 [delete] gnus-summary-delete-article
2224 [backspace] gnus-summary-delete-article
2225 "m" gnus-summary-move-article
2226 "r" gnus-summary-respool-article
2227 "w" gnus-summary-edit-article
2228 "c" gnus-summary-copy-article
2229 "B" gnus-summary-crosspost-article
2230 "q" gnus-summary-respool-query
2231 "t" gnus-summary-respool-trace
2232 "i" gnus-summary-import-article
2233 "I" gnus-summary-create-article
2234 "p" gnus-summary-article-posted-p)
2236 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2237 "o" gnus-summary-save-article
2238 "m" gnus-summary-save-article-mail
2239 "F" gnus-summary-write-article-file
2240 "r" gnus-summary-save-article-rmail
2241 "f" gnus-summary-save-article-file
2242 "b" gnus-summary-save-article-body-file
2243 "B" gnus-summary-write-article-body-file
2244 "h" gnus-summary-save-article-folder
2245 "v" gnus-summary-save-article-vm
2246 "p" gnus-summary-pipe-output
2247 "P" gnus-summary-muttprint)
2249 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2250 "b" gnus-summary-display-buttonized
2251 "m" gnus-summary-repair-multipart
2252 "v" gnus-article-view-part
2253 "o" gnus-article-save-part
2254 "O" gnus-article-save-part-and-strip
2255 "r" gnus-article-replace-part
2256 "d" gnus-article-delete-part
2257 "t" gnus-article-view-part-as-type
2258 "j" gnus-article-jump-to-part
2259 "c" gnus-article-copy-part
2260 "C" gnus-article-view-part-as-charset
2261 "e" gnus-article-view-part-externally
2262 "H" gnus-article-browse-html-article
2263 "E" gnus-article-encrypt-body
2264 "i" gnus-article-inline-part
2265 "|" gnus-article-pipe-part)
2267 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2268 "p" gnus-summary-mark-as-processable
2269 "u" gnus-summary-unmark-as-processable
2270 "U" gnus-summary-unmark-all-processable
2271 "v" gnus-uu-mark-over
2272 "s" gnus-uu-mark-series
2273 "r" gnus-uu-mark-region
2274 "g" gnus-uu-unmark-region
2275 "R" gnus-uu-mark-by-regexp
2276 "G" gnus-uu-unmark-by-regexp
2277 "t" gnus-uu-mark-thread
2278 "T" gnus-uu-unmark-thread
2279 "a" gnus-uu-mark-all
2280 "b" gnus-uu-mark-buffer
2281 "S" gnus-uu-mark-sparse
2282 "k" gnus-summary-kill-process-mark
2283 "y" gnus-summary-yank-process-mark
2284 "w" gnus-summary-save-process-mark
2285 "i" gnus-uu-invert-processable)
2287 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2288 ;;"x" gnus-uu-extract-any
2289 "m" gnus-summary-save-parts
2290 "u" gnus-uu-decode-uu
2291 "U" gnus-uu-decode-uu-and-save
2292 "s" gnus-uu-decode-unshar
2293 "S" gnus-uu-decode-unshar-and-save
2294 "o" gnus-uu-decode-save
2295 "O" gnus-uu-decode-save
2296 "b" gnus-uu-decode-binhex
2297 "B" gnus-uu-decode-binhex
2298 "Y" gnus-uu-decode-yenc
2299 "p" gnus-uu-decode-postscript
2300 "P" gnus-uu-decode-postscript-and-save)
2302 (gnus-define-keys
2303 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2304 "u" gnus-uu-decode-uu-view
2305 "U" gnus-uu-decode-uu-and-save-view
2306 "s" gnus-uu-decode-unshar-view
2307 "S" gnus-uu-decode-unshar-and-save-view
2308 "o" gnus-uu-decode-save-view
2309 "O" gnus-uu-decode-save-view
2310 "b" gnus-uu-decode-binhex-view
2311 "B" gnus-uu-decode-binhex-view
2312 "p" gnus-uu-decode-postscript-view
2313 "P" gnus-uu-decode-postscript-and-save-view)
2315 (defvar gnus-article-post-menu nil)
2317 (defconst gnus-summary-menu-maxlen 20)
2319 (defun gnus-summary-menu-split (menu)
2320 ;; If we have lots of elements, divide them into groups of 20
2321 ;; and make a pane (or submenu) for each one.
2322 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2323 (let ((menu menu) sublists next
2324 (i 1))
2325 (while menu
2326 ;; Pull off the next gnus-summary-menu-maxlen elements
2327 ;; and make them the next element of sublist.
2328 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2329 (if next
2330 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2331 nil))
2332 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2333 (aref (car (last menu)) 0)) menu)
2334 sublists))
2335 (setq i (1+ i))
2336 (setq menu next))
2337 (nreverse sublists))
2338 ;; Few elements--put them all in one pane.
2339 menu))
2341 (defun gnus-summary-make-menu-bar ()
2342 (gnus-turn-off-edit-menu 'summary)
2344 (unless (boundp 'gnus-summary-misc-menu)
2346 (easy-menu-define
2347 gnus-summary-kill-menu gnus-summary-mode-map ""
2348 (cons
2349 "Score"
2350 (nconc
2351 (list
2352 ["Customize" gnus-score-customize t])
2353 (gnus-make-score-map 'increase)
2354 (gnus-make-score-map 'lower)
2355 '(("Mark"
2356 ["Kill below" gnus-summary-kill-below t]
2357 ["Mark above" gnus-summary-mark-above t]
2358 ["Tick above" gnus-summary-tick-above t]
2359 ["Clear above" gnus-summary-clear-above t])
2360 ["Current article score" gnus-summary-current-score t]
2361 ["Current thread score" (gnus-summary-current-score 'total) t]
2362 ["Set score" gnus-summary-set-score t]
2363 ["Switch current score file..." gnus-score-change-score-file t]
2364 ["Set mark below..." gnus-score-set-mark-below t]
2365 ["Set expunge below..." gnus-score-set-expunge-below t]
2366 ["Edit current score file" gnus-score-edit-current-scores t]
2367 ["Edit score file..." gnus-score-edit-file t]
2368 ["Trace score" gnus-score-find-trace t]
2369 ["Find words" gnus-score-find-favourite-words t]
2370 ["Rescore buffer" gnus-summary-rescore t]
2371 ["Increase score..." gnus-summary-increase-score t]
2372 ["Lower score..." gnus-summary-lower-score t]))))
2374 ;; Define both the Article menu in the summary buffer and the
2375 ;; equivalent Commands menu in the article buffer here for
2376 ;; consistency.
2377 (let ((innards
2378 `(("Hide"
2379 ["All" gnus-article-hide t]
2380 ["Headers" gnus-article-hide-headers t]
2381 ["Signature" gnus-article-hide-signature t]
2382 ["Citation" gnus-article-hide-citation t]
2383 ["List identifiers" gnus-article-hide-list-identifiers t]
2384 ["Banner" gnus-article-strip-banner t]
2385 ["Boring headers" gnus-article-hide-boring-headers t])
2386 ("Highlight"
2387 ["All" gnus-article-highlight t]
2388 ["Headers" gnus-article-highlight-headers t]
2389 ["Signature" gnus-article-highlight-signature t]
2390 ["Citation" gnus-article-highlight-citation t])
2391 ("MIME"
2392 ["Words" gnus-article-decode-mime-words t]
2393 ["Charset" gnus-article-decode-charset t]
2394 ["QP" gnus-article-de-quoted-unreadable t]
2395 ["Base64" gnus-article-de-base64-unreadable t]
2396 ["View MIME buttons" gnus-summary-display-buttonized t]
2397 ["View MIME buttons in header"
2398 gnus-mime-buttonize-attachments-in-header t]
2399 ["View all" gnus-mime-view-all-parts t]
2400 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2401 ["Encrypt body" gnus-article-encrypt-body
2402 :active (not (gnus-group-read-only-p))
2403 :help "Encrypt the message body on disk"]
2404 ["Extract all parts..." gnus-summary-save-parts t]
2405 ("Multipart"
2406 ["Repair multipart" gnus-summary-repair-multipart t]
2407 ["Pipe part..." gnus-article-pipe-part t]
2408 ["Inline part" gnus-article-inline-part t]
2409 ["View part as type..." gnus-article-view-part-as-type t]
2410 ["Encrypt body" gnus-article-encrypt-body
2411 :active (not (gnus-group-read-only-p))
2412 :help "Encrypt the message body on disk"]
2413 ["View part externally" gnus-article-view-part-externally t]
2414 ["View HTML parts in browser" gnus-article-browse-html-article t]
2415 ["View part with charset..." gnus-article-view-part-as-charset t]
2416 ["Copy part" gnus-article-copy-part t]
2417 ["Save part..." gnus-article-save-part t]
2418 ["View part" gnus-article-view-part t]))
2419 ("Date"
2420 ["Local" gnus-article-date-local t]
2421 ["ISO8601" gnus-article-date-iso8601 t]
2422 ["UT" gnus-article-date-ut t]
2423 ["Original" gnus-article-date-original t]
2424 ["Lapsed" gnus-article-date-lapsed t]
2425 ["User-defined" gnus-article-date-user t])
2426 ("Display"
2427 ["Display HTML images" gnus-article-show-images t]
2428 ["Remove images" gnus-article-remove-images t]
2429 ["Toggle smiley" gnus-treat-smiley t]
2430 ["Show X-Face" gnus-article-display-x-face t]
2431 ["Show picons in From" gnus-treat-from-picon t]
2432 ["Show picons in mail headers" gnus-treat-mail-picon t]
2433 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2434 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2435 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2436 ("View as different encoding"
2437 ,@(gnus-summary-menu-split
2438 (mapcar
2439 (lambda (cs)
2440 ;; Since easymenu under Emacs doesn't allow
2441 ;; lambda forms for menu commands, we should
2442 ;; provide intern'ed function symbols.
2443 (let ((command (intern (format "\
2444 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2445 (fset command
2446 `(lambda ()
2447 (interactive)
2448 (let ((gnus-summary-show-article-charset-alist
2449 '((1 . ,cs))))
2450 (gnus-summary-show-article 1))))
2451 `[,(symbol-name cs) ,command t]))
2452 (sort (coding-system-list) 'string<)))))
2453 ("Washing"
2454 ("Remove Blanks"
2455 ["Leading" gnus-article-strip-leading-blank-lines t]
2456 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2457 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2458 ["All of the above" gnus-article-strip-blank-lines t]
2459 ["All" gnus-article-strip-all-blank-lines t]
2460 ["Leading space" gnus-article-strip-leading-space t]
2461 ["Trailing space" gnus-article-strip-trailing-space t]
2462 ["Leading space in headers"
2463 gnus-article-remove-leading-whitespace t])
2464 ["Overstrike" gnus-article-treat-overstrike t]
2465 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2466 ["Non-ASCII" gnus-article-treat-non-ascii t]
2467 ["Emphasis" gnus-article-emphasize t]
2468 ["Word wrap" gnus-article-fill-cited-article t]
2469 ["Fill long lines" gnus-article-fill-long-lines t]
2470 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2471 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2472 ["Remove CR" gnus-article-remove-cr t]
2473 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2474 ["Base64" gnus-article-de-base64-unreadable t]
2475 ["Rot 13" gnus-summary-caesar-message
2476 :help "\"Caesar rotate\" article by 13"]
2477 ["De-IDNA" gnus-summary-idna-message t]
2478 ["Morse decode" gnus-summary-morse-message t]
2479 ["Unix pipe..." gnus-summary-pipe-message t]
2480 ["Add buttons" gnus-article-add-buttons t]
2481 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2482 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2483 ["Verbose header" gnus-summary-verbose-headers t]
2484 ["Toggle header" gnus-summary-toggle-header t]
2485 ["Unfold headers" gnus-article-treat-unfold-headers t]
2486 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2487 ["Html" gnus-article-wash-html t]
2488 ["Unsplit URLs" gnus-article-unsplit-urls t]
2489 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2490 ["Decode HZ" gnus-article-decode-HZ t]
2491 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2492 ("(Outlook) Deuglify"
2493 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2494 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2495 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2496 ["Full (Outlook) deuglify"
2497 gnus-article-outlook-deuglify-article t])
2499 ("Output"
2500 ["Save in default format..." gnus-summary-save-article
2501 :help "Save article using default method"]
2502 ["Save in file..." gnus-summary-save-article-file
2503 :help "Save article in file"]
2504 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2505 ["Save in MH folder..." gnus-summary-save-article-folder t]
2506 ["Save in VM folder..." gnus-summary-save-article-vm t]
2507 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2508 ["Save body in file..." gnus-summary-save-article-body-file t]
2509 ["Pipe through a filter..." gnus-summary-pipe-output t]
2510 ["Print with Muttprint..." gnus-summary-muttprint t]
2511 ["Print" gnus-summary-print-article
2512 :help "Generate and print a PostScript image"])
2513 ("Copy, move,... (Backend)"
2514 :help "Copying, moving, expiring articles..."
2515 ["Respool article..." gnus-summary-respool-article t]
2516 ["Move article..." gnus-summary-move-article
2517 (gnus-check-backend-function
2518 'request-move-article gnus-newsgroup-name)]
2519 ["Copy article..." gnus-summary-copy-article t]
2520 ["Crosspost article..." gnus-summary-crosspost-article
2521 (gnus-check-backend-function
2522 'request-replace-article gnus-newsgroup-name)]
2523 ["Import file..." gnus-summary-import-article
2524 (gnus-check-backend-function
2525 'request-accept-article gnus-newsgroup-name)]
2526 ["Create article..." gnus-summary-create-article
2527 (gnus-check-backend-function
2528 'request-accept-article gnus-newsgroup-name)]
2529 ["Check if posted" gnus-summary-article-posted-p t]
2530 ["Edit article" gnus-summary-edit-article
2531 (not (gnus-group-read-only-p))]
2532 ["Delete article" gnus-summary-delete-article
2533 (gnus-check-backend-function
2534 'request-expire-articles gnus-newsgroup-name)]
2535 ["Query respool" gnus-summary-respool-query t]
2536 ["Trace respool" gnus-summary-respool-trace t]
2537 ["Delete expirable articles" gnus-summary-expire-articles-now
2538 (gnus-check-backend-function
2539 'request-expire-articles gnus-newsgroup-name)])
2540 ("Extract"
2541 ["Uudecode" gnus-uu-decode-uu :help "Decode uuencoded article(s)"]
2542 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2543 ["Unshar" gnus-uu-decode-unshar t]
2544 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2545 ["Save" gnus-uu-decode-save t]
2546 ["Binhex" gnus-uu-decode-binhex t]
2547 ["PostScript" gnus-uu-decode-postscript t]
2548 ["All MIME parts" gnus-summary-save-parts t])
2549 ("Cache"
2550 ["Enter article" gnus-cache-enter-article t]
2551 ["Remove article" gnus-cache-remove-article t])
2552 ["Translate" gnus-article-babel t]
2553 ["Select article buffer" gnus-summary-select-article-buffer t]
2554 ["Make article buffer sticky" gnus-sticky-article t]
2555 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2556 ["Isearch article..." gnus-summary-isearch-article t]
2557 ["Beginning of the article" gnus-summary-beginning-of-article t]
2558 ["End of the article" gnus-summary-end-of-article t]
2559 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2560 ["Fetch referenced articles" gnus-summary-refer-references t]
2561 ["Fetch current thread" gnus-summary-refer-thread t]
2562 ["Fetch article with id..." gnus-summary-refer-article t]
2563 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2564 ["Redisplay" gnus-summary-show-article t]
2565 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2566 (easy-menu-define
2567 gnus-summary-article-menu gnus-summary-mode-map ""
2568 (cons "Article" innards))
2570 (if (not (keymapp gnus-summary-article-menu))
2571 (easy-menu-define
2572 gnus-article-commands-menu gnus-article-mode-map ""
2573 (cons "Commands" innards))
2574 ;; Don't share the menu.
2575 (setq gnus-article-commands-menu
2576 (copy-keymap gnus-summary-article-menu))
2577 (define-key gnus-article-mode-map [menu-bar commands]
2578 (cons "Commands" gnus-article-commands-menu))))
2580 (easy-menu-define
2581 gnus-summary-thread-menu gnus-summary-mode-map ""
2582 '("Threads"
2583 ["Find all messages in thread" gnus-summary-refer-thread t]
2584 ["Toggle threading" gnus-summary-toggle-threads t]
2585 ["Hide threads" gnus-summary-hide-all-threads t]
2586 ["Show threads" gnus-summary-show-all-threads t]
2587 ["Hide thread" gnus-summary-hide-thread t]
2588 ["Show thread" gnus-summary-show-thread t]
2589 ["Go to next thread" gnus-summary-next-thread t]
2590 ["Go to previous thread" gnus-summary-prev-thread t]
2591 ["Go down thread" gnus-summary-down-thread t]
2592 ["Go up thread" gnus-summary-up-thread t]
2593 ["Top of thread" gnus-summary-top-thread t]
2594 ["Mark thread as read" gnus-summary-kill-thread t]
2595 ["Mark thread as expired" gnus-summary-expire-thread t]
2596 ["Lower thread score" gnus-summary-lower-thread t]
2597 ["Raise thread score" gnus-summary-raise-thread t]
2598 ["Rethread current" gnus-summary-rethread-current t]))
2600 (easy-menu-define
2601 gnus-summary-post-menu gnus-summary-mode-map ""
2602 `("Post"
2603 ["Send a message (mail or news)" gnus-summary-post-news
2604 :help "Compose a new message (mail or news)"]
2605 ["Followup" gnus-summary-followup
2606 :help "Post followup to this article"]
2607 ["Followup and yank" gnus-summary-followup-with-original
2608 :help "Post followup to this article, quoting its contents"]
2609 ["Supersede article" gnus-summary-supersede-article t]
2610 ["Cancel article" gnus-summary-cancel-article
2611 :help "Cancel an article you posted"]
2612 ["Reply" gnus-summary-reply t]
2613 ["Reply and yank" gnus-summary-reply-with-original t]
2614 ["Wide reply" gnus-summary-wide-reply t]
2615 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2616 :help "Mail a reply, quoting this article"]
2617 ["Very wide reply" gnus-summary-very-wide-reply t]
2618 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2619 :help "Mail a very wide reply, quoting this article"]
2620 ["Mail forward" gnus-summary-mail-forward t]
2621 ["Post forward" gnus-summary-post-forward t]
2622 ["Digest and mail" gnus-uu-digest-mail-forward t]
2623 ["Digest and post" gnus-uu-digest-post-forward t]
2624 ["Resend message" gnus-summary-resend-message t]
2625 ["Resend message edit" gnus-summary-resend-message-edit t]
2626 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2627 ["Send a mail" gnus-summary-mail-other-window t]
2628 ["Create a local message" gnus-summary-news-other-window t]
2629 ["Uuencode and post" gnus-uu-post-news
2630 :help "Post a uuencoded article"]
2631 ["Followup via news" gnus-summary-followup-to-mail t]
2632 ["Followup via news and yank"
2633 gnus-summary-followup-to-mail-with-original t]
2634 ["Strip signature on reply"
2635 (lambda ()
2636 (interactive)
2637 (setq message-cite-function
2638 (if (eq message-cite-function
2639 'message-cite-original-without-signature)
2640 'message-cite-original
2641 'message-cite-original-without-signature)))
2642 :visible (memq message-cite-function
2643 '(message-cite-original-without-signature
2644 message-cite-original))
2645 :style toggle
2646 :selected (eq message-cite-function
2647 'message-cite-original-without-signature)
2648 :help "Strip signature from cited article when replying."]))
2650 (cond
2651 ((not (keymapp gnus-summary-post-menu))
2652 (setq gnus-article-post-menu gnus-summary-post-menu))
2653 ((not gnus-article-post-menu)
2654 ;; Don't share post menu.
2655 (setq gnus-article-post-menu
2656 (copy-keymap gnus-summary-post-menu))))
2657 (define-key gnus-article-mode-map [menu-bar post]
2658 (cons "Post" gnus-article-post-menu))
2660 (easy-menu-define
2661 gnus-summary-misc-menu gnus-summary-mode-map ""
2662 `("Gnus"
2663 ("Mark Read"
2664 ["Mark as read" gnus-summary-mark-as-read-forward t]
2665 ["Mark same subject and select"
2666 gnus-summary-kill-same-subject-and-select t]
2667 ["Mark same subject" gnus-summary-kill-same-subject t]
2668 ["Catchup" gnus-summary-catchup
2669 :help "Mark unread articles in this group as read"]
2670 ["Catchup all" gnus-summary-catchup-all t]
2671 ["Catchup to here" gnus-summary-catchup-to-here t]
2672 ["Catchup from here" gnus-summary-catchup-from-here t]
2673 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2674 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2675 ("Mark Various"
2676 ["Tick" gnus-summary-tick-article-forward t]
2677 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2678 ["Remove marks" gnus-summary-clear-mark-forward t]
2679 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2680 ["Set bookmark" gnus-summary-set-bookmark t]
2681 ["Remove bookmark" gnus-summary-remove-bookmark t])
2682 ("Limit to"
2683 ["Marks..." gnus-summary-limit-to-marks t]
2684 ["Subject..." gnus-summary-limit-to-subject t]
2685 ["Author..." gnus-summary-limit-to-author t]
2686 ["Recipient..." gnus-summary-limit-to-recipient t]
2687 ["Address..." gnus-summary-limit-to-address t]
2688 ["Age..." gnus-summary-limit-to-age t]
2689 ["Extra..." gnus-summary-limit-to-extra t]
2690 ["Score..." gnus-summary-limit-to-score t]
2691 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2692 ["Unread" gnus-summary-limit-to-unread t]
2693 ["Unseen" gnus-summary-limit-to-unseen t]
2694 ["Singletons" gnus-summary-limit-to-singletons t]
2695 ["Replied" gnus-summary-limit-to-replied t]
2696 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2697 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2698 ["Pop limit" gnus-summary-pop-limit t]
2699 ["Show dormant" gnus-summary-limit-include-dormant t]
2700 ["Hide childless dormant"
2701 gnus-summary-limit-exclude-childless-dormant t]
2702 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2703 ["Hide marked" gnus-summary-limit-exclude-marks t]
2704 ["Show expunged" gnus-summary-limit-include-expunged t])
2705 ("Process Mark"
2706 ["Set mark" gnus-summary-mark-as-processable t]
2707 ["Remove mark" gnus-summary-unmark-as-processable t]
2708 ["Remove all marks" gnus-summary-unmark-all-processable t]
2709 ["Invert marks" gnus-uu-invert-processable t]
2710 ["Mark above" gnus-uu-mark-over t]
2711 ["Mark series" gnus-uu-mark-series t]
2712 ["Mark region" gnus-uu-mark-region mark-active]
2713 ["Unmark region" gnus-uu-unmark-region mark-active]
2714 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2715 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2716 ["Mark all" gnus-uu-mark-all t]
2717 ["Mark buffer" gnus-uu-mark-buffer t]
2718 ["Mark sparse" gnus-uu-mark-sparse t]
2719 ["Mark thread" gnus-uu-mark-thread t]
2720 ["Unmark thread" gnus-uu-unmark-thread t]
2721 ("Process Mark Sets"
2722 ["Kill" gnus-summary-kill-process-mark t]
2723 ["Yank" gnus-summary-yank-process-mark
2724 gnus-newsgroup-process-stack]
2725 ["Save" gnus-summary-save-process-mark t]
2726 ["Run command on marked..." gnus-summary-universal-argument t]))
2727 ("Registry Marks")
2728 ("Scroll article"
2729 ["Page forward" gnus-summary-next-page
2730 :help "Show next page of article"]
2731 ["Page backward" gnus-summary-prev-page
2732 :help "Show previous page of article"]
2733 ["Line forward" gnus-summary-scroll-up t])
2734 ("Move"
2735 ["Next unread article" gnus-summary-next-unread-article t]
2736 ["Previous unread article" gnus-summary-prev-unread-article t]
2737 ["Next article" gnus-summary-next-article t]
2738 ["Previous article" gnus-summary-prev-article t]
2739 ["Next unread subject" gnus-summary-next-unread-subject t]
2740 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2741 ["Next article same subject" gnus-summary-next-same-subject t]
2742 ["Previous article same subject" gnus-summary-prev-same-subject t]
2743 ["First unread article" gnus-summary-first-unread-article t]
2744 ["Best unread article" gnus-summary-best-unread-article t]
2745 ["Go to subject number..." gnus-summary-goto-subject t]
2746 ["Go to article number..." gnus-summary-goto-article t]
2747 ["Go to the last article" gnus-summary-goto-last-article t]
2748 ["Pop article off history" gnus-summary-pop-article t])
2749 ("Sort"
2750 ["Sort by number" gnus-summary-sort-by-number t]
2751 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2752 ["Sort by author" gnus-summary-sort-by-author t]
2753 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2754 ["Sort by subject" gnus-summary-sort-by-subject t]
2755 ["Sort by date" gnus-summary-sort-by-date t]
2756 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2757 ["Sort by score" gnus-summary-sort-by-score t]
2758 ["Sort by lines" gnus-summary-sort-by-lines t]
2759 ["Sort by characters" gnus-summary-sort-by-chars t]
2760 ["Sort by marks" gnus-summary-sort-by-marks t]
2761 ["Randomize" gnus-summary-sort-by-random t]
2762 ["Original sort" gnus-summary-sort-by-original t])
2763 ("Help"
2764 ["Describe group" gnus-summary-describe-group t]
2765 ["Read manual" gnus-info-find-node t])
2766 ("Modes"
2767 ["Pick and read" gnus-pick-mode t]
2768 ["Binary" gnus-binary-mode t])
2769 ("Regeneration"
2770 ["Regenerate" gnus-summary-prepare t]
2771 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2772 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2773 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2774 ["Toggle threading" gnus-summary-toggle-threads t])
2775 ["See old articles" gnus-summary-insert-old-articles t]
2776 ["See new articles" gnus-summary-insert-new-articles t]
2777 ["Filter articles..." gnus-summary-execute-command t]
2778 ["Run command on articles..." gnus-summary-universal-argument t]
2779 ["Search articles forward..." gnus-summary-search-article-forward t]
2780 ["Search articles backward..." gnus-summary-search-article-backward t]
2781 ["Toggle line truncation" toggle-truncate-lines t]
2782 ["Expand window" gnus-summary-expand-window t]
2783 ["Expire expirable articles" gnus-summary-expire-articles
2784 (gnus-check-backend-function
2785 'request-expire-articles gnus-newsgroup-name)]
2786 ["Edit local kill file" gnus-summary-edit-local-kill t]
2787 ["Edit main kill file" gnus-summary-edit-global-kill t]
2788 ["Edit group parameters" gnus-summary-edit-parameters t]
2789 ["Customize group parameters" gnus-summary-customize-parameters t]
2790 ["Send a bug report" gnus-bug t]
2791 ("Exit"
2792 ["Catchup and exit" gnus-summary-catchup-and-exit
2793 :help "Mark unread articles in this group as read, then exit"]
2794 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2795 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2796 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2797 ["Exit group" gnus-summary-exit
2798 :help "Exit current group, return to group selection mode"]
2799 ["Exit group without updating" gnus-summary-exit-no-update t]
2800 ["Exit and goto next group" gnus-summary-next-group t]
2801 ["Exit and goto prev group" gnus-summary-prev-group t]
2802 ["Reselect group" gnus-summary-reselect-current-group t]
2803 ["Rescan group" gnus-summary-rescan-group t]
2804 ["Update dribble" gnus-summary-save-newsrc t])))
2806 (gnus-run-hooks 'gnus-summary-menu-hook)))
2808 (defvar gnus-summary-tool-bar-map nil)
2810 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2811 ;; affect _new_ message buffers. We might add a function that walks thru all
2812 ;; summary-mode buffers and force the update.
2813 (defun gnus-summary-tool-bar-update (&optional symbol value)
2814 "Update summary mode toolbar.
2815 Setter function for custom variables."
2816 (setq-default gnus-summary-tool-bar-map nil)
2817 (when symbol
2818 ;; When used as ":set" function:
2819 (set-default symbol value))
2820 (when (gnus-buffer-live-p gnus-summary-buffer)
2821 (with-current-buffer gnus-summary-buffer
2822 (gnus-summary-make-tool-bar))))
2824 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2825 'gnus-summary-tool-bar-gnome
2826 'gnus-summary-tool-bar-retro)
2827 "Specifies the Gnus summary tool bar.
2829 It can be either a list or a symbol referring to a list. See
2830 `gmm-tool-bar-from-list' for the format of the list. The
2831 default key map is `gnus-summary-mode-map'.
2833 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2834 `gnus-summary-tool-bar-retro'."
2835 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2836 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2837 (repeat :tag "User defined list" gmm-tool-bar-item)
2838 (symbol))
2839 :version "23.1" ;; No Gnus
2840 :initialize 'custom-initialize-default
2841 :set 'gnus-summary-tool-bar-update
2842 :group 'gnus-summary)
2844 (defcustom gnus-summary-tool-bar-gnome
2845 '((gnus-summary-post-news "mail/compose" nil)
2846 (gnus-summary-insert-new-articles "mail/inbox" nil
2847 :visible (or (not gnus-agent)
2848 gnus-plugged))
2849 (gnus-summary-reply-with-original "mail/reply")
2850 (gnus-summary-reply "mail/reply" nil :visible nil)
2851 (gnus-summary-followup-with-original "mail/reply-all")
2852 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2853 (gnus-summary-mail-forward "mail/forward")
2854 (gnus-summary-save-article "mail/save")
2855 (gnus-summary-search-article-forward "search" nil :visible nil)
2856 (gnus-summary-print-article "print")
2857 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2858 ;; Some new commands that may need more suitable icons:
2859 (gnus-summary-save-newsrc "save" nil :visible nil)
2860 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2861 (gnus-summary-prev-article "left-arrow")
2862 (gnus-summary-next-article "right-arrow")
2863 (gnus-summary-next-page "next-page")
2864 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2866 ;; Maybe some sort-by-... could be added:
2867 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2868 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2869 (gnus-summary-mark-as-expirable
2870 "delete" nil
2871 :visible (gnus-check-backend-function 'request-expire-articles
2872 gnus-newsgroup-name))
2873 (gnus-summary-mark-as-spam
2874 "mail/spam" t
2875 :visible (and (fboundp 'spam-group-ham-contents-p)
2876 (spam-group-ham-contents-p gnus-newsgroup-name))
2877 :help "Mark as spam")
2878 (gnus-summary-mark-as-read-forward
2879 "mail/not-spam" nil
2880 :visible (and (fboundp 'spam-group-spam-contents-p)
2881 (spam-group-spam-contents-p gnus-newsgroup-name)))
2883 (gnus-summary-exit "exit")
2884 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2885 (gnus-info-find-node "help"))
2886 "List of functions for the summary tool bar (GNOME style).
2888 See `gmm-tool-bar-from-list' for the format of the list."
2889 :type '(repeat gmm-tool-bar-item)
2890 :version "23.1" ;; No Gnus
2891 :initialize 'custom-initialize-default
2892 :set 'gnus-summary-tool-bar-update
2893 :group 'gnus-summary)
2895 (defcustom gnus-summary-tool-bar-retro
2896 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2897 (gnus-summary-next-unread-article "gnus/next-ur")
2898 (gnus-summary-post-news "gnus/post")
2899 (gnus-summary-followup-with-original "gnus/fuwo")
2900 (gnus-summary-followup "gnus/followup")
2901 (gnus-summary-reply-with-original "gnus/reply-wo")
2902 (gnus-summary-reply "gnus/reply")
2903 (gnus-summary-caesar-message "gnus/rot13")
2904 (gnus-uu-decode-uu "gnus/uu-decode")
2905 (gnus-summary-save-article-file "gnus/save-aif")
2906 (gnus-summary-save-article "gnus/save-art")
2907 (gnus-uu-post-news "gnus/uu-post")
2908 (gnus-summary-catchup "gnus/catchup")
2909 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2910 (gnus-summary-exit "gnus/exit-summ")
2911 ;; Some new command that may need more suitable icons:
2912 (gnus-summary-print-article "gnus/print" nil :visible nil)
2913 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2914 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2915 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2916 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2917 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2918 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2920 (gnus-info-find-node "gnus/help" nil :visible nil))
2921 "List of functions for the summary tool bar (retro look).
2923 See `gmm-tool-bar-from-list' for the format of the list."
2924 :type '(repeat gmm-tool-bar-item)
2925 :version "23.1" ;; No Gnus
2926 :initialize 'custom-initialize-default
2927 :set 'gnus-summary-tool-bar-update
2928 :group 'gnus-summary)
2930 (defcustom gnus-summary-tool-bar-zap-list t
2931 "List of icon items from the global tool bar.
2932 These items are not displayed in the Gnus summary mode tool bar.
2934 See `gmm-tool-bar-from-list' for the format of the list."
2935 :type 'gmm-tool-bar-zap-list
2936 :version "23.1" ;; No Gnus
2937 :initialize 'custom-initialize-default
2938 :set 'gnus-summary-tool-bar-update
2939 :group 'gnus-summary)
2941 (defvar image-load-path)
2942 (defvar tool-bar-map)
2944 (defun gnus-summary-make-tool-bar (&optional force)
2945 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2946 When FORCE, rebuild the tool bar."
2947 (when (and (boundp 'tool-bar-mode)
2948 tool-bar-mode
2949 (or (not gnus-summary-tool-bar-map) force))
2950 (let* ((load-path
2951 (image-load-path-for-library "gnus" "mail/save.xpm" nil t))
2952 (image-load-path (cons (car load-path) image-load-path))
2953 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2954 gnus-summary-tool-bar-zap-list
2955 'gnus-summary-mode-map)))
2956 (when map
2957 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2958 ;; uses its value.
2959 (setq gnus-summary-tool-bar-map map))))
2960 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2962 (defun gnus-make-score-map (type)
2963 "Make a summary score map of type TYPE."
2964 (if t
2966 (let ((headers '(("author" "from" string)
2967 ("subject" "subject" string)
2968 ("article body" "body" string)
2969 ("article head" "head" string)
2970 ("xref" "xref" string)
2971 ("extra header" "extra" string)
2972 ("lines" "lines" number)
2973 ("followups to author" "followup" string)))
2974 (types '((number ("less than" <)
2975 ("greater than" >)
2976 ("equal" =))
2977 (string ("substring" s)
2978 ("exact string" e)
2979 ("fuzzy string" f)
2980 ("regexp" r))))
2981 (perms '(("temporary" (current-time-string))
2982 ("permanent" nil)
2983 ("immediate" now)))
2984 header)
2985 (list
2986 (apply
2987 'nconc
2988 (list
2989 (if (eq type 'lower)
2990 "Lower score"
2991 "Increase score"))
2992 (let (outh)
2993 (while headers
2994 (setq header (car headers))
2995 (setq outh
2996 (cons
2997 (apply
2998 'nconc
2999 (list (car header))
3000 (let ((ts (cdr (assoc (nth 2 header) types)))
3001 outt)
3002 (while ts
3003 (setq outt
3004 (cons
3005 (apply
3006 'nconc
3007 (list (caar ts))
3008 (let ((ps perms)
3009 outp)
3010 (while ps
3011 (setq outp
3012 (cons
3013 (vector
3014 (caar ps)
3015 (list
3016 'gnus-summary-score-entry
3017 (nth 1 header)
3018 (if (or (string= (nth 1 header)
3019 "head")
3020 (string= (nth 1 header)
3021 "body"))
3023 (list 'gnus-summary-header
3024 (nth 1 header)))
3025 (list 'quote (nth 1 (car ts)))
3026 (list 'gnus-score-delta-default
3027 nil)
3028 (nth 1 (car ps))
3031 outp))
3032 (setq ps (cdr ps)))
3033 (list (nreverse outp))))
3034 outt))
3035 (setq ts (cdr ts)))
3036 (list (nreverse outt))))
3037 outh))
3038 (setq headers (cdr headers)))
3039 (list (nreverse outh))))))))
3042 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3043 (defvar bookmark-make-record-function)
3045 (defvar bidi-paragraph-direction)
3047 (defun gnus-summary-mode (&optional group)
3048 "Major mode for reading articles.
3050 All normal editing commands are switched off.
3051 \\<gnus-summary-mode-map>
3052 Each line in this buffer represents one article. To read an
3053 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3054 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3055 respectively.
3057 You can also post articles and send mail from this buffer. To
3058 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3059 of an article, type `\\[gnus-summary-reply]'.
3061 There are approx. one gazillion commands you can execute in this
3062 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3064 The following commands are available:
3066 \\{gnus-summary-mode-map}"
3067 ;; FIXME: Use define-derived-mode.
3068 (interactive)
3069 (kill-all-local-variables)
3070 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3071 (gnus-summary-make-local-variables))
3072 (gnus-summary-make-local-variables)
3073 (setq gnus-newsgroup-name group)
3074 (when (gnus-visual-p 'summary-menu 'menu)
3075 (gnus-summary-make-menu-bar)
3076 (gnus-summary-make-tool-bar))
3077 (gnus-make-thread-indent-array)
3078 (gnus-simplify-mode-line)
3079 (setq major-mode 'gnus-summary-mode)
3080 (setq mode-name "Summary")
3081 (use-local-map gnus-summary-mode-map)
3082 (buffer-disable-undo)
3083 (setq buffer-read-only t
3084 show-trailing-whitespace nil
3085 truncate-lines t
3086 bidi-paragraph-direction 'left-to-right)
3087 (add-to-invisibility-spec '(gnus-sum . t))
3088 (gnus-summary-set-display-table)
3089 (gnus-set-default-directory)
3090 (make-local-variable 'gnus-summary-line-format)
3091 (make-local-variable 'gnus-summary-line-format-spec)
3092 (make-local-variable 'gnus-summary-dummy-line-format)
3093 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3094 (make-local-variable 'gnus-summary-mark-positions)
3095 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3096 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3097 (turn-on-gnus-mailing-list-mode)
3098 (mm-enable-multibyte)
3099 (set (make-local-variable 'bookmark-make-record-function)
3100 'gnus-summary-bookmark-make-record)
3101 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3102 (gnus-update-summary-mark-positions))
3104 (defun gnus-summary-make-local-variables ()
3105 "Make all the local summary buffer variables."
3106 (let (global)
3107 (dolist (local gnus-summary-local-variables)
3108 (if (consp local)
3109 (progn
3110 (if (eq (cdr local) 'global)
3111 ;; Copy the global value of the variable.
3112 (setq global (symbol-value (car local)))
3113 ;; Use the value from the list.
3114 (setq global (eval (cdr local))))
3115 (set (make-local-variable (car local)) global))
3116 ;; Simple nil-valued local variable.
3117 (set (make-local-variable local) nil)))))
3119 ;; Summary data functions.
3121 (defmacro gnus-data-number (data)
3122 `(car ,data))
3124 (defmacro gnus-data-set-number (data number)
3125 `(setcar ,data ,number))
3127 (defmacro gnus-data-mark (data)
3128 `(nth 1 ,data))
3130 (defmacro gnus-data-set-mark (data mark)
3131 `(setcar (nthcdr 1 ,data) ,mark))
3133 (defmacro gnus-data-pos (data)
3134 `(nth 2 ,data))
3136 (defmacro gnus-data-set-pos (data pos)
3137 `(setcar (nthcdr 2 ,data) ,pos))
3139 (defmacro gnus-data-header (data)
3140 `(nth 3 ,data))
3142 (defmacro gnus-data-set-header (data header)
3143 `(setf (nth 3 ,data) ,header))
3145 (defmacro gnus-data-level (data)
3146 `(nth 4 ,data))
3148 (defmacro gnus-data-unread-p (data)
3149 `(= (nth 1 ,data) gnus-unread-mark))
3151 (defmacro gnus-data-read-p (data)
3152 `(/= (nth 1 ,data) gnus-unread-mark))
3154 (defmacro gnus-data-pseudo-p (data)
3155 `(consp (nth 3 ,data)))
3157 (defmacro gnus-data-find (number)
3158 `(assq ,number gnus-newsgroup-data))
3160 (defmacro gnus-data-find-list (number &optional data)
3161 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3162 (memq (assq ,number bdata)
3163 bdata)))
3165 (defmacro gnus-data-make (number mark pos header level)
3166 `(list ,number ,mark ,pos ,header ,level))
3168 (defun gnus-data-enter (after-article number mark pos header level offset)
3169 (let ((data (gnus-data-find-list after-article)))
3170 (unless data
3171 (error "No such article: %d" after-article))
3172 (setcdr data (cons (gnus-data-make number mark pos header level)
3173 (cdr data)))
3174 (setq gnus-newsgroup-data-reverse nil)
3175 (gnus-data-update-list (cddr data) offset)))
3177 (defun gnus-data-enter-list (after-article list &optional offset)
3178 (when list
3179 (let ((data (and after-article (gnus-data-find-list after-article)))
3180 (ilist list))
3181 (if (not (or data
3182 after-article))
3183 (let ((odata gnus-newsgroup-data))
3184 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3185 (when offset
3186 (gnus-data-update-list odata offset)))
3187 ;; Find the last element in the list to be spliced into the main
3188 ;; list.
3189 (setq list (last list))
3190 (if (not data)
3191 (progn
3192 (setcdr list gnus-newsgroup-data)
3193 (setq gnus-newsgroup-data ilist)
3194 (when offset
3195 (gnus-data-update-list (cdr list) offset)))
3196 (setcdr list (cdr data))
3197 (setcdr data ilist)
3198 (when offset
3199 (gnus-data-update-list (cdr list) offset))))
3200 (setq gnus-newsgroup-data-reverse nil))))
3202 (defun gnus-data-remove (article &optional offset)
3203 (let ((data gnus-newsgroup-data))
3204 (if (= (gnus-data-number (car data)) article)
3205 (progn
3206 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3207 gnus-newsgroup-data-reverse nil)
3208 (when offset
3209 (gnus-data-update-list gnus-newsgroup-data offset)))
3210 (while (cdr data)
3211 (when (= (gnus-data-number (cadr data)) article)
3212 (setcdr data (cddr data))
3213 (when offset
3214 (gnus-data-update-list (cdr data) offset))
3215 (setq data nil
3216 gnus-newsgroup-data-reverse nil))
3217 (setq data (cdr data))))))
3219 (defmacro gnus-data-list (backward)
3220 `(if ,backward
3221 (or gnus-newsgroup-data-reverse
3222 (setq gnus-newsgroup-data-reverse
3223 (reverse gnus-newsgroup-data)))
3224 gnus-newsgroup-data))
3226 (defun gnus-data-update-list (data offset)
3227 "Add OFFSET to the POS of all data entries in DATA."
3228 (setq gnus-newsgroup-data-reverse nil)
3229 (while data
3230 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3231 (setq data (cdr data))))
3233 (defun gnus-summary-article-pseudo-p (article)
3234 "Say whether this article is a pseudo article or not."
3235 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3237 (defmacro gnus-summary-article-sparse-p (article)
3238 "Say whether this article is a sparse article or not."
3239 `(memq ,article gnus-newsgroup-sparse))
3241 (defmacro gnus-summary-article-ancient-p (article)
3242 "Say whether this article is a sparse article or not."
3243 `(memq ,article gnus-newsgroup-ancient))
3245 (defun gnus-article-children (number)
3246 "Return a list of all children to NUMBER."
3247 (let* ((data (gnus-data-find-list number))
3248 (level (gnus-data-level (car data)))
3249 children)
3250 (setq data (cdr data))
3251 (while (and data
3252 (= (gnus-data-level (car data)) (1+ level)))
3253 (push (gnus-data-number (car data)) children)
3254 (setq data (cdr data)))
3255 children))
3257 (defmacro gnus-summary-skip-intangible ()
3258 "If the current article is intangible, then jump to a different article."
3259 '(let ((to (get-text-property (point) 'gnus-intangible)))
3260 (and to (gnus-summary-goto-subject to))))
3262 (defmacro gnus-summary-article-intangible-p ()
3263 "Say whether this article is intangible or not."
3264 '(get-text-property (point) 'gnus-intangible))
3266 ;; Some summary mode macros.
3268 (defmacro gnus-summary-article-number ()
3269 "The article number of the article on the current line.
3270 If there isn't an article number here, then we return the current
3271 article number."
3272 '(progn
3273 (gnus-summary-skip-intangible)
3274 (or (get-text-property (point) 'gnus-number)
3275 (gnus-summary-last-subject))))
3277 (defmacro gnus-summary-article-header (&optional number)
3278 "Return the header of article NUMBER."
3279 `(gnus-data-header (gnus-data-find
3280 ,(or number '(gnus-summary-article-number)))))
3282 (defmacro gnus-summary-thread-level (&optional number)
3283 "Return the level of thread that starts with article NUMBER."
3284 `(if (and (eq gnus-summary-make-false-root 'dummy)
3285 (get-text-property (point) 'gnus-intangible))
3287 (gnus-data-level (gnus-data-find
3288 ,(or number '(gnus-summary-article-number))))))
3290 (defmacro gnus-summary-article-mark (&optional number)
3291 "Return the mark of article NUMBER."
3292 `(gnus-data-mark (gnus-data-find
3293 ,(or number '(gnus-summary-article-number)))))
3295 (defmacro gnus-summary-article-pos (&optional number)
3296 "Return the position of the line of article NUMBER."
3297 `(gnus-data-pos (gnus-data-find
3298 ,(or number '(gnus-summary-article-number)))))
3300 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3301 (defmacro gnus-summary-article-subject (&optional number)
3302 "Return current subject string or nil if nothing."
3303 `(let ((headers
3304 ,(if number
3305 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3306 '(gnus-data-header (assq (gnus-summary-article-number)
3307 gnus-newsgroup-data)))))
3308 (and headers
3309 (vectorp headers)
3310 (mail-header-subject headers))))
3312 (defmacro gnus-summary-article-score (&optional number)
3313 "Return current article score."
3314 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3315 gnus-newsgroup-scored))
3316 gnus-summary-default-score 0))
3318 (defun gnus-summary-article-children (&optional number)
3319 "Return a list of article numbers that are children of article NUMBER."
3320 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3321 (level (gnus-data-level (car data)))
3322 l children)
3323 (while (and (setq data (cdr data))
3324 (> (setq l (gnus-data-level (car data))) level))
3325 (and (= (1+ level) l)
3326 (push (gnus-data-number (car data))
3327 children)))
3328 (nreverse children)))
3330 (defun gnus-summary-article-parent (&optional number)
3331 "Return the article number of the parent of article NUMBER."
3332 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3333 (gnus-data-list t)))
3334 (level (gnus-data-level (car data))))
3335 (if (zerop level)
3336 () ; This is a root.
3337 ;; We search until we find an article with a level less than
3338 ;; this one. That function has to be the parent.
3339 (while (and (setq data (cdr data))
3340 (not (< (gnus-data-level (car data)) level))))
3341 (and data (gnus-data-number (car data))))))
3343 (defun gnus-unread-mark-p (mark)
3344 "Say whether MARK is the unread mark."
3345 (= mark gnus-unread-mark))
3347 (defun gnus-read-mark-p (mark)
3348 "Say whether MARK is one of the marks that mark as read.
3349 This is all marks except unread, ticked, dormant, and expirable."
3350 (not (or (= mark gnus-unread-mark)
3351 (= mark gnus-ticked-mark)
3352 (= mark gnus-spam-mark)
3353 (= mark gnus-dormant-mark)
3354 (= mark gnus-expirable-mark))))
3356 (defmacro gnus-article-mark (number)
3357 "Return the MARK of article NUMBER.
3358 This macro should only be used when computing the mark the \"first\"
3359 time; i.e., when generating the summary lines. After that,
3360 `gnus-summary-article-mark' should be used to examine the
3361 marks of articles."
3362 `(cond
3363 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3364 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3365 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3366 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3367 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3368 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3369 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3370 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3371 gnus-ancient-mark))))
3373 ;; Saving hidden threads.
3375 (defmacro gnus-save-hidden-threads (&rest forms)
3376 "Save hidden threads, eval FORMS, and restore the hidden threads."
3377 (let ((config (make-symbol "config")))
3378 `(let ((,config (gnus-hidden-threads-configuration)))
3379 (unwind-protect
3380 (save-excursion
3381 ,@forms)
3382 (gnus-restore-hidden-threads-configuration ,config)))))
3383 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3384 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3386 (defun gnus-data-compute-positions ()
3387 "Compute the positions of all articles."
3388 (setq gnus-newsgroup-data-reverse nil)
3389 (let ((data gnus-newsgroup-data))
3390 (save-excursion
3391 (gnus-save-hidden-threads
3392 (gnus-summary-show-all-threads)
3393 (goto-char (point-min))
3394 (while data
3395 (while (get-text-property (point) 'gnus-intangible)
3396 (forward-line 1))
3397 (gnus-data-set-pos (car data) (+ (point) 3))
3398 (setq data (cdr data))
3399 (forward-line 1))))))
3401 (defun gnus-hidden-threads-configuration ()
3402 "Return the current hidden threads configuration."
3403 (save-excursion
3404 (let (config)
3405 (goto-char (point-min))
3406 (while (not (eobp))
3407 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3408 (push (save-excursion (forward-line 0) (point)) config))
3409 (forward-line 1))
3410 config)))
3412 (defun gnus-restore-hidden-threads-configuration (config)
3413 "Restore hidden threads configuration from CONFIG."
3414 (save-excursion
3415 (let (point (inhibit-read-only t))
3416 (while (setq point (pop config))
3417 (goto-char point)
3418 (gnus-summary-hide-thread)))))
3420 ;; Various summary mode internalish functions.
3422 (defun gnus-mouse-pick-article (e)
3423 (interactive "e")
3424 (mouse-set-point e)
3425 (gnus-summary-next-page nil t))
3427 (defun gnus-summary-set-display-table ()
3428 "Change the display table.
3429 Odd characters have a tendency to mess
3430 up nicely formatted displays - we make all possible glyphs
3431 display only a single character."
3433 ;; We start from the standard display table, if any.
3434 (let ((table (or (copy-sequence standard-display-table)
3435 (make-display-table)))
3436 (i 32))
3437 ;; Nix out all the control chars...
3438 (while (>= (setq i (1- i)) 0)
3439 (aset table i [??]))
3440 ;; ... but not newline and cr, of course. (cr is necessary for the
3441 ;; selective display).
3442 (aset table ?\n nil)
3443 (aset table ?\r nil)
3444 ;; We keep TAB as well.
3445 (aset table ?\t nil)
3446 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3447 ;; Emacs 23 (unicode), that are not set already.
3448 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3450 256)))
3451 (while (>= (setq i (1- i)) 127)
3452 ;; Only modify if the entry is nil.
3453 (unless (aref table i)
3454 (aset table i [??]))))
3455 (setq buffer-display-table table)))
3457 (defun gnus-summary-set-article-display-arrow (pos)
3458 "Update the overlay arrow to point to line at position POS."
3459 (when gnus-summary-display-arrow
3460 (make-local-variable 'overlay-arrow-position)
3461 (make-local-variable 'overlay-arrow-string)
3462 (save-excursion
3463 (goto-char pos)
3464 (beginning-of-line)
3465 (unless overlay-arrow-position
3466 (setq overlay-arrow-position (make-marker)))
3467 (setq overlay-arrow-string "=>"
3468 overlay-arrow-position (set-marker overlay-arrow-position
3469 (point)
3470 (current-buffer))))))
3472 (defun gnus-summary-setup-buffer (group)
3473 "Initialize summary buffer.
3474 If the setup was successful, non-nil is returned."
3475 (let ((buffer (gnus-summary-buffer-name group))
3476 (dead-name (concat "*Dead Summary "
3477 (gnus-group-decoded-name group) "*")))
3478 ;; If a dead summary buffer exists, we kill it.
3479 (when (gnus-buffer-live-p dead-name)
3480 (gnus-kill-buffer dead-name))
3481 (if (get-buffer buffer)
3482 (progn
3483 (set-buffer buffer)
3484 (setq gnus-summary-buffer (current-buffer))
3485 (not gnus-newsgroup-prepared))
3486 (set-buffer (gnus-get-buffer-create buffer))
3487 (setq gnus-summary-buffer (current-buffer))
3488 (gnus-summary-mode group)
3489 (when (gnus-group-quit-config group)
3490 (set (make-local-variable 'gnus-single-article-buffer) nil))
3491 (make-local-variable 'gnus-article-buffer)
3492 (make-local-variable 'gnus-article-current)
3493 (make-local-variable 'gnus-original-article-buffer)
3494 (setq gnus-newsgroup-name group)
3495 ;; Set any local variables in the group parameters.
3496 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3497 t)))
3499 (defun gnus-set-global-variables ()
3500 "Set the global equivalents of the buffer-local variables.
3501 They are set to the latest values they had. These reflect the summary
3502 buffer that was in action when the last article was fetched."
3503 (when (derived-mode-p 'gnus-summary-mode)
3504 (setq gnus-summary-buffer (current-buffer))
3505 (let ((name gnus-newsgroup-name)
3506 (marked gnus-newsgroup-marked)
3507 (spam gnus-newsgroup-spam-marked)
3508 (unread gnus-newsgroup-unreads)
3509 (headers gnus-current-headers)
3510 (data gnus-newsgroup-data)
3511 (summary gnus-summary-buffer)
3512 (article-buffer gnus-article-buffer)
3513 (original gnus-original-article-buffer)
3514 (gac gnus-article-current)
3515 (reffed gnus-reffed-article-number)
3516 (score-file gnus-current-score-file)
3517 (default-charset gnus-newsgroup-charset)
3518 vlist)
3519 (let ((locals gnus-newsgroup-variables))
3520 (while locals
3521 (if (consp (car locals))
3522 (push (eval (caar locals)) vlist)
3523 (push (eval (car locals)) vlist))
3524 (setq locals (cdr locals)))
3525 (setq vlist (nreverse vlist)))
3526 (with-temp-buffer
3527 (setq gnus-newsgroup-name name
3528 gnus-newsgroup-marked marked
3529 gnus-newsgroup-spam-marked spam
3530 gnus-newsgroup-unreads unread
3531 gnus-current-headers headers
3532 gnus-newsgroup-data data
3533 gnus-article-current gac
3534 gnus-summary-buffer summary
3535 gnus-article-buffer article-buffer
3536 gnus-original-article-buffer original
3537 gnus-reffed-article-number reffed
3538 gnus-current-score-file score-file
3539 gnus-newsgroup-charset default-charset)
3540 (let ((locals gnus-newsgroup-variables))
3541 (while locals
3542 (if (consp (car locals))
3543 (set (caar locals) (pop vlist))
3544 (set (car locals) (pop vlist)))
3545 (setq locals (cdr locals))))))))
3547 (defun gnus-summary-article-unread-p (article)
3548 "Say whether ARTICLE is unread or not."
3549 (memq article gnus-newsgroup-unreads))
3551 (defun gnus-summary-first-article-p (&optional article)
3552 "Return whether ARTICLE is the first article in the buffer."
3553 (if (not (setq article (or article (gnus-summary-article-number))))
3555 (eq article (caar gnus-newsgroup-data))))
3557 (defun gnus-summary-last-article-p (&optional article)
3558 "Return whether ARTICLE is the last article in the buffer."
3559 (if (not (setq article (or article (gnus-summary-article-number))))
3560 ;; All non-existent numbers are the last article. :-)
3562 (not (cdr (gnus-data-find-list article)))))
3564 (defun gnus-make-thread-indent-array (&optional n)
3565 (when (or n
3566 (progn (setq n 200) nil)
3567 (null gnus-thread-indent-array)
3568 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3569 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3570 gnus-thread-indent-array-level gnus-thread-indent-level)
3571 (while (>= n 0)
3572 (aset gnus-thread-indent-array n
3573 (make-string (* n gnus-thread-indent-level) ? ))
3574 (setq n (1- n)))))
3576 (defun gnus-update-summary-mark-positions ()
3577 "Compute where the summary marks are to go."
3578 (save-excursion
3579 (when (gnus-buffer-exists-p gnus-summary-buffer)
3580 (set-buffer gnus-summary-buffer))
3581 (let ((spec gnus-summary-line-format-spec)
3582 pos)
3583 (save-excursion
3584 (gnus-set-work-buffer)
3585 (let ((gnus-tmp-unread ?Z)
3586 (gnus-replied-mark ?Z)
3587 (gnus-score-below-mark ?Z)
3588 (gnus-score-over-mark ?Z)
3589 (gnus-undownloaded-mark ?Z)
3590 (gnus-summary-line-format-spec spec)
3591 (gnus-newsgroup-downloadable '(0))
3592 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3593 case-fold-search ignores)
3594 ;; Here, all marks are bound to Z.
3595 (gnus-summary-insert-line header
3596 0 nil t gnus-tmp-unread t nil "" nil 1)
3597 (goto-char (point-min))
3598 ;; Memorize the positions of the same characters as dummy marks.
3599 (while (re-search-forward "[A-D]" nil t)
3600 (push (point) ignores))
3601 (erase-buffer)
3602 ;; We use A-D as dummy marks in order to know column positions
3603 ;; where marks should be inserted.
3604 (setq gnus-tmp-unread ?A
3605 gnus-replied-mark ?B
3606 gnus-score-below-mark ?C
3607 gnus-score-over-mark ?C
3608 gnus-undownloaded-mark ?D)
3609 (gnus-summary-insert-line header
3610 0 nil t gnus-tmp-unread t nil "" nil 1)
3611 ;; Ignore characters which aren't dummy marks.
3612 (dolist (p ignores)
3613 (delete-region (goto-char (1- p)) p)
3614 (insert ?Z))
3615 (goto-char (point-min))
3616 (setq pos (list (cons 'unread
3617 (and (search-forward "A" nil t)
3618 (- (point) (point-min) 1)))))
3619 (goto-char (point-min))
3620 (push (cons 'replied (and (search-forward "B" nil t)
3621 (- (point) (point-min) 1)))
3622 pos)
3623 (goto-char (point-min))
3624 (push (cons 'score (and (search-forward "C" nil t)
3625 (- (point) (point-min) 1)))
3626 pos)
3627 (goto-char (point-min))
3628 (push (cons 'download (and (search-forward "D" nil t)
3629 (- (point) (point-min) 1)))
3630 pos)))
3631 (setq gnus-summary-mark-positions pos))))
3633 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3634 "Insert a dummy root in the summary buffer."
3635 (beginning-of-line)
3636 (add-text-properties
3637 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3638 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3640 (defun gnus-summary-extract-address-component (from)
3641 (or (car (funcall gnus-extract-address-components from))
3642 from))
3644 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3645 (let ((mail-parse-charset gnus-newsgroup-charset)
3646 ;; Is it really necessary to do this next part for each summary line?
3647 ;; Luckily, doesn't seem to slow things down much.
3648 (mail-parse-ignored-charsets
3649 (with-current-buffer gnus-summary-buffer
3650 gnus-newsgroup-ignored-charsets)))
3652 (and gnus-ignored-from-addresses
3653 (cond ((functionp gnus-ignored-from-addresses)
3654 (funcall gnus-ignored-from-addresses
3655 (mail-strip-quoted-names gnus-tmp-from)))
3656 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3657 (let ((extra-headers (mail-header-extra header))
3659 newsgroups)
3660 (cond
3661 ((setq to (cdr (assq 'To extra-headers)))
3662 (concat gnus-summary-to-prefix
3663 (inline
3664 (gnus-summary-extract-address-component
3665 (funcall gnus-decode-encoded-address-function to)))))
3666 ((setq newsgroups
3668 (cdr (assq 'Newsgroups extra-headers))
3669 (and
3670 (memq 'Newsgroups gnus-extra-headers)
3671 (eq (car (gnus-find-method-for-group
3672 gnus-newsgroup-name)) 'nntp)
3673 (gnus-group-real-name gnus-newsgroup-name))))
3674 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3675 (bidi-string-mark-left-to-right
3676 (inline
3677 (gnus-summary-extract-address-component gnus-tmp-from))))))
3679 (defun gnus-summary-insert-line (gnus-tmp-header
3680 gnus-tmp-level gnus-tmp-current
3681 undownloaded gnus-tmp-unread gnus-tmp-replied
3682 gnus-tmp-expirable gnus-tmp-subject-or-nil
3683 &optional gnus-tmp-dummy gnus-tmp-score
3684 gnus-tmp-process)
3685 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3686 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3687 gnus-tmp-level)))
3688 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3689 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3690 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3691 (gnus-tmp-score-char
3692 (if (or (null gnus-summary-default-score)
3693 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3694 gnus-summary-zcore-fuzz))
3695 ? ;Whitespace
3696 (if (< gnus-tmp-score gnus-summary-default-score)
3697 gnus-score-below-mark gnus-score-over-mark)))
3698 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3699 (gnus-tmp-replied
3700 (cond (gnus-tmp-process gnus-process-mark)
3701 ((memq gnus-tmp-current gnus-newsgroup-cached)
3702 gnus-cached-mark)
3703 (gnus-tmp-replied gnus-replied-mark)
3704 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3705 gnus-forwarded-mark)
3706 ((memq gnus-tmp-current gnus-newsgroup-saved)
3707 gnus-saved-mark)
3708 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3709 gnus-unseen-mark)
3710 (t gnus-no-mark)))
3711 (gnus-tmp-downloaded
3712 (cond (undownloaded
3713 gnus-undownloaded-mark)
3714 (gnus-newsgroup-agentized
3715 gnus-downloaded-mark)
3717 gnus-no-mark)))
3718 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3719 (gnus-tmp-name
3720 (cond
3721 ((string-match "<[^>]+> *$" gnus-tmp-from)
3722 (let ((beg (match-beginning 0)))
3723 (or (and (string-match "^\".+\"" gnus-tmp-from)
3724 (substring gnus-tmp-from 1 (1- (match-end 0))))
3725 (substring gnus-tmp-from 0 beg))))
3726 ((string-match "(.+)" gnus-tmp-from)
3727 (substring gnus-tmp-from
3728 (1+ (match-beginning 0)) (1- (match-end 0))))
3729 (t gnus-tmp-from)))
3730 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3731 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3732 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3733 (inhibit-read-only t))
3734 (when (string= gnus-tmp-name "")
3735 (setq gnus-tmp-name gnus-tmp-from))
3736 (unless (numberp gnus-tmp-lines)
3737 (setq gnus-tmp-lines -1))
3738 (if (= gnus-tmp-lines -1)
3739 (setq gnus-tmp-lines "?")
3740 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3741 (condition-case ()
3742 (put-text-property
3743 (point)
3744 (progn (eval gnus-summary-line-format-spec) (point))
3745 'gnus-number gnus-tmp-number)
3746 (error (gnus-message 5 "Error updating the summary line")))
3747 (when (gnus-visual-p 'summary-highlight 'highlight)
3748 (forward-line -1)
3749 (gnus-summary-highlight-line)
3750 (gnus-run-hooks 'gnus-summary-update-hook)
3751 (forward-line 1))))
3753 (defun gnus-summary-update-line (&optional dont-update)
3754 "Update summary line after change."
3755 (when (and gnus-summary-default-score
3756 (not gnus-summary-inhibit-highlight))
3757 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3758 (article (gnus-summary-article-number))
3759 (score (gnus-summary-article-score article)))
3760 (unless dont-update
3761 (if (and gnus-summary-mark-below
3762 (< (gnus-summary-article-score)
3763 gnus-summary-mark-below))
3764 ;; This article has a low score, so we mark it as read.
3765 (when (memq article gnus-newsgroup-unreads)
3766 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3767 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3768 ;; This article was previously marked as read on account
3769 ;; of a low score, but now it has risen, so we mark it as
3770 ;; unread.
3771 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3772 (gnus-summary-update-mark
3773 (if (or (null gnus-summary-default-score)
3774 (<= (abs (- score gnus-summary-default-score))
3775 gnus-summary-zcore-fuzz))
3776 ? ;Whitespace
3777 (if (< score gnus-summary-default-score)
3778 gnus-score-below-mark gnus-score-over-mark))
3779 'score))
3780 ;; Do visual highlighting.
3781 (when (gnus-visual-p 'summary-highlight 'highlight)
3782 (gnus-summary-highlight-line)
3783 (gnus-run-hooks 'gnus-summary-update-hook)))))
3785 (defvar gnus-tmp-new-adopts nil)
3787 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3788 "Return the number of articles in THREAD.
3789 This may be 0 in some cases -- if none of the articles in
3790 the thread are to be displayed."
3791 (let* ((number
3792 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3793 (cond
3794 ((not (listp thread))
3796 ((and (consp thread) (cdr thread))
3797 (apply
3798 '+ 1 (mapcar
3799 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3800 ((null thread)
3802 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3804 (t 0))))
3805 (when (and level (zerop level) gnus-tmp-new-adopts)
3806 (incf number
3807 (apply '+ (mapcar
3808 'gnus-summary-number-of-articles-in-thread
3809 gnus-tmp-new-adopts))))
3810 (if char
3811 (if (> number 1) gnus-not-empty-thread-mark
3812 gnus-empty-thread-mark)
3813 number)))
3815 (defsubst gnus-summary-line-message-size (head)
3816 "Return pretty-printed version of message size.
3817 This function is intended to be used in
3818 `gnus-summary-line-format-alist'."
3819 (let ((c (or (mail-header-chars head) -1)))
3820 (cond ((< c 0) "n/a") ; chars not available
3821 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3822 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3823 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3824 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3826 (defcustom gnus-user-date-format-alist
3827 '(((gnus-seconds-today) . "Today, %H:%M")
3828 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3829 (604800 . "%A %H:%M") ; That's one week
3830 ((gnus-seconds-month) . "%A %d")
3831 ((gnus-seconds-year) . "%B %d")
3832 (t . "%b %d %Y")) ; This one is used when no other
3833 ; does match
3834 "Specifies date format depending on age of article.
3835 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3836 seconds) or a Lisp expression evaluating to a number. When the age of
3837 the article is less than this number, then use `format-time-string'
3838 with the corresponding FORMAT for displaying the date of the article.
3839 If AGE is not a number or a Lisp expression evaluating to a
3840 non-number, then the corresponding FORMAT is used as a default value.
3842 Note that the list is processed from the beginning, so it should be
3843 sorted by ascending AGE. Also note that items following the first
3844 non-number AGE will be ignored.
3846 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3847 and `gnus-seconds-year' in the AGE spec. They return the number of
3848 seconds passed since the start of today, of this month, of this year,
3849 respectively."
3850 :version "24.1"
3851 :group 'gnus-summary-format
3852 :type '(alist :key-type sexp :value-type string))
3854 (defun gnus-user-date (messy-date)
3855 "Format the messy-date according to `gnus-user-date-format-alist'.
3856 Returns \" ? \" if there's bad input or if another error occurs.
3857 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3858 (condition-case ()
3859 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3860 (now (float-time))
3861 ;;If we don't find something suitable we'll use this one
3862 (my-format "%b %d '%y"))
3863 (let* ((difference (- now messy-date))
3864 (templist gnus-user-date-format-alist)
3865 (top (eval (caar templist))))
3866 (while (if (numberp top) (< top difference) (not top))
3867 (progn
3868 (setq templist (cdr templist))
3869 (setq top (eval (caar templist)))))
3870 (if (stringp (cdr (car templist)))
3871 (setq my-format (cdr (car templist)))))
3872 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3873 (error " ? ")))
3875 (defun gnus-summary-set-local-parameters (group)
3876 "Go through the local params of GROUP and set all variable specs in that list."
3877 (let ((vars '(quit-config active))) ; Ignore things that aren't
3878 ; really variables.
3879 (dolist (elem (gnus-group-find-parameter group))
3880 (and (consp elem) ; Has to be a cons.
3881 (consp (cdr elem)) ; The cdr has to be a list.
3882 (symbolp (car elem)) ; Has to be a symbol in there.
3883 (not (memq (car elem) vars))
3884 (ignore-errors
3885 (push (car elem) vars)
3886 ;; Variables like `gnus-show-threads' that are globally
3887 ;; bound, if used as group parameters, need to get to be
3888 ;; buffer-local, whereas just parameters like `gcc-self',
3889 ;; `timestamp', etc. should not be bound as variables.
3890 (if (boundp (car elem))
3891 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3892 (eval (nth 1 elem))))))))
3894 (defun gnus-summary-read-group (group &optional show-all no-article
3895 kill-buffer no-display backward
3896 select-articles)
3897 "Start reading news in newsgroup GROUP.
3898 If SHOW-ALL is non-nil, already read articles are also listed.
3899 If NO-ARTICLE is non-nil, no article is selected initially.
3900 If NO-DISPLAY, don't generate the summary buffer contents.
3901 If KILL-BUFFER, it should be a buffer that's killed once the new
3902 summary buffer has been generated.
3903 If BACKWARD, move point to the previous group in the group buffer
3904 If SELECT-ARTICLES, only select those articles from GROUP."
3905 (let (result)
3906 (while (and group
3907 (null (setq result
3908 (let ((gnus-auto-select-next nil))
3909 (or (gnus-summary-read-group-1
3910 group show-all no-article
3911 kill-buffer no-display
3912 select-articles)
3913 (setq show-all nil
3914 select-articles nil)))))
3915 (eq gnus-auto-select-next 'quietly))
3916 (set-buffer gnus-group-buffer)
3917 ;; The entry function called above goes to the next
3918 ;; group automatically, so we go two groups back
3919 ;; if we are searching for the previous group.
3920 (when backward
3921 (gnus-group-prev-unread-group 2))
3922 (if (not (equal group (gnus-group-group-name)))
3923 (setq group (gnus-group-group-name))
3924 (setq group nil)))
3925 result))
3927 (defun gnus-summary-read-group-1 (group show-all no-article
3928 kill-buffer no-display
3929 &optional select-articles)
3930 ;; Killed foreign groups can't be entered.
3931 ;; (when (and (not (gnus-group-native-p group))
3932 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3933 ;; (error "Dead non-native groups can't be entered"))
3934 (gnus-message 7 "Retrieving newsgroup: %s..."
3935 (gnus-group-decoded-name group))
3936 (let* ((new-group (gnus-summary-setup-buffer group))
3937 (quit-config (gnus-group-quit-config group))
3938 (did-select (and new-group (gnus-select-newsgroup
3939 group show-all select-articles))))
3940 (cond
3941 ;; This summary buffer exists already, so we just select it.
3942 ((not new-group)
3943 (gnus-set-global-variables)
3944 (when kill-buffer
3945 (gnus-kill-or-deaden-summary kill-buffer))
3946 (gnus-configure-windows 'summary 'force)
3947 (gnus-set-mode-line 'summary)
3948 (gnus-summary-position-point)
3949 (message "")
3951 ;; We couldn't select this group.
3952 ((null did-select)
3953 (when (and (derived-mode-p 'gnus-summary-mode)
3954 (not (equal (current-buffer) kill-buffer)))
3955 (kill-buffer (current-buffer))
3956 (if (not quit-config)
3957 (progn
3958 ;; Update the info -- marks might need to be removed,
3959 ;; for instance.
3960 (gnus-summary-update-info)
3961 (set-buffer gnus-group-buffer)
3962 (gnus-group-jump-to-group group)
3963 (gnus-group-next-unread-group 1))
3964 (gnus-handle-ephemeral-exit quit-config)))
3965 (if (null (gnus-list-of-unread-articles group))
3966 (gnus-message 3 "Group %s contains no messages"
3967 (gnus-group-decoded-name group))
3968 (gnus-message 3 "Can't select group"))
3969 nil)
3970 ;; The user did a `C-g' while prompting for number of articles,
3971 ;; so we exit this group.
3972 ((eq did-select 'quit)
3973 (and (derived-mode-p 'gnus-summary-mode)
3974 (not (equal (current-buffer) kill-buffer))
3975 (kill-buffer (current-buffer)))
3976 (when kill-buffer
3977 (gnus-kill-or-deaden-summary kill-buffer))
3978 (if (not quit-config)
3979 (progn
3980 (set-buffer gnus-group-buffer)
3981 (gnus-group-jump-to-group group)
3982 (gnus-configure-windows 'group 'force))
3983 (gnus-handle-ephemeral-exit quit-config))
3984 ;; Finally signal the quit.
3985 (signal 'quit nil))
3986 ;; The group was successfully selected.
3988 (gnus-set-global-variables)
3989 (when (boundp 'gnus-pick-line-number)
3990 (setq gnus-pick-line-number 0))
3991 (when (boundp 'spam-install-hooks)
3992 (spam-initialize))
3993 ;; Save the active value in effect when the group was entered.
3994 (setq gnus-newsgroup-active
3995 (gnus-copy-sequence
3996 (gnus-active gnus-newsgroup-name)))
3997 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3998 ;; You can change the summary buffer in some way with this hook.
3999 (gnus-run-hooks 'gnus-select-group-hook)
4000 (when (memq 'summary (gnus-update-format-specifications
4001 nil 'summary 'summary-mode 'summary-dummy))
4002 ;; The format specification for the summary line was updated,
4003 ;; so we need to update the mark positions as well.
4004 (gnus-update-summary-mark-positions))
4005 ;; Do score processing.
4006 (when gnus-use-scoring
4007 (gnus-possibly-score-headers))
4008 ;; Check whether to fill in the gaps in the threads.
4009 (when gnus-build-sparse-threads
4010 (gnus-build-sparse-threads))
4011 ;; Find the initial limit.
4012 (if show-all
4013 (let ((gnus-newsgroup-dormant nil))
4014 (gnus-summary-initial-limit show-all))
4015 (gnus-summary-initial-limit show-all))
4016 ;; Generate the summary buffer.
4017 (unless no-display
4018 (gnus-summary-prepare))
4019 (when gnus-use-trees
4020 (gnus-tree-open)
4021 (setq gnus-summary-highlight-line-function
4022 'gnus-tree-highlight-article))
4023 ;; If the summary buffer is empty, but there are some low-scored
4024 ;; articles or some excluded dormants, we include these in the
4025 ;; buffer.
4026 (when (and (zerop (buffer-size))
4027 (not no-display))
4028 (cond (gnus-newsgroup-dormant
4029 (gnus-summary-limit-include-dormant))
4030 ((and gnus-newsgroup-scored show-all)
4031 (gnus-summary-limit-include-expunged t))))
4032 ;; Function `gnus-apply-kill-file' must be called in this hook.
4033 (gnus-run-hooks 'gnus-apply-kill-hook)
4034 (if (and (zerop (buffer-size))
4035 (not no-display))
4036 (progn
4037 ;; This newsgroup is empty.
4038 (gnus-summary-catchup-and-exit nil t)
4039 (gnus-message 6 "No unread news")
4040 (when kill-buffer
4041 (gnus-kill-or-deaden-summary kill-buffer))
4042 ;; Return nil from this function.
4043 nil)
4044 ;; Hide conversation thread subtrees. We cannot do this in
4045 ;; gnus-summary-prepare-hook since kill processing may not
4046 ;; work with hidden articles.
4047 (gnus-summary-maybe-hide-threads)
4048 (gnus-configure-windows 'summary)
4049 (when kill-buffer
4050 (gnus-kill-or-deaden-summary kill-buffer))
4051 (gnus-summary-auto-select-subject)
4052 ;; Don't mark any articles as selected if we haven't done that.
4053 (when no-article
4054 (setq overlay-arrow-position nil))
4055 ;; Show first unread article if requested.
4056 (if (and (not no-article)
4057 (not no-display)
4058 gnus-newsgroup-unreads
4059 gnus-auto-select-first)
4060 (progn
4061 (let ((art (gnus-summary-article-number)))
4062 (when (and art
4063 gnus-plugged
4064 (not (memq art gnus-newsgroup-undownloaded))
4065 (not (memq art gnus-newsgroup-downloadable)))
4066 (gnus-summary-goto-article art))))
4067 ;; Don't select any articles.
4068 (gnus-summary-position-point)
4069 (gnus-configure-windows 'summary 'force)
4070 (gnus-set-mode-line 'summary))
4071 (when (and gnus-auto-center-group
4072 (get-buffer-window gnus-group-buffer t))
4073 ;; Gotta use windows, because recenter does weird stuff if
4074 ;; the current buffer ain't the displayed window.
4075 (let ((owin (selected-window)))
4076 (select-window (get-buffer-window gnus-group-buffer t))
4077 (when (gnus-group-goto-group group)
4078 (recenter))
4079 (select-window owin)))
4080 ;; Mark this buffer as "prepared".
4081 (setq gnus-newsgroup-prepared t)
4082 (gnus-run-hooks 'gnus-summary-prepared-hook)
4083 (unless (gnus-ephemeral-group-p group)
4084 (gnus-group-update-group group nil t))
4085 t)))))
4087 (defun gnus-summary-auto-select-subject ()
4088 "Select the subject line on initial group entry."
4089 (goto-char (point-min))
4090 (cond
4091 ((eq gnus-auto-select-subject 'best)
4092 (gnus-summary-best-unread-subject))
4093 ((eq gnus-auto-select-subject 'unread)
4094 (gnus-summary-first-unread-subject))
4095 ((eq gnus-auto-select-subject 'unseen)
4096 (gnus-summary-first-unseen-subject))
4097 ((eq gnus-auto-select-subject 'unseen-or-unread)
4098 (gnus-summary-first-unseen-or-unread-subject))
4099 ((eq gnus-auto-select-subject 'first)
4100 ;; Do nothing.
4102 ((functionp gnus-auto-select-subject)
4103 (funcall gnus-auto-select-subject))))
4105 (defun gnus-summary-prepare ()
4106 "Generate the summary buffer."
4107 (interactive)
4108 (let ((inhibit-read-only t))
4109 (erase-buffer)
4110 (setq gnus-newsgroup-data nil
4111 gnus-newsgroup-data-reverse nil)
4112 (gnus-run-hooks 'gnus-summary-generate-hook)
4113 ;; Generate the buffer, either with threads or without.
4114 (when gnus-newsgroup-headers
4115 (gnus-summary-prepare-threads
4116 (if gnus-show-threads
4117 (gnus-sort-gathered-threads
4118 (funcall gnus-summary-thread-gathering-function
4119 (gnus-sort-threads
4120 (gnus-cut-threads (gnus-make-threads)))))
4121 ;; Unthreaded display.
4122 (gnus-sort-articles gnus-newsgroup-headers))))
4123 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4124 ;; Call hooks for modifying summary buffer.
4125 (goto-char (point-min))
4126 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4128 (defsubst gnus-general-simplify-subject (subject)
4129 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4130 (setq subject
4131 (cond
4132 ;; Truncate the subject.
4133 (gnus-simplify-subject-functions
4134 (gnus-map-function gnus-simplify-subject-functions subject))
4135 ((numberp gnus-summary-gather-subject-limit)
4136 (setq subject (gnus-simplify-subject-re subject))
4137 (if (> (length subject) gnus-summary-gather-subject-limit)
4138 (substring subject 0 gnus-summary-gather-subject-limit)
4139 subject))
4140 ;; Fuzzily simplify it.
4141 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4142 (gnus-simplify-subject-fuzzy subject))
4143 ;; Just remove the leading "Re:".
4145 (gnus-simplify-subject-re subject))))
4147 (if (and gnus-summary-gather-exclude-subject
4148 (string-match gnus-summary-gather-exclude-subject subject))
4149 nil ; This article shouldn't be gathered
4150 subject))
4152 (defun gnus-summary-simplify-subject-query ()
4153 "Query where the respool algorithm would put this article."
4154 (interactive)
4155 (gnus-summary-select-article)
4156 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4158 (defun gnus-gather-threads-by-subject (threads)
4159 "Gather threads by looking at Subject headers."
4160 (if (not gnus-summary-make-false-root)
4161 threads
4162 (let ((hashtb (gnus-make-hashtable 1024))
4163 (prev threads)
4164 (result threads)
4165 subject hthread whole-subject)
4166 (while threads
4167 (setq subject (gnus-general-simplify-subject
4168 (setq whole-subject (mail-header-subject
4169 (caar threads)))))
4170 (when subject
4171 (if (setq hthread (gnus-gethash subject hashtb))
4172 (progn
4173 ;; We enter a dummy root into the thread, if we
4174 ;; haven't done that already.
4175 (unless (stringp (caar hthread))
4176 (setcar hthread (list whole-subject (car hthread))))
4177 ;; We add this new gathered thread to this gathered
4178 ;; thread.
4179 (setcdr (car hthread)
4180 (nconc (cdar hthread) (list (car threads))))
4181 ;; Remove it from the list of threads.
4182 (setcdr prev (cdr threads))
4183 (setq threads prev))
4184 ;; Enter this thread into the hash table.
4185 (gnus-sethash subject
4186 (if gnus-summary-make-false-root-always
4187 (progn
4188 ;; If you want a dummy root above all
4189 ;; threads...
4190 (setcar threads (list whole-subject
4191 (car threads)))
4192 threads)
4193 threads)
4194 hashtb)))
4195 (setq prev threads)
4196 (setq threads (cdr threads)))
4197 result)))
4199 (defun gnus-gather-threads-by-references (threads)
4200 "Gather threads by looking at References headers."
4201 (let ((idhashtb (gnus-make-hashtable 1024))
4202 (thhashtb (gnus-make-hashtable 1024))
4203 (prev threads)
4204 (result threads)
4205 ids references id gthread gid entered ref)
4206 (while threads
4207 (when (setq references (mail-header-references (caar threads)))
4208 (setq id (mail-header-id (caar threads))
4209 ids (inline (gnus-split-references references))
4210 entered nil)
4211 (while (setq ref (pop ids))
4212 (setq ids (delete ref ids))
4213 (if (not (setq gid (gnus-gethash ref idhashtb)))
4214 (progn
4215 (gnus-sethash ref id idhashtb)
4216 (gnus-sethash id threads thhashtb))
4217 (setq gthread (gnus-gethash gid thhashtb))
4218 (unless entered
4219 ;; We enter a dummy root into the thread, if we
4220 ;; haven't done that already.
4221 (unless (stringp (caar gthread))
4222 (setcar gthread (list (mail-header-subject (caar gthread))
4223 (car gthread))))
4224 ;; We add this new gathered thread to this gathered
4225 ;; thread.
4226 (setcdr (car gthread)
4227 (nconc (cdar gthread) (list (car threads)))))
4228 ;; Add it into the thread hash table.
4229 (gnus-sethash id gthread thhashtb)
4230 (setq entered t)
4231 ;; Remove it from the list of threads.
4232 (setcdr prev (cdr threads))
4233 (setq threads prev))))
4234 (setq prev threads)
4235 (setq threads (cdr threads)))
4236 result))
4238 (defun gnus-sort-gathered-threads (threads)
4239 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4240 (let ((result threads))
4241 (while threads
4242 (when (stringp (caar threads))
4243 (setcdr (car threads)
4244 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4245 (setq threads (cdr threads)))
4246 result))
4248 (defun gnus-thread-loop-p (root thread)
4249 "Say whether ROOT is in THREAD."
4250 (let ((stack (list thread))
4251 (infloop 0)
4253 (while (setq thread (pop stack))
4254 (setq th (cdr thread))
4255 (while (and th
4256 (not (eq (caar th) root)))
4257 (pop th))
4258 (if th
4259 ;; We have found a loop.
4260 (let (ref-dep)
4261 (setcdr thread (delq (car th) (cdr thread)))
4262 (if (boundp (setq ref-dep (intern "none"
4263 gnus-newsgroup-dependencies)))
4264 (setcdr (symbol-value ref-dep)
4265 (nconc (cdr (symbol-value ref-dep))
4266 (list (car th))))
4267 (set ref-dep (list nil (car th))))
4268 (setq infloop 1
4269 stack nil))
4270 ;; Push all the subthreads onto the stack.
4271 (push (cdr thread) stack)))
4272 infloop))
4274 (defun gnus-make-threads ()
4275 "Go through the dependency hashtb and find the roots. Return all threads."
4276 (let (threads)
4277 (while (catch 'infloop
4278 (mapatoms
4279 (lambda (refs)
4280 ;; Deal with self-referencing References loops.
4281 (when (and (car (symbol-value refs))
4282 (not (zerop
4283 (apply
4285 (mapcar
4286 (lambda (thread)
4287 (gnus-thread-loop-p
4288 (car (symbol-value refs)) thread))
4289 (cdr (symbol-value refs)))))))
4290 (setq threads nil)
4291 (throw 'infloop t))
4292 (unless (car (symbol-value refs))
4293 ;; These threads do not refer back to any other
4294 ;; articles, so they're roots.
4295 (setq threads (append (cdr (symbol-value refs)) threads))))
4296 gnus-newsgroup-dependencies)))
4297 threads))
4299 ;; Build the thread tree.
4300 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4301 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4303 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4304 if it was already present.
4306 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4307 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4308 Message-IDs will be renamed to a unique Message-ID before being
4309 entered.
4311 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4312 (let* ((id (mail-header-id header))
4313 (id-dep (and id (intern id dependencies)))
4314 parent-id ref ref-dep ref-header replaced)
4315 ;; Enter this `header' in the `dependencies' table.
4316 (cond
4317 ((not id-dep)
4318 (setq header nil))
4319 ;; The first two cases do the normal part: enter a new `header'
4320 ;; in the `dependencies' table.
4321 ((not (boundp id-dep))
4322 (set id-dep (list header)))
4323 ((null (car (symbol-value id-dep)))
4324 (setcar (symbol-value id-dep) header))
4326 ;; From here the `header' was already present in the
4327 ;; `dependencies' table.
4328 (force-new
4329 ;; Overrides an existing entry;
4330 ;; just set the header part of the entry.
4331 (setcar (symbol-value id-dep) header)
4332 (setq replaced t))
4334 ;; Renames the existing `header' to a unique Message-ID.
4335 ((not gnus-summary-ignore-duplicates)
4336 ;; An article with this Message-ID has already been seen.
4337 ;; We rename the Message-ID.
4338 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4339 (list header))
4340 (mail-header-set-id header id))
4342 ;; The last case ignores an existing entry, except it adds any
4343 ;; additional Xrefs (in case the two articles came from different
4344 ;; servers.
4345 ;; Also sets `header' to nil meaning that the `dependencies'
4346 ;; table was *not* modified.
4348 (mail-header-set-xref
4349 (car (symbol-value id-dep))
4350 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4352 (or (mail-header-xref header) "")))
4353 (setq header nil)))
4355 (when (and header (not replaced))
4356 ;; First check that we are not creating a References loop.
4357 (setq parent-id (gnus-parent-id (mail-header-references header)))
4358 (setq ref parent-id)
4359 (while (and ref
4360 (setq ref-dep (intern-soft ref dependencies))
4361 (boundp ref-dep)
4362 (setq ref-header (car (symbol-value ref-dep))))
4363 (if (string= id ref)
4364 ;; Yuk! This is a reference loop. Make the article be a
4365 ;; root article.
4366 (progn
4367 (mail-header-set-references (car (symbol-value id-dep)) "none")
4368 (setq ref nil)
4369 (setq parent-id nil))
4370 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4371 (setq ref-dep (intern (or parent-id "none") dependencies))
4372 (if (boundp ref-dep)
4373 (setcdr (symbol-value ref-dep)
4374 (nconc (cdr (symbol-value ref-dep))
4375 (list (symbol-value id-dep))))
4376 (set ref-dep (list nil (symbol-value id-dep)))))
4377 header))
4379 (defun gnus-extract-message-id-from-in-reply-to (string)
4380 (if (string-match "<[^>]+>" string)
4381 (substring string (match-beginning 0) (match-end 0))
4382 nil))
4384 (defun gnus-build-sparse-threads ()
4385 (let ((headers gnus-newsgroup-headers)
4386 (mail-parse-charset gnus-newsgroup-charset)
4387 (gnus-summary-ignore-duplicates t)
4388 header references generation relations
4389 subject child end new-child date)
4390 ;; First we create an alist of generations/relations, where
4391 ;; generations is how much we trust the relation, and the relation
4392 ;; is parent/child.
4393 (gnus-message 7 "Making sparse threads...")
4394 (save-excursion
4395 (nnheader-set-temp-buffer " *gnus sparse threads*")
4396 (while (setq header (pop headers))
4397 (when (and (setq references (mail-header-references header))
4398 (not (string= references "")))
4399 (insert references)
4400 (setq child (mail-header-id header)
4401 subject (mail-header-subject header)
4402 date (mail-header-date header)
4403 generation 0)
4404 (while (search-backward ">" nil t)
4405 (setq end (1+ (point)))
4406 (when (search-backward "<" nil t)
4407 (setq new-child (buffer-substring (point) end))
4408 (push (list (incf generation)
4409 child (setq child new-child)
4410 subject date)
4411 relations)))
4412 (when child
4413 (push (list (1+ generation) child nil subject) relations))
4414 (erase-buffer)))
4415 (kill-buffer (current-buffer)))
4416 ;; Sort over trustworthiness.
4417 (dolist (relation (sort relations 'car-less-than-car))
4418 (when (gnus-dependencies-add-header
4419 (make-full-mail-header
4420 gnus-reffed-article-number
4421 (nth 3 relation) "" (or (nth 4 relation) "")
4422 (nth 1 relation)
4423 (or (nth 2 relation) "") 0 0 "")
4424 gnus-newsgroup-dependencies nil)
4425 (push gnus-reffed-article-number gnus-newsgroup-limit)
4426 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4427 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4428 gnus-newsgroup-reads)
4429 (decf gnus-reffed-article-number)))
4430 (gnus-message 7 "Making sparse threads...done")))
4432 (defun gnus-build-old-threads ()
4433 ;; Look at all the articles that refer back to old articles, and
4434 ;; fetch the headers for the articles that aren't there. This will
4435 ;; build complete threads - if the roots haven't been expired by the
4436 ;; server, that is.
4437 (let ((mail-parse-charset gnus-newsgroup-charset)
4438 id heads)
4439 (mapatoms
4440 (lambda (refs)
4441 (when (not (car (symbol-value refs)))
4442 (setq heads (cdr (symbol-value refs)))
4443 (while heads
4444 (if (memq (mail-header-number (caar heads))
4445 gnus-newsgroup-dormant)
4446 (setq heads (cdr heads))
4447 (setq id (symbol-name refs))
4448 (while (and (setq id (gnus-build-get-header id))
4449 (not (car (gnus-id-to-thread id)))))
4450 (setq heads nil)))))
4451 gnus-newsgroup-dependencies)))
4453 (defsubst gnus-remove-odd-characters (string)
4454 "Translate STRING into something that doesn't contain weird characters."
4455 (subst-char-in-string
4456 ?\r ?\-
4457 (subst-char-in-string ?\n ?\- string t) t))
4459 ;; This function has to be called with point after the article number
4460 ;; on the beginning of the line.
4461 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4462 (let ((eol (point-at-eol))
4463 (buffer (current-buffer))
4464 header references in-reply-to)
4466 ;; overview: [num subject from date id refs chars lines misc]
4467 (unwind-protect
4468 (let (x)
4469 (narrow-to-region (point) eol)
4470 (unless (eobp)
4471 (forward-char))
4473 (setq header
4474 (make-full-mail-header
4475 number ; number
4476 (condition-case () ; subject
4477 (gnus-remove-odd-characters
4478 (funcall gnus-decode-encoded-word-function
4479 (setq x (nnheader-nov-field))))
4480 (error x))
4481 (condition-case () ; from
4482 (gnus-remove-odd-characters
4483 (funcall gnus-decode-encoded-address-function
4484 (setq x (nnheader-nov-field))))
4485 (error x))
4486 (nnheader-nov-field) ; date
4487 (nnheader-nov-read-message-id number) ; id
4488 (setq references (nnheader-nov-field)) ; refs
4489 (nnheader-nov-read-integer) ; chars
4490 (nnheader-nov-read-integer) ; lines
4491 (unless (eobp)
4492 (if (looking-at "Xref: ")
4493 (goto-char (match-end 0)))
4494 (nnheader-nov-field)) ; Xref
4495 (nnheader-nov-parse-extra)))) ; extra
4497 (widen))
4499 (when (and (string= references "")
4500 (setq in-reply-to (mail-header-extra header))
4501 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4502 (mail-header-set-references
4503 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4505 (when gnus-alter-header-function
4506 (funcall gnus-alter-header-function header))
4507 (gnus-dependencies-add-header header dependencies force-new)))
4509 (defun gnus-build-get-header (id)
4510 "Look through the buffer of NOV lines and find the header to ID.
4511 Enter this line into the dependencies hash table, and return
4512 the id of the parent article (if any)."
4513 (let ((deps gnus-newsgroup-dependencies)
4514 found header)
4515 (prog1
4516 (with-current-buffer nntp-server-buffer
4517 (let ((case-fold-search nil))
4518 (goto-char (point-min))
4519 (while (and (not found)
4520 (search-forward id nil t))
4521 (beginning-of-line)
4522 (setq found (looking-at
4523 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4524 (regexp-quote id))))
4525 (or found (beginning-of-line 2)))
4526 (when found
4527 (beginning-of-line)
4528 (and
4529 (setq header (gnus-nov-parse-line
4530 (read (current-buffer)) deps))
4531 (gnus-parent-id (mail-header-references header))))))
4532 (when header
4533 (let ((number (mail-header-number header)))
4534 (push number gnus-newsgroup-limit)
4535 (push header gnus-newsgroup-headers)
4536 (if (memq number gnus-newsgroup-unselected)
4537 (progn
4538 (setq gnus-newsgroup-unreads
4539 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4540 number))
4541 (setq gnus-newsgroup-unselected
4542 (delq number gnus-newsgroup-unselected)))
4543 (push number gnus-newsgroup-ancient)))))))
4545 (defun gnus-build-all-threads ()
4546 "Read all the headers."
4547 (let ((gnus-summary-ignore-duplicates t)
4548 (mail-parse-charset gnus-newsgroup-charset)
4549 (dependencies gnus-newsgroup-dependencies)
4550 header article)
4551 (with-current-buffer nntp-server-buffer
4552 (let ((case-fold-search nil))
4553 (goto-char (point-min))
4554 (while (not (eobp))
4555 (ignore-errors
4556 (setq article (read (current-buffer))
4557 header (gnus-nov-parse-line article dependencies t)))
4558 (when header
4559 (with-current-buffer gnus-summary-buffer
4560 (push header gnus-newsgroup-headers)
4561 (if (memq (setq article (mail-header-number header))
4562 gnus-newsgroup-unselected)
4563 (progn
4564 (setq gnus-newsgroup-unreads
4565 (gnus-add-to-sorted-list
4566 gnus-newsgroup-unreads article))
4567 (setq gnus-newsgroup-unselected
4568 (delq article gnus-newsgroup-unselected)))
4569 (push article gnus-newsgroup-ancient)))
4570 (forward-line 1)))))))
4572 (defun gnus-summary-update-article-line (article header)
4573 "Update the line for ARTICLE using HEADER."
4574 (let* ((id (mail-header-id header))
4575 (thread (gnus-id-to-thread id)))
4576 (unless thread
4577 (error "Article in no thread"))
4578 ;; Update the thread.
4579 (setcar thread header)
4580 (gnus-summary-goto-subject article)
4581 (let* ((datal (gnus-data-find-list article))
4582 (data (car datal))
4583 (inhibit-read-only t)
4584 (level (gnus-summary-thread-level)))
4585 (gnus-delete-line)
4586 (let ((inserted (- (point)
4587 (progn
4588 (gnus-summary-insert-line
4589 header level nil
4590 (memq article gnus-newsgroup-undownloaded)
4591 (gnus-article-mark article)
4592 (memq article gnus-newsgroup-replied)
4593 (memq article gnus-newsgroup-expirable)
4594 ;; Only insert the Subject string when it's different
4595 ;; from the previous Subject string.
4596 (if (and
4597 gnus-show-threads
4598 (gnus-subject-equal
4599 (condition-case ()
4600 (mail-header-subject
4601 (gnus-data-header
4602 (cadr
4603 (gnus-data-find-list
4604 article
4605 (gnus-data-list t)))))
4606 ;; Error on the side of excessive subjects.
4607 (error ""))
4608 (mail-header-subject header)))
4610 (mail-header-subject header))
4611 nil (cdr (assq article gnus-newsgroup-scored))
4612 (memq article gnus-newsgroup-processable))
4613 (point)))))
4614 (when (cdr datal)
4615 (gnus-data-update-list
4616 (cdr datal)
4617 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4619 (defun gnus-summary-update-article (article &optional iheader)
4620 "Update ARTICLE in the summary buffer."
4621 (set-buffer gnus-summary-buffer)
4622 (let* ((header (gnus-summary-article-header article))
4623 (id (mail-header-id header))
4624 (data (gnus-data-find article))
4625 (thread (gnus-id-to-thread id))
4626 (references (mail-header-references header))
4627 (parent
4628 (gnus-id-to-thread
4629 (or (gnus-parent-id
4630 (when (and references
4631 (not (equal "" references)))
4632 references))
4633 "none")))
4634 (inhibit-read-only t)
4635 (old (car thread)))
4636 (when thread
4637 (unless iheader
4638 (setcar thread nil)
4639 (when parent
4640 (delq thread parent)))
4641 (if (gnus-summary-insert-subject id header)
4642 ;; Set the (possibly) new article number in the data structure.
4643 (gnus-data-set-number data (gnus-id-to-article id))
4644 (setcar thread old)
4645 nil))))
4647 (defun gnus-rebuild-thread (id &optional line)
4648 "Rebuild the thread containing ID.
4649 If LINE, insert the rebuilt thread starting on line LINE."
4650 (let ((inhibit-read-only t)
4651 old-pos current thread data)
4652 (if (not gnus-show-threads)
4653 (setq thread (list (car (gnus-id-to-thread id))))
4654 ;; Get the thread this article is part of.
4655 (setq thread (gnus-remove-thread id)))
4656 (setq old-pos (point-at-bol))
4657 (setq current (save-excursion
4658 (and (re-search-backward "[\r\n]" nil t)
4659 (gnus-summary-article-number))))
4660 ;; If this is a gathered thread, we have to go some re-gathering.
4661 (when (stringp (car thread))
4662 (let ((subject (car thread))
4663 roots thr)
4664 (setq thread (cdr thread))
4665 (while thread
4666 (unless (memq (setq thr (gnus-id-to-thread
4667 (gnus-root-id
4668 (mail-header-id (caar thread)))))
4669 roots)
4670 (push thr roots))
4671 (setq thread (cdr thread)))
4672 ;; We now have all (unique) roots.
4673 (if (= (length roots) 1)
4674 ;; All the loose roots are now one solid root.
4675 (setq thread (car roots))
4676 (setq thread (cons subject (gnus-sort-threads roots))))))
4677 (let (threads)
4678 ;; We then insert this thread into the summary buffer.
4679 (when line
4680 (goto-char (point-min))
4681 (forward-line (1- line)))
4682 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4683 (if gnus-show-threads
4684 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4685 (gnus-summary-prepare-unthreaded thread))
4686 (setq data (nreverse gnus-newsgroup-data))
4687 (setq threads gnus-newsgroup-threads))
4688 ;; We splice the new data into the data structure.
4689 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4690 ;;!!! then we want to insert at the beginning of the buffer.
4691 ;;!!! That happens to be true with Gnus now, but that may
4692 ;;!!! change in the future. Perhaps.
4693 (gnus-data-enter-list
4694 (if line nil current) data (- (point) old-pos))
4695 (setq gnus-newsgroup-threads
4696 (nconc threads gnus-newsgroup-threads))
4697 (gnus-data-compute-positions))))
4699 (defun gnus-number-to-header (number)
4700 "Return the header for article NUMBER."
4701 (let ((headers gnus-newsgroup-headers))
4702 (while (and headers
4703 (not (= number (mail-header-number (car headers)))))
4704 (pop headers))
4705 (when headers
4706 (car headers))))
4708 (defun gnus-parent-headers (in-headers &optional generation)
4709 "Return the headers of the GENERATIONth parent of HEADERS."
4710 (unless generation
4711 (setq generation 1))
4712 (let ((parent t)
4713 (headers in-headers)
4714 references)
4715 (while (and parent
4716 (not (zerop generation))
4717 (setq references (mail-header-references headers)))
4718 (setq headers (if (and references
4719 (setq parent (gnus-parent-id references)))
4720 (car (gnus-id-to-thread parent))
4721 nil))
4722 (decf generation))
4723 (and (not (eq headers in-headers))
4724 headers)))
4726 (defun gnus-id-to-thread (id)
4727 "Return the (sub-)thread where ID appears."
4728 (gnus-gethash id gnus-newsgroup-dependencies))
4730 (defun gnus-id-to-article (id)
4731 "Return the article number of ID."
4732 (let ((thread (gnus-id-to-thread id)))
4733 (when (and thread
4734 (car thread))
4735 (mail-header-number (car thread)))))
4737 (defun gnus-id-to-header (id)
4738 "Return the article headers of ID."
4739 (car (gnus-id-to-thread id)))
4741 (defun gnus-article-displayed-root-p (article)
4742 "Say whether ARTICLE is a root(ish) article."
4743 (let ((level (gnus-summary-thread-level article))
4744 (refs (mail-header-references (gnus-summary-article-header article)))
4745 particle)
4746 (cond
4747 ((null level) nil)
4748 ((zerop level) t)
4749 ((null refs) t)
4750 ((null (gnus-parent-id refs)) t)
4751 ((and (= 1 level)
4752 (null (setq particle (gnus-id-to-article
4753 (gnus-parent-id refs))))
4754 (null (gnus-summary-thread-level particle)))))))
4756 (defun gnus-root-id (id)
4757 "Return the id of the root of the thread where ID appears."
4758 (let (last-id prev)
4759 (while (and id (setq prev (car (gnus-id-to-thread id))))
4760 (setq last-id id
4761 id (gnus-parent-id (mail-header-references prev))))
4762 last-id))
4764 (defun gnus-articles-in-thread (thread)
4765 "Return the list of articles in THREAD."
4766 (cons (mail-header-number (car thread))
4767 (mapcan 'gnus-articles-in-thread (cdr thread))))
4769 (defun gnus-remove-thread (id &optional dont-remove)
4770 "Remove the thread that has ID in it."
4771 (let (headers thread last-id)
4772 ;; First go up in this thread until we find the root.
4773 (setq last-id (gnus-root-id id)
4774 headers (message-flatten-list (gnus-id-to-thread last-id)))
4775 ;; We have now found the real root of this thread. It might have
4776 ;; been gathered into some loose thread, so we have to search
4777 ;; through the threads to find the thread we wanted.
4778 (let ((threads gnus-newsgroup-threads)
4779 sub)
4780 (while threads
4781 (setq sub (car threads))
4782 (if (stringp (car sub))
4783 ;; This is a gathered thread, so we look at the roots
4784 ;; below it to find whether this article is in this
4785 ;; gathered root.
4786 (progn
4787 (setq sub (cdr sub))
4788 (while sub
4789 (when (member (caar sub) headers)
4790 (setq thread (car threads)
4791 threads nil
4792 sub nil))
4793 (setq sub (cdr sub))))
4794 ;; It's an ordinary thread, so we check it.
4795 (when (eq (car sub) (car headers))
4796 (setq thread sub
4797 threads nil)))
4798 (setq threads (cdr threads)))
4799 ;; If this article is in no thread, then it's a root.
4800 (if thread
4801 (unless dont-remove
4802 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4803 (setq thread (gnus-id-to-thread last-id)))
4804 (when thread
4805 (prog1
4806 thread ; We return this thread.
4807 (unless dont-remove
4808 (if (stringp (car thread))
4809 (progn
4810 ;; If we use dummy roots, then we have to remove the
4811 ;; dummy root as well.
4812 (when (eq gnus-summary-make-false-root 'dummy)
4813 ;; We go to the dummy root by going to
4814 ;; the first sub-"thread", and then one line up.
4815 (gnus-summary-goto-article
4816 (mail-header-number (caadr thread)))
4817 (forward-line -1)
4818 (gnus-delete-line)
4819 (gnus-data-compute-positions))
4820 (setq thread (cdr thread))
4821 (while thread
4822 (gnus-remove-thread-1 (car thread))
4823 (setq thread (cdr thread))))
4824 (gnus-remove-thread-1 thread))))))))
4826 (defun gnus-remove-thread-1 (thread)
4827 "Remove the thread THREAD recursively."
4828 (let ((number (mail-header-number (pop thread)))
4830 (setq thread (reverse thread))
4831 (while thread
4832 (gnus-remove-thread-1 (pop thread)))
4833 (when (setq d (gnus-data-find number))
4834 (goto-char (gnus-data-pos d))
4835 (gnus-summary-show-thread)
4836 (gnus-data-remove
4837 number
4838 (- (point-at-bol)
4839 (prog1
4840 (1+ (point-at-eol))
4841 (gnus-delete-line)))))))
4843 (defun gnus-sort-threads-recursive (threads func)
4844 ;; Responsible for sorting the root articles of threads.
4845 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4846 'gnus-thread-sort-functions)
4847 func
4848 (gnus-make-sort-function
4849 gnus-subthread-sort-functions))))
4850 (sort (mapcar (lambda (thread)
4851 (cons (car thread)
4852 (and (cdr thread)
4853 (gnus-sort-subthreads-recursive
4854 (cdr thread) subthread-sort-func))))
4855 threads) func)))
4857 (defun gnus-sort-subthreads-recursive (threads func)
4858 ;; Responsible for sorting subthreads.
4859 (sort (mapcar (lambda (thread)
4860 (cons (car thread)
4861 (and (cdr thread)
4862 (gnus-sort-subthreads-recursive (cdr thread) func))))
4863 threads) func))
4865 (defun gnus-sort-threads-loop (threads func)
4866 (let* ((superthread (cons nil threads))
4867 (stack (list (cons superthread threads)))
4868 remaining-threads thread)
4869 (while stack
4870 (setq remaining-threads (cdr (car stack)))
4871 (if remaining-threads
4872 (progn (setq thread (car remaining-threads))
4873 (setcdr (car stack) (cdr remaining-threads))
4874 (if (cdr thread)
4875 (push (cons thread (cdr thread)) stack)))
4876 (setq thread (caar stack))
4877 (setcdr thread (sort (cdr thread) func))
4878 (pop stack)))
4879 (cdr superthread)))
4881 (defun gnus-sort-threads (threads)
4882 "Sort THREADS."
4883 (if (not gnus-thread-sort-functions)
4884 threads
4885 (gnus-message 8 "Sorting threads...")
4886 (prog1
4887 (condition-case nil
4888 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4889 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4890 (gnus-sort-threads-recursive threads sort-func))
4891 ;; Even after binding max-lisp-eval-depth, the recursive
4892 ;; sorter might fail for very long threads. In that case,
4893 ;; try using a (less well-tested) non-recursive sorter.
4894 (error (gnus-message 9 "Sorting threads with loop...")
4895 (gnus-sort-threads-loop
4896 threads (gnus-make-sort-function
4897 gnus-thread-sort-functions))))
4898 (gnus-message 8 "Sorting threads...done"))))
4900 (defun gnus-sort-articles (articles)
4901 "Sort ARTICLES."
4902 (when gnus-article-sort-functions
4903 (gnus-message 7 "Sorting articles...")
4904 (prog1
4905 (setq gnus-newsgroup-headers
4906 (sort articles (gnus-make-sort-function
4907 gnus-article-sort-functions)))
4908 (gnus-message 7 "Sorting articles...done"))))
4910 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4911 (defmacro gnus-thread-header (thread)
4912 "Return header of first article in THREAD.
4913 Note that THREAD must never, ever be anything else than a variable -
4914 using some other form will lead to serious barfage."
4915 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4916 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4917 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4918 (vector thread) 2))
4920 (defsubst gnus-article-sort-by-number (h1 h2)
4921 "Sort articles by article number."
4922 (< (mail-header-number h1)
4923 (mail-header-number h2)))
4925 (defun gnus-thread-sort-by-number (h1 h2)
4926 "Sort threads by root article number."
4927 (gnus-article-sort-by-number
4928 (gnus-thread-header h1) (gnus-thread-header h2)))
4930 (defsubst gnus-article-sort-by-random (h1 h2)
4931 "Sort articles randomly."
4932 (zerop (random 2)))
4934 (defun gnus-thread-sort-by-random (h1 h2)
4935 "Sort threads randomly."
4936 (gnus-article-sort-by-random
4937 (gnus-thread-header h1) (gnus-thread-header h2)))
4939 (defsubst gnus-article-sort-by-lines (h1 h2)
4940 "Sort articles by article Lines header."
4941 (< (mail-header-lines h1)
4942 (mail-header-lines h2)))
4944 (defun gnus-thread-sort-by-lines (h1 h2)
4945 "Sort threads by root article Lines header."
4946 (gnus-article-sort-by-lines
4947 (gnus-thread-header h1) (gnus-thread-header h2)))
4949 (defsubst gnus-article-sort-by-chars (h1 h2)
4950 "Sort articles by octet length."
4951 (< (mail-header-chars h1)
4952 (mail-header-chars h2)))
4954 (defun gnus-thread-sort-by-chars (h1 h2)
4955 "Sort threads by root article octet length."
4956 (gnus-article-sort-by-chars
4957 (gnus-thread-header h1) (gnus-thread-header h2)))
4959 (defsubst gnus-article-sort-by-marks (h1 h2)
4960 "Sort articles by octet length."
4961 (< (gnus-article-mark (mail-header-number h1))
4962 (gnus-article-mark (mail-header-number h2))))
4964 (defun gnus-thread-sort-by-marks (h1 h2)
4965 "Sort threads by root article octet length."
4966 (gnus-article-sort-by-marks
4967 (gnus-thread-header h1) (gnus-thread-header h2)))
4969 (defsubst gnus-article-sort-by-author (h1 h2)
4970 "Sort articles by root author."
4971 (gnus-string<
4972 (let ((extract (funcall
4973 gnus-extract-address-components
4974 (mail-header-from h1))))
4975 (or (car extract) (cadr extract) ""))
4976 (let ((extract (funcall
4977 gnus-extract-address-components
4978 (mail-header-from h2))))
4979 (or (car extract) (cadr extract) ""))))
4981 (defun gnus-thread-sort-by-author (h1 h2)
4982 "Sort threads by root author."
4983 (gnus-article-sort-by-author
4984 (gnus-thread-header h1) (gnus-thread-header h2)))
4986 (defsubst gnus-article-sort-by-recipient (h1 h2)
4987 "Sort articles by recipient."
4988 (gnus-string<
4989 (let ((extract (funcall
4990 gnus-extract-address-components
4991 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4992 (or (car extract) (cadr extract)))
4993 (let ((extract (funcall
4994 gnus-extract-address-components
4995 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4996 (or (car extract) (cadr extract)))))
4998 (defun gnus-thread-sort-by-recipient (h1 h2)
4999 "Sort threads by root recipient."
5000 (gnus-article-sort-by-recipient
5001 (gnus-thread-header h1) (gnus-thread-header h2)))
5003 (defsubst gnus-article-sort-by-subject (h1 h2)
5004 "Sort articles by root subject."
5005 (gnus-string<
5006 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5007 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5009 (defun gnus-thread-sort-by-subject (h1 h2)
5010 "Sort threads by root subject."
5011 (gnus-article-sort-by-subject
5012 (gnus-thread-header h1) (gnus-thread-header h2)))
5014 (defsubst gnus-article-sort-by-date (h1 h2)
5015 "Sort articles by root article date."
5016 (time-less-p
5017 (gnus-date-get-time (mail-header-date h1))
5018 (gnus-date-get-time (mail-header-date h2))))
5020 (defun gnus-thread-sort-by-date (h1 h2)
5021 "Sort threads by root article date."
5022 (gnus-article-sort-by-date
5023 (gnus-thread-header h1) (gnus-thread-header h2)))
5025 (defsubst gnus-article-sort-by-score (h1 h2)
5026 "Sort articles by root article score.
5027 Unscored articles will be counted as having a score of zero."
5028 (> (or (cdr (assq (mail-header-number h1)
5029 gnus-newsgroup-scored))
5030 gnus-summary-default-score 0)
5031 (or (cdr (assq (mail-header-number h2)
5032 gnus-newsgroup-scored))
5033 gnus-summary-default-score 0)))
5035 (defun gnus-thread-sort-by-score (h1 h2)
5036 "Sort threads by root article score."
5037 (gnus-article-sort-by-score
5038 (gnus-thread-header h1) (gnus-thread-header h2)))
5040 (defun gnus-thread-sort-by-total-score (h1 h2)
5041 "Sort threads by the sum of all scores in the thread.
5042 Unscored articles will be counted as having a score of zero."
5043 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5045 (defun gnus-thread-total-score (thread)
5046 ;; This function find the total score of THREAD.
5047 (cond
5048 ((null thread)
5050 ((consp thread)
5051 (if (stringp (car thread))
5052 (apply gnus-thread-score-function 0
5053 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5054 (gnus-thread-total-score-1 thread)))
5056 (gnus-thread-total-score-1 (list thread)))))
5058 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5059 "Sort articles by number."
5060 (gnus-article-sort-by-number h1 h2))
5062 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5063 "Sort threads such that the thread with the most recently arrived article comes first."
5064 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5066 (defun gnus-thread-highest-number (thread)
5067 "Return the highest article number in THREAD."
5068 (apply 'max (mapcar (lambda (header)
5069 (mail-header-number header))
5070 (message-flatten-list thread))))
5072 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5073 "Sort articles by number."
5074 (gnus-article-sort-by-date h1 h2))
5076 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5077 "Sort threads such that the thread with the most recently dated article comes first."
5078 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5080 ; Since this is called not only to sort the top-level threads, but
5081 ; also in recursive sorts to order the articles within a thread, each
5082 ; article will be processed many times. Thus it speeds things up
5083 ; quite a bit to use gnus-date-get-time, which caches the time value.
5084 (defun gnus-thread-latest-date (thread)
5085 "Return the highest article date in THREAD."
5086 (apply 'max
5087 (mapcar (lambda (header) (float-time
5088 (gnus-date-get-time
5089 (mail-header-date header))))
5090 (message-flatten-list thread))))
5092 (defun gnus-thread-total-score-1 (root)
5093 ;; This function find the total score of the thread below ROOT.
5094 (setq root (car root))
5095 (apply gnus-thread-score-function
5096 (or (append
5097 (mapcar 'gnus-thread-total-score
5098 (cdr (gnus-id-to-thread (mail-header-id root))))
5099 (when (> (mail-header-number root) 0)
5100 (list (or (cdr (assq (mail-header-number root)
5101 gnus-newsgroup-scored))
5102 gnus-summary-default-score 0))))
5103 (list gnus-summary-default-score)
5104 '(0))))
5106 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5107 (defvar gnus-tmp-prev-subject nil)
5108 (defvar gnus-tmp-false-parent nil)
5109 (defvar gnus-tmp-root-expunged nil)
5110 (defvar gnus-tmp-dummy-line nil)
5112 (defun gnus-extra-header (type &optional header)
5113 "Return the extra header of TYPE."
5114 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5115 ""))
5117 (defvar gnus-tmp-thread-tree-header-string "")
5119 (defcustom gnus-sum-thread-tree-root "> "
5120 "With %B spec, used for the root of a thread.
5121 If nil, use subject instead."
5122 :version "22.1"
5123 :type '(radio (const :format "%v " nil) string)
5124 :group 'gnus-thread)
5126 (defcustom gnus-sum-thread-tree-false-root "> "
5127 "With %B spec, used for a false root of a thread.
5128 If nil, use subject instead."
5129 :version "22.1"
5130 :type '(radio (const :format "%v " nil) string)
5131 :group 'gnus-thread)
5133 (defcustom gnus-sum-thread-tree-single-indent ""
5134 "With %B spec, used for a thread with just one message.
5135 If nil, use subject instead."
5136 :version "22.1"
5137 :type '(radio (const :format "%v " nil) string)
5138 :group 'gnus-thread)
5140 (defcustom gnus-sum-thread-tree-vertical "| "
5141 "With %B spec, used for drawing a vertical line."
5142 :version "22.1"
5143 :type 'string
5144 :group 'gnus-thread)
5146 (defcustom gnus-sum-thread-tree-indent " "
5147 "With %B spec, used for indenting."
5148 :version "22.1"
5149 :type 'string
5150 :group 'gnus-thread)
5152 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5153 "With %B spec, used for a leaf with brothers."
5154 :version "22.1"
5155 :type 'string
5156 :group 'gnus-thread)
5158 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5159 "With %B spec, used for a leaf without brothers."
5160 :version "22.1"
5161 :type 'string
5162 :group 'gnus-thread)
5164 (defcustom gnus-summary-display-while-building nil
5165 "If non-nil, show and update the summary buffer as it's being built.
5166 If the value is t, update the buffer after every line is inserted. If
5167 the value is an integer (N), update the display every N lines."
5168 :version "22.1"
5169 :group 'gnus-thread
5170 :type '(choice (const :tag "off" nil)
5171 number
5172 (const :tag "frequently" t)))
5174 (defun gnus-summary-prepare-threads (threads)
5175 "Prepare summary buffer from THREADS and indentation LEVEL.
5176 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5177 or a straight list of headers."
5178 (gnus-message 7 "Generating summary...")
5180 (setq gnus-newsgroup-threads threads)
5181 (beginning-of-line)
5183 (let ((gnus-tmp-level 0)
5184 (default-score (or gnus-summary-default-score 0))
5185 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5186 (building-line-count gnus-summary-display-while-building)
5187 (building-count (integerp gnus-summary-display-while-building))
5188 thread number subject stack state gnus-tmp-gathered beg-match
5189 new-roots gnus-tmp-new-adopts thread-end simp-subject
5190 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5191 gnus-tmp-replied gnus-tmp-subject-or-nil
5192 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5193 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5194 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5195 tree-stack)
5197 (setq gnus-tmp-prev-subject nil
5198 gnus-tmp-thread-tree-header-string "")
5200 (if (vectorp (car threads))
5201 ;; If this is a straight (sic) list of headers, then a
5202 ;; threaded summary display isn't required, so we just create
5203 ;; an unthreaded one.
5204 (gnus-summary-prepare-unthreaded threads)
5206 ;; Do the threaded display.
5208 (if gnus-summary-display-while-building
5209 (switch-to-buffer (buffer-name)))
5210 (while (or threads stack gnus-tmp-new-adopts new-roots)
5212 (if (and (= gnus-tmp-level 0)
5213 (or (not stack)
5214 (= (caar stack) 0))
5215 (not gnus-tmp-false-parent)
5216 (or gnus-tmp-new-adopts new-roots))
5217 (if gnus-tmp-new-adopts
5218 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5219 thread (list (car gnus-tmp-new-adopts))
5220 gnus-tmp-header (caar thread)
5221 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5222 (when new-roots
5223 (setq thread (list (car new-roots))
5224 gnus-tmp-header (caar thread)
5225 new-roots (cdr new-roots))))
5227 (if threads
5228 ;; If there are some threads, we do them before the
5229 ;; threads on the stack.
5230 (setq thread threads
5231 gnus-tmp-header (caar thread))
5232 ;; There were no current threads, so we pop something off
5233 ;; the stack.
5234 (setq state (car stack)
5235 gnus-tmp-level (car state)
5236 tree-stack (cadr state)
5237 thread (caddr state)
5238 stack (cdr stack)
5239 gnus-tmp-header (caar thread))))
5241 (setq gnus-tmp-false-parent nil)
5242 (setq gnus-tmp-root-expunged nil)
5243 (setq thread-end nil)
5245 (if (stringp gnus-tmp-header)
5246 ;; The header is a dummy root.
5247 (cond
5248 ((eq gnus-summary-make-false-root 'adopt)
5249 ;; We let the first article adopt the rest.
5250 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5251 (cddar thread)))
5252 (setq gnus-tmp-gathered
5253 (nconc (mapcar
5254 (lambda (h) (mail-header-number (car h)))
5255 (cddar thread))
5256 gnus-tmp-gathered))
5257 (setq thread (cons (list (caar thread)
5258 (cadar thread))
5259 (cdr thread)))
5260 (setq gnus-tmp-level -1
5261 gnus-tmp-false-parent t))
5262 ((eq gnus-summary-make-false-root 'empty)
5263 ;; We print adopted articles with empty subject fields.
5264 (setq gnus-tmp-gathered
5265 (nconc (mapcar
5266 (lambda (h) (mail-header-number (car h)))
5267 (cddar thread))
5268 gnus-tmp-gathered))
5269 (setq gnus-tmp-level -1))
5270 ((eq gnus-summary-make-false-root 'dummy)
5271 ;; We remember that we probably want to output a dummy
5272 ;; root.
5273 (setq gnus-tmp-dummy-line gnus-tmp-header)
5274 (setq gnus-tmp-prev-subject gnus-tmp-header))
5276 ;; We do not make a root for the gathered
5277 ;; sub-threads at all.
5278 (setq gnus-tmp-level -1)))
5280 (setq number (mail-header-number gnus-tmp-header)
5281 subject (mail-header-subject gnus-tmp-header)
5282 simp-subject (gnus-simplify-subject-fully subject))
5284 (cond
5285 ;; If the thread has changed subject, we might want to make
5286 ;; this subthread into a root.
5287 ((and (null gnus-thread-ignore-subject)
5288 (not (zerop gnus-tmp-level))
5289 gnus-tmp-prev-subject
5290 (not (string= gnus-tmp-prev-subject simp-subject)))
5291 (setq new-roots (nconc new-roots (list (car thread)))
5292 thread-end t
5293 gnus-tmp-header nil))
5294 ;; If the article lies outside the current limit,
5295 ;; then we do not display it.
5296 ((not (memq number gnus-newsgroup-limit))
5297 (setq gnus-tmp-gathered
5298 (nconc (mapcar
5299 (lambda (h) (mail-header-number (car h)))
5300 (cdar thread))
5301 gnus-tmp-gathered))
5302 (setq gnus-tmp-new-adopts (if (cdar thread)
5303 (append gnus-tmp-new-adopts
5304 (cdar thread))
5305 gnus-tmp-new-adopts)
5306 thread-end t
5307 gnus-tmp-header nil)
5308 (when (zerop gnus-tmp-level)
5309 (setq gnus-tmp-root-expunged t)))
5310 ;; Perhaps this article is to be marked as read?
5311 ((and gnus-summary-mark-below
5312 (< (or (cdr (assq number gnus-newsgroup-scored))
5313 default-score)
5314 gnus-summary-mark-below)
5315 ;; Don't touch sparse articles.
5316 (not (gnus-summary-article-sparse-p number))
5317 (not (gnus-summary-article-ancient-p number)))
5318 (setq gnus-newsgroup-unreads
5319 (delq number gnus-newsgroup-unreads))
5320 (if gnus-newsgroup-auto-expire
5321 (setq gnus-newsgroup-expirable
5322 (gnus-add-to-sorted-list
5323 gnus-newsgroup-expirable number))
5324 (push (cons number gnus-low-score-mark)
5325 gnus-newsgroup-reads))))
5327 (when gnus-tmp-header
5328 ;; We may have an old dummy line to output before this
5329 ;; article.
5330 (when (and gnus-tmp-dummy-line
5331 (gnus-subject-equal
5332 gnus-tmp-dummy-line
5333 (mail-header-subject gnus-tmp-header)))
5334 (gnus-summary-insert-dummy-line
5335 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5336 (setq gnus-tmp-dummy-line nil))
5338 ;; Compute the mark.
5339 (setq gnus-tmp-unread (gnus-article-mark number))
5341 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5342 gnus-tmp-header gnus-tmp-level)
5343 gnus-newsgroup-data)
5345 ;; Actually insert the line.
5346 (setq
5347 gnus-tmp-subject-or-nil
5348 (cond
5349 ((and gnus-thread-ignore-subject
5350 gnus-tmp-prev-subject
5351 (not (string= gnus-tmp-prev-subject simp-subject)))
5352 subject)
5353 ((zerop gnus-tmp-level)
5354 (if (and (eq gnus-summary-make-false-root 'empty)
5355 (memq number gnus-tmp-gathered)
5356 gnus-tmp-prev-subject
5357 (string= gnus-tmp-prev-subject simp-subject))
5358 gnus-summary-same-subject
5359 subject))
5360 (t gnus-summary-same-subject)))
5361 (if (and (eq gnus-summary-make-false-root 'adopt)
5362 (= gnus-tmp-level 1)
5363 (memq number gnus-tmp-gathered))
5364 (setq gnus-tmp-opening-bracket ?\<
5365 gnus-tmp-closing-bracket ?\>)
5366 (setq gnus-tmp-opening-bracket ?\[
5367 gnus-tmp-closing-bracket ?\]))
5368 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5369 (gnus-make-thread-indent-array
5370 (max (* 2 (length gnus-thread-indent-array))
5371 gnus-tmp-level)))
5372 (setq
5373 gnus-tmp-indentation
5374 (aref gnus-thread-indent-array gnus-tmp-level)
5375 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5376 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5377 gnus-summary-default-score 0)
5378 gnus-tmp-score-char
5379 (if (or (null gnus-summary-default-score)
5380 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5381 gnus-summary-zcore-fuzz))
5382 ? ;Whitespace
5383 (if (< gnus-tmp-score gnus-summary-default-score)
5384 gnus-score-below-mark gnus-score-over-mark))
5385 gnus-tmp-replied
5386 (cond ((memq number gnus-newsgroup-processable)
5387 gnus-process-mark)
5388 ((memq number gnus-newsgroup-cached)
5389 gnus-cached-mark)
5390 ((memq number gnus-newsgroup-replied)
5391 gnus-replied-mark)
5392 ((memq number gnus-newsgroup-forwarded)
5393 gnus-forwarded-mark)
5394 ((memq number gnus-newsgroup-saved)
5395 gnus-saved-mark)
5396 ((memq number gnus-newsgroup-unseen)
5397 gnus-unseen-mark)
5398 (t gnus-no-mark))
5399 gnus-tmp-downloaded
5400 (cond ((memq number gnus-newsgroup-undownloaded)
5401 gnus-undownloaded-mark)
5402 (gnus-newsgroup-agentized
5403 gnus-downloaded-mark)
5405 gnus-no-mark))
5406 gnus-tmp-from (mail-header-from gnus-tmp-header)
5407 gnus-tmp-name
5408 (cond
5409 ((string-match "<[^>]+> *$" gnus-tmp-from)
5410 (setq beg-match (match-beginning 0))
5411 (or (and (string-match "^\".+\"" gnus-tmp-from)
5412 (substring gnus-tmp-from 1 (1- (match-end 0))))
5413 (substring gnus-tmp-from 0 beg-match)))
5414 ((string-match "(.+)" gnus-tmp-from)
5415 (substring gnus-tmp-from
5416 (1+ (match-beginning 0)) (1- (match-end 0))))
5417 (t gnus-tmp-from))
5419 ;; Do the %B string
5420 gnus-tmp-thread-tree-header-string
5421 (cond
5422 ((not gnus-show-threads) "")
5423 ((zerop gnus-tmp-level)
5424 (cond ((cdar thread)
5425 (or gnus-sum-thread-tree-root subject))
5426 (gnus-tmp-new-adopts
5427 (or gnus-sum-thread-tree-false-root subject))
5429 (or gnus-sum-thread-tree-single-indent subject))))
5431 (concat (apply 'concat
5432 (mapcar (lambda (item)
5433 (if (= item 1)
5434 gnus-sum-thread-tree-vertical
5435 gnus-sum-thread-tree-indent))
5436 (cdr (reverse tree-stack))))
5437 (if (nth 1 thread)
5438 gnus-sum-thread-tree-leaf-with-other
5439 gnus-sum-thread-tree-single-leaf)))))
5440 (when (string= gnus-tmp-name "")
5441 (setq gnus-tmp-name gnus-tmp-from))
5442 (unless (numberp gnus-tmp-lines)
5443 (setq gnus-tmp-lines -1))
5444 (if (= gnus-tmp-lines -1)
5445 (setq gnus-tmp-lines "?")
5446 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5447 (put-text-property
5448 (point)
5449 (progn (eval gnus-summary-line-format-spec) (point))
5450 'gnus-number number)
5451 (when gnus-visual-p
5452 (forward-line -1)
5453 (gnus-summary-highlight-line)
5454 (when gnus-summary-update-hook
5455 (gnus-run-hooks 'gnus-summary-update-hook))
5456 (forward-line 1))
5458 (setq gnus-tmp-prev-subject simp-subject)))
5460 (when (nth 1 thread)
5461 (push (list (max 0 gnus-tmp-level)
5462 (copy-sequence tree-stack)
5463 (nthcdr 1 thread))
5464 stack))
5465 (push (if (nth 1 thread) 1 0) tree-stack)
5466 (incf gnus-tmp-level)
5467 (setq threads (if thread-end nil (cdar thread)))
5468 (if gnus-summary-display-while-building
5469 (if building-count
5470 (progn
5471 ;; use a set frequency
5472 (setq building-line-count (1- building-line-count))
5473 (when (= building-line-count 0)
5474 (sit-for 0)
5475 (setq building-line-count
5476 gnus-summary-display-while-building)))
5477 ;; always
5478 (sit-for 0)))
5479 (unless threads
5480 (setq gnus-tmp-level 0)))))
5481 (gnus-message 7 "Generating summary...done"))
5483 (defun gnus-summary-prepare-unthreaded (headers)
5484 "Generate an unthreaded summary buffer based on HEADERS."
5485 (let (header number mark)
5487 (beginning-of-line)
5489 (while headers
5490 ;; We may have to root out some bad articles...
5491 (when (memq (setq number (mail-header-number
5492 (setq header (pop headers))))
5493 gnus-newsgroup-limit)
5494 ;; Mark article as read when it has a low score.
5495 (when (and gnus-summary-mark-below
5496 (< (or (cdr (assq number gnus-newsgroup-scored))
5497 gnus-summary-default-score 0)
5498 gnus-summary-mark-below)
5499 (not (gnus-summary-article-ancient-p number)))
5500 (setq gnus-newsgroup-unreads
5501 (delq number gnus-newsgroup-unreads))
5502 (if gnus-newsgroup-auto-expire
5503 (push number gnus-newsgroup-expirable)
5504 (push (cons number gnus-low-score-mark)
5505 gnus-newsgroup-reads)))
5507 (setq mark (gnus-article-mark number))
5508 (push (gnus-data-make number mark (1+ (point)) header 0)
5509 gnus-newsgroup-data)
5510 (gnus-summary-insert-line
5511 header 0 number
5512 (memq number gnus-newsgroup-undownloaded)
5513 mark (memq number gnus-newsgroup-replied)
5514 (memq number gnus-newsgroup-expirable)
5515 (mail-header-subject header) nil
5516 (cdr (assq number gnus-newsgroup-scored))
5517 (memq number gnus-newsgroup-processable))))))
5519 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5521 (defun gnus-group-get-list-identifiers (group)
5522 "Get list identifier regexp for GROUP."
5523 (or (gnus-parameter-list-identifier group)
5524 (if (consp gnus-list-identifiers)
5525 (mapconcat 'identity gnus-list-identifiers " *\\|")
5526 gnus-list-identifiers)))
5528 (defun gnus-summary-remove-list-identifiers ()
5529 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5530 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5531 changed subject)
5532 (when regexp
5533 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5534 (dolist (header gnus-newsgroup-headers)
5535 (setq subject (mail-header-subject header)
5536 changed nil)
5537 (while (string-match regexp subject)
5538 (setq subject
5539 (concat (substring subject 0 (match-beginning 1))
5540 (substring subject (match-end 0)))
5541 changed t))
5542 (when changed
5543 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5544 (setq subject
5545 (concat (substring subject 0 (match-beginning 1))
5546 (substring subject (match-end 1)))))
5547 (mail-header-set-subject header subject))))))
5549 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5550 "Fetch headers of ARTICLES."
5551 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5552 (gnus-message 7 "Fetching headers for %s..." name)
5553 (prog1
5554 (if (eq 'nov
5555 (setq gnus-headers-retrieved-by
5556 (gnus-retrieve-headers
5557 articles gnus-newsgroup-name
5558 (or limit
5559 ;; We might want to fetch old headers, but
5560 ;; not if there is only 1 article.
5561 (and (or (and
5562 (not (eq gnus-fetch-old-headers 'some))
5563 (not (numberp gnus-fetch-old-headers)))
5564 (> (length articles) 1))
5565 gnus-fetch-old-headers)))))
5566 (gnus-get-newsgroup-headers-xover
5567 articles force-new dependencies gnus-newsgroup-name t)
5568 (gnus-get-newsgroup-headers dependencies force-new))
5569 (gnus-message 7 "Fetching headers for %s...done" name))))
5571 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5572 "Select newsgroup GROUP.
5573 If READ-ALL is non-nil, all articles in the group are selected.
5574 If SELECT-ARTICLES, only select those articles from GROUP."
5575 (let* ((entry (gnus-group-entry group))
5576 ;;!!! Dirty hack; should be removed.
5577 (gnus-summary-ignore-duplicates
5578 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5580 gnus-summary-ignore-duplicates))
5581 (info (nth 2 entry))
5582 charset articles fetched-articles cached)
5584 (unless (gnus-check-server
5585 (set (make-local-variable 'gnus-current-select-method)
5586 (gnus-find-method-for-group group)))
5587 (error "Couldn't open server"))
5588 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5590 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5591 (gnus-activate-group group) ; Or we can activate it...
5592 (progn ; Or we bug out.
5593 (when (derived-mode-p 'gnus-summary-mode)
5594 (gnus-kill-buffer (current-buffer)))
5595 (error
5596 "Couldn't activate group %s: %s"
5597 (decode-coding-string group charset)
5598 (decode-coding-string (gnus-status-message group) charset))))
5600 (unless (gnus-request-group group t nil (gnus-get-info group))
5601 (when (derived-mode-p 'gnus-summary-mode)
5602 (gnus-kill-buffer (current-buffer)))
5603 (error "Couldn't request group %s: %s"
5604 (decode-coding-string group charset)
5605 (decode-coding-string (gnus-status-message group) charset)))
5607 (when (and gnus-agent
5608 (gnus-active group))
5609 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5611 (setq gnus-summary-use-undownloaded-faces
5612 (gnus-agent-find-parameter
5613 group
5614 'agent-enable-undownloaded-faces)))
5616 (setq gnus-newsgroup-name group
5617 gnus-newsgroup-unselected nil
5618 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5620 (let ((display (gnus-group-find-parameter group 'display)))
5621 (setq gnus-newsgroup-display
5622 (cond
5623 ((not (zerop (or (car-safe read-all) 0)))
5624 ;; The user entered the group with C-u SPC/RET, let's show
5625 ;; all articles.
5626 'gnus-not-ignore)
5627 ((eq display 'all)
5628 'gnus-not-ignore)
5629 ((arrayp display)
5630 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5631 ((numberp display)
5632 ;; The following is probably the "correct" solution, but
5633 ;; it makes Gnus fetch all headers and then limit the
5634 ;; articles (which is slow), so instead we hack the
5635 ;; select-articles parameter instead. -- Simon Josefsson
5636 ;; <jas@kth.se>
5638 ;; (gnus-byte-compile
5639 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5640 ;; display)))))
5641 (setq select-articles
5642 (gnus-uncompress-range
5643 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5644 (if (> tmp 0)
5647 (cdr (gnus-active group)))))
5648 nil)
5650 nil))))
5652 (gnus-summary-setup-default-charset)
5654 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5655 (when (gnus-virtual-group-p group)
5656 (setq cached gnus-newsgroup-cached))
5658 (setq gnus-newsgroup-unreads
5659 (gnus-sorted-ndifference
5660 (gnus-sorted-ndifference gnus-newsgroup-unreads
5661 gnus-newsgroup-marked)
5662 gnus-newsgroup-dormant))
5664 (setq gnus-newsgroup-processable nil)
5666 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5668 ;; Adjust and set lists of article marks.
5669 (when info
5670 (gnus-adjust-marked-articles info))
5671 (if (setq articles select-articles)
5672 (setq gnus-newsgroup-unselected
5673 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5674 (setq articles (gnus-articles-to-read group read-all)))
5676 (cond
5677 ((null articles)
5678 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5679 'quit)
5680 ((eq articles 0) nil)
5682 ;; Init the dependencies hash table.
5683 (setq gnus-newsgroup-dependencies
5684 (gnus-make-hashtable (length articles)))
5685 (if (gnus-buffer-live-p gnus-group-buffer)
5686 (gnus-set-global-variables)
5687 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5688 ;; Retrieve the headers and read them in.
5690 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5692 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5693 (when cached
5694 (setq gnus-newsgroup-cached cached))
5696 ;; Suppress duplicates?
5697 (when gnus-suppress-duplicates
5698 (gnus-dup-suppress-articles))
5700 ;; Set the initial limit.
5701 (setq gnus-newsgroup-limit (copy-sequence articles))
5702 ;; Remove canceled articles from the list of unread articles.
5703 (setq fetched-articles
5704 (mapcar (lambda (headers) (mail-header-number headers))
5705 gnus-newsgroup-headers))
5706 (setq gnus-newsgroup-articles fetched-articles)
5707 (setq gnus-newsgroup-unreads
5708 (gnus-sorted-nintersection
5709 gnus-newsgroup-unreads fetched-articles))
5710 (gnus-compute-unseen-list)
5712 ;; Removed marked articles that do not exist.
5713 (gnus-update-missing-marks
5714 (gnus-sorted-difference articles fetched-articles))
5715 ;; We might want to build some more threads first.
5716 (when (and gnus-fetch-old-headers
5717 (eq gnus-headers-retrieved-by 'nov))
5718 (if (eq gnus-fetch-old-headers 'invisible)
5719 (gnus-build-all-threads)
5720 (gnus-build-old-threads)))
5721 ;; Let the Gnus agent mark articles as read.
5722 (when gnus-agent
5723 (gnus-agent-get-undownloaded-list))
5724 ;; Remove list identifiers from subject
5725 (gnus-summary-remove-list-identifiers)
5726 ;; Check whether auto-expire is to be done in this group.
5727 (setq gnus-newsgroup-auto-expire
5728 (and (gnus-group-auto-expirable-p group)
5729 (not (gnus-group-read-only-p group))))
5730 ;; Set up the article buffer now, if necessary.
5731 (unless (and gnus-single-article-buffer
5732 (equal gnus-article-buffer "*Article*"))
5733 (gnus-article-setup-buffer))
5734 ;; First and last article in this newsgroup.
5735 (when gnus-newsgroup-headers
5736 (setq gnus-newsgroup-begin
5737 (mail-header-number (car gnus-newsgroup-headers))
5738 gnus-newsgroup-end
5739 (mail-header-number
5740 (gnus-last-element gnus-newsgroup-headers))))
5741 ;; GROUP is successfully selected.
5742 (or gnus-newsgroup-headers t)))))
5744 (defun gnus-compute-unseen-list ()
5745 ;; The `seen' marks are treated specially.
5746 (if (not gnus-newsgroup-seen)
5747 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5748 (setq gnus-newsgroup-unseen
5749 (gnus-inverse-list-range-intersection
5750 gnus-newsgroup-articles gnus-newsgroup-seen))))
5752 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5754 (defun gnus-summary-display-make-predicate (display)
5755 (require 'gnus-agent)
5756 (when (= (length display) 1)
5757 (setq display (car display)))
5758 (unless gnus-summary-display-cache
5759 (dolist (elem (append '((unread . unread)
5760 (read . read)
5761 (unseen . unseen))
5762 gnus-article-mark-lists))
5763 (push (cons (cdr elem)
5764 (gnus-byte-compile ;Why bother?
5765 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5766 gnus-summary-display-cache)))
5767 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5768 (gnus-category-predicate-cache gnus-summary-display-cache))
5769 (gnus-get-predicate display)))
5771 ;; Uses the dynamically bound `gnus-number' variable.
5772 (defvar gnus-number)
5773 (defun gnus-article-marked-p (type &optional article)
5774 (let ((article (or article gnus-number)))
5775 (cond
5776 ((eq type 'tick)
5777 (memq article gnus-newsgroup-marked))
5778 ((eq type 'spam)
5779 (memq article gnus-newsgroup-spam-marked))
5780 ((eq type 'unsend)
5781 (memq article gnus-newsgroup-unsendable))
5782 ((eq type 'undownload)
5783 (memq article gnus-newsgroup-undownloaded))
5784 ((eq type 'download)
5785 (memq article gnus-newsgroup-downloadable))
5786 ((eq type 'unread)
5787 (memq article gnus-newsgroup-unreads))
5788 ((eq type 'read)
5789 (memq article gnus-newsgroup-reads))
5790 ((eq type 'dormant)
5791 (memq article gnus-newsgroup-dormant) )
5792 ((eq type 'expire)
5793 (memq article gnus-newsgroup-expirable))
5794 ((eq type 'reply)
5795 (memq article gnus-newsgroup-replied))
5796 ((eq type 'killed)
5797 (memq article gnus-newsgroup-killed))
5798 ((eq type 'bookmark)
5799 (assq article gnus-newsgroup-bookmarks))
5800 ((eq type 'score)
5801 (assq article gnus-newsgroup-scored))
5802 ((eq type 'save)
5803 (memq article gnus-newsgroup-saved))
5804 ((eq type 'cache)
5805 (memq article gnus-newsgroup-cached))
5806 ((eq type 'forward)
5807 (memq article gnus-newsgroup-forwarded))
5808 ((eq type 'seen)
5809 (not (memq article gnus-newsgroup-unseen)))
5810 (t t))))
5812 (defun gnus-articles-to-read (group &optional read-all)
5813 "Find out what articles the user wants to read."
5814 (let* ((only-read-p t)
5815 (articles
5816 (gnus-list-range-difference
5817 ;; Select all articles if `read-all' is non-nil, or if there
5818 ;; are no unread articles.
5819 (if (or read-all
5820 (and (zerop (length gnus-newsgroup-marked))
5821 (zerop (length gnus-newsgroup-unreads)))
5822 ;; Fetch all if the predicate is non-nil.
5823 gnus-newsgroup-display)
5824 ;; We want to select the headers for all the articles in
5825 ;; the group, so we select either all the active
5826 ;; articles in the group, or (if that's nil), the
5827 ;; articles in the cache.
5829 (if gnus-newsgroup-maximum-articles
5830 (let ((active (gnus-active group)))
5831 (gnus-uncompress-range
5832 (cons (max (car active)
5833 (- (cdr active)
5834 gnus-newsgroup-maximum-articles
5835 -1))
5836 (cdr active))))
5837 (gnus-uncompress-range (gnus-active group)))
5838 (gnus-cache-articles-in-group group))
5839 ;; Select only the "normal" subset of articles.
5840 (setq only-read-p nil)
5841 (gnus-sorted-nunion
5842 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5843 gnus-newsgroup-unreads))
5844 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5845 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5846 (scored (length scored-list))
5847 (number (length articles))
5848 (marked (+ (length gnus-newsgroup-marked)
5849 (length gnus-newsgroup-dormant)))
5850 (select
5851 (cond
5852 ((numberp read-all)
5853 read-all)
5854 ((numberp gnus-newsgroup-display)
5855 gnus-newsgroup-display)
5857 (condition-case ()
5858 (cond
5859 ((and (or (<= scored marked) (= scored number))
5860 (numberp gnus-large-newsgroup)
5861 (> number gnus-large-newsgroup))
5862 (let* ((cursor-in-echo-area nil)
5863 (initial (gnus-parameter-large-newsgroup-initial
5864 gnus-newsgroup-name))
5865 (default (if only-read-p
5866 (or initial gnus-large-newsgroup)
5867 number))
5868 (input
5869 (read-string
5870 (if only-read-p
5871 (format
5872 "How many articles from %s (available %d, default %d): "
5873 (gnus-group-real-name
5874 (gnus-group-decoded-name gnus-newsgroup-name))
5875 number default)
5876 (format
5877 "How many articles from %s (%d default): "
5878 (gnus-group-real-name
5879 (gnus-group-decoded-name gnus-newsgroup-name))
5880 default))
5883 (number-to-string default))))
5884 (if (string-match "^[ \t]*$" input) number input)))
5885 ((and (> scored marked) (< scored number)
5886 (> (- scored number) 20))
5887 (let ((input
5888 (read-string
5889 (format "%s %s (%d scored, %d total): "
5890 "How many articles from"
5891 (gnus-group-decoded-name
5892 (gnus-group-real-name gnus-newsgroup-name))
5893 scored number))))
5894 (if (string-match "^[ \t]*$" input)
5895 number input)))
5896 (t number))
5897 (quit
5898 (message "Quit getting the articles to read")
5899 nil))))))
5900 (setq select (if (stringp select) (string-to-number select) select))
5901 (if (or (null select) (zerop select))
5902 select
5903 (if (and (not (zerop scored)) (<= (abs select) scored))
5904 (progn
5905 (setq articles (sort scored-list '<))
5906 (setq number (length articles)))
5907 (setq articles (copy-sequence articles)))
5909 (when (< (abs select) number)
5910 (if (< select 0)
5911 ;; Select the N oldest articles.
5912 (setcdr (nthcdr (1- (abs select)) articles) nil)
5913 ;; Select the N most recent articles.
5914 (setq articles (nthcdr (- number select) articles))))
5915 (setq gnus-newsgroup-unselected
5916 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5917 (when gnus-alter-articles-to-read-function
5918 (setq articles
5919 (sort
5920 (funcall gnus-alter-articles-to-read-function
5921 gnus-newsgroup-name articles)
5922 '<)))
5923 articles)))
5925 (defun gnus-killed-articles (killed articles)
5926 (let (out)
5927 (while articles
5928 (when (inline (gnus-member-of-range (car articles) killed))
5929 (push (car articles) out))
5930 (setq articles (cdr articles)))
5931 out))
5933 (defun gnus-article-mark-to-type (mark)
5934 "Return the type of MARK."
5935 (or (cadr (assq mark gnus-article-special-mark-lists))
5936 'list))
5938 (defun gnus-article-unpropagatable-p (mark)
5939 "Return whether MARK should be propagated to back end."
5940 (memq mark gnus-article-unpropagated-mark-lists))
5942 (defun gnus-adjust-marked-articles (info)
5943 "Set all article lists and remove all marks that are no longer valid."
5944 (let* ((marked-lists (gnus-info-marks info))
5945 (active (gnus-active (gnus-info-group info)))
5946 (min (car active))
5947 (max (cdr active))
5948 (types gnus-article-mark-lists)
5949 marks var articles article mark mark-type
5950 bgn end)
5951 ;; Hack to avoid adjusting marks for imap.
5952 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5953 'nnimap)
5954 (setq min 1))
5956 (dolist (marks marked-lists)
5957 (setq mark (car marks)
5958 mark-type (gnus-article-mark-to-type mark)
5959 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5960 ;; We set the variable according to the type of the marks list,
5961 ;; and then adjust the marks to a subset of the active articles.
5962 (cond
5963 ;; Adjust "simple" lists - compressed yet unsorted
5964 ((eq mark-type 'list)
5965 ;; Simultaneously uncompress and clip to active range
5966 ;; See gnus-uncompress-range for a description of possible marks
5967 (let (l lh)
5968 (if (not (cadr marks))
5969 (set var nil)
5970 (setq articles (if (numberp (cddr marks))
5971 (list (cdr marks))
5972 (cdr marks))
5973 lh (cons nil nil)
5974 l lh)
5976 (while (setq article (pop articles))
5977 (cond ((consp article)
5978 (setq bgn (max (car article) min)
5979 end (min (cdr article) max))
5980 (while (<= bgn end)
5981 (setq l (setcdr l (cons bgn nil))
5982 bgn (1+ bgn))))
5983 ((and (<= min article)
5984 (>= max article))
5985 (setq l (setcdr l (cons article nil))))))
5986 (set var (cdr lh)))))
5987 ;; Adjust assocs.
5988 ((eq mark-type 'tuple)
5989 (set var (setq articles (cdr marks)))
5990 (when (not (listp (cdr (symbol-value var))))
5991 (set var (list (symbol-value var))))
5992 (when (not (listp (cdr articles)))
5993 (setq articles (list articles)))
5994 (while articles
5995 (when (or (not (consp (setq article (pop articles))))
5996 (< (car article) min)
5997 (> (car article) max))
5998 (set var (delq article (symbol-value var))))))
5999 ;; Adjust ranges (sloppily).
6000 ((eq mark-type 'range)
6001 (cond
6002 ((eq mark 'seen)
6003 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6004 ;; It should be (seen (NUM1 . NUM2)).
6005 (when (numberp (cddr marks))
6006 (setcdr marks (list (cdr marks))))
6007 (setq articles (cdr marks))
6008 (while (and articles
6009 (or (and (consp (car articles))
6010 (> min (cdar articles)))
6011 (and (numberp (car articles))
6012 (> min (car articles)))))
6013 (pop articles))
6014 (set var articles))
6015 ((eq mark 'unexist)
6016 (set var (cdr marks)))))))))
6018 (defun gnus-update-missing-marks (missing)
6019 "Go through the list of MISSING articles and remove them from the mark lists."
6020 (when missing
6021 (let (var m)
6022 ;; Go through all types.
6023 (dolist (elem gnus-article-mark-lists)
6024 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6025 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6026 (when (symbol-value var)
6027 ;; This list has articles. So we delete all missing
6028 ;; articles from it.
6029 (setq m missing)
6030 (while m
6031 (set var (delq (pop m) (symbol-value var))))))))))
6033 (defun gnus-update-marks ()
6034 "Enter the various lists of marked articles into the newsgroup info list."
6035 (let ((types gnus-article-mark-lists)
6036 (info (gnus-get-info gnus-newsgroup-name))
6037 type list newmarked symbol delta-marks)
6038 (when info
6039 ;; Add all marks lists to the list of marks lists.
6040 (while (setq type (pop types))
6041 (setq list (symbol-value
6042 (setq symbol
6043 (intern (format "gnus-newsgroup-%s" (car type))))))
6045 (when list
6046 ;; Get rid of the entries of the articles that have the
6047 ;; default score.
6048 (when (and (eq (cdr type) 'score)
6049 gnus-save-score
6050 list)
6051 (let* ((arts list)
6052 (prev (cons nil list))
6053 (all prev))
6054 (while arts
6055 (if (or (not (consp (car arts)))
6056 (= (cdar arts) gnus-summary-default-score))
6057 (setcdr prev (cdr arts))
6058 (setq prev arts))
6059 (setq arts (cdr arts)))
6060 (setq list (cdr all)))))
6062 ;; When exiting the group, everything that's previously been
6063 ;; unseen is now seen.
6064 (when (eq (cdr type) 'seen)
6065 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6067 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6068 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6070 (when (and (gnus-check-backend-function
6071 'request-set-mark gnus-newsgroup-name)
6072 (not (gnus-article-unpropagatable-p (cdr type))))
6073 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6074 ;; Don't do anything about marks for articles we
6075 ;; didn't actually get any headers for.
6076 (del
6077 (gnus-list-range-intersection
6078 gnus-newsgroup-articles
6079 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6080 (add
6081 (gnus-list-range-intersection
6082 gnus-newsgroup-articles
6083 (gnus-remove-from-range
6084 (gnus-copy-sequence list) old))))
6085 (when add
6086 (push (list add 'add (list (cdr type))) delta-marks))
6087 (when del
6088 ;; Don't delete marks from outside the active range.
6089 ;; This shouldn't happen, but is a sanity check.
6090 (setq del (gnus-sorted-range-intersection
6091 (gnus-active gnus-newsgroup-name) del))
6092 (push (list del 'del (list (cdr type))) delta-marks))))
6094 (when (or list
6095 (eq (cdr type) 'unexist))
6096 (push (cons (cdr type) list) newmarked)))
6098 (when delta-marks
6099 (unless (gnus-check-group gnus-newsgroup-name)
6100 (error "Can't open server for %s" gnus-newsgroup-name))
6101 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6103 ;; Enter these new marks into the info of the group.
6104 (if (nthcdr 3 info)
6105 (setcar (nthcdr 3 info) newmarked)
6106 ;; Add the marks lists to the end of the info.
6107 (when newmarked
6108 (setcdr (nthcdr 2 info) (list newmarked))))
6110 ;; Cut off the end of the info if there's nothing else there.
6111 (let ((i 5))
6112 (while (and (> i 2)
6113 (not (nth i info)))
6114 (when (nthcdr (decf i) info)
6115 (setcdr (nthcdr i info) nil)))))))
6117 (defun gnus-set-mode-line (where)
6118 "Set the mode line of the article or summary buffers.
6119 If WHERE is `summary', the summary mode line format will be used."
6120 ;; Is this mode line one we keep updated?
6121 (when (and (memq where gnus-updated-mode-lines)
6122 (symbol-value
6123 (intern (format "gnus-%s-mode-line-format-spec" where))))
6124 (let (mode-string)
6125 ;; We evaluate this in the summary buffer since these
6126 ;; variables are buffer-local to that buffer.
6127 (with-current-buffer gnus-summary-buffer
6128 ;; We bind all these variables that are used in the `eval' form
6129 ;; below.
6130 (let* ((mformat (symbol-value
6131 (intern
6132 (format "gnus-%s-mode-line-format-spec" where))))
6133 (gnus-tmp-group-name (gnus-mode-string-quote
6134 (gnus-group-decoded-name
6135 gnus-newsgroup-name)))
6136 (gnus-tmp-article-number (or gnus-current-article 0))
6137 (gnus-tmp-unread gnus-newsgroup-unreads)
6138 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6139 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6140 (gnus-tmp-unread-and-unselected
6141 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6142 (zerop gnus-tmp-unselected))
6144 ((zerop gnus-tmp-unselected)
6145 (format "{%d more}" gnus-tmp-unread-and-unticked))
6146 (t (format "{%d(+%d) more}"
6147 gnus-tmp-unread-and-unticked
6148 gnus-tmp-unselected))))
6149 (gnus-tmp-subject
6150 (if (and gnus-current-headers
6151 (vectorp gnus-current-headers))
6152 (gnus-mode-string-quote
6153 (mail-header-subject gnus-current-headers))
6154 ""))
6155 bufname-length max-len
6156 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6157 (setq mode-string (eval mformat))
6158 (setq bufname-length (if (string-match "%b" mode-string)
6159 (- (length
6160 (buffer-name
6161 (if (eq where 'summary)
6163 (get-buffer gnus-article-buffer))))
6166 (setq max-len (max 4 (if gnus-mode-non-string-length
6167 (- (window-width)
6168 gnus-mode-non-string-length
6169 bufname-length)
6170 (length mode-string))))
6171 ;; We might have to chop a bit of the string off...
6172 (when (> (length mode-string) max-len)
6173 (setq mode-string
6174 (concat (truncate-string-to-width mode-string (- max-len 3))
6175 "...")))))
6176 ;; Update the mode line.
6177 (setq mode-line-buffer-identification
6178 (gnus-mode-line-buffer-identification (list mode-string)))
6179 (set-buffer-modified-p t))))
6181 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6182 "Go through the HEADERS list and add all Xrefs to a hash table.
6183 The resulting hash table is returned, or nil if no Xrefs were found."
6184 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6185 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6186 (xref-hashtb (gnus-make-hashtable))
6187 start group entry number xrefs header)
6188 (while headers
6189 (setq header (pop headers))
6190 (when (and (setq xrefs (mail-header-xref header))
6191 (not (memq (setq number (mail-header-number header))
6192 unreads)))
6193 (setq start 0)
6194 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6195 (setq start (match-end 0))
6196 (setq group (if prefix
6197 (concat prefix (substring xrefs (match-beginning 1)
6198 (match-end 1)))
6199 (substring xrefs (match-beginning 1) (match-end 1))))
6200 (setq number
6201 (string-to-number (substring xrefs (match-beginning 2)
6202 (match-end 2))))
6203 (if (setq entry (gnus-gethash group xref-hashtb))
6204 (setcdr entry (cons number (cdr entry)))
6205 (gnus-sethash group (cons number nil) xref-hashtb)))))
6206 (and start xref-hashtb)))
6208 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6209 "Look through all the headers and mark the Xrefs as read."
6210 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6211 name info xref-hashtb idlist method nth4)
6212 (with-current-buffer gnus-group-buffer
6213 (when (setq xref-hashtb
6214 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6215 (mapatoms
6216 (lambda (group)
6217 (unless (string= from-newsgroup (setq name (symbol-name group)))
6218 (setq idlist (symbol-value group))
6219 ;; Dead groups are not updated.
6220 (and (prog1
6221 (setq info (gnus-get-info name))
6222 (when (stringp (setq nth4 (gnus-info-method info)))
6223 (setq nth4 (gnus-server-to-method nth4))))
6224 ;; Only do the xrefs if the group has the same
6225 ;; select method as the group we have just read.
6226 (or (gnus-methods-equal-p
6227 nth4 (gnus-find-method-for-group from-newsgroup))
6228 virtual
6229 (equal nth4 (setq method (gnus-find-method-for-group
6230 from-newsgroup)))
6231 (and (equal (car nth4) (car method))
6232 (equal (nth 1 nth4) (nth 1 method))))
6233 gnus-use-cross-reference
6234 (or (not (eq gnus-use-cross-reference t))
6235 virtual
6236 ;; Only do cross-references on subscribed
6237 ;; groups, if that is what is wanted.
6238 (<= (gnus-info-level info) gnus-level-subscribed))
6239 (gnus-group-make-articles-read name idlist))))
6240 xref-hashtb)))))
6242 (defun gnus-compute-read-articles (group articles)
6243 (let* ((entry (gnus-group-entry group))
6244 (info (nth 2 entry))
6245 (active (gnus-active group))
6246 ninfo)
6247 (when entry
6248 ;; First peel off all invalid article numbers.
6249 (when active
6250 (let ((ids articles)
6251 id first)
6252 (while (setq id (pop ids))
6253 (when (and first (> id (cdr active)))
6254 ;; We'll end up in this situation in one particular
6255 ;; obscure situation. If you re-scan a group and get
6256 ;; a new article that is cross-posted to a different
6257 ;; group that has not been re-scanned, you might get
6258 ;; crossposted article that has a higher number than
6259 ;; Gnus believes possible. So we re-activate this
6260 ;; group as well. This might mean doing the
6261 ;; crossposting thingy will *increase* the number
6262 ;; of articles in some groups. Tsk, tsk.
6263 (setq active (or (gnus-activate-group group) active)))
6264 (when (or (> id (cdr active))
6265 (< id (car active)))
6266 (setq articles (delq id articles))))))
6267 ;; If the read list is nil, we init it.
6268 (if (and active
6269 (null (gnus-info-read info))
6270 (> (car active) 1))
6271 (setq ninfo (cons 1 (1- (car active))))
6272 (setq ninfo (gnus-info-read info)))
6273 ;; Then we add the read articles to the range.
6274 (gnus-add-to-range
6275 ninfo (setq articles (sort articles '<))))))
6277 (defun gnus-group-make-articles-read (group articles)
6278 "Update the info of GROUP to say that ARTICLES are read."
6279 (let* ((num 0)
6280 (entry (gnus-group-entry group))
6281 (info (nth 2 entry))
6282 (active (gnus-active group))
6283 (set-marks
6284 (gnus-method-option-p
6285 (gnus-find-method-for-group group)
6286 'server-marks))
6287 range)
6288 (if (not entry)
6289 ;; Group that Gnus doesn't know exists, but still allow the
6290 ;; backend to set marks.
6291 (when set-marks
6292 (gnus-request-set-mark
6293 group (list (list (gnus-compress-sequence (sort articles #'<))
6294 'add '(read)))))
6295 ;; Normal, subscribed groups.
6296 (setq range (gnus-compute-read-articles group articles))
6297 (with-current-buffer gnus-group-buffer
6298 (gnus-undo-register
6299 `(progn
6300 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6301 (gnus-info-set-read ',info ',(gnus-info-read info))
6302 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6303 (when ,set-marks
6304 (gnus-request-set-mark
6305 ,group (list (list ',range 'del '(read)))))
6306 (gnus-group-update-group ,group t))))
6307 ;; Add the read articles to the range.
6308 (gnus-info-set-read info range)
6309 (when set-marks
6310 (gnus-request-set-mark group (list (list range 'add '(read)))))
6311 ;; Then we have to re-compute how many unread
6312 ;; articles there are in this group.
6313 (when active
6314 (cond
6315 ((not range)
6316 (setq num (- (1+ (cdr active)) (car active))))
6317 ((not (listp (cdr range)))
6318 (setq num (- (cdr active) (- (1+ (cdr range))
6319 (car range)))))
6321 (while range
6322 (if (numberp (car range))
6323 (setq num (1+ num))
6324 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6325 (setq range (cdr range)))
6326 (setq num (- (cdr active) num))))
6327 ;; Update the number of unread articles.
6328 (setcar entry num)
6329 ;; Update the group buffer.
6330 (unless (gnus-ephemeral-group-p group)
6331 (gnus-group-update-group group t))))))
6333 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6334 (let ((cur nntp-server-buffer)
6335 (dependencies
6336 (or dependencies
6337 (with-current-buffer gnus-summary-buffer
6338 gnus-newsgroup-dependencies)))
6339 headers id end ref number
6340 (mail-parse-charset gnus-newsgroup-charset)
6341 (mail-parse-ignored-charsets
6342 (save-current-buffer (condition-case nil
6343 (set-buffer gnus-summary-buffer)
6344 (error))
6345 gnus-newsgroup-ignored-charsets)))
6346 (with-current-buffer nntp-server-buffer
6347 ;; Translate all TAB characters into SPACE characters.
6348 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6349 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6350 (ietf-drums-unfold-fws)
6351 (gnus-run-hooks 'gnus-parse-headers-hook)
6352 (let ((case-fold-search t)
6353 in-reply-to header p lines chars)
6354 (goto-char (point-min))
6355 ;; Search to the beginning of the next header. Error messages
6356 ;; do not begin with 2 or 3.
6357 (while (re-search-forward "^[23][0-9]+ " nil t)
6358 (setq id nil
6359 ref nil)
6360 ;; This implementation of this function, with nine
6361 ;; search-forwards instead of the one re-search-forward and
6362 ;; a case (which basically was the old function) is actually
6363 ;; about twice as fast, even though it looks messier. You
6364 ;; can't have everything, I guess. Speed and elegance
6365 ;; doesn't always go hand in hand.
6366 (setq
6367 header
6368 (vector
6369 ;; Number.
6370 (prog1
6371 (setq number (read cur))
6372 (end-of-line)
6373 (setq p (point))
6374 (narrow-to-region (point)
6375 (or (and (search-forward "\n.\n" nil t)
6376 (- (point) 2))
6377 (point))))
6378 ;; Subject.
6379 (progn
6380 (goto-char p)
6381 (if (search-forward "\nsubject:" nil t)
6382 (funcall gnus-decode-encoded-word-function
6383 (nnheader-header-value))
6384 "(none)"))
6385 ;; From.
6386 (progn
6387 (goto-char p)
6388 (if (search-forward "\nfrom:" nil t)
6389 (funcall gnus-decode-encoded-address-function
6390 (nnheader-header-value))
6391 "(nobody)"))
6392 ;; Date.
6393 (progn
6394 (goto-char p)
6395 (if (search-forward "\ndate:" nil t)
6396 (nnheader-header-value) ""))
6397 ;; Message-ID.
6398 (progn
6399 (goto-char p)
6400 (setq id (if (re-search-forward
6401 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6402 ;; We do it this way to make sure the Message-ID
6403 ;; is (somewhat) syntactically valid.
6404 (buffer-substring (match-beginning 1)
6405 (match-end 1))
6406 ;; If there was no message-id, we just fake one
6407 ;; to make subsequent routines simpler.
6408 (nnheader-generate-fake-message-id number))))
6409 ;; References.
6410 (progn
6411 (goto-char p)
6412 (if (search-forward "\nreferences:" nil t)
6413 (progn
6414 (setq end (point))
6415 (prog1
6416 (nnheader-header-value)
6417 (setq ref
6418 (buffer-substring
6419 (progn
6420 (end-of-line)
6421 (search-backward ">" end t)
6422 (1+ (point)))
6423 (progn
6424 (search-backward "<" end t)
6425 (point))))))
6426 ;; Get the references from the in-reply-to header if there
6427 ;; were no references and the in-reply-to header looks
6428 ;; promising.
6429 (if (and (search-forward "\nin-reply-to:" nil t)
6430 (setq in-reply-to (nnheader-header-value))
6431 (string-match "<[^>]+>" in-reply-to))
6432 (let (ref2)
6433 (setq ref (substring in-reply-to (match-beginning 0)
6434 (match-end 0)))
6435 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6436 (setq ref2 (substring in-reply-to (match-beginning 0)
6437 (match-end 0)))
6438 (when (> (length ref2) (length ref))
6439 (setq ref ref2)))
6440 ref)
6441 (setq ref nil))))
6442 ;; Chars.
6443 (progn
6444 (goto-char p)
6445 (if (search-forward "\nchars: " nil t)
6446 (if (numberp (setq chars (ignore-errors (read cur))))
6447 chars -1)
6448 -1))
6449 ;; Lines.
6450 (progn
6451 (goto-char p)
6452 (if (search-forward "\nlines: " nil t)
6453 (if (numberp (setq lines (ignore-errors (read cur))))
6454 lines -1)
6455 -1))
6456 ;; Xref.
6457 (progn
6458 (goto-char p)
6459 (and (search-forward "\nxref:" nil t)
6460 (nnheader-header-value)))
6461 ;; Extra.
6462 (when gnus-extra-headers
6463 (let ((extra gnus-extra-headers)
6464 out)
6465 (while extra
6466 (goto-char p)
6467 (when (search-forward
6468 (concat "\n" (symbol-name (car extra)) ":") nil t)
6469 (push (cons (car extra) (nnheader-header-value))
6470 out))
6471 (pop extra))
6472 out))))
6473 (when (equal id ref)
6474 (setq ref nil))
6476 (when gnus-alter-header-function
6477 (funcall gnus-alter-header-function header)
6478 (setq id (mail-header-id header)
6479 ref (gnus-parent-id (mail-header-references header))))
6481 (when (setq header
6482 (gnus-dependencies-add-header
6483 header dependencies force-new))
6484 (push header headers))
6485 (goto-char (point-max))
6486 (widen))
6487 (nreverse headers)))))
6489 ;; Goes through the xover lines and returns a list of vectors
6490 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6491 force-new dependencies
6492 group also-fetch-heads)
6493 "Parse the news overview data in the server buffer.
6494 Return a list of headers that match SEQUENCE (see
6495 `nntp-retrieve-headers')."
6496 ;; Get the Xref when the users reads the articles since most/some
6497 ;; NNTP servers do not include Xrefs when using XOVER.
6498 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6499 (let ((mail-parse-charset gnus-newsgroup-charset)
6500 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6501 (cur nntp-server-buffer)
6502 (dependencies (or dependencies gnus-newsgroup-dependencies))
6503 (allp (cond
6504 ((eq gnus-read-all-available-headers t)
6506 ((and (stringp gnus-read-all-available-headers)
6507 group)
6508 (string-match gnus-read-all-available-headers group))
6510 nil)))
6511 number headers header)
6512 (with-current-buffer nntp-server-buffer
6513 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6514 ;; Allow the user to mangle the headers before parsing them.
6515 (gnus-run-hooks 'gnus-parse-headers-hook)
6516 (goto-char (point-min))
6517 (gnus-parse-without-error
6518 (while (and (or sequence allp)
6519 (not (eobp)))
6520 (setq number (read cur))
6521 (when (not allp)
6522 (while (and sequence
6523 (< (car sequence) number))
6524 (setq sequence (cdr sequence))))
6525 (when (and (or allp
6526 (and sequence
6527 (eq number (car sequence))))
6528 (progn
6529 (setq sequence (cdr sequence))
6530 (setq header (inline
6531 (gnus-nov-parse-line
6532 number dependencies force-new)))))
6533 (push header headers))
6534 (forward-line 1)))
6535 ;; A common bug in inn is that if you have posted an article and
6536 ;; then retrieves the active file, it will answer correctly --
6537 ;; the new article is included. However, a NOV entry for the
6538 ;; article may not have been generated yet, so this may fail.
6539 ;; We work around this problem by retrieving the last few
6540 ;; headers using HEAD.
6541 (if (or (not also-fetch-heads)
6542 (not sequence))
6543 ;; We (probably) got all the headers.
6544 (nreverse headers)
6545 (let ((gnus-nov-is-evil t))
6546 (nconc
6547 (nreverse headers)
6548 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6549 (gnus-get-newsgroup-headers))))))))
6551 (defun gnus-article-get-xrefs ()
6552 "Fill in the Xref value in `gnus-current-headers', if necessary.
6553 This is meant to be called in `gnus-article-internal-prepare-hook'."
6554 (let ((headers (with-current-buffer gnus-summary-buffer
6555 gnus-current-headers)))
6556 (or (not gnus-use-cross-reference)
6557 (not headers)
6558 (and (mail-header-xref headers)
6559 (not (string= (mail-header-xref headers) "")))
6560 (let ((case-fold-search t)
6561 xref)
6562 (save-restriction
6563 (nnheader-narrow-to-headers)
6564 (goto-char (point-min))
6565 (when (or (and (not (eobp))
6566 (eq (downcase (char-after)) ?x)
6567 (looking-at "Xref:"))
6568 (search-forward "\nXref:" nil t))
6569 (goto-char (1+ (match-end 0)))
6570 (setq xref (buffer-substring (point) (point-at-eol)))
6571 (mail-header-set-xref headers xref)))))))
6573 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6574 "Find article ID and insert the summary line for that article.
6575 OLD-HEADER can either be a header or a line number to insert
6576 the subject line on.
6577 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6578 and OLD-HEADER will be used when the summary line is inserted,
6579 too, instead of trying to fetch new headers."
6580 (let* ((line (and (numberp old-header) old-header))
6581 (old-header (and (vectorp old-header) old-header))
6582 (header (cond ((and old-header use-old-header)
6583 old-header)
6584 ((and (numberp id)
6585 (gnus-number-to-header id))
6586 (gnus-number-to-header id))
6588 (gnus-read-header id))))
6589 (number (and (numberp id) id))
6591 (when header
6592 ;; Rebuild the thread that this article is part of and go to the
6593 ;; article we have fetched.
6594 (when (and (not gnus-show-threads)
6595 old-header)
6596 (when (and number
6597 (setq d (gnus-data-find (mail-header-number old-header))))
6598 (goto-char (gnus-data-pos d))
6599 (gnus-data-remove
6600 number
6601 (- (point-at-bol)
6602 (prog1
6603 (1+ (point-at-eol))
6604 (gnus-delete-line))))))
6605 ;; Remove list identifiers from subject.
6606 (let ((gnus-newsgroup-headers (list header)))
6607 (gnus-summary-remove-list-identifiers))
6608 (when old-header
6609 (mail-header-set-number header (mail-header-number old-header)))
6610 (setq gnus-newsgroup-sparse
6611 (delq (setq number (mail-header-number header))
6612 gnus-newsgroup-sparse))
6613 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6614 (push number gnus-newsgroup-limit)
6615 (gnus-rebuild-thread (mail-header-id header) line)
6616 (gnus-summary-goto-subject number nil t))
6617 (when (and (numberp number)
6618 (> number 0))
6619 ;; We have to update the boundaries even if we can't fetch the
6620 ;; article if ID is a number -- so that the next `P' or `N'
6621 ;; command will fetch the previous (or next) article even
6622 ;; if the one we tried to fetch this time has been canceled.
6623 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6624 (setq gnus-newsgroup-end number))
6625 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6626 (setq gnus-newsgroup-begin number))
6627 (setq gnus-newsgroup-unselected
6628 (delq number gnus-newsgroup-unselected)))
6629 ;; Report back a success?
6630 (and header (mail-header-number header))))
6632 ;;; Process/prefix in the summary buffer
6634 (defun gnus-summary-work-articles (n)
6635 "Return a list of articles to be worked upon.
6636 The prefix argument, the list of process marked articles, and the
6637 current article will be taken into consideration."
6638 (with-current-buffer gnus-summary-buffer
6639 (cond
6641 ;; A numerical prefix has been given.
6642 (setq n (prefix-numeric-value n))
6643 (let ((backward (< n 0))
6644 (n (abs (prefix-numeric-value n)))
6645 articles article)
6646 (save-excursion
6647 (while
6648 (and (> n 0)
6649 (push (setq article (gnus-summary-article-number))
6650 articles)
6651 (if backward
6652 (gnus-summary-find-prev nil article)
6653 (gnus-summary-find-next nil article)))
6654 (decf n)))
6655 (nreverse articles)))
6656 ((and (and transient-mark-mode mark-active) (mark))
6657 (message "region active")
6658 ;; Work on the region between point and mark.
6659 (let ((max (max (point) (mark)))
6660 articles article)
6661 (save-excursion
6662 (goto-char (min (point) (mark)))
6663 (while
6664 (and
6665 (push (setq article (gnus-summary-article-number)) articles)
6666 (gnus-summary-find-next nil article)
6667 (< (point) max)))
6668 (nreverse articles))))
6669 (gnus-newsgroup-processable
6670 ;; There are process-marked articles present.
6671 ;; Save current state.
6672 (gnus-summary-save-process-mark)
6673 ;; Return the list.
6674 (reverse gnus-newsgroup-processable))
6676 ;; Just return the current article.
6677 (list (gnus-summary-article-number))))))
6679 (defmacro gnus-summary-iterate (arg &rest forms)
6680 "Iterate over the process/prefixed articles and do FORMS.
6681 ARG is the interactive prefix given to the command. FORMS will be
6682 executed with point over the summary line of the articles."
6683 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6684 `(let ((,articles (gnus-summary-work-articles ,arg)))
6685 (while ,articles
6686 (gnus-summary-goto-subject (car ,articles))
6687 ,@forms
6688 (pop ,articles)))))
6690 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6691 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6693 (defun gnus-summary-save-process-mark ()
6694 "Push the current set of process marked articles on the stack."
6695 (interactive)
6696 (push (copy-sequence gnus-newsgroup-processable)
6697 gnus-newsgroup-process-stack))
6699 (defun gnus-summary-kill-process-mark ()
6700 "Push the current set of process marked articles on the stack and unmark."
6701 (interactive)
6702 (gnus-summary-save-process-mark)
6703 (gnus-summary-unmark-all-processable))
6705 (defun gnus-summary-yank-process-mark ()
6706 "Pop the last process mark state off the stack and restore it."
6707 (interactive)
6708 (unless gnus-newsgroup-process-stack
6709 (error "Empty mark stack"))
6710 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6712 (defun gnus-summary-process-mark-set (set)
6713 "Make SET into the current process marked articles."
6714 (gnus-summary-unmark-all-processable)
6715 (mapc 'gnus-summary-set-process-mark set))
6717 ;;; Searching and stuff
6719 (defun gnus-summary-search-group (&optional backward use-level)
6720 "Search for next unread newsgroup.
6721 If optional argument BACKWARD is non-nil, search backward instead."
6722 (with-current-buffer gnus-group-buffer
6723 (when (gnus-group-search-forward
6724 backward nil (if use-level (gnus-group-group-level) nil))
6725 (gnus-group-group-name))))
6727 (defun gnus-summary-best-group (&optional exclude-group)
6728 "Find the name of the best unread group.
6729 If EXCLUDE-GROUP, do not go to this group."
6730 (with-current-buffer gnus-group-buffer
6731 (save-excursion
6732 (gnus-group-best-unread-group exclude-group))))
6734 (defun gnus-summary-find-next (&optional unread article backward)
6735 (if backward
6736 (gnus-summary-find-prev unread article)
6737 (let* ((dummy (gnus-summary-article-intangible-p))
6738 (article (or article (gnus-summary-article-number)))
6739 (data (gnus-data-find-list article))
6740 result)
6741 (when (and (not dummy)
6742 (or (not gnus-summary-check-current)
6743 (not unread)
6744 (not (gnus-data-unread-p (car data)))))
6745 (setq data (cdr data)))
6746 (when (setq result
6747 (if unread
6748 (progn
6749 (while data
6750 (unless (memq (gnus-data-number (car data))
6751 (cond
6752 ((eq gnus-auto-goto-ignores
6753 'always-undownloaded)
6754 gnus-newsgroup-undownloaded)
6755 (gnus-plugged
6756 nil)
6757 ((eq gnus-auto-goto-ignores
6758 'unfetched)
6759 gnus-newsgroup-unfetched)
6760 ((eq gnus-auto-goto-ignores
6761 'undownloaded)
6762 gnus-newsgroup-undownloaded)))
6763 (when (gnus-data-unread-p (car data))
6764 (setq result (car data)
6765 data nil)))
6766 (setq data (cdr data)))
6767 result)
6768 (car data)))
6769 (goto-char (gnus-data-pos result))
6770 (gnus-data-number result)))))
6772 (defun gnus-summary-find-prev (&optional unread article)
6773 (let* ((eobp (eobp))
6774 (article (or article (gnus-summary-article-number)))
6775 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6776 result)
6777 (when (and (not eobp)
6778 (or (not gnus-summary-check-current)
6779 (not unread)
6780 (not (gnus-data-unread-p (car data)))))
6781 (setq data (cdr data)))
6782 (when (setq result
6783 (if unread
6784 (progn
6785 (while data
6786 (unless (memq (gnus-data-number (car data))
6787 (cond
6788 ((eq gnus-auto-goto-ignores
6789 'always-undownloaded)
6790 gnus-newsgroup-undownloaded)
6791 (gnus-plugged
6792 nil)
6793 ((eq gnus-auto-goto-ignores
6794 'unfetched)
6795 gnus-newsgroup-unfetched)
6796 ((eq gnus-auto-goto-ignores
6797 'undownloaded)
6798 gnus-newsgroup-undownloaded)))
6799 (when (gnus-data-unread-p (car data))
6800 (setq result (car data)
6801 data nil)))
6802 (setq data (cdr data)))
6803 result)
6804 (car data)))
6805 (goto-char (gnus-data-pos result))
6806 (gnus-data-number result))))
6808 (defun gnus-summary-find-subject (subject &optional unread backward article)
6809 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6810 (article (or article (gnus-summary-article-number)))
6811 (articles (gnus-data-list backward))
6812 (arts (gnus-data-find-list article articles))
6813 result)
6814 (when (or (not gnus-summary-check-current)
6815 (not unread)
6816 (not (gnus-data-unread-p (car arts))))
6817 (setq arts (cdr arts)))
6818 (while arts
6819 (and (or (not unread)
6820 (gnus-data-unread-p (car arts)))
6821 (vectorp (gnus-data-header (car arts)))
6822 (gnus-subject-equal
6823 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6824 (setq result (car arts)
6825 arts nil))
6826 (setq arts (cdr arts)))
6827 (and result
6828 (goto-char (gnus-data-pos result))
6829 (gnus-data-number result))))
6831 (defun gnus-summary-search-forward (&optional unread subject backward)
6832 "Search forward for an article.
6833 If UNREAD, look for unread articles. If SUBJECT, look for
6834 articles with that subject. If BACKWARD, search backward instead."
6835 (cond (subject (gnus-summary-find-subject subject unread backward))
6836 (backward (gnus-summary-find-prev unread))
6837 (t (gnus-summary-find-next unread))))
6839 (defun gnus-recenter (&optional n)
6840 "Center point in window and redisplay frame.
6841 Also do horizontal recentering."
6842 (interactive "P")
6843 (when (and gnus-auto-center-summary
6844 (not (eq gnus-auto-center-summary 'vertical)))
6845 (gnus-horizontal-recenter))
6846 (recenter-top-bottom n))
6848 (put 'gnus-recenter 'isearch-scroll t)
6850 (defun gnus-forward-line-ignore-invisible (n)
6851 "Move N lines forward (backward if N is negative).
6852 Like forward-line, but skip over (and don't count) invisible lines."
6853 (let (done)
6854 (while (and (> n 0) (not done))
6855 ;; If the following character is currently invisible,
6856 ;; skip all characters with that same `invisible' property value.
6857 (while (invisible-p (point))
6858 (goto-char (next-char-property-change (point))))
6859 (forward-line 1)
6860 (if (eobp)
6861 (setq done t)
6862 (setq n (1- n))))
6863 (while (and (< n 0) (not done))
6864 (forward-line -1)
6865 (if (bobp) (setq done t)
6866 (setq n (1+ n))
6867 (while (and (not (bobp)) (invisible-p (1- (point))))
6868 (goto-char (previous-char-property-change (point))))))))
6870 (defun gnus-summary-recenter ()
6871 "Center point in the summary window.
6872 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6873 displayed, no centering will be performed."
6874 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6875 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6876 (interactive)
6877 ;; The user has to want it.
6878 (when gnus-auto-center-summary
6879 (let* ((top (cond ((< (window-height) 4) 0)
6880 ((< (window-height) 7) 1)
6881 (t (if (numberp gnus-auto-center-summary)
6882 gnus-auto-center-summary
6883 (/ (1- (window-height)) 2)))))
6884 (height (1- (window-height)))
6885 (bottom (save-excursion
6886 (goto-char (point-max))
6887 (gnus-forward-line-ignore-invisible (- height))
6888 (point)))
6889 (window (get-buffer-window (current-buffer))))
6890 (when (get-buffer-window gnus-article-buffer)
6891 ;; Only do recentering when the article buffer is displayed,
6892 ;; Set the window start to either `bottom', which is the biggest
6893 ;; possible valid number, or the second line from the top,
6894 ;; whichever is the least.
6895 (let ((top-pos (save-excursion
6896 (gnus-forward-line-ignore-invisible (- top))
6897 (point))))
6898 (if (> bottom top-pos)
6899 ;; Keep the second line from the top visible
6900 (set-window-start window top-pos)
6901 ;; Try to keep the bottom line visible; if it's partially
6902 ;; obscured, either scroll one more line to make it fully
6903 ;; visible, or revert to using TOP-POS.
6904 (save-excursion
6905 (goto-char (point-max))
6906 (gnus-forward-line-ignore-invisible -1)
6907 (let ((last-line-start (point)))
6908 (goto-char bottom)
6909 (set-window-start window (point) t)
6910 (when (not (pos-visible-in-window-p last-line-start window))
6911 (gnus-forward-line-ignore-invisible 1)
6912 (set-window-start window (min (point) top-pos) t)))))))
6913 ;; Do horizontal recentering while we're at it.
6914 (when (and (get-buffer-window (current-buffer) t)
6915 (not (eq gnus-auto-center-summary 'vertical)))
6916 (let ((selected (selected-window)))
6917 (select-window (get-buffer-window (current-buffer) t))
6918 (gnus-summary-position-point)
6919 (gnus-horizontal-recenter)
6920 (select-window selected))))))
6922 (defun gnus-summary-jump-to-group (newsgroup)
6923 "Move point to NEWSGROUP in group mode buffer."
6924 ;; Keep update point of group mode buffer if visible.
6925 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6926 (save-window-excursion
6927 ;; Take care of tree window mode.
6928 (when (get-buffer-window gnus-group-buffer)
6929 (pop-to-buffer gnus-group-buffer))
6930 (gnus-group-jump-to-group newsgroup))
6931 (save-excursion
6932 ;; Take care of tree window mode.
6933 (if (get-buffer-window gnus-group-buffer 0)
6934 (pop-to-buffer gnus-group-buffer t)
6935 (set-buffer gnus-group-buffer))
6936 (gnus-group-jump-to-group newsgroup))))
6938 ;; This function returns a list of article numbers based on the
6939 ;; difference between the ranges of read articles in this group and
6940 ;; the range of active articles.
6941 (defun gnus-list-of-unread-articles (group)
6942 (let* ((read (gnus-info-read (gnus-get-info group)))
6943 (active (or (gnus-active group) (gnus-activate-group group)))
6944 (last (or (cdr active)
6945 (error "Group %s couldn't be activated " group)))
6946 (bottom (if gnus-newsgroup-maximum-articles
6947 (max (car active)
6948 (- last gnus-newsgroup-maximum-articles -1))
6949 (car active)))
6950 first nlast unread)
6951 ;; If none are read, then all are unread.
6952 (if (not read)
6953 (setq first bottom)
6954 ;; If the range of read articles is a single range, then the
6955 ;; first unread article is the article after the last read
6956 ;; article. Sounds logical, doesn't it?
6957 (if (and (not (listp (cdr read)))
6958 (or (< (car read) bottom)
6959 (progn (setq read (list read))
6960 nil)))
6961 (setq first (max bottom (1+ (cdr read))))
6962 ;; `read' is a list of ranges.
6963 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6964 (caar read)))
6966 (setq first bottom))
6967 (while read
6968 (when first
6969 (while (< first nlast)
6970 (setq unread (cons first unread)
6971 first (1+ first))))
6972 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6973 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6974 (setq read (cdr read)))))
6975 ;; And add the last unread articles.
6976 (while (<= first last)
6977 (setq unread (cons first unread)
6978 first (1+ first)))
6979 ;; Return the list of unread articles.
6980 (delq 0 (nreverse unread))))
6982 (defun gnus-list-of-read-articles (group)
6983 "Return a list of unread, unticked and non-dormant articles."
6984 (let* ((info (gnus-get-info group))
6985 (marked (gnus-info-marks info))
6986 (active (gnus-active group)))
6987 (and info active
6988 (gnus-list-range-difference
6989 (gnus-list-range-difference
6990 (gnus-sorted-complement
6991 (gnus-uncompress-range
6992 (if gnus-newsgroup-maximum-articles
6993 (cons (max (car active)
6994 (- (cdr active)
6995 gnus-newsgroup-maximum-articles
6996 -1))
6997 (cdr active))
6998 active))
6999 (gnus-list-of-unread-articles group))
7000 (cdr (assq 'dormant marked)))
7001 (cdr (assq 'tick marked))))))
7003 ;; This function returns a sequence of article numbers based on the
7004 ;; difference between the ranges of read articles in this group and
7005 ;; the range of active articles.
7006 (defun gnus-sequence-of-unread-articles (group)
7007 (let* ((read (gnus-info-read (gnus-get-info group)))
7008 (active (or (gnus-active group) (gnus-activate-group group)))
7009 (last (cdr active))
7010 (bottom (if gnus-newsgroup-maximum-articles
7011 (max (car active)
7012 (- last gnus-newsgroup-maximum-articles -1))
7013 (car active)))
7014 first nlast unread)
7015 ;; If none are read, then all are unread.
7016 (if (not read)
7017 (setq first bottom)
7018 ;; If the range of read articles is a single range, then the
7019 ;; first unread article is the article after the last read
7020 ;; article. Sounds logical, doesn't it?
7021 (if (and (not (listp (cdr read)))
7022 (or (< (car read) bottom)
7023 (progn (setq read (list read))
7024 nil)))
7025 (setq first (max bottom (1+ (cdr read))))
7026 ;; `read' is a list of ranges.
7027 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7028 (caar read)))
7030 (setq first bottom))
7031 (while read
7032 (when first
7033 (push (cons first nlast) unread))
7034 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7035 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7036 (setq read (cdr read)))))
7037 ;; And add the last unread articles.
7038 (cond ((not (and first last))
7039 nil)
7040 ((< first last)
7041 (push (cons first last) unread))
7042 ((= first last)
7043 (push first unread)))
7044 ;; Return the sequence of unread articles.
7045 (delq 0 (nreverse unread))))
7047 ;; Various summary commands
7049 (defun gnus-summary-select-article-buffer ()
7050 "Reconfigure windows to show the article buffer.
7051 If `gnus-widen-article-window' is set, show only the article
7052 buffer."
7053 (interactive)
7054 (if (not (gnus-buffer-live-p gnus-article-buffer))
7055 (error "There is no article buffer for this summary buffer")
7056 (or (get-buffer-window gnus-article-buffer)
7057 (eq gnus-current-article (gnus-summary-article-number))
7058 (gnus-summary-show-article))
7059 (gnus-configure-windows
7060 (if gnus-widen-article-window
7061 'only-article
7062 'article)
7064 (select-window (get-buffer-window gnus-article-buffer))))
7066 (defun gnus-summary-universal-argument (arg)
7067 "Perform any operation on all articles that are process/prefixed."
7068 (interactive "P")
7069 (let ((articles (gnus-summary-work-articles arg))
7070 func article)
7071 (if (eq
7072 (setq
7073 func
7074 (key-binding
7075 (read-key-sequence
7076 (substitute-command-keys
7077 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7078 'undefined)
7079 (gnus-error 1 "Undefined key")
7080 (save-excursion
7081 (while articles
7082 (gnus-summary-goto-subject (setq article (pop articles)))
7083 (let (gnus-newsgroup-processable)
7084 (command-execute func))
7085 (gnus-summary-remove-process-mark article)))))
7086 (gnus-summary-position-point))
7088 (define-obsolete-function-alias
7089 'gnus-summary-toggle-truncation 'toggle-truncate-lines "26.1")
7091 (defun gnus-summary-find-for-reselect ()
7092 "Return the number of an article to stay on across a reselect.
7093 The current article is considered, then following articles, then previous
7094 articles. An article is sought which is not canceled and isn't a temporary
7095 insertion from another group. If there's no such then return a dummy 0."
7096 (let (found)
7097 (dolist (rev '(nil t))
7098 (unless found ; don't demand the reverse list if we don't need it
7099 (let ((data (gnus-data-find-list
7100 (gnus-summary-article-number) (gnus-data-list rev))))
7101 (while (and data (not found))
7102 (if (and (< 0 (gnus-data-number (car data)))
7103 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7104 (setq found (gnus-data-number (car data))))
7105 (setq data (cdr data))))))
7106 (or found 0)))
7108 (defun gnus-summary-reselect-current-group (&optional all rescan)
7109 "Exit and then reselect the current newsgroup.
7110 The prefix argument ALL means to select all articles."
7111 (interactive "P")
7112 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7113 (error "Ephemeral groups can't be reselected"))
7114 (let ((current-subject (gnus-summary-find-for-reselect))
7115 (group gnus-newsgroup-name))
7116 (setq gnus-newsgroup-begin nil)
7117 (gnus-summary-exit nil 'leave-hidden)
7118 ;; We have to adjust the point of group mode buffer because
7119 ;; point was moved to the next unread newsgroup by exiting.
7120 (gnus-summary-jump-to-group group)
7121 (when rescan
7122 (save-excursion
7123 (gnus-group-get-new-news-this-group 1)))
7124 (gnus-group-read-group all t)
7125 (gnus-summary-goto-subject current-subject nil t)))
7127 (defun gnus-summary-rescan-group (&optional all)
7128 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7129 (interactive "P")
7130 (let ((config gnus-current-window-configuration))
7131 (gnus-summary-reselect-current-group all t)
7132 (gnus-configure-windows config)
7133 (when (eq config 'article)
7134 (gnus-summary-select-article))))
7136 (defun gnus-summary-update-info (&optional non-destructive)
7137 (save-excursion
7138 (let ((group gnus-newsgroup-name))
7139 (when group
7140 (when gnus-newsgroup-kill-headers
7141 (setq gnus-newsgroup-killed
7142 (gnus-compress-sequence
7143 (gnus-sorted-union
7144 (gnus-list-range-intersection
7145 gnus-newsgroup-unselected gnus-newsgroup-killed)
7146 gnus-newsgroup-unreads)
7147 t)))
7148 (unless (listp (cdr gnus-newsgroup-killed))
7149 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7150 (let ((headers gnus-newsgroup-headers)
7151 (ephemeral-p (gnus-ephemeral-group-p group))
7152 info)
7153 (unless ephemeral-p
7154 (setq info (copy-sequence (gnus-get-info group))
7155 info (delq (gnus-info-params info) info)))
7156 ;; Set the new ranges of read articles.
7157 (with-current-buffer gnus-group-buffer
7158 (gnus-undo-force-boundary))
7159 (gnus-update-read-articles
7160 group (gnus-sorted-union
7161 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7162 ;; Set the current article marks.
7163 (let ((gnus-newsgroup-scored
7164 (if (and (not gnus-save-score)
7165 (not non-destructive))
7167 gnus-newsgroup-scored)))
7168 (save-excursion
7169 (gnus-update-marks)))
7170 ;; Do the cross-ref thing.
7171 (when gnus-use-cross-reference
7172 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7173 ;; Do not switch windows but change the buffer to work.
7174 (set-buffer gnus-group-buffer)
7175 (unless ephemeral-p
7176 (gnus-group-update-group
7177 group nil
7178 (equal info
7179 (setq info (copy-sequence (gnus-get-info group))
7180 info (delq (gnus-info-params info) info))))))))))
7182 (defun gnus-summary-save-newsrc (&optional force)
7183 "Save the current number of read/marked articles in the dribble buffer.
7184 The dribble buffer will then be saved.
7185 If FORCE (the prefix), also save the .newsrc file(s)."
7186 (interactive "P")
7187 (gnus-summary-update-info t)
7188 (if force
7189 (gnus-save-newsrc-file)
7190 (gnus-dribble-save)))
7192 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7193 (declare-function gnus-article-stop-animations "gnus-art" ())
7195 (defun gnus-summary-exit (&optional temporary leave-hidden)
7196 "Exit reading current newsgroup, and then return to group selection mode.
7197 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7198 (interactive)
7199 (gnus-set-global-variables)
7200 (when (gnus-buffer-live-p gnus-article-buffer)
7201 (with-current-buffer gnus-article-buffer
7202 (mm-destroy-parts gnus-article-mime-handles)
7203 ;; Set it to nil for safety reason.
7204 (setq gnus-article-mime-handle-alist nil)
7205 (setq gnus-article-mime-handles nil)))
7206 (gnus-kill-save-kill-buffer)
7207 (gnus-async-halt-prefetch)
7208 (let* ((group gnus-newsgroup-name)
7209 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7210 (gnus-group-is-exiting-p t)
7211 (article-buffer gnus-article-buffer)
7212 (original-article-buffer gnus-original-article-buffer)
7213 (mode major-mode)
7214 (group-point nil)
7215 (buf (current-buffer))
7216 ;; `gnus-single-article-buffer' is nil buffer-locally in
7217 ;; ephemeral group of which summary buffer will be killed,
7218 ;; but the global value may be non-nil.
7219 (single-article-buffer gnus-single-article-buffer))
7220 (unless quit-config
7221 ;; Do adaptive scoring, and possibly save score files.
7222 (when gnus-newsgroup-adaptive
7223 (gnus-score-adaptive))
7224 (when gnus-use-scoring
7225 (gnus-score-save)))
7226 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7227 (when gnus-use-cache
7228 (gnus-cache-possibly-remove-articles)
7229 (gnus-cache-save-buffers))
7230 (gnus-async-prefetch-remove-group group)
7231 (when gnus-suppress-duplicates
7232 (gnus-dup-enter-articles))
7233 (when gnus-use-trees
7234 (gnus-tree-close))
7235 (when gnus-use-cache
7236 (gnus-cache-write-active))
7237 ;; Remove entries for this group.
7238 (nnmail-purge-split-history (gnus-group-real-name group))
7239 ;; Make all changes in this group permanent.
7240 (unless quit-config
7241 (gnus-run-hooks 'gnus-exit-group-hook)
7242 (gnus-summary-update-info))
7243 (gnus-close-group group)
7244 ;; Make sure where we were, and go to next newsgroup.
7245 (when (buffer-live-p (get-buffer gnus-group-buffer))
7246 (set-buffer gnus-group-buffer))
7247 (unless quit-config
7248 (gnus-group-jump-to-group group))
7249 (gnus-run-hooks 'gnus-summary-exit-hook)
7250 (unless (or quit-config
7251 (not gnus-summary-next-group-on-exit)
7252 ;; If this group has disappeared from the summary
7253 ;; buffer, don't skip forwards.
7254 (not (string= group (gnus-group-group-name))))
7255 (gnus-group-next-unread-group 1))
7256 (setq group-point (point))
7257 (gnus-article-stop-animations)
7258 (if temporary
7259 nil ;Nothing to do.
7260 (set-buffer buf)
7261 (if (not gnus-kill-summary-on-exit)
7262 (progn
7263 (gnus-deaden-summary)
7264 (setq mode nil))
7265 (when (get-buffer gnus-article-buffer)
7266 (bury-buffer gnus-article-buffer))
7267 ;; Return to group mode buffer.
7268 (when (eq mode 'gnus-summary-mode)
7269 (gnus-kill-buffer buf)))
7271 (setq gnus-current-select-method gnus-select-method)
7272 (when (gnus-buffer-live-p gnus-group-buffer)
7273 (set-buffer gnus-group-buffer))
7274 (if quit-config
7275 (gnus-handle-ephemeral-exit quit-config)
7276 (goto-char group-point)
7277 ;; If gnus-group-buffer is already displayed, make sure we also move
7278 ;; the cursor in the window that displays it.
7279 (let ((win (get-buffer-window (current-buffer) 0)))
7280 (if win (set-window-point win (point))))
7281 (unless leave-hidden
7282 (gnus-configure-windows 'group 'force)))
7284 ;; If we have several article buffers, we kill them at exit.
7285 (unless single-article-buffer
7286 (when (gnus-buffer-live-p article-buffer)
7287 (with-current-buffer article-buffer
7288 ;; Don't kill sticky article buffers
7289 (unless (eq major-mode 'gnus-sticky-article-mode)
7290 (gnus-kill-buffer article-buffer)
7291 (setq gnus-article-current nil))))
7292 (gnus-kill-buffer original-article-buffer))
7294 ;; Clear the current group name.
7295 (unless quit-config
7296 (setq gnus-newsgroup-name nil)))))
7298 (declare-function gnus-stop-downloads "gnus-art" ())
7300 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7301 (defun gnus-summary-exit-no-update (&optional no-questions)
7302 "Quit reading current newsgroup without updating read article info."
7303 (interactive)
7304 (let* ((group gnus-newsgroup-name)
7305 (gnus-group-is-exiting-p t)
7306 (gnus-group-is-exiting-without-update-p t)
7307 (quit-config (gnus-group-quit-config group)))
7308 (when (or no-questions
7309 (gnus-ephemeral-group-p group)
7310 gnus-expert-user
7311 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7312 (gnus-async-halt-prefetch)
7313 (run-hooks 'gnus-summary-prepare-exit-hook)
7314 (when (gnus-buffer-live-p gnus-article-buffer)
7315 (with-current-buffer gnus-article-buffer
7316 (gnus-article-stop-animations)
7317 (gnus-stop-downloads)
7318 (mm-destroy-parts gnus-article-mime-handles)
7319 ;; Set it to nil for safety reason.
7320 (setq gnus-article-mime-handle-alist nil)
7321 (setq gnus-article-mime-handles nil)))
7322 ;; If we have several article buffers, we kill them at exit.
7323 (unless gnus-single-article-buffer
7324 (gnus-kill-buffer gnus-article-buffer)
7325 (gnus-kill-buffer gnus-original-article-buffer)
7326 (setq gnus-article-current nil))
7327 ;; Return to the group buffer.
7328 (if (not gnus-kill-summary-on-exit)
7329 (progn
7330 (gnus-deaden-summary)
7331 (gnus-configure-windows 'group 'force))
7332 (gnus-configure-windows 'group 'force)
7333 (gnus-close-group group)
7334 (gnus-kill-buffer gnus-summary-buffer))
7335 (unless gnus-single-article-buffer
7336 (setq gnus-article-current nil))
7337 (when gnus-use-trees
7338 (gnus-tree-close))
7339 (gnus-async-prefetch-remove-group group)
7340 (when (get-buffer gnus-article-buffer)
7341 (bury-buffer gnus-article-buffer))
7342 ;; Clear the current group name.
7343 (setq gnus-newsgroup-name nil)
7344 (unless (gnus-ephemeral-group-p group)
7345 (gnus-group-update-group group nil t))
7346 (when (equal (gnus-group-group-name) group)
7347 (gnus-group-next-unread-group 1))
7348 (gnus-article-stop-animations)
7349 (when quit-config
7350 (gnus-handle-ephemeral-exit quit-config)))))
7352 (defun gnus-handle-ephemeral-exit (quit-config)
7353 "Handle movement when leaving an ephemeral group.
7354 The state which existed when entering the ephemeral is reset."
7355 (if (not (buffer-live-p (car quit-config)))
7356 (when (gnus-buffer-live-p gnus-group-buffer)
7357 (gnus-configure-windows 'group 'force))
7358 (set-buffer (car quit-config))
7359 (unless (eq (cdr quit-config) 'group)
7360 (setq gnus-current-select-method
7361 (gnus-find-method-for-group gnus-newsgroup-name)))
7362 (cond ((derived-mode-p 'gnus-summary-mode)
7363 (gnus-set-global-variables))
7364 ((derived-mode-p 'gnus-article-mode)
7365 (save-current-buffer
7366 ;; The `gnus-summary-buffer' variable may point
7367 ;; to the old summary buffer when using a single
7368 ;; article buffer.
7369 (unless (gnus-buffer-live-p gnus-summary-buffer)
7370 (set-buffer gnus-group-buffer))
7371 (set-buffer gnus-summary-buffer)
7372 (gnus-set-global-variables))))
7373 (if (or (eq (cdr quit-config) 'article)
7374 (eq (cdr quit-config) 'pick))
7375 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7376 (gnus-configure-windows 'pick 'force)
7377 (gnus-configure-windows (cdr quit-config) 'force))
7378 (gnus-configure-windows (cdr quit-config) 'force))
7379 (when (derived-mode-p 'gnus-summary-mode)
7380 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7381 next-unread-noselect))
7382 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7383 'next-noselect)
7384 (gnus-summary-next-subject 1 nil t))
7385 ((eq gnus-auto-select-on-ephemeral-exit
7386 'next-unread-noselect)
7387 (gnus-summary-next-subject 1 t t))))
7388 ;; Hide the article buffer which displays the article different
7389 ;; from the one that the cursor points to in the summary buffer.
7390 (gnus-configure-windows 'summary 'force))
7391 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7392 (gnus-summary-next-subject 1))
7393 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7394 (gnus-summary-next-subject 1 t))))
7395 (gnus-summary-recenter)
7396 (gnus-summary-position-point))))
7398 ;;; Dead summaries.
7400 (defvar gnus-dead-summary-mode-map
7401 (let ((map (make-keymap)))
7402 (suppress-keymap map)
7403 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7404 (dolist (key '("\C-d" "\r" "\177" [delete]))
7405 (define-key map key 'gnus-summary-wake-up-the-dead))
7406 (dolist (key '("q" "Q"))
7407 (define-key map key 'bury-buffer))
7408 map))
7410 (define-minor-mode gnus-dead-summary-mode
7411 "Minor mode for Gnus summary buffers."
7412 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7413 (unless (derived-mode-p 'gnus-summary-mode)
7414 (setq gnus-dead-summary-mode nil)))
7416 (defun gnus-deaden-summary ()
7417 "Make the current summary buffer into a dead summary buffer."
7418 ;; Kill any previous dead summary buffer.
7419 (when (and gnus-dead-summary
7420 (buffer-name gnus-dead-summary))
7421 (with-current-buffer gnus-dead-summary
7422 (when gnus-dead-summary-mode
7423 (kill-buffer (current-buffer)))))
7424 ;; Make this the current dead summary.
7425 (setq gnus-dead-summary (current-buffer))
7426 (gnus-dead-summary-mode 1)
7427 (let ((name (buffer-name)))
7428 (when (string-match "Summary" name)
7429 (rename-buffer
7430 (concat (substring name 0 (match-beginning 0)) "Dead "
7431 (substring name (match-beginning 0)))
7433 (bury-buffer))))
7435 (defun gnus-kill-or-deaden-summary (buffer)
7436 "Kill or deaden the summary BUFFER."
7437 (save-excursion
7438 (when (and (buffer-name buffer)
7439 (not gnus-single-article-buffer))
7440 (with-current-buffer buffer
7441 (gnus-kill-buffer gnus-article-buffer)
7442 (gnus-kill-buffer gnus-original-article-buffer)))
7443 (cond
7444 ;; Kill the buffer.
7445 (gnus-kill-summary-on-exit
7446 (when (and gnus-use-trees
7447 (gnus-buffer-exists-p buffer))
7448 (with-current-buffer buffer
7449 (gnus-tree-close)))
7450 (gnus-kill-buffer buffer))
7451 ;; Deaden the buffer.
7452 ((gnus-buffer-exists-p buffer)
7453 (with-current-buffer buffer
7454 (gnus-deaden-summary))))))
7456 (defun gnus-summary-wake-up-the-dead (&rest args)
7457 "Wake up the dead summary buffer."
7458 (interactive)
7459 (gnus-dead-summary-mode -1)
7460 (let ((name (buffer-name)))
7461 (when (string-match "Dead " name)
7462 (rename-buffer
7463 (concat (substring name 0 (match-beginning 0))
7464 (substring name (match-end 0)))
7465 t)))
7466 (gnus-message 3 "This dead summary is now alive again"))
7468 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7469 (defun gnus-summary-describe-group (&optional force)
7470 "Describe the current newsgroup."
7471 (interactive "P")
7472 (gnus-group-describe-group force gnus-newsgroup-name))
7474 (defun gnus-summary-describe-briefly ()
7475 "Describe summary mode commands briefly."
7476 (interactive)
7477 (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")))
7479 ;; Walking around group mode buffer from summary mode.
7481 (defun gnus-summary-next-group (&optional no-article target-group backward)
7482 "Exit current newsgroup and then select next unread newsgroup.
7483 If prefix argument NO-ARTICLE is non-nil, no article is selected
7484 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7485 previous group instead."
7486 (interactive "P")
7487 ;; Stop pre-fetching.
7488 (gnus-async-halt-prefetch)
7489 (let ((current-group gnus-newsgroup-name)
7490 (current-buffer (current-buffer))
7491 entered)
7492 ;; First we semi-exit this group to update Xrefs and all variables.
7493 ;; We can't do a real exit, because the window conf must remain
7494 ;; the same in case the user is prompted for info, and we don't
7495 ;; want the window conf to change before that...
7496 (gnus-summary-exit t)
7497 (while (not entered)
7498 ;; Then we find what group we are supposed to enter.
7499 (set-buffer gnus-group-buffer)
7500 (gnus-group-jump-to-group current-group)
7501 (setq target-group
7502 (or target-group
7503 (if (eq gnus-keep-same-level 'best)
7504 (gnus-summary-best-group gnus-newsgroup-name)
7505 (gnus-summary-search-group backward gnus-keep-same-level))))
7506 (if (not target-group)
7507 ;; There are no further groups, so we return to the group
7508 ;; buffer.
7509 (progn
7510 (gnus-message 5 "Returning to the group buffer")
7511 (setq entered t)
7512 (when (gnus-buffer-live-p current-buffer)
7513 (set-buffer current-buffer)
7514 (gnus-summary-exit))
7515 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7516 ;; We try to enter the target group.
7517 (gnus-group-jump-to-group target-group)
7518 (let ((unreads (gnus-group-group-unread)))
7519 (if (and (or (eq t unreads)
7520 (and unreads (not (zerop unreads))))
7521 (gnus-summary-read-group
7522 target-group nil no-article
7523 (and (buffer-name current-buffer) current-buffer)
7524 nil backward))
7525 (setq entered t)
7526 (setq current-group target-group
7527 target-group nil)))))))
7529 (defun gnus-summary-prev-group (&optional no-article)
7530 "Exit current newsgroup and then select previous unread newsgroup.
7531 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7532 (interactive "P")
7533 (gnus-summary-next-group no-article nil t))
7535 ;; Walking around summary lines.
7537 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7538 "Go to the first subject satisfying any non-nil constraint.
7539 If UNREAD is non-nil, the article should be unread.
7540 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7541 If UNSEEN is non-nil, the article should be unseen as well as unread.
7542 Returns the article selected or nil if there are no matching articles."
7543 (interactive "P")
7544 (cond
7545 ;; Empty summary.
7546 ((null gnus-newsgroup-data)
7547 (gnus-message 3 "No articles in the group")
7548 nil)
7549 ;; Pick the first article.
7550 ((not (or unread undownloaded unseen))
7551 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7552 (gnus-data-number (car gnus-newsgroup-data)))
7553 ;; Find the first unread article.
7555 (let ((data gnus-newsgroup-data))
7556 (while (and data
7557 (let ((num (gnus-data-number (car data))))
7558 (or (memq num gnus-newsgroup-unfetched)
7559 (not (or (and unread
7560 (memq num gnus-newsgroup-unreads))
7561 (and undownloaded
7562 (memq num gnus-newsgroup-undownloaded))
7563 (and unseen
7564 (memq num gnus-newsgroup-unseen)
7565 (memq num gnus-newsgroup-unreads)))))))
7566 (setq data (cdr data)))
7567 (prog1
7568 (if data
7569 (progn
7570 (goto-char (gnus-data-pos (car data)))
7571 (gnus-data-number (car data)))
7572 (gnus-message 3 "No more%s articles"
7573 (let* ((r (when unread " unread"))
7574 (d (when undownloaded " undownloaded"))
7575 (s (when unseen " unseen"))
7576 (l (delq nil (list r d s))))
7577 (cond ((= 3 (length l))
7578 (concat r "," d ", or" s))
7579 ((= 2 (length l))
7580 (concat (car l) ", or" (cadr l)))
7581 ((= 1 (length l))
7582 (car l))
7584 ""))))
7587 (gnus-summary-position-point))))))
7589 (defun gnus-summary-next-subject (n &optional unread dont-display)
7590 "Go to next N'th summary line.
7591 If N is negative, go to the previous N'th subject line.
7592 If UNREAD is non-nil, only unread articles are selected.
7593 The difference between N and the actual number of steps taken is
7594 returned."
7595 (interactive "p")
7596 (let ((backward (< n 0))
7597 (n (abs n)))
7598 (while (and (> n 0)
7599 (if backward
7600 (gnus-summary-find-prev unread)
7601 (gnus-summary-find-next unread)))
7602 (unless (zerop (setq n (1- n)))
7603 (gnus-summary-show-thread)))
7604 (when (/= 0 n)
7605 (gnus-message 7 "No more%s articles"
7606 (if unread " unread" "")))
7607 (unless dont-display
7608 (gnus-summary-recenter)
7609 (gnus-summary-position-point))
7612 (defun gnus-summary-next-unread-subject (n)
7613 "Go to next N'th unread summary line."
7614 (interactive "p")
7615 (gnus-summary-next-subject n t))
7617 (defun gnus-summary-prev-subject (n &optional unread)
7618 "Go to previous N'th summary line.
7619 If optional argument UNREAD is non-nil, only unread article is selected."
7620 (interactive "p")
7621 (gnus-summary-next-subject (- n) unread))
7623 (defun gnus-summary-prev-unread-subject (n)
7624 "Go to previous N'th unread summary line."
7625 (interactive "p")
7626 (gnus-summary-next-subject (- n) t))
7628 (defun gnus-summary-goto-subjects (articles)
7629 "Insert the subject header for ARTICLES in the current buffer."
7630 (save-excursion
7631 (dolist (article articles)
7632 (gnus-summary-goto-subject article t)))
7633 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7634 (gnus-summary-position-point))
7636 (defun gnus-summary-goto-subject (article &optional force silent)
7637 "Go to the subject line of ARTICLE.
7638 If FORCE, also allow jumping to articles not currently shown."
7639 (interactive "nArticle number: ")
7640 (unless (numberp article)
7641 (error "Article %s is not a number" article))
7642 (let ((b (point))
7643 (data (gnus-data-find article)))
7644 ;; We read in the article if we have to.
7645 (and (not data)
7646 force
7647 (gnus-summary-insert-subject
7648 article
7649 (if (or (numberp force) (vectorp force)) force)
7651 (setq data (gnus-data-find article)))
7652 (goto-char b)
7653 (if (not data)
7654 (progn
7655 (unless silent
7656 (gnus-message 3 "Can't find article %d" article))
7657 nil)
7658 (let ((pt (gnus-data-pos data)))
7659 (goto-char pt)
7660 (gnus-summary-set-article-display-arrow pt))
7661 (gnus-summary-position-point)
7662 article)))
7664 ;; Walking around summary lines with displaying articles.
7666 (defun gnus-summary-expand-window (&optional arg)
7667 "Make the summary buffer take up the entire Emacs frame.
7668 Given a prefix, will force an `article' buffer configuration."
7669 (interactive "P")
7670 (if arg
7671 (gnus-configure-windows 'article 'force)
7672 (gnus-configure-windows 'summary 'force)))
7674 (defun gnus-summary-display-article (article &optional all-header)
7675 "Display ARTICLE in article buffer."
7676 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7677 (with-current-buffer gnus-article-buffer
7678 (derived-mode-p 'gnus-article-mode)))
7679 (gnus-article-setup-buffer))
7680 (gnus-set-global-variables)
7681 (with-current-buffer gnus-article-buffer
7682 (setq gnus-article-charset gnus-newsgroup-charset)
7683 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7684 (mm-enable-multibyte))
7685 (if (null article)
7687 (prog1
7688 (if gnus-summary-display-article-function
7689 (funcall gnus-summary-display-article-function article all-header)
7690 (gnus-article-prepare article all-header))
7691 (gnus-run-hooks 'gnus-select-article-hook)
7692 (when (and gnus-current-article
7693 (not (zerop gnus-current-article)))
7694 (gnus-summary-goto-subject gnus-current-article))
7695 (gnus-summary-recenter)
7696 (when (and gnus-use-trees gnus-show-threads)
7697 (gnus-possibly-generate-tree article)
7698 (gnus-highlight-selected-tree article))
7699 ;; Successfully display article.
7700 (gnus-article-set-window-start
7701 (cdr (assq article gnus-newsgroup-bookmarks))))))
7703 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7704 "Select the current article.
7705 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7706 non-nil, the article will be re-fetched even if it already present in
7707 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7708 be displayed."
7709 ;; Make sure we are in the summary buffer to work around bbdb bug.
7710 (unless (derived-mode-p 'gnus-summary-mode)
7711 (set-buffer gnus-summary-buffer))
7712 (let ((article (or article (gnus-summary-article-number)))
7713 (all-headers (not (not all-headers))) ;Must be t or nil.
7714 gnus-summary-display-article-function)
7715 (and (not pseudo)
7716 (gnus-summary-article-pseudo-p article)
7717 (error "This is a pseudo-article"))
7718 (with-current-buffer gnus-summary-buffer
7719 (if (or (and gnus-single-article-buffer
7720 (or (null gnus-current-article)
7721 (null gnus-article-current)
7722 (null (get-buffer gnus-article-buffer))
7723 (not (eq article (cdr gnus-article-current)))
7724 (not (equal (car gnus-article-current)
7725 gnus-newsgroup-name))
7726 (not (get-buffer gnus-original-article-buffer))))
7727 (and (not gnus-single-article-buffer)
7728 (or (null gnus-current-article)
7729 (not (get-buffer gnus-original-article-buffer))
7730 (not (eq gnus-current-article article))))
7731 force)
7732 ;; The requested article is different from the current article.
7733 (progn
7734 (gnus-summary-display-article article all-headers)
7735 (when (gnus-buffer-live-p gnus-article-buffer)
7736 (with-current-buffer gnus-article-buffer
7737 (if (not gnus-article-decoded-p) ;; a local variable
7738 (mm-disable-multibyte))))
7739 (gnus-article-set-window-start
7740 (cdr (assq article gnus-newsgroup-bookmarks)))
7741 article)
7742 'old))))
7744 (defun gnus-summary-force-verify-and-decrypt ()
7745 "Display buttons for signed/encrypted parts and verify/decrypt them."
7746 (interactive)
7747 (let ((mm-verify-option 'known)
7748 (mm-decrypt-option 'known)
7749 (gnus-article-emulate-mime t)
7750 (gnus-buttonized-mime-types (append (list "multipart/signed"
7751 "multipart/encrypted")
7752 gnus-buttonized-mime-types)))
7753 (gnus-summary-select-article nil 'force)))
7755 (defun gnus-summary-next-article (&optional unread subject backward push)
7756 "Select the next article.
7757 If UNREAD, only unread articles are selected.
7758 If SUBJECT, only articles with SUBJECT are selected.
7759 If BACKWARD, the previous article is selected instead of the next."
7760 (interactive "P")
7761 ;; Make sure we are in the summary buffer.
7762 (unless (derived-mode-p 'gnus-summary-mode)
7763 (set-buffer gnus-summary-buffer))
7764 (cond
7765 ;; Is there such an article?
7766 ((and (gnus-summary-search-forward unread subject backward)
7767 (or (gnus-summary-display-article (gnus-summary-article-number))
7768 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7769 (gnus-summary-position-point))
7770 ;; If not, we try the first unread, if that is wanted.
7771 ((and subject
7772 gnus-auto-select-same
7773 (gnus-summary-first-unread-article))
7774 (gnus-summary-position-point)
7775 (gnus-message 6 "Wrapped"))
7776 ;; Try to get next/previous article not displayed in this group.
7777 ((and gnus-auto-extend-newsgroup
7778 (not unread) (not subject))
7779 (gnus-summary-goto-article
7780 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7781 nil (count-lines (point-min) (point))))
7782 ;; Go to next/previous group.
7784 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7785 (gnus-summary-jump-to-group gnus-newsgroup-name))
7786 (let ((cmd last-command-event)
7787 (point
7788 (with-current-buffer gnus-group-buffer
7789 (point)))
7790 (current-summary (current-buffer))
7791 (group
7792 (if (eq gnus-keep-same-level 'best)
7793 (gnus-summary-best-group gnus-newsgroup-name)
7794 (gnus-summary-search-group backward gnus-keep-same-level))))
7795 ;; Select next unread newsgroup automagically.
7796 (cond
7797 ((or (not gnus-auto-select-next)
7798 (not cmd))
7799 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7800 ((or (eq gnus-auto-select-next 'quietly)
7801 (and (eq gnus-auto-select-next 'slightly-quietly)
7802 push)
7803 (and (eq gnus-auto-select-next 'almost-quietly)
7804 (gnus-summary-last-article-p)))
7805 ;; Select quietly.
7806 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7807 (gnus-summary-exit)
7808 (gnus-message 7 "No more%s articles (%s)..."
7809 (if unread " unread" "")
7810 (if group (concat "selecting " group)
7811 "exiting"))
7812 (gnus-summary-next-group nil group backward)))
7814 (when (numberp last-input-event)
7815 ;; Somehow or other, we may now have selected a different
7816 ;; window. Make point go back to the summary buffer.
7817 (when (eq current-summary (current-buffer))
7818 ;; FIXME: This burps when get-buffer-window returns nil.
7819 (select-window (get-buffer-window current-summary 0)))
7820 (gnus-summary-walk-group-buffer
7821 gnus-newsgroup-name cmd unread backward point))))))))
7823 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7824 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7825 (?\C-p (gnus-group-prev-unread-group 1))))
7826 (cursor-in-echo-area t)
7827 keve key group ended prompt)
7828 (with-current-buffer gnus-group-buffer
7829 (goto-char start)
7830 (setq group
7831 (if (eq gnus-keep-same-level 'best)
7832 (gnus-summary-best-group gnus-newsgroup-name)
7833 (gnus-summary-search-group backward gnus-keep-same-level))))
7834 (while (not ended)
7835 (setq prompt
7836 (format
7837 "No more%s articles%s " (if unread " unread" "")
7838 (if (and group
7839 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7840 (format " (Type %s for %s [%s])"
7841 (single-key-description cmd)
7842 (gnus-group-decoded-name group)
7843 (gnus-group-unread group))
7844 (format " (Type %s to exit %s)"
7845 (single-key-description cmd)
7846 (gnus-group-decoded-name gnus-newsgroup-name)))))
7847 ;; Confirm auto selection.
7848 (setq key (car (setq keve (gnus-read-event-char prompt)))
7849 ended t)
7850 (cond
7851 ((assq key keystrokes)
7852 (let ((obuf (current-buffer)))
7853 (switch-to-buffer gnus-group-buffer)
7854 (when group
7855 (gnus-group-jump-to-group group))
7856 (eval (cadr (assq key keystrokes)))
7857 (setq group (gnus-group-group-name))
7858 (switch-to-buffer obuf))
7859 (setq ended nil))
7860 ((equal key cmd)
7861 (if (or (not group)
7862 (gnus-ephemeral-group-p gnus-newsgroup-name))
7863 (gnus-summary-exit)
7864 (gnus-summary-next-group nil group backward)))
7866 (push (cdr keve) unread-command-events))))))
7868 (defun gnus-summary-next-unread-article ()
7869 "Select unread article after current one."
7870 (interactive)
7871 (gnus-summary-next-article
7872 (or (not (eq gnus-summary-goto-unread 'never))
7873 (gnus-summary-last-article-p (gnus-summary-article-number)))
7874 (and gnus-auto-select-same
7875 (gnus-summary-article-subject))))
7877 (defun gnus-summary-prev-article (&optional unread subject)
7878 "Select the article before the current one.
7879 If UNREAD is non-nil, only unread articles are selected."
7880 (interactive "P")
7881 (gnus-summary-next-article unread subject t))
7883 (defun gnus-summary-prev-unread-article ()
7884 "Select unread article before current one."
7885 (interactive)
7886 (gnus-summary-prev-article
7887 (or (not (eq gnus-summary-goto-unread 'never))
7888 (gnus-summary-first-article-p (gnus-summary-article-number)))
7889 (and gnus-auto-select-same
7890 (gnus-summary-article-subject))))
7892 (declare-function gnus-article-only-boring-p "gnus-art" ())
7894 (defun gnus-summary-next-page (&optional lines circular stop)
7895 "Show next page of the selected article.
7896 If at the end of the current article, select the next article.
7897 LINES says how many lines should be scrolled up.
7899 If CIRCULAR is non-nil, go to the start of the article instead of
7900 selecting the next article when reaching the end of the current
7901 article.
7903 If STOP is non-nil, just stop when reaching the end of the message.
7905 Also see the variable `gnus-article-skip-boring'."
7906 (interactive "P")
7907 (gnus-set-global-variables)
7908 (let ((article (gnus-summary-article-number))
7909 (article-window (get-buffer-window gnus-article-buffer t))
7910 endp)
7911 ;; If the buffer is empty, we have no article.
7912 (unless article
7913 (error "No article to select"))
7914 (gnus-configure-windows 'article)
7915 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7916 (if (and (eq gnus-summary-goto-unread 'never)
7917 (not (gnus-summary-last-article-p article)))
7918 (gnus-summary-next-article)
7919 (gnus-summary-next-unread-article))
7920 (if (or (null gnus-current-article)
7921 (null gnus-article-current)
7922 (/= article (cdr gnus-article-current))
7923 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7924 ;; Selected subject is different from current article's.
7925 (gnus-summary-display-article article)
7926 (when article-window
7927 (gnus-eval-in-buffer-window gnus-article-buffer
7928 (setq endp (or (gnus-article-next-page lines)
7929 (gnus-article-only-boring-p))))
7930 (when endp
7931 (cond ((or stop gnus-summary-stop-at-end-of-message)
7932 (gnus-message 3 "End of message"))
7933 (circular
7934 (gnus-summary-beginning-of-article))
7935 (lines
7936 (gnus-message 3 "End of message"))
7937 ((null lines)
7938 (if (and (eq gnus-summary-goto-unread 'never)
7939 (not (gnus-summary-last-article-p article)))
7940 (gnus-summary-next-article)
7941 (gnus-summary-next-unread-article))))))))
7942 (gnus-summary-recenter)
7943 (gnus-summary-position-point)))
7945 (defun gnus-summary-prev-page (&optional lines move)
7946 "Show previous page of selected article.
7947 Argument LINES specifies lines to be scrolled down.
7948 If MOVE, move to the previous unread article if point is at
7949 the beginning of the buffer."
7950 (interactive "P")
7951 (let ((article (gnus-summary-article-number))
7952 (article-window (get-buffer-window gnus-article-buffer t))
7953 endp)
7954 (gnus-configure-windows 'article)
7955 (if (or (null gnus-current-article)
7956 (null gnus-article-current)
7957 (/= article (cdr gnus-article-current))
7958 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7959 ;; Selected subject is different from current article's.
7960 (gnus-summary-display-article article)
7961 (gnus-summary-recenter)
7962 (when article-window
7963 (gnus-eval-in-buffer-window gnus-article-buffer
7964 (setq endp (gnus-article-prev-page lines)))
7965 (when (and move endp)
7966 (cond (lines
7967 (gnus-message 3 "Beginning of message"))
7968 ((null lines)
7969 (if (and (eq gnus-summary-goto-unread 'never)
7970 (not (gnus-summary-first-article-p article)))
7971 (gnus-summary-prev-article)
7972 (gnus-summary-prev-unread-article))))))))
7973 (gnus-summary-position-point))
7975 (defun gnus-summary-prev-page-or-article (&optional lines)
7976 "Show previous page of selected article.
7977 Argument LINES specifies lines to be scrolled down.
7978 If at the beginning of the article, go to the next article."
7979 (interactive "P")
7980 (gnus-summary-prev-page lines t))
7982 (defun gnus-summary-scroll-up (lines)
7983 "Scroll up (or down) one line current article.
7984 Argument LINES specifies lines to be scrolled up (or down if negative).
7985 If no article is selected, then the current article will be selected first."
7986 (interactive "p")
7987 (gnus-configure-windows 'article)
7988 (gnus-summary-show-thread)
7989 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7990 (gnus-eval-in-buffer-window gnus-article-buffer
7991 (cond ((> lines 0)
7992 (when (gnus-article-next-page lines)
7993 (gnus-message 3 "End of message")))
7994 ((< lines 0)
7995 (gnus-article-prev-page (- lines))))))
7996 (gnus-summary-recenter)
7997 (gnus-summary-position-point))
7999 (defun gnus-summary-scroll-down (lines)
8000 "Scroll down (or up) one line current article.
8001 Argument LINES specifies lines to be scrolled down (or up if negative).
8002 If no article is selected, then the current article will be selected first."
8003 (interactive "p")
8004 (gnus-summary-scroll-up (- lines)))
8006 (defun gnus-summary-next-same-subject ()
8007 "Select next article which has the same subject as current one."
8008 (interactive)
8009 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8011 (defun gnus-summary-prev-same-subject ()
8012 "Select previous article which has the same subject as current one."
8013 (interactive)
8014 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8016 (defun gnus-summary-next-unread-same-subject ()
8017 "Select next unread article which has the same subject as current one."
8018 (interactive)
8019 (gnus-summary-next-article t (gnus-summary-article-subject)))
8021 (defun gnus-summary-prev-unread-same-subject ()
8022 "Select previous unread article which has the same subject as current one."
8023 (interactive)
8024 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8026 (defun gnus-summary-first-unread-article ()
8027 "Select the first unread article.
8028 Return nil if there are no unread articles."
8029 (interactive)
8030 (prog1
8031 (when (gnus-summary-first-subject t)
8032 (gnus-summary-show-thread)
8033 (gnus-summary-first-subject t)
8034 (gnus-summary-display-article (gnus-summary-article-number)))
8035 (gnus-summary-position-point)))
8037 (defun gnus-summary-first-unread-subject ()
8038 "Place the point on the subject line of the first unread article.
8039 Return nil if there are no unread articles."
8040 (interactive)
8041 (prog1
8042 (when (gnus-summary-first-subject t)
8043 (gnus-summary-show-thread)
8044 (gnus-summary-first-subject t))
8045 (gnus-summary-position-point)))
8047 (defun gnus-summary-first-unseen-subject ()
8048 "Place the point on the subject line of the first unseen article.
8049 Return nil if there are no unseen articles."
8050 (interactive)
8051 (prog1
8052 (when (gnus-summary-first-subject nil nil t)
8053 (gnus-summary-show-thread)
8054 (gnus-summary-first-subject nil nil t))
8055 (gnus-summary-position-point)))
8057 (defun gnus-summary-first-unseen-or-unread-subject ()
8058 "Place the point on the subject line of the first unseen and unread article.
8059 If all article have been seen, on the subject line of the first unread
8060 article."
8061 (interactive)
8062 (prog1
8063 (unless (when (gnus-summary-first-subject nil nil t)
8064 (gnus-summary-show-thread)
8065 (gnus-summary-first-subject nil nil t))
8066 (when (gnus-summary-first-subject t)
8067 (gnus-summary-show-thread)
8068 (gnus-summary-first-subject t)))
8069 (gnus-summary-position-point)))
8071 (defun gnus-summary-first-article ()
8072 "Select the first article.
8073 Return nil if there are no articles."
8074 (interactive)
8075 (prog1
8076 (when (gnus-summary-first-subject)
8077 (gnus-summary-show-thread)
8078 (gnus-summary-first-subject)
8079 (gnus-summary-display-article (gnus-summary-article-number)))
8080 (gnus-summary-position-point)))
8082 (defun gnus-summary-best-unread-article (&optional arg)
8083 "Select the unread article with the highest score.
8084 If given a prefix argument, select the next unread article that has a
8085 score higher than the default score."
8086 (interactive "P")
8087 (let ((article (if arg
8088 (gnus-summary-better-unread-subject)
8089 (gnus-summary-best-unread-subject))))
8090 (if article
8091 (gnus-summary-goto-article article)
8092 (error "No unread articles"))))
8094 (defun gnus-summary-best-unread-subject ()
8095 "Select the unread subject with the highest score."
8096 (interactive)
8097 (let ((best -1000000)
8098 (data gnus-newsgroup-data)
8099 article score)
8100 (while data
8101 (and (gnus-data-unread-p (car data))
8102 (> (setq score
8103 (gnus-summary-article-score (gnus-data-number (car data))))
8104 best)
8105 (setq best score
8106 article (gnus-data-number (car data))))
8107 (setq data (cdr data)))
8108 (when article
8109 (gnus-summary-goto-subject article))
8110 (gnus-summary-position-point)
8111 article))
8113 (defun gnus-summary-better-unread-subject ()
8114 "Select the first unread subject that has a score over the default score."
8115 (interactive)
8116 (let ((data gnus-newsgroup-data)
8117 article score)
8118 (while (and (setq article (gnus-data-number (car data)))
8119 (or (gnus-data-read-p (car data))
8120 (not (> (gnus-summary-article-score article)
8121 gnus-summary-default-score))))
8122 (setq data (cdr data)))
8123 (when article
8124 (gnus-summary-goto-subject article))
8125 (gnus-summary-position-point)
8126 article))
8128 (defun gnus-summary-last-subject ()
8129 "Go to the last displayed subject line in the group."
8130 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8131 (when article
8132 (gnus-summary-goto-subject article))))
8134 (defun gnus-summary-goto-article (article &optional all-headers force)
8135 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8136 If ALL-HEADERS is non-nil, no header lines are hidden.
8137 If FORCE, go to the article even if it isn't displayed. If FORCE
8138 is a number, it is the line the article is to be displayed on."
8139 (interactive
8140 (list
8141 (gnus-completing-read
8142 "Article number or Message-ID"
8143 (mapcar 'int-to-string gnus-newsgroup-limit))
8144 current-prefix-arg
8146 (prog1
8147 (if (and (stringp article)
8148 (string-match "@\\|%40" article))
8149 (gnus-summary-refer-article article)
8150 (when (stringp article)
8151 (setq article (string-to-number article)))
8152 (if (gnus-summary-goto-subject article force)
8153 (gnus-summary-display-article article all-headers)
8154 (gnus-message 4 "Couldn't go to article %s" article) nil))
8155 (gnus-summary-position-point)))
8157 (defun gnus-summary-goto-last-article ()
8158 "Go to the previously read article."
8159 (interactive)
8160 (prog1
8161 (when gnus-last-article
8162 (gnus-summary-goto-article gnus-last-article nil t))
8163 (gnus-summary-position-point)))
8165 (defun gnus-summary-pop-article (number)
8166 "Pop one article off the history and go to the previous.
8167 NUMBER articles will be popped off."
8168 (interactive "p")
8169 (let (to)
8170 (setq gnus-newsgroup-history
8171 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8172 (if to
8173 (gnus-summary-goto-article (car to) nil t)
8174 (error "Article history empty")))
8175 (gnus-summary-position-point))
8177 ;; Summary commands and functions for limiting the summary buffer.
8179 (defun gnus-summary-limit-to-articles (n)
8180 "Limit the summary buffer to the next N articles.
8181 If not given a prefix, use the process marked articles instead."
8182 (interactive "P")
8183 (prog1
8184 (let ((articles (gnus-summary-work-articles n)))
8185 (setq gnus-newsgroup-processable nil)
8186 (gnus-summary-limit articles))
8187 (gnus-summary-position-point)))
8189 (defun gnus-summary-pop-limit (&optional total)
8190 "Restore the previous limit.
8191 If given a prefix, remove all limits."
8192 (interactive "P")
8193 (when total
8194 (setq gnus-newsgroup-limits
8195 (list (mapcar (lambda (h) (mail-header-number h))
8196 gnus-newsgroup-headers))))
8197 (unless gnus-newsgroup-limits
8198 (error "No limit to pop"))
8199 (prog1
8200 (gnus-summary-limit nil 'pop)
8201 (gnus-summary-position-point)))
8203 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8204 "Limit the summary buffer to articles that have subjects that match a regexp.
8205 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8206 (interactive
8207 (list (read-string (if current-prefix-arg
8208 "Exclude subject (regexp): "
8209 "Limit to subject (regexp): "))
8210 nil current-prefix-arg))
8211 (unless header
8212 (setq header "subject"))
8213 (when (not (equal "" subject))
8214 (prog1
8215 (let ((articles (gnus-summary-find-matching
8216 (or header "subject") subject 'all nil nil
8217 not-matching)))
8218 (unless articles
8219 (error "Found no matches for \"%s\"" subject))
8220 (gnus-summary-limit articles))
8221 (gnus-summary-position-point))))
8223 (defun gnus-summary-limit-to-author (from &optional not-matching)
8224 "Limit the summary buffer to articles that have authors that match a regexp.
8225 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8226 (interactive
8227 (list (let* ((header (gnus-summary-article-header))
8228 (default (and header (car (mail-header-parse-address
8229 (mail-header-from header))))))
8230 (read-string (concat (if current-prefix-arg
8231 "Exclude author (regexp"
8232 "Limit to author (regexp")
8233 (if default
8234 (concat ", default \"" default "\"): ")
8235 "): "))
8236 nil nil
8237 default))
8238 current-prefix-arg))
8239 (gnus-summary-limit-to-subject from "from" not-matching))
8241 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8242 "Limit the summary buffer to articles with the given RECIPIENT.
8244 If NOT-MATCHING, exclude RECIPIENT.
8246 To and Cc headers are checked. You need to include them in
8247 `nnmail-extra-headers'."
8248 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8249 (interactive
8250 (list (read-string (format "%s recipient (regexp): "
8251 (if current-prefix-arg "Exclude" "Limit to")))
8252 current-prefix-arg))
8253 (when (not (equal "" recipient))
8254 (prog1 (let* ((to
8255 (if (memq 'To nnmail-extra-headers)
8256 (gnus-summary-find-matching
8257 (cons 'extra 'To) recipient 'all nil nil
8258 not-matching)
8259 (gnus-message
8260 1 "`To' isn't present in `nnmail-extra-headers'")
8261 (sit-for 1)
8262 nil))
8264 (if (memq 'Cc nnmail-extra-headers)
8265 (gnus-summary-find-matching
8266 (cons 'extra 'Cc) recipient 'all nil nil
8267 not-matching)
8268 (gnus-message
8269 1 "`Cc' isn't present in `nnmail-extra-headers'")
8270 (sit-for 1)
8271 nil))
8272 (articles
8273 (if not-matching
8274 ;; We need the numbers that are in both lists:
8275 (mapcar (lambda (a)
8276 (and (memq a to) a))
8278 (nconc to cc))))
8279 (unless articles
8280 (error "Found no matches for \"%s\"" recipient))
8281 (gnus-summary-limit articles))
8282 (gnus-summary-position-point))))
8284 (defun gnus-summary-limit-to-address (address &optional not-matching)
8285 "Limit the summary buffer to articles with the given ADDRESS.
8287 If NOT-MATCHING, exclude ADDRESS.
8289 To, Cc and From headers are checked. You need to include `To' and `Cc'
8290 in `nnmail-extra-headers'."
8291 (interactive
8292 (list (read-string (format "%s address (regexp): "
8293 (if current-prefix-arg "Exclude" "Limit to")))
8294 current-prefix-arg))
8295 (when (not (equal "" address))
8296 (prog1 (let* ((to
8297 (if (memq 'To nnmail-extra-headers)
8298 (gnus-summary-find-matching
8299 (cons 'extra 'To) address 'all nil nil
8300 not-matching)
8301 (gnus-message
8302 1 "`To' isn't present in `nnmail-extra-headers'")
8303 (sit-for 1)
8306 (if (memq 'Cc nnmail-extra-headers)
8307 (gnus-summary-find-matching
8308 (cons 'extra 'Cc) address 'all nil nil
8309 not-matching)
8310 (gnus-message
8311 1 "`Cc' isn't present in `nnmail-extra-headers'")
8312 (sit-for 1)
8314 (from
8315 (gnus-summary-find-matching "from" address
8316 'all nil nil not-matching))
8317 (articles
8318 (if not-matching
8319 ;; We need the numbers that are in all lists:
8320 (if (eq cc t)
8321 (if (eq to t)
8322 from
8323 (mapcar (lambda (a) (car (memq a from))) to))
8324 (if (eq to t)
8325 (mapcar (lambda (a) (car (memq a from))) cc)
8326 (mapcar (lambda (a) (car (memq a from)))
8327 (mapcar (lambda (a) (car (memq a to)))
8328 cc))))
8329 (nconc (if (eq to t) nil to)
8330 (if (eq cc t) nil cc)
8331 from))))
8332 (unless articles
8333 (error "Found no matches for \"%s\"" address))
8334 (gnus-summary-limit articles))
8335 (gnus-summary-position-point))))
8337 (defun gnus-summary-limit-strange-charsets-predicate (header)
8338 (let ((string (concat (mail-header-subject header)
8339 (mail-header-from header)))
8340 charset found)
8341 (dotimes (i (1- (length string)))
8342 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8343 (when (string-match "unicode\\|big\\|japanese" charset)
8344 (setq found t)))
8345 found))
8347 (defun gnus-summary-limit-to-predicate (predicate)
8348 "Limit to articles where PREDICATE returns non-nil.
8349 PREDICATE will be called with the header structures of the
8350 articles."
8351 (let ((articles nil)
8352 (case-fold-search t))
8353 (dolist (header gnus-newsgroup-headers)
8354 (when (funcall predicate header)
8355 (push (mail-header-number header) articles)))
8356 (gnus-summary-limit (nreverse articles))))
8358 (defun gnus-summary-limit-to-age (age &optional younger-p)
8359 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8360 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8361 articles that are younger than AGE days."
8362 (interactive
8363 (let ((younger current-prefix-arg)
8364 (days-got nil)
8365 days)
8366 (while (not days-got)
8367 (setq days (if younger
8368 (read-string "Limit to articles younger than (in days, older when negative): ")
8369 (read-string
8370 "Limit to articles older than (in days, younger when negative): ")))
8371 (when (> (length days) 0)
8372 (setq days (read days)))
8373 (if (numberp days)
8374 (progn
8375 (setq days-got t)
8376 (when (< days 0)
8377 (setq younger (not younger))
8378 (setq days (* days -1))))
8379 (message "Please enter a number.")
8380 (sleep-for 1)))
8381 (list days younger)))
8382 (prog1
8383 (let ((data gnus-newsgroup-data)
8384 (cutoff (days-to-time age))
8385 articles d date is-younger)
8386 (while (setq d (pop data))
8387 (when (and (vectorp (gnus-data-header d))
8388 (setq date (mail-header-date (gnus-data-header d))))
8389 (setq is-younger (time-less-p
8390 (time-since (gnus-date-get-time date))
8391 cutoff))
8392 (when (if younger-p
8393 is-younger
8394 (not is-younger))
8395 (push (gnus-data-number d) articles))))
8396 (gnus-summary-limit (nreverse articles)))
8397 (gnus-summary-position-point)))
8399 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8400 "Limit the summary buffer to articles that match an `extra' header."
8401 (interactive
8402 (let ((header
8403 (intern
8404 (gnus-completing-read
8405 (if current-prefix-arg
8406 "Exclude extra header"
8407 "Limit extra header")
8408 (mapcar 'symbol-name gnus-extra-headers)
8409 t nil nil
8410 (symbol-name (car gnus-extra-headers))))))
8411 (list header
8412 (read-string (format "%s header %s (regexp): "
8413 (if current-prefix-arg "Exclude" "Limit to")
8414 header))
8415 current-prefix-arg)))
8416 (when (not (equal "" regexp))
8417 (prog1
8418 (let ((articles (gnus-summary-find-matching
8419 (cons 'extra header) regexp 'all nil nil
8420 not-matching)))
8421 (unless articles
8422 (error "Found no matches for \"%s\"" regexp))
8423 (gnus-summary-limit articles))
8424 (gnus-summary-position-point))))
8426 (defun gnus-summary-limit-to-display-predicate ()
8427 "Limit the summary buffer to the predicated in the `display' group parameter."
8428 (interactive)
8429 (unless gnus-newsgroup-display
8430 (error "There is no `display' group parameter"))
8431 (let (articles)
8432 (dolist (gnus-number gnus-newsgroup-articles)
8433 (when (funcall gnus-newsgroup-display)
8434 (push gnus-number articles)))
8435 (gnus-summary-limit articles))
8436 (gnus-summary-position-point))
8438 (defun gnus-summary-limit-to-unread (&optional all)
8439 "Limit the summary buffer to articles that are not marked as read.
8440 If ALL is non-nil, limit strictly to unread articles."
8441 (interactive "P")
8442 (if all
8443 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8444 (gnus-summary-limit-to-marks
8445 ;; Concat all the marks that say that an article is read and have
8446 ;; those removed.
8447 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8448 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8449 gnus-low-score-mark gnus-expirable-mark
8450 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8451 gnus-duplicate-mark)
8452 'reverse)))
8454 (defun gnus-summary-limit-to-headers (match &optional reverse)
8455 "Limit the summary buffer to articles that have headers that match MATCH.
8456 If REVERSE (the prefix), limit to articles that don't match."
8457 (interactive "sMatch headers (regexp): \nP")
8458 (gnus-summary-limit-to-bodies match reverse t))
8460 (declare-function article-goto-body "gnus-art" ())
8462 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8463 "Limit the summary buffer to articles that have bodies that match MATCH.
8464 If REVERSE (the prefix), limit to articles that don't match."
8465 (interactive "sMatch body (regexp): \nP")
8466 (let ((articles nil)
8467 (gnus-select-article-hook nil) ;Disable hook.
8468 (gnus-article-prepare-hook nil)
8469 (gnus-use-article-prefetch nil)
8470 (gnus-keep-backlog nil)
8471 (gnus-break-pages nil)
8472 (gnus-summary-display-arrow nil)
8473 (gnus-updated-mode-lines nil)
8474 (gnus-auto-center-summary nil)
8475 (gnus-display-mime-function nil))
8476 (dolist (data gnus-newsgroup-data)
8477 (let (gnus-mark-article-hook)
8478 (gnus-summary-select-article t t nil (gnus-data-number data)))
8479 (with-current-buffer gnus-article-buffer
8480 (article-goto-body)
8481 (let* ((case-fold-search t)
8482 (found (if headersp
8483 (re-search-backward match nil t)
8484 (re-search-forward match nil t))))
8485 (when (or (and found
8486 (not reverse))
8487 (and (not found)
8488 reverse))
8489 (push (gnus-data-number data) articles)))))
8490 (if (not articles)
8491 (message "No messages matched")
8492 (gnus-summary-limit articles)))
8493 (gnus-summary-position-point))
8495 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8496 "Limit the summary buffer to articles that aren't part on any thread.
8497 If THREADSP (the prefix), limit to articles that are in threads."
8498 (interactive "P")
8499 (let ((articles nil)
8500 thread-articles
8501 threads)
8502 (dolist (thread gnus-newsgroup-threads)
8503 (if (stringp (car thread))
8504 (dolist (thread (cdr thread))
8505 (push thread threads))
8506 (push thread threads)))
8507 (dolist (thread threads)
8508 (setq thread-articles (gnus-articles-in-thread thread))
8509 (when (or (and threadsp
8510 (> (length thread-articles) 1))
8511 (and (not threadsp)
8512 (= (length thread-articles) 1)))
8513 (setq articles (nconc thread-articles articles))))
8514 (if (not articles)
8515 (message "No messages matched")
8516 (gnus-summary-limit articles))
8517 (gnus-summary-position-point)))
8519 (defun gnus-summary-limit-to-replied (&optional unreplied)
8520 "Limit the summary buffer to replied articles.
8521 If UNREPLIED (the prefix), limit to unreplied articles."
8522 (interactive "P")
8523 (if unreplied
8524 (gnus-summary-limit
8525 (gnus-set-difference gnus-newsgroup-articles
8526 gnus-newsgroup-replied))
8527 (gnus-summary-limit gnus-newsgroup-replied))
8528 (gnus-summary-position-point))
8530 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8531 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8532 If REVERSE, limit the summary buffer to articles that are marked
8533 with MARKS. MARKS can either be a string of marks or a list of marks.
8534 Returns how many articles were removed."
8535 (interactive "sMarks: ")
8536 (gnus-summary-limit-to-marks marks t))
8538 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8539 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8540 If REVERSE (the prefix), limit the summary buffer to articles that are
8541 not marked with MARKS. MARKS can either be a string of marks or a
8542 list of marks.
8543 Returns how many articles were removed."
8544 (interactive "sMarks: \nP")
8545 (prog1
8546 (let ((data gnus-newsgroup-data)
8547 (marks (if (listp marks) marks
8548 (append marks nil))) ; Transform to list.
8549 articles)
8550 (while data
8551 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8552 (memq (gnus-data-mark (car data)) marks))
8553 (push (gnus-data-number (car data)) articles))
8554 (setq data (cdr data)))
8555 (gnus-summary-limit articles))
8556 (gnus-summary-position-point)))
8558 (defun gnus-summary-limit-to-score (score)
8559 "Limit to articles with score at or above SCORE."
8560 (interactive "NLimit to articles with score of at least: ")
8561 (let ((data gnus-newsgroup-data)
8562 articles)
8563 (while data
8564 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8565 score)
8566 (push (gnus-data-number (car data)) articles))
8567 (setq data (cdr data)))
8568 (prog1
8569 (gnus-summary-limit articles)
8570 (gnus-summary-position-point))))
8572 (defun gnus-summary-limit-to-unseen ()
8573 "Limit to unseen articles."
8574 (interactive)
8575 (prog1
8576 (gnus-summary-limit gnus-newsgroup-unseen)
8577 (gnus-summary-position-point)))
8579 (defun gnus-summary-limit-include-thread (id &optional thread-only)
8580 "Display all hidden articles belonging to thread ID.
8581 When called interactively, ID is the Message-ID of the current
8582 article. If thread-only is non-nil limit the summary buffer to
8583 these articles."
8584 (interactive (list (mail-header-id (gnus-summary-article-header))))
8585 (let ((articles (gnus-articles-in-thread
8586 (gnus-id-to-thread (gnus-root-id id))))
8587 ;;we REALLY want the whole thread---this prevents cut-threads
8588 ;;from removing the thread we want to include.
8589 (gnus-fetch-old-headers nil)
8590 (gnus-build-sparse-threads nil))
8591 (prog1
8592 (gnus-summary-limit (if thread-only articles
8593 (nconc articles gnus-newsgroup-limit)))
8594 (gnus-summary-limit-include-matching-articles
8595 "subject"
8596 (regexp-quote (gnus-general-simplify-subject
8597 (mail-header-subject (gnus-id-to-header id)))))
8598 ;; the previous two calls each push a limit onto the limit
8599 ;; stack. the first pop remove the articles that match the
8600 ;; subject, while the second pop gets us back to the state
8601 ;; before we started to deal with the thread. presumably we want
8602 ;; to think of the thread and its associated subject matches as
8603 ;; a single thing so that we need to pop only once to get back
8604 ;; to the original view.
8605 (pop gnus-newsgroup-limits)
8606 (gnus-summary-position-point))))
8608 (defun gnus-summary-limit-include-matching-articles (header regexp)
8609 "Display all the hidden articles that have HEADERs that match REGEXP."
8610 (interactive (list (read-string "Match on header: ")
8611 (read-string "Regexp: ")))
8612 (let ((articles (gnus-find-matching-articles header regexp)))
8613 (prog1
8614 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8615 (gnus-summary-position-point))))
8617 (defun gnus-summary-insert-dormant-articles ()
8618 "Insert all the dormant articles for this group into the current buffer."
8619 (interactive)
8620 (let ((gnus-verbose (max 6 gnus-verbose)))
8621 (if (not gnus-newsgroup-dormant)
8622 (gnus-message 3 "No dormant articles for this group")
8623 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8625 (defun gnus-summary-insert-ticked-articles ()
8626 "Insert ticked articles for this group into the current buffer."
8627 (interactive)
8628 (let ((gnus-verbose (max 6 gnus-verbose)))
8629 (if (not gnus-newsgroup-marked)
8630 (gnus-message 3 "No ticked articles for this group")
8631 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8633 (defun gnus-summary-limit-include-dormant ()
8634 "Display all the hidden articles that are marked as dormant.
8635 Note that this command only works on a subset of the articles currently
8636 fetched for this group."
8637 (interactive)
8638 (unless gnus-newsgroup-dormant
8639 (error "There are no dormant articles in this group"))
8640 (prog1
8641 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8642 (gnus-summary-position-point)))
8644 (defun gnus-summary-include-articles (articles)
8645 "Fetch the headers for ARTICLES and then display the summary lines."
8646 (let ((gnus-inhibit-demon t)
8647 (gnus-agent nil)
8648 (gnus-read-all-available-headers t))
8649 (setq gnus-newsgroup-headers
8650 (cl-merge
8651 'list gnus-newsgroup-headers
8652 (gnus-fetch-headers articles nil t)
8653 'gnus-article-sort-by-number))
8654 (setq gnus-newsgroup-articles
8655 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8656 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8658 (defun gnus-summary-limit-exclude-dormant ()
8659 "Hide all dormant articles."
8660 (interactive)
8661 (prog1
8662 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8663 (gnus-summary-position-point)))
8665 (defun gnus-summary-limit-exclude-childless-dormant ()
8666 "Hide all dormant articles that have no children."
8667 (interactive)
8668 (let ((data (gnus-data-list t))
8669 articles d children)
8670 ;; Find all articles that are either not dormant or have
8671 ;; children.
8672 (while (setq d (pop data))
8673 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8674 (and (setq children
8675 (gnus-article-children (gnus-data-number d)))
8676 (let (found)
8677 (while children
8678 (when (memq (car children) articles)
8679 (setq children nil
8680 found t))
8681 (pop children))
8682 found)))
8683 (push (gnus-data-number d) articles)))
8684 ;; Do the limiting.
8685 (prog1
8686 (gnus-summary-limit articles)
8687 (gnus-summary-position-point))))
8689 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8690 "Mark all unread excluded articles as read.
8691 If ALL, mark even excluded ticked and dormants as read."
8692 (interactive "P")
8693 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8694 (let ((articles (gnus-sorted-ndifference
8695 (sort
8696 (mapcar (lambda (h) (mail-header-number h))
8697 gnus-newsgroup-headers)
8699 gnus-newsgroup-limit))
8700 article)
8701 (setq gnus-newsgroup-unreads
8702 (gnus-sorted-intersection gnus-newsgroup-unreads
8703 gnus-newsgroup-limit))
8704 (if all
8705 (setq gnus-newsgroup-dormant nil
8706 gnus-newsgroup-marked nil
8707 gnus-newsgroup-reads
8708 (nconc
8709 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8710 gnus-newsgroup-reads))
8711 (while (setq article (pop articles))
8712 (unless (or (memq article gnus-newsgroup-dormant)
8713 (memq article gnus-newsgroup-marked))
8714 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8716 (defun gnus-summary-limit (articles &optional pop)
8717 (if pop
8718 ;; We pop the previous limit off the stack and use that.
8719 (setq articles (car gnus-newsgroup-limits)
8720 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8721 ;; We use the new limit, so we push the old limit on the stack.
8722 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8723 ;; Set the limit.
8724 (setq gnus-newsgroup-limit articles)
8725 (let ((total (length gnus-newsgroup-data))
8726 (data (gnus-data-find-list (gnus-summary-article-number)))
8727 (gnus-summary-mark-below nil) ; Inhibit this.
8728 found)
8729 ;; This will do all the work of generating the new summary buffer
8730 ;; according to the new limit.
8731 (gnus-summary-prepare)
8732 ;; Hide any threads, possibly.
8733 (gnus-summary-maybe-hide-threads)
8734 ;; Try to return to the article you were at, or one in the
8735 ;; neighborhood.
8736 (when data
8737 ;; We try to find some article after the current one.
8738 (while data
8739 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8740 (setq data nil
8741 found t))
8742 (setq data (cdr data))))
8743 (unless found
8744 ;; If there is no data, that means that we were after the last
8745 ;; article. The same goes when we can't find any articles
8746 ;; after the current one.
8747 (goto-char (point-max))
8748 (gnus-summary-find-prev))
8749 (gnus-set-mode-line 'summary)
8750 ;; We return how many articles were removed from the summary
8751 ;; buffer as a result of the new limit.
8752 (- total (length gnus-newsgroup-data))))
8754 (defsubst gnus-invisible-cut-children (threads)
8755 (let ((num 0))
8756 (while threads
8757 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8758 (incf num))
8759 (pop threads))
8760 (< num 2)))
8762 (defsubst gnus-cut-thread (thread)
8763 "Go forwards in the thread until we find an article that we want to display."
8764 (when (or (eq gnus-fetch-old-headers 'some)
8765 (eq gnus-fetch-old-headers 'invisible)
8766 (numberp gnus-fetch-old-headers)
8767 (eq gnus-build-sparse-threads 'some)
8768 (eq gnus-build-sparse-threads 'more))
8769 ;; Deal with old-fetched headers and sparse threads.
8770 (while (and
8771 thread
8773 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8774 (gnus-summary-article-ancient-p
8775 (mail-header-number (car thread))))
8776 (if (or (<= (length (cdr thread)) 1)
8777 (eq gnus-fetch-old-headers 'invisible))
8778 (setq gnus-newsgroup-limit
8779 (delq (mail-header-number (car thread))
8780 gnus-newsgroup-limit)
8781 thread (cadr thread))
8782 (when (gnus-invisible-cut-children (cdr thread))
8783 (let ((th (cdr thread)))
8784 (while th
8785 (if (memq (mail-header-number (caar th))
8786 gnus-newsgroup-limit)
8787 (setq thread (car th)
8788 th nil)
8789 (setq th (cdr th))))))))))
8790 thread)
8792 (defun gnus-cut-threads (threads)
8793 "Cut off all uninteresting articles from the beginning of THREADS."
8794 (when (or (eq gnus-fetch-old-headers 'some)
8795 (eq gnus-fetch-old-headers 'invisible)
8796 (numberp gnus-fetch-old-headers)
8797 (eq gnus-build-sparse-threads 'some)
8798 (eq gnus-build-sparse-threads 'more))
8799 (let ((th threads))
8800 (while th
8801 (setcar th (gnus-cut-thread (car th)))
8802 (setq th (cdr th)))))
8803 ;; Remove nixed out threads.
8804 (delq nil threads))
8806 (defun gnus-summary-initial-limit (&optional show-if-empty)
8807 "Figure out what the initial limit is supposed to be on group entry.
8808 This entails weeding out unwanted dormants, low-scored articles,
8809 fetch-old-headers verbiage, and so on."
8810 ;; Most groups have nothing to remove.
8811 (unless (or gnus-inhibit-limiting
8812 (and (null gnus-newsgroup-dormant)
8813 (eq gnus-newsgroup-display 'gnus-not-ignore)
8814 (not (eq gnus-fetch-old-headers 'some))
8815 (not (numberp gnus-fetch-old-headers))
8816 (not (eq gnus-fetch-old-headers 'invisible))
8817 (null gnus-summary-expunge-below)
8818 (not (eq gnus-build-sparse-threads 'some))
8819 (not (eq gnus-build-sparse-threads 'more))
8820 (null gnus-thread-expunge-below)))
8821 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8822 (setq gnus-newsgroup-limit nil)
8823 (mapatoms
8824 (lambda (node)
8825 (unless (car (symbol-value node))
8826 ;; These threads have no parents -- they are roots.
8827 (let ((nodes (cdr (symbol-value node)))
8828 thread)
8829 (while nodes
8830 (if (and gnus-thread-expunge-below
8831 (< (gnus-thread-total-score (car nodes))
8832 gnus-thread-expunge-below))
8833 (gnus-expunge-thread (pop nodes))
8834 (setq thread (pop nodes))
8835 (gnus-summary-limit-children thread))))))
8836 gnus-newsgroup-dependencies)
8837 ;; If this limitation resulted in an empty group, we might
8838 ;; pop the previous limit and use it instead.
8839 (when (and (not gnus-newsgroup-limit)
8840 show-if-empty)
8841 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8842 gnus-newsgroup-limit))
8844 (defun gnus-summary-limit-children (thread)
8845 "Return 1 if this subthread is visible and 0 if it is not."
8846 ;; First we get the number of visible children to this thread. This
8847 ;; is done by recursing down the thread using this function, so this
8848 ;; will really go down to a leaf article first, before slowly
8849 ;; working its way up towards the root.
8850 (when thread
8851 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8852 (children
8853 (if (cdr thread)
8854 (apply '+ (mapcar 'gnus-summary-limit-children
8855 (cdr thread)))
8857 (number (mail-header-number (car thread)))
8858 score)
8859 (if (and
8860 (not (memq number gnus-newsgroup-marked))
8862 ;; If this article is dormant and has absolutely no visible
8863 ;; children, then this article isn't visible.
8864 (and (memq number gnus-newsgroup-dormant)
8865 (zerop children))
8866 ;; If this is "fetch-old-headered" and there is no
8867 ;; visible children, then we don't want this article.
8868 (and (or (eq gnus-fetch-old-headers 'some)
8869 (numberp gnus-fetch-old-headers))
8870 (gnus-summary-article-ancient-p number)
8871 (zerop children))
8872 ;; If this is "fetch-old-headered" and `invisible', then
8873 ;; we don't want this article.
8874 (and (eq gnus-fetch-old-headers 'invisible)
8875 (gnus-summary-article-ancient-p number))
8876 ;; If this is a sparsely inserted article with no children,
8877 ;; we don't want it.
8878 (and (eq gnus-build-sparse-threads 'some)
8879 (gnus-summary-article-sparse-p number)
8880 (zerop children))
8881 ;; If we use expunging, and this article is really
8882 ;; low-scored, then we don't want this article.
8883 (when (and gnus-summary-expunge-below
8884 (< (setq score
8885 (or (cdr (assq number gnus-newsgroup-scored))
8886 gnus-summary-default-score))
8887 gnus-summary-expunge-below))
8888 ;; We increase the expunge-tally here, but that has
8889 ;; nothing to do with the limits, really.
8890 (incf gnus-newsgroup-expunged-tally)
8891 ;; We also mark as read here, if that's wanted.
8892 (when (and gnus-summary-mark-below
8893 (< score gnus-summary-mark-below))
8894 (setq gnus-newsgroup-unreads
8895 (delq number gnus-newsgroup-unreads))
8896 (if gnus-newsgroup-auto-expire
8897 (push number gnus-newsgroup-expirable)
8898 (push (cons number gnus-low-score-mark)
8899 gnus-newsgroup-reads)))
8901 ;; Do the `display' group parameter.
8902 (and gnus-newsgroup-display
8903 (let ((gnus-number number))
8904 (not (funcall gnus-newsgroup-display))))))
8905 ;; Nope, invisible article.
8907 ;; Ok, this article is to be visible, so we add it to the limit
8908 ;; and return 1.
8909 (push number gnus-newsgroup-limit)
8910 1))))
8912 (defun gnus-expunge-thread (thread)
8913 "Mark all articles in THREAD as read."
8914 (let* ((number (mail-header-number (car thread))))
8915 (incf gnus-newsgroup-expunged-tally)
8916 ;; We also mark as read here, if that's wanted.
8917 (setq gnus-newsgroup-unreads
8918 (delq number gnus-newsgroup-unreads))
8919 (if gnus-newsgroup-auto-expire
8920 (push number gnus-newsgroup-expirable)
8921 (push (cons number gnus-low-score-mark)
8922 gnus-newsgroup-reads)))
8923 ;; Go recursively through all subthreads.
8924 (mapcar 'gnus-expunge-thread (cdr thread)))
8926 ;; Summary article oriented commands
8928 (defun gnus-summary-refer-parent-article (n)
8929 "Refer parent article N times.
8930 If N is negative, go to ancestor -N instead.
8931 The difference between N and the number of articles fetched is returned."
8932 (interactive "p")
8933 (let ((skip 1)
8934 error header ref)
8935 (when (not (natnump n))
8936 (setq skip (abs n)
8937 n 1))
8938 (while (and (> n 0)
8939 (not error))
8940 (setq header (gnus-summary-article-header))
8941 (if (and (eq (mail-header-number header)
8942 (cdr gnus-article-current))
8943 (equal gnus-newsgroup-name
8944 (car gnus-article-current)))
8945 ;; If we try to find the parent of the currently
8946 ;; displayed article, then we take a look at the actual
8947 ;; References header, since this is slightly more
8948 ;; reliable than the References field we got from the
8949 ;; server.
8950 (with-current-buffer gnus-original-article-buffer
8951 (nnheader-narrow-to-headers)
8952 (unless (setq ref (message-fetch-field "references"))
8953 (when (setq ref (message-fetch-field "in-reply-to"))
8954 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8955 (widen))
8956 (setq ref
8957 ;; It's not the current article, so we take a bet on
8958 ;; the value we got from the server.
8959 (mail-header-references header)))
8960 (if (and ref
8961 (not (equal ref "")))
8962 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8963 (gnus-message 1 "Couldn't find parent"))
8964 (gnus-message 1 "No references in article %d"
8965 (gnus-summary-article-number))
8966 (setq error t))
8967 (decf n))
8968 (gnus-summary-position-point)
8971 (defun gnus-summary-refer-references ()
8972 "Fetch all articles mentioned in the References header.
8973 Return the number of articles fetched."
8974 (interactive)
8975 (let ((ref (mail-header-references (gnus-summary-article-header)))
8976 (current (gnus-summary-article-number))
8977 (n 0))
8978 (if (or (not ref)
8979 (equal ref ""))
8980 (error "No References in the current article")
8981 ;; For each Message-ID in the References header...
8982 (while (string-match "<[^>]*>" ref)
8983 (incf n)
8984 ;; ... fetch that article.
8985 (gnus-summary-refer-article
8986 (prog1 (match-string 0 ref)
8987 (setq ref (substring ref (match-end 0))))))
8988 (gnus-summary-goto-subject current)
8989 (gnus-summary-position-point)
8990 n)))
8992 (defun gnus-delete-duplicate-headers (headers)
8993 ;; First remove leading duplicates.
8994 (while (and (> (length headers) 1)
8995 (= (mail-header-number (car headers))
8996 (mail-header-number (cadr headers))))
8997 (pop headers))
8998 ;; Then the rest.
8999 (let ((result headers))
9000 (while (> (length headers) 1)
9001 (if (= (mail-header-number (car headers))
9002 (mail-header-number (cadr headers)))
9003 (setcdr headers (cddr headers))
9004 (pop headers)))
9005 result))
9007 (defun gnus-summary-refer-thread (&optional limit)
9008 "Fetch all articles in the current thread. For backends that
9009 know how to search for threads (currently only 'nnimap) a
9010 non-numeric prefix arg will use nnir to search the entire
9011 server; without a prefix arg only the current group is
9012 searched. If the variable `gnus-refer-thread-use-nnir' is
9013 non-nil the prefix arg has the reverse meaning. If no
9014 backend-specific 'request-thread function is available fetch
9015 LIMIT (the numerical prefix) old headers. If LIMIT is
9016 non-numeric or nil fetch the number specified by the
9017 `gnus-refer-thread-limit' variable."
9018 (interactive "P")
9019 (let* ((header (gnus-summary-article-header))
9020 (id (mail-header-id header))
9021 (gnus-inhibit-demon t)
9022 (gnus-summary-ignore-duplicates t)
9023 (gnus-read-all-available-headers t)
9024 (gnus-refer-thread-use-nnir
9025 (if (and (not (null limit)) (listp limit))
9026 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9027 (new-headers
9028 (if (gnus-check-backend-function
9029 'request-thread gnus-newsgroup-name)
9030 (gnus-request-thread header gnus-newsgroup-name)
9031 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9032 gnus-refer-thread-limit))
9033 (last (if (numberp limit)
9034 (min (+ (mail-header-number header)
9035 limit)
9036 gnus-newsgroup-highest)
9037 gnus-newsgroup-highest))
9038 (subject (gnus-simplify-subject
9039 (mail-header-subject header)))
9040 (refs (split-string (or (mail-header-references header)
9041 "")))
9042 (gnus-parse-headers-hook
9043 `(lambda () (goto-char (point-min))
9044 (keep-lines
9045 (regexp-opt ',(append refs (list id subject)))))))
9046 (gnus-fetch-headers (list last) (if (numberp limit)
9047 (* 2 limit) limit) t))))
9048 article-ids new-unreads)
9049 (when (listp new-headers)
9050 (dolist (header new-headers)
9051 (push (mail-header-number header) article-ids))
9052 (setq article-ids (nreverse article-ids))
9053 (setq new-unreads
9054 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9055 (setq gnus-newsgroup-unselected
9056 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9057 (setq gnus-newsgroup-unreads
9058 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9059 (setq gnus-newsgroup-headers
9060 (gnus-delete-duplicate-headers
9061 (cl-merge
9062 'list gnus-newsgroup-headers new-headers
9063 'gnus-article-sort-by-number)))
9064 (setq gnus-newsgroup-articles
9065 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9066 (gnus-summary-limit-include-thread id gnus-refer-thread-limit-to-thread)))
9067 (gnus-summary-show-thread))
9069 (defun gnus-summary-open-group-with-article (message-id)
9070 "Open a group containing the article with the given MESSAGE-ID."
9071 (interactive "sMessage-ID: ")
9072 (require 'nndoc)
9073 (with-temp-buffer
9074 ;; Prepare a dummy article
9075 (erase-buffer)
9076 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9078 ;; Prepare pretty modelines for summary and article buffers
9079 (let ((gnus-summary-mode-line-format "Found %G")
9080 (gnus-article-mode-line-format
9081 ;; Group names just get in the way here, especially the
9082 ;; abbreviated ones
9083 (if (string-match "%[gG]" gnus-article-mode-line-format)
9084 (concat (substring gnus-article-mode-line-format
9085 0 (match-beginning 0))
9086 (substring gnus-article-mode-line-format (match-end 0)))
9087 gnus-article-mode-line-format)))
9089 ;; Build an ephemeral group containing the dummy article (hidden)
9090 (gnus-group-read-ephemeral-group
9091 message-id
9092 `(nndoc ,message-id
9093 (nndoc-address ,(current-buffer))
9094 (nndoc-article-type mbox))
9095 :activate
9096 (cons (current-buffer) gnus-current-window-configuration)
9097 (not :request-only)
9098 '(-1) ; :select-articles
9099 (not :parameters)
9100 0)) ; :number
9101 ;; Fetch the desired article
9102 (gnus-summary-refer-article message-id)))
9104 (defun gnus-summary-refer-article (message-id)
9105 "Fetch an article specified by MESSAGE-ID."
9106 (interactive "sMessage-ID: ")
9107 (when (and (stringp message-id)
9108 (not (zerop (length message-id))))
9109 (setq message-id (replace-regexp-in-string " " "" message-id))
9110 ;; Construct the correct Message-ID if necessary.
9111 ;; Suggested by tale@pawl.rpi.edu.
9112 (unless (string-match "^<" message-id)
9113 (setq message-id (concat "<" message-id)))
9114 (unless (string-match ">$" message-id)
9115 (setq message-id (concat message-id ">")))
9116 ;; People often post MIDs from URLs, so unhex it:
9117 (unless (string-match "@" message-id)
9118 (setq message-id (gnus-url-unhex-string message-id)))
9119 (let* ((header (gnus-id-to-header message-id))
9120 (sparse (and header
9121 (gnus-summary-article-sparse-p
9122 (mail-header-number header))
9123 (memq (mail-header-number header)
9124 gnus-newsgroup-limit)))
9125 number)
9126 (cond
9127 ;; If the article is present in the buffer we just go to it.
9128 ((and header
9129 (or (not (gnus-summary-article-sparse-p
9130 (mail-header-number header)))
9131 sparse))
9132 (prog1
9133 (gnus-summary-goto-article
9134 (mail-header-number header) nil t)
9135 (when sparse
9136 (gnus-summary-update-article (mail-header-number header)))))
9138 ;; We fetch the article.
9139 (catch 'found
9140 (dolist (gnus-override-method (gnus-refer-article-methods))
9141 (when (and (gnus-check-server gnus-override-method)
9142 ;; Fetch the header,
9143 (setq number (gnus-summary-insert-subject message-id)))
9144 ;; and display the article.
9145 (gnus-summary-select-article nil nil nil number)
9146 (throw 'found t)))
9147 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9149 (defun gnus-refer-article-methods ()
9150 "Return a list of referable methods."
9151 (cond
9152 ;; No method, so we default to current and native.
9153 ((null gnus-refer-article-method)
9154 (list gnus-current-select-method gnus-select-method))
9155 ;; Current.
9156 ((eq 'current gnus-refer-article-method)
9157 (list gnus-current-select-method))
9158 ;; List of select methods.
9159 ((not (and (symbolp (car gnus-refer-article-method))
9160 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9161 (let (out)
9162 (dolist (method gnus-refer-article-method)
9163 (push (if (eq 'current method)
9164 gnus-current-select-method
9165 (if (eq 'nnir (car method))
9166 (list
9167 'nnir
9168 (or (cadr method)
9169 (gnus-method-to-server gnus-current-select-method)))
9170 method))
9171 out))
9172 (nreverse out)))
9173 ;; One single select method.
9175 (list gnus-refer-article-method))))
9177 (defun gnus-summary-edit-parameters ()
9178 "Edit the group parameters of the current group."
9179 (interactive)
9180 (gnus-group-edit-group gnus-newsgroup-name 'params))
9182 (defun gnus-summary-customize-parameters ()
9183 "Customize the group parameters of the current group."
9184 (interactive)
9185 (gnus-group-customize gnus-newsgroup-name))
9187 (defun gnus-summary-enter-digest-group (&optional force)
9188 "Enter an nndoc group based on the current article.
9189 If FORCE, force a digest interpretation. If not, try to guess
9190 what the document format is.
9192 To control what happens when you exit the group, see the
9193 `gnus-auto-select-on-ephemeral-exit' variable."
9194 (interactive "P")
9195 (let ((conf gnus-current-window-configuration))
9196 (save-window-excursion
9197 (save-excursion
9198 (let (gnus-article-prepare-hook
9199 gnus-display-mime-function
9200 gnus-break-pages)
9201 (gnus-summary-select-article))))
9202 (setq gnus-current-window-configuration conf)
9203 (let* ((name (format "%s-%d"
9204 (gnus-group-prefixed-name
9205 gnus-newsgroup-name (list 'nndoc ""))
9206 (with-current-buffer gnus-summary-buffer
9207 gnus-current-article)))
9208 (ogroup gnus-newsgroup-name)
9209 (params (append (gnus-info-params (gnus-get-info ogroup))
9210 (list (cons 'to-group ogroup))
9211 (list (cons 'parent-group ogroup))
9212 (list (cons 'save-article-group ogroup))))
9213 (case-fold-search t)
9214 (buf (current-buffer))
9215 dig to-address charset)
9216 (with-current-buffer gnus-original-article-buffer
9217 ;; Have the digest group inherit the main mail address of
9218 ;; the parent article.
9219 (when (setq to-address (or (gnus-fetch-field "reply-to")
9220 (gnus-fetch-field "from")))
9221 (setq params
9222 (append
9223 params
9224 (list (cons 'to-address
9225 (funcall gnus-decode-encoded-address-function
9226 to-address))))))
9227 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9228 (insert-buffer-substring gnus-original-article-buffer)
9229 (narrow-to-region
9230 (goto-char (point-min))
9231 (or (search-forward "\n\n" nil t) (point)))
9232 ;; Remove lines that may lead nndoc to misinterpret the
9233 ;; document type.
9234 (goto-char (point-min))
9235 (delete-matching-lines "^Path:\\|^From ")
9236 ;; Parse charset, and decode content transfer encoding.
9237 (setq charset (mail-content-type-get
9238 (mail-header-parse-content-type
9239 (or (gnus-fetch-field "content-type") ""))
9240 'charset))
9241 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9242 (when encoding
9243 (message-remove-header "content-transfer-encoding")
9244 (goto-char (point-max))
9245 (widen)
9246 (narrow-to-region (point) (point-max))
9247 (mm-decode-content-transfer-encoding
9248 (intern (downcase (mail-header-strip-cte encoding))))))
9249 (widen))
9250 (unwind-protect
9251 (if (let ((gnus-newsgroup-ephemeral-charset
9252 (if charset
9253 (intern (downcase (gnus-strip-whitespace charset)))
9254 gnus-newsgroup-charset))
9255 (gnus-newsgroup-ephemeral-ignored-charsets
9256 gnus-newsgroup-ignored-charsets))
9257 (gnus-group-read-ephemeral-group
9258 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9259 (nndoc-article-type
9260 ,(if force 'mbox 'guess)))
9261 t nil nil nil
9262 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9263 "ADAPT")))))
9264 ;; Make all postings to this group go to the parent group.
9265 (nconc (gnus-info-params (gnus-get-info name))
9266 params)
9267 ;; Couldn't select this doc group.
9268 (switch-to-buffer buf)
9269 (gnus-set-global-variables)
9270 (gnus-configure-windows 'summary)
9271 (gnus-message 3 "Article couldn't be entered?"))
9272 (kill-buffer dig)))))
9274 (defun gnus-summary-read-document (n)
9275 "Open a new group based on the current article(s).
9276 This will allow you to read digests and other similar
9277 documents as newsgroups.
9278 Obeys the standard process/prefix convention."
9279 (interactive "P")
9280 (let* ((ogroup gnus-newsgroup-name)
9281 (params (append (gnus-info-params (gnus-get-info ogroup))
9282 (list (cons 'to-group ogroup))))
9283 group egroup groups vgroup)
9284 (dolist (article (gnus-summary-work-articles n))
9285 (setq group (format "%s-%d" gnus-newsgroup-name article))
9286 (gnus-summary-remove-process-mark article)
9287 (when (gnus-summary-display-article article)
9288 (save-excursion ;;What for?
9289 (with-temp-buffer
9290 (insert-buffer-substring gnus-original-article-buffer)
9291 ;; Remove some headers that may lead nndoc to make
9292 ;; the wrong guess.
9293 (message-narrow-to-head)
9294 (goto-char (point-min))
9295 (delete-matching-lines "^Path:\\|^From ")
9296 (widen)
9297 (if (setq egroup
9298 (gnus-group-read-ephemeral-group
9299 group `(nndoc ,group (nndoc-address ,(current-buffer))
9300 (nndoc-article-type guess))
9301 t nil t))
9302 (progn
9303 ;; Make all postings to this group go to the parent group.
9304 (nconc (gnus-info-params (gnus-get-info egroup))
9305 params)
9306 (push egroup groups))
9307 ;; Couldn't select this doc group.
9308 (gnus-error 3 "Article couldn't be entered"))))))
9309 ;; Now we have selected all the documents.
9310 (cond
9311 ((not groups)
9312 (error "None of the articles could be interpreted as documents"))
9313 ((gnus-group-read-ephemeral-group
9314 (setq vgroup (format
9315 "nnvirtual:%s-%s" gnus-newsgroup-name
9316 (format-time-string "%Y%m%dT%H%M%S")))
9317 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9319 (cons (current-buffer) 'summary)))
9321 (error "Couldn't select virtual nndoc group")))))
9323 (defun gnus-summary-widget-forward (arg)
9324 "Move point to the next field or button in the article.
9325 With optional ARG, move across that many fields."
9326 (interactive "p")
9327 (gnus-summary-select-article)
9328 (gnus-configure-windows 'article)
9329 (select-window (gnus-get-buffer-window gnus-article-buffer))
9330 (widget-forward arg))
9332 (defun gnus-summary-widget-backward (arg)
9333 "Move point to the previous field or button in the article.
9334 With optional ARG, move across that many fields."
9335 (interactive "p")
9336 (gnus-summary-select-article)
9337 (gnus-configure-windows 'article)
9338 (select-window (gnus-get-buffer-window gnus-article-buffer))
9339 (unless (widget-at (point))
9340 (goto-char (point-max)))
9341 (widget-backward arg))
9343 (defun gnus-summary-isearch-article (&optional regexp-p)
9344 "Do incremental search forward on the current article.
9345 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9346 (interactive "P")
9347 (gnus-summary-select-article)
9348 (gnus-configure-windows 'article)
9349 (gnus-eval-in-buffer-window gnus-article-buffer
9350 (save-restriction
9351 (widen)
9352 (isearch-forward regexp-p))))
9354 (defun gnus-summary-repeat-search-article-forward ()
9355 "Repeat the previous search forwards."
9356 (interactive)
9357 (unless gnus-last-search-regexp
9358 (error "No previous search"))
9359 (gnus-summary-search-article-forward gnus-last-search-regexp))
9361 (defun gnus-summary-repeat-search-article-backward ()
9362 "Repeat the previous search backwards."
9363 (interactive)
9364 (unless gnus-last-search-regexp
9365 (error "No previous search"))
9366 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9368 (defun gnus-summary-search-article-forward (regexp &optional backward)
9369 "Search for an article containing REGEXP forward.
9370 If BACKWARD, search backward instead."
9371 (interactive
9372 (list (read-string
9373 (format "Search article %s (regexp%s): "
9374 (if current-prefix-arg "backward" "forward")
9375 (if gnus-last-search-regexp
9376 (concat ", default " gnus-last-search-regexp)
9377 "")))
9378 current-prefix-arg))
9379 (if (string-equal regexp "")
9380 (setq regexp (or gnus-last-search-regexp ""))
9381 (setq gnus-last-search-regexp regexp)
9382 (setq gnus-article-before-search gnus-current-article))
9383 ;; Intentionally set gnus-last-article.
9384 (setq gnus-last-article gnus-article-before-search)
9385 (let ((gnus-last-article gnus-last-article))
9386 (if (gnus-summary-search-article regexp backward)
9387 (gnus-summary-show-thread)
9388 (signal 'search-failed (list regexp)))))
9390 (defun gnus-summary-search-article-backward (regexp)
9391 "Search for an article containing REGEXP backward."
9392 (interactive
9393 (list (read-string
9394 (format "Search article backward (regexp%s): "
9395 (if gnus-last-search-regexp
9396 (concat ", default " gnus-last-search-regexp)
9397 "")))))
9398 (gnus-summary-search-article-forward regexp 'backward))
9400 (defun gnus-summary-search-article (regexp &optional backward)
9401 "Search for an article containing REGEXP.
9402 Optional argument BACKWARD means do search for backward.
9403 `gnus-select-article-hook' is not called during the search."
9404 ;; We have to require this here to make sure that the following
9405 ;; dynamic binding isn't shadowed by autoloading.
9406 (require 'gnus-async)
9407 (require 'gnus-art)
9408 (let ((gnus-select-article-hook nil) ;Disable hook.
9409 (gnus-article-prepare-hook nil)
9410 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9411 (gnus-use-article-prefetch nil)
9412 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9413 (gnus-visual nil)
9414 (gnus-keep-backlog nil)
9415 (gnus-break-pages nil)
9416 (gnus-summary-display-arrow nil)
9417 (gnus-updated-mode-lines nil)
9418 (gnus-auto-center-summary nil)
9419 (sum (current-buffer))
9420 (gnus-display-mime-function nil)
9421 (found nil)
9422 point)
9423 (gnus-save-hidden-threads
9424 (gnus-summary-select-article)
9425 (set-buffer gnus-article-buffer)
9426 (goto-char (window-point (get-buffer-window (current-buffer))))
9427 (when backward
9428 (forward-line -1))
9429 (while (not found)
9430 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9431 (if (if backward
9432 (re-search-backward regexp nil t)
9433 (re-search-forward regexp nil t))
9434 ;; We found the regexp.
9435 (progn
9436 (setq found 'found)
9437 (beginning-of-line)
9438 (set-window-start
9439 (get-buffer-window (current-buffer))
9440 (point))
9441 (forward-line 1)
9442 (set-window-point
9443 (get-buffer-window (current-buffer))
9444 (point))
9445 (set-buffer sum)
9446 (setq point (point)))
9447 ;; We didn't find it, so we go to the next article.
9448 (set-buffer sum)
9449 (setq found 'not)
9450 (while (eq found 'not)
9451 (if (not (if backward (gnus-summary-find-prev)
9452 (gnus-summary-find-next)))
9453 ;; No more articles.
9454 (setq found t)
9455 ;; Select the next article and adjust point.
9456 (unless (gnus-summary-article-sparse-p
9457 (gnus-summary-article-number))
9458 (setq found nil)
9459 (gnus-summary-select-article)
9460 (set-buffer gnus-article-buffer)
9461 (widen)
9462 (goto-char (if backward (point-max) (point-min))))))))
9463 (gnus-message 7 ""))
9464 ;; Return whether we found the regexp.
9465 (when (eq found 'found)
9466 (goto-char point)
9467 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9468 (gnus-summary-show-thread)
9469 (gnus-summary-goto-subject gnus-current-article)
9470 (gnus-summary-position-point)
9471 t)))
9473 (defun gnus-find-matching-articles (header regexp)
9474 "Return a list of all articles that match REGEXP on HEADER.
9475 This search includes all articles in the current group that Gnus has
9476 fetched headers for, whether they are displayed or not."
9477 (let ((articles nil)
9478 ;; Can't eta-reduce because it's a macro.
9479 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9480 (case-fold-search t))
9481 (dolist (header gnus-newsgroup-headers)
9482 (when (string-match regexp (funcall func header))
9483 (push (mail-header-number header) articles)))
9484 (nreverse articles)))
9486 (defun gnus-summary-find-matching (header regexp &optional backward unread
9487 not-case-fold not-matching)
9488 "Return a list of all articles that match REGEXP on HEADER.
9489 The search stars on the current article and goes forwards unless
9490 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9491 If UNREAD is non-nil, only unread articles will
9492 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9493 in the comparisons. If NOT-MATCHING, return a list of all articles that
9494 not match REGEXP on HEADER."
9495 (let ((case-fold-search (not not-case-fold))
9496 articles d func)
9497 (if (consp header)
9498 (if (eq (car header) 'extra)
9499 (setq func
9500 `(lambda (h)
9501 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9502 "")))
9503 (error "%s is an invalid header" header))
9504 (unless (fboundp (intern (concat "mail-header-" header)))
9505 (error "%s is not a valid header" header))
9506 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9507 (dolist (d (if (eq backward 'all)
9508 gnus-newsgroup-data
9509 (gnus-data-find-list
9510 (gnus-summary-article-number)
9511 (gnus-data-list backward))))
9512 (when (and (or (not unread) ; We want all articles...
9513 (gnus-data-unread-p d)) ; Or just unreads.
9514 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9515 (if not-matching
9516 (not (string-match
9517 regexp
9518 (funcall func (gnus-data-header d))))
9519 (string-match regexp
9520 (funcall func (gnus-data-header d)))))
9521 (push (gnus-data-number d) articles))) ; Success!
9522 (nreverse articles)))
9524 (defun gnus-summary-execute-command (header regexp command &optional backward)
9525 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9526 If HEADER is an empty string (or nil), the match is done on the entire
9527 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9528 (interactive
9529 (list (let ((completion-ignore-case t))
9530 (gnus-completing-read
9531 "Header name"
9532 (mapcar 'symbol-name
9533 (append
9534 '(Number Subject From Lines Date
9535 Message-ID Xref References Body)
9536 gnus-extra-headers))
9537 'require-match))
9538 (read-string "Regexp: ")
9539 (read-key-sequence "Command: ")
9540 current-prefix-arg))
9541 (when (equal header "Body")
9542 (setq header ""))
9543 ;; Hidden thread subtrees must be searched as well.
9544 (gnus-summary-show-all-threads)
9545 ;; We don't want to change current point nor window configuration.
9546 (save-excursion
9547 (save-window-excursion
9548 (let (gnus-visual
9549 gnus-treat-strip-trailing-blank-lines
9550 gnus-treat-strip-leading-blank-lines
9551 gnus-treat-strip-multiple-blank-lines
9552 gnus-treat-hide-boring-headers
9553 gnus-treat-fold-newsgroups
9554 gnus-article-prepare-hook)
9555 (gnus-message 6 "Executing %s..." (key-description command))
9556 ;; We'd like to execute COMMAND interactively so as to give arguments.
9557 (gnus-execute header regexp
9558 `(call-interactively ',(key-binding command))
9559 backward)
9560 (gnus-message 6 "Executing %s...done" (key-description command))))))
9562 (defun gnus-summary-beginning-of-article ()
9563 "Scroll the article back to the beginning."
9564 (interactive)
9565 (gnus-summary-select-article)
9566 (gnus-configure-windows 'article)
9567 (gnus-eval-in-buffer-window gnus-article-buffer
9568 (widen)
9569 (goto-char (point-min))
9570 (when gnus-break-pages
9571 (gnus-narrow-to-page))))
9573 (defun gnus-summary-end-of-article ()
9574 "Scroll to the end of the article."
9575 (interactive)
9576 (gnus-summary-select-article)
9577 (gnus-configure-windows 'article)
9578 (gnus-eval-in-buffer-window gnus-article-buffer
9579 (widen)
9580 (goto-char (point-max))
9581 (recenter -3)
9582 (when gnus-break-pages
9583 (gnus-narrow-to-page))))
9585 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9586 "Truncate to LEN and quote all \"(\"'s in STRING."
9587 (replace-regexp-in-string "[()]" "\\\\\\&"
9588 (if (and len (> (length string) len))
9589 (substring string 0 len)
9590 string)))
9592 (defun gnus-summary-print-article (&optional filename n)
9593 "Generate and print a PostScript image of the process-marked (mail) articles.
9595 If used interactively, print the current article if none are
9596 process-marked. With prefix arg, prompt the user for the name of the
9597 file to save in.
9599 When used from Lisp, accept two optional args FILENAME and N. N means
9600 to print the next N articles. If N is negative, print the N previous
9601 articles. If N is nil and articles have been marked with the process
9602 mark, print these instead.
9604 If the optional first argument FILENAME is nil, send the image to the
9605 printer. If FILENAME is a string, save the PostScript image in a file with
9606 that name. If FILENAME is a number, prompt the user for the name of the file
9607 to save in."
9608 (interactive (list (ps-print-preprint current-prefix-arg)))
9609 (dolist (article (gnus-summary-work-articles n))
9610 (gnus-summary-select-article nil nil 'pseudo article)
9611 (gnus-eval-in-buffer-window gnus-article-buffer
9612 (gnus-print-buffer))
9613 (gnus-summary-remove-process-mark article))
9614 (ps-despool filename))
9616 (defun gnus-print-buffer ()
9617 (let ((ps-left-header
9618 (list
9619 (concat "("
9620 (gnus-summary-print-truncate-and-quote
9621 (mail-header-subject gnus-current-headers)
9622 66) ")")
9623 (concat "("
9624 (gnus-summary-print-truncate-and-quote
9625 (mail-header-from gnus-current-headers)
9626 45) ")")))
9627 (ps-right-header
9628 (list
9629 "/pagenumberstring load"
9630 (concat "("
9631 (mail-header-date gnus-current-headers) ")"))))
9632 (gnus-run-hooks 'gnus-ps-print-hook)
9633 (save-excursion
9634 (if ps-print-color-p
9635 (ps-spool-buffer-with-faces)
9636 (ps-spool-buffer)))))
9638 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9640 (defun gnus-summary-show-complete-article ()
9641 "Show a complete version of the current article.
9642 This is only useful if you're looking at a partial version of the
9643 article currently."
9644 (interactive)
9645 (let ((gnus-keep-backlog nil)
9646 (gnus-use-cache nil)
9647 (gnus-agent nil)
9648 (variable (intern
9649 (format "%s-fetch-partial-articles"
9650 (car (gnus-find-method-for-group
9651 gnus-newsgroup-name)))
9652 obarray))
9653 old-val)
9654 (unwind-protect
9655 (progn
9656 (setq old-val (symbol-value variable))
9657 (set variable nil)
9658 (gnus-flush-original-article-buffer)
9659 (gnus-summary-show-article))
9660 (set variable old-val))))
9662 (defun gnus-summary-show-article (&optional arg)
9663 "Force redisplaying of the current article.
9664 If ARG (the prefix) is a number, show the article with the charset
9665 defined in `gnus-summary-show-article-charset-alist', or the charset
9666 input.
9667 If ARG (the prefix) is non-nil and not a number, show the article,
9668 but without running any of the article treatment functions
9669 article. Normally, the keystroke is `C-u g'. When using `C-u
9670 C-u g', show the raw article."
9671 (interactive "P")
9672 (cond
9673 ((numberp arg)
9674 (gnus-summary-show-article t)
9675 (let ((gnus-newsgroup-charset
9676 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9677 (read-coding-system
9678 "View as charset: " ;; actually it is coding system.
9679 (with-current-buffer gnus-article-buffer
9680 (mm-detect-coding-region (point) (point-max))))))
9681 (gnus-newsgroup-ignored-charsets 'gnus-all))
9682 (gnus-summary-select-article nil 'force)
9683 (let ((deps gnus-newsgroup-dependencies)
9684 head header lines)
9685 (with-current-buffer gnus-original-article-buffer
9686 (save-restriction
9687 (message-narrow-to-head)
9688 (setq head (buffer-string))
9689 (goto-char (point-min))
9690 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9691 (goto-char (point-max))
9692 (widen)
9693 (setq lines (1- (count-lines (point) (point-max))))))
9694 (with-temp-buffer
9695 (insert (format "211 %d Article retrieved.\n"
9696 (cdr gnus-article-current)))
9697 (insert head)
9698 (if lines (insert (format "Lines: %d\n" lines)))
9699 (insert ".\n")
9700 (let ((nntp-server-buffer (current-buffer)))
9701 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9702 (gnus-data-set-header
9703 (gnus-data-find (cdr gnus-article-current))
9704 header)
9705 (gnus-summary-update-article-line
9706 (cdr gnus-article-current) header)
9707 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9708 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9709 ((not arg)
9710 ;; Select the article the normal way.
9711 (if (eq mm-text-html-renderer 'shr)
9712 (progn
9713 (require 'shr)
9714 (let ((shr-ignore-cache t))
9715 (gnus-summary-select-article nil 'force)))
9716 (gnus-summary-select-article nil 'force)))
9717 ((equal arg '(16))
9718 ;; C-u C-u g
9719 (let ((gnus-inhibit-article-treatments t))
9720 (gnus-summary-select-article nil 'force)))
9722 ;; We have to require this here to make sure that the following
9723 ;; dynamic binding isn't shadowed by autoloading.
9724 (require 'gnus-async)
9725 (require 'gnus-art)
9726 ;; Bind the article treatment functions to nil.
9727 (let ((gnus-have-all-headers t)
9728 gnus-article-prepare-hook
9729 gnus-article-decode-hook
9730 gnus-display-mime-function
9731 gnus-break-pages)
9732 ;; Destroy any MIME parts.
9733 (when (gnus-buffer-live-p gnus-article-buffer)
9734 (with-current-buffer gnus-article-buffer
9735 (gnus-article-stop-animations)
9736 (gnus-stop-downloads)
9737 (mm-destroy-parts gnus-article-mime-handles)
9738 ;; Set it to nil for safety reason.
9739 (setq gnus-article-mime-handle-alist nil)
9740 (setq gnus-article-mime-handles nil)))
9741 (gnus-summary-select-article nil 'force))))
9742 (gnus-summary-goto-subject gnus-current-article)
9743 (gnus-summary-position-point))
9745 (defun gnus-summary-show-raw-article ()
9746 "Show the raw article without any article massaging functions being run."
9747 (interactive)
9748 (gnus-summary-show-article t))
9750 (defun gnus-summary-verbose-headers (&optional arg)
9751 "Toggle permanent full header display.
9752 If ARG is a positive number, turn header display on.
9753 If ARG is a negative number, turn header display off."
9754 (interactive "P")
9755 (setq gnus-show-all-headers
9756 (cond ((or (not (numberp arg))
9757 (zerop arg))
9758 (not gnus-show-all-headers))
9759 ((natnump arg)
9760 t)))
9761 (gnus-summary-show-article))
9763 (declare-function article-narrow-to-head "gnus-art" ())
9764 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9765 (declare-function gnus-delete-wash-type "gnus-art" (type))
9766 (declare-function gnus-mime-buttonize-attachments-in-header
9767 "gnus-art" (&optional interactive))
9769 (defun gnus-summary-toggle-header (&optional arg)
9770 "Show the headers if they are hidden, or hide them if they are shown.
9771 If ARG is a positive number, show the entire header.
9772 If ARG is a negative number, hide the unwanted header lines."
9773 (interactive "P")
9774 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9775 (get-buffer-window gnus-article-buffer t))))
9776 (with-current-buffer gnus-article-buffer
9777 (widen)
9778 (article-narrow-to-head)
9779 (let* ((inhibit-read-only t)
9780 (inhibit-point-motion-hooks t)
9781 (hidden (if (numberp arg)
9782 (>= arg 0)
9784 ;; The case where there's no visible header
9785 ;; that matches `gnus-visible-headers'.
9786 (looking-at "\n?\\'")
9787 (gnus-article-hidden-text-p 'headers))))
9788 s e)
9789 (delete-region (point-min) (point-max))
9790 (with-current-buffer gnus-original-article-buffer
9791 (goto-char (setq s (point-min)))
9792 (setq e (if (search-forward "\n\n" nil t)
9793 (1- (point))
9794 (point-max))))
9795 (insert-buffer-substring gnus-original-article-buffer s e)
9796 (run-hooks 'gnus-article-decode-hook)
9797 (if hidden
9798 (let ((gnus-treat-hide-headers nil)
9799 (gnus-treat-hide-boring-headers nil))
9800 (gnus-delete-wash-type 'headers)
9801 (gnus-treat-article 'head))
9802 (gnus-treat-article 'head)
9803 ;; Add attachment buttons to the header.
9804 (when gnus-mime-display-attachment-buttons-in-header
9805 (gnus-mime-buttonize-attachments-in-header)))
9806 (widen)
9807 (if window
9808 (set-window-start window (goto-char (point-min))))
9809 (if gnus-break-pages
9810 (gnus-narrow-to-page)
9811 (when (gnus-visual-p 'page-marker)
9812 (let ((inhibit-read-only t))
9813 (gnus-remove-text-with-property 'gnus-prev)
9814 (gnus-remove-text-with-property 'gnus-next))))
9815 (gnus-set-mode-line 'article)))))
9817 (defun gnus-summary-show-all-headers ()
9818 "Make all header lines visible."
9819 (interactive)
9820 (gnus-summary-toggle-header 1))
9822 (defun gnus-summary-caesar-message (&optional arg)
9823 "Caesar rotate the current article by 13.
9824 With a non-numerical prefix, also rotate headers. A numerical
9825 prefix specifies how many places to rotate each letter forward."
9826 (interactive "P")
9827 (gnus-summary-select-article)
9828 (let ((mail-header-separator ""))
9829 (gnus-eval-in-buffer-window gnus-article-buffer
9830 (save-restriction
9831 (widen)
9832 (let ((start (window-start))
9833 (inhibit-read-only t))
9834 (if (equal arg '(4))
9835 (message-caesar-buffer-body nil t)
9836 (message-caesar-buffer-body arg))
9837 (set-window-start (get-buffer-window (current-buffer)) start)))))
9838 ;; Create buttons and stuff...
9839 (gnus-treat-article nil))
9841 (defun gnus-summary-idna-message (&optional arg)
9842 "Decode IDNA encoded domain names in the current articles.
9843 IDNA encoded domain names looks like `xn--bar'. If a string
9844 remain unencoded after running this function, it is likely an
9845 invalid IDNA string (`xn--bar' is invalid).
9847 You must have GNU Libidn (URL `https://www.gnu.org/software/libidn/')
9848 installed for this command to work."
9849 (interactive "P")
9850 (gnus-summary-select-article)
9851 (let ((mail-header-separator ""))
9852 (gnus-eval-in-buffer-window gnus-article-buffer
9853 (save-restriction
9854 (widen)
9855 (let ((start (window-start))
9856 buffer-read-only)
9857 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9858 (replace-match (puny-decode-domain (match-string 1))))
9859 (set-window-start (get-buffer-window (current-buffer)) start))))))
9861 (defun gnus-summary-morse-message (&optional arg)
9862 "Morse decode the current article."
9863 (interactive "P")
9864 (gnus-summary-select-article)
9865 (let ((mail-header-separator ""))
9866 (gnus-eval-in-buffer-window gnus-article-buffer
9867 (save-excursion
9868 (save-restriction
9869 (widen)
9870 (let ((pos (window-start))
9871 (inhibit-read-only t))
9872 (goto-char (point-min))
9873 (when (message-goto-body)
9874 (gnus-narrow-to-body))
9875 (goto-char (point-min))
9876 (while (search-forward "·" (point-max) t)
9877 (replace-match "."))
9878 (unmorse-region (point-min) (point-max))
9879 (widen)
9880 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9882 (defun gnus-summary-stop-page-breaking ()
9883 "Stop page breaking in the current article."
9884 (interactive)
9885 (gnus-summary-select-article)
9886 (gnus-eval-in-buffer-window gnus-article-buffer
9887 (widen)
9888 (when (gnus-visual-p 'page-marker)
9889 (let ((inhibit-read-only t))
9890 (gnus-remove-text-with-property 'gnus-prev)
9891 (gnus-remove-text-with-property 'gnus-next))
9892 (setq gnus-page-broken nil))))
9894 (defun gnus-summary-move-article (&optional n to-newsgroup
9895 select-method action)
9896 "Move the current article to a different newsgroup.
9897 If N is a positive number, move the N next articles.
9898 If N is a negative number, move the N previous articles.
9899 If N is nil and any articles have been marked with the process mark,
9900 move those articles instead.
9901 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9902 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9903 re-spool using this method.
9905 When called interactively with TO-NEWSGROUP being nil, the value of
9906 the variable `gnus-move-split-methods' is used for finding a default
9907 for the target newsgroup.
9909 For this function to work, both the current newsgroup and the
9910 newsgroup that you want to move to have to support the `request-move'
9911 and `request-accept' functions.
9913 ACTION can be either `move' (the default), `crosspost' or `copy'."
9914 (interactive "P")
9915 (unless action
9916 (setq action 'move))
9917 ;; Check whether the source group supports the required functions.
9918 (cond ((and (eq action 'move)
9919 (not (gnus-check-backend-function
9920 'request-move-article gnus-newsgroup-name)))
9921 (error "The current group does not support article moving"))
9922 ((and (eq action 'crosspost)
9923 (not (gnus-check-backend-function
9924 'request-replace-article gnus-newsgroup-name)))
9925 (error "The current group does not support article editing")))
9926 (let ((articles (gnus-summary-work-articles n))
9927 (prefix (if (gnus-check-backend-function
9928 'request-move-article gnus-newsgroup-name)
9929 (funcall gnus-move-group-prefix-function
9930 gnus-newsgroup-name)
9931 ""))
9932 (names '((move "Move" "Moving")
9933 (copy "Copy" "Copying")
9934 (crosspost "Crosspost" "Crossposting")))
9935 (copy-buf (save-excursion
9936 (nnheader-set-temp-buffer " *copy article*")))
9937 art-group to-method new-xref article to-groups
9938 articles-to-update-marks encoded)
9939 (unless (assq action names)
9940 (error "Unknown action %s" action))
9941 ;; Read the newsgroup name.
9942 (when (and (not to-newsgroup)
9943 (not select-method))
9944 (if (and gnus-move-split-methods
9945 (not
9946 (and (memq gnus-current-article articles)
9947 (gnus-buffer-live-p gnus-original-article-buffer))))
9948 ;; When `gnus-move-split-methods' is non-nil, we have to
9949 ;; select an article to give `gnus-read-move-group-name' an
9950 ;; opportunity to suggest an appropriate default. However,
9951 ;; we needn't render or mark the article.
9952 (let ((gnus-display-mime-function nil)
9953 (gnus-article-prepare-hook nil)
9954 (gnus-mark-article-hook nil))
9955 (gnus-summary-select-article nil nil nil (car articles))))
9956 (setq to-newsgroup (gnus-read-move-group-name
9957 (cadr (assq action names))
9958 (symbol-value
9959 (intern (format "gnus-current-%s-group" action)))
9960 articles prefix)
9961 encoded to-newsgroup
9962 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9963 (set (intern (format "gnus-current-%s-group" action))
9964 (decode-coding-string
9965 to-newsgroup
9966 (gnus-group-name-charset to-method to-newsgroup))))
9967 (unless to-method
9968 (setq to-method (or select-method
9969 (gnus-server-to-method
9970 (gnus-group-method to-newsgroup)))))
9971 (setq to-newsgroup
9972 (or encoded
9973 (and to-newsgroup
9974 (encode-coding-string
9975 to-newsgroup
9976 (gnus-group-name-charset to-method to-newsgroup)))))
9977 ;; Check the method we are to move this article to...
9978 (unless (gnus-check-backend-function
9979 'request-accept-article (car to-method))
9980 (error "%s does not support article copying" (car to-method)))
9981 (unless (gnus-check-server to-method)
9982 (error "Can't open server %s" (car to-method)))
9983 (gnus-message 6 "%s to %s: %s..."
9984 (caddr (assq action names))
9985 (or (car select-method)
9986 (gnus-group-decoded-name to-newsgroup))
9987 articles)
9988 (while articles
9989 (setq article (pop articles))
9990 ;; Set any marks that may have changed in the summary buffer.
9991 (when gnus-preserve-marks
9992 (gnus-summary-push-marks-to-backend article))
9993 (setq
9994 art-group
9995 (cond
9996 ;; Move the article.
9997 ((eq action 'move)
9998 ;; Remove this article from future suppression.
9999 (gnus-dup-unsuppress-article article)
10000 (let* ((from-method (gnus-find-method-for-group
10001 gnus-newsgroup-name))
10002 (to-method (or select-method
10003 (gnus-find-method-for-group to-newsgroup)))
10004 (move-is-internal (gnus-server-equal from-method to-method)))
10005 (gnus-request-move-article
10006 article ; Article to move
10007 gnus-newsgroup-name ; From newsgroup
10008 (nth 1 (gnus-find-method-for-group
10009 gnus-newsgroup-name)) ; Server
10010 (list 'gnus-request-accept-article
10011 to-newsgroup (list 'quote select-method)
10012 (not articles) t) ; Accept form
10013 (not articles) ; Only save nov last time
10014 (and move-is-internal
10015 to-newsgroup ; Not respooling
10016 ; Is this move internal?
10017 (gnus-group-real-name to-newsgroup)))))
10018 ;; Copy the article.
10019 ((eq action 'copy)
10020 (with-current-buffer copy-buf
10021 (when (gnus-request-article-this-buffer article
10022 gnus-newsgroup-name)
10023 (save-restriction
10024 (nnheader-narrow-to-headers)
10025 (dolist (hdr gnus-copy-article-ignored-headers)
10026 (message-remove-header hdr t)))
10027 (gnus-request-accept-article
10028 to-newsgroup select-method (not articles) t))))
10029 ;; Crosspost the article.
10030 ((eq action 'crosspost)
10031 (let ((xref (message-tokenize-header
10032 (mail-header-xref (gnus-summary-article-header
10033 article))
10034 " ")))
10035 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10036 ":" (number-to-string article)))
10037 (unless xref
10038 (setq xref (list (system-name))))
10039 (setq new-xref
10040 (concat
10041 (mapconcat 'identity
10042 (delete "Xref:" (delete new-xref xref))
10043 " ")
10044 " " new-xref))
10045 (with-current-buffer copy-buf
10046 ;; First put the article in the destination group.
10047 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10048 (when (consp (setq art-group
10049 (gnus-request-accept-article
10050 to-newsgroup select-method (not articles)
10051 t)))
10052 (setq new-xref (concat new-xref " " (car art-group)
10054 (number-to-string (cdr art-group))))
10055 ;; Now we have the new Xrefs header, so we insert
10056 ;; it and replace the new article.
10057 (nnheader-replace-header "Xref" new-xref)
10058 (gnus-request-replace-article
10059 (cdr art-group) to-newsgroup (current-buffer) t)
10060 art-group))))))
10061 (cond
10062 ((not art-group)
10063 (gnus-message 1 "Couldn't %s article %s: %s"
10064 (cadr (assq action names)) article
10065 (nnheader-get-report (car to-method))))
10066 ((eq art-group 'junk)
10067 (when (eq action 'move)
10068 (gnus-summary-mark-article article gnus-canceled-mark)
10069 (gnus-message 4 "Deleted article %s" article)
10070 ;; run the delete hook
10071 (run-hook-with-args 'gnus-summary-article-delete-hook
10072 action
10073 (gnus-data-header
10074 (assoc article (gnus-data-list nil)))
10075 gnus-newsgroup-name nil
10076 select-method)))
10078 (let* ((pto-group (gnus-group-prefixed-name
10079 (car art-group) to-method))
10080 (info (gnus-get-info pto-group))
10081 (to-group (gnus-info-group info))
10082 to-marks)
10083 ;; Update the group that has been moved to.
10084 (when (and info
10085 (memq action '(move copy)))
10086 (unless (member to-group to-groups)
10087 (push to-group to-groups))
10089 (when (and (not (memq article gnus-newsgroup-unreads))
10090 (cdr art-group))
10091 (push 'read to-marks)
10092 (gnus-info-set-read
10093 info (gnus-add-to-range (gnus-info-read info)
10094 (list (cdr art-group)))))
10096 ;; See whether the article is to be put in the cache.
10097 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10098 (marks (if expirable
10099 gnus-article-mark-lists
10100 (delete '(expirable . expire)
10101 (copy-sequence
10102 gnus-article-mark-lists))))
10103 (to-article (cdr art-group)))
10105 ;; Enter the article into the cache in the new group,
10106 ;; if that is required.
10107 (when (and to-article
10108 gnus-use-cache)
10109 (gnus-cache-possibly-enter-article
10110 to-group to-article
10111 (memq article gnus-newsgroup-marked)
10112 (memq article gnus-newsgroup-dormant)
10113 (memq article gnus-newsgroup-unreads)))
10115 (when (and gnus-preserve-marks
10116 to-article)
10117 ;; Copy any marks over to the new group.
10118 (when (and (equal to-group gnus-newsgroup-name)
10119 (not (memq article gnus-newsgroup-unreads)))
10120 ;; Mark this article as read in this group.
10121 (push (cons to-article gnus-read-mark)
10122 gnus-newsgroup-reads)
10123 ;; Increase the active status of this group.
10124 (setcdr (gnus-active to-group) to-article)
10125 (setcdr gnus-newsgroup-active to-article))
10127 (while marks
10128 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10129 (when (memq article (symbol-value
10130 (intern (format "gnus-newsgroup-%s"
10131 (caar marks)))))
10132 (push (cdar marks) to-marks)
10133 ;; If the other group is the same as this group,
10134 ;; then we have to add the mark to the list.
10135 (when (equal to-group gnus-newsgroup-name)
10136 (set (intern (format "gnus-newsgroup-%s"
10137 (caar marks)))
10138 (cons to-article
10139 (symbol-value
10140 (intern (format "gnus-newsgroup-%s"
10141 (caar marks)))))))
10142 ;; Copy the marks to other group.
10143 (gnus-add-marked-articles
10144 to-group (cdar marks) (list to-article) info)))
10145 (setq marks (cdr marks)))
10147 (when (and expirable
10148 gnus-mark-copied-or-moved-articles-as-expirable
10149 (not (memq 'expire to-marks)))
10150 ;; Mark this article as expirable.
10151 (push 'expire to-marks)
10152 (when (equal to-group gnus-newsgroup-name)
10153 (push to-article gnus-newsgroup-expirable))
10154 ;; Copy the expirable mark to other group.
10155 (gnus-add-marked-articles
10156 to-group 'expire (list to-article) info))
10158 (when (and to-marks
10159 (gnus-method-option-p
10160 (gnus-find-method-for-group to-group)
10161 'server-marks))
10162 (gnus-request-set-mark
10163 to-group (list (list (list to-article) 'add to-marks)))))
10165 (gnus-dribble-enter
10166 (concat "(gnus-group-set-info '"
10167 (gnus-prin1-to-string (gnus-get-info to-group))
10168 ")")
10169 (concat "^(gnus-group-set-info '(\""
10170 (regexp-quote to-group) "\""))))
10172 ;; Update the Xref header in this article to point to
10173 ;; the new crossposted article we have just created.
10174 (when (eq action 'crosspost)
10175 (with-current-buffer copy-buf
10176 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10177 (nnheader-replace-header "Xref" new-xref)
10178 (gnus-request-replace-article
10179 article gnus-newsgroup-name (current-buffer) t)))
10181 ;; run the move/copy/crosspost/respool hook
10182 (run-hook-with-args 'gnus-summary-article-move-hook
10183 action
10184 (gnus-data-header
10185 (assoc article (gnus-data-list nil)))
10186 gnus-newsgroup-name
10187 to-newsgroup
10188 select-method))
10190 ;;;!!!Why is this necessary?
10191 (set-buffer gnus-summary-buffer)
10193 (when (eq action 'move)
10194 (save-excursion
10195 (gnus-summary-goto-subject article)
10196 (gnus-summary-mark-article article gnus-canceled-mark)))))
10197 (push article articles-to-update-marks))
10199 (save-excursion
10200 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10201 ;; Re-activate all groups that have been moved to.
10202 (with-current-buffer gnus-group-buffer
10203 (let ((gnus-group-marked to-groups))
10204 (gnus-group-get-new-news-this-group nil t)))
10206 (gnus-kill-buffer copy-buf)
10207 (gnus-summary-position-point)
10208 (gnus-set-mode-line 'summary)))
10210 (defun gnus-summary-push-marks-to-backend (article)
10211 (let ((set nil)
10212 (del nil)
10213 (marks gnus-article-mark-lists))
10214 (unless (memq article gnus-newsgroup-unreads)
10215 (push 'read set))
10216 (while marks
10217 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10218 (memq article (symbol-value
10219 (intern (format "gnus-newsgroup-%s"
10220 (caar marks))))))
10221 (push (cdar marks) set)
10222 (push (cdar marks) del))
10223 (pop marks))
10224 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10225 ((,article) del ,del)))))
10227 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10228 "Copy the current article to some other group.
10229 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10230 When called interactively, if TO-NEWSGROUP is nil, use the value of
10231 the variable `gnus-move-split-methods' for finding a default target
10232 newsgroup.
10233 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10234 re-spool using this method."
10235 (interactive "P")
10236 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10238 (defun gnus-summary-crosspost-article (&optional n)
10239 "Crosspost the current article to some other group."
10240 (interactive "P")
10241 (gnus-summary-move-article n nil nil 'crosspost))
10243 (defcustom gnus-summary-respool-default-method nil
10244 "Default method type for respooling an article.
10245 If nil, use to the current newsgroup method."
10246 :type 'symbol
10247 :group 'gnus-summary-mail)
10249 (defun gnus-summary-respool-article (&optional n method)
10250 "Respool the current article.
10251 The article will be squeezed through the mail spooling process again,
10252 which means that it will be put in some mail newsgroup or other
10253 depending on `nnmail-split-methods'.
10254 If N is a positive number, respool the N next articles.
10255 If N is a negative number, respool the N previous articles.
10256 If N is nil and any articles have been marked with the process mark,
10257 respool those articles instead.
10259 Respooling can be done both from mail groups and \"real\" newsgroups.
10260 In the former case, the articles in question will be moved from the
10261 current group into whatever groups they are destined to. In the
10262 latter case, they will be copied into the relevant groups."
10263 (interactive
10264 (list current-prefix-arg
10265 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10266 (methname
10267 (symbol-name (or gnus-summary-respool-default-method
10268 (car (gnus-find-method-for-group
10269 gnus-newsgroup-name)))))
10270 (method
10271 (gnus-completing-read
10272 "Backend to use when respooling"
10273 methods t nil 'gnus-mail-method-history methname))
10275 (cond
10276 ((zerop (length (setq ms (gnus-servers-using-backend
10277 (intern method)))))
10278 (list (intern method) ""))
10279 ((= 1 (length ms))
10280 (car ms))
10282 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10283 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10284 ms-alist))))))))
10285 (unless method
10286 (error "No method given for respooling"))
10287 (if (assoc (symbol-name
10288 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10289 (gnus-methods-using 'respool))
10290 (gnus-summary-move-article n nil method)
10291 (gnus-summary-copy-article n nil method)))
10293 (defun gnus-summary-import-article (file &optional edit)
10294 "Import an arbitrary file into a mail newsgroup."
10295 (interactive "fImport file: \nP")
10296 (let ((group gnus-newsgroup-name)
10297 atts lines group-art)
10298 (unless (gnus-check-backend-function 'request-accept-article group)
10299 (error "%s does not support article importing" group))
10300 (or (file-readable-p file)
10301 (not (file-regular-p file))
10302 (error "Can't read %s" file))
10303 (with-current-buffer (gnus-get-buffer-create " *import file*")
10304 (erase-buffer)
10305 (nnheader-insert-file-contents file)
10306 (goto-char (point-min))
10307 (if (nnheader-article-p)
10308 (save-restriction
10309 (goto-char (point-min))
10310 (search-forward "\n\n" nil t)
10311 (narrow-to-region (point-min) (1- (point)))
10312 (goto-char (point-min))
10313 (unless (re-search-forward "^date:" nil t)
10314 (goto-char (point-max))
10315 (setq atts (file-attributes file))
10316 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10317 ;; This doesn't look like an article, so we fudge some headers.
10318 (setq atts (file-attributes file)
10319 lines (count-lines (point-min) (point-max)))
10320 (insert "From: " (read-string "From: ") "\n"
10321 "Subject: " (read-string "Subject: ") "\n"
10322 "Date: " (message-make-date (nth 5 atts)) "\n"
10323 "Message-ID: " (message-make-message-id) "\n"
10324 "Lines: " (int-to-string lines) "\n"
10325 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10326 (setq group-art (gnus-request-accept-article group nil t))
10327 (kill-buffer (current-buffer)))
10328 (setq gnus-newsgroup-active (gnus-activate-group group))
10329 (forward-line 1)
10330 (gnus-summary-goto-article (cdr group-art) nil t)
10331 (when edit
10332 (gnus-summary-edit-article))))
10334 (defun gnus-summary-create-article ()
10335 "Create an article in a mail newsgroup."
10336 (interactive)
10337 (let ((group gnus-newsgroup-name)
10338 (now (current-time))
10339 group-art)
10340 (unless (gnus-check-backend-function 'request-accept-article group)
10341 (error "%s does not support article importing" group))
10342 (with-current-buffer (gnus-get-buffer-create " *import file*")
10343 (erase-buffer)
10344 (goto-char (point-min))
10345 ;; This doesn't look like an article, so we fudge some headers.
10346 (insert "From: " (read-string "From: ") "\n"
10347 "Subject: " (read-string "Subject: ") "\n"
10348 "Date: " (message-make-date now) "\n"
10349 "Message-ID: " (message-make-message-id) "\n")
10350 (setq group-art (gnus-request-accept-article group nil t))
10351 (kill-buffer (current-buffer)))
10352 (setq gnus-newsgroup-active (gnus-activate-group group))
10353 (forward-line 1)
10354 (gnus-summary-goto-article (cdr group-art) nil t)
10355 (gnus-summary-edit-article)))
10357 (defun gnus-summary-article-posted-p ()
10358 "Say whether the current (mail) article is available from news as well.
10359 This will be the case if the article has both been mailed and posted."
10360 (interactive)
10361 (let ((id (mail-header-references (gnus-summary-article-header)))
10362 (gnus-override-method (car (gnus-refer-article-methods))))
10363 (if (gnus-request-head id "")
10364 (gnus-message 2 "The current message was found on %s"
10365 gnus-override-method)
10366 (gnus-message 2 "The current message couldn't be found on %s"
10367 gnus-override-method)
10368 nil)))
10370 (defun gnus-summary-expire-articles (&optional now)
10371 "Expire all articles that are marked as expirable in the current group."
10372 (interactive)
10373 (when (and (not gnus-group-is-exiting-without-update-p)
10374 (gnus-check-backend-function
10375 'request-expire-articles gnus-newsgroup-name))
10376 ;; This backend supports expiry.
10377 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10378 (expirable
10379 (gnus-list-range-difference
10380 (if total
10381 (progn
10382 ;; We need to update the info for
10383 ;; this group for `gnus-list-of-read-articles'
10384 ;; to give us the right answer.
10385 (gnus-run-hooks 'gnus-exit-group-hook)
10386 (gnus-summary-update-info)
10387 (gnus-list-of-read-articles gnus-newsgroup-name))
10388 (setq gnus-newsgroup-expirable
10389 (sort gnus-newsgroup-expirable '<)))
10390 gnus-newsgroup-unexist))
10391 (expiry-wait (if now 'immediate
10392 (gnus-group-find-parameter
10393 gnus-newsgroup-name 'expiry-wait)))
10394 (nnmail-expiry-target
10395 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10396 nnmail-expiry-target))
10398 (when expirable
10399 ;; There are expirable articles in this group, so we run them
10400 ;; through the expiry process.
10401 (gnus-message 6 "Expiring articles...")
10402 (when (gnus-check-group gnus-newsgroup-name)
10403 ;; The list of articles that weren't expired is returned.
10404 (save-excursion
10405 (if expiry-wait
10406 (let ((nnmail-expiry-wait-function nil)
10407 (nnmail-expiry-wait expiry-wait))
10408 (setq es (gnus-request-expire-articles
10409 expirable gnus-newsgroup-name)))
10410 (setq es (gnus-request-expire-articles
10411 expirable gnus-newsgroup-name)))
10412 (unless total
10413 (setq gnus-newsgroup-expirable es))
10414 ;; We go through the old list of expirable, and mark all
10415 ;; really expired articles as nonexistent.
10416 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10417 (let ((gnus-use-cache nil))
10418 (dolist (article expirable)
10419 (when (and (not (memq article es))
10420 (gnus-data-find article))
10421 (gnus-summary-mark-article article gnus-canceled-mark)
10422 (run-hook-with-args
10423 'gnus-summary-article-expire-hook
10424 'delete
10425 (gnus-data-header (assoc article (gnus-data-list nil)))
10426 gnus-newsgroup-name
10427 (cond
10428 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10429 ((eq nnmail-expiry-target 'delete) nil)
10431 (let ((rescall (funcall nnmail-expiry-target
10432 gnus-newsgroup-name)))
10433 (if (stringp rescall) rescall nil))))
10434 nil)))))))
10435 (gnus-message 6 "Expiring articles...done")))))
10437 (defun gnus-summary-expire-articles-now ()
10438 "Expunge all expirable articles in the current group.
10439 This means that *all* articles that are marked as expirable will be
10440 deleted forever, right now."
10441 (interactive)
10442 (or gnus-expert-user
10443 (gnus-yes-or-no-p
10444 "Are you really, really sure you want to delete all expirable messages? ")
10445 (error "Phew!"))
10446 (gnus-summary-expire-articles t))
10448 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10449 (defun gnus-summary-delete-article (&optional n)
10450 "Delete the N next (mail) articles.
10451 This command actually deletes articles. This is not a marking
10452 command. The article will disappear forever from your life, never to
10453 return.
10455 If N is negative, delete backwards.
10456 If N is nil and articles have been marked with the process mark,
10457 delete these instead.
10459 If `gnus-novice-user' is non-nil you will be asked for
10460 confirmation before the articles are deleted."
10461 (interactive "P")
10462 (unless (gnus-check-backend-function 'request-expire-articles
10463 gnus-newsgroup-name)
10464 (error "The current newsgroup does not support article deletion"))
10465 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10466 (error "Couldn't open server"))
10467 ;; Compute the list of articles to delete.
10468 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10469 (nnmail-expiry-target 'delete)
10470 not-deleted)
10471 (if (and gnus-novice-user
10472 (not (gnus-yes-or-no-p
10473 (format "Do you really want to delete %s forever? "
10474 (if (> (length articles) 1)
10475 (format "these %s articles" (length articles))
10476 "this article")))))
10478 ;; Delete the articles.
10479 (setq not-deleted (gnus-request-expire-articles
10480 articles gnus-newsgroup-name 'force))
10481 (save-excursion
10482 (while articles
10483 (gnus-summary-remove-process-mark (car articles))
10484 ;; The backend might not have been able to delete the article
10485 ;; after all.
10486 (unless (memq (car articles) not-deleted)
10487 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10488 (let* ((article (car articles))
10489 (ghead (gnus-data-header
10490 (assoc article (gnus-data-list nil)))))
10491 (run-hook-with-args 'gnus-summary-article-delete-hook
10492 'delete ghead gnus-newsgroup-name nil
10493 nil)))
10494 (setq articles (cdr articles))))
10495 (when not-deleted
10496 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10497 (gnus-summary-position-point)
10498 (gnus-set-mode-line 'summary)
10499 not-deleted))
10501 (defun gnus-summary-edit-article (&optional arg)
10502 "Edit the current article.
10503 This will have permanent effect only in mail groups.
10504 If ARG is nil, edit the decoded articles.
10505 If ARG is 1, edit the raw articles.
10506 If ARG is 2, edit the raw articles even in read-only groups.
10507 If ARG is 3, edit the articles with the current handles.
10508 Otherwise, allow editing of articles even in read-only
10509 groups."
10510 (interactive "P")
10511 (let (force raw current-handles)
10512 (cond
10513 ((null arg))
10514 ((eq arg 1)
10515 (setq raw t))
10516 ((eq arg 2)
10517 (setq raw t
10518 force t))
10519 ((eq arg 3)
10520 (setq current-handles
10521 (and (gnus-buffer-live-p gnus-article-buffer)
10522 (with-current-buffer gnus-article-buffer
10523 (prog1
10524 gnus-article-mime-handles
10525 (setq gnus-article-mime-handles nil))))))
10527 (setq force t)))
10528 (when (and raw (not force)
10529 (member gnus-newsgroup-name '("nndraft:delayed"
10530 "nndraft:drafts"
10531 "nndraft:queue")))
10532 (error "Can't edit the raw article in group %s"
10533 gnus-newsgroup-name))
10534 (with-current-buffer gnus-summary-buffer
10535 (let ((mail-parse-charset gnus-newsgroup-charset)
10536 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10537 (gnus-set-global-variables)
10538 (when (and (not force)
10539 (gnus-group-read-only-p))
10540 (error "The current newsgroup does not support article editing"))
10541 (gnus-summary-show-article t)
10542 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10543 (with-current-buffer gnus-article-buffer
10544 (mm-enable-multibyte)))
10545 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10546 (setq raw t))
10547 (gnus-article-edit-article
10548 (if raw 'ignore
10549 `(lambda ()
10550 (let ((mbl mml-buffer-list))
10551 (setq mml-buffer-list nil)
10552 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10553 (mime-to-mml ,'current-handles))
10554 (let ((mbl1 mml-buffer-list))
10555 (setq mml-buffer-list mbl)
10556 (set (make-local-variable 'mml-buffer-list) mbl1))
10557 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10558 `(lambda (no-highlight)
10559 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10560 (message-options message-options)
10561 (message-options-set-recipient)
10562 (mail-parse-ignored-charsets
10563 ',gnus-newsgroup-ignored-charsets)
10564 (rfc2047-header-encoding-alist
10565 ',(let ((charset (gnus-group-name-charset
10566 (gnus-find-method-for-group
10567 gnus-newsgroup-name)
10568 gnus-newsgroup-name)))
10569 (append (list (cons "Newsgroups" charset)
10570 (cons "Followup-To" charset)
10571 (cons "Xref" charset))
10572 rfc2047-header-encoding-alist))))
10573 ,(if (not raw) '(progn
10574 (mml-to-mime)
10575 (mml-destroy-buffers)
10576 (remove-hook 'kill-buffer-hook
10577 'mml-destroy-buffers t)
10578 (kill-local-variable 'mml-buffer-list)))
10579 (gnus-summary-edit-article-done
10580 ,(or (mail-header-references gnus-current-headers) "")
10581 ,(gnus-group-read-only-p)
10582 ,gnus-summary-buffer no-highlight))))))))
10584 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10586 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10587 no-highlight)
10588 "Make edits to the current article permanent."
10589 (interactive)
10590 (save-excursion
10591 ;; The buffer restriction contains the entire article if it exists.
10592 (when (article-goto-body)
10593 (let ((lines (count-lines (point) (point-max)))
10594 (length (- (point-max) (point)))
10595 (case-fold-search t)
10596 (body (point-marker)))
10597 (goto-char (point-min))
10598 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10599 (delete-region (match-beginning 1) (match-end 1))
10600 (insert (number-to-string length)))
10601 (goto-char (point-min))
10602 (when (re-search-forward
10603 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10604 (delete-region (match-beginning 1) (match-end 1))
10605 (insert (number-to-string length)))
10606 (goto-char (point-min))
10607 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10608 (delete-region (match-beginning 1) (match-end 1))
10609 (insert (number-to-string lines))))))
10610 ;; Replace the article.
10611 (let ((buf (current-buffer))
10612 (article (cdr gnus-article-current))
10613 replace-result)
10614 (with-temp-buffer
10615 (insert-buffer-substring buf)
10616 (if (and (not read-only)
10617 (not (setq replace-result
10618 (gnus-request-replace-article
10619 article (car gnus-article-current)
10620 (current-buffer) t))))
10621 (error "Couldn't replace article")
10622 ;; If we got a number back, then that's the new article number
10623 ;; for this article. Otherwise, the article number didn't change.
10624 (when (numberp replace-result)
10625 (with-current-buffer gnus-summary-buffer
10626 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10627 (gnus-summary-limit gnus-newsgroup-limit)
10628 (setq article replace-result)
10629 (gnus-summary-goto-subject article t)))
10630 ;; Update the summary buffer.
10631 (if (and references
10632 (equal (message-tokenize-header references " ")
10633 (message-tokenize-header
10634 (or (message-fetch-field "references") "") " ")))
10635 ;; We only have to update this line.
10636 (save-excursion
10637 (save-restriction
10638 (message-narrow-to-head)
10639 (let ((head (buffer-substring-no-properties
10640 (point-min) (point-max)))
10641 header)
10642 (with-temp-buffer
10643 (insert (format "211 %d Article retrieved.\n" article))
10644 (insert head)
10645 (insert ".\n")
10646 (let ((nntp-server-buffer (current-buffer)))
10647 (setq header (car (gnus-get-newsgroup-headers nil t))))
10648 (with-current-buffer gnus-summary-buffer
10649 (gnus-data-set-header (gnus-data-find article) header)
10650 (gnus-summary-update-article-line article header)
10651 (if (gnus-summary-goto-subject article nil t)
10652 (gnus-summary-update-secondary-mark article)))))))
10653 ;; Update threads.
10654 (set-buffer (or buffer gnus-summary-buffer))
10655 (gnus-summary-update-article article)
10656 (if (gnus-summary-goto-subject article nil t)
10657 (gnus-summary-update-secondary-mark article)))
10658 ;; Prettify the article buffer again.
10659 (unless no-highlight
10660 (with-current-buffer gnus-article-buffer
10661 ;;!!! Fix this -- article should be rehighlighted.
10662 ;;(gnus-run-hooks 'gnus-article-display-hook)
10663 (set-buffer gnus-original-article-buffer)
10664 (gnus-request-article
10665 article (car gnus-article-current) (current-buffer))))
10666 ;; Prettify the summary buffer line.
10667 (when (gnus-visual-p 'summary-highlight 'highlight)
10668 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10670 (defun gnus-summary-edit-wash (key)
10671 "Perform editing command KEY in the article buffer."
10672 (interactive
10673 (list
10674 (progn
10675 (message "%s" (concat (this-command-keys) "- "))
10676 (read-char))))
10677 (message "")
10678 (gnus-summary-edit-article)
10679 (execute-kbd-macro (concat (this-command-keys) key))
10680 (gnus-article-edit-done))
10682 ;;; Respooling
10684 (defvar nnimap-split-fancy)
10685 (defvar nnimap-split-methods)
10687 (defun gnus-summary-respool-query (&optional silent trace)
10688 "Query where the respool algorithm would put this article."
10689 (interactive)
10690 (let (gnus-mark-article-hook)
10691 (gnus-summary-select-article)
10692 (with-current-buffer gnus-original-article-buffer
10693 (let ((groups
10694 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10695 'nnimap)
10696 ;; nnimap has its own splitting variables.
10697 (let ((nnmail-split-methods
10698 (cond
10699 ((eq nnimap-split-methods 'default)
10700 nnmail-split-methods)
10701 (nnimap-split-methods
10702 nnimap-split-methods)
10703 (nnimap-split-fancy
10704 'nnmail-split-fancy)))
10705 (nnmail-split-fancy (or nnimap-split-fancy
10706 nnmail-split-fancy)))
10707 (nnmail-article-group 'identity trace))
10708 (nnmail-article-group 'identity trace))))
10709 (unless silent
10710 (if groups
10711 (message "This message would go to %s"
10712 (mapconcat 'car groups ", "))
10713 (message "This message would go to no groups"))
10714 groups)))))
10716 (defun gnus-summary-respool-trace ()
10717 "Trace where the respool algorithm would put this article.
10718 Display a buffer showing all fancy splitting patterns which matched."
10719 (interactive)
10720 (gnus-summary-respool-query nil t))
10722 ;; Summary marking commands.
10724 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10725 "Mark articles which has the same subject as read, and then select the next.
10726 If UNMARK is positive, remove any kind of mark.
10727 If UNMARK is negative, tick articles."
10728 (interactive "P")
10729 (when unmark
10730 (setq unmark (prefix-numeric-value unmark)))
10731 (let ((count
10732 (gnus-summary-mark-same-subject
10733 (gnus-summary-article-subject) unmark)))
10734 ;; Select next unread article. If auto-select-same mode, should
10735 ;; select the first unread article.
10736 (gnus-summary-next-article t (and gnus-auto-select-same
10737 (gnus-summary-article-subject)))
10738 (gnus-message 7 "%d article%s marked as %s"
10739 count (if (= count 1) " is" "s are")
10740 (if unmark "unread" "read"))))
10742 (defun gnus-summary-kill-same-subject (&optional unmark)
10743 "Mark articles which has the same subject as read.
10744 If UNMARK is positive, remove any kind of mark.
10745 If UNMARK is negative, tick articles."
10746 (interactive "P")
10747 (when unmark
10748 (setq unmark (prefix-numeric-value unmark)))
10749 (let ((count
10750 (gnus-summary-mark-same-subject
10751 (gnus-summary-article-subject) unmark)))
10752 ;; If marked as read, go to next unread subject.
10753 (when (null unmark)
10754 ;; Go to next unread subject.
10755 (gnus-summary-next-subject 1 t))
10756 (gnus-message 7 "%d articles are marked as %s"
10757 count (if unmark "unread" "read"))))
10759 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10760 "Mark articles with same SUBJECT as read, and return marked number.
10761 If optional argument UNMARK is positive, remove any kinds of marks.
10762 If optional argument UNMARK is negative, mark articles as unread instead."
10763 (let ((count 1))
10764 (save-excursion
10765 (cond
10766 ((null unmark) ; Mark as read.
10767 (while (and
10768 (progn
10769 (gnus-summary-mark-article-as-read gnus-killed-mark)
10770 (gnus-summary-show-thread) t)
10771 (gnus-summary-find-subject subject))
10772 (setq count (1+ count))))
10773 ((> unmark 0) ; Tick.
10774 (while (and
10775 (progn
10776 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10777 (gnus-summary-show-thread) t)
10778 (gnus-summary-find-subject subject))
10779 (setq count (1+ count))))
10780 (t ; Mark as unread.
10781 (while (and
10782 (progn
10783 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10784 (gnus-summary-show-thread) t)
10785 (gnus-summary-find-subject subject))
10786 (setq count (1+ count)))))
10787 (gnus-set-mode-line 'summary)
10788 ;; Return the number of marked articles.
10789 count)))
10791 (defun gnus-summary-mark-as-processable (n &optional unmark)
10792 "Set the process mark on the next N articles.
10793 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10794 the process mark instead. The difference between N and the actual
10795 number of articles marked is returned."
10796 (interactive "P")
10797 (if (and (null n) (and transient-mark-mode mark-active))
10798 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10799 (setq n (prefix-numeric-value n))
10800 (let ((backward (< n 0))
10801 (n (abs n)))
10802 (while (and
10803 (> n 0)
10804 (if unmark
10805 (gnus-summary-remove-process-mark
10806 (gnus-summary-article-number))
10807 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10808 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10809 (setq n (1- n)))
10810 (when (/= 0 n)
10811 (gnus-message 7 "No more articles"))
10812 (gnus-summary-recenter)
10813 (gnus-summary-position-point)
10814 n)))
10816 (defun gnus-summary-unmark-as-processable (n)
10817 "Remove the process mark from the next N articles.
10818 If N is negative, unmark backward instead. The difference between N and
10819 the actual number of articles unmarked is returned."
10820 (interactive "P")
10821 (gnus-summary-mark-as-processable n t))
10823 (defun gnus-summary-unmark-all-processable ()
10824 "Remove the process mark from all articles."
10825 (interactive)
10826 (save-excursion
10827 (while gnus-newsgroup-processable
10828 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10829 (gnus-summary-position-point))
10831 (defun gnus-summary-add-mark (article type)
10832 "Mark ARTICLE with a mark of TYPE."
10833 (let ((vtype (car (assq type gnus-article-mark-lists)))
10834 var)
10835 (if (not vtype)
10836 (error "No such mark type: %s" type)
10837 (setq var (intern (format "gnus-newsgroup-%s" type)))
10838 (set var (cons article (symbol-value var)))
10839 (if (memq type '(processable cached replied forwarded recent saved))
10840 (gnus-summary-update-secondary-mark article)
10841 ;;; !!! This is bogus. We should find out what primary
10842 ;;; !!! mark we want to set.
10843 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10845 (defun gnus-summary-mark-as-expirable (n)
10846 "Mark N articles forward as expirable.
10847 If N is negative, mark backward instead. The difference between N and
10848 the actual number of articles marked is returned."
10849 (interactive "p")
10850 (gnus-summary-mark-forward n gnus-expirable-mark))
10852 (defun gnus-summary-mark-as-spam (n)
10853 "Mark N articles forward as spam.
10854 If N is negative, mark backward instead. The difference between N and
10855 the actual number of articles marked is returned."
10856 (interactive "p")
10857 (gnus-summary-mark-forward n gnus-spam-mark))
10859 (defun gnus-summary-mark-article-as-replied (article)
10860 "Mark ARTICLE as replied to and update the summary line.
10861 ARTICLE can also be a list of articles."
10862 (interactive (list (gnus-summary-article-number)))
10863 (let ((articles (if (listp article) article (list article))))
10864 (dolist (article articles)
10865 (unless (numberp article)
10866 (error "%s is not a number" article))
10867 (push article gnus-newsgroup-replied)
10868 (let ((inhibit-read-only t))
10869 (when (gnus-summary-goto-subject article nil t)
10870 (gnus-summary-update-secondary-mark article))))))
10872 (defun gnus-summary-mark-article-as-forwarded (article)
10873 "Mark ARTICLE as forwarded and update the summary line.
10874 ARTICLE can also be a list of articles."
10875 (let ((articles (if (listp article) article (list article))))
10876 (dolist (article articles)
10877 (push article gnus-newsgroup-forwarded)
10878 (let ((inhibit-read-only t))
10879 (when (gnus-summary-goto-subject article nil t)
10880 (gnus-summary-update-secondary-mark article))))))
10882 (defun gnus-summary-set-bookmark (article)
10883 "Set a bookmark in current article."
10884 (interactive (list (gnus-summary-article-number)))
10885 (when (or (not (get-buffer gnus-article-buffer))
10886 (not gnus-current-article)
10887 (not gnus-article-current)
10888 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10889 (error "No current article selected"))
10890 ;; Remove old bookmark, if one exists.
10891 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10892 ;; Set the new bookmark, which is on the form
10893 ;; (article-number . line-number-in-body).
10894 (push
10895 (cons article
10896 (with-current-buffer gnus-article-buffer
10897 (count-lines
10898 (min (point)
10899 (save-excursion
10900 (article-goto-body)
10901 (point)))
10902 (point))))
10903 gnus-newsgroup-bookmarks)
10904 (gnus-message 6 "A bookmark has been added to the current article."))
10906 (defun gnus-summary-remove-bookmark (article)
10907 "Remove the bookmark from the current article."
10908 (interactive (list (gnus-summary-article-number)))
10909 ;; Remove old bookmark, if one exists.
10910 (if (not (assq article gnus-newsgroup-bookmarks))
10911 (gnus-message 6 "No bookmark in current article.")
10912 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10913 (gnus-message 6 "Removed bookmark.")))
10915 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10916 (defun gnus-summary-mark-as-dormant (n)
10917 "Mark N articles forward as dormant.
10918 If N is negative, mark backward instead. The difference between N and
10919 the actual number of articles marked is returned."
10920 (interactive "p")
10921 (gnus-summary-mark-forward n gnus-dormant-mark))
10923 (defun gnus-summary-set-process-mark (article)
10924 "Set the process mark on ARTICLE and update the summary line."
10925 (setq gnus-newsgroup-processable
10926 (cons article
10927 (delq article gnus-newsgroup-processable)))
10928 (when (gnus-summary-goto-subject article)
10929 (gnus-summary-show-thread)
10930 (gnus-summary-goto-subject article)
10931 (gnus-summary-update-secondary-mark article)))
10933 (defun gnus-summary-remove-process-mark (&rest articles)
10934 "Remove the process mark from ARTICLES and update the summary line."
10935 (dolist (article articles)
10936 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10937 (when (gnus-summary-goto-subject article)
10938 (gnus-summary-show-thread)
10939 (gnus-summary-goto-subject article)
10940 (gnus-summary-update-secondary-mark article)))
10943 (defun gnus-summary-set-saved-mark (article)
10944 "Set the process mark on ARTICLE and update the summary line."
10945 (push article gnus-newsgroup-saved)
10946 (when (gnus-summary-goto-subject article)
10947 (gnus-summary-update-secondary-mark article)))
10949 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10950 "Mark N articles as read forwards.
10951 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10952 The difference between N and the actual number of articles marked is
10953 returned.
10954 If NO-EXPIRE, auto-expiry will be inhibited."
10955 (interactive "p")
10956 (gnus-summary-show-thread)
10957 (let ((backward (< n 0))
10958 (gnus-summary-goto-unread
10959 (and gnus-summary-goto-unread
10960 (not (eq gnus-summary-goto-unread 'never))
10961 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10962 gnus-ticked-mark gnus-dormant-mark)))))
10963 (n (abs n))
10964 (mark (or mark gnus-del-mark)))
10965 (while (and (> n 0)
10966 (gnus-summary-mark-article nil mark no-expire)
10967 (zerop (gnus-summary-next-subject
10968 (if backward -1 1)
10969 (and gnus-summary-goto-unread
10970 (not (eq gnus-summary-goto-unread 'never)))
10971 t)))
10972 (setq n (1- n)))
10973 (when (/= 0 n)
10974 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10975 (gnus-summary-recenter)
10976 (gnus-summary-position-point)
10977 (gnus-set-mode-line 'summary)
10980 (defun gnus-summary-mark-article-as-read (mark)
10981 "Mark the current article quickly as read with MARK."
10982 (let ((article (gnus-summary-article-number)))
10983 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10984 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10985 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10986 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10987 (push (cons article mark) gnus-newsgroup-reads)
10988 ;; Possibly remove from cache, if that is used.
10989 (when gnus-use-cache
10990 (gnus-cache-enter-remove-article article))
10991 ;; Allow the backend to change the mark.
10992 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10993 ;; Check for auto-expiry.
10994 (when (and gnus-newsgroup-auto-expire
10995 (memq mark gnus-auto-expirable-marks))
10996 (setq mark gnus-expirable-mark)
10997 ;; Let the backend know about the mark change.
10998 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10999 (push article gnus-newsgroup-expirable))
11000 ;; Set the mark in the buffer.
11001 (gnus-summary-update-mark mark 'unread)
11004 (defun gnus-summary-mark-article-as-unread (mark)
11005 "Mark the current article quickly as unread with MARK."
11006 (let* ((article (gnus-summary-article-number))
11007 (old-mark (gnus-summary-article-mark article)))
11008 ;; Allow the backend to change the mark.
11009 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11010 (if (eq mark old-mark)
11012 (if (<= article 0)
11013 (progn
11014 (gnus-error 1 "Can't mark negative article numbers")
11015 nil)
11016 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11017 (setq gnus-newsgroup-spam-marked
11018 (delq article gnus-newsgroup-spam-marked))
11019 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11020 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11021 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11022 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11023 (cond ((= mark gnus-ticked-mark)
11024 (setq gnus-newsgroup-marked
11025 (gnus-add-to-sorted-list gnus-newsgroup-marked
11026 article)))
11027 ((= mark gnus-spam-mark)
11028 (setq gnus-newsgroup-spam-marked
11029 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11030 article)))
11031 ((= mark gnus-dormant-mark)
11032 (setq gnus-newsgroup-dormant
11033 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11034 article)))
11036 (setq gnus-newsgroup-unreads
11037 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11038 article))))
11039 (gnus-alist-pull article gnus-newsgroup-reads)
11041 ;; See whether the article is to be put in the cache.
11042 (and gnus-use-cache
11043 (vectorp (gnus-summary-article-header article))
11044 (save-excursion
11045 (gnus-cache-possibly-enter-article
11046 gnus-newsgroup-name article
11047 (= mark gnus-ticked-mark)
11048 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11050 ;; Fix the mark.
11051 (gnus-summary-update-mark mark 'unread)
11052 t))))
11054 (defun gnus-summary-mark-article (&optional article mark no-expire)
11055 "Mark ARTICLE with MARK. MARK can be any character.
11056 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11057 `??' (dormant) and `?E' (expirable).
11058 If MARK is nil, then the default character `?r' is used.
11059 If ARTICLE is nil, then the article on the current line will be
11060 marked.
11061 If NO-EXPIRE, auto-expiry will be inhibited."
11062 ;; The mark might be a string.
11063 (when (stringp mark)
11064 (setq mark (aref mark 0)))
11065 ;; If no mark is given, then we check auto-expiring.
11066 (when (null mark)
11067 (setq mark gnus-del-mark))
11068 (when (and (not no-expire)
11069 gnus-newsgroup-auto-expire
11070 (memq mark gnus-auto-expirable-marks))
11071 (setq mark gnus-expirable-mark))
11072 (let ((article (or article (gnus-summary-article-number)))
11073 (old-mark (gnus-summary-article-mark article)))
11074 ;; Allow the backend to change the mark.
11075 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11076 (if (eq mark old-mark)
11078 (unless article
11079 (error "No article on current line"))
11080 (if (not (if (or (= mark gnus-unread-mark)
11081 (= mark gnus-ticked-mark)
11082 (= mark gnus-spam-mark)
11083 (= mark gnus-dormant-mark))
11084 (gnus-mark-article-as-unread article mark)
11085 (gnus-mark-article-as-read article mark)))
11087 ;; See whether the article is to be put in the cache.
11088 (and gnus-use-cache
11089 (not (= mark gnus-canceled-mark))
11090 (vectorp (gnus-summary-article-header article))
11091 (save-excursion
11092 (gnus-cache-possibly-enter-article
11093 gnus-newsgroup-name article
11094 (= mark gnus-ticked-mark)
11095 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11097 (when (gnus-summary-goto-subject article nil t)
11098 (let ((inhibit-read-only t))
11099 (gnus-summary-show-thread)
11100 ;; Fix the mark.
11101 (gnus-summary-update-mark mark 'unread)
11102 t))))))
11104 (defun gnus-summary-update-secondary-mark (article)
11105 "Update the secondary (read, process, cache) mark."
11106 (gnus-summary-update-mark
11107 (cond ((memq article gnus-newsgroup-processable)
11108 gnus-process-mark)
11109 ((memq article gnus-newsgroup-cached)
11110 gnus-cached-mark)
11111 ((memq article gnus-newsgroup-replied)
11112 gnus-replied-mark)
11113 ((memq article gnus-newsgroup-forwarded)
11114 gnus-forwarded-mark)
11115 ((memq article gnus-newsgroup-saved)
11116 gnus-saved-mark)
11117 ((memq article gnus-newsgroup-unseen)
11118 gnus-unseen-mark)
11119 (t gnus-no-mark))
11120 'replied)
11121 (when (gnus-visual-p 'summary-highlight 'highlight)
11122 (gnus-summary-highlight-line)
11123 (gnus-run-hooks 'gnus-summary-update-hook))
11126 (defun gnus-summary-update-download-mark (article)
11127 "Update the download mark."
11128 (gnus-summary-update-mark
11129 (cond ((memq article gnus-newsgroup-undownloaded)
11130 gnus-undownloaded-mark)
11131 (gnus-newsgroup-agentized
11132 gnus-downloaded-mark)
11134 gnus-no-mark))
11135 'download)
11136 (gnus-summary-update-line t)
11139 (defun gnus-summary-update-mark (mark type)
11140 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11141 (inhibit-read-only t))
11142 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11143 (when forward
11144 (when (looking-at "\r")
11145 (incf forward))
11146 (when (<= (+ forward (point)) (point-max))
11147 ;; Go to the right position on the line.
11148 (goto-char (+ forward (point)))
11149 ;; Replace the old mark with the new mark.
11150 (let ((to-insert
11151 (subst-char-in-string
11152 (char-after) mark
11153 (buffer-substring (point) (1+ (point))))))
11154 (delete-region (point) (1+ (point)))
11155 (insert to-insert))
11156 ;; Optionally update the marks by some user rule.
11157 (when (eq type 'unread)
11158 (gnus-data-set-mark
11159 (gnus-data-find (gnus-summary-article-number)) mark)
11160 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11162 (defun gnus-mark-article-as-read (article &optional mark)
11163 "Enter ARTICLE in the pertinent lists and remove it from others."
11164 ;; Make the article expirable.
11165 (let ((mark (or mark gnus-del-mark)))
11166 (setq gnus-newsgroup-expirable
11167 (if (= mark gnus-expirable-mark)
11168 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11169 (delq article gnus-newsgroup-expirable)))
11170 ;; Remove from unread and marked lists.
11171 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11172 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11173 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11174 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11175 (push (cons article mark) gnus-newsgroup-reads)
11176 ;; Possibly remove from cache, if that is used.
11177 (when gnus-use-cache
11178 (gnus-cache-enter-remove-article article))
11181 (defun gnus-mark-article-as-unread (article &optional mark)
11182 "Enter ARTICLE in the pertinent lists and remove it from others."
11183 (let ((mark (or mark gnus-ticked-mark)))
11184 (if (<= article 0)
11185 (progn
11186 (gnus-error 1 "Can't mark negative article numbers")
11187 nil)
11188 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11189 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11190 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11191 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11192 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11194 ;; Unsuppress duplicates?
11195 (when gnus-suppress-duplicates
11196 (gnus-dup-unsuppress-article article))
11198 (cond ((= mark gnus-ticked-mark)
11199 (setq gnus-newsgroup-marked
11200 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11201 ((= mark gnus-spam-mark)
11202 (setq gnus-newsgroup-spam-marked
11203 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11204 article)))
11205 ((= mark gnus-dormant-mark)
11206 (setq gnus-newsgroup-dormant
11207 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11209 (setq gnus-newsgroup-unreads
11210 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11211 (gnus-alist-pull article gnus-newsgroup-reads)
11212 t)))
11214 (defun gnus-summary-tick-article-forward (n)
11215 "Tick N articles forwards.
11216 If N is negative, tick backwards instead.
11217 The difference between N and the number of articles ticked is returned."
11218 (interactive "p")
11219 (gnus-summary-mark-forward n gnus-ticked-mark))
11221 (defun gnus-summary-tick-article-backward (n)
11222 "Tick N articles backwards.
11223 The difference between N and the number of articles ticked is returned."
11224 (interactive "p")
11225 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11227 (defun gnus-summary-tick-article (&optional article clear-mark)
11228 "Mark current article as unread.
11229 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11230 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11231 (interactive)
11232 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11233 gnus-ticked-mark)))
11235 (defun gnus-summary-mark-as-read-forward (n)
11236 "Mark N articles as read forwards.
11237 If N is negative, mark backwards instead.
11238 The difference between N and the actual number of articles marked is
11239 returned."
11240 (interactive "p")
11241 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11243 (defun gnus-summary-mark-as-read-backward (n)
11244 "Mark the N articles as read backwards.
11245 The difference between N and the actual number of articles marked is
11246 returned."
11247 (interactive "p")
11248 (gnus-summary-mark-forward
11249 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11251 (defun gnus-summary-mark-as-read (&optional article mark)
11252 "Mark current article as read.
11253 ARTICLE specifies the article to be marked as read.
11254 MARK specifies a string to be inserted at the beginning of the line."
11255 (gnus-summary-mark-article article mark))
11257 (defun gnus-summary-clear-mark-forward (n)
11258 "Clear marks from N articles forward.
11259 If N is negative, clear backward instead.
11260 The difference between N and the number of marks cleared is returned."
11261 (interactive "p")
11262 (gnus-summary-mark-forward n gnus-unread-mark))
11264 (defun gnus-summary-clear-mark-backward (n)
11265 "Clear marks from N articles backward.
11266 The difference between N and the number of marks cleared is returned."
11267 (interactive "p")
11268 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11270 (defun gnus-summary-mark-unread-as-read ()
11271 "Intended to be used by `gnus-mark-article-hook'."
11272 (when (memq gnus-current-article gnus-newsgroup-unreads)
11273 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11275 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11276 "Intended to be used by `gnus-mark-article-hook'."
11277 (let ((mark (gnus-summary-article-mark)))
11278 (when (or (gnus-unread-mark-p mark)
11279 (gnus-read-mark-p mark))
11280 (gnus-summary-mark-article gnus-current-article
11281 (or new-mark gnus-read-mark)))))
11283 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11284 "Intended to be used by `gnus-mark-article-hook'."
11285 (let ((mark (gnus-summary-article-mark)))
11286 (when (or (gnus-unread-mark-p mark)
11287 (gnus-read-mark-p mark))
11288 (gnus-summary-mark-article (gnus-summary-article-number)
11289 (or new-mark gnus-read-mark)))))
11291 (defun gnus-summary-mark-unread-as-ticked ()
11292 "Intended to be used by `gnus-mark-article-hook'."
11293 (when (memq gnus-current-article gnus-newsgroup-unreads)
11294 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11296 (defun gnus-summary-mark-region-as-read (point mark all)
11297 "Mark all unread articles between point and mark as read.
11298 If given a prefix, mark all articles between point and mark as read,
11299 even ticked and dormant ones."
11300 (interactive "r\nP")
11301 (save-excursion
11302 (let (article)
11303 (goto-char point)
11304 (beginning-of-line)
11305 (while (and
11306 (< (point) mark)
11307 (progn
11308 (when (or all
11309 (memq (setq article (gnus-summary-article-number))
11310 gnus-newsgroup-unreads))
11311 (gnus-summary-mark-article article gnus-del-mark))
11313 (gnus-summary-find-next))))))
11315 (defun gnus-summary-mark-below (score mark)
11316 "Mark articles with score less than SCORE with MARK."
11317 (interactive "P\ncMark: ")
11318 (setq score (if score
11319 (prefix-numeric-value score)
11320 (or gnus-summary-default-score 0)))
11321 (with-current-buffer gnus-summary-buffer
11322 (goto-char (point-min))
11323 (while
11324 (progn
11325 (and (< (gnus-summary-article-score) score)
11326 (gnus-summary-mark-article nil mark))
11327 (gnus-summary-find-next)))))
11329 (defun gnus-summary-kill-below (&optional score)
11330 "Mark articles with score below SCORE as read."
11331 (interactive "P")
11332 (gnus-summary-mark-below score gnus-killed-mark))
11334 (defun gnus-summary-clear-above (&optional score)
11335 "Clear all marks from articles with score above SCORE."
11336 (interactive "P")
11337 (gnus-summary-mark-above score gnus-unread-mark))
11339 (defun gnus-summary-tick-above (&optional score)
11340 "Tick all articles with score above SCORE."
11341 (interactive "P")
11342 (gnus-summary-mark-above score gnus-ticked-mark))
11344 (defun gnus-summary-mark-above (score mark)
11345 "Mark articles with score over SCORE with MARK."
11346 (interactive "P\ncMark: ")
11347 (setq score (if score
11348 (prefix-numeric-value score)
11349 (or gnus-summary-default-score 0)))
11350 (with-current-buffer gnus-summary-buffer
11351 (goto-char (point-min))
11352 (while (and (progn
11353 (when (> (gnus-summary-article-score) score)
11354 (gnus-summary-mark-article nil mark))
11356 (gnus-summary-find-next)))))
11358 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11359 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11360 (defun gnus-summary-limit-include-expunged (&optional no-error)
11361 "Display all the hidden articles that were expunged for low scores."
11362 (interactive)
11363 (let ((inhibit-read-only t))
11364 (let ((scored gnus-newsgroup-scored)
11365 headers h)
11366 (while scored
11367 (unless (gnus-summary-article-header (caar scored))
11368 (and (setq h (gnus-number-to-header (caar scored)))
11369 (< (cdar scored) gnus-summary-expunge-below)
11370 (push h headers)))
11371 (setq scored (cdr scored)))
11372 (if (not headers)
11373 (when (not no-error)
11374 (error "No expunged articles hidden"))
11375 (goto-char (point-min))
11376 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11377 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11378 (dolist (x headers)
11379 (push (mail-header-number x) gnus-newsgroup-limit))
11380 (gnus-summary-prepare-unthreaded (nreverse headers))
11381 (goto-char (point-min))
11382 (gnus-summary-position-point)
11383 t))))
11385 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11386 "Mark all unread articles in this newsgroup as read.
11387 If prefix argument ALL is non-nil, ticked and dormant articles will
11388 also be marked as read.
11389 If QUIETLY is non-nil, no questions will be asked.
11391 If TO-HERE is non-nil, it should be a point in the buffer. All
11392 articles before (after, if REVERSE is set) this point will be marked
11393 as read.
11395 Note that this function will only catch up the unread article
11396 in the current summary buffer limitation.
11398 The number of articles marked as read is returned."
11399 (interactive "P")
11400 (prog1
11401 (save-excursion
11402 (when (or quietly
11403 (not gnus-interactive-catchup) ;Without confirmation?
11404 gnus-expert-user
11405 (gnus-y-or-n-p
11406 (if all
11407 "Mark absolutely all articles as read? "
11408 "Mark all unread articles as read? ")))
11409 (if (and not-mark
11410 (not gnus-newsgroup-adaptive)
11411 (not gnus-newsgroup-auto-expire)
11412 (not gnus-suppress-duplicates)
11413 (or (not gnus-use-cache)
11414 (eq gnus-use-cache 'passive)))
11415 (progn
11416 (when all
11417 (setq gnus-newsgroup-marked nil
11418 gnus-newsgroup-spam-marked nil
11419 gnus-newsgroup-dormant nil))
11420 (setq gnus-newsgroup-unreads
11421 (gnus-sorted-nunion
11422 (gnus-sorted-intersection gnus-newsgroup-unreads
11423 gnus-newsgroup-downloadable)
11424 (gnus-sorted-difference gnus-newsgroup-unfetched
11425 gnus-newsgroup-cached))))
11426 ;; We actually mark all articles as canceled, which we
11427 ;; have to do when using auto-expiry or adaptive scoring.
11428 (gnus-summary-show-all-threads)
11429 (if (and to-here reverse)
11430 (progn
11431 (goto-char to-here)
11432 (gnus-summary-mark-current-read-and-unread-as-read
11433 gnus-catchup-mark)
11434 (while (gnus-summary-find-next (not all))
11435 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11436 (when (gnus-summary-first-subject (not all))
11437 (while (and
11438 (if to-here (< (point) to-here) t)
11439 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11440 (gnus-summary-find-next (not all))))))
11441 (gnus-set-mode-line 'summary))
11443 (gnus-summary-position-point)))
11445 (defun gnus-summary-catchup-to-here (&optional all)
11446 "Mark all unticked articles before the current one as read.
11447 If ALL is non-nil, also mark ticked and dormant articles as read."
11448 (interactive "P")
11449 (save-excursion
11450 (gnus-save-hidden-threads
11451 (let ((beg (point)))
11452 ;; We check that there are unread articles.
11453 (when (or all (gnus-summary-find-prev))
11454 (gnus-summary-catchup all t beg)))))
11455 (gnus-summary-position-point))
11457 (defun gnus-summary-catchup-from-here (&optional all)
11458 "Mark all unticked articles after (and including) the current one as read.
11459 If ALL is non-nil, also mark ticked and dormant articles as read."
11460 (interactive "P")
11461 (save-excursion
11462 (gnus-save-hidden-threads
11463 (let ((beg (point)))
11464 ;; We check that there are unread articles.
11465 (when (or all (gnus-summary-find-next))
11466 (gnus-summary-catchup all t beg nil t)))))
11467 (gnus-summary-position-point))
11469 (defun gnus-summary-catchup-all (&optional quietly)
11470 "Mark all articles in this newsgroup as read.
11471 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11472 instead, which marks only unread articles as read."
11473 (interactive "P")
11474 (gnus-summary-catchup t quietly))
11476 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11477 "Mark all unread articles in this group as read, then exit.
11478 If prefix argument ALL is non-nil, all articles are marked as read.
11479 If QUIETLY is non-nil, no questions will be asked."
11480 (interactive "P")
11481 (when (gnus-summary-catchup all quietly nil 'fast)
11482 ;; Select next newsgroup or exit.
11483 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11484 (eq gnus-auto-select-next 'quietly))
11485 (gnus-summary-next-group nil)
11486 (gnus-summary-exit))))
11488 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11489 "Mark all articles in this newsgroup as read, and then exit.
11490 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11491 instead, which marks only unread articles as read."
11492 (interactive "P")
11493 (gnus-summary-catchup-and-exit t quietly))
11495 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11496 "Mark all articles in this group as read and select the next group.
11497 If given a prefix, mark all articles, unread as well as ticked, as
11498 read."
11499 (interactive "P")
11500 (save-excursion
11501 (gnus-summary-catchup all))
11502 (gnus-summary-next-group))
11504 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11505 "Mark all articles in this group as read and select the previous group.
11506 If given a prefix, mark all articles, unread as well as ticked, as
11507 read."
11508 (interactive "P")
11509 (save-excursion
11510 (gnus-summary-catchup all))
11511 (gnus-summary-next-group nil nil t))
11514 ;;; with article
11517 (defmacro gnus-with-article (article &rest forms)
11518 "Select ARTICLE and perform FORMS in the original article buffer.
11519 Then replace the article with the result."
11520 `(progn
11521 ;; We don't want the article to be marked as read.
11522 (let (gnus-mark-article-hook)
11523 (gnus-summary-select-article t t nil ,article))
11524 (set-buffer gnus-original-article-buffer)
11525 ,@forms
11526 (if (not (gnus-check-backend-function
11527 'request-replace-article (car gnus-article-current)))
11528 (gnus-message 5 "Read-only group; not replacing")
11529 (unless (gnus-request-replace-article
11530 ,article (car gnus-article-current)
11531 (current-buffer) t)
11532 (error "Couldn't replace article")))
11533 ;; The cache and backlog have to be flushed somewhat.
11534 (when gnus-keep-backlog
11535 (gnus-backlog-remove-article
11536 (car gnus-article-current) (cdr gnus-article-current)))
11537 (when gnus-use-cache
11538 (gnus-cache-update-article
11539 (car gnus-article-current) (cdr gnus-article-current)))))
11541 (put 'gnus-with-article 'lisp-indent-function 1)
11542 (put 'gnus-with-article 'edebug-form-spec '(form body))
11544 ;; Thread-based commands.
11546 (defun gnus-summary-articles-in-thread (&optional article)
11547 "Return a list of all articles in the current thread.
11548 If ARTICLE is non-nil, return all articles in the thread that starts
11549 with that article."
11550 (let* ((article (or article (gnus-summary-article-number)))
11551 (data (gnus-data-find-list article))
11552 (top-level (gnus-data-level (car data)))
11553 (top-subject
11554 (cond ((null gnus-thread-operation-ignore-subject)
11555 (gnus-simplify-subject-re
11556 (mail-header-subject (gnus-data-header (car data)))))
11557 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11558 (gnus-simplify-subject-fuzzy
11559 (mail-header-subject (gnus-data-header (car data)))))
11560 (t nil)))
11561 (end-point (save-excursion
11562 (goto-char (gnus-data-pos (car data)))
11563 (if (gnus-summary-go-to-next-thread)
11564 (point) (point-max))))
11565 articles)
11566 (while (and data
11567 (< (gnus-data-pos (car data)) end-point))
11568 (when (or (not top-subject)
11569 (string= top-subject
11570 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11571 (gnus-simplify-subject-fuzzy
11572 (mail-header-subject
11573 (gnus-data-header (car data))))
11574 (gnus-simplify-subject-re
11575 (mail-header-subject
11576 (gnus-data-header (car data)))))))
11577 (push (gnus-data-number (car data)) articles))
11578 (unless (and (setq data (cdr data))
11579 (> (gnus-data-level (car data)) top-level))
11580 (setq data nil)))
11581 ;; Return the list of articles.
11582 (nreverse articles)))
11584 (defun gnus-summary-rethread-current ()
11585 "Rethread the thread the current article is part of."
11586 (interactive)
11587 (let* ((gnus-show-threads t)
11588 (article (gnus-summary-article-number))
11589 (id (mail-header-id (gnus-summary-article-header)))
11590 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11591 (unless id
11592 (error "No article on the current line"))
11593 (gnus-rebuild-thread id)
11594 (gnus-summary-goto-subject article)))
11596 (defun gnus-summary-reparent-thread ()
11597 "Make the current article child of the marked (or previous) article.
11599 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11600 is non-nil or the Subject: of both articles are the same."
11601 (interactive)
11602 (unless (not (gnus-group-read-only-p))
11603 (error "The current newsgroup does not support article editing"))
11604 (unless (<= (length gnus-newsgroup-processable) 1)
11605 (error "No more than one article may be marked"))
11606 (let ((child (gnus-summary-article-number))
11607 ;; First grab the marked article, otherwise one line up.
11608 (parent (if (not (null gnus-newsgroup-processable))
11609 (car gnus-newsgroup-processable)
11610 (save-excursion
11611 (if (eq (forward-line -1) 0)
11612 (gnus-summary-article-number)
11613 (error "Beginning of summary buffer"))))))
11614 (gnus-summary-reparent-children parent (list child))))
11616 (defun gnus-summary-reparent-children (parent children)
11617 "Make PARENT the parent of CHILDREN.
11618 When called interactively, PARENT is the current article and CHILDREN
11619 are the process-marked articles."
11620 (interactive
11621 (list (gnus-summary-article-number)
11622 (gnus-summary-work-articles nil)))
11623 (dolist (child children)
11624 (save-window-excursion
11625 (let ((gnus-article-buffer " *reparent*"))
11626 (unless (not (eq parent child))
11627 (error "An article may not be self-referential"))
11628 (let ((message-id (mail-header-id
11629 (gnus-summary-article-header parent))))
11630 (unless (and message-id (not (equal message-id "")))
11631 (error "No message-id in desired parent"))
11632 (gnus-with-article child
11633 (save-restriction
11634 (goto-char (point-min))
11635 (message-narrow-to-head)
11636 (if (re-search-forward "^References: " nil t)
11637 (progn
11638 (re-search-forward "^[^ \t]" nil t)
11639 (forward-line -1)
11640 (end-of-line)
11641 (insert " " message-id))
11642 (insert "References: " message-id "\n"))))
11643 (set-buffer gnus-summary-buffer)
11644 (gnus-summary-unmark-all-processable)
11645 (gnus-summary-update-article child)
11646 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11647 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11648 (gnus-summary-rethread-current)
11649 (gnus-message 3 "Article %d is now the child of article %d"
11650 child parent))))))
11652 (defun gnus-summary-toggle-threads (&optional arg)
11653 "Toggle showing conversation threads.
11654 If ARG is positive number, turn showing conversation threads on."
11655 (interactive "P")
11656 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11657 (setq gnus-show-threads
11658 (if (null arg) (not gnus-show-threads)
11659 (> (prefix-numeric-value arg) 0)))
11660 (gnus-summary-prepare)
11661 (gnus-summary-goto-subject current)
11662 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11663 (gnus-summary-position-point)))
11665 (defun gnus-summary-show-all-threads ()
11666 "Show all threads."
11667 (interactive)
11668 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11669 (gnus-summary-position-point))
11671 (defsubst gnus-summary--inv (p)
11672 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11674 (defun gnus-summary-show-thread ()
11675 "Show thread subtrees.
11676 Returns nil if no thread was there to be shown."
11677 (interactive)
11678 (let* ((orig (point))
11679 (end (point-at-eol))
11680 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11681 ;; Leave point at bol
11682 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11683 (eoi (and end (next-single-char-property-change end 'invisible))))
11684 (when eoi
11685 (remove-overlays beg eoi 'invisible 'gnus-sum)
11686 (goto-char orig)
11687 (gnus-summary-position-point)
11688 eoi)))
11690 (defun gnus-summary-maybe-hide-threads ()
11691 "If requested, hide the threads that should be hidden."
11692 (when (and gnus-show-threads
11693 gnus-thread-hide-subtree)
11694 (gnus-summary-hide-all-threads
11695 (if (or (consp gnus-thread-hide-subtree)
11696 (functionp gnus-thread-hide-subtree))
11697 (gnus-make-predicate gnus-thread-hide-subtree)
11698 nil))))
11700 ;;; Hiding predicates.
11702 (defun gnus-article-unread-p (header)
11703 (memq (mail-header-number header) gnus-newsgroup-unreads))
11705 (defun gnus-article-unseen-p (header)
11706 (memq (mail-header-number header) gnus-newsgroup-unseen))
11708 (defun gnus-map-articles (predicate articles)
11709 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11710 (apply 'gnus-or (mapcar predicate
11711 (mapcar (lambda (number)
11712 (gnus-summary-article-header number))
11713 articles))))
11715 (defun gnus-summary-hide-all-threads (&optional predicate)
11716 "Hide all thread subtrees.
11717 If PREDICATE is supplied, threads that satisfy this predicate
11718 will not be hidden."
11719 (interactive)
11720 (save-excursion
11721 (goto-char (point-min))
11722 (let ((end nil)
11723 (count 0))
11724 (while (not end)
11725 (incf count)
11726 (when (zerop (mod count 1000))
11727 (message "Hiding all threads... %d" count))
11728 (when (or (not predicate)
11729 (gnus-map-articles
11730 predicate (gnus-summary-article-children)))
11731 (gnus-summary-hide-thread))
11732 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11733 (gnus-summary-position-point))
11735 (defun gnus-summary-hide-thread ()
11736 "Hide thread subtrees.
11737 If PREDICATE is supplied, threads that satisfy this predicate
11738 will not be hidden.
11739 Returns nil if no threads were there to be hidden."
11740 (interactive)
11741 (beginning-of-line)
11742 (let ((start (point))
11743 (starteol (line-end-position))
11744 (article (gnus-summary-article-number)))
11745 ;; Go forward until either the buffer ends or the subthread ends.
11746 (when (and (not (eobp))
11747 (or (zerop (gnus-summary-next-thread 1 t))
11748 (goto-char (point-max))))
11749 (if (and (> (point) start)
11750 ;; FIXME: this should actually search for a non-invisible \n.
11751 (search-backward "\n" start t))
11752 (progn
11753 (when (> (point) starteol)
11754 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11755 (let ((ol (make-overlay starteol (point) nil t nil)))
11756 (overlay-put ol 'invisible 'gnus-sum)
11757 (overlay-put ol 'evaporate t)))
11758 (gnus-summary-goto-subject article)
11759 (when (> start (point))
11760 (message "Hiding the thread moved us backwards, aborting!")
11761 (goto-char (point-max))))
11762 (goto-char start)
11763 nil))))
11765 (defun gnus-summary-go-to-next-thread (&optional previous)
11766 "Go to the same level (or less) next thread.
11767 If PREVIOUS is non-nil, go to previous thread instead.
11768 Return the article number moved to, or nil if moving was impossible."
11769 (let ((level (gnus-summary-thread-level))
11770 (way (if previous -1 1))
11771 (beg (point)))
11772 (forward-line way)
11773 (while (and (not (eobp))
11774 (< level (gnus-summary-thread-level)))
11775 (forward-line way))
11776 (if (eobp)
11777 (progn
11778 (goto-char beg)
11779 nil)
11780 (setq beg (point))
11781 (prog1
11782 (gnus-summary-article-number)
11783 (goto-char beg)))))
11785 (defun gnus-summary-next-thread (n &optional silent)
11786 "Go to the same level next N'th thread.
11787 If N is negative, search backward instead.
11788 Returns the difference between N and the number of skips actually
11789 done.
11791 If SILENT, don't output messages."
11792 (interactive "p")
11793 (let ((backward (< n 0))
11794 (n (abs n)))
11795 (while (and (> n 0)
11796 (gnus-summary-go-to-next-thread backward))
11797 (decf n))
11798 (unless silent
11799 (gnus-summary-position-point))
11800 (when (and (not silent) (/= 0 n))
11801 (gnus-message 7 "No more threads"))
11804 (defun gnus-summary-prev-thread (n)
11805 "Go to the same level previous N'th thread.
11806 Returns the difference between N and the number of skips actually
11807 done."
11808 (interactive "p")
11809 (gnus-summary-next-thread (- n)))
11811 (defun gnus-summary-go-down-thread ()
11812 "Go down one level in the current thread."
11813 (let ((children (gnus-summary-article-children)))
11814 (when children
11815 (gnus-summary-goto-subject (car children)))))
11817 (defun gnus-summary-go-up-thread ()
11818 "Go up one level in the current thread."
11819 (let ((parent (gnus-summary-article-parent)))
11820 (when parent
11821 (gnus-summary-goto-subject parent))))
11823 (defun gnus-summary-down-thread (n)
11824 "Go down thread N steps.
11825 If N is negative, go up instead.
11826 Returns the difference between N and how many steps down that were
11827 taken."
11828 (interactive "p")
11829 (let ((up (< n 0))
11830 (n (abs n)))
11831 (while (and (> n 0)
11832 (if up (gnus-summary-go-up-thread)
11833 (gnus-summary-go-down-thread)))
11834 (setq n (1- n)))
11835 (gnus-summary-position-point)
11836 (when (/= 0 n)
11837 (gnus-message 7 "Can't go further"))
11840 (defun gnus-summary-up-thread (n)
11841 "Go up thread N steps.
11842 If N is negative, go down instead.
11843 Returns the difference between N and how many steps down that were
11844 taken."
11845 (interactive "p")
11846 (gnus-summary-down-thread (- n)))
11848 (defun gnus-summary-top-thread ()
11849 "Go to the top of the thread."
11850 (interactive)
11851 (while (gnus-summary-go-up-thread))
11852 (gnus-summary-article-number))
11854 (defun gnus-summary-expire-thread ()
11855 "Mark articles under current thread as expired."
11856 (interactive)
11857 (gnus-summary-kill-thread 0))
11859 (defun gnus-summary-kill-thread (&optional unmark)
11860 "Mark articles under current thread as read.
11861 If the prefix argument is positive, remove any kinds of marks.
11862 If the prefix argument is zero, mark thread as expired.
11863 If the prefix argument is negative, tick articles instead."
11864 (interactive "P")
11865 (when unmark
11866 (setq unmark (prefix-numeric-value unmark)))
11867 (let ((articles (gnus-summary-articles-in-thread))
11868 (hide (or (null unmark) (= unmark 0))))
11869 (save-excursion
11870 ;; Expand the thread.
11871 (gnus-summary-show-thread)
11872 ;; Mark all the articles.
11873 (while articles
11874 (gnus-summary-goto-subject (car articles))
11875 (cond ((null unmark)
11876 (gnus-summary-mark-article-as-read gnus-killed-mark))
11877 ((> unmark 0)
11878 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11879 ((= unmark 0)
11880 (gnus-summary-mark-article nil gnus-expirable-mark))
11882 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11883 (setq articles (cdr articles))))
11884 ;; Hide killed subtrees when hide is true.
11885 (and hide
11886 gnus-thread-hide-killed
11887 (gnus-summary-hide-thread))
11888 ;; If hide is t, go to next unread subject.
11889 (when hide
11890 ;; Go to next unread subject.
11891 (gnus-summary-next-subject 1 t)))
11892 (gnus-set-mode-line 'summary))
11894 ;; Summary sorting commands
11896 (defun gnus-summary-sort-by-number (&optional reverse)
11897 "Sort the summary buffer by article number.
11898 Argument REVERSE means reverse order."
11899 (interactive "P")
11900 (gnus-summary-sort 'number reverse))
11902 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11903 "Sort the summary buffer by most recent article number.
11904 Argument REVERSE means reverse order."
11905 (interactive "P")
11906 (gnus-summary-sort 'most-recent-number reverse))
11908 (defun gnus-summary-sort-by-random (&optional reverse)
11909 "Randomize the order in the summary buffer.
11910 Argument REVERSE means to randomize in reverse order."
11911 (interactive "P")
11912 (gnus-summary-sort 'random reverse))
11914 (defun gnus-summary-sort-by-author (&optional reverse)
11915 "Sort the summary buffer by author name alphabetically.
11916 If `case-fold-search' is non-nil, case of letters is ignored.
11917 Argument REVERSE means reverse order."
11918 (interactive "P")
11919 (gnus-summary-sort 'author reverse))
11921 (defun gnus-summary-sort-by-recipient (&optional reverse)
11922 "Sort the summary buffer by recipient name alphabetically.
11923 If `case-fold-search' is non-nil, case of letters is ignored.
11924 Argument REVERSE means reverse order."
11925 (interactive "P")
11926 (gnus-summary-sort 'recipient reverse))
11928 (defun gnus-summary-sort-by-subject (&optional reverse)
11929 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11930 If `case-fold-search' is non-nil, case of letters is ignored.
11931 Argument REVERSE means reverse order."
11932 (interactive "P")
11933 (gnus-summary-sort 'subject reverse))
11935 (defun gnus-summary-sort-by-date (&optional reverse)
11936 "Sort the summary buffer by date.
11937 Argument REVERSE means reverse order."
11938 (interactive "P")
11939 (gnus-summary-sort 'date reverse))
11941 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11942 "Sort the summary buffer by most recent date.
11943 Argument REVERSE means reverse order."
11944 (interactive "P")
11945 (gnus-summary-sort 'most-recent-date reverse))
11947 (defun gnus-summary-sort-by-score (&optional reverse)
11948 "Sort the summary buffer by score.
11949 Argument REVERSE means reverse order."
11950 (interactive "P")
11951 (gnus-summary-sort 'score reverse))
11953 (defun gnus-summary-sort-by-lines (&optional reverse)
11954 "Sort the summary buffer by the number of lines.
11955 Argument REVERSE means reverse order."
11956 (interactive "P")
11957 (gnus-summary-sort 'lines reverse))
11959 (defun gnus-summary-sort-by-chars (&optional reverse)
11960 "Sort the summary buffer by article length.
11961 Argument REVERSE means reverse order."
11962 (interactive "P")
11963 (gnus-summary-sort 'chars reverse))
11965 (defun gnus-summary-sort-by-mark (&optional reverse)
11966 "Sort the summary buffer by article marks.
11967 Argument REVERSE means reverse order."
11968 (interactive "P")
11969 (gnus-summary-sort 'marks reverse))
11971 (defun gnus-summary-sort-by-original (&optional reverse)
11972 "Sort the summary buffer using the default sorting method.
11973 Argument REVERSE means reverse order."
11974 (interactive "P")
11975 (let* ((inhibit-read-only t)
11976 (gnus-summary-prepare-hook nil))
11977 ;; We do the sorting by regenerating the threads.
11978 (gnus-summary-prepare)
11979 ;; Hide subthreads if needed.
11980 (gnus-summary-maybe-hide-threads)))
11982 (defun gnus-summary-sort (predicate reverse)
11983 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11984 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11985 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11986 (gnus-thread-sort-functions
11987 (if (not reverse)
11988 thread
11989 `(lambda (t1 t2)
11990 (,thread t2 t1))))
11991 (gnus-sort-gathered-threads-function
11992 gnus-thread-sort-functions)
11993 (gnus-article-sort-functions
11994 (if (not reverse)
11995 article
11996 `(lambda (t1 t2)
11997 (,article t2 t1))))
11998 (inhibit-read-only t)
11999 (gnus-summary-prepare-hook nil))
12000 ;; We do the sorting by regenerating the threads.
12001 (gnus-summary-prepare)
12002 ;; Hide subthreads if needed.
12003 (gnus-summary-maybe-hide-threads)))
12005 ;; Summary saving commands.
12007 (defun gnus-summary-save-article (&optional n not-saved)
12008 "Save the current article using the default saver function.
12009 If N is a positive number, save the N next articles.
12010 If N is a negative number, save the N previous articles.
12011 If N is nil and any articles have been marked with the process mark,
12012 save those articles instead.
12013 The variable `gnus-default-article-saver' specifies the saver function.
12015 If the optional second argument NOT-SAVED is non-nil, articles saved
12016 will not be marked as saved.
12018 The `gnus-prompt-before-saving' variable says how prompting is
12019 performed."
12020 (interactive "P")
12021 (require 'gnus-art)
12022 (let* ((articles (gnus-summary-work-articles n))
12023 (save-buffer (save-excursion
12024 (nnheader-set-temp-buffer " *Gnus Save*")))
12025 (num (length articles))
12026 ;; Whether to save decoded articles or raw articles.
12027 (decode (when gnus-article-save-coding-system
12028 (get gnus-default-article-saver :decode)))
12029 ;; When saving many articles in a single file, use the other
12030 ;; function to save articles other than the first one.
12031 (saver2 (get gnus-default-article-saver :function))
12032 (gnus-prompt-before-saving (if saver2
12034 gnus-prompt-before-saving))
12035 (gnus-default-article-saver gnus-default-article-saver)
12036 header file)
12037 (dolist (article articles)
12038 (setq header (gnus-summary-article-header article))
12039 (if (not (vectorp header))
12040 ;; This is a pseudo-article.
12041 (if (assq 'name header)
12042 (gnus-copy-file (cdr (assq 'name header)))
12043 (gnus-message 1 "Article %d is unsavable" article))
12044 ;; This is a real article.
12045 (save-window-excursion
12046 (gnus-summary-select-article decode decode nil article)
12047 (gnus-summary-goto-subject article))
12048 (with-current-buffer save-buffer
12049 (erase-buffer)
12050 (insert-buffer-substring (if decode
12051 gnus-article-buffer
12052 gnus-original-article-buffer)))
12053 (setq file (gnus-article-save save-buffer file num))
12054 (gnus-summary-remove-process-mark article)
12055 (unless not-saved
12056 (gnus-summary-set-saved-mark article)))
12057 (when saver2
12058 (setq gnus-default-article-saver saver2
12059 saver2 nil)))
12060 (gnus-kill-buffer save-buffer)
12061 (gnus-summary-position-point)
12062 (gnus-set-mode-line 'summary)
12065 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12067 (defun gnus-summary-pipe-output (&optional n sym)
12068 "Pipe the current article to a subprocess.
12069 If N is a positive number, pipe the N next articles.
12070 If N is a negative number, pipe the N previous articles.
12071 If N is nil and any articles have been marked with the process mark,
12072 pipe those articles instead.
12073 The default command to which articles are piped is specified by the
12074 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12075 will be prompted for the command.
12077 The properties `:decode' and `:headers' that are put to the function
12078 symbol `gnus-summary-save-in-pipe' control whether this function
12079 decodes articles and what headers to keep (see the doc string for the
12080 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12081 is neither omitted nor the symbol `r', force including all headers
12082 regardless of the `:headers' property. If it is the symbol `r',
12083 articles that are not decoded and include all headers will be piped
12084 no matter what the properties `:decode' and `:headers' are."
12085 (interactive (gnus-interactive "P\ny"))
12086 (require 'gnus-art)
12087 (let* ((articles (gnus-summary-work-articles n))
12088 (result-buffer "*Shell Command Output*")
12089 (all-headers (not (memq sym '(nil r))))
12090 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12091 (raw (eq sym 'r))
12092 (headers (get 'gnus-summary-save-in-pipe :headers))
12093 command result)
12094 (unless (numberp (car articles))
12095 (error "No article to pipe"))
12096 (setq command (read-shell-command
12097 (concat "Shell command on "
12098 (if (cdr articles)
12099 (format "these %d articles" (length articles))
12100 "this article")
12101 ": ")
12102 gnus-summary-pipe-output-default-command))
12103 (when (string-equal command "")
12104 (error "A command is required"))
12105 (when all-headers
12106 (put 'gnus-summary-save-in-pipe :headers nil))
12107 (unwind-protect
12108 (while articles
12109 (gnus-summary-goto-subject (pop articles))
12110 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12111 (when (and (get-buffer result-buffer)
12112 (not (zerop (buffer-size (get-buffer result-buffer)))))
12113 (setq result (concat result (with-current-buffer result-buffer
12114 (buffer-string))))))
12115 (put 'gnus-summary-save-in-pipe :headers headers))
12116 (unless (zerop (length result))
12117 (if (with-current-buffer (get-buffer-create result-buffer)
12118 (erase-buffer)
12119 (insert result)
12120 (prog1
12121 (and (= (count-lines (point-min) (point)) 1)
12122 (progn
12123 (end-of-line 0)
12124 (<= (current-column)
12125 (window-width (minibuffer-window)))))
12126 (goto-char (point-min))))
12127 (message "%s" (substring result 0 -1))
12128 (message nil)
12129 (gnus-configure-windows 'pipe)))))
12131 (defun gnus-summary-save-article-mail (&optional arg)
12132 "Append the current article to a Unix mail box file.
12133 If N is a positive number, save the N next articles.
12134 If N is a negative number, save the N previous articles.
12135 If N is nil and any articles have been marked with the process mark,
12136 save those articles instead."
12137 (interactive "P")
12138 (require 'gnus-art)
12139 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12140 (gnus-summary-save-article arg)))
12142 (defun gnus-summary-save-article-rmail (&optional arg)
12143 "Append the current article to an rmail file.
12144 If N is a positive number, save the N next articles.
12145 If N is a negative number, save the N previous articles.
12146 If N is nil and any articles have been marked with the process mark,
12147 save those articles instead."
12148 (interactive "P")
12149 (require 'gnus-art)
12150 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12151 (gnus-summary-save-article arg)))
12153 (defun gnus-summary-save-article-file (&optional arg)
12154 "Append the current article to a file.
12155 If N is a positive number, save the N next articles.
12156 If N is a negative number, save the N previous articles.
12157 If N is nil and any articles have been marked with the process mark,
12158 save those articles instead."
12159 (interactive "P")
12160 (require 'gnus-art)
12161 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12162 (gnus-summary-save-article arg)))
12164 (defun gnus-summary-write-article-file (&optional arg)
12165 "Write the current article to a file, deleting the previous file.
12166 If N is a positive number, save the N next articles.
12167 If N is a negative number, save the N previous articles.
12168 If N is nil and any articles have been marked with the process mark,
12169 save those articles instead."
12170 (interactive "P")
12171 (require 'gnus-art)
12172 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12173 (gnus-summary-save-article arg)))
12175 (defun gnus-summary-save-article-body-file (&optional arg)
12176 "Append the current article body to a file.
12177 If N is a positive number, save the N next articles.
12178 If N is a negative number, save the N previous articles.
12179 If N is nil and any articles have been marked with the process mark,
12180 save those articles instead."
12181 (interactive "P")
12182 (require 'gnus-art)
12183 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12184 (gnus-summary-save-article arg)))
12186 (defun gnus-summary-write-article-body-file (&optional arg)
12187 "Write the current article body to a file, deleting the previous file.
12188 If N is a positive number, save the N next articles.
12189 If N is a negative number, save the N previous articles.
12190 If N is nil and any articles have been marked with the process mark,
12191 save those articles instead."
12192 (interactive "P")
12193 (require 'gnus-art)
12194 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12195 (gnus-summary-save-article arg)))
12197 (defun gnus-summary-muttprint (&optional arg)
12198 "Print the current article using Muttprint.
12199 If N is a positive number, save the N next articles.
12200 If N is a negative number, save the N previous articles.
12201 If N is nil and any articles have been marked with the process mark,
12202 save those articles instead."
12203 (interactive "P")
12204 (require 'gnus-art)
12205 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12206 (gnus-summary-save-article arg t)))
12208 (defun gnus-summary-pipe-message (program)
12209 "Pipe the current article through PROGRAM."
12210 (interactive "sProgram: ")
12211 (gnus-summary-select-article)
12212 (let ((mail-header-separator ""))
12213 (gnus-eval-in-buffer-window gnus-article-buffer
12214 (save-restriction
12215 (widen)
12216 (let ((start (window-start))
12217 (inhibit-read-only t))
12218 (message-pipe-buffer-body program)
12219 (set-window-start (get-buffer-window (current-buffer)) start))))))
12221 (defun gnus-get-split-value (methods)
12222 "Return a value based on the split METHODS."
12223 (let (split-name method result match)
12224 (when methods
12225 (with-current-buffer gnus-original-article-buffer
12226 (save-restriction
12227 (nnheader-narrow-to-headers)
12228 (while (and methods (not split-name))
12229 (goto-char (point-min))
12230 (setq method (pop methods))
12231 (setq match (car method))
12232 (when (cond
12233 ((stringp match)
12234 ;; Regular expression.
12235 (ignore-errors
12236 (re-search-forward match nil t)))
12237 ((functionp match)
12238 ;; Function.
12239 (save-restriction
12240 (widen)
12241 (setq result (funcall match gnus-newsgroup-name))))
12242 ((consp match)
12243 ;; Form.
12244 (save-restriction
12245 (widen)
12246 (setq result (eval match)))))
12247 (setq split-name (cdr method))
12248 (cond ((stringp result)
12249 (push (expand-file-name
12250 result gnus-article-save-directory)
12251 split-name))
12252 ((consp result)
12253 (setq split-name (append result split-name)))))))))
12254 (nreverse split-name)))
12256 (defun gnus-valid-move-group-p (group)
12257 (and (symbolp group)
12258 (boundp group)
12259 (symbol-name group)
12260 (symbol-value group)
12261 (gnus-get-function (gnus-find-method-for-group
12262 (symbol-name group)) 'request-accept-article t)))
12264 (defun gnus-read-move-group-name (prompt default articles prefix)
12265 "Read a group name."
12266 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12267 (prom
12268 (format "%s %s to"
12269 prompt
12270 (if (> (length articles) 1)
12271 (format "these %d articles" (length articles))
12272 "this article")))
12273 (to-newsgroup
12274 (cond
12275 ((null split-name)
12276 (gnus-group-completing-read
12277 prom
12278 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12279 nil prefix nil default))
12280 ((= 1 (length split-name))
12281 (gnus-group-completing-read
12282 prom
12283 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12284 nil prefix 'gnus-group-history (car split-name)))
12286 (gnus-completing-read
12287 prom (nreverse split-name) nil nil 'gnus-group-history))))
12288 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12289 encoded)
12290 (when to-newsgroup
12291 (if (or (string= to-newsgroup "")
12292 (string= to-newsgroup prefix))
12293 (setq to-newsgroup default))
12294 (unless to-newsgroup
12295 (error "No group name entered"))
12296 (setq encoded (encode-coding-string
12297 to-newsgroup
12298 (gnus-group-name-charset to-method to-newsgroup)))
12299 (or (gnus-active encoded)
12300 (gnus-activate-group encoded nil nil to-method)
12301 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12302 to-newsgroup))
12303 (or (and (gnus-request-create-group encoded to-method)
12304 (gnus-activate-group encoded nil nil to-method)
12305 (gnus-subscribe-group encoded))
12306 (error "Couldn't create group %s" to-newsgroup)))
12307 (error "No such group: %s" to-newsgroup))
12308 encoded)))
12310 (defvar gnus-summary-save-parts-counter)
12311 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12313 (defun gnus-summary-save-parts (type dir n &optional reverse)
12314 "Save parts matching TYPE to DIR.
12315 If REVERSE, save parts that do not match TYPE."
12316 (interactive
12317 (list (read-string "Save parts of type: "
12318 (or (car gnus-summary-save-parts-type-history)
12319 gnus-summary-save-parts-default-mime)
12320 'gnus-summary-save-parts-type-history)
12321 (setq gnus-summary-save-parts-last-directory
12322 (read-directory-name "Save to directory: "
12323 gnus-summary-save-parts-last-directory
12324 nil t))
12325 current-prefix-arg))
12326 (gnus-summary-iterate n
12327 (let ((gnus-display-mime-function nil)
12328 gnus-article-prepare-hook
12329 gnus-article-decode-hook
12330 gnus-display-mime-function
12331 gnus-break-pages
12332 (gnus-inhibit-treatment t))
12333 (gnus-summary-select-article))
12334 (with-current-buffer gnus-article-buffer
12335 (let ((handles (or gnus-article-mime-handles
12336 (mm-dissect-buffer nil gnus-article-loose-mime)
12337 (and gnus-article-emulate-mime
12338 (mm-uu-dissect))))
12339 (gnus-summary-save-parts-counter 1))
12340 (when handles
12341 (gnus-summary-save-parts-1 type dir handles reverse)
12342 (unless gnus-article-mime-handles ;; Don't destroy this case.
12343 (mm-destroy-parts handles)))))))
12345 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12346 (if (stringp (car handle))
12347 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12348 (cdr handle))
12349 (when (if reverse
12350 (not (string-match type (mm-handle-media-type handle)))
12351 (string-match type (mm-handle-media-type handle)))
12352 (let ((file (expand-file-name
12353 (gnus-map-function
12354 mm-file-name-rewrite-functions
12355 (file-name-nondirectory
12357 (mm-handle-filename handle)
12358 (format "%s.%d.%d" gnus-newsgroup-name
12359 (cdr gnus-article-current)
12360 gnus-summary-save-parts-counter))))
12361 dir)))
12362 (incf gnus-summary-save-parts-counter)
12363 (unless (file-exists-p file)
12364 (mm-save-part-to-file handle file))))))
12366 ;; Summary extract commands
12368 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12369 (let ((inhibit-read-only t)
12370 (article (gnus-summary-article-number))
12371 after-article b e)
12372 (unless (gnus-summary-goto-subject article)
12373 (error "No such article: %d" article))
12374 (gnus-summary-position-point)
12375 ;; If all commands are to be bunched up on one line, we collect
12376 ;; them here.
12377 (unless gnus-view-pseudos-separately
12378 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12379 files action)
12380 (while ps
12381 (setq action (cdr (assq 'action (car ps))))
12382 (setq files (list (cdr (assq 'name (car ps)))))
12383 (while (and ps (cdr ps)
12384 (string= (or action "1")
12385 (or (cdr (assq 'action (cadr ps))) "2")))
12386 (push (cdr (assq 'name (cadr ps))) files)
12387 (setcdr ps (cddr ps)))
12388 (when files
12389 (when (not (string-match "%s" action))
12390 (push " " files))
12391 (push " " files)
12392 (when (assq 'execute (car ps))
12393 (setcdr (assq 'execute (car ps))
12394 (funcall (if (string-match "%s" action)
12395 'format 'concat)
12396 action
12397 (mapconcat
12398 (lambda (f)
12399 (if (equal f " ")
12401 (shell-quote-argument f)))
12402 files " ")))))
12403 (setq ps (cdr ps)))))
12404 (if (and gnus-view-pseudos (not not-view))
12405 (while pslist
12406 (when (assq 'execute (car pslist))
12407 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12408 (eq gnus-view-pseudos 'not-confirm)))
12409 (setq pslist (cdr pslist)))
12410 (save-excursion
12411 (while pslist
12412 (setq after-article (or (cdr (assq 'article (car pslist)))
12413 (gnus-summary-article-number)))
12414 (gnus-summary-goto-subject after-article)
12415 (forward-line 1)
12416 (setq b (point))
12417 (insert " " (file-name-nondirectory
12418 (cdr (assq 'name (car pslist))))
12419 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12420 (setq e (point))
12421 (forward-line -1) ; back to `b'
12422 (add-text-properties
12423 b (1- e) (list 'gnus-number gnus-reffed-article-number
12424 'mouse-face gnus-mouse-face))
12425 (gnus-data-enter
12426 after-article gnus-reffed-article-number
12427 gnus-unread-mark b (car pslist) 0 (- e b))
12428 (setq gnus-newsgroup-unreads
12429 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12430 gnus-reffed-article-number))
12431 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12432 (setq pslist (cdr pslist)))))))
12434 (defun gnus-pseudos< (p1 p2)
12435 (let ((c1 (cdr (assq 'action p1)))
12436 (c2 (cdr (assq 'action p2))))
12437 (and c1 c2 (string< c1 c2))))
12439 (defun gnus-request-pseudo-article (props)
12440 (cond ((assq 'execute props)
12441 (gnus-execute-command (cdr (assq 'execute props)))))
12442 (let ((gnus-current-article (gnus-summary-article-number)))
12443 (gnus-run-hooks 'gnus-mark-article-hook)))
12445 (defun gnus-execute-command (command &optional automatic)
12446 (save-excursion
12447 (gnus-article-setup-buffer)
12448 (set-buffer gnus-article-buffer)
12449 (setq buffer-read-only nil)
12450 (let ((command (if automatic command
12451 (read-string "Command: " (cons command 0)))))
12452 (erase-buffer)
12453 (insert "$ " command "\n\n")
12454 (if gnus-view-pseudo-asynchronously
12455 (start-process "gnus-execute" (current-buffer) shell-file-name
12456 shell-command-switch command)
12457 (call-process shell-file-name nil t nil
12458 shell-command-switch command)))))
12460 ;; Summary kill commands.
12462 (defun gnus-summary-edit-global-kill (article)
12463 "Edit the \"global\" kill file."
12464 (interactive (list (gnus-summary-article-number)))
12465 (gnus-group-edit-global-kill article))
12467 (defun gnus-summary-edit-local-kill ()
12468 "Edit a local kill file applied to the current newsgroup."
12469 (interactive)
12470 (setq gnus-current-headers (gnus-summary-article-header))
12471 (gnus-group-edit-local-kill
12472 (gnus-summary-article-number) gnus-newsgroup-name))
12474 ;;; Header reading.
12476 (defun gnus-read-header (id &optional header)
12477 "Read the headers of article ID and enter them into the Gnus system."
12478 (let ((group gnus-newsgroup-name)
12479 (gnus-override-method
12481 gnus-override-method
12482 (and (gnus-news-group-p gnus-newsgroup-name)
12483 (car (gnus-refer-article-methods)))))
12484 where)
12485 ;; First we check to see whether the header in question is already
12486 ;; fetched.
12487 (if (stringp id)
12488 ;; This is a Message-ID.
12489 (setq header (or header (gnus-id-to-header id)))
12490 ;; This is an article number.
12491 (setq header (or header (gnus-summary-article-header id))))
12492 (if (and header
12493 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12494 ;; We have found the header.
12495 header
12496 ;; We have to really fetch the header to this article.
12497 (with-current-buffer nntp-server-buffer
12498 (when (setq where (gnus-request-head id group))
12499 (nnheader-fold-continuation-lines)
12500 (goto-char (point-max))
12501 (insert ".\n")
12502 (goto-char (point-min))
12503 (insert "211 ")
12504 (princ (cond
12505 ((numberp id) id)
12506 ((cdr where) (cdr where))
12507 (header (mail-header-number header))
12508 (t gnus-reffed-article-number))
12509 (current-buffer))
12510 (insert " Article retrieved.\n"))
12511 (if (or (not where)
12512 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12513 () ; Malformed head.
12514 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12515 (when (and (bound-and-true-p gnus-registry-enabled)
12516 (not (gnus-ephemeral-group-p (car where))))
12517 (gnus-registry-handle-action
12518 (mail-header-id header) nil
12519 (gnus-group-prefixed-name
12520 (car where)
12521 (or gnus-override-method (gnus-find-method-for-group group)))
12522 (mail-header-subject header)
12523 (mail-header-from header)))
12524 (when (and (stringp id)
12526 (not (string= (gnus-group-real-name group)
12527 (car where)))
12528 (not (gnus-server-equal gnus-override-method
12529 (gnus-group-method group)))))
12530 ;; If we fetched by Message-ID and the article came from
12531 ;; a different group (or server), we fudge some bogus
12532 ;; article numbers for this article.
12533 (mail-header-set-number header gnus-reffed-article-number))
12534 (with-current-buffer gnus-summary-buffer
12535 (decf gnus-reffed-article-number)
12536 (gnus-remove-header (mail-header-number header))
12537 (push header gnus-newsgroup-headers)
12538 (setq gnus-current-headers header)
12539 (push (mail-header-number header) gnus-newsgroup-limit)))
12540 header)))))
12542 (defun gnus-remove-header (number)
12543 "Remove header NUMBER from `gnus-newsgroup-headers'."
12544 (if (and gnus-newsgroup-headers
12545 (= number (mail-header-number (car gnus-newsgroup-headers))))
12546 (pop gnus-newsgroup-headers)
12547 (let ((headers gnus-newsgroup-headers))
12548 (while (and (cdr headers)
12549 (not (= number (mail-header-number (cadr headers)))))
12550 (pop headers))
12551 (when (cdr headers)
12552 (setcdr headers (cddr headers))))))
12555 ;;; summary highlights
12558 (defun gnus-highlight-selected-summary ()
12559 "Highlight selected article in summary buffer."
12560 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12561 (when gnus-summary-selected-face
12562 (save-excursion
12563 (let* ((beg (point-at-bol))
12564 (end (point-at-eol))
12565 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12566 (from (if (get-text-property beg 'mouse-face)
12568 (or (next-single-property-change
12569 beg 'mouse-face nil end)
12570 beg)))
12572 (if (= from end)
12573 (- from 2)
12574 (or (next-single-property-change
12575 from 'mouse-face nil end)
12576 end))))
12577 ;; If no mouse-face prop on line we will have to = from = end,
12578 ;; so we highlight the entire line instead.
12579 (when (= (+ to 2) from)
12580 (setq from beg)
12581 (setq to end))
12582 (if gnus-newsgroup-selected-overlay
12583 ;; Move old overlay.
12584 (move-overlay
12585 gnus-newsgroup-selected-overlay from to (current-buffer))
12586 ;; Create new overlay.
12587 (overlay-put
12588 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12589 'face gnus-summary-selected-face))))))
12591 (defvar gnus-summary-highlight-line-cached nil)
12592 (defvar gnus-summary-highlight-line-trigger nil)
12594 (defun gnus-summary-highlight-line-0 ()
12595 (if (and (eq gnus-summary-highlight-line-trigger
12596 gnus-summary-highlight)
12597 gnus-summary-highlight-line-cached)
12598 gnus-summary-highlight-line-cached
12599 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12600 gnus-summary-highlight-line-cached
12601 (let* ((cond (list 'cond))
12602 (c cond)
12603 (list gnus-summary-highlight))
12604 (while list
12605 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12606 nil))
12607 (setq c (cdr c)
12608 list (cdr list)))
12609 (gnus-byte-compile (list 'lambda nil cond))))))
12611 (defun gnus-summary-highlight-line ()
12612 "Highlight current line according to `gnus-summary-highlight'."
12613 (let* ((beg (point-at-bol))
12614 (article (or (gnus-summary-article-number) gnus-current-article))
12615 (score (or (cdr (assq article
12616 gnus-newsgroup-scored))
12617 gnus-summary-default-score 0))
12618 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12619 (inhibit-read-only t)
12620 (default gnus-summary-default-score)
12621 (default-high gnus-summary-default-high-score)
12622 (default-low gnus-summary-default-low-score)
12623 (uncached (and gnus-summary-use-undownloaded-faces
12624 (memq article gnus-newsgroup-undownloaded)
12625 (not (memq article gnus-newsgroup-cached)))))
12626 (let ((face (funcall (gnus-summary-highlight-line-0))))
12627 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12628 (gnus-put-text-property-excluding-characters-with-faces
12629 beg (point-at-eol) 'face
12630 (setq face (if (boundp face) (symbol-value face) face)))
12631 (when gnus-summary-highlight-line-function
12632 (funcall gnus-summary-highlight-line-function article face))))))
12634 (defun gnus-update-read-articles (group unread &optional compute)
12635 "Update the list of read articles in GROUP.
12636 UNREAD is a sorted list."
12637 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12638 (info (gnus-get-info group))
12639 (prev 1)
12640 read)
12641 (if (or (not info) (not active))
12642 ;; There is no info on this group if it was, in fact,
12643 ;; killed. Gnus stores no information on killed groups, so
12644 ;; there's nothing to be done.
12645 ;; One could store the information somewhere temporarily,
12646 ;; perhaps... Hmmm...
12648 ;; Remove any negative articles numbers.
12649 (while (and unread (< (car unread) 0))
12650 (setq unread (cdr unread)))
12651 ;; Remove any expired article numbers
12652 (while (and unread (< (car unread) (car active)))
12653 (setq unread (cdr unread)))
12654 ;; Compute the ranges of read articles by looking at the list of
12655 ;; unread articles.
12656 (while unread
12657 (when (/= (car unread) prev)
12658 (push (if (= prev (1- (car unread))) prev
12659 (cons prev (1- (car unread))))
12660 read))
12661 (setq prev (1+ (car unread)))
12662 (setq unread (cdr unread)))
12663 (when (<= prev (cdr active))
12664 (push (cons prev (cdr active)) read))
12665 (setq read (if (> (length read) 1) (nreverse read) read))
12666 (if compute
12667 read
12668 (save-excursion
12669 (let (setmarkundo)
12670 ;; Propagate the read marks to the backend.
12671 (when (and (gnus-method-option-p
12672 (gnus-find-method-for-group group)
12673 'server-marks)
12674 (gnus-check-backend-function 'request-set-mark group))
12675 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12676 (add (gnus-remove-from-range read (gnus-info-read info))))
12677 (when (or add del)
12678 (unless (gnus-check-group group)
12679 (error "Can't open server for %s" group))
12680 (gnus-request-set-mark
12681 group (delq nil (list (if add (list add 'add '(read)))
12682 (if del (list del 'del '(read))))))
12683 (setq setmarkundo
12684 `(gnus-request-set-mark
12685 ,group
12686 ',(delq nil (list
12687 (if del (list del 'add '(read)))
12688 (if add (list add 'del '(read))))))))))
12689 (set-buffer gnus-group-buffer)
12690 (gnus-undo-register
12691 `(progn
12692 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12693 (gnus-info-set-read ',info ',(gnus-info-read info))
12694 (gnus-get-unread-articles-in-group ',info
12695 (gnus-active ,group))
12696 (gnus-group-update-group ,group t)
12697 ,setmarkundo))))
12698 ;; Enter this list into the group info.
12699 (gnus-info-set-read info read)
12700 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12701 (gnus-get-unread-articles-in-group info (gnus-active group))
12702 t))))
12704 (defun gnus-offer-save-summaries ()
12705 "Offer to save all active summary buffers."
12706 (let (buffers)
12707 ;; Go through all buffers and find all summaries.
12708 (dolist (buffer (buffer-list))
12709 (when (and (setq buffer (buffer-name buffer))
12710 (string-match "Summary" buffer)
12711 (with-current-buffer buffer
12712 ;; We check that this is, indeed, a summary buffer.
12713 (and (derived-mode-p 'gnus-summary-mode)
12714 ;; Also make sure this isn't bogus.
12715 gnus-newsgroup-prepared
12716 ;; Also make sure that this isn't a
12717 ;; dead summary buffer.
12718 (not gnus-dead-summary-mode))))
12719 (push buffer buffers)))
12720 ;; Go through all these summary buffers and offer to save them.
12721 (when buffers
12722 (save-excursion
12723 (if (eq gnus-interactive-exit 'quiet)
12724 (dolist (buffer buffers)
12725 (switch-to-buffer buffer)
12726 (gnus-summary-exit))
12727 (map-y-or-n-p
12728 "Update summary buffer %s? "
12729 (lambda (buf)
12730 (switch-to-buffer buf)
12731 (gnus-summary-exit))
12732 buffers))))))
12734 (defun gnus-summary-setup-default-charset ()
12735 "Setup newsgroup default charset."
12736 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12737 (setq gnus-newsgroup-charset nil)
12738 (let* ((ignored-charsets
12739 (or gnus-newsgroup-ephemeral-ignored-charsets
12740 (append
12741 (and gnus-newsgroup-name
12742 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12743 gnus-newsgroup-ignored-charsets))))
12744 (setq gnus-newsgroup-charset
12745 (or gnus-newsgroup-ephemeral-charset
12746 (and gnus-newsgroup-name
12747 (gnus-parameter-charset gnus-newsgroup-name))
12748 gnus-default-charset))
12749 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12750 ignored-charsets))))
12753 ;;; Mime Commands
12756 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12757 "Display the current article buffer fully MIME-buttonized.
12758 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12759 treated as multipart/mixed."
12760 (interactive "P")
12761 (require 'gnus-art)
12762 (let ((gnus-unbuttonized-mime-types nil)
12763 (gnus-mime-display-multipart-as-mixed show-all-parts))
12764 (gnus-summary-show-article)))
12766 (defun gnus-summary-repair-multipart (article)
12767 "Add a Content-Type header to a multipart article without one."
12768 (interactive (list (gnus-summary-article-number)))
12769 (gnus-with-article article
12770 (message-narrow-to-head)
12771 (message-remove-header "Mime-Version")
12772 (goto-char (point-max))
12773 (insert "Mime-Version: 1.0\n")
12774 (widen)
12775 (when (search-forward "\n--" nil t)
12776 (let ((separator (buffer-substring (point) (point-at-eol))))
12777 (message-narrow-to-head)
12778 (message-remove-header "Content-Type")
12779 (goto-char (point-max))
12780 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12781 separator))
12782 (widen))))
12783 (let (gnus-mark-article-hook)
12784 (gnus-summary-select-article t t nil article)))
12786 (defun gnus-summary-toggle-display-buttonized ()
12787 "Toggle the buttonizing of the article buffer."
12788 (interactive)
12789 (require 'gnus-art)
12790 (if (setq gnus-inhibit-mime-unbuttonizing
12791 (not gnus-inhibit-mime-unbuttonizing))
12792 (let ((gnus-unbuttonized-mime-types nil))
12793 (gnus-summary-show-article))
12794 (gnus-summary-show-article)))
12797 ;;; Generic summary marking commands
12800 (defvar gnus-summary-marking-alist
12801 '((read gnus-del-mark "d")
12802 (unread gnus-unread-mark "u")
12803 (ticked gnus-ticked-mark "!")
12804 (dormant gnus-dormant-mark "?")
12805 (expirable gnus-expirable-mark "e"))
12806 "An alist of names/marks/keystrokes.")
12808 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12809 (defvar gnus-summary-mark-map)
12811 (defun gnus-summary-make-all-marking-commands ()
12812 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12813 (dolist (elem gnus-summary-marking-alist)
12814 (apply 'gnus-summary-make-marking-command elem)))
12816 (defun gnus-summary-make-marking-command (name mark keystroke)
12817 (let ((map (make-sparse-keymap)))
12818 (define-key gnus-summary-generic-mark-map keystroke map)
12819 (dolist (lway `((next "next" next nil "n")
12820 (next-unread "next unread" next t "N")
12821 (prev "previous" prev nil "p")
12822 (prev-unread "previous unread" prev t "P")
12823 (nomove "" nil nil ,keystroke)))
12824 (let ((func (gnus-summary-make-marking-command-1
12825 mark (car lway) lway name)))
12826 (setq func (eval func))
12827 (define-key map (nth 4 lway) func)))))
12829 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12830 `(defun ,(intern
12831 (format "gnus-summary-put-mark-as-%s%s"
12832 name (if (eq way 'nomove)
12834 (concat "-" (symbol-name way)))))
12836 ,(format
12837 "Mark the current article as %s%s.
12838 If N, the prefix, then repeat N times.
12839 If N is negative, move in reverse order.
12840 The difference between N and the actual number of articles marked is
12841 returned."
12842 name (cadr lway))
12843 (interactive "p")
12844 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12846 (defun gnus-summary-generic-mark (n mark move unread)
12847 "Mark N articles with MARK."
12848 (unless (derived-mode-p 'gnus-summary-mode)
12849 (error "This command can only be used in the summary buffer"))
12850 (gnus-summary-show-thread)
12851 (let ((nummove
12852 (cond
12853 ((eq move 'next) 1)
12854 ((eq move 'prev) -1)
12855 (t 0))))
12856 (if (zerop nummove)
12857 (setq n 1)
12858 (when (< n 0)
12859 (setq n (abs n)
12860 nummove (* -1 nummove))))
12861 (while (and (> n 0)
12862 (gnus-summary-mark-article nil mark)
12863 (zerop (gnus-summary-next-subject nummove unread t)))
12864 (setq n (1- n)))
12865 (when (/= 0 n)
12866 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12867 (gnus-summary-recenter)
12868 (gnus-summary-position-point)
12869 (gnus-set-mode-line 'summary)
12872 (defun gnus-summary-insert-articles (articles)
12873 (when (setq articles
12874 (gnus-sorted-difference articles
12875 (mapcar (lambda (h)
12876 (mail-header-number h))
12877 gnus-newsgroup-headers)))
12878 (setq gnus-newsgroup-headers
12879 (cl-merge 'list
12880 gnus-newsgroup-headers
12881 (gnus-fetch-headers articles nil t)
12882 'gnus-article-sort-by-number))
12883 (setq gnus-newsgroup-articles
12884 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12885 ;; Suppress duplicates?
12886 (when gnus-suppress-duplicates
12887 (gnus-dup-suppress-articles))
12889 (if (and gnus-fetch-old-headers
12890 (eq gnus-headers-retrieved-by 'nov))
12891 ;; We might want to build some more threads first.
12892 (if (eq gnus-fetch-old-headers 'invisible)
12893 (gnus-build-all-threads)
12894 (gnus-build-old-threads))
12895 ;; Mark the inserted articles that are unread as unread.
12896 (setq gnus-newsgroup-unreads
12897 (gnus-sorted-nunion
12898 gnus-newsgroup-unreads
12899 (gnus-sorted-nintersection
12900 (gnus-list-of-unread-articles gnus-newsgroup-name)
12901 articles)))
12902 ;; Mark the inserted articles as selected so that the information
12903 ;; of the marks having been changed by a user may be updated when
12904 ;; exiting this group. See `gnus-summary-update-info'.
12905 (dolist (art articles)
12906 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12907 ;; Let the Gnus agent mark articles as read.
12908 (when gnus-agent
12909 (gnus-agent-get-undownloaded-list))
12910 ;; Remove list identifiers from subject
12911 (gnus-summary-remove-list-identifiers)
12912 ;; First and last article in this newsgroup.
12913 (when gnus-newsgroup-headers
12914 (setq gnus-newsgroup-begin
12915 (mail-header-number (car gnus-newsgroup-headers))
12916 gnus-newsgroup-end
12917 (mail-header-number
12918 (gnus-last-element gnus-newsgroup-headers))))
12919 (when gnus-use-scoring
12920 (gnus-possibly-score-headers))))
12922 (defun gnus-summary-insert-old-articles (&optional all)
12923 "Insert all old articles in this group.
12924 If ALL is non-nil, already read articles become readable.
12925 If ALL is a number, fetch this number of articles."
12926 (interactive "P")
12927 (prog1
12928 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12929 older len)
12930 (setq older
12931 ;; Some nntp servers lie about their active range. When
12932 ;; this happens, the active range can be in the millions.
12933 ;; Use a compressed range to avoid creating a huge list.
12934 (gnus-range-difference
12935 (gnus-range-difference (list gnus-newsgroup-active) old)
12936 gnus-newsgroup-unexist))
12937 (setq len (gnus-range-length older))
12938 (cond
12939 ((null older) nil)
12940 ((numberp all)
12941 (if (< all len)
12942 (let ((older-range (nreverse older)))
12943 (setq older nil)
12945 (while (> all 0)
12946 (let* ((r (pop older-range))
12947 (min (if (numberp r) r (car r)))
12948 (max (if (numberp r) r (cdr r))))
12949 (while (and (<= min max)
12950 (> all 0))
12951 (push max older)
12952 (setq all (1- all)
12953 max (1- max))))))
12954 (setq older (gnus-uncompress-range older))))
12955 (all
12956 (setq older (gnus-uncompress-range older)))
12958 (when (and (numberp gnus-large-newsgroup)
12959 (> len gnus-large-newsgroup))
12960 (let* ((cursor-in-echo-area nil)
12961 (initial (gnus-parameter-large-newsgroup-initial
12962 gnus-newsgroup-name))
12963 (input
12964 (read-string
12965 (format
12966 "How many articles from %s (%s %d): "
12967 (gnus-group-decoded-name gnus-newsgroup-name)
12968 (if initial "max" "default")
12969 len)
12970 nil nil
12971 (and initial
12972 (number-to-string initial)))))
12973 (unless (string-match "^[ \t]*$" input)
12974 (setq all (string-to-number input))
12975 (if (< all len)
12976 (let ((older-range (nreverse older)))
12977 (setq older nil)
12979 (while (> all 0)
12980 (let* ((r (pop older-range))
12981 (min (if (numberp r) r (car r)))
12982 (max (if (numberp r) r (cdr r))))
12983 (while (and (<= min max)
12984 (> all 0))
12985 (push max older)
12986 (setq all (1- all)
12987 max (1- max))))))))))
12988 (setq older (gnus-uncompress-range older))))
12989 (if (not older)
12990 (message "No old news.")
12991 (gnus-summary-insert-articles older)
12992 (gnus-summary-limit (gnus-sorted-nunion old older))))
12993 (gnus-summary-position-point)))
12995 (defun gnus-summary-insert-new-articles ()
12996 "Insert all new articles in this group."
12997 (interactive)
12998 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12999 (old-high gnus-newsgroup-highest)
13000 (nnmail-fetched-sources (list t))
13001 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13002 i new)
13003 (unless new-active
13004 (error "Couldn't fetch new data"))
13005 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13006 (setq i (cdr gnus-newsgroup-active)
13007 gnus-newsgroup-highest i)
13008 (while (> i old-high)
13009 (push i new)
13010 (decf i))
13011 (if (not new)
13012 (message "No gnus is bad news")
13013 (gnus-summary-insert-articles new)
13014 (setq gnus-newsgroup-unreads
13015 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13016 (gnus-summary-limit (gnus-sorted-nunion old new))))
13017 (gnus-summary-position-point))
13019 ;;; Bookmark support for Gnus.
13020 (declare-function gnus-article-show-summary "gnus-art" ())
13021 (declare-function bookmark-make-record-default
13022 "bookmark" (&optional no-file no-context posn))
13023 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13024 (declare-function bookmark-default-handler "bookmark" (bmk))
13025 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13026 (defvar bookmark-yank-point)
13027 (defvar bookmark-current-buffer)
13029 (defun gnus-summary-bookmark-make-record ()
13030 "Make a bookmark entry for a Gnus summary buffer."
13031 (let (pos buf)
13032 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13033 (save-restriction ; FIXME is it necessary to widen?
13034 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13035 (setq buf "art") ; We are recording bookmark from article buffer.
13036 (setq bookmark-yank-point (point))
13037 (setq bookmark-current-buffer (current-buffer))
13038 (gnus-article-show-summary)) ; Go back in summary buffer.
13039 ;; We are now recording bookmark from summary buffer.
13040 (unless buf (setq buf "sum"))
13041 (let* ((subject (elt (gnus-summary-article-header) 1))
13042 (grp (car gnus-article-current))
13043 (art (cdr gnus-article-current))
13044 (head (gnus-summary-article-header art))
13045 (id (mail-header-id head)))
13046 `(,subject
13047 ,@(condition-case nil
13048 (bookmark-make-record-default 'no-file 'no-context pos)
13049 (wrong-number-of-arguments
13050 (bookmark-make-record-default 'point-only)))
13051 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13052 (group . ,grp) (article . ,art)
13053 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13055 ;;;###autoload
13056 (defun gnus-summary-bookmark-jump (bookmark)
13057 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13058 BOOKMARK is a bookmark name or a bookmark record."
13059 (let ((group (bookmark-prop-get bookmark 'group))
13060 (article (bookmark-prop-get bookmark 'article))
13061 (id (bookmark-prop-get bookmark 'message-id))
13062 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13063 (gnus-fetch-group group (list article))
13064 (gnus-summary-insert-cached-articles)
13065 (gnus-summary-goto-article id nil 'force)
13066 ;; FIXME we have to wait article buffer is ready (only large buffer)
13067 ;; Is there a better solution to know that?
13068 ;; If we don't wait `bookmark-default-handler' will have no chance
13069 ;; to set position. However there is no error, just wrong pos.
13070 (sit-for 1)
13071 (when (string= buf "Gnus-art")
13072 (other-window 1))
13073 (bookmark-default-handler
13074 `(""
13075 (buffer . ,(current-buffer))
13076 . ,(bookmark-get-bookmark-record bookmark)))))
13078 (gnus-summary-make-all-marking-commands)
13080 (provide 'gnus-sum)
13082 (run-hooks 'gnus-sum-load-hook)
13084 ;; Local Variables:
13085 ;; coding: utf-8
13086 ;; End:
13088 ;;; gnus-sum.el ends here