Add isearch-yank-symbol-or-char
[emacs.git] / lisp / gnus / gnus-sum.el
blobb6e9ea91b620ec784d3409e404b5a6c771fe48b0
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
1270 (lambda (_group article-list) article-list)
1271 "Function to be called to alter the list of articles to be selected.
1272 This option defaults to a lambda form that simply returns the
1273 list of articles unchanged. Use `add-function' to set one or
1274 more custom filter functions."
1275 :type 'function
1276 :group 'gnus-summary)
1278 (defcustom gnus-orphan-score nil
1279 "All orphans get this score added. Set in the score file."
1280 :group 'gnus-score-default
1281 :type '(choice (const nil)
1282 integer))
1284 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1285 "A regexp to match MIME parts when saving multiple parts of a
1286 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1287 This regexp will be used by default when prompting the user for which
1288 type of files to save."
1289 :group 'gnus-summary
1290 :type 'regexp)
1292 (defcustom gnus-read-all-available-headers nil
1293 "Whether Gnus should parse all headers made available to it.
1294 This is mostly relevant for slow back ends where the user may
1295 wish to widen the summary buffer to include all headers
1296 that were fetched."
1297 :version "22.1"
1298 :group 'gnus-summary
1299 :type '(choice boolean regexp))
1301 (defcustom gnus-summary-pipe-output-default-command nil
1302 "Command (and optional arguments) used to pipe article to subprocess.
1303 This will be used as the default command if it is non-nil. The value
1304 will be updated if you modify it when executing the command
1305 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1306 :version "23.1" ;; No Gnus
1307 :group 'gnus-summary
1308 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1310 (defcustom gnus-summary-muttprint-program "muttprint"
1311 "Command (and optional arguments) used to run Muttprint.
1312 The value will be updated if you modify it when executing the command
1313 `gnus-summary-muttprint'."
1314 :version "22.1"
1315 :group 'gnus-summary
1316 :type 'string)
1318 (defcustom gnus-article-loose-mime t
1319 "If non-nil, don't require MIME-Version header.
1320 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1321 supply the MIME-Version header or deliberately strip it from the mail.
1322 If non-nil (the default), Gnus will treat some articles as MIME
1323 even if the MIME-Version header is missing."
1324 :version "22.1"
1325 :type 'boolean
1326 :group 'gnus-article-mime)
1328 (defcustom gnus-article-emulate-mime t
1329 "If non-nil, use MIME emulation for uuencode and the like.
1330 This means that Gnus will search message bodies for text that look
1331 like uuencoded bits, yEncoded bits, and so on, and present that using
1332 the normal Gnus MIME machinery."
1333 :version "22.1"
1334 :type 'boolean
1335 :group 'gnus-article-mime)
1337 ;;; Internal variables
1339 (defvar gnus-summary-display-cache nil)
1340 (defvar gnus-article-mime-handles nil)
1341 (defvar gnus-article-decoded-p nil)
1342 (defvar gnus-article-charset nil)
1343 (defvar gnus-article-ignored-charsets nil)
1344 (defvar gnus-scores-exclude-files nil)
1345 (defvar gnus-page-broken nil)
1347 (defvar gnus-original-article nil)
1348 (defvar gnus-article-internal-prepare-hook nil)
1349 (defvar gnus-newsgroup-process-stack nil)
1351 (defvar gnus-thread-indent-array nil)
1352 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1353 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1354 "Function called to sort the articles within a thread after it has been gathered together.")
1356 (defvar gnus-summary-save-parts-type-history nil)
1357 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1359 ;; Avoid highlighting in kill files.
1360 (defvar gnus-summary-inhibit-highlight nil)
1361 (defvar gnus-newsgroup-selected-overlay nil)
1362 (defvar gnus-inhibit-limiting nil)
1363 (defvar gnus-newsgroup-adaptive-score-file nil)
1364 (defvar gnus-current-score-file nil)
1365 (defvar gnus-current-move-group nil)
1366 (defvar gnus-current-copy-group nil)
1367 (defvar gnus-current-crosspost-group nil)
1368 (defvar gnus-newsgroup-display nil)
1370 (defvar gnus-newsgroup-dependencies nil)
1371 (defvar gnus-newsgroup-adaptive nil)
1372 (defvar gnus-summary-display-article-function nil)
1373 (defvar gnus-summary-highlight-line-function nil
1374 "Function called after highlighting a summary line.")
1376 (defvar gnus-summary-line-format-alist
1377 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1378 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1379 (?s gnus-tmp-subject-or-nil ?s)
1380 (?n gnus-tmp-name ?s)
1381 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1383 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1384 gnus-tmp-from) ?s)
1385 (?F gnus-tmp-from ?s)
1386 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1387 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1388 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1389 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1390 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1391 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1392 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1393 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1394 (?L gnus-tmp-lines ?s)
1395 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1396 0) ?d)
1397 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1398 "") ?s)
1399 (?g (or (gnus-group-short-name
1400 (nnir-article-group (mail-header-number gnus-tmp-header)))
1401 "") ?s)
1402 (?O gnus-tmp-downloaded ?c)
1403 (?I gnus-tmp-indentation ?s)
1404 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1405 (?R gnus-tmp-replied ?c)
1406 (?\[ gnus-tmp-opening-bracket ?c)
1407 (?\] gnus-tmp-closing-bracket ?c)
1408 (?\> (make-string gnus-tmp-level ? ) ?s)
1409 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1410 (?i gnus-tmp-score ?d)
1411 (?z gnus-tmp-score-char ?c)
1412 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1413 (?U gnus-tmp-unread ?c)
1414 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1416 (?t (gnus-summary-number-of-articles-in-thread
1417 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1419 (?e (gnus-summary-number-of-articles-in-thread
1420 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1422 (?u gnus-tmp-user-defined ?s)
1423 (?P (gnus-pick-line-number) ?d)
1424 (?B gnus-tmp-thread-tree-header-string ?s)
1425 (user-date (gnus-user-date
1426 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1427 "An alist of format specifications that can appear in summary lines.
1428 These are paired with what variables they correspond with, along with
1429 the type of the variable (string, integer, character, etc).")
1431 (defvar gnus-summary-dummy-line-format-alist
1432 `((?S gnus-tmp-subject ?s)
1433 (?N gnus-tmp-number ?d)
1434 (?u gnus-tmp-user-defined ?s)))
1436 (defvar gnus-summary-mode-line-format-alist
1437 `((?G gnus-tmp-group-name ?s)
1438 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1439 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1440 (?A gnus-tmp-article-number ?d)
1441 (?Z gnus-tmp-unread-and-unselected ?s)
1442 (?V gnus-version ?s)
1443 (?U gnus-tmp-unread-and-unticked ?d)
1444 (?S gnus-tmp-subject ?s)
1445 (?e gnus-tmp-unselected ?d)
1446 (?u gnus-tmp-user-defined ?s)
1447 (?d (length gnus-newsgroup-dormant) ?d)
1448 (?t (length gnus-newsgroup-marked) ?d)
1449 (?h (length gnus-newsgroup-spam-marked) ?d)
1450 (?r (length gnus-newsgroup-reads) ?d)
1451 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1452 (?E gnus-newsgroup-expunged-tally ?d)
1453 (?s (gnus-current-score-file-nondirectory) ?s)))
1455 ;; This is here rather than in gnus-art for compilation reasons.
1456 (defvar gnus-article-mode-line-format-alist
1457 (nconc '((?w (gnus-article-wash-status) ?s)
1458 (?m (gnus-article-mime-part-status) ?s))
1459 gnus-summary-mode-line-format-alist))
1461 (defvar gnus-last-search-regexp nil
1462 "Default regexp for article search command.")
1464 (defvar gnus-last-shell-command nil
1465 "Default shell command on article.")
1467 (defvar gnus-newsgroup-agentized nil
1468 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1469 (defvar gnus-newsgroup-begin nil)
1470 (defvar gnus-newsgroup-end nil)
1471 (defvar gnus-newsgroup-last-rmail nil)
1472 (defvar gnus-newsgroup-last-mail nil)
1473 (defvar gnus-newsgroup-last-folder nil)
1474 (defvar gnus-newsgroup-last-file nil)
1475 (defvar gnus-newsgroup-last-directory nil)
1476 (defvar gnus-newsgroup-auto-expire nil)
1477 (defvar gnus-newsgroup-active nil)
1478 (defvar gnus-newsgroup-highest nil)
1480 (defvar gnus-newsgroup-data nil)
1481 (defvar gnus-newsgroup-data-reverse nil)
1482 (defvar gnus-newsgroup-limit nil)
1483 (defvar gnus-newsgroup-limits nil)
1484 (defvar gnus-summary-use-undownloaded-faces nil)
1486 (defvar gnus-newsgroup-unreads nil
1487 "Sorted list of unread articles in the current newsgroup.")
1489 (defvar gnus-newsgroup-unselected nil
1490 "Sorted list of unselected unread articles in the current newsgroup.")
1492 (defvar gnus-newsgroup-reads nil
1493 "Alist of read articles and article marks in the current newsgroup.")
1495 (defvar gnus-newsgroup-expunged-tally nil)
1497 (defvar gnus-newsgroup-marked nil
1498 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1500 (defvar gnus-newsgroup-spam-marked nil
1501 "List of ranges of articles that have been marked as spam.")
1503 (defvar gnus-newsgroup-killed nil
1504 "List of ranges of articles that have been through the scoring process.")
1506 (defvar gnus-newsgroup-cached nil
1507 "Sorted list of articles that come from the article cache.")
1509 (defvar gnus-newsgroup-saved nil
1510 "List of articles that have been saved.")
1512 (defvar gnus-newsgroup-kill-headers nil)
1514 (defvar gnus-newsgroup-replied nil
1515 "List of articles that have been replied to in the current newsgroup.")
1517 (defvar gnus-newsgroup-forwarded nil
1518 "List of articles that have been forwarded in the current newsgroup.")
1520 (defvar gnus-newsgroup-expirable nil
1521 "Sorted list of articles in the current newsgroup that can be expired.")
1523 (defvar gnus-newsgroup-processable nil
1524 "List of articles in the current newsgroup that can be processed.")
1526 (defvar gnus-newsgroup-downloadable nil
1527 "Sorted list of articles in the current newsgroup that can be processed.")
1529 (defvar gnus-newsgroup-unfetched nil
1530 "Sorted list of articles in the current newsgroup whose headers have
1531 not been fetched into the agent.
1533 This list will always be a subset of gnus-newsgroup-undownloaded.")
1535 (defvar gnus-newsgroup-undownloaded nil
1536 "List of articles in the current newsgroup that haven't been downloaded.")
1538 (defvar gnus-newsgroup-unsendable nil
1539 "List of articles in the current newsgroup that won't be sent.")
1541 (defvar gnus-newsgroup-bookmarks nil
1542 "List of articles in the current newsgroup that have bookmarks.")
1544 (defvar gnus-newsgroup-dormant nil
1545 "Sorted list of dormant articles in the current newsgroup.")
1547 (defvar gnus-newsgroup-unseen nil
1548 "List of unseen articles in the current newsgroup.")
1550 (defvar gnus-newsgroup-seen nil
1551 "Range of seen articles in the current newsgroup.")
1553 (defvar gnus-newsgroup-unexist nil
1554 "Range of unexisting articles in the current newsgroup.")
1556 (defvar gnus-newsgroup-articles nil
1557 "List of articles in the current newsgroup.")
1559 (defvar gnus-newsgroup-scored nil
1560 "List of scored articles in the current newsgroup.")
1562 (defvar gnus-newsgroup-headers nil
1563 "List of article headers in the current newsgroup.")
1565 (defvar gnus-newsgroup-threads nil)
1567 (defvar gnus-newsgroup-prepared nil
1568 "Whether the current group has been prepared properly.")
1570 (defvar gnus-newsgroup-ancient nil
1571 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1573 (defvar gnus-newsgroup-sparse nil)
1575 (defvar gnus-current-article nil)
1576 (defvar gnus-article-current nil)
1577 (defvar gnus-current-headers nil)
1578 (defvar gnus-have-all-headers nil)
1579 (defvar gnus-last-article nil)
1580 (defvar gnus-newsgroup-history nil)
1581 (defvar gnus-newsgroup-charset nil)
1582 (defvar gnus-newsgroup-ephemeral-charset nil)
1583 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1585 (defvar gnus-article-before-search nil)
1587 (defvar gnus-summary-local-variables
1588 '(gnus-newsgroup-name
1590 ;; Marks lists
1591 gnus-newsgroup-unreads
1592 gnus-newsgroup-unselected
1593 gnus-newsgroup-marked
1594 gnus-newsgroup-spam-marked
1595 gnus-newsgroup-reads
1596 gnus-newsgroup-saved
1597 gnus-newsgroup-replied
1598 gnus-newsgroup-forwarded
1599 gnus-newsgroup-expirable
1600 gnus-newsgroup-killed
1601 gnus-newsgroup-unseen
1602 gnus-newsgroup-seen
1603 gnus-newsgroup-unexist
1604 gnus-newsgroup-cached
1605 gnus-newsgroup-downloadable
1606 gnus-newsgroup-undownloaded
1607 gnus-newsgroup-unsendable
1609 gnus-newsgroup-begin gnus-newsgroup-end
1610 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1611 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1612 gnus-newsgroup-last-directory
1613 gnus-newsgroup-auto-expire
1614 gnus-newsgroup-processable
1615 gnus-newsgroup-unfetched
1616 gnus-newsgroup-articles
1617 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1618 gnus-newsgroup-headers gnus-newsgroup-threads
1619 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1620 gnus-current-article gnus-current-headers gnus-have-all-headers
1621 gnus-last-article gnus-article-internal-prepare-hook
1622 (gnus-summary-article-delete-hook . global)
1623 (gnus-summary-article-move-hook . global)
1624 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1625 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1626 gnus-thread-expunge-below
1627 gnus-score-alist gnus-current-score-file
1628 (gnus-summary-expunge-below . global)
1629 (gnus-summary-mark-below . global)
1630 (gnus-orphan-score . global)
1631 gnus-newsgroup-active gnus-scores-exclude-files
1632 gnus-newsgroup-highest
1633 gnus-newsgroup-history gnus-newsgroup-ancient
1634 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1635 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1636 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1637 (gnus-newsgroup-expunged-tally . 0)
1638 gnus-cache-removable-articles
1639 gnus-newsgroup-data gnus-newsgroup-data-reverse
1640 gnus-newsgroup-limit gnus-newsgroup-limits
1641 gnus-newsgroup-charset gnus-newsgroup-display
1642 gnus-summary-use-undownloaded-faces)
1643 "Variables that are buffer-local to the summary buffers.")
1645 (defvar gnus-newsgroup-variables nil
1646 "A list of variables that have separate values in different newsgroups.
1647 A list of newsgroup (summary buffer) local variables, or cons of
1648 variables and their default expressions to be evalled (when the default
1649 values are not nil), that should be made global while the summary buffer
1650 is active.
1652 Note: The default expressions will be evaluated (using function `eval')
1653 before assignment to the local variable rather than just assigned to it.
1654 If the default expression is the symbol `global', that symbol will not
1655 be evaluated but the global value of the local variable will be used
1656 instead.
1658 These variables can be used to set variables in the group parameters
1659 while still allowing them to affect operations done in other buffers.
1660 For example:
1662 \(setq gnus-newsgroup-variables
1663 \\='(message-use-followup-to
1664 (gnus-visible-headers .
1665 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1668 (eval-when-compile
1669 ;; Bind features so that require will believe that gnus-sum has
1670 ;; already been loaded (avoids infinite recursion)
1671 (let ((features (cons 'gnus-sum features)))
1672 (require 'gnus-art)))
1674 ;; MIME stuff.
1676 (defvar gnus-decode-encoded-word-methods
1677 '(mail-decode-encoded-word-string)
1678 "List of methods used to decode encoded words.
1680 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1681 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1682 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1683 whose names match REGEXP.
1685 For example:
1686 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1687 mail-decode-encoded-word-string
1688 (\"chinese\" . rfc1843-decode-string))")
1690 (defvar gnus-decode-encoded-word-methods-cache nil)
1692 (defun gnus-multi-decode-encoded-word-string (string)
1693 "Apply the functions from `gnus-encoded-word-methods' that match."
1694 (unless (and gnus-decode-encoded-word-methods-cache
1695 (eq gnus-newsgroup-name
1696 (car gnus-decode-encoded-word-methods-cache)))
1697 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1698 (dolist (method gnus-decode-encoded-word-methods)
1699 (if (symbolp method)
1700 (nconc gnus-decode-encoded-word-methods-cache (list method))
1701 (if (and gnus-newsgroup-name
1702 (string-match (car method) gnus-newsgroup-name))
1703 (nconc gnus-decode-encoded-word-methods-cache
1704 (list (cdr method)))))))
1705 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1706 (setq string (funcall method string))))
1708 ;; Subject simplification.
1710 (defun gnus-simplify-whitespace (str)
1711 "Remove excessive whitespace from STR."
1712 ;; Multiple spaces.
1713 (while (string-match "[ \t][ \t]+" str)
1714 (setq str (concat (substring str 0 (match-beginning 0))
1716 (substring str (match-end 0)))))
1717 ;; Leading spaces.
1718 (when (string-match "^[ \t]+" str)
1719 (setq str (substring str (match-end 0))))
1720 ;; Trailing spaces.
1721 (when (string-match "[ \t]+$" str)
1722 (setq str (substring str 0 (match-beginning 0))))
1723 str)
1725 (defun gnus-simplify-all-whitespace (str)
1726 "Remove all whitespace from STR."
1727 (while (string-match "[ \t\n]+" str)
1728 (setq str (replace-match "" nil nil str)))
1729 str)
1731 (defsubst gnus-simplify-subject-re (subject)
1732 "Remove \"Re:\" from subject lines."
1733 (if (string-match message-subject-re-regexp subject)
1734 (substring subject (match-end 0))
1735 subject))
1737 (defun gnus-simplify-subject (subject &optional re-only)
1738 "Remove `Re:' and words in parentheses.
1739 If RE-ONLY is non-nil, strip leading `Re:'s only."
1740 (let ((case-fold-search t)) ;Ignore case.
1741 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1742 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1743 (setq subject (substring subject (match-end 0))))
1744 ;; Remove uninteresting prefixes.
1745 (when (and (not re-only)
1746 gnus-simplify-ignored-prefixes
1747 (string-match gnus-simplify-ignored-prefixes subject))
1748 (setq subject (substring subject (match-end 0))))
1749 ;; Remove words in parentheses from end.
1750 (unless re-only
1751 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1752 (setq subject (substring subject 0 (match-beginning 0)))))
1753 ;; Return subject string.
1754 subject))
1756 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1757 ;; all whitespace.
1758 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1759 (goto-char (point-min))
1760 (while (re-search-forward regexp nil t)
1761 (replace-match (or newtext ""))))
1763 (defun gnus-simplify-buffer-fuzzy (regexp)
1764 "Simplify string in the buffer fuzzily.
1765 The string in the accessible portion of the current buffer is simplified.
1766 It is assumed to be a single-line subject.
1767 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1768 matter is removed. Additional things can be deleted by setting
1769 `gnus-simplify-subject-fuzzy-regexp'."
1770 (let ((case-fold-search t)
1771 (modified-tick))
1772 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1774 (while (not (eq modified-tick (buffer-modified-tick)))
1775 (setq modified-tick (buffer-modified-tick))
1776 (cond
1777 ((listp regexp)
1778 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1779 (regexp
1780 (gnus-simplify-buffer-fuzzy-step regexp)))
1781 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1782 (gnus-simplify-buffer-fuzzy-step
1783 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1784 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1786 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1787 (gnus-simplify-buffer-fuzzy-step " +" " ")
1788 (gnus-simplify-buffer-fuzzy-step " $")
1789 (gnus-simplify-buffer-fuzzy-step "^ +")))
1791 (defun gnus-simplify-subject-fuzzy (subject)
1792 "Simplify a subject string fuzzily.
1793 See `gnus-simplify-buffer-fuzzy' for details."
1794 (save-excursion
1795 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1796 (gnus-set-work-buffer)
1797 (let ((case-fold-search t))
1798 ;; Remove uninteresting prefixes.
1799 (when (and gnus-simplify-ignored-prefixes
1800 (string-match gnus-simplify-ignored-prefixes subject))
1801 (setq subject (substring subject (match-end 0))))
1802 (insert subject)
1803 (inline (gnus-simplify-buffer-fuzzy regexp))
1804 (buffer-string)))))
1806 (defsubst gnus-simplify-subject-fully (subject)
1807 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1808 (cond
1809 (gnus-simplify-subject-functions
1810 (gnus-map-function gnus-simplify-subject-functions subject))
1811 ((null gnus-summary-gather-subject-limit)
1812 (gnus-simplify-subject-re subject))
1813 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1814 (gnus-simplify-subject-fuzzy subject))
1815 ((numberp gnus-summary-gather-subject-limit)
1816 (truncate-string-to-width (gnus-simplify-subject-re subject)
1817 gnus-summary-gather-subject-limit))
1819 subject)))
1821 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1822 "Check whether two subjects are equal.
1823 If optional argument SIMPLE-FIRST is t, first argument is already
1824 simplified."
1825 (cond
1826 ((null simple-first)
1827 (equal (gnus-simplify-subject-fully s1)
1828 (gnus-simplify-subject-fully s2)))
1830 (equal s1
1831 (gnus-simplify-subject-fully s2)))))
1833 (defun gnus-summary-bubble-group ()
1834 "Increase the score of the current group.
1835 This is a handy function to add to `gnus-summary-exit-hook' to
1836 increase the score of each group you read."
1837 (gnus-group-add-score gnus-newsgroup-name))
1841 ;;; Gnus summary mode
1844 (put 'gnus-summary-mode 'mode-class 'special)
1846 (defvar gnus-article-commands-menu)
1848 ;; Non-orthogonal keys
1850 (gnus-define-keys gnus-summary-mode-map
1851 " " gnus-summary-next-page
1852 [?\S-\ ] gnus-summary-prev-page
1853 "\177" gnus-summary-prev-page
1854 [delete] gnus-summary-prev-page
1855 "\r" gnus-summary-scroll-up
1856 "\M-\r" gnus-summary-scroll-down
1857 "n" gnus-summary-next-unread-article
1858 "p" gnus-summary-prev-unread-article
1859 "N" gnus-summary-next-article
1860 "P" gnus-summary-prev-article
1861 "\M-\C-n" gnus-summary-next-same-subject
1862 "\M-\C-p" gnus-summary-prev-same-subject
1863 "\M-n" gnus-summary-next-unread-subject
1864 "\M-p" gnus-summary-prev-unread-subject
1865 "." gnus-summary-first-unread-article
1866 "," gnus-summary-best-unread-article
1867 "\M-s" gnus-summary-search-article-forward
1868 "\M-r" gnus-summary-search-article-backward
1869 "\M-S" gnus-summary-repeat-search-article-forward
1870 "\M-R" gnus-summary-repeat-search-article-backward
1871 "<" gnus-summary-beginning-of-article
1872 ">" gnus-summary-end-of-article
1873 "j" gnus-summary-goto-article
1874 "^" gnus-summary-refer-parent-article
1875 "\M-^" gnus-summary-refer-article
1876 "u" gnus-summary-tick-article-forward
1877 "!" gnus-summary-tick-article-forward
1878 "U" gnus-summary-tick-article-backward
1879 "d" gnus-summary-mark-as-read-forward
1880 "D" gnus-summary-mark-as-read-backward
1881 "E" gnus-summary-mark-as-expirable
1882 "\M-u" gnus-summary-clear-mark-forward
1883 "\M-U" gnus-summary-clear-mark-backward
1884 "k" gnus-summary-kill-same-subject-and-select
1885 "\C-k" gnus-summary-kill-same-subject
1886 "\M-\C-k" gnus-summary-kill-thread
1887 "\M-\C-l" gnus-summary-lower-thread
1888 "e" gnus-summary-edit-article
1889 "#" gnus-summary-mark-as-processable
1890 "\M-#" gnus-summary-unmark-as-processable
1891 "\M-\C-t" gnus-summary-toggle-threads
1892 "\M-\C-s" gnus-summary-show-thread
1893 "\M-\C-h" gnus-summary-hide-thread
1894 "\M-\C-f" gnus-summary-next-thread
1895 "\M-\C-b" gnus-summary-prev-thread
1896 [(meta down)] gnus-summary-next-thread
1897 [(meta up)] gnus-summary-prev-thread
1898 "\M-\C-u" gnus-summary-up-thread
1899 "\M-\C-d" gnus-summary-down-thread
1900 "&" gnus-summary-execute-command
1901 "c" gnus-summary-catchup-and-exit
1902 "\C-w" gnus-summary-mark-region-as-read
1903 "\C-t" toggle-truncate-lines
1904 "?" gnus-summary-mark-as-dormant
1905 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1906 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1907 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1908 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1909 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1910 "\C-c\C-s\C-m\C-m" gnus-summary-sort-by-marks
1911 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1912 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1913 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1914 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1915 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1916 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1917 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1918 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1919 "=" gnus-summary-expand-window
1920 "\C-x\C-s" gnus-summary-reselect-current-group
1921 "\M-g" gnus-summary-rescan-group
1922 "\C-c\C-r" gnus-summary-caesar-message
1923 "f" gnus-summary-followup
1924 "F" gnus-summary-followup-with-original
1925 "C" gnus-summary-cancel-article
1926 "r" gnus-summary-reply
1927 "R" gnus-summary-reply-with-original
1928 "\C-c\C-f" gnus-summary-mail-forward
1929 "o" gnus-summary-save-article
1930 "\C-o" gnus-summary-save-article-mail
1931 "|" gnus-summary-pipe-output
1932 "\M-k" gnus-summary-edit-local-kill
1933 "\M-K" gnus-summary-edit-global-kill
1934 ;; "V" gnus-version
1935 "\C-c\C-d" gnus-summary-describe-group
1936 "q" gnus-summary-exit
1937 "Q" gnus-summary-exit-no-update
1938 "\C-c\C-i" gnus-info-find-node
1939 [mouse-2] gnus-mouse-pick-article
1940 [follow-link] mouse-face
1941 "m" gnus-summary-mail-other-window
1942 "a" gnus-summary-post-news
1943 "x" gnus-summary-limit-to-unread
1944 "s" gnus-summary-isearch-article
1945 "\t" gnus-summary-widget-forward
1946 [backtab] gnus-summary-widget-backward
1947 "t" gnus-summary-toggle-header
1948 "g" gnus-summary-show-article
1949 "l" gnus-summary-goto-last-article
1950 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1951 "\C-d" gnus-summary-enter-digest-group
1952 "\M-\C-d" gnus-summary-read-document
1953 "\M-\C-e" gnus-summary-edit-parameters
1954 "\M-\C-a" gnus-summary-customize-parameters
1955 "\C-c\C-b" gnus-bug
1956 "*" gnus-cache-enter-article
1957 "\M-*" gnus-cache-remove-article
1958 "\M-&" gnus-summary-universal-argument
1959 "\C-l" gnus-recenter
1960 "I" gnus-summary-increase-score
1961 "L" gnus-summary-lower-score
1962 "\M-i" gnus-symbolic-argument
1963 "h" gnus-summary-select-article-buffer
1965 "b" gnus-article-view-part
1966 "\M-t" gnus-summary-toggle-display-buttonized
1968 "V" gnus-summary-score-map
1969 "X" gnus-uu-extract-map
1970 "S" gnus-summary-send-map)
1972 ;; Sort of orthogonal keymap
1973 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1974 "t" gnus-summary-tick-article-forward
1975 "!" gnus-summary-tick-article-forward
1976 "d" gnus-summary-mark-as-read-forward
1977 "r" gnus-summary-mark-as-read-forward
1978 "c" gnus-summary-clear-mark-forward
1979 " " gnus-summary-clear-mark-forward
1980 "e" gnus-summary-mark-as-expirable
1981 "x" gnus-summary-mark-as-expirable
1982 "?" gnus-summary-mark-as-dormant
1983 "b" gnus-summary-set-bookmark
1984 "B" gnus-summary-remove-bookmark
1985 "#" gnus-summary-mark-as-processable
1986 "\M-#" gnus-summary-unmark-as-processable
1987 "S" gnus-summary-limit-include-expunged
1988 "C" gnus-summary-catchup
1989 "H" gnus-summary-catchup-to-here
1990 "h" gnus-summary-catchup-from-here
1991 "\C-c" gnus-summary-catchup-all
1992 "k" gnus-summary-kill-same-subject-and-select
1993 "K" gnus-summary-kill-same-subject
1994 "P" gnus-uu-mark-map)
1996 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1997 "c" gnus-summary-clear-above
1998 "u" gnus-summary-tick-above
1999 "m" gnus-summary-mark-above
2000 "k" gnus-summary-kill-below)
2002 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
2003 "/" gnus-summary-limit-to-subject
2004 "n" gnus-summary-limit-to-articles
2005 "b" gnus-summary-limit-to-bodies
2006 "h" gnus-summary-limit-to-headers
2007 "w" gnus-summary-pop-limit
2008 "s" gnus-summary-limit-to-subject
2009 "a" gnus-summary-limit-to-author
2010 "u" gnus-summary-limit-to-unread
2011 "m" gnus-summary-limit-to-marks
2012 "M" gnus-summary-limit-exclude-marks
2013 "v" gnus-summary-limit-to-score
2014 "*" gnus-summary-limit-include-cached
2015 "D" gnus-summary-limit-include-dormant
2016 "T" gnus-summary-limit-include-thread
2017 "d" gnus-summary-limit-exclude-dormant
2018 "t" gnus-summary-limit-to-age
2019 "." gnus-summary-limit-to-unseen
2020 "x" gnus-summary-limit-to-extra
2021 "p" gnus-summary-limit-to-display-predicate
2022 "E" gnus-summary-limit-include-expunged
2023 "c" gnus-summary-limit-exclude-childless-dormant
2024 "C" gnus-summary-limit-mark-excluded-as-read
2025 "o" gnus-summary-insert-old-articles
2026 "N" gnus-summary-insert-new-articles
2027 "S" gnus-summary-limit-to-singletons
2028 "r" gnus-summary-limit-to-replied
2029 "R" gnus-summary-limit-to-recipient
2030 "A" gnus-summary-limit-to-address)
2032 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2033 "n" gnus-summary-next-unread-article
2034 "p" gnus-summary-prev-unread-article
2035 "N" gnus-summary-next-article
2036 "P" gnus-summary-prev-article
2037 "\C-n" gnus-summary-next-same-subject
2038 "\C-p" gnus-summary-prev-same-subject
2039 "\M-n" gnus-summary-next-unread-subject
2040 "\M-p" gnus-summary-prev-unread-subject
2041 "f" gnus-summary-first-unread-article
2042 "b" gnus-summary-best-unread-article
2043 "j" gnus-summary-goto-article
2044 "g" gnus-summary-goto-subject
2045 "l" gnus-summary-goto-last-article
2046 "o" gnus-summary-pop-article)
2048 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2049 "k" gnus-summary-kill-thread
2050 "E" gnus-summary-expire-thread
2051 "l" gnus-summary-lower-thread
2052 "i" gnus-summary-raise-thread
2053 "T" gnus-summary-toggle-threads
2054 "t" gnus-summary-rethread-current
2055 "^" gnus-summary-reparent-thread
2056 "\M-^" gnus-summary-reparent-children
2057 "s" gnus-summary-show-thread
2058 "S" gnus-summary-show-all-threads
2059 "h" gnus-summary-hide-thread
2060 "H" gnus-summary-hide-all-threads
2061 "n" gnus-summary-next-thread
2062 "p" gnus-summary-prev-thread
2063 "u" gnus-summary-up-thread
2064 "o" gnus-summary-top-thread
2065 "d" gnus-summary-down-thread
2066 "#" gnus-uu-mark-thread
2067 "\M-#" gnus-uu-unmark-thread)
2069 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2070 "g" gnus-summary-prepare
2071 "c" gnus-summary-insert-cached-articles
2072 "d" gnus-summary-insert-dormant-articles
2073 "t" gnus-summary-insert-ticked-articles)
2075 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2076 "c" gnus-summary-catchup-and-exit
2077 "C" gnus-summary-catchup-all-and-exit
2078 "E" gnus-summary-exit-no-update
2079 "Q" gnus-summary-exit
2080 "Z" gnus-summary-exit
2081 "n" gnus-summary-catchup-and-goto-next-group
2082 "p" gnus-summary-catchup-and-goto-prev-group
2083 "R" gnus-summary-reselect-current-group
2084 "G" gnus-summary-rescan-group
2085 "N" gnus-summary-next-group
2086 "s" gnus-summary-save-newsrc
2087 "P" gnus-summary-prev-group)
2089 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2090 " " gnus-summary-next-page
2091 "n" gnus-summary-next-page
2092 [?\S-\ ] gnus-summary-prev-page
2093 "\177" gnus-summary-prev-page
2094 [delete] gnus-summary-prev-page
2095 "p" gnus-summary-prev-page
2096 "\r" gnus-summary-scroll-up
2097 "\M-\r" gnus-summary-scroll-down
2098 "<" gnus-summary-beginning-of-article
2099 ">" gnus-summary-end-of-article
2100 "b" gnus-summary-beginning-of-article
2101 "e" gnus-summary-end-of-article
2102 "^" gnus-summary-refer-parent-article
2103 "r" gnus-summary-refer-parent-article
2104 "C" gnus-summary-show-complete-article
2105 "D" gnus-summary-enter-digest-group
2106 "R" gnus-summary-refer-references
2107 "T" gnus-summary-refer-thread
2108 "W" gnus-warp-to-article
2109 "g" gnus-summary-show-article
2110 "s" gnus-summary-isearch-article
2111 "\t" gnus-summary-widget-forward
2112 [backtab] gnus-summary-widget-backward
2113 "P" gnus-summary-print-article
2114 "S" gnus-sticky-article
2115 "M" gnus-mailing-list-insinuate
2116 "t" gnus-article-babel)
2118 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2119 "b" gnus-article-add-buttons
2120 "B" gnus-article-add-buttons-to-head
2121 "o" gnus-article-treat-overstrike
2122 "e" gnus-article-emphasize
2123 "w" gnus-article-fill-cited-article
2124 "Q" gnus-article-fill-long-lines
2125 "L" gnus-article-toggle-truncate-lines
2126 "C" gnus-article-capitalize-sentences
2127 "c" gnus-article-remove-cr
2128 "q" gnus-article-de-quoted-unreadable
2129 "6" gnus-article-de-base64-unreadable
2130 "Z" gnus-article-decode-HZ
2131 "A" gnus-article-treat-ansi-sequences
2132 "h" gnus-article-wash-html
2133 "u" gnus-article-unsplit-urls
2134 "s" gnus-summary-force-verify-and-decrypt
2135 "f" gnus-article-display-x-face
2136 "l" gnus-summary-stop-page-breaking
2137 "r" gnus-summary-caesar-message
2138 "m" gnus-summary-morse-message
2139 "t" gnus-summary-toggle-header
2140 "g" gnus-treat-smiley
2141 "v" gnus-summary-verbose-headers
2142 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2143 "p" gnus-article-verify-x-pgp-sig
2144 "d" gnus-article-treat-dumbquotes
2145 "U" gnus-article-treat-non-ascii
2146 "i" gnus-summary-idna-message)
2148 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2149 ;; mnemonic: deuglif*Y*
2150 "u" gnus-article-outlook-unwrap-lines
2151 "a" gnus-article-outlook-repair-attribution
2152 "c" gnus-article-outlook-rearrange-citation
2153 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2155 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2156 "a" gnus-article-hide
2157 "h" gnus-article-hide-headers
2158 "b" gnus-article-hide-boring-headers
2159 "s" gnus-article-hide-signature
2160 "c" gnus-article-hide-citation
2161 "C" gnus-article-hide-citation-in-followups
2162 "l" gnus-article-hide-list-identifiers
2163 "B" gnus-article-strip-banner
2164 "P" gnus-article-hide-pem
2165 "\C-c" gnus-article-hide-citation-maybe)
2167 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2168 "a" gnus-article-highlight
2169 "h" gnus-article-highlight-headers
2170 "c" gnus-article-highlight-citation
2171 "s" gnus-article-highlight-signature)
2173 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2174 "f" gnus-article-treat-fold-headers
2175 "u" gnus-article-treat-unfold-headers
2176 "n" gnus-article-treat-fold-newsgroups)
2178 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2179 "x" gnus-article-display-x-face
2180 "d" gnus-article-display-face
2181 "s" gnus-treat-smiley
2182 "D" gnus-article-remove-images
2183 "W" gnus-article-show-images
2184 "f" gnus-treat-from-picon
2185 "m" gnus-treat-mail-picon
2186 "n" gnus-treat-newsgroups-picon
2187 "g" gnus-treat-from-gravatar
2188 "h" gnus-treat-mail-gravatar)
2190 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2191 "w" gnus-article-decode-mime-words
2192 "c" gnus-article-decode-charset
2193 "h" gnus-mime-buttonize-attachments-in-header
2194 "v" gnus-mime-view-all-parts
2195 "b" gnus-article-view-part)
2197 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2198 "z" gnus-article-date-ut
2199 "u" gnus-article-date-ut
2200 "l" gnus-article-date-local
2201 "p" gnus-article-date-english
2202 "e" gnus-article-date-lapsed
2203 "o" gnus-article-date-original
2204 "i" gnus-article-date-iso8601
2205 "s" gnus-article-date-user)
2207 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2208 "t" gnus-article-remove-trailing-blank-lines
2209 "l" gnus-article-strip-leading-blank-lines
2210 "m" gnus-article-strip-multiple-blank-lines
2211 "a" gnus-article-strip-blank-lines
2212 "A" gnus-article-strip-all-blank-lines
2213 "s" gnus-article-strip-leading-space
2214 "e" gnus-article-strip-trailing-space
2215 "w" gnus-article-remove-leading-whitespace)
2217 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2218 "v" gnus-version
2219 "d" gnus-summary-describe-group
2220 "h" gnus-summary-describe-briefly
2221 "i" gnus-info-find-node)
2223 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2224 "e" gnus-summary-expire-articles
2225 "\M-\C-e" gnus-summary-expire-articles-now
2226 "\177" gnus-summary-delete-article
2227 [delete] gnus-summary-delete-article
2228 [backspace] gnus-summary-delete-article
2229 "m" gnus-summary-move-article
2230 "r" gnus-summary-respool-article
2231 "w" gnus-summary-edit-article
2232 "c" gnus-summary-copy-article
2233 "B" gnus-summary-crosspost-article
2234 "q" gnus-summary-respool-query
2235 "t" gnus-summary-respool-trace
2236 "i" gnus-summary-import-article
2237 "I" gnus-summary-create-article
2238 "p" gnus-summary-article-posted-p)
2240 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2241 "o" gnus-summary-save-article
2242 "m" gnus-summary-save-article-mail
2243 "F" gnus-summary-write-article-file
2244 "r" gnus-summary-save-article-rmail
2245 "f" gnus-summary-save-article-file
2246 "b" gnus-summary-save-article-body-file
2247 "B" gnus-summary-write-article-body-file
2248 "h" gnus-summary-save-article-folder
2249 "v" gnus-summary-save-article-vm
2250 "p" gnus-summary-pipe-output
2251 "P" gnus-summary-muttprint)
2253 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2254 "b" gnus-summary-display-buttonized
2255 "m" gnus-summary-repair-multipart
2256 "v" gnus-article-view-part
2257 "o" gnus-article-save-part
2258 "O" gnus-article-save-part-and-strip
2259 "r" gnus-article-replace-part
2260 "d" gnus-article-delete-part
2261 "t" gnus-article-view-part-as-type
2262 "j" gnus-article-jump-to-part
2263 "c" gnus-article-copy-part
2264 "C" gnus-article-view-part-as-charset
2265 "e" gnus-article-view-part-externally
2266 "H" gnus-article-browse-html-article
2267 "E" gnus-article-encrypt-body
2268 "i" gnus-article-inline-part
2269 "|" gnus-article-pipe-part)
2271 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2272 "p" gnus-summary-mark-as-processable
2273 "u" gnus-summary-unmark-as-processable
2274 "U" gnus-summary-unmark-all-processable
2275 "v" gnus-uu-mark-over
2276 "s" gnus-uu-mark-series
2277 "r" gnus-uu-mark-region
2278 "g" gnus-uu-unmark-region
2279 "R" gnus-uu-mark-by-regexp
2280 "G" gnus-uu-unmark-by-regexp
2281 "t" gnus-uu-mark-thread
2282 "T" gnus-uu-unmark-thread
2283 "a" gnus-uu-mark-all
2284 "b" gnus-uu-mark-buffer
2285 "S" gnus-uu-mark-sparse
2286 "k" gnus-summary-kill-process-mark
2287 "y" gnus-summary-yank-process-mark
2288 "w" gnus-summary-save-process-mark
2289 "i" gnus-uu-invert-processable)
2291 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2292 ;;"x" gnus-uu-extract-any
2293 "m" gnus-summary-save-parts
2294 "u" gnus-uu-decode-uu
2295 "U" gnus-uu-decode-uu-and-save
2296 "s" gnus-uu-decode-unshar
2297 "S" gnus-uu-decode-unshar-and-save
2298 "o" gnus-uu-decode-save
2299 "O" gnus-uu-decode-save
2300 "b" gnus-uu-decode-binhex
2301 "B" gnus-uu-decode-binhex
2302 "Y" gnus-uu-decode-yenc
2303 "p" gnus-uu-decode-postscript
2304 "P" gnus-uu-decode-postscript-and-save)
2306 (gnus-define-keys
2307 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2308 "u" gnus-uu-decode-uu-view
2309 "U" gnus-uu-decode-uu-and-save-view
2310 "s" gnus-uu-decode-unshar-view
2311 "S" gnus-uu-decode-unshar-and-save-view
2312 "o" gnus-uu-decode-save-view
2313 "O" gnus-uu-decode-save-view
2314 "b" gnus-uu-decode-binhex-view
2315 "B" gnus-uu-decode-binhex-view
2316 "p" gnus-uu-decode-postscript-view
2317 "P" gnus-uu-decode-postscript-and-save-view)
2319 (defvar gnus-article-post-menu nil)
2321 (defconst gnus-summary-menu-maxlen 20)
2323 (defun gnus-summary-menu-split (menu)
2324 ;; If we have lots of elements, divide them into groups of 20
2325 ;; and make a pane (or submenu) for each one.
2326 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2327 (let ((menu menu) sublists next
2328 (i 1))
2329 (while menu
2330 ;; Pull off the next gnus-summary-menu-maxlen elements
2331 ;; and make them the next element of sublist.
2332 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2333 (if next
2334 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2335 nil))
2336 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2337 (aref (car (last menu)) 0)) menu)
2338 sublists))
2339 (setq i (1+ i))
2340 (setq menu next))
2341 (nreverse sublists))
2342 ;; Few elements--put them all in one pane.
2343 menu))
2345 (defun gnus-summary-make-menu-bar ()
2346 (gnus-turn-off-edit-menu 'summary)
2348 (unless (boundp 'gnus-summary-misc-menu)
2350 (easy-menu-define
2351 gnus-summary-kill-menu gnus-summary-mode-map ""
2352 (cons
2353 "Score"
2354 (nconc
2355 (list
2356 ["Customize" gnus-score-customize t])
2357 (gnus-make-score-map 'increase)
2358 (gnus-make-score-map 'lower)
2359 '(("Mark"
2360 ["Kill below" gnus-summary-kill-below t]
2361 ["Mark above" gnus-summary-mark-above t]
2362 ["Tick above" gnus-summary-tick-above t]
2363 ["Clear above" gnus-summary-clear-above t])
2364 ["Current article score" gnus-summary-current-score t]
2365 ["Current thread score" (gnus-summary-current-score 'total) t]
2366 ["Set score" gnus-summary-set-score t]
2367 ["Switch current score file..." gnus-score-change-score-file t]
2368 ["Set mark below..." gnus-score-set-mark-below t]
2369 ["Set expunge below..." gnus-score-set-expunge-below t]
2370 ["Edit current score file" gnus-score-edit-current-scores t]
2371 ["Edit score file..." gnus-score-edit-file t]
2372 ["Trace score" gnus-score-find-trace t]
2373 ["Find words" gnus-score-find-favourite-words t]
2374 ["Rescore buffer" gnus-summary-rescore t]
2375 ["Increase score..." gnus-summary-increase-score t]
2376 ["Lower score..." gnus-summary-lower-score t]))))
2378 ;; Define both the Article menu in the summary buffer and the
2379 ;; equivalent Commands menu in the article buffer here for
2380 ;; consistency.
2381 (let ((innards
2382 `(("Hide"
2383 ["All" gnus-article-hide t]
2384 ["Headers" gnus-article-hide-headers t]
2385 ["Signature" gnus-article-hide-signature t]
2386 ["Citation" gnus-article-hide-citation t]
2387 ["List identifiers" gnus-article-hide-list-identifiers t]
2388 ["Banner" gnus-article-strip-banner t]
2389 ["Boring headers" gnus-article-hide-boring-headers t])
2390 ("Highlight"
2391 ["All" gnus-article-highlight t]
2392 ["Headers" gnus-article-highlight-headers t]
2393 ["Signature" gnus-article-highlight-signature t]
2394 ["Citation" gnus-article-highlight-citation t])
2395 ("MIME"
2396 ["Words" gnus-article-decode-mime-words t]
2397 ["Charset" gnus-article-decode-charset t]
2398 ["QP" gnus-article-de-quoted-unreadable t]
2399 ["Base64" gnus-article-de-base64-unreadable t]
2400 ["View MIME buttons" gnus-summary-display-buttonized t]
2401 ["View MIME buttons in header"
2402 gnus-mime-buttonize-attachments-in-header t]
2403 ["View all" gnus-mime-view-all-parts t]
2404 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2405 ["Encrypt body" gnus-article-encrypt-body
2406 :active (not (gnus-group-read-only-p))
2407 :help "Encrypt the message body on disk"]
2408 ["Extract all parts..." gnus-summary-save-parts t]
2409 ("Multipart"
2410 ["Repair multipart" gnus-summary-repair-multipart t]
2411 ["Pipe part..." gnus-article-pipe-part t]
2412 ["Inline part" gnus-article-inline-part t]
2413 ["View part as type..." gnus-article-view-part-as-type t]
2414 ["Encrypt body" gnus-article-encrypt-body
2415 :active (not (gnus-group-read-only-p))
2416 :help "Encrypt the message body on disk"]
2417 ["View part externally" gnus-article-view-part-externally t]
2418 ["View HTML parts in browser" gnus-article-browse-html-article t]
2419 ["View part with charset..." gnus-article-view-part-as-charset t]
2420 ["Copy part" gnus-article-copy-part t]
2421 ["Save part..." gnus-article-save-part t]
2422 ["View part" gnus-article-view-part t]))
2423 ("Date"
2424 ["Local" gnus-article-date-local t]
2425 ["ISO8601" gnus-article-date-iso8601 t]
2426 ["UT" gnus-article-date-ut t]
2427 ["Original" gnus-article-date-original t]
2428 ["Lapsed" gnus-article-date-lapsed t]
2429 ["User-defined" gnus-article-date-user t])
2430 ("Display"
2431 ["Display HTML images" gnus-article-show-images t]
2432 ["Remove images" gnus-article-remove-images t]
2433 ["Toggle smiley" gnus-treat-smiley t]
2434 ["Show X-Face" gnus-article-display-x-face t]
2435 ["Show picons in From" gnus-treat-from-picon t]
2436 ["Show picons in mail headers" gnus-treat-mail-picon t]
2437 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2438 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2439 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2440 ("View as different encoding"
2441 ,@(gnus-summary-menu-split
2442 (mapcar
2443 (lambda (cs)
2444 ;; Since easymenu under Emacs doesn't allow
2445 ;; lambda forms for menu commands, we should
2446 ;; provide intern'ed function symbols.
2447 (let ((command (intern (format "\
2448 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2449 (fset command
2450 `(lambda ()
2451 (interactive)
2452 (let ((gnus-summary-show-article-charset-alist
2453 '((1 . ,cs))))
2454 (gnus-summary-show-article 1))))
2455 `[,(symbol-name cs) ,command t]))
2456 (sort (coding-system-list) 'string<)))))
2457 ("Washing"
2458 ("Remove Blanks"
2459 ["Leading" gnus-article-strip-leading-blank-lines t]
2460 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2461 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2462 ["All of the above" gnus-article-strip-blank-lines t]
2463 ["All" gnus-article-strip-all-blank-lines t]
2464 ["Leading space" gnus-article-strip-leading-space t]
2465 ["Trailing space" gnus-article-strip-trailing-space t]
2466 ["Leading space in headers"
2467 gnus-article-remove-leading-whitespace t])
2468 ["Overstrike" gnus-article-treat-overstrike t]
2469 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2470 ["Non-ASCII" gnus-article-treat-non-ascii t]
2471 ["Emphasis" gnus-article-emphasize t]
2472 ["Word wrap" gnus-article-fill-cited-article t]
2473 ["Fill long lines" gnus-article-fill-long-lines t]
2474 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2475 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2476 ["Remove CR" gnus-article-remove-cr t]
2477 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2478 ["Base64" gnus-article-de-base64-unreadable t]
2479 ["Rot 13" gnus-summary-caesar-message
2480 :help "\"Caesar rotate\" article by 13"]
2481 ["De-IDNA" gnus-summary-idna-message t]
2482 ["Morse decode" gnus-summary-morse-message t]
2483 ["Unix pipe..." gnus-summary-pipe-message t]
2484 ["Add buttons" gnus-article-add-buttons t]
2485 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2486 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2487 ["Verbose header" gnus-summary-verbose-headers t]
2488 ["Toggle header" gnus-summary-toggle-header t]
2489 ["Unfold headers" gnus-article-treat-unfold-headers t]
2490 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2491 ["Html" gnus-article-wash-html t]
2492 ["Unsplit URLs" gnus-article-unsplit-urls t]
2493 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2494 ["Decode HZ" gnus-article-decode-HZ t]
2495 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2496 ("(Outlook) Deuglify"
2497 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2498 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2499 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2500 ["Full (Outlook) deuglify"
2501 gnus-article-outlook-deuglify-article t])
2503 ("Output"
2504 ["Save in default format..." gnus-summary-save-article
2505 :help "Save article using default method"]
2506 ["Save in file..." gnus-summary-save-article-file
2507 :help "Save article in file"]
2508 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2509 ["Save in MH folder..." gnus-summary-save-article-folder t]
2510 ["Save in VM folder..." gnus-summary-save-article-vm t]
2511 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2512 ["Save body in file..." gnus-summary-save-article-body-file t]
2513 ["Pipe through a filter..." gnus-summary-pipe-output t]
2514 ["Print with Muttprint..." gnus-summary-muttprint t]
2515 ["Print" gnus-summary-print-article
2516 :help "Generate and print a PostScript image"])
2517 ("Copy, move,... (Backend)"
2518 :help "Copying, moving, expiring articles..."
2519 ["Respool article..." gnus-summary-respool-article t]
2520 ["Move article..." gnus-summary-move-article
2521 (gnus-check-backend-function
2522 'request-move-article gnus-newsgroup-name)]
2523 ["Copy article..." gnus-summary-copy-article t]
2524 ["Crosspost article..." gnus-summary-crosspost-article
2525 (gnus-check-backend-function
2526 'request-replace-article gnus-newsgroup-name)]
2527 ["Import file..." gnus-summary-import-article
2528 (gnus-check-backend-function
2529 'request-accept-article gnus-newsgroup-name)]
2530 ["Create article..." gnus-summary-create-article
2531 (gnus-check-backend-function
2532 'request-accept-article gnus-newsgroup-name)]
2533 ["Check if posted" gnus-summary-article-posted-p t]
2534 ["Edit article" gnus-summary-edit-article
2535 (not (gnus-group-read-only-p))]
2536 ["Delete article" gnus-summary-delete-article
2537 (gnus-check-backend-function
2538 'request-expire-articles gnus-newsgroup-name)]
2539 ["Query respool" gnus-summary-respool-query t]
2540 ["Trace respool" gnus-summary-respool-trace t]
2541 ["Delete expirable articles" gnus-summary-expire-articles-now
2542 (gnus-check-backend-function
2543 'request-expire-articles gnus-newsgroup-name)])
2544 ("Extract"
2545 ["Uudecode" gnus-uu-decode-uu :help "Decode uuencoded article(s)"]
2546 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2547 ["Unshar" gnus-uu-decode-unshar t]
2548 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2549 ["Save" gnus-uu-decode-save t]
2550 ["Binhex" gnus-uu-decode-binhex t]
2551 ["PostScript" gnus-uu-decode-postscript t]
2552 ["All MIME parts" gnus-summary-save-parts t])
2553 ("Cache"
2554 ["Enter article" gnus-cache-enter-article t]
2555 ["Remove article" gnus-cache-remove-article t])
2556 ["Translate" gnus-article-babel t]
2557 ["Select article buffer" gnus-summary-select-article-buffer t]
2558 ["Make article buffer sticky" gnus-sticky-article t]
2559 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2560 ["Isearch article..." gnus-summary-isearch-article t]
2561 ["Beginning of the article" gnus-summary-beginning-of-article t]
2562 ["End of the article" gnus-summary-end-of-article t]
2563 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2564 ["Fetch referenced articles" gnus-summary-refer-references t]
2565 ["Fetch current thread" gnus-summary-refer-thread t]
2566 ["Fetch article with id..." gnus-summary-refer-article t]
2567 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2568 ["Redisplay" gnus-summary-show-article t]
2569 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2570 (easy-menu-define
2571 gnus-summary-article-menu gnus-summary-mode-map ""
2572 (cons "Article" innards))
2574 (if (not (keymapp gnus-summary-article-menu))
2575 (easy-menu-define
2576 gnus-article-commands-menu gnus-article-mode-map ""
2577 (cons "Commands" innards))
2578 ;; Don't share the menu.
2579 (setq gnus-article-commands-menu
2580 (copy-keymap gnus-summary-article-menu))
2581 (define-key gnus-article-mode-map [menu-bar commands]
2582 (cons "Commands" gnus-article-commands-menu))))
2584 (easy-menu-define
2585 gnus-summary-thread-menu gnus-summary-mode-map ""
2586 '("Threads"
2587 ["Find all messages in thread" gnus-summary-refer-thread t]
2588 ["Toggle threading" gnus-summary-toggle-threads t]
2589 ["Hide threads" gnus-summary-hide-all-threads t]
2590 ["Show threads" gnus-summary-show-all-threads t]
2591 ["Hide thread" gnus-summary-hide-thread t]
2592 ["Show thread" gnus-summary-show-thread t]
2593 ["Go to next thread" gnus-summary-next-thread t]
2594 ["Go to previous thread" gnus-summary-prev-thread t]
2595 ["Go down thread" gnus-summary-down-thread t]
2596 ["Go up thread" gnus-summary-up-thread t]
2597 ["Top of thread" gnus-summary-top-thread t]
2598 ["Mark thread as read" gnus-summary-kill-thread t]
2599 ["Mark thread as expired" gnus-summary-expire-thread t]
2600 ["Lower thread score" gnus-summary-lower-thread t]
2601 ["Raise thread score" gnus-summary-raise-thread t]
2602 ["Rethread current" gnus-summary-rethread-current t]))
2604 (easy-menu-define
2605 gnus-summary-post-menu gnus-summary-mode-map ""
2606 `("Post"
2607 ["Send a message (mail or news)" gnus-summary-post-news
2608 :help "Compose a new message (mail or news)"]
2609 ["Followup" gnus-summary-followup
2610 :help "Post followup to this article"]
2611 ["Followup and yank" gnus-summary-followup-with-original
2612 :help "Post followup to this article, quoting its contents"]
2613 ["Supersede article" gnus-summary-supersede-article t]
2614 ["Cancel article" gnus-summary-cancel-article
2615 :help "Cancel an article you posted"]
2616 ["Reply" gnus-summary-reply t]
2617 ["Reply and yank" gnus-summary-reply-with-original t]
2618 ["Wide reply" gnus-summary-wide-reply t]
2619 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2620 :help "Mail a reply, quoting this article"]
2621 ["Very wide reply" gnus-summary-very-wide-reply t]
2622 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2623 :help "Mail a very wide reply, quoting this article"]
2624 ["Mail forward" gnus-summary-mail-forward t]
2625 ["Post forward" gnus-summary-post-forward t]
2626 ["Digest and mail" gnus-uu-digest-mail-forward t]
2627 ["Digest and post" gnus-uu-digest-post-forward t]
2628 ["Resend message" gnus-summary-resend-message t]
2629 ["Resend message edit" gnus-summary-resend-message-edit t]
2630 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2631 ["Send a mail" gnus-summary-mail-other-window t]
2632 ["Create a local message" gnus-summary-news-other-window t]
2633 ["Uuencode and post" gnus-uu-post-news
2634 :help "Post a uuencoded article"]
2635 ["Followup via news" gnus-summary-followup-to-mail t]
2636 ["Followup via news and yank"
2637 gnus-summary-followup-to-mail-with-original t]
2638 ["Strip signature on reply"
2639 (lambda ()
2640 (interactive)
2641 (setq message-cite-function
2642 (if (eq message-cite-function
2643 'message-cite-original-without-signature)
2644 'message-cite-original
2645 'message-cite-original-without-signature)))
2646 :visible (memq message-cite-function
2647 '(message-cite-original-without-signature
2648 message-cite-original))
2649 :style toggle
2650 :selected (eq message-cite-function
2651 'message-cite-original-without-signature)
2652 :help "Strip signature from cited article when replying."]))
2654 (cond
2655 ((not (keymapp gnus-summary-post-menu))
2656 (setq gnus-article-post-menu gnus-summary-post-menu))
2657 ((not gnus-article-post-menu)
2658 ;; Don't share post menu.
2659 (setq gnus-article-post-menu
2660 (copy-keymap gnus-summary-post-menu))))
2661 (define-key gnus-article-mode-map [menu-bar post]
2662 (cons "Post" gnus-article-post-menu))
2664 (easy-menu-define
2665 gnus-summary-misc-menu gnus-summary-mode-map ""
2666 `("Gnus"
2667 ("Mark Read"
2668 ["Mark as read" gnus-summary-mark-as-read-forward t]
2669 ["Mark same subject and select"
2670 gnus-summary-kill-same-subject-and-select t]
2671 ["Mark same subject" gnus-summary-kill-same-subject t]
2672 ["Catchup" gnus-summary-catchup
2673 :help "Mark unread articles in this group as read"]
2674 ["Catchup all" gnus-summary-catchup-all t]
2675 ["Catchup to here" gnus-summary-catchup-to-here t]
2676 ["Catchup from here" gnus-summary-catchup-from-here t]
2677 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2678 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2679 ("Mark Various"
2680 ["Tick" gnus-summary-tick-article-forward t]
2681 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2682 ["Remove marks" gnus-summary-clear-mark-forward t]
2683 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2684 ["Set bookmark" gnus-summary-set-bookmark t]
2685 ["Remove bookmark" gnus-summary-remove-bookmark t])
2686 ("Limit to"
2687 ["Marks..." gnus-summary-limit-to-marks t]
2688 ["Subject..." gnus-summary-limit-to-subject t]
2689 ["Author..." gnus-summary-limit-to-author t]
2690 ["Recipient..." gnus-summary-limit-to-recipient t]
2691 ["Address..." gnus-summary-limit-to-address t]
2692 ["Age..." gnus-summary-limit-to-age t]
2693 ["Extra..." gnus-summary-limit-to-extra t]
2694 ["Score..." gnus-summary-limit-to-score t]
2695 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2696 ["Unread" gnus-summary-limit-to-unread t]
2697 ["Unseen" gnus-summary-limit-to-unseen t]
2698 ["Singletons" gnus-summary-limit-to-singletons t]
2699 ["Replied" gnus-summary-limit-to-replied t]
2700 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2701 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2702 ["Pop limit" gnus-summary-pop-limit t]
2703 ["Show dormant" gnus-summary-limit-include-dormant t]
2704 ["Hide childless dormant"
2705 gnus-summary-limit-exclude-childless-dormant t]
2706 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2707 ["Hide marked" gnus-summary-limit-exclude-marks t]
2708 ["Show expunged" gnus-summary-limit-include-expunged t])
2709 ("Process Mark"
2710 ["Set mark" gnus-summary-mark-as-processable t]
2711 ["Remove mark" gnus-summary-unmark-as-processable t]
2712 ["Remove all marks" gnus-summary-unmark-all-processable t]
2713 ["Invert marks" gnus-uu-invert-processable t]
2714 ["Mark above" gnus-uu-mark-over t]
2715 ["Mark series" gnus-uu-mark-series t]
2716 ["Mark region" gnus-uu-mark-region mark-active]
2717 ["Unmark region" gnus-uu-unmark-region mark-active]
2718 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2719 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2720 ["Mark all" gnus-uu-mark-all t]
2721 ["Mark buffer" gnus-uu-mark-buffer t]
2722 ["Mark sparse" gnus-uu-mark-sparse t]
2723 ["Mark thread" gnus-uu-mark-thread t]
2724 ["Unmark thread" gnus-uu-unmark-thread t]
2725 ("Process Mark Sets"
2726 ["Kill" gnus-summary-kill-process-mark t]
2727 ["Yank" gnus-summary-yank-process-mark
2728 gnus-newsgroup-process-stack]
2729 ["Save" gnus-summary-save-process-mark t]
2730 ["Run command on marked..." gnus-summary-universal-argument t]))
2731 ("Registry Marks")
2732 ("Scroll article"
2733 ["Page forward" gnus-summary-next-page
2734 :help "Show next page of article"]
2735 ["Page backward" gnus-summary-prev-page
2736 :help "Show previous page of article"]
2737 ["Line forward" gnus-summary-scroll-up t])
2738 ("Move"
2739 ["Next unread article" gnus-summary-next-unread-article t]
2740 ["Previous unread article" gnus-summary-prev-unread-article t]
2741 ["Next article" gnus-summary-next-article t]
2742 ["Previous article" gnus-summary-prev-article t]
2743 ["Next unread subject" gnus-summary-next-unread-subject t]
2744 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2745 ["Next article same subject" gnus-summary-next-same-subject t]
2746 ["Previous article same subject" gnus-summary-prev-same-subject t]
2747 ["First unread article" gnus-summary-first-unread-article t]
2748 ["Best unread article" gnus-summary-best-unread-article t]
2749 ["Go to subject number..." gnus-summary-goto-subject t]
2750 ["Go to article number..." gnus-summary-goto-article t]
2751 ["Go to the last article" gnus-summary-goto-last-article t]
2752 ["Pop article off history" gnus-summary-pop-article t])
2753 ("Sort"
2754 ["Sort by number" gnus-summary-sort-by-number t]
2755 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2756 ["Sort by author" gnus-summary-sort-by-author t]
2757 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2758 ["Sort by subject" gnus-summary-sort-by-subject t]
2759 ["Sort by date" gnus-summary-sort-by-date t]
2760 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2761 ["Sort by score" gnus-summary-sort-by-score t]
2762 ["Sort by lines" gnus-summary-sort-by-lines t]
2763 ["Sort by characters" gnus-summary-sort-by-chars t]
2764 ["Sort by marks" gnus-summary-sort-by-marks t]
2765 ["Randomize" gnus-summary-sort-by-random t]
2766 ["Original sort" gnus-summary-sort-by-original t])
2767 ("Help"
2768 ["Describe group" gnus-summary-describe-group t]
2769 ["Read manual" gnus-info-find-node t])
2770 ("Modes"
2771 ["Pick and read" gnus-pick-mode t]
2772 ["Binary" gnus-binary-mode t])
2773 ("Regeneration"
2774 ["Regenerate" gnus-summary-prepare t]
2775 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2776 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2777 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2778 ["Toggle threading" gnus-summary-toggle-threads t])
2779 ["See old articles" gnus-summary-insert-old-articles t]
2780 ["See new articles" gnus-summary-insert-new-articles t]
2781 ["Filter articles..." gnus-summary-execute-command t]
2782 ["Run command on articles..." gnus-summary-universal-argument t]
2783 ["Search articles forward..." gnus-summary-search-article-forward t]
2784 ["Search articles backward..." gnus-summary-search-article-backward t]
2785 ["Toggle line truncation" toggle-truncate-lines t]
2786 ["Expand window" gnus-summary-expand-window t]
2787 ["Expire expirable articles" gnus-summary-expire-articles
2788 (gnus-check-backend-function
2789 'request-expire-articles gnus-newsgroup-name)]
2790 ["Edit local kill file" gnus-summary-edit-local-kill t]
2791 ["Edit main kill file" gnus-summary-edit-global-kill t]
2792 ["Edit group parameters" gnus-summary-edit-parameters t]
2793 ["Customize group parameters" gnus-summary-customize-parameters t]
2794 ["Send a bug report" gnus-bug t]
2795 ("Exit"
2796 ["Catchup and exit" gnus-summary-catchup-and-exit
2797 :help "Mark unread articles in this group as read, then exit"]
2798 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2799 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2800 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2801 ["Exit group" gnus-summary-exit
2802 :help "Exit current group, return to group selection mode"]
2803 ["Exit group without updating" gnus-summary-exit-no-update t]
2804 ["Exit and goto next group" gnus-summary-next-group t]
2805 ["Exit and goto prev group" gnus-summary-prev-group t]
2806 ["Reselect group" gnus-summary-reselect-current-group t]
2807 ["Rescan group" gnus-summary-rescan-group t]
2808 ["Update dribble" gnus-summary-save-newsrc t])))
2810 (gnus-run-hooks 'gnus-summary-menu-hook)))
2812 (defvar gnus-summary-tool-bar-map nil)
2814 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2815 ;; affect _new_ message buffers. We might add a function that walks thru all
2816 ;; summary-mode buffers and force the update.
2817 (defun gnus-summary-tool-bar-update (&optional symbol value)
2818 "Update summary mode toolbar.
2819 Setter function for custom variables."
2820 (setq-default gnus-summary-tool-bar-map nil)
2821 (when symbol
2822 ;; When used as ":set" function:
2823 (set-default symbol value))
2824 (when (gnus-buffer-live-p gnus-summary-buffer)
2825 (with-current-buffer gnus-summary-buffer
2826 (gnus-summary-make-tool-bar))))
2828 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2829 'gnus-summary-tool-bar-gnome
2830 'gnus-summary-tool-bar-retro)
2831 "Specifies the Gnus summary tool bar.
2833 It can be either a list or a symbol referring to a list. See
2834 `gmm-tool-bar-from-list' for the format of the list. The
2835 default key map is `gnus-summary-mode-map'.
2837 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2838 `gnus-summary-tool-bar-retro'."
2839 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2840 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2841 (repeat :tag "User defined list" gmm-tool-bar-item)
2842 (symbol))
2843 :version "23.1" ;; No Gnus
2844 :initialize 'custom-initialize-default
2845 :set 'gnus-summary-tool-bar-update
2846 :group 'gnus-summary)
2848 (defcustom gnus-summary-tool-bar-gnome
2849 '((gnus-summary-post-news "mail/compose" nil)
2850 (gnus-summary-insert-new-articles "mail/inbox" nil
2851 :visible (or (not gnus-agent)
2852 gnus-plugged))
2853 (gnus-summary-reply-with-original "mail/reply")
2854 (gnus-summary-reply "mail/reply" nil :visible nil)
2855 (gnus-summary-followup-with-original "mail/reply-all")
2856 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2857 (gnus-summary-mail-forward "mail/forward")
2858 (gnus-summary-save-article "mail/save")
2859 (gnus-summary-search-article-forward "search" nil :visible nil)
2860 (gnus-summary-print-article "print")
2861 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2862 ;; Some new commands that may need more suitable icons:
2863 (gnus-summary-save-newsrc "save" nil :visible nil)
2864 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2865 (gnus-summary-prev-article "left-arrow")
2866 (gnus-summary-next-article "right-arrow")
2867 (gnus-summary-next-page "next-page")
2868 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2870 ;; Maybe some sort-by-... could be added:
2871 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2872 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2873 (gnus-summary-mark-as-expirable
2874 "delete" nil
2875 :visible (gnus-check-backend-function 'request-expire-articles
2876 gnus-newsgroup-name))
2877 (gnus-summary-mark-as-spam
2878 "mail/spam" t
2879 :visible (and (fboundp 'spam-group-ham-contents-p)
2880 (spam-group-ham-contents-p gnus-newsgroup-name))
2881 :help "Mark as spam")
2882 (gnus-summary-mark-as-read-forward
2883 "mail/not-spam" nil
2884 :visible (and (fboundp 'spam-group-spam-contents-p)
2885 (spam-group-spam-contents-p gnus-newsgroup-name)))
2887 (gnus-summary-exit "exit")
2888 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2889 (gnus-info-find-node "help"))
2890 "List of functions for the summary tool bar (GNOME style).
2892 See `gmm-tool-bar-from-list' for the format of the list."
2893 :type '(repeat gmm-tool-bar-item)
2894 :version "23.1" ;; No Gnus
2895 :initialize 'custom-initialize-default
2896 :set 'gnus-summary-tool-bar-update
2897 :group 'gnus-summary)
2899 (defcustom gnus-summary-tool-bar-retro
2900 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2901 (gnus-summary-next-unread-article "gnus/next-ur")
2902 (gnus-summary-post-news "gnus/post")
2903 (gnus-summary-followup-with-original "gnus/fuwo")
2904 (gnus-summary-followup "gnus/followup")
2905 (gnus-summary-reply-with-original "gnus/reply-wo")
2906 (gnus-summary-reply "gnus/reply")
2907 (gnus-summary-caesar-message "gnus/rot13")
2908 (gnus-uu-decode-uu "gnus/uu-decode")
2909 (gnus-summary-save-article-file "gnus/save-aif")
2910 (gnus-summary-save-article "gnus/save-art")
2911 (gnus-uu-post-news "gnus/uu-post")
2912 (gnus-summary-catchup "gnus/catchup")
2913 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2914 (gnus-summary-exit "gnus/exit-summ")
2915 ;; Some new command that may need more suitable icons:
2916 (gnus-summary-print-article "gnus/print" nil :visible nil)
2917 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2918 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2919 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2920 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2921 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2922 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2924 (gnus-info-find-node "gnus/help" nil :visible nil))
2925 "List of functions for the summary tool bar (retro look).
2927 See `gmm-tool-bar-from-list' for the format of the list."
2928 :type '(repeat gmm-tool-bar-item)
2929 :version "23.1" ;; No Gnus
2930 :initialize 'custom-initialize-default
2931 :set 'gnus-summary-tool-bar-update
2932 :group 'gnus-summary)
2934 (defcustom gnus-summary-tool-bar-zap-list t
2935 "List of icon items from the global tool bar.
2936 These items are not displayed in the Gnus summary mode tool bar.
2938 See `gmm-tool-bar-from-list' for the format of the list."
2939 :type 'gmm-tool-bar-zap-list
2940 :version "23.1" ;; No Gnus
2941 :initialize 'custom-initialize-default
2942 :set 'gnus-summary-tool-bar-update
2943 :group 'gnus-summary)
2945 (defvar image-load-path)
2946 (defvar tool-bar-map)
2948 (defun gnus-summary-make-tool-bar (&optional force)
2949 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2950 When FORCE, rebuild the tool bar."
2951 (when (and (boundp 'tool-bar-mode)
2952 tool-bar-mode
2953 (or (not gnus-summary-tool-bar-map) force))
2954 (let* ((load-path
2955 (image-load-path-for-library "gnus" "mail/save.xpm" nil t))
2956 (image-load-path (cons (car load-path) image-load-path))
2957 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2958 gnus-summary-tool-bar-zap-list
2959 'gnus-summary-mode-map)))
2960 (when map
2961 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2962 ;; uses its value.
2963 (setq gnus-summary-tool-bar-map map))))
2964 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2966 (defun gnus-make-score-map (type)
2967 "Make a summary score map of type TYPE."
2968 (if t
2970 (let ((headers '(("author" "from" string)
2971 ("subject" "subject" string)
2972 ("article body" "body" string)
2973 ("article head" "head" string)
2974 ("xref" "xref" string)
2975 ("extra header" "extra" string)
2976 ("lines" "lines" number)
2977 ("followups to author" "followup" string)))
2978 (types '((number ("less than" <)
2979 ("greater than" >)
2980 ("equal" =))
2981 (string ("substring" s)
2982 ("exact string" e)
2983 ("fuzzy string" f)
2984 ("regexp" r))))
2985 (perms '(("temporary" (current-time-string))
2986 ("permanent" nil)
2987 ("immediate" now)))
2988 header)
2989 (list
2990 (apply
2991 'nconc
2992 (list
2993 (if (eq type 'lower)
2994 "Lower score"
2995 "Increase score"))
2996 (let (outh)
2997 (while headers
2998 (setq header (car headers))
2999 (setq outh
3000 (cons
3001 (apply
3002 'nconc
3003 (list (car header))
3004 (let ((ts (cdr (assoc (nth 2 header) types)))
3005 outt)
3006 (while ts
3007 (setq outt
3008 (cons
3009 (apply
3010 'nconc
3011 (list (caar ts))
3012 (let ((ps perms)
3013 outp)
3014 (while ps
3015 (setq outp
3016 (cons
3017 (vector
3018 (caar ps)
3019 (list
3020 'gnus-summary-score-entry
3021 (nth 1 header)
3022 (if (or (string= (nth 1 header)
3023 "head")
3024 (string= (nth 1 header)
3025 "body"))
3027 (list 'gnus-summary-header
3028 (nth 1 header)))
3029 (list 'quote (nth 1 (car ts)))
3030 (list 'gnus-score-delta-default
3031 nil)
3032 (nth 1 (car ps))
3035 outp))
3036 (setq ps (cdr ps)))
3037 (list (nreverse outp))))
3038 outt))
3039 (setq ts (cdr ts)))
3040 (list (nreverse outt))))
3041 outh))
3042 (setq headers (cdr headers)))
3043 (list (nreverse outh))))))))
3046 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3047 (defvar bookmark-make-record-function)
3049 (defvar bidi-paragraph-direction)
3051 (defun gnus-summary-mode (&optional group)
3052 "Major mode for reading articles.
3054 All normal editing commands are switched off.
3055 \\<gnus-summary-mode-map>
3056 Each line in this buffer represents one article. To read an
3057 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3058 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3059 respectively.
3061 You can also post articles and send mail from this buffer. To
3062 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3063 of an article, type `\\[gnus-summary-reply]'.
3065 There are approx. one gazillion commands you can execute in this
3066 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3068 The following commands are available:
3070 \\{gnus-summary-mode-map}"
3071 ;; FIXME: Use define-derived-mode.
3072 (interactive)
3073 (kill-all-local-variables)
3074 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3075 (gnus-summary-make-local-variables))
3076 (gnus-summary-make-local-variables)
3077 (setq gnus-newsgroup-name group)
3078 (when (gnus-visual-p 'summary-menu 'menu)
3079 (gnus-summary-make-menu-bar)
3080 (gnus-summary-make-tool-bar))
3081 (gnus-make-thread-indent-array)
3082 (gnus-simplify-mode-line)
3083 (setq major-mode 'gnus-summary-mode)
3084 (setq mode-name "Summary")
3085 (use-local-map gnus-summary-mode-map)
3086 (buffer-disable-undo)
3087 (setq buffer-read-only t
3088 show-trailing-whitespace nil
3089 truncate-lines t
3090 bidi-paragraph-direction 'left-to-right)
3091 (add-to-invisibility-spec '(gnus-sum . t))
3092 (gnus-summary-set-display-table)
3093 (gnus-set-default-directory)
3094 (make-local-variable 'gnus-summary-line-format)
3095 (make-local-variable 'gnus-summary-line-format-spec)
3096 (make-local-variable 'gnus-summary-dummy-line-format)
3097 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3098 (make-local-variable 'gnus-summary-mark-positions)
3099 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3100 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3101 (turn-on-gnus-mailing-list-mode)
3102 (mm-enable-multibyte)
3103 (set (make-local-variable 'bookmark-make-record-function)
3104 'gnus-summary-bookmark-make-record)
3105 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3106 (gnus-update-summary-mark-positions))
3108 (defun gnus-summary-make-local-variables ()
3109 "Make all the local summary buffer variables."
3110 (let (global)
3111 (dolist (local gnus-summary-local-variables)
3112 (if (consp local)
3113 (progn
3114 (if (eq (cdr local) 'global)
3115 ;; Copy the global value of the variable.
3116 (setq global (symbol-value (car local)))
3117 ;; Use the value from the list.
3118 (setq global (eval (cdr local))))
3119 (set (make-local-variable (car local)) global))
3120 ;; Simple nil-valued local variable.
3121 (set (make-local-variable local) nil)))))
3123 ;; Summary data functions.
3125 (defmacro gnus-data-number (data)
3126 `(car ,data))
3128 (defmacro gnus-data-set-number (data number)
3129 `(setcar ,data ,number))
3131 (defmacro gnus-data-mark (data)
3132 `(nth 1 ,data))
3134 (defmacro gnus-data-set-mark (data mark)
3135 `(setcar (nthcdr 1 ,data) ,mark))
3137 (defmacro gnus-data-pos (data)
3138 `(nth 2 ,data))
3140 (defmacro gnus-data-set-pos (data pos)
3141 `(setcar (nthcdr 2 ,data) ,pos))
3143 (defmacro gnus-data-header (data)
3144 `(nth 3 ,data))
3146 (defmacro gnus-data-set-header (data header)
3147 `(setf (nth 3 ,data) ,header))
3149 (defmacro gnus-data-level (data)
3150 `(nth 4 ,data))
3152 (defmacro gnus-data-unread-p (data)
3153 `(= (nth 1 ,data) gnus-unread-mark))
3155 (defmacro gnus-data-read-p (data)
3156 `(/= (nth 1 ,data) gnus-unread-mark))
3158 (defmacro gnus-data-pseudo-p (data)
3159 `(consp (nth 3 ,data)))
3161 (defmacro gnus-data-find (number)
3162 `(assq ,number gnus-newsgroup-data))
3164 (defmacro gnus-data-find-list (number &optional data)
3165 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3166 (memq (assq ,number bdata)
3167 bdata)))
3169 (defmacro gnus-data-make (number mark pos header level)
3170 `(list ,number ,mark ,pos ,header ,level))
3172 (defun gnus-data-enter (after-article number mark pos header level offset)
3173 (let ((data (gnus-data-find-list after-article)))
3174 (unless data
3175 (error "No such article: %d" after-article))
3176 (setcdr data (cons (gnus-data-make number mark pos header level)
3177 (cdr data)))
3178 (setq gnus-newsgroup-data-reverse nil)
3179 (gnus-data-update-list (cddr data) offset)))
3181 (defun gnus-data-enter-list (after-article list &optional offset)
3182 (when list
3183 (let ((data (and after-article (gnus-data-find-list after-article)))
3184 (ilist list))
3185 (if (not (or data
3186 after-article))
3187 (let ((odata gnus-newsgroup-data))
3188 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3189 (when offset
3190 (gnus-data-update-list odata offset)))
3191 ;; Find the last element in the list to be spliced into the main
3192 ;; list.
3193 (setq list (last list))
3194 (if (not data)
3195 (progn
3196 (setcdr list gnus-newsgroup-data)
3197 (setq gnus-newsgroup-data ilist)
3198 (when offset
3199 (gnus-data-update-list (cdr list) offset)))
3200 (setcdr list (cdr data))
3201 (setcdr data ilist)
3202 (when offset
3203 (gnus-data-update-list (cdr list) offset))))
3204 (setq gnus-newsgroup-data-reverse nil))))
3206 (defun gnus-data-remove (article &optional offset)
3207 (let ((data gnus-newsgroup-data))
3208 (if (= (gnus-data-number (car data)) article)
3209 (progn
3210 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3211 gnus-newsgroup-data-reverse nil)
3212 (when offset
3213 (gnus-data-update-list gnus-newsgroup-data offset)))
3214 (while (cdr data)
3215 (when (= (gnus-data-number (cadr data)) article)
3216 (setcdr data (cddr data))
3217 (when offset
3218 (gnus-data-update-list (cdr data) offset))
3219 (setq data nil
3220 gnus-newsgroup-data-reverse nil))
3221 (setq data (cdr data))))))
3223 (defmacro gnus-data-list (backward)
3224 `(if ,backward
3225 (or gnus-newsgroup-data-reverse
3226 (setq gnus-newsgroup-data-reverse
3227 (reverse gnus-newsgroup-data)))
3228 gnus-newsgroup-data))
3230 (defun gnus-data-update-list (data offset)
3231 "Add OFFSET to the POS of all data entries in DATA."
3232 (setq gnus-newsgroup-data-reverse nil)
3233 (while data
3234 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3235 (setq data (cdr data))))
3237 (defun gnus-summary-article-pseudo-p (article)
3238 "Say whether this article is a pseudo article or not."
3239 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3241 (defmacro gnus-summary-article-sparse-p (article)
3242 "Say whether this article is a sparse article or not."
3243 `(memq ,article gnus-newsgroup-sparse))
3245 (defmacro gnus-summary-article-ancient-p (article)
3246 "Say whether this article is a sparse article or not."
3247 `(memq ,article gnus-newsgroup-ancient))
3249 (defun gnus-article-children (number)
3250 "Return a list of all children to NUMBER."
3251 (let* ((data (gnus-data-find-list number))
3252 (level (gnus-data-level (car data)))
3253 children)
3254 (setq data (cdr data))
3255 (while (and data
3256 (= (gnus-data-level (car data)) (1+ level)))
3257 (push (gnus-data-number (car data)) children)
3258 (setq data (cdr data)))
3259 children))
3261 (defmacro gnus-summary-skip-intangible ()
3262 "If the current article is intangible, then jump to a different article."
3263 '(let ((to (get-text-property (point) 'gnus-intangible)))
3264 (and to (gnus-summary-goto-subject to))))
3266 (defmacro gnus-summary-article-intangible-p ()
3267 "Say whether this article is intangible or not."
3268 '(get-text-property (point) 'gnus-intangible))
3270 ;; Some summary mode macros.
3272 (defmacro gnus-summary-article-number ()
3273 "The article number of the article on the current line.
3274 If there isn't an article number here, then we return the current
3275 article number."
3276 '(progn
3277 (gnus-summary-skip-intangible)
3278 (or (get-text-property (point) 'gnus-number)
3279 (gnus-summary-last-subject))))
3281 (defmacro gnus-summary-article-header (&optional number)
3282 "Return the header of article NUMBER."
3283 `(gnus-data-header (gnus-data-find
3284 ,(or number '(gnus-summary-article-number)))))
3286 (defmacro gnus-summary-thread-level (&optional number)
3287 "Return the level of thread that starts with article NUMBER."
3288 `(if (and (eq gnus-summary-make-false-root 'dummy)
3289 (get-text-property (point) 'gnus-intangible))
3291 (gnus-data-level (gnus-data-find
3292 ,(or number '(gnus-summary-article-number))))))
3294 (defmacro gnus-summary-article-mark (&optional number)
3295 "Return the mark of article NUMBER."
3296 `(gnus-data-mark (gnus-data-find
3297 ,(or number '(gnus-summary-article-number)))))
3299 (defmacro gnus-summary-article-pos (&optional number)
3300 "Return the position of the line of article NUMBER."
3301 `(gnus-data-pos (gnus-data-find
3302 ,(or number '(gnus-summary-article-number)))))
3304 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3305 (defmacro gnus-summary-article-subject (&optional number)
3306 "Return current subject string or nil if nothing."
3307 `(let ((headers
3308 ,(if number
3309 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3310 '(gnus-data-header (assq (gnus-summary-article-number)
3311 gnus-newsgroup-data)))))
3312 (and headers
3313 (vectorp headers)
3314 (mail-header-subject headers))))
3316 (defmacro gnus-summary-article-score (&optional number)
3317 "Return current article score."
3318 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3319 gnus-newsgroup-scored))
3320 gnus-summary-default-score 0))
3322 (defun gnus-summary-article-children (&optional number)
3323 "Return a list of article numbers that are children of article NUMBER."
3324 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3325 (level (gnus-data-level (car data)))
3326 l children)
3327 (while (and (setq data (cdr data))
3328 (> (setq l (gnus-data-level (car data))) level))
3329 (and (= (1+ level) l)
3330 (push (gnus-data-number (car data))
3331 children)))
3332 (nreverse children)))
3334 (defun gnus-summary-article-parent (&optional number)
3335 "Return the article number of the parent of article NUMBER."
3336 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3337 (gnus-data-list t)))
3338 (level (gnus-data-level (car data))))
3339 (if (zerop level)
3340 () ; This is a root.
3341 ;; We search until we find an article with a level less than
3342 ;; this one. That function has to be the parent.
3343 (while (and (setq data (cdr data))
3344 (not (< (gnus-data-level (car data)) level))))
3345 (and data (gnus-data-number (car data))))))
3347 (defun gnus-unread-mark-p (mark)
3348 "Say whether MARK is the unread mark."
3349 (= mark gnus-unread-mark))
3351 (defun gnus-read-mark-p (mark)
3352 "Say whether MARK is one of the marks that mark as read.
3353 This is all marks except unread, ticked, dormant, and expirable."
3354 (not (or (= mark gnus-unread-mark)
3355 (= mark gnus-ticked-mark)
3356 (= mark gnus-spam-mark)
3357 (= mark gnus-dormant-mark)
3358 (= mark gnus-expirable-mark))))
3360 (defmacro gnus-article-mark (number)
3361 "Return the MARK of article NUMBER.
3362 This macro should only be used when computing the mark the \"first\"
3363 time; i.e., when generating the summary lines. After that,
3364 `gnus-summary-article-mark' should be used to examine the
3365 marks of articles."
3366 `(cond
3367 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3368 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3369 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3370 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3371 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3372 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3373 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3374 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3375 gnus-ancient-mark))))
3377 ;; Saving hidden threads.
3379 (defmacro gnus-save-hidden-threads (&rest forms)
3380 "Save hidden threads, eval FORMS, and restore the hidden threads."
3381 (let ((config (make-symbol "config")))
3382 `(let ((,config (gnus-hidden-threads-configuration)))
3383 (unwind-protect
3384 (save-excursion
3385 ,@forms)
3386 (gnus-restore-hidden-threads-configuration ,config)))))
3387 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3388 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3390 (defun gnus-data-compute-positions ()
3391 "Compute the positions of all articles."
3392 (setq gnus-newsgroup-data-reverse nil)
3393 (let ((data gnus-newsgroup-data))
3394 (save-excursion
3395 (gnus-save-hidden-threads
3396 (gnus-summary-show-all-threads)
3397 (goto-char (point-min))
3398 (while data
3399 (while (get-text-property (point) 'gnus-intangible)
3400 (forward-line 1))
3401 (gnus-data-set-pos (car data) (+ (point) 3))
3402 (setq data (cdr data))
3403 (forward-line 1))))))
3405 (defun gnus-hidden-threads-configuration ()
3406 "Return the current hidden threads configuration."
3407 (save-excursion
3408 (let (config)
3409 (goto-char (point-min))
3410 (while (not (eobp))
3411 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3412 (push (save-excursion (forward-line 0) (point)) config))
3413 (forward-line 1))
3414 config)))
3416 (defun gnus-restore-hidden-threads-configuration (config)
3417 "Restore hidden threads configuration from CONFIG."
3418 (save-excursion
3419 (let (point (inhibit-read-only t))
3420 (while (setq point (pop config))
3421 (goto-char point)
3422 (gnus-summary-hide-thread)))))
3424 ;; Various summary mode internalish functions.
3426 (defun gnus-mouse-pick-article (e)
3427 (interactive "e")
3428 (mouse-set-point e)
3429 (gnus-summary-next-page nil t))
3431 (defun gnus-summary-set-display-table ()
3432 "Change the display table.
3433 Odd characters have a tendency to mess
3434 up nicely formatted displays - we make all possible glyphs
3435 display only a single character."
3437 ;; We start from the standard display table, if any.
3438 (let ((table (or (copy-sequence standard-display-table)
3439 (make-display-table)))
3440 (i 32))
3441 ;; Nix out all the control chars...
3442 (while (>= (setq i (1- i)) 0)
3443 (aset table i [??]))
3444 ;; ... but not newline and cr, of course. (cr is necessary for the
3445 ;; selective display).
3446 (aset table ?\n nil)
3447 (aset table ?\r nil)
3448 ;; We keep TAB as well.
3449 (aset table ?\t nil)
3450 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3451 ;; Emacs 23 (unicode), that are not set already.
3452 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3454 256)))
3455 (while (>= (setq i (1- i)) 127)
3456 ;; Only modify if the entry is nil.
3457 (unless (aref table i)
3458 (aset table i [??]))))
3459 (setq buffer-display-table table)))
3461 (defun gnus-summary-set-article-display-arrow (pos)
3462 "Update the overlay arrow to point to line at position POS."
3463 (when gnus-summary-display-arrow
3464 (make-local-variable 'overlay-arrow-position)
3465 (make-local-variable 'overlay-arrow-string)
3466 (save-excursion
3467 (goto-char pos)
3468 (beginning-of-line)
3469 (unless overlay-arrow-position
3470 (setq overlay-arrow-position (make-marker)))
3471 (setq overlay-arrow-string "=>"
3472 overlay-arrow-position (set-marker overlay-arrow-position
3473 (point)
3474 (current-buffer))))))
3476 (defun gnus-summary-setup-buffer (group)
3477 "Initialize summary buffer.
3478 If the setup was successful, non-nil is returned."
3479 (let ((buffer (gnus-summary-buffer-name group))
3480 (dead-name (concat "*Dead Summary "
3481 (gnus-group-decoded-name group) "*")))
3482 ;; If a dead summary buffer exists, we kill it.
3483 (when (gnus-buffer-live-p dead-name)
3484 (gnus-kill-buffer dead-name))
3485 (if (get-buffer buffer)
3486 (progn
3487 (set-buffer buffer)
3488 (setq gnus-summary-buffer (current-buffer))
3489 (not gnus-newsgroup-prepared))
3490 (set-buffer (gnus-get-buffer-create buffer))
3491 (setq gnus-summary-buffer (current-buffer))
3492 (gnus-summary-mode group)
3493 (when (gnus-group-quit-config group)
3494 (set (make-local-variable 'gnus-single-article-buffer) nil))
3495 (make-local-variable 'gnus-article-buffer)
3496 (make-local-variable 'gnus-article-current)
3497 (make-local-variable 'gnus-original-article-buffer)
3498 (setq gnus-newsgroup-name group)
3499 ;; Set any local variables in the group parameters.
3500 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3501 t)))
3503 (defun gnus-set-global-variables ()
3504 "Set the global equivalents of the buffer-local variables.
3505 They are set to the latest values they had. These reflect the summary
3506 buffer that was in action when the last article was fetched."
3507 (when (derived-mode-p 'gnus-summary-mode)
3508 (setq gnus-summary-buffer (current-buffer))
3509 (let ((name gnus-newsgroup-name)
3510 (marked gnus-newsgroup-marked)
3511 (spam gnus-newsgroup-spam-marked)
3512 (unread gnus-newsgroup-unreads)
3513 (headers gnus-current-headers)
3514 (data gnus-newsgroup-data)
3515 (summary gnus-summary-buffer)
3516 (article-buffer gnus-article-buffer)
3517 (original gnus-original-article-buffer)
3518 (gac gnus-article-current)
3519 (reffed gnus-reffed-article-number)
3520 (score-file gnus-current-score-file)
3521 (default-charset gnus-newsgroup-charset)
3522 vlist)
3523 (let ((locals gnus-newsgroup-variables))
3524 (while locals
3525 (if (consp (car locals))
3526 (push (eval (caar locals)) vlist)
3527 (push (eval (car locals)) vlist))
3528 (setq locals (cdr locals)))
3529 (setq vlist (nreverse vlist)))
3530 (with-temp-buffer
3531 (setq gnus-newsgroup-name name
3532 gnus-newsgroup-marked marked
3533 gnus-newsgroup-spam-marked spam
3534 gnus-newsgroup-unreads unread
3535 gnus-current-headers headers
3536 gnus-newsgroup-data data
3537 gnus-article-current gac
3538 gnus-summary-buffer summary
3539 gnus-article-buffer article-buffer
3540 gnus-original-article-buffer original
3541 gnus-reffed-article-number reffed
3542 gnus-current-score-file score-file
3543 gnus-newsgroup-charset default-charset)
3544 (let ((locals gnus-newsgroup-variables))
3545 (while locals
3546 (if (consp (car locals))
3547 (set (caar locals) (pop vlist))
3548 (set (car locals) (pop vlist)))
3549 (setq locals (cdr locals))))))))
3551 (defun gnus-summary-article-unread-p (article)
3552 "Say whether ARTICLE is unread or not."
3553 (memq article gnus-newsgroup-unreads))
3555 (defun gnus-summary-first-article-p (&optional article)
3556 "Return whether ARTICLE is the first article in the buffer."
3557 (if (not (setq article (or article (gnus-summary-article-number))))
3559 (eq article (caar gnus-newsgroup-data))))
3561 (defun gnus-summary-last-article-p (&optional article)
3562 "Return whether ARTICLE is the last article in the buffer."
3563 (if (not (setq article (or article (gnus-summary-article-number))))
3564 ;; All non-existent numbers are the last article. :-)
3566 (not (cdr (gnus-data-find-list article)))))
3568 (defun gnus-make-thread-indent-array (&optional n)
3569 (when (or n
3570 (progn (setq n 200) nil)
3571 (null gnus-thread-indent-array)
3572 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3573 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3574 gnus-thread-indent-array-level gnus-thread-indent-level)
3575 (while (>= n 0)
3576 (aset gnus-thread-indent-array n
3577 (make-string (* n gnus-thread-indent-level) ? ))
3578 (setq n (1- n)))))
3580 (defun gnus-update-summary-mark-positions ()
3581 "Compute where the summary marks are to go."
3582 (save-excursion
3583 (when (gnus-buffer-exists-p gnus-summary-buffer)
3584 (set-buffer gnus-summary-buffer))
3585 (let ((spec gnus-summary-line-format-spec)
3586 pos)
3587 (save-excursion
3588 (gnus-set-work-buffer)
3589 (let ((gnus-tmp-unread ?Z)
3590 (gnus-replied-mark ?Z)
3591 (gnus-score-below-mark ?Z)
3592 (gnus-score-over-mark ?Z)
3593 (gnus-undownloaded-mark ?Z)
3594 (gnus-summary-line-format-spec spec)
3595 (gnus-newsgroup-downloadable '(0))
3596 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3597 case-fold-search ignores)
3598 ;; Here, all marks are bound to Z.
3599 (gnus-summary-insert-line header
3600 0 nil t gnus-tmp-unread t nil "" nil 1)
3601 (goto-char (point-min))
3602 ;; Memorize the positions of the same characters as dummy marks.
3603 (while (re-search-forward "[A-D]" nil t)
3604 (push (point) ignores))
3605 (erase-buffer)
3606 ;; We use A-D as dummy marks in order to know column positions
3607 ;; where marks should be inserted.
3608 (setq gnus-tmp-unread ?A
3609 gnus-replied-mark ?B
3610 gnus-score-below-mark ?C
3611 gnus-score-over-mark ?C
3612 gnus-undownloaded-mark ?D)
3613 (gnus-summary-insert-line header
3614 0 nil t gnus-tmp-unread t nil "" nil 1)
3615 ;; Ignore characters which aren't dummy marks.
3616 (dolist (p ignores)
3617 (delete-region (goto-char (1- p)) p)
3618 (insert ?Z))
3619 (goto-char (point-min))
3620 (setq pos (list (cons 'unread
3621 (and (search-forward "A" nil t)
3622 (- (point) (point-min) 1)))))
3623 (goto-char (point-min))
3624 (push (cons 'replied (and (search-forward "B" nil t)
3625 (- (point) (point-min) 1)))
3626 pos)
3627 (goto-char (point-min))
3628 (push (cons 'score (and (search-forward "C" nil t)
3629 (- (point) (point-min) 1)))
3630 pos)
3631 (goto-char (point-min))
3632 (push (cons 'download (and (search-forward "D" nil t)
3633 (- (point) (point-min) 1)))
3634 pos)))
3635 (setq gnus-summary-mark-positions pos))))
3637 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3638 "Insert a dummy root in the summary buffer."
3639 (beginning-of-line)
3640 (add-text-properties
3641 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3642 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3644 (defun gnus-summary-extract-address-component (from)
3645 (or (car (funcall gnus-extract-address-components from))
3646 from))
3648 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3649 (let ((mail-parse-charset gnus-newsgroup-charset)
3650 ;; Is it really necessary to do this next part for each summary line?
3651 ;; Luckily, doesn't seem to slow things down much.
3652 (mail-parse-ignored-charsets
3653 (with-current-buffer gnus-summary-buffer
3654 gnus-newsgroup-ignored-charsets)))
3656 (and gnus-ignored-from-addresses
3657 (cond ((functionp gnus-ignored-from-addresses)
3658 (funcall gnus-ignored-from-addresses
3659 (mail-strip-quoted-names gnus-tmp-from)))
3660 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3661 (let ((extra-headers (mail-header-extra header))
3663 newsgroups)
3664 (cond
3665 ((setq to (cdr (assq 'To extra-headers)))
3666 (concat gnus-summary-to-prefix
3667 (inline
3668 (gnus-summary-extract-address-component
3669 (funcall gnus-decode-encoded-address-function to)))))
3670 ((setq newsgroups
3672 (cdr (assq 'Newsgroups extra-headers))
3673 (and
3674 (memq 'Newsgroups gnus-extra-headers)
3675 (eq (car (gnus-find-method-for-group
3676 gnus-newsgroup-name)) 'nntp)
3677 (gnus-group-real-name gnus-newsgroup-name))))
3678 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3679 (bidi-string-mark-left-to-right
3680 (inline
3681 (gnus-summary-extract-address-component gnus-tmp-from))))))
3683 (defun gnus-summary-insert-line (gnus-tmp-header
3684 gnus-tmp-level gnus-tmp-current
3685 undownloaded gnus-tmp-unread gnus-tmp-replied
3686 gnus-tmp-expirable gnus-tmp-subject-or-nil
3687 &optional gnus-tmp-dummy gnus-tmp-score
3688 gnus-tmp-process)
3689 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3690 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3691 gnus-tmp-level)))
3692 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3693 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3694 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3695 (gnus-tmp-score-char
3696 (if (or (null gnus-summary-default-score)
3697 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3698 gnus-summary-zcore-fuzz))
3699 ? ;Whitespace
3700 (if (< gnus-tmp-score gnus-summary-default-score)
3701 gnus-score-below-mark gnus-score-over-mark)))
3702 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3703 (gnus-tmp-replied
3704 (cond (gnus-tmp-process gnus-process-mark)
3705 ((memq gnus-tmp-current gnus-newsgroup-cached)
3706 gnus-cached-mark)
3707 (gnus-tmp-replied gnus-replied-mark)
3708 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3709 gnus-forwarded-mark)
3710 ((memq gnus-tmp-current gnus-newsgroup-saved)
3711 gnus-saved-mark)
3712 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3713 gnus-unseen-mark)
3714 (t gnus-no-mark)))
3715 (gnus-tmp-downloaded
3716 (cond (undownloaded
3717 gnus-undownloaded-mark)
3718 (gnus-newsgroup-agentized
3719 gnus-downloaded-mark)
3721 gnus-no-mark)))
3722 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3723 (gnus-tmp-name
3724 (cond
3725 ((string-match "<[^>]+> *$" gnus-tmp-from)
3726 (let ((beg (match-beginning 0)))
3727 (or (and (string-match "^\".+\"" gnus-tmp-from)
3728 (substring gnus-tmp-from 1 (1- (match-end 0))))
3729 (substring gnus-tmp-from 0 beg))))
3730 ((string-match "(.+)" gnus-tmp-from)
3731 (substring gnus-tmp-from
3732 (1+ (match-beginning 0)) (1- (match-end 0))))
3733 (t gnus-tmp-from)))
3734 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3735 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3736 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3737 (inhibit-read-only t))
3738 (when (string= gnus-tmp-name "")
3739 (setq gnus-tmp-name gnus-tmp-from))
3740 (unless (numberp gnus-tmp-lines)
3741 (setq gnus-tmp-lines -1))
3742 (if (= gnus-tmp-lines -1)
3743 (setq gnus-tmp-lines "?")
3744 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3745 (condition-case ()
3746 (put-text-property
3747 (point)
3748 (progn (eval gnus-summary-line-format-spec) (point))
3749 'gnus-number gnus-tmp-number)
3750 (error (gnus-message 5 "Error updating the summary line")))
3751 (when (gnus-visual-p 'summary-highlight 'highlight)
3752 (forward-line -1)
3753 (gnus-summary-highlight-line)
3754 (gnus-run-hooks 'gnus-summary-update-hook)
3755 (forward-line 1))))
3757 (defun gnus-summary-update-line (&optional dont-update)
3758 "Update summary line after change."
3759 (when (and gnus-summary-default-score
3760 (not gnus-summary-inhibit-highlight))
3761 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3762 (article (gnus-summary-article-number))
3763 (score (gnus-summary-article-score article)))
3764 (unless dont-update
3765 (if (and gnus-summary-mark-below
3766 (< (gnus-summary-article-score)
3767 gnus-summary-mark-below))
3768 ;; This article has a low score, so we mark it as read.
3769 (when (memq article gnus-newsgroup-unreads)
3770 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3771 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3772 ;; This article was previously marked as read on account
3773 ;; of a low score, but now it has risen, so we mark it as
3774 ;; unread.
3775 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3776 (gnus-summary-update-mark
3777 (if (or (null gnus-summary-default-score)
3778 (<= (abs (- score gnus-summary-default-score))
3779 gnus-summary-zcore-fuzz))
3780 ? ;Whitespace
3781 (if (< score gnus-summary-default-score)
3782 gnus-score-below-mark gnus-score-over-mark))
3783 'score))
3784 ;; Do visual highlighting.
3785 (when (gnus-visual-p 'summary-highlight 'highlight)
3786 (gnus-summary-highlight-line)
3787 (gnus-run-hooks 'gnus-summary-update-hook)))))
3789 (defvar gnus-tmp-new-adopts nil)
3791 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3792 "Return the number of articles in THREAD.
3793 This may be 0 in some cases -- if none of the articles in
3794 the thread are to be displayed."
3795 (let* ((number
3796 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3797 (cond
3798 ((not (listp thread))
3800 ((and (consp thread) (cdr thread))
3801 (apply
3802 '+ 1 (mapcar
3803 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3804 ((null thread)
3806 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3808 (t 0))))
3809 (when (and level (zerop level) gnus-tmp-new-adopts)
3810 (incf number
3811 (apply '+ (mapcar
3812 'gnus-summary-number-of-articles-in-thread
3813 gnus-tmp-new-adopts))))
3814 (if char
3815 (if (> number 1) gnus-not-empty-thread-mark
3816 gnus-empty-thread-mark)
3817 number)))
3819 (defsubst gnus-summary-line-message-size (head)
3820 "Return pretty-printed version of message size.
3821 This function is intended to be used in
3822 `gnus-summary-line-format-alist'."
3823 (let ((c (or (mail-header-chars head) -1)))
3824 (cond ((< c 0) "n/a") ; chars not available
3825 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3826 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3827 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3828 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3830 (defcustom gnus-user-date-format-alist
3831 '(((gnus-seconds-today) . "Today, %H:%M")
3832 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3833 (604800 . "%A %H:%M") ; That's one week
3834 ((gnus-seconds-month) . "%A %d")
3835 ((gnus-seconds-year) . "%B %d")
3836 (t . "%b %d %Y")) ; This one is used when no other
3837 ; does match
3838 "Specifies date format depending on age of article.
3839 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3840 seconds) or a Lisp expression evaluating to a number. When the age of
3841 the article is less than this number, then use `format-time-string'
3842 with the corresponding FORMAT for displaying the date of the article.
3843 If AGE is not a number or a Lisp expression evaluating to a
3844 non-number, then the corresponding FORMAT is used as a default value.
3846 Note that the list is processed from the beginning, so it should be
3847 sorted by ascending AGE. Also note that items following the first
3848 non-number AGE will be ignored.
3850 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3851 and `gnus-seconds-year' in the AGE spec. They return the number of
3852 seconds passed since the start of today, of this month, of this year,
3853 respectively."
3854 :version "24.1"
3855 :group 'gnus-summary-format
3856 :type '(alist :key-type sexp :value-type string))
3858 (defun gnus-user-date (messy-date)
3859 "Format the messy-date according to `gnus-user-date-format-alist'.
3860 Returns \" ? \" if there's bad input or if another error occurs.
3861 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3862 (condition-case ()
3863 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3864 (now (float-time))
3865 ;;If we don't find something suitable we'll use this one
3866 (my-format "%b %d '%y"))
3867 (let* ((difference (- now messy-date))
3868 (templist gnus-user-date-format-alist)
3869 (top (eval (caar templist))))
3870 (while (if (numberp top) (< top difference) (not top))
3871 (progn
3872 (setq templist (cdr templist))
3873 (setq top (eval (caar templist)))))
3874 (if (stringp (cdr (car templist)))
3875 (setq my-format (cdr (car templist)))))
3876 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3877 (error " ? ")))
3879 (defun gnus-summary-set-local-parameters (group)
3880 "Go through the local params of GROUP and set all variable specs in that list."
3881 (let ((vars '(quit-config active))) ; Ignore things that aren't
3882 ; really variables.
3883 (dolist (elem (gnus-group-find-parameter group))
3884 (and (consp elem) ; Has to be a cons.
3885 (consp (cdr elem)) ; The cdr has to be a list.
3886 (symbolp (car elem)) ; Has to be a symbol in there.
3887 (not (memq (car elem) vars))
3888 (ignore-errors
3889 (push (car elem) vars)
3890 ;; Variables like `gnus-show-threads' that are globally
3891 ;; bound, if used as group parameters, need to get to be
3892 ;; buffer-local, whereas just parameters like `gcc-self',
3893 ;; `timestamp', etc. should not be bound as variables.
3894 (if (boundp (car elem))
3895 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3896 (eval (nth 1 elem))))))))
3898 (defun gnus-summary-read-group (group &optional show-all no-article
3899 kill-buffer no-display backward
3900 select-articles)
3901 "Start reading news in newsgroup GROUP.
3902 If SHOW-ALL is non-nil, already read articles are also listed.
3903 If NO-ARTICLE is non-nil, no article is selected initially.
3904 If NO-DISPLAY, don't generate the summary buffer contents.
3905 If KILL-BUFFER, it should be a buffer that's killed once the new
3906 summary buffer has been generated.
3907 If BACKWARD, move point to the previous group in the group buffer
3908 If SELECT-ARTICLES, only select those articles from GROUP."
3909 (let (result)
3910 (while (and group
3911 (null (setq result
3912 (let ((gnus-auto-select-next nil))
3913 (or (gnus-summary-read-group-1
3914 group show-all no-article
3915 kill-buffer no-display
3916 select-articles)
3917 (setq show-all nil
3918 select-articles nil)))))
3919 (eq gnus-auto-select-next 'quietly))
3920 (set-buffer gnus-group-buffer)
3921 ;; The entry function called above goes to the next
3922 ;; group automatically, so we go two groups back
3923 ;; if we are searching for the previous group.
3924 (when backward
3925 (gnus-group-prev-unread-group 2))
3926 (if (not (equal group (gnus-group-group-name)))
3927 (setq group (gnus-group-group-name))
3928 (setq group nil)))
3929 result))
3931 (defun gnus-summary-read-group-1 (group show-all no-article
3932 kill-buffer no-display
3933 &optional select-articles)
3934 ;; Killed foreign groups can't be entered.
3935 ;; (when (and (not (gnus-group-native-p group))
3936 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3937 ;; (error "Dead non-native groups can't be entered"))
3938 (gnus-message 7 "Retrieving newsgroup: %s..."
3939 (gnus-group-decoded-name group))
3940 (let* ((new-group (gnus-summary-setup-buffer group))
3941 (quit-config (gnus-group-quit-config group))
3942 (did-select (and new-group (gnus-select-newsgroup
3943 group show-all select-articles))))
3944 (cond
3945 ;; This summary buffer exists already, so we just select it.
3946 ((not new-group)
3947 (gnus-set-global-variables)
3948 (when kill-buffer
3949 (gnus-kill-or-deaden-summary kill-buffer))
3950 (gnus-configure-windows 'summary 'force)
3951 (gnus-set-mode-line 'summary)
3952 (gnus-summary-position-point)
3953 (message "")
3955 ;; We couldn't select this group.
3956 ((null did-select)
3957 (when (and (derived-mode-p 'gnus-summary-mode)
3958 (not (equal (current-buffer) kill-buffer)))
3959 (kill-buffer (current-buffer))
3960 (if (not quit-config)
3961 (progn
3962 ;; Update the info -- marks might need to be removed,
3963 ;; for instance.
3964 (gnus-summary-update-info)
3965 (set-buffer gnus-group-buffer)
3966 (gnus-group-jump-to-group group)
3967 (gnus-group-next-unread-group 1))
3968 (gnus-handle-ephemeral-exit quit-config)))
3969 (if (null (gnus-list-of-unread-articles group))
3970 (gnus-message 3 "Group %s contains no messages"
3971 (gnus-group-decoded-name group))
3972 (gnus-message 3 "Can't select group"))
3973 nil)
3974 ;; The user did a `C-g' while prompting for number of articles,
3975 ;; so we exit this group.
3976 ((eq did-select 'quit)
3977 (and (derived-mode-p 'gnus-summary-mode)
3978 (not (equal (current-buffer) kill-buffer))
3979 (kill-buffer (current-buffer)))
3980 (when kill-buffer
3981 (gnus-kill-or-deaden-summary kill-buffer))
3982 (if (not quit-config)
3983 (progn
3984 (set-buffer gnus-group-buffer)
3985 (gnus-group-jump-to-group group)
3986 (gnus-configure-windows 'group 'force))
3987 (gnus-handle-ephemeral-exit quit-config))
3988 ;; Finally signal the quit.
3989 (signal 'quit nil))
3990 ;; The group was successfully selected.
3992 (gnus-set-global-variables)
3993 (when (boundp 'gnus-pick-line-number)
3994 (setq gnus-pick-line-number 0))
3995 (when (boundp 'spam-install-hooks)
3996 (spam-initialize))
3997 ;; Save the active value in effect when the group was entered.
3998 (setq gnus-newsgroup-active
3999 (copy-tree
4000 (gnus-active gnus-newsgroup-name)))
4001 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4002 ;; You can change the summary buffer in some way with this hook.
4003 (gnus-run-hooks 'gnus-select-group-hook)
4004 (when (memq 'summary (gnus-update-format-specifications
4005 nil 'summary 'summary-mode 'summary-dummy))
4006 ;; The format specification for the summary line was updated,
4007 ;; so we need to update the mark positions as well.
4008 (gnus-update-summary-mark-positions))
4009 ;; Do score processing.
4010 (when gnus-use-scoring
4011 (gnus-possibly-score-headers))
4012 ;; Check whether to fill in the gaps in the threads.
4013 (when gnus-build-sparse-threads
4014 (gnus-build-sparse-threads))
4015 ;; Find the initial limit.
4016 (if show-all
4017 (let ((gnus-newsgroup-dormant nil))
4018 (gnus-summary-initial-limit show-all))
4019 (gnus-summary-initial-limit show-all))
4020 ;; Generate the summary buffer.
4021 (unless no-display
4022 (gnus-summary-prepare))
4023 (when gnus-use-trees
4024 (gnus-tree-open)
4025 (setq gnus-summary-highlight-line-function
4026 'gnus-tree-highlight-article))
4027 ;; If the summary buffer is empty, but there are some low-scored
4028 ;; articles or some excluded dormants, we include these in the
4029 ;; buffer.
4030 (when (and (zerop (buffer-size))
4031 (not no-display))
4032 (cond (gnus-newsgroup-dormant
4033 (gnus-summary-limit-include-dormant))
4034 ((and gnus-newsgroup-scored show-all)
4035 (gnus-summary-limit-include-expunged t))))
4036 ;; Function `gnus-apply-kill-file' must be called in this hook.
4037 (gnus-run-hooks 'gnus-apply-kill-hook)
4038 (if (and (zerop (buffer-size))
4039 (not no-display))
4040 (progn
4041 ;; This newsgroup is empty.
4042 (gnus-summary-catchup-and-exit nil t)
4043 (gnus-message 6 "No unread news")
4044 (when kill-buffer
4045 (gnus-kill-or-deaden-summary kill-buffer))
4046 ;; Return nil from this function.
4047 nil)
4048 ;; Hide conversation thread subtrees. We cannot do this in
4049 ;; gnus-summary-prepare-hook since kill processing may not
4050 ;; work with hidden articles.
4051 (gnus-summary-maybe-hide-threads)
4052 (gnus-configure-windows 'summary)
4053 (when kill-buffer
4054 (gnus-kill-or-deaden-summary kill-buffer))
4055 (gnus-summary-auto-select-subject)
4056 ;; Don't mark any articles as selected if we haven't done that.
4057 (when no-article
4058 (setq overlay-arrow-position nil))
4059 ;; Show first unread article if requested.
4060 (if (and (not no-article)
4061 (not no-display)
4062 gnus-newsgroup-unreads
4063 gnus-auto-select-first)
4064 (progn
4065 (let ((art (gnus-summary-article-number)))
4066 (when (and art
4067 gnus-plugged
4068 (not (memq art gnus-newsgroup-undownloaded))
4069 (not (memq art gnus-newsgroup-downloadable)))
4070 (gnus-summary-goto-article art))))
4071 ;; Don't select any articles.
4072 (gnus-summary-position-point)
4073 (gnus-configure-windows 'summary 'force)
4074 (gnus-set-mode-line 'summary))
4075 (when (and gnus-auto-center-group
4076 (get-buffer-window gnus-group-buffer t))
4077 ;; Gotta use windows, because recenter does weird stuff if
4078 ;; the current buffer ain't the displayed window.
4079 (let ((owin (selected-window)))
4080 (select-window (get-buffer-window gnus-group-buffer t))
4081 (when (gnus-group-goto-group group)
4082 (recenter))
4083 (select-window owin)))
4084 ;; Mark this buffer as "prepared".
4085 (setq gnus-newsgroup-prepared t)
4086 (gnus-run-hooks 'gnus-summary-prepared-hook)
4087 (unless (gnus-ephemeral-group-p group)
4088 (gnus-group-update-group group nil t))
4089 t)))))
4091 (defun gnus-summary-auto-select-subject ()
4092 "Select the subject line on initial group entry."
4093 (goto-char (point-min))
4094 (cond
4095 ((eq gnus-auto-select-subject 'best)
4096 (gnus-summary-best-unread-subject))
4097 ((eq gnus-auto-select-subject 'unread)
4098 (gnus-summary-first-unread-subject))
4099 ((eq gnus-auto-select-subject 'unseen)
4100 (gnus-summary-first-unseen-subject))
4101 ((eq gnus-auto-select-subject 'unseen-or-unread)
4102 (gnus-summary-first-unseen-or-unread-subject))
4103 ((eq gnus-auto-select-subject 'first)
4104 ;; Do nothing.
4106 ((functionp gnus-auto-select-subject)
4107 (funcall gnus-auto-select-subject))))
4109 (defun gnus-summary-prepare ()
4110 "Generate the summary buffer."
4111 (interactive)
4112 (let ((inhibit-read-only t))
4113 (erase-buffer)
4114 (setq gnus-newsgroup-data nil
4115 gnus-newsgroup-data-reverse nil)
4116 (gnus-run-hooks 'gnus-summary-generate-hook)
4117 ;; Generate the buffer, either with threads or without.
4118 (when gnus-newsgroup-headers
4119 (gnus-summary-prepare-threads
4120 (if gnus-show-threads
4121 (gnus-sort-gathered-threads
4122 (funcall gnus-summary-thread-gathering-function
4123 (gnus-sort-threads
4124 (gnus-cut-threads (gnus-make-threads)))))
4125 ;; Unthreaded display.
4126 (gnus-sort-articles gnus-newsgroup-headers))))
4127 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4128 ;; Call hooks for modifying summary buffer.
4129 (goto-char (point-min))
4130 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4132 (defsubst gnus-general-simplify-subject (subject)
4133 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4134 (setq subject
4135 (cond
4136 ;; Truncate the subject.
4137 (gnus-simplify-subject-functions
4138 (gnus-map-function gnus-simplify-subject-functions subject))
4139 ((numberp gnus-summary-gather-subject-limit)
4140 (setq subject (gnus-simplify-subject-re subject))
4141 (if (> (length subject) gnus-summary-gather-subject-limit)
4142 (substring subject 0 gnus-summary-gather-subject-limit)
4143 subject))
4144 ;; Fuzzily simplify it.
4145 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4146 (gnus-simplify-subject-fuzzy subject))
4147 ;; Just remove the leading "Re:".
4149 (gnus-simplify-subject-re subject))))
4151 (if (and gnus-summary-gather-exclude-subject
4152 (string-match gnus-summary-gather-exclude-subject subject))
4153 nil ; This article shouldn't be gathered
4154 subject))
4156 (defun gnus-summary-simplify-subject-query ()
4157 "Query where the respool algorithm would put this article."
4158 (interactive)
4159 (gnus-summary-select-article)
4160 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4162 (defun gnus-gather-threads-by-subject (threads)
4163 "Gather threads by looking at Subject headers."
4164 (if (not gnus-summary-make-false-root)
4165 threads
4166 (let ((hashtb (gnus-make-hashtable 1024))
4167 (prev threads)
4168 (result threads)
4169 subject hthread whole-subject)
4170 (while threads
4171 (setq subject (gnus-general-simplify-subject
4172 (setq whole-subject (mail-header-subject
4173 (caar threads)))))
4174 (when subject
4175 (if (setq hthread (gnus-gethash subject hashtb))
4176 (progn
4177 ;; We enter a dummy root into the thread, if we
4178 ;; haven't done that already.
4179 (unless (stringp (caar hthread))
4180 (setcar hthread (list whole-subject (car hthread))))
4181 ;; We add this new gathered thread to this gathered
4182 ;; thread.
4183 (setcdr (car hthread)
4184 (nconc (cdar hthread) (list (car threads))))
4185 ;; Remove it from the list of threads.
4186 (setcdr prev (cdr threads))
4187 (setq threads prev))
4188 ;; Enter this thread into the hash table.
4189 (gnus-sethash subject
4190 (if gnus-summary-make-false-root-always
4191 (progn
4192 ;; If you want a dummy root above all
4193 ;; threads...
4194 (setcar threads (list whole-subject
4195 (car threads)))
4196 threads)
4197 threads)
4198 hashtb)))
4199 (setq prev threads)
4200 (setq threads (cdr threads)))
4201 result)))
4203 (defun gnus-gather-threads-by-references (threads)
4204 "Gather threads by looking at References headers."
4205 (let ((idhashtb (gnus-make-hashtable 1024))
4206 (thhashtb (gnus-make-hashtable 1024))
4207 (prev threads)
4208 (result threads)
4209 ids references id gthread gid entered ref)
4210 (while threads
4211 (when (setq references (mail-header-references (caar threads)))
4212 (setq id (mail-header-id (caar threads))
4213 ids (inline (gnus-split-references references))
4214 entered nil)
4215 (while (setq ref (pop ids))
4216 (setq ids (delete ref ids))
4217 (if (not (setq gid (gnus-gethash ref idhashtb)))
4218 (progn
4219 (gnus-sethash ref id idhashtb)
4220 (gnus-sethash id threads thhashtb))
4221 (setq gthread (gnus-gethash gid thhashtb))
4222 (unless entered
4223 ;; We enter a dummy root into the thread, if we
4224 ;; haven't done that already.
4225 (unless (stringp (caar gthread))
4226 (setcar gthread (list (mail-header-subject (caar gthread))
4227 (car gthread))))
4228 ;; We add this new gathered thread to this gathered
4229 ;; thread.
4230 (setcdr (car gthread)
4231 (nconc (cdar gthread) (list (car threads)))))
4232 ;; Add it into the thread hash table.
4233 (gnus-sethash id gthread thhashtb)
4234 (setq entered t)
4235 ;; Remove it from the list of threads.
4236 (setcdr prev (cdr threads))
4237 (setq threads prev))))
4238 (setq prev threads)
4239 (setq threads (cdr threads)))
4240 result))
4242 (defun gnus-sort-gathered-threads (threads)
4243 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4244 (let ((result threads))
4245 (while threads
4246 (when (stringp (caar threads))
4247 (setcdr (car threads)
4248 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4249 (setq threads (cdr threads)))
4250 result))
4252 (defun gnus-thread-loop-p (root thread)
4253 "Say whether ROOT is in THREAD."
4254 (let ((stack (list thread))
4255 (infloop 0)
4257 (while (setq thread (pop stack))
4258 (setq th (cdr thread))
4259 (while (and th
4260 (not (eq (caar th) root)))
4261 (pop th))
4262 (if th
4263 ;; We have found a loop.
4264 (let (ref-dep)
4265 (setcdr thread (delq (car th) (cdr thread)))
4266 (if (boundp (setq ref-dep (intern "none"
4267 gnus-newsgroup-dependencies)))
4268 (setcdr (symbol-value ref-dep)
4269 (nconc (cdr (symbol-value ref-dep))
4270 (list (car th))))
4271 (set ref-dep (list nil (car th))))
4272 (setq infloop 1
4273 stack nil))
4274 ;; Push all the subthreads onto the stack.
4275 (push (cdr thread) stack)))
4276 infloop))
4278 (defun gnus-make-threads ()
4279 "Go through the dependency hashtb and find the roots. Return all threads."
4280 (let (threads)
4281 (while (catch 'infloop
4282 (mapatoms
4283 (lambda (refs)
4284 ;; Deal with self-referencing References loops.
4285 (when (and (car (symbol-value refs))
4286 (not (zerop
4287 (apply
4289 (mapcar
4290 (lambda (thread)
4291 (gnus-thread-loop-p
4292 (car (symbol-value refs)) thread))
4293 (cdr (symbol-value refs)))))))
4294 (setq threads nil)
4295 (throw 'infloop t))
4296 (unless (car (symbol-value refs))
4297 ;; These threads do not refer back to any other
4298 ;; articles, so they're roots.
4299 (setq threads (append (cdr (symbol-value refs)) threads))))
4300 gnus-newsgroup-dependencies)))
4301 threads))
4303 ;; Build the thread tree.
4304 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4305 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4307 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4308 if it was already present.
4310 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4311 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4312 Message-IDs will be renamed to a unique Message-ID before being
4313 entered.
4315 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4316 (let* ((id (mail-header-id header))
4317 (id-dep (and id (intern id dependencies)))
4318 parent-id ref ref-dep ref-header replaced)
4319 ;; Enter this `header' in the `dependencies' table.
4320 (cond
4321 ((not id-dep)
4322 (setq header nil))
4323 ;; The first two cases do the normal part: enter a new `header'
4324 ;; in the `dependencies' table.
4325 ((not (boundp id-dep))
4326 (set id-dep (list header)))
4327 ((null (car (symbol-value id-dep)))
4328 (setcar (symbol-value id-dep) header))
4330 ;; From here the `header' was already present in the
4331 ;; `dependencies' table.
4332 (force-new
4333 ;; Overrides an existing entry;
4334 ;; just set the header part of the entry.
4335 (setcar (symbol-value id-dep) header)
4336 (setq replaced t))
4338 ;; Renames the existing `header' to a unique Message-ID.
4339 ((not gnus-summary-ignore-duplicates)
4340 ;; An article with this Message-ID has already been seen.
4341 ;; We rename the Message-ID.
4342 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4343 (list header))
4344 (mail-header-set-id header id))
4346 ;; The last case ignores an existing entry, except it adds any
4347 ;; additional Xrefs (in case the two articles came from different
4348 ;; servers.
4349 ;; Also sets `header' to nil meaning that the `dependencies'
4350 ;; table was *not* modified.
4352 (mail-header-set-xref
4353 (car (symbol-value id-dep))
4354 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4356 (or (mail-header-xref header) "")))
4357 (setq header nil)))
4359 (when (and header (not replaced))
4360 ;; First check that we are not creating a References loop.
4361 (setq parent-id (gnus-parent-id (mail-header-references header)))
4362 (setq ref parent-id)
4363 (while (and ref
4364 (setq ref-dep (intern-soft ref dependencies))
4365 (boundp ref-dep)
4366 (setq ref-header (car (symbol-value ref-dep))))
4367 (if (string= id ref)
4368 ;; Yuk! This is a reference loop. Make the article be a
4369 ;; root article.
4370 (progn
4371 (mail-header-set-references (car (symbol-value id-dep)) "none")
4372 (setq ref nil)
4373 (setq parent-id nil))
4374 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4375 (setq ref-dep (intern (or parent-id "none") dependencies))
4376 (if (boundp ref-dep)
4377 (setcdr (symbol-value ref-dep)
4378 (nconc (cdr (symbol-value ref-dep))
4379 (list (symbol-value id-dep))))
4380 (set ref-dep (list nil (symbol-value id-dep)))))
4381 header))
4383 (defun gnus-extract-message-id-from-in-reply-to (string)
4384 (if (string-match "<[^>]+>" string)
4385 (substring string (match-beginning 0) (match-end 0))
4386 nil))
4388 (defun gnus-build-sparse-threads ()
4389 (let ((headers gnus-newsgroup-headers)
4390 (mail-parse-charset gnus-newsgroup-charset)
4391 (gnus-summary-ignore-duplicates t)
4392 header references generation relations
4393 subject child end new-child date)
4394 ;; First we create an alist of generations/relations, where
4395 ;; generations is how much we trust the relation, and the relation
4396 ;; is parent/child.
4397 (gnus-message 7 "Making sparse threads...")
4398 (save-excursion
4399 (nnheader-set-temp-buffer " *gnus sparse threads*")
4400 (while (setq header (pop headers))
4401 (when (and (setq references (mail-header-references header))
4402 (not (string= references "")))
4403 (insert references)
4404 (setq child (mail-header-id header)
4405 subject (mail-header-subject header)
4406 date (mail-header-date header)
4407 generation 0)
4408 (while (search-backward ">" nil t)
4409 (setq end (1+ (point)))
4410 (when (search-backward "<" nil t)
4411 (setq new-child (buffer-substring (point) end))
4412 (push (list (incf generation)
4413 child (setq child new-child)
4414 subject date)
4415 relations)))
4416 (when child
4417 (push (list (1+ generation) child nil subject) relations))
4418 (erase-buffer)))
4419 (kill-buffer (current-buffer)))
4420 ;; Sort over trustworthiness.
4421 (dolist (relation (sort relations 'car-less-than-car))
4422 (when (gnus-dependencies-add-header
4423 (make-full-mail-header
4424 gnus-reffed-article-number
4425 (nth 3 relation) "" (or (nth 4 relation) "")
4426 (nth 1 relation)
4427 (or (nth 2 relation) "") 0 0 "")
4428 gnus-newsgroup-dependencies nil)
4429 (push gnus-reffed-article-number gnus-newsgroup-limit)
4430 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4431 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4432 gnus-newsgroup-reads)
4433 (decf gnus-reffed-article-number)))
4434 (gnus-message 7 "Making sparse threads...done")))
4436 (defun gnus-build-old-threads ()
4437 ;; Look at all the articles that refer back to old articles, and
4438 ;; fetch the headers for the articles that aren't there. This will
4439 ;; build complete threads - if the roots haven't been expired by the
4440 ;; server, that is.
4441 (let ((mail-parse-charset gnus-newsgroup-charset)
4442 id heads)
4443 (mapatoms
4444 (lambda (refs)
4445 (when (not (car (symbol-value refs)))
4446 (setq heads (cdr (symbol-value refs)))
4447 (while heads
4448 (if (memq (mail-header-number (caar heads))
4449 gnus-newsgroup-dormant)
4450 (setq heads (cdr heads))
4451 (setq id (symbol-name refs))
4452 (while (and (setq id (gnus-build-get-header id))
4453 (not (car (gnus-id-to-thread id)))))
4454 (setq heads nil)))))
4455 gnus-newsgroup-dependencies)))
4457 (defsubst gnus-remove-odd-characters (string)
4458 "Translate STRING into something that doesn't contain weird characters."
4459 (subst-char-in-string
4460 ?\r ?\-
4461 (subst-char-in-string ?\n ?\- string t) t))
4463 ;; This function has to be called with point after the article number
4464 ;; on the beginning of the line.
4465 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4466 (let ((eol (point-at-eol))
4467 (buffer (current-buffer))
4468 header references in-reply-to)
4470 ;; overview: [num subject from date id refs chars lines misc]
4471 (unwind-protect
4472 (let (x)
4473 (narrow-to-region (point) eol)
4474 (unless (eobp)
4475 (forward-char))
4477 (setq header
4478 (make-full-mail-header
4479 number ; number
4480 (condition-case () ; subject
4481 (gnus-remove-odd-characters
4482 (funcall gnus-decode-encoded-word-function
4483 (setq x (nnheader-nov-field))))
4484 (error x))
4485 (condition-case () ; from
4486 (gnus-remove-odd-characters
4487 (funcall gnus-decode-encoded-address-function
4488 (setq x (nnheader-nov-field))))
4489 (error x))
4490 (nnheader-nov-field) ; date
4491 (nnheader-nov-read-message-id number) ; id
4492 (setq references (nnheader-nov-field)) ; refs
4493 (nnheader-nov-read-integer) ; chars
4494 (nnheader-nov-read-integer) ; lines
4495 (unless (eobp)
4496 (if (looking-at "Xref: ")
4497 (goto-char (match-end 0)))
4498 (nnheader-nov-field)) ; Xref
4499 (nnheader-nov-parse-extra)))) ; extra
4501 (widen))
4503 (when (and (string= references "")
4504 (setq in-reply-to (mail-header-extra header))
4505 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4506 (mail-header-set-references
4507 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4509 (when gnus-alter-header-function
4510 (funcall gnus-alter-header-function header))
4511 (gnus-dependencies-add-header header dependencies force-new)))
4513 (defun gnus-build-get-header (id)
4514 "Look through the buffer of NOV lines and find the header to ID.
4515 Enter this line into the dependencies hash table, and return
4516 the id of the parent article (if any)."
4517 (let ((deps gnus-newsgroup-dependencies)
4518 found header)
4519 (prog1
4520 (with-current-buffer nntp-server-buffer
4521 (let ((case-fold-search nil))
4522 (goto-char (point-min))
4523 (while (and (not found)
4524 (search-forward id nil t))
4525 (beginning-of-line)
4526 (setq found (looking-at
4527 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4528 (regexp-quote id))))
4529 (or found (beginning-of-line 2)))
4530 (when found
4531 (beginning-of-line)
4532 (and
4533 (setq header (gnus-nov-parse-line
4534 (read (current-buffer)) deps))
4535 (gnus-parent-id (mail-header-references header))))))
4536 (when header
4537 (let ((number (mail-header-number header)))
4538 (push number gnus-newsgroup-limit)
4539 (push header gnus-newsgroup-headers)
4540 (if (memq number gnus-newsgroup-unselected)
4541 (progn
4542 (setq gnus-newsgroup-unreads
4543 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4544 number))
4545 (setq gnus-newsgroup-unselected
4546 (delq number gnus-newsgroup-unselected)))
4547 (push number gnus-newsgroup-ancient)))))))
4549 (defun gnus-build-all-threads ()
4550 "Read all the headers."
4551 (let ((gnus-summary-ignore-duplicates t)
4552 (mail-parse-charset gnus-newsgroup-charset)
4553 (dependencies gnus-newsgroup-dependencies)
4554 header article)
4555 (with-current-buffer nntp-server-buffer
4556 (let ((case-fold-search nil))
4557 (goto-char (point-min))
4558 (while (not (eobp))
4559 (ignore-errors
4560 (setq article (read (current-buffer))
4561 header (gnus-nov-parse-line article dependencies t)))
4562 (when header
4563 (with-current-buffer gnus-summary-buffer
4564 (push header gnus-newsgroup-headers)
4565 (if (memq (setq article (mail-header-number header))
4566 gnus-newsgroup-unselected)
4567 (progn
4568 (setq gnus-newsgroup-unreads
4569 (gnus-add-to-sorted-list
4570 gnus-newsgroup-unreads article))
4571 (setq gnus-newsgroup-unselected
4572 (delq article gnus-newsgroup-unselected)))
4573 (push article gnus-newsgroup-ancient)))
4574 (forward-line 1)))))))
4576 (defun gnus-summary-update-article-line (article header)
4577 "Update the line for ARTICLE using HEADER."
4578 (let* ((id (mail-header-id header))
4579 (thread (gnus-id-to-thread id)))
4580 (unless thread
4581 (error "Article in no thread"))
4582 ;; Update the thread.
4583 (setcar thread header)
4584 (gnus-summary-goto-subject article)
4585 (let* ((datal (gnus-data-find-list article))
4586 (data (car datal))
4587 (inhibit-read-only t)
4588 (level (gnus-summary-thread-level)))
4589 (gnus-delete-line)
4590 (let ((inserted (- (point)
4591 (progn
4592 (gnus-summary-insert-line
4593 header level nil
4594 (memq article gnus-newsgroup-undownloaded)
4595 (gnus-article-mark article)
4596 (memq article gnus-newsgroup-replied)
4597 (memq article gnus-newsgroup-expirable)
4598 ;; Only insert the Subject string when it's different
4599 ;; from the previous Subject string.
4600 (if (and
4601 gnus-show-threads
4602 (gnus-subject-equal
4603 (condition-case ()
4604 (mail-header-subject
4605 (gnus-data-header
4606 (cadr
4607 (gnus-data-find-list
4608 article
4609 (gnus-data-list t)))))
4610 ;; Error on the side of excessive subjects.
4611 (error ""))
4612 (mail-header-subject header)))
4614 (mail-header-subject header))
4615 nil (cdr (assq article gnus-newsgroup-scored))
4616 (memq article gnus-newsgroup-processable))
4617 (point)))))
4618 (when (cdr datal)
4619 (gnus-data-update-list
4620 (cdr datal)
4621 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4623 (defun gnus-summary-update-article (article &optional iheader)
4624 "Update ARTICLE in the summary buffer."
4625 (set-buffer gnus-summary-buffer)
4626 (let* ((header (gnus-summary-article-header article))
4627 (id (mail-header-id header))
4628 (data (gnus-data-find article))
4629 (thread (gnus-id-to-thread id))
4630 (references (mail-header-references header))
4631 (parent
4632 (gnus-id-to-thread
4633 (or (gnus-parent-id
4634 (when (and references
4635 (not (equal "" references)))
4636 references))
4637 "none")))
4638 (inhibit-read-only t)
4639 (old (car thread)))
4640 (when thread
4641 (unless iheader
4642 (setcar thread nil)
4643 (when parent
4644 (delq thread parent)))
4645 (if (gnus-summary-insert-subject id header)
4646 ;; Set the (possibly) new article number in the data structure.
4647 (gnus-data-set-number data (gnus-id-to-article id))
4648 (setcar thread old)
4649 nil))))
4651 (defun gnus-rebuild-thread (id &optional line)
4652 "Rebuild the thread containing ID.
4653 If LINE, insert the rebuilt thread starting on line LINE."
4654 (let ((inhibit-read-only t)
4655 old-pos current thread data)
4656 (if (not gnus-show-threads)
4657 (setq thread (list (car (gnus-id-to-thread id))))
4658 ;; Get the thread this article is part of.
4659 (setq thread (gnus-remove-thread id)))
4660 (setq old-pos (point-at-bol))
4661 (setq current (save-excursion
4662 (and (re-search-backward "[\r\n]" nil t)
4663 (gnus-summary-article-number))))
4664 ;; If this is a gathered thread, we have to go some re-gathering.
4665 (when (stringp (car thread))
4666 (let ((subject (car thread))
4667 roots thr)
4668 (setq thread (cdr thread))
4669 (while thread
4670 (unless (memq (setq thr (gnus-id-to-thread
4671 (gnus-root-id
4672 (mail-header-id (caar thread)))))
4673 roots)
4674 (push thr roots))
4675 (setq thread (cdr thread)))
4676 ;; We now have all (unique) roots.
4677 (if (= (length roots) 1)
4678 ;; All the loose roots are now one solid root.
4679 (setq thread (car roots))
4680 (setq thread (cons subject (gnus-sort-threads roots))))))
4681 (let (threads)
4682 ;; We then insert this thread into the summary buffer.
4683 (when line
4684 (goto-char (point-min))
4685 (forward-line (1- line)))
4686 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4687 (if gnus-show-threads
4688 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4689 (gnus-summary-prepare-unthreaded thread))
4690 (setq data (nreverse gnus-newsgroup-data))
4691 (setq threads gnus-newsgroup-threads))
4692 ;; We splice the new data into the data structure.
4693 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4694 ;;!!! then we want to insert at the beginning of the buffer.
4695 ;;!!! That happens to be true with Gnus now, but that may
4696 ;;!!! change in the future. Perhaps.
4697 (gnus-data-enter-list
4698 (if line nil current) data (- (point) old-pos))
4699 (setq gnus-newsgroup-threads
4700 (nconc threads gnus-newsgroup-threads))
4701 (gnus-data-compute-positions))))
4703 (defun gnus-number-to-header (number)
4704 "Return the header for article NUMBER."
4705 (let ((headers gnus-newsgroup-headers))
4706 (while (and headers
4707 (not (= number (mail-header-number (car headers)))))
4708 (pop headers))
4709 (when headers
4710 (car headers))))
4712 (defun gnus-parent-headers (in-headers &optional generation)
4713 "Return the headers of the GENERATIONth parent of HEADERS."
4714 (unless generation
4715 (setq generation 1))
4716 (let ((parent t)
4717 (headers in-headers)
4718 references)
4719 (while (and parent
4720 (not (zerop generation))
4721 (setq references (mail-header-references headers)))
4722 (setq headers (if (and references
4723 (setq parent (gnus-parent-id references)))
4724 (car (gnus-id-to-thread parent))
4725 nil))
4726 (decf generation))
4727 (and (not (eq headers in-headers))
4728 headers)))
4730 (defun gnus-id-to-thread (id)
4731 "Return the (sub-)thread where ID appears."
4732 (gnus-gethash id gnus-newsgroup-dependencies))
4734 (defun gnus-id-to-article (id)
4735 "Return the article number of ID."
4736 (let ((thread (gnus-id-to-thread id)))
4737 (when (and thread
4738 (car thread))
4739 (mail-header-number (car thread)))))
4741 (defun gnus-id-to-header (id)
4742 "Return the article headers of ID."
4743 (car (gnus-id-to-thread id)))
4745 (defun gnus-article-displayed-root-p (article)
4746 "Say whether ARTICLE is a root(ish) article."
4747 (let ((level (gnus-summary-thread-level article))
4748 (refs (mail-header-references (gnus-summary-article-header article)))
4749 particle)
4750 (cond
4751 ((null level) nil)
4752 ((zerop level) t)
4753 ((null refs) t)
4754 ((null (gnus-parent-id refs)) t)
4755 ((and (= 1 level)
4756 (null (setq particle (gnus-id-to-article
4757 (gnus-parent-id refs))))
4758 (null (gnus-summary-thread-level particle)))))))
4760 (defun gnus-root-id (id)
4761 "Return the id of the root of the thread where ID appears."
4762 (let (last-id prev)
4763 (while (and id (setq prev (car (gnus-id-to-thread id))))
4764 (setq last-id id
4765 id (gnus-parent-id (mail-header-references prev))))
4766 last-id))
4768 (defun gnus-articles-in-thread (thread)
4769 "Return the list of articles in THREAD."
4770 (cons (mail-header-number (car thread))
4771 (mapcan 'gnus-articles-in-thread (cdr thread))))
4773 (defun gnus-remove-thread (id &optional dont-remove)
4774 "Remove the thread that has ID in it."
4775 (let (headers thread last-id)
4776 ;; First go up in this thread until we find the root.
4777 (setq last-id (gnus-root-id id)
4778 headers (message-flatten-list (gnus-id-to-thread last-id)))
4779 ;; We have now found the real root of this thread. It might have
4780 ;; been gathered into some loose thread, so we have to search
4781 ;; through the threads to find the thread we wanted.
4782 (let ((threads gnus-newsgroup-threads)
4783 sub)
4784 (while threads
4785 (setq sub (car threads))
4786 (if (stringp (car sub))
4787 ;; This is a gathered thread, so we look at the roots
4788 ;; below it to find whether this article is in this
4789 ;; gathered root.
4790 (progn
4791 (setq sub (cdr sub))
4792 (while sub
4793 (when (member (caar sub) headers)
4794 (setq thread (car threads)
4795 threads nil
4796 sub nil))
4797 (setq sub (cdr sub))))
4798 ;; It's an ordinary thread, so we check it.
4799 (when (eq (car sub) (car headers))
4800 (setq thread sub
4801 threads nil)))
4802 (setq threads (cdr threads)))
4803 ;; If this article is in no thread, then it's a root.
4804 (if thread
4805 (unless dont-remove
4806 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4807 (setq thread (gnus-id-to-thread last-id)))
4808 (when thread
4809 (prog1
4810 thread ; We return this thread.
4811 (unless dont-remove
4812 (if (stringp (car thread))
4813 (progn
4814 ;; If we use dummy roots, then we have to remove the
4815 ;; dummy root as well.
4816 (when (eq gnus-summary-make-false-root 'dummy)
4817 ;; We go to the dummy root by going to
4818 ;; the first sub-"thread", and then one line up.
4819 (gnus-summary-goto-article
4820 (mail-header-number (caadr thread)))
4821 (forward-line -1)
4822 (gnus-delete-line)
4823 (gnus-data-compute-positions))
4824 (setq thread (cdr thread))
4825 (while thread
4826 (gnus-remove-thread-1 (car thread))
4827 (setq thread (cdr thread))))
4828 (gnus-remove-thread-1 thread))))))))
4830 (defun gnus-remove-thread-1 (thread)
4831 "Remove the thread THREAD recursively."
4832 (let ((number (mail-header-number (pop thread)))
4834 (setq thread (reverse thread))
4835 (while thread
4836 (gnus-remove-thread-1 (pop thread)))
4837 (when (setq d (gnus-data-find number))
4838 (goto-char (gnus-data-pos d))
4839 (gnus-summary-show-thread)
4840 (gnus-data-remove
4841 number
4842 (- (point-at-bol)
4843 (prog1
4844 (1+ (point-at-eol))
4845 (gnus-delete-line)))))))
4847 (defun gnus-sort-threads-recursive (threads func)
4848 ;; Responsible for sorting the root articles of threads.
4849 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4850 'gnus-thread-sort-functions)
4851 func
4852 (gnus-make-sort-function
4853 gnus-subthread-sort-functions))))
4854 (sort (mapcar (lambda (thread)
4855 (cons (car thread)
4856 (and (cdr thread)
4857 (gnus-sort-subthreads-recursive
4858 (cdr thread) subthread-sort-func))))
4859 threads) func)))
4861 (defun gnus-sort-subthreads-recursive (threads func)
4862 ;; Responsible for sorting subthreads.
4863 (sort (mapcar (lambda (thread)
4864 (cons (car thread)
4865 (and (cdr thread)
4866 (gnus-sort-subthreads-recursive (cdr thread) func))))
4867 threads) func))
4869 (defun gnus-sort-threads-loop (threads func)
4870 (let* ((superthread (cons nil threads))
4871 (stack (list (cons superthread threads)))
4872 remaining-threads thread)
4873 (while stack
4874 (setq remaining-threads (cdr (car stack)))
4875 (if remaining-threads
4876 (progn (setq thread (car remaining-threads))
4877 (setcdr (car stack) (cdr remaining-threads))
4878 (if (cdr thread)
4879 (push (cons thread (cdr thread)) stack)))
4880 (setq thread (caar stack))
4881 (setcdr thread (sort (cdr thread) func))
4882 (pop stack)))
4883 (cdr superthread)))
4885 (defun gnus-sort-threads (threads)
4886 "Sort THREADS."
4887 (if (not gnus-thread-sort-functions)
4888 threads
4889 (gnus-message 8 "Sorting threads...")
4890 (prog1
4891 (condition-case nil
4892 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4893 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4894 (gnus-sort-threads-recursive threads sort-func))
4895 ;; Even after binding max-lisp-eval-depth, the recursive
4896 ;; sorter might fail for very long threads. In that case,
4897 ;; try using a (less well-tested) non-recursive sorter.
4898 (error (gnus-message 9 "Sorting threads with loop...")
4899 (gnus-sort-threads-loop
4900 threads (gnus-make-sort-function
4901 gnus-thread-sort-functions))))
4902 (gnus-message 8 "Sorting threads...done"))))
4904 (defun gnus-sort-articles (articles)
4905 "Sort ARTICLES."
4906 (when gnus-article-sort-functions
4907 (gnus-message 7 "Sorting articles...")
4908 (prog1
4909 (setq gnus-newsgroup-headers
4910 (sort articles (gnus-make-sort-function
4911 gnus-article-sort-functions)))
4912 (gnus-message 7 "Sorting articles...done"))))
4914 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4915 (defmacro gnus-thread-header (thread)
4916 "Return header of first article in THREAD.
4917 Note that THREAD must never, ever be anything else than a variable -
4918 using some other form will lead to serious barfage."
4919 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4920 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4921 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4922 (vector thread) 2))
4924 (defsubst gnus-article-sort-by-number (h1 h2)
4925 "Sort articles by article number."
4926 (< (mail-header-number h1)
4927 (mail-header-number h2)))
4929 (defun gnus-thread-sort-by-number (h1 h2)
4930 "Sort threads by root article number."
4931 (gnus-article-sort-by-number
4932 (gnus-thread-header h1) (gnus-thread-header h2)))
4934 (defsubst gnus-article-sort-by-random (h1 h2)
4935 "Sort articles randomly."
4936 (zerop (random 2)))
4938 (defun gnus-thread-sort-by-random (h1 h2)
4939 "Sort threads randomly."
4940 (gnus-article-sort-by-random
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4943 (defsubst gnus-article-sort-by-lines (h1 h2)
4944 "Sort articles by article Lines header."
4945 (< (mail-header-lines h1)
4946 (mail-header-lines h2)))
4948 (defun gnus-thread-sort-by-lines (h1 h2)
4949 "Sort threads by root article Lines header."
4950 (gnus-article-sort-by-lines
4951 (gnus-thread-header h1) (gnus-thread-header h2)))
4953 (defsubst gnus-article-sort-by-chars (h1 h2)
4954 "Sort articles by octet length."
4955 (< (mail-header-chars h1)
4956 (mail-header-chars h2)))
4958 (defun gnus-thread-sort-by-chars (h1 h2)
4959 "Sort threads by root article octet length."
4960 (gnus-article-sort-by-chars
4961 (gnus-thread-header h1) (gnus-thread-header h2)))
4963 (defsubst gnus-article-sort-by-marks (h1 h2)
4964 "Sort articles by octet length."
4965 (< (gnus-article-mark (mail-header-number h1))
4966 (gnus-article-mark (mail-header-number h2))))
4968 (defun gnus-thread-sort-by-marks (h1 h2)
4969 "Sort threads by root article octet length."
4970 (gnus-article-sort-by-marks
4971 (gnus-thread-header h1) (gnus-thread-header h2)))
4973 (defsubst gnus-article-sort-by-author (h1 h2)
4974 "Sort articles by root author."
4975 (gnus-string<
4976 (let ((extract (funcall
4977 gnus-extract-address-components
4978 (mail-header-from h1))))
4979 (or (car extract) (cadr extract) ""))
4980 (let ((extract (funcall
4981 gnus-extract-address-components
4982 (mail-header-from h2))))
4983 (or (car extract) (cadr extract) ""))))
4985 (defun gnus-thread-sort-by-author (h1 h2)
4986 "Sort threads by root author."
4987 (gnus-article-sort-by-author
4988 (gnus-thread-header h1) (gnus-thread-header h2)))
4990 (defsubst gnus-article-sort-by-recipient (h1 h2)
4991 "Sort articles by recipient."
4992 (gnus-string<
4993 (let ((extract (funcall
4994 gnus-extract-address-components
4995 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4996 (or (car extract) (cadr extract)))
4997 (let ((extract (funcall
4998 gnus-extract-address-components
4999 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5000 (or (car extract) (cadr extract)))))
5002 (defun gnus-thread-sort-by-recipient (h1 h2)
5003 "Sort threads by root recipient."
5004 (gnus-article-sort-by-recipient
5005 (gnus-thread-header h1) (gnus-thread-header h2)))
5007 (defsubst gnus-article-sort-by-subject (h1 h2)
5008 "Sort articles by root subject."
5009 (gnus-string<
5010 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5011 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5013 (defun gnus-thread-sort-by-subject (h1 h2)
5014 "Sort threads by root subject."
5015 (gnus-article-sort-by-subject
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5018 (defsubst gnus-article-sort-by-date (h1 h2)
5019 "Sort articles by root article date."
5020 (time-less-p
5021 (gnus-date-get-time (mail-header-date h1))
5022 (gnus-date-get-time (mail-header-date h2))))
5024 (defun gnus-thread-sort-by-date (h1 h2)
5025 "Sort threads by root article date."
5026 (gnus-article-sort-by-date
5027 (gnus-thread-header h1) (gnus-thread-header h2)))
5029 (defsubst gnus-article-sort-by-score (h1 h2)
5030 "Sort articles by root article score.
5031 Unscored articles will be counted as having a score of zero."
5032 (> (or (cdr (assq (mail-header-number h1)
5033 gnus-newsgroup-scored))
5034 gnus-summary-default-score 0)
5035 (or (cdr (assq (mail-header-number h2)
5036 gnus-newsgroup-scored))
5037 gnus-summary-default-score 0)))
5039 (defun gnus-thread-sort-by-score (h1 h2)
5040 "Sort threads by root article score."
5041 (gnus-article-sort-by-score
5042 (gnus-thread-header h1) (gnus-thread-header h2)))
5044 (defun gnus-thread-sort-by-total-score (h1 h2)
5045 "Sort threads by the sum of all scores in the thread.
5046 Unscored articles will be counted as having a score of zero."
5047 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5049 (defun gnus-thread-total-score (thread)
5050 ;; This function find the total score of THREAD.
5051 (cond
5052 ((null thread)
5054 ((consp thread)
5055 (if (stringp (car thread))
5056 (apply gnus-thread-score-function 0
5057 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5058 (gnus-thread-total-score-1 thread)))
5060 (gnus-thread-total-score-1 (list thread)))))
5062 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5063 "Sort articles by number."
5064 (gnus-article-sort-by-number h1 h2))
5066 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5067 "Sort threads such that the thread with the most recently arrived article comes first."
5068 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5070 (defun gnus-thread-highest-number (thread)
5071 "Return the highest article number in THREAD."
5072 (apply 'max (mapcar (lambda (header)
5073 (mail-header-number header))
5074 (message-flatten-list thread))))
5076 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5077 "Sort articles by number."
5078 (gnus-article-sort-by-date h1 h2))
5080 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5081 "Sort threads such that the thread with the most recently dated article comes first."
5082 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5084 ; Since this is called not only to sort the top-level threads, but
5085 ; also in recursive sorts to order the articles within a thread, each
5086 ; article will be processed many times. Thus it speeds things up
5087 ; quite a bit to use gnus-date-get-time, which caches the time value.
5088 (defun gnus-thread-latest-date (thread)
5089 "Return the highest article date in THREAD."
5090 (apply 'max
5091 (mapcar (lambda (header) (float-time
5092 (gnus-date-get-time
5093 (mail-header-date header))))
5094 (message-flatten-list thread))))
5096 (defun gnus-thread-total-score-1 (root)
5097 ;; This function find the total score of the thread below ROOT.
5098 (setq root (car root))
5099 (apply gnus-thread-score-function
5100 (or (append
5101 (mapcar 'gnus-thread-total-score
5102 (cdr (gnus-id-to-thread (mail-header-id root))))
5103 (when (> (mail-header-number root) 0)
5104 (list (or (cdr (assq (mail-header-number root)
5105 gnus-newsgroup-scored))
5106 gnus-summary-default-score 0))))
5107 (list gnus-summary-default-score)
5108 '(0))))
5110 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5111 (defvar gnus-tmp-prev-subject nil)
5112 (defvar gnus-tmp-false-parent nil)
5113 (defvar gnus-tmp-root-expunged nil)
5114 (defvar gnus-tmp-dummy-line nil)
5116 (defun gnus-extra-header (type &optional header)
5117 "Return the extra header of TYPE."
5118 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5119 ""))
5121 (defvar gnus-tmp-thread-tree-header-string "")
5123 (defcustom gnus-sum-thread-tree-root "> "
5124 "With %B spec, used for the root of a thread.
5125 If nil, use subject instead."
5126 :version "22.1"
5127 :type '(radio (const :format "%v " nil) string)
5128 :group 'gnus-thread)
5130 (defcustom gnus-sum-thread-tree-false-root "> "
5131 "With %B spec, used for a false root of a thread.
5132 If nil, use subject instead."
5133 :version "22.1"
5134 :type '(radio (const :format "%v " nil) string)
5135 :group 'gnus-thread)
5137 (defcustom gnus-sum-thread-tree-single-indent ""
5138 "With %B spec, used for a thread with just one message.
5139 If nil, use subject instead."
5140 :version "22.1"
5141 :type '(radio (const :format "%v " nil) string)
5142 :group 'gnus-thread)
5144 (defcustom gnus-sum-thread-tree-vertical "| "
5145 "With %B spec, used for drawing a vertical line."
5146 :version "22.1"
5147 :type 'string
5148 :group 'gnus-thread)
5150 (defcustom gnus-sum-thread-tree-indent " "
5151 "With %B spec, used for indenting."
5152 :version "22.1"
5153 :type 'string
5154 :group 'gnus-thread)
5156 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5157 "With %B spec, used for a leaf with brothers."
5158 :version "22.1"
5159 :type 'string
5160 :group 'gnus-thread)
5162 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5163 "With %B spec, used for a leaf without brothers."
5164 :version "22.1"
5165 :type 'string
5166 :group 'gnus-thread)
5168 (defcustom gnus-summary-display-while-building nil
5169 "If non-nil, show and update the summary buffer as it's being built.
5170 If the value is t, update the buffer after every line is inserted. If
5171 the value is an integer (N), update the display every N lines."
5172 :version "22.1"
5173 :group 'gnus-thread
5174 :type '(choice (const :tag "off" nil)
5175 number
5176 (const :tag "frequently" t)))
5178 (defun gnus-summary-prepare-threads (threads)
5179 "Prepare summary buffer from THREADS and indentation LEVEL.
5180 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5181 or a straight list of headers."
5182 (gnus-message 7 "Generating summary...")
5184 (setq gnus-newsgroup-threads threads)
5185 (beginning-of-line)
5187 (let ((gnus-tmp-level 0)
5188 (default-score (or gnus-summary-default-score 0))
5189 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5190 (building-line-count gnus-summary-display-while-building)
5191 (building-count (integerp gnus-summary-display-while-building))
5192 thread number subject stack state gnus-tmp-gathered beg-match
5193 new-roots gnus-tmp-new-adopts thread-end simp-subject
5194 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5195 gnus-tmp-replied gnus-tmp-subject-or-nil
5196 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5197 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5198 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5199 tree-stack)
5201 (setq gnus-tmp-prev-subject nil
5202 gnus-tmp-thread-tree-header-string "")
5204 (if (vectorp (car threads))
5205 ;; If this is a straight (sic) list of headers, then a
5206 ;; threaded summary display isn't required, so we just create
5207 ;; an unthreaded one.
5208 (gnus-summary-prepare-unthreaded threads)
5210 ;; Do the threaded display.
5212 (if gnus-summary-display-while-building
5213 (switch-to-buffer (buffer-name)))
5214 (while (or threads stack gnus-tmp-new-adopts new-roots)
5216 (if (and (= gnus-tmp-level 0)
5217 (or (not stack)
5218 (= (caar stack) 0))
5219 (not gnus-tmp-false-parent)
5220 (or gnus-tmp-new-adopts new-roots))
5221 (if gnus-tmp-new-adopts
5222 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5223 thread (list (car gnus-tmp-new-adopts))
5224 gnus-tmp-header (caar thread)
5225 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5226 (when new-roots
5227 (setq thread (list (car new-roots))
5228 gnus-tmp-header (caar thread)
5229 new-roots (cdr new-roots))))
5231 (if threads
5232 ;; If there are some threads, we do them before the
5233 ;; threads on the stack.
5234 (setq thread threads
5235 gnus-tmp-header (caar thread))
5236 ;; There were no current threads, so we pop something off
5237 ;; the stack.
5238 (setq state (car stack)
5239 gnus-tmp-level (car state)
5240 tree-stack (cadr state)
5241 thread (caddr state)
5242 stack (cdr stack)
5243 gnus-tmp-header (caar thread))))
5245 (setq gnus-tmp-false-parent nil)
5246 (setq gnus-tmp-root-expunged nil)
5247 (setq thread-end nil)
5249 (if (stringp gnus-tmp-header)
5250 ;; The header is a dummy root.
5251 (cond
5252 ((eq gnus-summary-make-false-root 'adopt)
5253 ;; We let the first article adopt the rest.
5254 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5255 (cddar thread)))
5256 (setq gnus-tmp-gathered
5257 (nconc (mapcar
5258 (lambda (h) (mail-header-number (car h)))
5259 (cddar thread))
5260 gnus-tmp-gathered))
5261 (setq thread (cons (list (caar thread)
5262 (cadar thread))
5263 (cdr thread)))
5264 (setq gnus-tmp-level -1
5265 gnus-tmp-false-parent t))
5266 ((eq gnus-summary-make-false-root 'empty)
5267 ;; We print adopted articles with empty subject fields.
5268 (setq gnus-tmp-gathered
5269 (nconc (mapcar
5270 (lambda (h) (mail-header-number (car h)))
5271 (cddar thread))
5272 gnus-tmp-gathered))
5273 (setq gnus-tmp-level -1))
5274 ((eq gnus-summary-make-false-root 'dummy)
5275 ;; We remember that we probably want to output a dummy
5276 ;; root.
5277 (setq gnus-tmp-dummy-line gnus-tmp-header)
5278 (setq gnus-tmp-prev-subject gnus-tmp-header))
5280 ;; We do not make a root for the gathered
5281 ;; sub-threads at all.
5282 (setq gnus-tmp-level -1)))
5284 (setq number (mail-header-number gnus-tmp-header)
5285 subject (mail-header-subject gnus-tmp-header)
5286 simp-subject (gnus-simplify-subject-fully subject))
5288 (cond
5289 ;; If the thread has changed subject, we might want to make
5290 ;; this subthread into a root.
5291 ((and (null gnus-thread-ignore-subject)
5292 (not (zerop gnus-tmp-level))
5293 gnus-tmp-prev-subject
5294 (not (string= gnus-tmp-prev-subject simp-subject)))
5295 (setq new-roots (nconc new-roots (list (car thread)))
5296 thread-end t
5297 gnus-tmp-header nil))
5298 ;; If the article lies outside the current limit,
5299 ;; then we do not display it.
5300 ((not (memq number gnus-newsgroup-limit))
5301 (setq gnus-tmp-gathered
5302 (nconc (mapcar
5303 (lambda (h) (mail-header-number (car h)))
5304 (cdar thread))
5305 gnus-tmp-gathered))
5306 (setq gnus-tmp-new-adopts (if (cdar thread)
5307 (append gnus-tmp-new-adopts
5308 (cdar thread))
5309 gnus-tmp-new-adopts)
5310 thread-end t
5311 gnus-tmp-header nil)
5312 (when (zerop gnus-tmp-level)
5313 (setq gnus-tmp-root-expunged t)))
5314 ;; Perhaps this article is to be marked as read?
5315 ((and gnus-summary-mark-below
5316 (< (or (cdr (assq number gnus-newsgroup-scored))
5317 default-score)
5318 gnus-summary-mark-below)
5319 ;; Don't touch sparse articles.
5320 (not (gnus-summary-article-sparse-p number))
5321 (not (gnus-summary-article-ancient-p number)))
5322 (setq gnus-newsgroup-unreads
5323 (delq number gnus-newsgroup-unreads))
5324 (if gnus-newsgroup-auto-expire
5325 (setq gnus-newsgroup-expirable
5326 (gnus-add-to-sorted-list
5327 gnus-newsgroup-expirable number))
5328 (push (cons number gnus-low-score-mark)
5329 gnus-newsgroup-reads))))
5331 (when gnus-tmp-header
5332 ;; We may have an old dummy line to output before this
5333 ;; article.
5334 (when (and gnus-tmp-dummy-line
5335 (gnus-subject-equal
5336 gnus-tmp-dummy-line
5337 (mail-header-subject gnus-tmp-header)))
5338 (gnus-summary-insert-dummy-line
5339 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5340 (setq gnus-tmp-dummy-line nil))
5342 ;; Compute the mark.
5343 (setq gnus-tmp-unread (gnus-article-mark number))
5345 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5346 gnus-tmp-header gnus-tmp-level)
5347 gnus-newsgroup-data)
5349 ;; Actually insert the line.
5350 (setq
5351 gnus-tmp-subject-or-nil
5352 (cond
5353 ((and gnus-thread-ignore-subject
5354 gnus-tmp-prev-subject
5355 (not (string= gnus-tmp-prev-subject simp-subject)))
5356 subject)
5357 ((zerop gnus-tmp-level)
5358 (if (and (eq gnus-summary-make-false-root 'empty)
5359 (memq number gnus-tmp-gathered)
5360 gnus-tmp-prev-subject
5361 (string= gnus-tmp-prev-subject simp-subject))
5362 gnus-summary-same-subject
5363 subject))
5364 (t gnus-summary-same-subject)))
5365 (if (and (eq gnus-summary-make-false-root 'adopt)
5366 (= gnus-tmp-level 1)
5367 (memq number gnus-tmp-gathered))
5368 (setq gnus-tmp-opening-bracket ?\<
5369 gnus-tmp-closing-bracket ?\>)
5370 (setq gnus-tmp-opening-bracket ?\[
5371 gnus-tmp-closing-bracket ?\]))
5372 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5373 (gnus-make-thread-indent-array
5374 (max (* 2 (length gnus-thread-indent-array))
5375 gnus-tmp-level)))
5376 (setq
5377 gnus-tmp-indentation
5378 (aref gnus-thread-indent-array gnus-tmp-level)
5379 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5380 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5381 gnus-summary-default-score 0)
5382 gnus-tmp-score-char
5383 (if (or (null gnus-summary-default-score)
5384 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5385 gnus-summary-zcore-fuzz))
5386 ? ;Whitespace
5387 (if (< gnus-tmp-score gnus-summary-default-score)
5388 gnus-score-below-mark gnus-score-over-mark))
5389 gnus-tmp-replied
5390 (cond ((memq number gnus-newsgroup-processable)
5391 gnus-process-mark)
5392 ((memq number gnus-newsgroup-cached)
5393 gnus-cached-mark)
5394 ((memq number gnus-newsgroup-replied)
5395 gnus-replied-mark)
5396 ((memq number gnus-newsgroup-forwarded)
5397 gnus-forwarded-mark)
5398 ((memq number gnus-newsgroup-saved)
5399 gnus-saved-mark)
5400 ((memq number gnus-newsgroup-unseen)
5401 gnus-unseen-mark)
5402 (t gnus-no-mark))
5403 gnus-tmp-downloaded
5404 (cond ((memq number gnus-newsgroup-undownloaded)
5405 gnus-undownloaded-mark)
5406 (gnus-newsgroup-agentized
5407 gnus-downloaded-mark)
5409 gnus-no-mark))
5410 gnus-tmp-from (mail-header-from gnus-tmp-header)
5411 gnus-tmp-name
5412 (cond
5413 ((string-match "<[^>]+> *$" gnus-tmp-from)
5414 (setq beg-match (match-beginning 0))
5415 (or (and (string-match "^\".+\"" gnus-tmp-from)
5416 (substring gnus-tmp-from 1 (1- (match-end 0))))
5417 (substring gnus-tmp-from 0 beg-match)))
5418 ((string-match "(.+)" gnus-tmp-from)
5419 (substring gnus-tmp-from
5420 (1+ (match-beginning 0)) (1- (match-end 0))))
5421 (t gnus-tmp-from))
5423 ;; Do the %B string
5424 gnus-tmp-thread-tree-header-string
5425 (cond
5426 ((not gnus-show-threads) "")
5427 ((zerop gnus-tmp-level)
5428 (cond ((cdar thread)
5429 (or gnus-sum-thread-tree-root subject))
5430 (gnus-tmp-new-adopts
5431 (or gnus-sum-thread-tree-false-root subject))
5433 (or gnus-sum-thread-tree-single-indent subject))))
5435 (concat (apply 'concat
5436 (mapcar (lambda (item)
5437 (if (= item 1)
5438 gnus-sum-thread-tree-vertical
5439 gnus-sum-thread-tree-indent))
5440 (cdr (reverse tree-stack))))
5441 (if (nth 1 thread)
5442 gnus-sum-thread-tree-leaf-with-other
5443 gnus-sum-thread-tree-single-leaf)))))
5444 (when (string= gnus-tmp-name "")
5445 (setq gnus-tmp-name gnus-tmp-from))
5446 (unless (numberp gnus-tmp-lines)
5447 (setq gnus-tmp-lines -1))
5448 (if (= gnus-tmp-lines -1)
5449 (setq gnus-tmp-lines "?")
5450 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5451 (put-text-property
5452 (point)
5453 (progn (eval gnus-summary-line-format-spec) (point))
5454 'gnus-number number)
5455 (when gnus-visual-p
5456 (forward-line -1)
5457 (gnus-summary-highlight-line)
5458 (when gnus-summary-update-hook
5459 (gnus-run-hooks 'gnus-summary-update-hook))
5460 (forward-line 1))
5462 (setq gnus-tmp-prev-subject simp-subject)))
5464 (when (nth 1 thread)
5465 (push (list (max 0 gnus-tmp-level)
5466 (copy-sequence tree-stack)
5467 (nthcdr 1 thread))
5468 stack))
5469 (push (if (nth 1 thread) 1 0) tree-stack)
5470 (incf gnus-tmp-level)
5471 (setq threads (if thread-end nil (cdar thread)))
5472 (if gnus-summary-display-while-building
5473 (if building-count
5474 (progn
5475 ;; use a set frequency
5476 (setq building-line-count (1- building-line-count))
5477 (when (= building-line-count 0)
5478 (sit-for 0)
5479 (setq building-line-count
5480 gnus-summary-display-while-building)))
5481 ;; always
5482 (sit-for 0)))
5483 (unless threads
5484 (setq gnus-tmp-level 0)))))
5485 (gnus-message 7 "Generating summary...done"))
5487 (defun gnus-summary-prepare-unthreaded (headers)
5488 "Generate an unthreaded summary buffer based on HEADERS."
5489 (let (header number mark)
5491 (beginning-of-line)
5493 (while headers
5494 ;; We may have to root out some bad articles...
5495 (when (memq (setq number (mail-header-number
5496 (setq header (pop headers))))
5497 gnus-newsgroup-limit)
5498 ;; Mark article as read when it has a low score.
5499 (when (and gnus-summary-mark-below
5500 (< (or (cdr (assq number gnus-newsgroup-scored))
5501 gnus-summary-default-score 0)
5502 gnus-summary-mark-below)
5503 (not (gnus-summary-article-ancient-p number)))
5504 (setq gnus-newsgroup-unreads
5505 (delq number gnus-newsgroup-unreads))
5506 (if gnus-newsgroup-auto-expire
5507 (push number gnus-newsgroup-expirable)
5508 (push (cons number gnus-low-score-mark)
5509 gnus-newsgroup-reads)))
5511 (setq mark (gnus-article-mark number))
5512 (push (gnus-data-make number mark (1+ (point)) header 0)
5513 gnus-newsgroup-data)
5514 (gnus-summary-insert-line
5515 header 0 number
5516 (memq number gnus-newsgroup-undownloaded)
5517 mark (memq number gnus-newsgroup-replied)
5518 (memq number gnus-newsgroup-expirable)
5519 (mail-header-subject header) nil
5520 (cdr (assq number gnus-newsgroup-scored))
5521 (memq number gnus-newsgroup-processable))))))
5523 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5525 (defun gnus-group-get-list-identifiers (group)
5526 "Get list identifier regexp for GROUP."
5527 (or (gnus-parameter-list-identifier group)
5528 (if (consp gnus-list-identifiers)
5529 (mapconcat 'identity gnus-list-identifiers " *\\|")
5530 gnus-list-identifiers)))
5532 (defun gnus-summary-remove-list-identifiers ()
5533 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5534 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5535 changed subject)
5536 (when regexp
5537 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5538 (dolist (header gnus-newsgroup-headers)
5539 (setq subject (mail-header-subject header)
5540 changed nil)
5541 (while (string-match regexp subject)
5542 (setq subject
5543 (concat (substring subject 0 (match-beginning 1))
5544 (substring subject (match-end 0)))
5545 changed t))
5546 (when changed
5547 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5548 (setq subject
5549 (concat (substring subject 0 (match-beginning 1))
5550 (substring subject (match-end 1)))))
5551 (mail-header-set-subject header subject))))))
5553 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5554 "Fetch headers of ARTICLES."
5555 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5556 (gnus-message 7 "Fetching headers for %s..." name)
5557 (prog1
5558 (if (eq 'nov
5559 (setq gnus-headers-retrieved-by
5560 (gnus-retrieve-headers
5561 articles gnus-newsgroup-name
5562 (or limit
5563 ;; We might want to fetch old headers, but
5564 ;; not if there is only 1 article.
5565 (and (or (and
5566 (not (eq gnus-fetch-old-headers 'some))
5567 (not (numberp gnus-fetch-old-headers)))
5568 (> (length articles) 1))
5569 gnus-fetch-old-headers)))))
5570 (gnus-get-newsgroup-headers-xover
5571 articles force-new dependencies gnus-newsgroup-name t)
5572 (gnus-get-newsgroup-headers dependencies force-new))
5573 (gnus-message 7 "Fetching headers for %s...done" name))))
5575 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5576 "Select newsgroup GROUP.
5577 If READ-ALL is non-nil, all articles in the group are selected.
5578 If SELECT-ARTICLES, only select those articles from GROUP."
5579 (let* ((entry (gnus-group-entry group))
5580 ;;!!! Dirty hack; should be removed.
5581 (gnus-summary-ignore-duplicates
5582 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5584 gnus-summary-ignore-duplicates))
5585 (info (nth 2 entry))
5586 charset articles fetched-articles cached)
5588 (unless (gnus-check-server
5589 (set (make-local-variable 'gnus-current-select-method)
5590 (gnus-find-method-for-group group)))
5591 (error "Couldn't open server"))
5592 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5594 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5595 (gnus-activate-group group) ; Or we can activate it...
5596 (progn ; Or we bug out.
5597 (when (derived-mode-p 'gnus-summary-mode)
5598 (gnus-kill-buffer (current-buffer)))
5599 (error
5600 "Couldn't activate group %s: %s"
5601 (decode-coding-string group charset)
5602 (decode-coding-string (gnus-status-message group) charset))))
5604 (unless (gnus-request-group group t nil (gnus-get-info group))
5605 (when (derived-mode-p 'gnus-summary-mode)
5606 (gnus-kill-buffer (current-buffer)))
5607 (error "Couldn't request group %s: %s"
5608 (decode-coding-string group charset)
5609 (decode-coding-string (gnus-status-message group) charset)))
5611 (when (and gnus-agent
5612 (gnus-active group))
5613 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5615 (setq gnus-summary-use-undownloaded-faces
5616 (gnus-agent-find-parameter
5617 group
5618 'agent-enable-undownloaded-faces)))
5620 (setq gnus-newsgroup-name group
5621 gnus-newsgroup-unselected nil
5622 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5624 (let ((display (gnus-group-find-parameter group 'display)))
5625 (setq gnus-newsgroup-display
5626 (cond
5627 ((not (zerop (or (car-safe read-all) 0)))
5628 ;; The user entered the group with C-u SPC/RET, let's show
5629 ;; all articles.
5630 'gnus-not-ignore)
5631 ((eq display 'all)
5632 'gnus-not-ignore)
5633 ((arrayp display)
5634 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5635 ((numberp display)
5636 ;; The following is probably the "correct" solution, but
5637 ;; it makes Gnus fetch all headers and then limit the
5638 ;; articles (which is slow), so instead we hack the
5639 ;; select-articles parameter instead. -- Simon Josefsson
5640 ;; <jas@kth.se>
5642 ;; (gnus-byte-compile
5643 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5644 ;; display)))))
5645 (setq select-articles
5646 (gnus-uncompress-range
5647 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5648 (if (> tmp 0)
5651 (cdr (gnus-active group)))))
5652 nil)
5654 nil))))
5656 (gnus-summary-setup-default-charset)
5658 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5659 (when (gnus-virtual-group-p group)
5660 (setq cached gnus-newsgroup-cached))
5662 (setq gnus-newsgroup-unreads
5663 (gnus-sorted-ndifference
5664 (gnus-sorted-ndifference gnus-newsgroup-unreads
5665 gnus-newsgroup-marked)
5666 gnus-newsgroup-dormant))
5668 (setq gnus-newsgroup-processable nil)
5670 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5672 ;; Adjust and set lists of article marks.
5673 (when info
5674 (gnus-adjust-marked-articles info))
5675 (if (setq articles select-articles)
5676 (setq gnus-newsgroup-unselected
5677 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5678 (setq articles (gnus-articles-to-read group read-all)))
5680 (cond
5681 ((null articles)
5682 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5683 'quit)
5684 ((eq articles 0) nil)
5686 ;; Init the dependencies hash table.
5687 (setq gnus-newsgroup-dependencies
5688 (gnus-make-hashtable (length articles)))
5689 (if (gnus-buffer-live-p gnus-group-buffer)
5690 (gnus-set-global-variables)
5691 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5692 ;; Retrieve the headers and read them in.
5694 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5696 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5697 (when cached
5698 (setq gnus-newsgroup-cached cached))
5700 ;; Suppress duplicates?
5701 (when gnus-suppress-duplicates
5702 (gnus-dup-suppress-articles))
5704 ;; Set the initial limit.
5705 (setq gnus-newsgroup-limit (copy-sequence articles))
5706 ;; Remove canceled articles from the list of unread articles.
5707 (setq fetched-articles
5708 (mapcar (lambda (headers) (mail-header-number headers))
5709 gnus-newsgroup-headers))
5710 (setq gnus-newsgroup-articles fetched-articles)
5711 (setq gnus-newsgroup-unreads
5712 (gnus-sorted-nintersection
5713 gnus-newsgroup-unreads fetched-articles))
5714 (gnus-compute-unseen-list)
5716 ;; Removed marked articles that do not exist.
5717 (gnus-update-missing-marks
5718 (gnus-sorted-difference articles fetched-articles))
5719 ;; We might want to build some more threads first.
5720 (when (and gnus-fetch-old-headers
5721 (eq gnus-headers-retrieved-by 'nov))
5722 (if (eq gnus-fetch-old-headers 'invisible)
5723 (gnus-build-all-threads)
5724 (gnus-build-old-threads)))
5725 ;; Let the Gnus agent mark articles as read.
5726 (when gnus-agent
5727 (gnus-agent-get-undownloaded-list))
5728 ;; Remove list identifiers from subject
5729 (gnus-summary-remove-list-identifiers)
5730 ;; Check whether auto-expire is to be done in this group.
5731 (setq gnus-newsgroup-auto-expire
5732 (and (gnus-group-auto-expirable-p group)
5733 (not (gnus-group-read-only-p group))))
5734 ;; Set up the article buffer now, if necessary.
5735 (unless (and gnus-single-article-buffer
5736 (equal gnus-article-buffer "*Article*"))
5737 (gnus-article-setup-buffer))
5738 ;; First and last article in this newsgroup.
5739 (when gnus-newsgroup-headers
5740 (setq gnus-newsgroup-begin
5741 (mail-header-number (car gnus-newsgroup-headers))
5742 gnus-newsgroup-end
5743 (mail-header-number
5744 (car (last gnus-newsgroup-headers)))))
5745 ;; GROUP is successfully selected.
5746 (or gnus-newsgroup-headers t)))))
5748 (defun gnus-compute-unseen-list ()
5749 ;; The `seen' marks are treated specially.
5750 (if (not gnus-newsgroup-seen)
5751 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5752 (setq gnus-newsgroup-unseen
5753 (gnus-inverse-list-range-intersection
5754 gnus-newsgroup-articles gnus-newsgroup-seen))))
5756 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5758 (defun gnus-summary-display-make-predicate (display)
5759 (require 'gnus-agent)
5760 (when (= (length display) 1)
5761 (setq display (car display)))
5762 (unless gnus-summary-display-cache
5763 (dolist (elem (append '((unread . unread)
5764 (read . read)
5765 (unseen . unseen))
5766 gnus-article-mark-lists))
5767 (push (cons (cdr elem)
5768 (gnus-byte-compile ;Why bother?
5769 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5770 gnus-summary-display-cache)))
5771 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5772 (gnus-category-predicate-cache gnus-summary-display-cache))
5773 (gnus-get-predicate display)))
5775 ;; Uses the dynamically bound `gnus-number' variable.
5776 (defvar gnus-number)
5777 (defun gnus-article-marked-p (type &optional article)
5778 (let ((article (or article gnus-number)))
5779 (cond
5780 ((eq type 'tick)
5781 (memq article gnus-newsgroup-marked))
5782 ((eq type 'spam)
5783 (memq article gnus-newsgroup-spam-marked))
5784 ((eq type 'unsend)
5785 (memq article gnus-newsgroup-unsendable))
5786 ((eq type 'undownload)
5787 (memq article gnus-newsgroup-undownloaded))
5788 ((eq type 'download)
5789 (memq article gnus-newsgroup-downloadable))
5790 ((eq type 'unread)
5791 (memq article gnus-newsgroup-unreads))
5792 ((eq type 'read)
5793 (memq article gnus-newsgroup-reads))
5794 ((eq type 'dormant)
5795 (memq article gnus-newsgroup-dormant) )
5796 ((eq type 'expire)
5797 (memq article gnus-newsgroup-expirable))
5798 ((eq type 'reply)
5799 (memq article gnus-newsgroup-replied))
5800 ((eq type 'killed)
5801 (memq article gnus-newsgroup-killed))
5802 ((eq type 'bookmark)
5803 (assq article gnus-newsgroup-bookmarks))
5804 ((eq type 'score)
5805 (assq article gnus-newsgroup-scored))
5806 ((eq type 'save)
5807 (memq article gnus-newsgroup-saved))
5808 ((eq type 'cache)
5809 (memq article gnus-newsgroup-cached))
5810 ((eq type 'forward)
5811 (memq article gnus-newsgroup-forwarded))
5812 ((eq type 'seen)
5813 (not (memq article gnus-newsgroup-unseen)))
5814 (t t))))
5816 (defun gnus-articles-to-read (group &optional read-all)
5817 "Find out what articles the user wants to read."
5818 (let* ((only-read-p t)
5819 (articles
5820 (gnus-list-range-difference
5821 ;; Select all articles if `read-all' is non-nil, or if there
5822 ;; are no unread articles.
5823 (if (or read-all
5824 (and (zerop (length gnus-newsgroup-marked))
5825 (zerop (length gnus-newsgroup-unreads)))
5826 ;; Fetch all if the predicate is non-nil.
5827 gnus-newsgroup-display)
5828 ;; We want to select the headers for all the articles in
5829 ;; the group, so we select either all the active
5830 ;; articles in the group, or (if that's nil), the
5831 ;; articles in the cache.
5833 (if gnus-newsgroup-maximum-articles
5834 (let ((active (gnus-active group)))
5835 (gnus-uncompress-range
5836 (cons (max (car active)
5837 (- (cdr active)
5838 gnus-newsgroup-maximum-articles
5839 -1))
5840 (cdr active))))
5841 (gnus-uncompress-range (gnus-active group)))
5842 (gnus-cache-articles-in-group group))
5843 ;; Select only the "normal" subset of articles.
5844 (setq only-read-p nil)
5845 (gnus-sorted-nunion
5846 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5847 gnus-newsgroup-unreads))
5848 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5849 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5850 (scored (length scored-list))
5851 (number (length articles))
5852 (marked (+ (length gnus-newsgroup-marked)
5853 (length gnus-newsgroup-dormant)))
5854 (select
5855 (cond
5856 ((numberp read-all)
5857 read-all)
5858 ((numberp gnus-newsgroup-display)
5859 gnus-newsgroup-display)
5861 (condition-case ()
5862 (cond
5863 ((and (or (<= scored marked) (= scored number))
5864 (numberp gnus-large-newsgroup)
5865 (> number gnus-large-newsgroup))
5866 (let* ((cursor-in-echo-area nil)
5867 (initial (gnus-parameter-large-newsgroup-initial
5868 gnus-newsgroup-name))
5869 (default (if only-read-p
5870 (or initial gnus-large-newsgroup)
5871 number))
5872 (input
5873 (read-string
5874 (if only-read-p
5875 (format
5876 "How many articles from %s (available %d, default %d): "
5877 (gnus-group-real-name
5878 (gnus-group-decoded-name gnus-newsgroup-name))
5879 number default)
5880 (format
5881 "How many articles from %s (%d default): "
5882 (gnus-group-real-name
5883 (gnus-group-decoded-name gnus-newsgroup-name))
5884 default))
5887 (number-to-string default))))
5888 (if (string-match "^[ \t]*$" input) number input)))
5889 ((and (> scored marked) (< scored number)
5890 (> (- scored number) 20))
5891 (let ((input
5892 (read-string
5893 (format "%s %s (%d scored, %d total): "
5894 "How many articles from"
5895 (gnus-group-decoded-name
5896 (gnus-group-real-name gnus-newsgroup-name))
5897 scored number))))
5898 (if (string-match "^[ \t]*$" input)
5899 number input)))
5900 (t number))
5901 (quit
5902 (message "Quit getting the articles to read")
5903 nil))))))
5904 (setq select (if (stringp select) (string-to-number select) select))
5905 (if (or (null select) (zerop select))
5906 select
5907 (if (and (not (zerop scored)) (<= (abs select) scored))
5908 (progn
5909 (setq articles (sort scored-list '<))
5910 (setq number (length articles)))
5911 (setq articles (copy-sequence articles)))
5913 (when (< (abs select) number)
5914 (if (< select 0)
5915 ;; Select the N oldest articles.
5916 (setcdr (nthcdr (1- (abs select)) articles) nil)
5917 ;; Select the N most recent articles.
5918 (setq articles (nthcdr (- number select) articles))))
5919 (setq gnus-newsgroup-unselected
5920 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5921 (when (functionp gnus-alter-articles-to-read-function)
5922 (setq articles
5923 (sort
5924 (funcall gnus-alter-articles-to-read-function
5925 gnus-newsgroup-name articles)
5926 '<)))
5927 articles)))
5929 (defun gnus-killed-articles (killed articles)
5930 (let (out)
5931 (while articles
5932 (when (inline (gnus-member-of-range (car articles) killed))
5933 (push (car articles) out))
5934 (setq articles (cdr articles)))
5935 out))
5937 (defun gnus-article-mark-to-type (mark)
5938 "Return the type of MARK."
5939 (or (cadr (assq mark gnus-article-special-mark-lists))
5940 'list))
5942 (defun gnus-article-unpropagatable-p (mark)
5943 "Return whether MARK should be propagated to back end."
5944 (memq mark gnus-article-unpropagated-mark-lists))
5946 (defun gnus-adjust-marked-articles (info)
5947 "Set all article lists and remove all marks that are no longer valid."
5948 (let* ((marked-lists (gnus-info-marks info))
5949 (active (gnus-active (gnus-info-group info)))
5950 (min (car active))
5951 (max (cdr active))
5952 (types gnus-article-mark-lists)
5953 marks var articles article mark mark-type
5954 bgn end)
5955 ;; Hack to avoid adjusting marks for imap.
5956 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5957 'nnimap)
5958 (setq min 1))
5960 (dolist (marks marked-lists)
5961 (setq mark (car marks)
5962 mark-type (gnus-article-mark-to-type mark)
5963 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5964 ;; We set the variable according to the type of the marks list,
5965 ;; and then adjust the marks to a subset of the active articles.
5966 (cond
5967 ;; Adjust "simple" lists - compressed yet unsorted
5968 ((eq mark-type 'list)
5969 ;; Simultaneously uncompress and clip to active range
5970 ;; See gnus-uncompress-range for a description of possible marks
5971 (let (l lh)
5972 (if (not (cadr marks))
5973 (set var nil)
5974 (setq articles (if (numberp (cddr marks))
5975 (list (cdr marks))
5976 (cdr marks))
5977 lh (cons nil nil)
5978 l lh)
5980 (while (setq article (pop articles))
5981 (cond ((consp article)
5982 (setq bgn (max (car article) min)
5983 end (min (cdr article) max))
5984 (while (<= bgn end)
5985 (setq l (setcdr l (cons bgn nil))
5986 bgn (1+ bgn))))
5987 ((and (<= min article)
5988 (>= max article))
5989 (setq l (setcdr l (cons article nil))))))
5990 (set var (cdr lh)))))
5991 ;; Adjust assocs.
5992 ((eq mark-type 'tuple)
5993 (set var (setq articles (cdr marks)))
5994 (when (not (listp (cdr (symbol-value var))))
5995 (set var (list (symbol-value var))))
5996 (when (not (listp (cdr articles)))
5997 (setq articles (list articles)))
5998 (while articles
5999 (when (or (not (consp (setq article (pop articles))))
6000 (< (car article) min)
6001 (> (car article) max))
6002 (set var (delq article (symbol-value var))))))
6003 ;; Adjust ranges (sloppily).
6004 ((eq mark-type 'range)
6005 (cond
6006 ((eq mark 'seen)
6007 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6008 ;; It should be (seen (NUM1 . NUM2)).
6009 (when (numberp (cddr marks))
6010 (setcdr marks (list (cdr marks))))
6011 (setq articles (cdr marks))
6012 (while (and articles
6013 (or (and (consp (car articles))
6014 (> min (cdar articles)))
6015 (and (numberp (car articles))
6016 (> min (car articles)))))
6017 (pop articles))
6018 (set var articles))
6019 ((eq mark 'unexist)
6020 (set var (cdr marks)))))))))
6022 (defun gnus-update-missing-marks (missing)
6023 "Go through the list of MISSING articles and remove them from the mark lists."
6024 (when missing
6025 (let (var m)
6026 ;; Go through all types.
6027 (dolist (elem gnus-article-mark-lists)
6028 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6029 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6030 (when (symbol-value var)
6031 ;; This list has articles. So we delete all missing
6032 ;; articles from it.
6033 (setq m missing)
6034 (while m
6035 (set var (delq (pop m) (symbol-value var))))))))))
6037 (defun gnus-update-marks ()
6038 "Enter the various lists of marked articles into the newsgroup info list."
6039 (let ((types gnus-article-mark-lists)
6040 (info (gnus-get-info gnus-newsgroup-name))
6041 type list newmarked symbol delta-marks)
6042 (when info
6043 ;; Add all marks lists to the list of marks lists.
6044 (while (setq type (pop types))
6045 (setq list (symbol-value
6046 (setq symbol
6047 (intern (format "gnus-newsgroup-%s" (car type))))))
6049 (when list
6050 ;; Get rid of the entries of the articles that have the
6051 ;; default score.
6052 (when (and (eq (cdr type) 'score)
6053 gnus-save-score
6054 list)
6055 (let* ((arts list)
6056 (prev (cons nil list))
6057 (all prev))
6058 (while arts
6059 (if (or (not (consp (car arts)))
6060 (= (cdar arts) gnus-summary-default-score))
6061 (setcdr prev (cdr arts))
6062 (setq prev arts))
6063 (setq arts (cdr arts)))
6064 (setq list (cdr all)))))
6066 ;; When exiting the group, everything that's previously been
6067 ;; unseen is now seen.
6068 (when (eq (cdr type) 'seen)
6069 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6071 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6072 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6074 (when (and (gnus-check-backend-function
6075 'request-set-mark gnus-newsgroup-name)
6076 (not (gnus-article-unpropagatable-p (cdr type))))
6077 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6078 ;; Don't do anything about marks for articles we
6079 ;; didn't actually get any headers for.
6080 (del
6081 (gnus-list-range-intersection
6082 gnus-newsgroup-articles
6083 (gnus-remove-from-range (copy-tree old) list)))
6084 (add
6085 (gnus-list-range-intersection
6086 gnus-newsgroup-articles
6087 (gnus-remove-from-range
6088 (copy-tree list) old))))
6089 (when add
6090 (push (list add 'add (list (cdr type))) delta-marks))
6091 (when del
6092 ;; Don't delete marks from outside the active range.
6093 ;; This shouldn't happen, but is a sanity check.
6094 (setq del (gnus-sorted-range-intersection
6095 (gnus-active gnus-newsgroup-name) del))
6096 (push (list del 'del (list (cdr type))) delta-marks))))
6098 (when (or list
6099 (eq (cdr type) 'unexist))
6100 (push (cons (cdr type) list) newmarked)))
6102 (when delta-marks
6103 (unless (gnus-check-group gnus-newsgroup-name)
6104 (error "Can't open server for %s" gnus-newsgroup-name))
6105 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6107 ;; Enter these new marks into the info of the group.
6108 (if (nthcdr 3 info)
6109 (setcar (nthcdr 3 info) newmarked)
6110 ;; Add the marks lists to the end of the info.
6111 (when newmarked
6112 (setcdr (nthcdr 2 info) (list newmarked))))
6114 ;; Cut off the end of the info if there's nothing else there.
6115 (let ((i 5))
6116 (while (and (> i 2)
6117 (not (nth i info)))
6118 (when (nthcdr (decf i) info)
6119 (setcdr (nthcdr i info) nil)))))))
6121 (defun gnus-set-mode-line (where)
6122 "Set the mode line of the article or summary buffers.
6123 If WHERE is `summary', the summary mode line format will be used."
6124 ;; Is this mode line one we keep updated?
6125 (when (and (memq where gnus-updated-mode-lines)
6126 (symbol-value
6127 (intern (format "gnus-%s-mode-line-format-spec" where))))
6128 (let (mode-string)
6129 ;; We evaluate this in the summary buffer since these
6130 ;; variables are buffer-local to that buffer.
6131 (with-current-buffer gnus-summary-buffer
6132 ;; We bind all these variables that are used in the `eval' form
6133 ;; below.
6134 (let* ((mformat (symbol-value
6135 (intern
6136 (format "gnus-%s-mode-line-format-spec" where))))
6137 (gnus-tmp-group-name (gnus-mode-string-quote
6138 (gnus-group-decoded-name
6139 gnus-newsgroup-name)))
6140 (gnus-tmp-article-number (or gnus-current-article 0))
6141 (gnus-tmp-unread gnus-newsgroup-unreads)
6142 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6143 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6144 (gnus-tmp-unread-and-unselected
6145 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6146 (zerop gnus-tmp-unselected))
6148 ((zerop gnus-tmp-unselected)
6149 (format "{%d more}" gnus-tmp-unread-and-unticked))
6150 (t (format "{%d(+%d) more}"
6151 gnus-tmp-unread-and-unticked
6152 gnus-tmp-unselected))))
6153 (gnus-tmp-subject
6154 (if (and gnus-current-headers
6155 (vectorp gnus-current-headers))
6156 (gnus-mode-string-quote
6157 (mail-header-subject gnus-current-headers))
6158 ""))
6159 bufname-length max-len
6160 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6161 (setq mode-string (eval mformat))
6162 (setq bufname-length (if (string-match "%b" mode-string)
6163 (- (length
6164 (buffer-name
6165 (if (eq where 'summary)
6167 (get-buffer gnus-article-buffer))))
6170 (setq max-len (max 4 (if gnus-mode-non-string-length
6171 (- (window-width)
6172 gnus-mode-non-string-length
6173 bufname-length)
6174 (length mode-string))))
6175 ;; We might have to chop a bit of the string off...
6176 (when (> (length mode-string) max-len)
6177 (setq mode-string
6178 (concat (truncate-string-to-width mode-string (- max-len 3))
6179 "...")))))
6180 ;; Update the mode line.
6181 (setq mode-line-buffer-identification
6182 (gnus-mode-line-buffer-identification (list mode-string)))
6183 (set-buffer-modified-p t))))
6185 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6186 "Go through the HEADERS list and add all Xrefs to a hash table.
6187 The resulting hash table is returned, or nil if no Xrefs were found."
6188 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6189 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6190 (xref-hashtb (gnus-make-hashtable))
6191 start group entry number xrefs header)
6192 (while headers
6193 (setq header (pop headers))
6194 (when (and (setq xrefs (mail-header-xref header))
6195 (not (memq (setq number (mail-header-number header))
6196 unreads)))
6197 (setq start 0)
6198 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6199 (setq start (match-end 0))
6200 (setq group (if prefix
6201 (concat prefix (substring xrefs (match-beginning 1)
6202 (match-end 1)))
6203 (substring xrefs (match-beginning 1) (match-end 1))))
6204 (setq number
6205 (string-to-number (substring xrefs (match-beginning 2)
6206 (match-end 2))))
6207 (if (setq entry (gnus-gethash group xref-hashtb))
6208 (setcdr entry (cons number (cdr entry)))
6209 (gnus-sethash group (cons number nil) xref-hashtb)))))
6210 (and start xref-hashtb)))
6212 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6213 "Look through all the headers and mark the Xrefs as read."
6214 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6215 name info xref-hashtb idlist method nth4)
6216 (with-current-buffer gnus-group-buffer
6217 (when (setq xref-hashtb
6218 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6219 (mapatoms
6220 (lambda (group)
6221 (unless (string= from-newsgroup (setq name (symbol-name group)))
6222 (setq idlist (symbol-value group))
6223 ;; Dead groups are not updated.
6224 (and (prog1
6225 (setq info (gnus-get-info name))
6226 (when (stringp (setq nth4 (gnus-info-method info)))
6227 (setq nth4 (gnus-server-to-method nth4))))
6228 ;; Only do the xrefs if the group has the same
6229 ;; select method as the group we have just read.
6230 (or (gnus-methods-equal-p
6231 nth4 (gnus-find-method-for-group from-newsgroup))
6232 virtual
6233 (equal nth4 (setq method (gnus-find-method-for-group
6234 from-newsgroup)))
6235 (and (equal (car nth4) (car method))
6236 (equal (nth 1 nth4) (nth 1 method))))
6237 gnus-use-cross-reference
6238 (or (not (eq gnus-use-cross-reference t))
6239 virtual
6240 ;; Only do cross-references on subscribed
6241 ;; groups, if that is what is wanted.
6242 (<= (gnus-info-level info) gnus-level-subscribed))
6243 (gnus-group-make-articles-read name idlist))))
6244 xref-hashtb)))))
6246 (defun gnus-compute-read-articles (group articles)
6247 (let* ((entry (gnus-group-entry group))
6248 (info (nth 2 entry))
6249 (active (gnus-active group))
6250 ninfo)
6251 (when entry
6252 ;; First peel off all invalid article numbers.
6253 (when active
6254 (let ((ids articles)
6255 id first)
6256 (while (setq id (pop ids))
6257 (when (and first (> id (cdr active)))
6258 ;; We'll end up in this situation in one particular
6259 ;; obscure situation. If you re-scan a group and get
6260 ;; a new article that is cross-posted to a different
6261 ;; group that has not been re-scanned, you might get
6262 ;; crossposted article that has a higher number than
6263 ;; Gnus believes possible. So we re-activate this
6264 ;; group as well. This might mean doing the
6265 ;; crossposting thingy will *increase* the number
6266 ;; of articles in some groups. Tsk, tsk.
6267 (setq active (or (gnus-activate-group group) active)))
6268 (when (or (> id (cdr active))
6269 (< id (car active)))
6270 (setq articles (delq id articles))))))
6271 ;; If the read list is nil, we init it.
6272 (if (and active
6273 (null (gnus-info-read info))
6274 (> (car active) 1))
6275 (setq ninfo (cons 1 (1- (car active))))
6276 (setq ninfo (gnus-info-read info)))
6277 ;; Then we add the read articles to the range.
6278 (gnus-add-to-range
6279 ninfo (setq articles (sort articles '<))))))
6281 (defun gnus-group-make-articles-read (group articles)
6282 "Update the info of GROUP to say that ARTICLES are read."
6283 (let* ((num 0)
6284 (entry (gnus-group-entry group))
6285 (info (nth 2 entry))
6286 (active (gnus-active group))
6287 (set-marks
6288 (gnus-method-option-p
6289 (gnus-find-method-for-group group)
6290 'server-marks))
6291 range)
6292 (if (not entry)
6293 ;; Group that Gnus doesn't know exists, but still allow the
6294 ;; backend to set marks.
6295 (when set-marks
6296 (gnus-request-set-mark
6297 group (list (list (gnus-compress-sequence (sort articles #'<))
6298 'add '(read)))))
6299 ;; Normal, subscribed groups.
6300 (setq range (gnus-compute-read-articles group articles))
6301 (with-current-buffer gnus-group-buffer
6302 (gnus-undo-register
6303 `(progn
6304 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6305 (gnus-info-set-read ',info ',(gnus-info-read info))
6306 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6307 (when ,set-marks
6308 (gnus-request-set-mark
6309 ,group (list (list ',range 'del '(read)))))
6310 (gnus-group-update-group ,group t))))
6311 ;; Add the read articles to the range.
6312 (gnus-info-set-read info range)
6313 (when set-marks
6314 (gnus-request-set-mark group (list (list range 'add '(read)))))
6315 ;; Then we have to re-compute how many unread
6316 ;; articles there are in this group.
6317 (when active
6318 (cond
6319 ((not range)
6320 (setq num (- (1+ (cdr active)) (car active))))
6321 ((not (listp (cdr range)))
6322 (setq num (- (cdr active) (- (1+ (cdr range))
6323 (car range)))))
6325 (while range
6326 (if (numberp (car range))
6327 (setq num (1+ num))
6328 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6329 (setq range (cdr range)))
6330 (setq num (- (cdr active) num))))
6331 ;; Update the number of unread articles.
6332 (setcar entry num)
6333 ;; Update the group buffer.
6334 (unless (gnus-ephemeral-group-p group)
6335 (gnus-group-update-group group t))))))
6337 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6338 (let ((cur nntp-server-buffer)
6339 (dependencies
6340 (or dependencies
6341 (with-current-buffer gnus-summary-buffer
6342 gnus-newsgroup-dependencies)))
6343 headers id end ref number
6344 (mail-parse-charset gnus-newsgroup-charset)
6345 (mail-parse-ignored-charsets
6346 (save-current-buffer (condition-case nil
6347 (set-buffer gnus-summary-buffer)
6348 (error))
6349 gnus-newsgroup-ignored-charsets)))
6350 (with-current-buffer nntp-server-buffer
6351 ;; Translate all TAB characters into SPACE characters.
6352 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6353 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6354 (ietf-drums-unfold-fws)
6355 (gnus-run-hooks 'gnus-parse-headers-hook)
6356 (let ((case-fold-search t)
6357 in-reply-to header p lines chars)
6358 (goto-char (point-min))
6359 ;; Search to the beginning of the next header. Error messages
6360 ;; do not begin with 2 or 3.
6361 (while (re-search-forward "^[23][0-9]+ " nil t)
6362 (setq id nil
6363 ref nil)
6364 ;; This implementation of this function, with nine
6365 ;; search-forwards instead of the one re-search-forward and
6366 ;; a case (which basically was the old function) is actually
6367 ;; about twice as fast, even though it looks messier. You
6368 ;; can't have everything, I guess. Speed and elegance
6369 ;; doesn't always go hand in hand.
6370 (setq
6371 header
6372 (vector
6373 ;; Number.
6374 (prog1
6375 (setq number (read cur))
6376 (end-of-line)
6377 (setq p (point))
6378 (narrow-to-region (point)
6379 (or (and (search-forward "\n.\n" nil t)
6380 (- (point) 2))
6381 (point))))
6382 ;; Subject.
6383 (progn
6384 (goto-char p)
6385 (if (search-forward "\nsubject:" nil t)
6386 (funcall gnus-decode-encoded-word-function
6387 (nnheader-header-value))
6388 "(none)"))
6389 ;; From.
6390 (progn
6391 (goto-char p)
6392 (if (search-forward "\nfrom:" nil t)
6393 (funcall gnus-decode-encoded-address-function
6394 (nnheader-header-value))
6395 "(nobody)"))
6396 ;; Date.
6397 (progn
6398 (goto-char p)
6399 (if (search-forward "\ndate:" nil t)
6400 (nnheader-header-value) ""))
6401 ;; Message-ID.
6402 (progn
6403 (goto-char p)
6404 (setq id (if (re-search-forward
6405 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6406 ;; We do it this way to make sure the Message-ID
6407 ;; is (somewhat) syntactically valid.
6408 (buffer-substring (match-beginning 1)
6409 (match-end 1))
6410 ;; If there was no message-id, we just fake one
6411 ;; to make subsequent routines simpler.
6412 (nnheader-generate-fake-message-id number))))
6413 ;; References.
6414 (progn
6415 (goto-char p)
6416 (if (search-forward "\nreferences:" nil t)
6417 (progn
6418 (setq end (point))
6419 (prog1
6420 (nnheader-header-value)
6421 (setq ref
6422 (buffer-substring
6423 (progn
6424 (end-of-line)
6425 (search-backward ">" end t)
6426 (1+ (point)))
6427 (progn
6428 (search-backward "<" end t)
6429 (point))))))
6430 ;; Get the references from the in-reply-to header if there
6431 ;; were no references and the in-reply-to header looks
6432 ;; promising.
6433 (if (and (search-forward "\nin-reply-to:" nil t)
6434 (setq in-reply-to (nnheader-header-value))
6435 (string-match "<[^>]+>" in-reply-to))
6436 (let (ref2)
6437 (setq ref (substring in-reply-to (match-beginning 0)
6438 (match-end 0)))
6439 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6440 (setq ref2 (substring in-reply-to (match-beginning 0)
6441 (match-end 0)))
6442 (when (> (length ref2) (length ref))
6443 (setq ref ref2)))
6444 ref)
6445 (setq ref nil))))
6446 ;; Chars.
6447 (progn
6448 (goto-char p)
6449 (if (search-forward "\nchars: " nil t)
6450 (if (numberp (setq chars (ignore-errors (read cur))))
6451 chars -1)
6452 -1))
6453 ;; Lines.
6454 (progn
6455 (goto-char p)
6456 (if (search-forward "\nlines: " nil t)
6457 (if (numberp (setq lines (ignore-errors (read cur))))
6458 lines -1)
6459 -1))
6460 ;; Xref.
6461 (progn
6462 (goto-char p)
6463 (and (search-forward "\nxref:" nil t)
6464 (nnheader-header-value)))
6465 ;; Extra.
6466 (when gnus-extra-headers
6467 (let ((extra gnus-extra-headers)
6468 out)
6469 (while extra
6470 (goto-char p)
6471 (when (search-forward
6472 (concat "\n" (symbol-name (car extra)) ":") nil t)
6473 (push (cons (car extra) (nnheader-header-value))
6474 out))
6475 (pop extra))
6476 out))))
6477 (when (equal id ref)
6478 (setq ref nil))
6480 (when gnus-alter-header-function
6481 (funcall gnus-alter-header-function header)
6482 (setq id (mail-header-id header)
6483 ref (gnus-parent-id (mail-header-references header))))
6485 (when (setq header
6486 (gnus-dependencies-add-header
6487 header dependencies force-new))
6488 (push header headers))
6489 (goto-char (point-max))
6490 (widen))
6491 (nreverse headers)))))
6493 ;; Goes through the xover lines and returns a list of vectors
6494 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6495 force-new dependencies
6496 group also-fetch-heads)
6497 "Parse the news overview data in the server buffer.
6498 Return a list of headers that match SEQUENCE (see
6499 `nntp-retrieve-headers')."
6500 ;; Get the Xref when the users reads the articles since most/some
6501 ;; NNTP servers do not include Xrefs when using XOVER.
6502 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6503 (let ((mail-parse-charset gnus-newsgroup-charset)
6504 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6505 (cur nntp-server-buffer)
6506 (dependencies (or dependencies gnus-newsgroup-dependencies))
6507 (allp (cond
6508 ((eq gnus-read-all-available-headers t)
6510 ((and (stringp gnus-read-all-available-headers)
6511 group)
6512 (string-match gnus-read-all-available-headers group))
6514 nil)))
6515 number headers header)
6516 (with-current-buffer nntp-server-buffer
6517 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6518 ;; Allow the user to mangle the headers before parsing them.
6519 (gnus-run-hooks 'gnus-parse-headers-hook)
6520 (goto-char (point-min))
6521 (gnus-parse-without-error
6522 (while (and (or sequence allp)
6523 (not (eobp)))
6524 (setq number (read cur))
6525 (when (not allp)
6526 (while (and sequence
6527 (< (car sequence) number))
6528 (setq sequence (cdr sequence))))
6529 (when (and (or allp
6530 (and sequence
6531 (eq number (car sequence))))
6532 (progn
6533 (setq sequence (cdr sequence))
6534 (setq header (inline
6535 (gnus-nov-parse-line
6536 number dependencies force-new)))))
6537 (push header headers))
6538 (forward-line 1)))
6539 ;; A common bug in inn is that if you have posted an article and
6540 ;; then retrieves the active file, it will answer correctly --
6541 ;; the new article is included. However, a NOV entry for the
6542 ;; article may not have been generated yet, so this may fail.
6543 ;; We work around this problem by retrieving the last few
6544 ;; headers using HEAD.
6545 (if (or (not also-fetch-heads)
6546 (not sequence))
6547 ;; We (probably) got all the headers.
6548 (nreverse headers)
6549 (let ((gnus-nov-is-evil t))
6550 (nconc
6551 (nreverse headers)
6552 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6553 (gnus-get-newsgroup-headers))))))))
6555 (defun gnus-article-get-xrefs ()
6556 "Fill in the Xref value in `gnus-current-headers', if necessary.
6557 This is meant to be called in `gnus-article-internal-prepare-hook'."
6558 (let ((headers (with-current-buffer gnus-summary-buffer
6559 gnus-current-headers)))
6560 (or (not gnus-use-cross-reference)
6561 (not headers)
6562 (and (mail-header-xref headers)
6563 (not (string= (mail-header-xref headers) "")))
6564 (let ((case-fold-search t)
6565 xref)
6566 (save-restriction
6567 (nnheader-narrow-to-headers)
6568 (goto-char (point-min))
6569 (when (or (and (not (eobp))
6570 (eq (downcase (char-after)) ?x)
6571 (looking-at "Xref:"))
6572 (search-forward "\nXref:" nil t))
6573 (goto-char (1+ (match-end 0)))
6574 (setq xref (buffer-substring (point) (point-at-eol)))
6575 (mail-header-set-xref headers xref)))))))
6577 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6578 "Find article ID and insert the summary line for that article.
6579 OLD-HEADER can either be a header or a line number to insert
6580 the subject line on.
6581 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6582 and OLD-HEADER will be used when the summary line is inserted,
6583 too, instead of trying to fetch new headers."
6584 (let* ((line (and (numberp old-header) old-header))
6585 (old-header (and (vectorp old-header) old-header))
6586 (header (cond ((and old-header use-old-header)
6587 old-header)
6588 ((and (numberp id)
6589 (gnus-number-to-header id))
6590 (gnus-number-to-header id))
6592 (gnus-read-header id))))
6593 (number (and (numberp id) id))
6595 (when header
6596 ;; Rebuild the thread that this article is part of and go to the
6597 ;; article we have fetched.
6598 (when (and (not gnus-show-threads)
6599 old-header)
6600 (when (and number
6601 (setq d (gnus-data-find (mail-header-number old-header))))
6602 (goto-char (gnus-data-pos d))
6603 (gnus-data-remove
6604 number
6605 (- (point-at-bol)
6606 (prog1
6607 (1+ (point-at-eol))
6608 (gnus-delete-line))))))
6609 ;; Remove list identifiers from subject.
6610 (let ((gnus-newsgroup-headers (list header)))
6611 (gnus-summary-remove-list-identifiers))
6612 (when old-header
6613 (mail-header-set-number header (mail-header-number old-header)))
6614 (setq gnus-newsgroup-sparse
6615 (delq (setq number (mail-header-number header))
6616 gnus-newsgroup-sparse))
6617 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6618 (push number gnus-newsgroup-limit)
6619 (gnus-rebuild-thread (mail-header-id header) line)
6620 (gnus-summary-goto-subject number nil t))
6621 (when (and (numberp number)
6622 (> number 0))
6623 ;; We have to update the boundaries even if we can't fetch the
6624 ;; article if ID is a number -- so that the next `P' or `N'
6625 ;; command will fetch the previous (or next) article even
6626 ;; if the one we tried to fetch this time has been canceled.
6627 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6628 (setq gnus-newsgroup-end number))
6629 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6630 (setq gnus-newsgroup-begin number))
6631 (setq gnus-newsgroup-unselected
6632 (delq number gnus-newsgroup-unselected)))
6633 ;; Report back a success?
6634 (and header (mail-header-number header))))
6636 ;;; Process/prefix in the summary buffer
6638 (defun gnus-summary-work-articles (n)
6639 "Return a list of articles to be worked upon.
6640 The prefix argument, the list of process marked articles, and the
6641 current article will be taken into consideration."
6642 (with-current-buffer gnus-summary-buffer
6643 (cond
6645 ;; A numerical prefix has been given.
6646 (setq n (prefix-numeric-value n))
6647 (let ((backward (< n 0))
6648 (n (abs (prefix-numeric-value n)))
6649 articles article)
6650 (save-excursion
6651 (while
6652 (and (> n 0)
6653 (push (setq article (gnus-summary-article-number))
6654 articles)
6655 (if backward
6656 (gnus-summary-find-prev nil article)
6657 (gnus-summary-find-next nil article)))
6658 (decf n)))
6659 (nreverse articles)))
6660 ((and (and transient-mark-mode mark-active) (mark))
6661 (message "region active")
6662 ;; Work on the region between point and mark.
6663 (let ((max (max (point) (mark)))
6664 articles article)
6665 (save-excursion
6666 (goto-char (min (point) (mark)))
6667 (while
6668 (and
6669 (push (setq article (gnus-summary-article-number)) articles)
6670 (gnus-summary-find-next nil article)
6671 (< (point) max)))
6672 (nreverse articles))))
6673 (gnus-newsgroup-processable
6674 ;; There are process-marked articles present.
6675 ;; Save current state.
6676 (gnus-summary-save-process-mark)
6677 ;; Return the list.
6678 (reverse gnus-newsgroup-processable))
6680 ;; Just return the current article.
6681 (list (gnus-summary-article-number))))))
6683 (defmacro gnus-summary-iterate (arg &rest forms)
6684 "Iterate over the process/prefixed articles and do FORMS.
6685 ARG is the interactive prefix given to the command. FORMS will be
6686 executed with point over the summary line of the articles."
6687 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6688 `(let ((,articles (gnus-summary-work-articles ,arg)))
6689 (while ,articles
6690 (gnus-summary-goto-subject (car ,articles))
6691 ,@forms
6692 (pop ,articles)))))
6694 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6695 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6697 (defun gnus-summary-save-process-mark ()
6698 "Push the current set of process marked articles on the stack."
6699 (interactive)
6700 (push (copy-sequence gnus-newsgroup-processable)
6701 gnus-newsgroup-process-stack))
6703 (defun gnus-summary-kill-process-mark ()
6704 "Push the current set of process marked articles on the stack and unmark."
6705 (interactive)
6706 (gnus-summary-save-process-mark)
6707 (gnus-summary-unmark-all-processable))
6709 (defun gnus-summary-yank-process-mark ()
6710 "Pop the last process mark state off the stack and restore it."
6711 (interactive)
6712 (unless gnus-newsgroup-process-stack
6713 (error "Empty mark stack"))
6714 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6716 (defun gnus-summary-process-mark-set (set)
6717 "Make SET into the current process marked articles."
6718 (gnus-summary-unmark-all-processable)
6719 (mapc 'gnus-summary-set-process-mark set))
6721 ;;; Searching and stuff
6723 (defun gnus-summary-search-group (&optional backward use-level)
6724 "Search for next unread newsgroup.
6725 If optional argument BACKWARD is non-nil, search backward instead."
6726 (with-current-buffer gnus-group-buffer
6727 (when (gnus-group-search-forward
6728 backward nil (if use-level (gnus-group-group-level) nil))
6729 (gnus-group-group-name))))
6731 (defun gnus-summary-best-group (&optional exclude-group)
6732 "Find the name of the best unread group.
6733 If EXCLUDE-GROUP, do not go to this group."
6734 (with-current-buffer gnus-group-buffer
6735 (save-excursion
6736 (gnus-group-best-unread-group exclude-group))))
6738 (defun gnus-summary-find-next (&optional unread article backward)
6739 (if backward
6740 (gnus-summary-find-prev unread article)
6741 (let* ((dummy (gnus-summary-article-intangible-p))
6742 (article (or article (gnus-summary-article-number)))
6743 (data (gnus-data-find-list article))
6744 result)
6745 (when (and (not dummy)
6746 (or (not gnus-summary-check-current)
6747 (not unread)
6748 (not (gnus-data-unread-p (car data)))))
6749 (setq data (cdr data)))
6750 (when (setq result
6751 (if unread
6752 (progn
6753 (while data
6754 (unless (memq (gnus-data-number (car data))
6755 (cond
6756 ((eq gnus-auto-goto-ignores
6757 'always-undownloaded)
6758 gnus-newsgroup-undownloaded)
6759 (gnus-plugged
6760 nil)
6761 ((eq gnus-auto-goto-ignores
6762 'unfetched)
6763 gnus-newsgroup-unfetched)
6764 ((eq gnus-auto-goto-ignores
6765 'undownloaded)
6766 gnus-newsgroup-undownloaded)))
6767 (when (gnus-data-unread-p (car data))
6768 (setq result (car data)
6769 data nil)))
6770 (setq data (cdr data)))
6771 result)
6772 (car data)))
6773 (goto-char (gnus-data-pos result))
6774 (gnus-data-number result)))))
6776 (defun gnus-summary-find-prev (&optional unread article)
6777 (let* ((eobp (eobp))
6778 (article (or article (gnus-summary-article-number)))
6779 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6780 result)
6781 (when (and (not eobp)
6782 (or (not gnus-summary-check-current)
6783 (not unread)
6784 (not (gnus-data-unread-p (car data)))))
6785 (setq data (cdr data)))
6786 (when (setq result
6787 (if unread
6788 (progn
6789 (while data
6790 (unless (memq (gnus-data-number (car data))
6791 (cond
6792 ((eq gnus-auto-goto-ignores
6793 'always-undownloaded)
6794 gnus-newsgroup-undownloaded)
6795 (gnus-plugged
6796 nil)
6797 ((eq gnus-auto-goto-ignores
6798 'unfetched)
6799 gnus-newsgroup-unfetched)
6800 ((eq gnus-auto-goto-ignores
6801 'undownloaded)
6802 gnus-newsgroup-undownloaded)))
6803 (when (gnus-data-unread-p (car data))
6804 (setq result (car data)
6805 data nil)))
6806 (setq data (cdr data)))
6807 result)
6808 (car data)))
6809 (goto-char (gnus-data-pos result))
6810 (gnus-data-number result))))
6812 (defun gnus-summary-find-subject (subject &optional unread backward article)
6813 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6814 (article (or article (gnus-summary-article-number)))
6815 (articles (gnus-data-list backward))
6816 (arts (gnus-data-find-list article articles))
6817 result)
6818 (when (or (not gnus-summary-check-current)
6819 (not unread)
6820 (not (gnus-data-unread-p (car arts))))
6821 (setq arts (cdr arts)))
6822 (while arts
6823 (and (or (not unread)
6824 (gnus-data-unread-p (car arts)))
6825 (vectorp (gnus-data-header (car arts)))
6826 (gnus-subject-equal
6827 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6828 (setq result (car arts)
6829 arts nil))
6830 (setq arts (cdr arts)))
6831 (and result
6832 (goto-char (gnus-data-pos result))
6833 (gnus-data-number result))))
6835 (defun gnus-summary-search-forward (&optional unread subject backward)
6836 "Search forward for an article.
6837 If UNREAD, look for unread articles. If SUBJECT, look for
6838 articles with that subject. If BACKWARD, search backward instead."
6839 (cond (subject (gnus-summary-find-subject subject unread backward))
6840 (backward (gnus-summary-find-prev unread))
6841 (t (gnus-summary-find-next unread))))
6843 (defun gnus-recenter (&optional n)
6844 "Center point in window and redisplay frame.
6845 Also do horizontal recentering."
6846 (interactive "P")
6847 (when (and gnus-auto-center-summary
6848 (not (eq gnus-auto-center-summary 'vertical)))
6849 (gnus-horizontal-recenter))
6850 (recenter-top-bottom n))
6852 (put 'gnus-recenter 'isearch-scroll t)
6854 (defun gnus-forward-line-ignore-invisible (n)
6855 "Move N lines forward (backward if N is negative).
6856 Like forward-line, but skip over (and don't count) invisible lines."
6857 (let (done)
6858 (while (and (> n 0) (not done))
6859 ;; If the following character is currently invisible,
6860 ;; skip all characters with that same `invisible' property value.
6861 (while (invisible-p (point))
6862 (goto-char (next-char-property-change (point))))
6863 (forward-line 1)
6864 (if (eobp)
6865 (setq done t)
6866 (setq n (1- n))))
6867 (while (and (< n 0) (not done))
6868 (forward-line -1)
6869 (if (bobp) (setq done t)
6870 (setq n (1+ n))
6871 (while (and (not (bobp)) (invisible-p (1- (point))))
6872 (goto-char (previous-char-property-change (point))))))))
6874 (defun gnus-summary-recenter ()
6875 "Center point in the summary window.
6876 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6877 displayed, no centering will be performed."
6878 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6879 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6880 (interactive)
6881 ;; The user has to want it.
6882 (when gnus-auto-center-summary
6883 (let* ((top (cond ((< (window-height) 4) 0)
6884 ((< (window-height) 7) 1)
6885 (t (if (numberp gnus-auto-center-summary)
6886 gnus-auto-center-summary
6887 (/ (1- (window-height)) 2)))))
6888 (height (1- (window-height)))
6889 (bottom (save-excursion
6890 (goto-char (point-max))
6891 (gnus-forward-line-ignore-invisible (- height))
6892 (point)))
6893 (window (get-buffer-window (current-buffer))))
6894 (when (get-buffer-window gnus-article-buffer)
6895 ;; Only do recentering when the article buffer is displayed,
6896 ;; Set the window start to either `bottom', which is the biggest
6897 ;; possible valid number, or the second line from the top,
6898 ;; whichever is the least.
6899 (let ((top-pos (save-excursion
6900 (gnus-forward-line-ignore-invisible (- top))
6901 (point))))
6902 (if (> bottom top-pos)
6903 ;; Keep the second line from the top visible
6904 (set-window-start window top-pos)
6905 ;; Try to keep the bottom line visible; if it's partially
6906 ;; obscured, either scroll one more line to make it fully
6907 ;; visible, or revert to using TOP-POS.
6908 (save-excursion
6909 (goto-char (point-max))
6910 (gnus-forward-line-ignore-invisible -1)
6911 (let ((last-line-start (point)))
6912 (goto-char bottom)
6913 (set-window-start window (point) t)
6914 (when (not (pos-visible-in-window-p last-line-start window))
6915 (gnus-forward-line-ignore-invisible 1)
6916 (set-window-start window (min (point) top-pos) t)))))))
6917 ;; Do horizontal recentering while we're at it.
6918 (when (and (get-buffer-window (current-buffer) t)
6919 (not (eq gnus-auto-center-summary 'vertical)))
6920 (let ((selected (selected-window)))
6921 (select-window (get-buffer-window (current-buffer) t))
6922 (gnus-summary-position-point)
6923 (gnus-horizontal-recenter)
6924 (select-window selected))))))
6926 (defun gnus-summary-jump-to-group (newsgroup)
6927 "Move point to NEWSGROUP in group mode buffer."
6928 ;; Keep update point of group mode buffer if visible.
6929 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6930 (save-window-excursion
6931 ;; Take care of tree window mode.
6932 (when (get-buffer-window gnus-group-buffer)
6933 (pop-to-buffer gnus-group-buffer))
6934 (gnus-group-jump-to-group newsgroup))
6935 (save-excursion
6936 ;; Take care of tree window mode.
6937 (if (get-buffer-window gnus-group-buffer 0)
6938 (pop-to-buffer gnus-group-buffer t)
6939 (set-buffer gnus-group-buffer))
6940 (gnus-group-jump-to-group newsgroup))))
6942 ;; This function returns a list of article numbers based on the
6943 ;; difference between the ranges of read articles in this group and
6944 ;; the range of active articles.
6945 (defun gnus-list-of-unread-articles (group)
6946 (let* ((read (gnus-info-read (gnus-get-info group)))
6947 (active (or (gnus-active group) (gnus-activate-group group)))
6948 (last (or (cdr active)
6949 (error "Group %s couldn't be activated " group)))
6950 (bottom (if gnus-newsgroup-maximum-articles
6951 (max (car active)
6952 (- last gnus-newsgroup-maximum-articles -1))
6953 (car active)))
6954 first nlast unread)
6955 ;; If none are read, then all are unread.
6956 (if (not read)
6957 (setq first bottom)
6958 ;; If the range of read articles is a single range, then the
6959 ;; first unread article is the article after the last read
6960 ;; article. Sounds logical, doesn't it?
6961 (if (and (not (listp (cdr read)))
6962 (or (< (car read) bottom)
6963 (progn (setq read (list read))
6964 nil)))
6965 (setq first (max bottom (1+ (cdr read))))
6966 ;; `read' is a list of ranges.
6967 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6968 (caar read)))
6970 (setq first bottom))
6971 (while read
6972 (when first
6973 (while (< first nlast)
6974 (setq unread (cons first unread)
6975 first (1+ first))))
6976 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6977 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6978 (setq read (cdr read)))))
6979 ;; And add the last unread articles.
6980 (while (<= first last)
6981 (setq unread (cons first unread)
6982 first (1+ first)))
6983 ;; Return the list of unread articles.
6984 (delq 0 (nreverse unread))))
6986 (defun gnus-list-of-read-articles (group)
6987 "Return a list of unread, unticked and non-dormant articles."
6988 (let* ((info (gnus-get-info group))
6989 (marked (gnus-info-marks info))
6990 (active (gnus-active group)))
6991 (and info active
6992 (gnus-list-range-difference
6993 (gnus-list-range-difference
6994 (gnus-sorted-complement
6995 (gnus-uncompress-range
6996 (if gnus-newsgroup-maximum-articles
6997 (cons (max (car active)
6998 (- (cdr active)
6999 gnus-newsgroup-maximum-articles
7000 -1))
7001 (cdr active))
7002 active))
7003 (gnus-list-of-unread-articles group))
7004 (cdr (assq 'dormant marked)))
7005 (cdr (assq 'tick marked))))))
7007 ;; This function returns a sequence of article numbers based on the
7008 ;; difference between the ranges of read articles in this group and
7009 ;; the range of active articles.
7010 (defun gnus-sequence-of-unread-articles (group)
7011 (let* ((read (gnus-info-read (gnus-get-info group)))
7012 (active (or (gnus-active group) (gnus-activate-group group)))
7013 (last (cdr active))
7014 (bottom (if gnus-newsgroup-maximum-articles
7015 (max (car active)
7016 (- last gnus-newsgroup-maximum-articles -1))
7017 (car active)))
7018 first nlast unread)
7019 ;; If none are read, then all are unread.
7020 (if (not read)
7021 (setq first bottom)
7022 ;; If the range of read articles is a single range, then the
7023 ;; first unread article is the article after the last read
7024 ;; article. Sounds logical, doesn't it?
7025 (if (and (not (listp (cdr read)))
7026 (or (< (car read) bottom)
7027 (progn (setq read (list read))
7028 nil)))
7029 (setq first (max bottom (1+ (cdr read))))
7030 ;; `read' is a list of ranges.
7031 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7032 (caar read)))
7034 (setq first bottom))
7035 (while read
7036 (when first
7037 (push (cons first nlast) unread))
7038 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7039 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7040 (setq read (cdr read)))))
7041 ;; And add the last unread articles.
7042 (cond ((not (and first last))
7043 nil)
7044 ((< first last)
7045 (push (cons first last) unread))
7046 ((= first last)
7047 (push first unread)))
7048 ;; Return the sequence of unread articles.
7049 (delq 0 (nreverse unread))))
7051 ;; Various summary commands
7053 (defun gnus-summary-select-article-buffer ()
7054 "Reconfigure windows to show the article buffer.
7055 If `gnus-widen-article-window' is set, show only the article
7056 buffer."
7057 (interactive)
7058 (if (not (gnus-buffer-live-p gnus-article-buffer))
7059 (error "There is no article buffer for this summary buffer")
7060 (or (get-buffer-window gnus-article-buffer)
7061 (eq gnus-current-article (gnus-summary-article-number))
7062 (gnus-summary-show-article))
7063 (gnus-configure-windows
7064 (if gnus-widen-article-window
7065 'only-article
7066 'article)
7068 (select-window (get-buffer-window gnus-article-buffer))))
7070 (defun gnus-summary-universal-argument (arg)
7071 "Perform any operation on all articles that are process/prefixed."
7072 (interactive "P")
7073 (let ((articles (gnus-summary-work-articles arg))
7074 func article)
7075 (if (eq
7076 (setq
7077 func
7078 (key-binding
7079 (read-key-sequence
7080 (substitute-command-keys
7081 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7082 'undefined)
7083 (gnus-error 1 "Undefined key")
7084 (save-excursion
7085 (while articles
7086 (gnus-summary-goto-subject (setq article (pop articles)))
7087 (let (gnus-newsgroup-processable)
7088 (command-execute func))
7089 (gnus-summary-remove-process-mark article)))))
7090 (gnus-summary-position-point))
7092 (define-obsolete-function-alias
7093 'gnus-summary-toggle-truncation 'toggle-truncate-lines "26.1")
7095 (defun gnus-summary-find-for-reselect ()
7096 "Return the number of an article to stay on across a reselect.
7097 The current article is considered, then following articles, then previous
7098 articles. An article is sought which is not canceled and isn't a temporary
7099 insertion from another group. If there's no such then return a dummy 0."
7100 (let (found)
7101 (dolist (rev '(nil t))
7102 (unless found ; don't demand the reverse list if we don't need it
7103 (let ((data (gnus-data-find-list
7104 (gnus-summary-article-number) (gnus-data-list rev))))
7105 (while (and data (not found))
7106 (if (and (< 0 (gnus-data-number (car data)))
7107 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7108 (setq found (gnus-data-number (car data))))
7109 (setq data (cdr data))))))
7110 (or found 0)))
7112 (defun gnus-summary-reselect-current-group (&optional all rescan)
7113 "Exit and then reselect the current newsgroup.
7114 The prefix argument ALL means to select all articles."
7115 (interactive "P")
7116 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7117 (error "Ephemeral groups can't be reselected"))
7118 (let ((current-subject (gnus-summary-find-for-reselect))
7119 (group gnus-newsgroup-name))
7120 (setq gnus-newsgroup-begin nil)
7121 (gnus-summary-exit nil 'leave-hidden)
7122 ;; We have to adjust the point of group mode buffer because
7123 ;; point was moved to the next unread newsgroup by exiting.
7124 (gnus-summary-jump-to-group group)
7125 (when rescan
7126 (save-excursion
7127 (gnus-group-get-new-news-this-group 1)))
7128 (gnus-group-read-group all t)
7129 (gnus-summary-goto-subject current-subject nil t)))
7131 (defun gnus-summary-rescan-group (&optional all)
7132 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7133 (interactive "P")
7134 (let ((config gnus-current-window-configuration))
7135 (gnus-summary-reselect-current-group all t)
7136 (gnus-configure-windows config)
7137 (when (eq config 'article)
7138 (gnus-summary-select-article))))
7140 (defun gnus-summary-update-info (&optional non-destructive)
7141 (save-excursion
7142 (let ((group gnus-newsgroup-name))
7143 (when group
7144 (when gnus-newsgroup-kill-headers
7145 (setq gnus-newsgroup-killed
7146 (gnus-compress-sequence
7147 (gnus-sorted-union
7148 (gnus-list-range-intersection
7149 gnus-newsgroup-unselected gnus-newsgroup-killed)
7150 gnus-newsgroup-unreads)
7151 t)))
7152 (unless (listp (cdr gnus-newsgroup-killed))
7153 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7154 (let ((headers gnus-newsgroup-headers)
7155 (ephemeral-p (gnus-ephemeral-group-p group))
7156 info)
7157 (unless ephemeral-p
7158 (setq info (copy-sequence (gnus-get-info group))
7159 info (delq (gnus-info-params info) info)))
7160 ;; Set the new ranges of read articles.
7161 (with-current-buffer gnus-group-buffer
7162 (gnus-undo-force-boundary))
7163 (gnus-update-read-articles
7164 group (gnus-sorted-union
7165 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7166 ;; Set the current article marks.
7167 (let ((gnus-newsgroup-scored
7168 (if (and (not gnus-save-score)
7169 (not non-destructive))
7171 gnus-newsgroup-scored)))
7172 (save-excursion
7173 (gnus-update-marks)))
7174 ;; Do the cross-ref thing.
7175 (when gnus-use-cross-reference
7176 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7177 ;; Do not switch windows but change the buffer to work.
7178 (set-buffer gnus-group-buffer)
7179 (unless ephemeral-p
7180 (gnus-group-update-group
7181 group nil
7182 (equal info
7183 (setq info (copy-sequence (gnus-get-info group))
7184 info (delq (gnus-info-params info) info))))))))))
7186 (defun gnus-summary-save-newsrc (&optional force)
7187 "Save the current number of read/marked articles in the dribble buffer.
7188 The dribble buffer will then be saved.
7189 If FORCE (the prefix), also save the .newsrc file(s)."
7190 (interactive "P")
7191 (gnus-summary-update-info t)
7192 (if force
7193 (gnus-save-newsrc-file)
7194 (gnus-dribble-save)))
7196 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7197 (declare-function gnus-article-stop-animations "gnus-art" ())
7199 (defun gnus-summary-exit (&optional temporary leave-hidden)
7200 "Exit reading current newsgroup, and then return to group selection mode.
7201 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7202 (interactive)
7203 (gnus-set-global-variables)
7204 (when (gnus-buffer-live-p gnus-article-buffer)
7205 (with-current-buffer gnus-article-buffer
7206 (mm-destroy-parts gnus-article-mime-handles)
7207 ;; Set it to nil for safety reason.
7208 (setq gnus-article-mime-handle-alist nil)
7209 (setq gnus-article-mime-handles nil)))
7210 (gnus-kill-save-kill-buffer)
7211 (gnus-async-halt-prefetch)
7212 (let* ((group gnus-newsgroup-name)
7213 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7214 (gnus-group-is-exiting-p t)
7215 (article-buffer gnus-article-buffer)
7216 (original-article-buffer gnus-original-article-buffer)
7217 (mode major-mode)
7218 (group-point nil)
7219 (buf (current-buffer))
7220 ;; `gnus-single-article-buffer' is nil buffer-locally in
7221 ;; ephemeral group of which summary buffer will be killed,
7222 ;; but the global value may be non-nil.
7223 (single-article-buffer gnus-single-article-buffer))
7224 (unless quit-config
7225 ;; Do adaptive scoring, and possibly save score files.
7226 (when gnus-newsgroup-adaptive
7227 (gnus-score-adaptive))
7228 (when gnus-use-scoring
7229 (gnus-score-save)))
7230 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7231 (when gnus-use-cache
7232 (gnus-cache-possibly-remove-articles)
7233 (gnus-cache-save-buffers))
7234 (gnus-async-prefetch-remove-group group)
7235 (when gnus-suppress-duplicates
7236 (gnus-dup-enter-articles))
7237 (when gnus-use-trees
7238 (gnus-tree-close))
7239 (when gnus-use-cache
7240 (gnus-cache-write-active))
7241 ;; Remove entries for this group.
7242 (nnmail-purge-split-history (gnus-group-real-name group))
7243 ;; Make all changes in this group permanent.
7244 (unless quit-config
7245 (gnus-run-hooks 'gnus-exit-group-hook)
7246 (gnus-summary-update-info))
7247 (gnus-close-group group)
7248 ;; Make sure where we were, and go to next newsgroup.
7249 (when (buffer-live-p (get-buffer gnus-group-buffer))
7250 (set-buffer gnus-group-buffer))
7251 (unless quit-config
7252 (gnus-group-jump-to-group group))
7253 (gnus-run-hooks 'gnus-summary-exit-hook)
7254 (unless (or quit-config
7255 (not gnus-summary-next-group-on-exit)
7256 ;; If this group has disappeared from the summary
7257 ;; buffer, don't skip forwards.
7258 (not (string= group (gnus-group-group-name))))
7259 (gnus-group-next-unread-group 1))
7260 (setq group-point (point))
7261 (gnus-article-stop-animations)
7262 (if temporary
7263 nil ;Nothing to do.
7264 (set-buffer buf)
7265 (if (not gnus-kill-summary-on-exit)
7266 (progn
7267 (gnus-deaden-summary)
7268 (setq mode nil))
7269 (when (get-buffer gnus-article-buffer)
7270 (bury-buffer gnus-article-buffer))
7271 ;; Return to group mode buffer.
7272 (when (eq mode 'gnus-summary-mode)
7273 (gnus-kill-buffer buf)))
7275 (setq gnus-current-select-method gnus-select-method)
7276 (when (gnus-buffer-live-p gnus-group-buffer)
7277 (set-buffer gnus-group-buffer))
7278 (if quit-config
7279 (gnus-handle-ephemeral-exit quit-config)
7280 (goto-char group-point)
7281 ;; If gnus-group-buffer is already displayed, make sure we also move
7282 ;; the cursor in the window that displays it.
7283 (let ((win (get-buffer-window (current-buffer) 0)))
7284 (if win (set-window-point win (point))))
7285 (unless leave-hidden
7286 (gnus-configure-windows 'group 'force)))
7288 ;; If we have several article buffers, we kill them at exit.
7289 (unless single-article-buffer
7290 (when (gnus-buffer-live-p article-buffer)
7291 (with-current-buffer article-buffer
7292 ;; Don't kill sticky article buffers
7293 (unless (eq major-mode 'gnus-sticky-article-mode)
7294 (gnus-kill-buffer article-buffer)
7295 (setq gnus-article-current nil))))
7296 (gnus-kill-buffer original-article-buffer))
7298 ;; Clear the current group name.
7299 (unless quit-config
7300 (setq gnus-newsgroup-name nil)))))
7302 (declare-function gnus-stop-downloads "gnus-art" ())
7304 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7305 (defun gnus-summary-exit-no-update (&optional no-questions)
7306 "Quit reading current newsgroup without updating read article info."
7307 (interactive)
7308 (let* ((group gnus-newsgroup-name)
7309 (gnus-group-is-exiting-p t)
7310 (gnus-group-is-exiting-without-update-p t)
7311 (quit-config (gnus-group-quit-config group)))
7312 (when (or no-questions
7313 (gnus-ephemeral-group-p group)
7314 gnus-expert-user
7315 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7316 (gnus-async-halt-prefetch)
7317 (run-hooks 'gnus-summary-prepare-exit-hook)
7318 (when (gnus-buffer-live-p gnus-article-buffer)
7319 (with-current-buffer gnus-article-buffer
7320 (gnus-article-stop-animations)
7321 (gnus-stop-downloads)
7322 (mm-destroy-parts gnus-article-mime-handles)
7323 ;; Set it to nil for safety reason.
7324 (setq gnus-article-mime-handle-alist nil)
7325 (setq gnus-article-mime-handles nil)))
7326 ;; If we have several article buffers, we kill them at exit.
7327 (unless gnus-single-article-buffer
7328 (gnus-kill-buffer gnus-article-buffer)
7329 (gnus-kill-buffer gnus-original-article-buffer)
7330 (setq gnus-article-current nil))
7331 ;; Return to the group buffer.
7332 (if (not gnus-kill-summary-on-exit)
7333 (progn
7334 (gnus-deaden-summary)
7335 (gnus-configure-windows 'group 'force))
7336 (gnus-configure-windows 'group 'force)
7337 (gnus-close-group group)
7338 (gnus-kill-buffer gnus-summary-buffer))
7339 (unless gnus-single-article-buffer
7340 (setq gnus-article-current nil))
7341 (when gnus-use-trees
7342 (gnus-tree-close))
7343 (gnus-async-prefetch-remove-group group)
7344 (when (get-buffer gnus-article-buffer)
7345 (bury-buffer gnus-article-buffer))
7346 ;; Clear the current group name.
7347 (setq gnus-newsgroup-name nil)
7348 (unless (gnus-ephemeral-group-p group)
7349 (gnus-group-update-group group nil t))
7350 (when (equal (gnus-group-group-name) group)
7351 (gnus-group-next-unread-group 1))
7352 (gnus-article-stop-animations)
7353 (when quit-config
7354 (gnus-handle-ephemeral-exit quit-config)))))
7356 (defun gnus-handle-ephemeral-exit (quit-config)
7357 "Handle movement when leaving an ephemeral group.
7358 The state which existed when entering the ephemeral is reset."
7359 (if (not (buffer-live-p (car quit-config)))
7360 (when (gnus-buffer-live-p gnus-group-buffer)
7361 (gnus-configure-windows 'group 'force))
7362 (set-buffer (car quit-config))
7363 (unless (eq (cdr quit-config) 'group)
7364 (setq gnus-current-select-method
7365 (gnus-find-method-for-group gnus-newsgroup-name)))
7366 (cond ((derived-mode-p 'gnus-summary-mode)
7367 (gnus-set-global-variables))
7368 ((derived-mode-p 'gnus-article-mode)
7369 (save-current-buffer
7370 ;; The `gnus-summary-buffer' variable may point
7371 ;; to the old summary buffer when using a single
7372 ;; article buffer.
7373 (unless (gnus-buffer-live-p gnus-summary-buffer)
7374 (set-buffer gnus-group-buffer))
7375 (set-buffer gnus-summary-buffer)
7376 (gnus-set-global-variables))))
7377 (if (or (eq (cdr quit-config) 'article)
7378 (eq (cdr quit-config) 'pick))
7379 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7380 (gnus-configure-windows 'pick 'force)
7381 (gnus-configure-windows (cdr quit-config) 'force))
7382 (gnus-configure-windows (cdr quit-config) 'force))
7383 (when (derived-mode-p 'gnus-summary-mode)
7384 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7385 next-unread-noselect))
7386 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7387 'next-noselect)
7388 (gnus-summary-next-subject 1 nil t))
7389 ((eq gnus-auto-select-on-ephemeral-exit
7390 'next-unread-noselect)
7391 (gnus-summary-next-subject 1 t t))))
7392 ;; Hide the article buffer which displays the article different
7393 ;; from the one that the cursor points to in the summary buffer.
7394 (gnus-configure-windows 'summary 'force))
7395 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7396 (gnus-summary-next-subject 1))
7397 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7398 (gnus-summary-next-subject 1 t))))
7399 (gnus-summary-recenter)
7400 (gnus-summary-position-point))))
7402 ;;; Dead summaries.
7404 (defvar gnus-dead-summary-mode-map
7405 (let ((map (make-keymap)))
7406 (suppress-keymap map)
7407 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7408 (dolist (key '("\C-d" "\r" "\177" [delete]))
7409 (define-key map key 'gnus-summary-wake-up-the-dead))
7410 (dolist (key '("q" "Q"))
7411 (define-key map key 'bury-buffer))
7412 map))
7414 (define-minor-mode gnus-dead-summary-mode
7415 "Minor mode for Gnus summary buffers."
7416 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7417 (unless (derived-mode-p 'gnus-summary-mode)
7418 (setq gnus-dead-summary-mode nil)))
7420 (defun gnus-deaden-summary ()
7421 "Make the current summary buffer into a dead summary buffer."
7422 ;; Kill any previous dead summary buffer.
7423 (when (and gnus-dead-summary
7424 (buffer-name gnus-dead-summary))
7425 (with-current-buffer gnus-dead-summary
7426 (when gnus-dead-summary-mode
7427 (kill-buffer (current-buffer)))))
7428 ;; Make this the current dead summary.
7429 (setq gnus-dead-summary (current-buffer))
7430 (gnus-dead-summary-mode 1)
7431 (let ((name (buffer-name)))
7432 (when (string-match "Summary" name)
7433 (rename-buffer
7434 (concat (substring name 0 (match-beginning 0)) "Dead "
7435 (substring name (match-beginning 0)))
7437 (bury-buffer))))
7439 (defun gnus-kill-or-deaden-summary (buffer)
7440 "Kill or deaden the summary BUFFER."
7441 (save-excursion
7442 (when (and (buffer-name buffer)
7443 (not gnus-single-article-buffer))
7444 (with-current-buffer buffer
7445 (gnus-kill-buffer gnus-article-buffer)
7446 (gnus-kill-buffer gnus-original-article-buffer)))
7447 (cond
7448 ;; Kill the buffer.
7449 (gnus-kill-summary-on-exit
7450 (when (and gnus-use-trees
7451 (gnus-buffer-exists-p buffer))
7452 (with-current-buffer buffer
7453 (gnus-tree-close)))
7454 (gnus-kill-buffer buffer))
7455 ;; Deaden the buffer.
7456 ((gnus-buffer-exists-p buffer)
7457 (with-current-buffer buffer
7458 (gnus-deaden-summary))))))
7460 (defun gnus-summary-wake-up-the-dead (&rest args)
7461 "Wake up the dead summary buffer."
7462 (interactive)
7463 (gnus-dead-summary-mode -1)
7464 (let ((name (buffer-name)))
7465 (when (string-match "Dead " name)
7466 (rename-buffer
7467 (concat (substring name 0 (match-beginning 0))
7468 (substring name (match-end 0)))
7469 t)))
7470 (gnus-message 3 "This dead summary is now alive again"))
7472 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7473 (defun gnus-summary-describe-group (&optional force)
7474 "Describe the current newsgroup."
7475 (interactive "P")
7476 (gnus-group-describe-group force gnus-newsgroup-name))
7478 (defun gnus-summary-describe-briefly ()
7479 "Describe summary mode commands briefly."
7480 (interactive)
7481 (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")))
7483 ;; Walking around group mode buffer from summary mode.
7485 (defun gnus-summary-next-group (&optional no-article target-group backward)
7486 "Exit current newsgroup and then select next unread newsgroup.
7487 If prefix argument NO-ARTICLE is non-nil, no article is selected
7488 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7489 previous group instead."
7490 (interactive "P")
7491 ;; Stop pre-fetching.
7492 (gnus-async-halt-prefetch)
7493 (let ((current-group gnus-newsgroup-name)
7494 (current-buffer (current-buffer))
7495 entered)
7496 ;; First we semi-exit this group to update Xrefs and all variables.
7497 ;; We can't do a real exit, because the window conf must remain
7498 ;; the same in case the user is prompted for info, and we don't
7499 ;; want the window conf to change before that...
7500 (gnus-summary-exit t)
7501 (while (not entered)
7502 ;; Then we find what group we are supposed to enter.
7503 (set-buffer gnus-group-buffer)
7504 (gnus-group-jump-to-group current-group)
7505 (setq target-group
7506 (or target-group
7507 (if (eq gnus-keep-same-level 'best)
7508 (gnus-summary-best-group gnus-newsgroup-name)
7509 (gnus-summary-search-group backward gnus-keep-same-level))))
7510 (if (not target-group)
7511 ;; There are no further groups, so we return to the group
7512 ;; buffer.
7513 (progn
7514 (gnus-message 5 "Returning to the group buffer")
7515 (setq entered t)
7516 (when (gnus-buffer-live-p current-buffer)
7517 (set-buffer current-buffer)
7518 (gnus-summary-exit))
7519 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7520 ;; We try to enter the target group.
7521 (gnus-group-jump-to-group target-group)
7522 (let ((unreads (gnus-group-group-unread)))
7523 (if (and (or (eq t unreads)
7524 (and unreads (not (zerop unreads))))
7525 (gnus-summary-read-group
7526 target-group nil no-article
7527 (and (buffer-name current-buffer) current-buffer)
7528 nil backward))
7529 (setq entered t)
7530 (setq current-group target-group
7531 target-group nil)))))))
7533 (defun gnus-summary-prev-group (&optional no-article)
7534 "Exit current newsgroup and then select previous unread newsgroup.
7535 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7536 (interactive "P")
7537 (gnus-summary-next-group no-article nil t))
7539 ;; Walking around summary lines.
7541 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7542 "Go to the first subject satisfying any non-nil constraint.
7543 If UNREAD is non-nil, the article should be unread.
7544 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7545 If UNSEEN is non-nil, the article should be unseen as well as unread.
7546 Returns the article selected or nil if there are no matching articles."
7547 (interactive "P")
7548 (cond
7549 ;; Empty summary.
7550 ((null gnus-newsgroup-data)
7551 (gnus-message 3 "No articles in the group")
7552 nil)
7553 ;; Pick the first article.
7554 ((not (or unread undownloaded unseen))
7555 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7556 (gnus-data-number (car gnus-newsgroup-data)))
7557 ;; Find the first unread article.
7559 (let ((data gnus-newsgroup-data))
7560 (while (and data
7561 (let ((num (gnus-data-number (car data))))
7562 (or (memq num gnus-newsgroup-unfetched)
7563 (not (or (and unread
7564 (memq num gnus-newsgroup-unreads))
7565 (and undownloaded
7566 (memq num gnus-newsgroup-undownloaded))
7567 (and unseen
7568 (memq num gnus-newsgroup-unseen)
7569 (memq num gnus-newsgroup-unreads)))))))
7570 (setq data (cdr data)))
7571 (prog1
7572 (if data
7573 (progn
7574 (goto-char (gnus-data-pos (car data)))
7575 (gnus-data-number (car data)))
7576 (gnus-message 3 "No more%s articles"
7577 (let* ((r (when unread " unread"))
7578 (d (when undownloaded " undownloaded"))
7579 (s (when unseen " unseen"))
7580 (l (delq nil (list r d s))))
7581 (cond ((= 3 (length l))
7582 (concat r "," d ", or" s))
7583 ((= 2 (length l))
7584 (concat (car l) ", or" (cadr l)))
7585 ((= 1 (length l))
7586 (car l))
7588 ""))))
7591 (gnus-summary-position-point))))))
7593 (defun gnus-summary-next-subject (n &optional unread dont-display)
7594 "Go to next N'th summary line.
7595 If N is negative, go to the previous N'th subject line.
7596 If UNREAD is non-nil, only unread articles are selected.
7597 The difference between N and the actual number of steps taken is
7598 returned."
7599 (interactive "p")
7600 (let ((backward (< n 0))
7601 (n (abs n)))
7602 (while (and (> n 0)
7603 (if backward
7604 (gnus-summary-find-prev unread)
7605 (gnus-summary-find-next unread)))
7606 (unless (zerop (setq n (1- n)))
7607 (gnus-summary-show-thread)))
7608 (when (/= 0 n)
7609 (gnus-message 7 "No more%s articles"
7610 (if unread " unread" "")))
7611 (unless dont-display
7612 (gnus-summary-recenter)
7613 (gnus-summary-position-point))
7616 (defun gnus-summary-next-unread-subject (n)
7617 "Go to next N'th unread summary line."
7618 (interactive "p")
7619 (gnus-summary-next-subject n t))
7621 (defun gnus-summary-prev-subject (n &optional unread)
7622 "Go to previous N'th summary line.
7623 If optional argument UNREAD is non-nil, only unread article is selected."
7624 (interactive "p")
7625 (gnus-summary-next-subject (- n) unread))
7627 (defun gnus-summary-prev-unread-subject (n)
7628 "Go to previous N'th unread summary line."
7629 (interactive "p")
7630 (gnus-summary-next-subject (- n) t))
7632 (defun gnus-summary-goto-subjects (articles)
7633 "Insert the subject header for ARTICLES in the current buffer."
7634 (save-excursion
7635 (dolist (article articles)
7636 (gnus-summary-goto-subject article t)))
7637 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7638 (gnus-summary-position-point))
7640 (defun gnus-summary-goto-subject (article &optional force silent)
7641 "Go to the subject line of ARTICLE.
7642 If FORCE, also allow jumping to articles not currently shown."
7643 (interactive "nArticle number: ")
7644 (unless (numberp article)
7645 (error "Article %s is not a number" article))
7646 (let ((b (point))
7647 (data (gnus-data-find article)))
7648 ;; We read in the article if we have to.
7649 (and (not data)
7650 force
7651 (gnus-summary-insert-subject
7652 article
7653 (if (or (numberp force) (vectorp force)) force)
7655 (setq data (gnus-data-find article)))
7656 (goto-char b)
7657 (if (not data)
7658 (progn
7659 (unless silent
7660 (gnus-message 3 "Can't find article %d" article))
7661 nil)
7662 (let ((pt (gnus-data-pos data)))
7663 (goto-char pt)
7664 (gnus-summary-set-article-display-arrow pt))
7665 (gnus-summary-position-point)
7666 article)))
7668 ;; Walking around summary lines with displaying articles.
7670 (defun gnus-summary-expand-window (&optional arg)
7671 "Make the summary buffer take up the entire Emacs frame.
7672 Given a prefix, will force an `article' buffer configuration."
7673 (interactive "P")
7674 (if arg
7675 (gnus-configure-windows 'article 'force)
7676 (gnus-configure-windows 'summary 'force)))
7678 (defun gnus-summary-display-article (article &optional all-header)
7679 "Display ARTICLE in article buffer."
7680 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7681 (with-current-buffer gnus-article-buffer
7682 (derived-mode-p 'gnus-article-mode)))
7683 (gnus-article-setup-buffer))
7684 (gnus-set-global-variables)
7685 (with-current-buffer gnus-article-buffer
7686 (setq gnus-article-charset gnus-newsgroup-charset)
7687 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7688 (mm-enable-multibyte))
7689 (if (null article)
7691 (prog1
7692 (if gnus-summary-display-article-function
7693 (funcall gnus-summary-display-article-function article all-header)
7694 (gnus-article-prepare article all-header))
7695 (gnus-run-hooks 'gnus-select-article-hook)
7696 (when (and gnus-current-article
7697 (not (zerop gnus-current-article)))
7698 (gnus-summary-goto-subject gnus-current-article))
7699 (gnus-summary-recenter)
7700 (when (and gnus-use-trees gnus-show-threads)
7701 (gnus-possibly-generate-tree article)
7702 (gnus-highlight-selected-tree article))
7703 ;; Successfully display article.
7704 (gnus-article-set-window-start
7705 (cdr (assq article gnus-newsgroup-bookmarks))))))
7707 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7708 "Select the current article.
7709 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7710 non-nil, the article will be re-fetched even if it already present in
7711 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7712 be displayed."
7713 ;; Make sure we are in the summary buffer to work around bbdb bug.
7714 (unless (derived-mode-p 'gnus-summary-mode)
7715 (set-buffer gnus-summary-buffer))
7716 (let ((article (or article (gnus-summary-article-number)))
7717 (all-headers (not (not all-headers))) ;Must be t or nil.
7718 gnus-summary-display-article-function)
7719 (and (not pseudo)
7720 (gnus-summary-article-pseudo-p article)
7721 (error "This is a pseudo-article"))
7722 (with-current-buffer gnus-summary-buffer
7723 (if (or (and gnus-single-article-buffer
7724 (or (null gnus-current-article)
7725 (null gnus-article-current)
7726 (null (get-buffer gnus-article-buffer))
7727 (not (eq article (cdr gnus-article-current)))
7728 (not (equal (car gnus-article-current)
7729 gnus-newsgroup-name))
7730 (not (get-buffer gnus-original-article-buffer))))
7731 (and (not gnus-single-article-buffer)
7732 (or (null gnus-current-article)
7733 (not (get-buffer gnus-original-article-buffer))
7734 (not (eq gnus-current-article article))))
7735 force)
7736 ;; The requested article is different from the current article.
7737 (progn
7738 (gnus-summary-display-article article all-headers)
7739 (when (gnus-buffer-live-p gnus-article-buffer)
7740 (with-current-buffer gnus-article-buffer
7741 (if (not gnus-article-decoded-p) ;; a local variable
7742 (mm-disable-multibyte))))
7743 (gnus-article-set-window-start
7744 (cdr (assq article gnus-newsgroup-bookmarks)))
7745 article)
7746 'old))))
7748 (defun gnus-summary-force-verify-and-decrypt ()
7749 "Display buttons for signed/encrypted parts and verify/decrypt them."
7750 (interactive)
7751 (let ((mm-verify-option 'known)
7752 (mm-decrypt-option 'known)
7753 (gnus-article-emulate-mime t)
7754 (gnus-buttonized-mime-types (append (list "multipart/signed"
7755 "multipart/encrypted")
7756 gnus-buttonized-mime-types)))
7757 (gnus-summary-select-article nil 'force)))
7759 (defun gnus-summary-next-article (&optional unread subject backward push)
7760 "Select the next article.
7761 If UNREAD, only unread articles are selected.
7762 If SUBJECT, only articles with SUBJECT are selected.
7763 If BACKWARD, the previous article is selected instead of the next."
7764 (interactive "P")
7765 ;; Make sure we are in the summary buffer.
7766 (unless (derived-mode-p 'gnus-summary-mode)
7767 (set-buffer gnus-summary-buffer))
7768 (cond
7769 ;; Is there such an article?
7770 ((and (gnus-summary-search-forward unread subject backward)
7771 (or (gnus-summary-display-article (gnus-summary-article-number))
7772 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7773 (gnus-summary-position-point))
7774 ;; If not, we try the first unread, if that is wanted.
7775 ((and subject
7776 gnus-auto-select-same
7777 (gnus-summary-first-unread-article))
7778 (gnus-summary-position-point)
7779 (gnus-message 6 "Wrapped"))
7780 ;; Try to get next/previous article not displayed in this group.
7781 ((and gnus-auto-extend-newsgroup
7782 (not unread) (not subject))
7783 (gnus-summary-goto-article
7784 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7785 nil (count-lines (point-min) (point))))
7786 ;; Go to next/previous group.
7788 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7789 (gnus-summary-jump-to-group gnus-newsgroup-name))
7790 (let ((cmd last-command-event)
7791 (point
7792 (with-current-buffer gnus-group-buffer
7793 (point)))
7794 (current-summary (current-buffer))
7795 (group
7796 (if (eq gnus-keep-same-level 'best)
7797 (gnus-summary-best-group gnus-newsgroup-name)
7798 (gnus-summary-search-group backward gnus-keep-same-level))))
7799 ;; Select next unread newsgroup automagically.
7800 (cond
7801 ((or (not gnus-auto-select-next)
7802 (not cmd))
7803 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7804 ((or (eq gnus-auto-select-next 'quietly)
7805 (and (eq gnus-auto-select-next 'slightly-quietly)
7806 push)
7807 (and (eq gnus-auto-select-next 'almost-quietly)
7808 (gnus-summary-last-article-p)))
7809 ;; Select quietly.
7810 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7811 (gnus-summary-exit)
7812 (gnus-message 7 "No more%s articles (%s)..."
7813 (if unread " unread" "")
7814 (if group (concat "selecting " group)
7815 "exiting"))
7816 (gnus-summary-next-group nil group backward)))
7818 (when (numberp last-input-event)
7819 ;; Somehow or other, we may now have selected a different
7820 ;; window. Make point go back to the summary buffer.
7821 (when (eq current-summary (current-buffer))
7822 ;; FIXME: This burps when get-buffer-window returns nil.
7823 (select-window (get-buffer-window current-summary 0)))
7824 (gnus-summary-walk-group-buffer
7825 gnus-newsgroup-name cmd unread backward point))))))))
7827 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7828 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7829 (?\C-p (gnus-group-prev-unread-group 1))))
7830 (cursor-in-echo-area t)
7831 keve key group ended prompt)
7832 (with-current-buffer gnus-group-buffer
7833 (goto-char start)
7834 (setq group
7835 (if (eq gnus-keep-same-level 'best)
7836 (gnus-summary-best-group gnus-newsgroup-name)
7837 (gnus-summary-search-group backward gnus-keep-same-level))))
7838 (while (not ended)
7839 (setq prompt
7840 (format
7841 "No more%s articles%s " (if unread " unread" "")
7842 (if (and group
7843 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7844 (format " (Type %s for %s [%s])"
7845 (single-key-description cmd)
7846 (gnus-group-decoded-name group)
7847 (gnus-group-unread group))
7848 (format " (Type %s to exit %s)"
7849 (single-key-description cmd)
7850 (gnus-group-decoded-name gnus-newsgroup-name)))))
7851 ;; Confirm auto selection.
7852 (setq key (car (setq keve (gnus-read-event-char prompt)))
7853 ended t)
7854 (cond
7855 ((assq key keystrokes)
7856 (let ((obuf (current-buffer)))
7857 (switch-to-buffer gnus-group-buffer)
7858 (when group
7859 (gnus-group-jump-to-group group))
7860 (eval (cadr (assq key keystrokes)))
7861 (setq group (gnus-group-group-name))
7862 (switch-to-buffer obuf))
7863 (setq ended nil))
7864 ((equal key cmd)
7865 (if (or (not group)
7866 (gnus-ephemeral-group-p gnus-newsgroup-name))
7867 (gnus-summary-exit)
7868 (gnus-summary-next-group nil group backward)))
7870 (push (cdr keve) unread-command-events))))))
7872 (defun gnus-summary-next-unread-article ()
7873 "Select unread article after current one."
7874 (interactive)
7875 (gnus-summary-next-article
7876 (or (not (eq gnus-summary-goto-unread 'never))
7877 (gnus-summary-last-article-p (gnus-summary-article-number)))
7878 (and gnus-auto-select-same
7879 (gnus-summary-article-subject))))
7881 (defun gnus-summary-prev-article (&optional unread subject)
7882 "Select the article before the current one.
7883 If UNREAD is non-nil, only unread articles are selected."
7884 (interactive "P")
7885 (gnus-summary-next-article unread subject t))
7887 (defun gnus-summary-prev-unread-article ()
7888 "Select unread article before current one."
7889 (interactive)
7890 (gnus-summary-prev-article
7891 (or (not (eq gnus-summary-goto-unread 'never))
7892 (gnus-summary-first-article-p (gnus-summary-article-number)))
7893 (and gnus-auto-select-same
7894 (gnus-summary-article-subject))))
7896 (declare-function gnus-article-only-boring-p "gnus-art" ())
7898 (defun gnus-summary-next-page (&optional lines circular stop)
7899 "Show next page of the selected article.
7900 If at the end of the current article, select the next article.
7901 LINES says how many lines should be scrolled up.
7903 If CIRCULAR is non-nil, go to the start of the article instead of
7904 selecting the next article when reaching the end of the current
7905 article.
7907 If STOP is non-nil, just stop when reaching the end of the message.
7909 Also see the variable `gnus-article-skip-boring'."
7910 (interactive "P")
7911 (gnus-set-global-variables)
7912 (let ((article (gnus-summary-article-number))
7913 (article-window (get-buffer-window gnus-article-buffer t))
7914 endp)
7915 ;; If the buffer is empty, we have no article.
7916 (unless article
7917 (error "No article to select"))
7918 (gnus-configure-windows 'article)
7919 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7920 (if (and (eq gnus-summary-goto-unread 'never)
7921 (not (gnus-summary-last-article-p article)))
7922 (gnus-summary-next-article)
7923 (gnus-summary-next-unread-article))
7924 (if (or (null gnus-current-article)
7925 (null gnus-article-current)
7926 (/= article (cdr gnus-article-current))
7927 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7928 ;; Selected subject is different from current article's.
7929 (gnus-summary-display-article article)
7930 (when article-window
7931 (gnus-eval-in-buffer-window gnus-article-buffer
7932 (setq endp (or (gnus-article-next-page lines)
7933 (gnus-article-only-boring-p))))
7934 (when endp
7935 (cond ((or stop gnus-summary-stop-at-end-of-message)
7936 (gnus-message 3 "End of message"))
7937 (circular
7938 (gnus-summary-beginning-of-article))
7939 (lines
7940 (gnus-message 3 "End of message"))
7941 ((null lines)
7942 (if (and (eq gnus-summary-goto-unread 'never)
7943 (not (gnus-summary-last-article-p article)))
7944 (gnus-summary-next-article)
7945 (gnus-summary-next-unread-article))))))))
7946 (gnus-summary-recenter)
7947 (gnus-summary-position-point)))
7949 (defun gnus-summary-prev-page (&optional lines move)
7950 "Show previous page of selected article.
7951 Argument LINES specifies lines to be scrolled down.
7952 If MOVE, move to the previous unread article if point is at
7953 the beginning of the buffer."
7954 (interactive "P")
7955 (let ((article (gnus-summary-article-number))
7956 (article-window (get-buffer-window gnus-article-buffer t))
7957 endp)
7958 (gnus-configure-windows 'article)
7959 (if (or (null gnus-current-article)
7960 (null gnus-article-current)
7961 (/= article (cdr gnus-article-current))
7962 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7963 ;; Selected subject is different from current article's.
7964 (gnus-summary-display-article article)
7965 (gnus-summary-recenter)
7966 (when article-window
7967 (gnus-eval-in-buffer-window gnus-article-buffer
7968 (setq endp (gnus-article-prev-page lines)))
7969 (when (and move endp)
7970 (cond (lines
7971 (gnus-message 3 "Beginning of message"))
7972 ((null lines)
7973 (if (and (eq gnus-summary-goto-unread 'never)
7974 (not (gnus-summary-first-article-p article)))
7975 (gnus-summary-prev-article)
7976 (gnus-summary-prev-unread-article))))))))
7977 (gnus-summary-position-point))
7979 (defun gnus-summary-prev-page-or-article (&optional lines)
7980 "Show previous page of selected article.
7981 Argument LINES specifies lines to be scrolled down.
7982 If at the beginning of the article, go to the next article."
7983 (interactive "P")
7984 (gnus-summary-prev-page lines t))
7986 (defun gnus-summary-scroll-up (lines)
7987 "Scroll up (or down) one line current article.
7988 Argument LINES specifies lines to be scrolled up (or down if negative).
7989 If no article is selected, then the current article will be selected first."
7990 (interactive "p")
7991 (gnus-configure-windows 'article)
7992 (gnus-summary-show-thread)
7993 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7994 (gnus-eval-in-buffer-window gnus-article-buffer
7995 (cond ((> lines 0)
7996 (when (gnus-article-next-page lines)
7997 (gnus-message 3 "End of message")))
7998 ((< lines 0)
7999 (gnus-article-prev-page (- lines))))))
8000 (gnus-summary-recenter)
8001 (gnus-summary-position-point))
8003 (defun gnus-summary-scroll-down (lines)
8004 "Scroll down (or up) one line current article.
8005 Argument LINES specifies lines to be scrolled down (or up if negative).
8006 If no article is selected, then the current article will be selected first."
8007 (interactive "p")
8008 (gnus-summary-scroll-up (- lines)))
8010 (defun gnus-summary-next-same-subject ()
8011 "Select next article which has the same subject as current one."
8012 (interactive)
8013 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8015 (defun gnus-summary-prev-same-subject ()
8016 "Select previous article which has the same subject as current one."
8017 (interactive)
8018 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8020 (defun gnus-summary-next-unread-same-subject ()
8021 "Select next unread article which has the same subject as current one."
8022 (interactive)
8023 (gnus-summary-next-article t (gnus-summary-article-subject)))
8025 (defun gnus-summary-prev-unread-same-subject ()
8026 "Select previous unread article which has the same subject as current one."
8027 (interactive)
8028 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8030 (defun gnus-summary-first-unread-article ()
8031 "Select the first unread article.
8032 Return nil if there are no unread articles."
8033 (interactive)
8034 (prog1
8035 (when (gnus-summary-first-subject t)
8036 (gnus-summary-show-thread)
8037 (gnus-summary-first-subject t)
8038 (gnus-summary-display-article (gnus-summary-article-number)))
8039 (gnus-summary-position-point)))
8041 (defun gnus-summary-first-unread-subject ()
8042 "Place the point on the subject line of the first unread article.
8043 Return nil if there are no unread articles."
8044 (interactive)
8045 (prog1
8046 (when (gnus-summary-first-subject t)
8047 (gnus-summary-show-thread)
8048 (gnus-summary-first-subject t))
8049 (gnus-summary-position-point)))
8051 (defun gnus-summary-first-unseen-subject ()
8052 "Place the point on the subject line of the first unseen article.
8053 Return nil if there are no unseen articles."
8054 (interactive)
8055 (prog1
8056 (when (gnus-summary-first-subject nil nil t)
8057 (gnus-summary-show-thread)
8058 (gnus-summary-first-subject nil nil t))
8059 (gnus-summary-position-point)))
8061 (defun gnus-summary-first-unseen-or-unread-subject ()
8062 "Place the point on the subject line of the first unseen and unread article.
8063 If all article have been seen, on the subject line of the first unread
8064 article."
8065 (interactive)
8066 (prog1
8067 (unless (when (gnus-summary-first-subject nil nil t)
8068 (gnus-summary-show-thread)
8069 (gnus-summary-first-subject nil nil t))
8070 (when (gnus-summary-first-subject t)
8071 (gnus-summary-show-thread)
8072 (gnus-summary-first-subject t)))
8073 (gnus-summary-position-point)))
8075 (defun gnus-summary-first-article ()
8076 "Select the first article.
8077 Return nil if there are no articles."
8078 (interactive)
8079 (prog1
8080 (when (gnus-summary-first-subject)
8081 (gnus-summary-show-thread)
8082 (gnus-summary-first-subject)
8083 (gnus-summary-display-article (gnus-summary-article-number)))
8084 (gnus-summary-position-point)))
8086 (defun gnus-summary-best-unread-article (&optional arg)
8087 "Select the unread article with the highest score.
8088 If given a prefix argument, select the next unread article that has a
8089 score higher than the default score."
8090 (interactive "P")
8091 (let ((article (if arg
8092 (gnus-summary-better-unread-subject)
8093 (gnus-summary-best-unread-subject))))
8094 (if article
8095 (gnus-summary-goto-article article)
8096 (error "No unread articles"))))
8098 (defun gnus-summary-best-unread-subject ()
8099 "Select the unread subject with the highest score."
8100 (interactive)
8101 (let ((best -1000000)
8102 (data gnus-newsgroup-data)
8103 article score)
8104 (while data
8105 (and (gnus-data-unread-p (car data))
8106 (> (setq score
8107 (gnus-summary-article-score (gnus-data-number (car data))))
8108 best)
8109 (setq best score
8110 article (gnus-data-number (car data))))
8111 (setq data (cdr data)))
8112 (when article
8113 (gnus-summary-goto-subject article))
8114 (gnus-summary-position-point)
8115 article))
8117 (defun gnus-summary-better-unread-subject ()
8118 "Select the first unread subject that has a score over the default score."
8119 (interactive)
8120 (let ((data gnus-newsgroup-data)
8121 article score)
8122 (while (and (setq article (gnus-data-number (car data)))
8123 (or (gnus-data-read-p (car data))
8124 (not (> (gnus-summary-article-score article)
8125 gnus-summary-default-score))))
8126 (setq data (cdr data)))
8127 (when article
8128 (gnus-summary-goto-subject article))
8129 (gnus-summary-position-point)
8130 article))
8132 (defun gnus-summary-last-subject ()
8133 "Go to the last displayed subject line in the group."
8134 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8135 (when article
8136 (gnus-summary-goto-subject article))))
8138 (defun gnus-summary-goto-article (article &optional all-headers force)
8139 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8140 If ALL-HEADERS is non-nil, no header lines are hidden.
8141 If FORCE, go to the article even if it isn't displayed. If FORCE
8142 is a number, it is the line the article is to be displayed on."
8143 (interactive
8144 (list
8145 (gnus-completing-read
8146 "Article number or Message-ID"
8147 (mapcar 'int-to-string gnus-newsgroup-limit))
8148 current-prefix-arg
8150 (prog1
8151 (if (and (stringp article)
8152 (string-match "@\\|%40" article))
8153 (gnus-summary-refer-article article)
8154 (when (stringp article)
8155 (setq article (string-to-number article)))
8156 (if (gnus-summary-goto-subject article force)
8157 (gnus-summary-display-article article all-headers)
8158 (gnus-message 4 "Couldn't go to article %s" article) nil))
8159 (gnus-summary-position-point)))
8161 (defun gnus-summary-goto-last-article ()
8162 "Go to the previously read article."
8163 (interactive)
8164 (prog1
8165 (when gnus-last-article
8166 (gnus-summary-goto-article gnus-last-article nil t))
8167 (gnus-summary-position-point)))
8169 (defun gnus-summary-pop-article (number)
8170 "Pop one article off the history and go to the previous.
8171 NUMBER articles will be popped off."
8172 (interactive "p")
8173 (let (to)
8174 (setq gnus-newsgroup-history
8175 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8176 (if to
8177 (gnus-summary-goto-article (car to) nil t)
8178 (error "Article history empty")))
8179 (gnus-summary-position-point))
8181 ;; Summary commands and functions for limiting the summary buffer.
8183 (defun gnus-summary-limit-to-articles (n)
8184 "Limit the summary buffer to the next N articles.
8185 If not given a prefix, use the process marked articles instead."
8186 (interactive "P")
8187 (prog1
8188 (let ((articles (gnus-summary-work-articles n)))
8189 (setq gnus-newsgroup-processable nil)
8190 (gnus-summary-limit articles))
8191 (gnus-summary-position-point)))
8193 (defun gnus-summary-pop-limit (&optional total)
8194 "Restore the previous limit.
8195 If given a prefix, remove all limits."
8196 (interactive "P")
8197 (when total
8198 (setq gnus-newsgroup-limits
8199 (list (mapcar (lambda (h) (mail-header-number h))
8200 gnus-newsgroup-headers))))
8201 (unless gnus-newsgroup-limits
8202 (error "No limit to pop"))
8203 (prog1
8204 (gnus-summary-limit nil 'pop)
8205 (gnus-summary-position-point)))
8207 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8208 "Limit the summary buffer to articles that have subjects that match a regexp.
8209 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8210 (interactive
8211 (list (read-string (if current-prefix-arg
8212 "Exclude subject (regexp): "
8213 "Limit to subject (regexp): "))
8214 nil current-prefix-arg))
8215 (unless header
8216 (setq header "subject"))
8217 (when (not (equal "" subject))
8218 (prog1
8219 (let ((articles (gnus-summary-find-matching
8220 (or header "subject") subject 'all nil nil
8221 not-matching)))
8222 (unless articles
8223 (error "Found no matches for \"%s\"" subject))
8224 (gnus-summary-limit articles))
8225 (gnus-summary-position-point))))
8227 (defun gnus-summary-limit-to-author (from &optional not-matching)
8228 "Limit the summary buffer to articles that have authors that match a regexp.
8229 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8230 (interactive
8231 (list (let* ((header (gnus-summary-article-header))
8232 (default (and header (car (mail-header-parse-address
8233 (mail-header-from header))))))
8234 (read-string (concat (if current-prefix-arg
8235 "Exclude author (regexp"
8236 "Limit to author (regexp")
8237 (if default
8238 (concat ", default \"" default "\"): ")
8239 "): "))
8240 nil nil
8241 default))
8242 current-prefix-arg))
8243 (gnus-summary-limit-to-subject from "from" not-matching))
8245 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8246 "Limit the summary buffer to articles with the given RECIPIENT.
8248 If NOT-MATCHING, exclude RECIPIENT.
8250 To and Cc headers are checked. You need to include them in
8251 `nnmail-extra-headers'."
8252 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8253 (interactive
8254 (list (read-string (format "%s recipient (regexp): "
8255 (if current-prefix-arg "Exclude" "Limit to")))
8256 current-prefix-arg))
8257 (when (not (equal "" recipient))
8258 (prog1 (let* ((to
8259 (if (memq 'To nnmail-extra-headers)
8260 (gnus-summary-find-matching
8261 (cons 'extra 'To) recipient 'all nil nil
8262 not-matching)
8263 (gnus-message
8264 1 "`To' isn't present in `nnmail-extra-headers'")
8265 (sit-for 1)
8266 nil))
8268 (if (memq 'Cc nnmail-extra-headers)
8269 (gnus-summary-find-matching
8270 (cons 'extra 'Cc) recipient 'all nil nil
8271 not-matching)
8272 (gnus-message
8273 1 "`Cc' isn't present in `nnmail-extra-headers'")
8274 (sit-for 1)
8275 nil))
8276 (articles
8277 (if not-matching
8278 ;; We need the numbers that are in both lists:
8279 (mapcar (lambda (a)
8280 (and (memq a to) a))
8282 (nconc to cc))))
8283 (unless articles
8284 (error "Found no matches for \"%s\"" recipient))
8285 (gnus-summary-limit articles))
8286 (gnus-summary-position-point))))
8288 (defun gnus-summary-limit-to-address (address &optional not-matching)
8289 "Limit the summary buffer to articles with the given ADDRESS.
8291 If NOT-MATCHING, exclude ADDRESS.
8293 To, Cc and From headers are checked. You need to include `To' and `Cc'
8294 in `nnmail-extra-headers'."
8295 (interactive
8296 (list (read-string (format "%s address (regexp): "
8297 (if current-prefix-arg "Exclude" "Limit to")))
8298 current-prefix-arg))
8299 (when (not (equal "" address))
8300 (prog1 (let* ((to
8301 (if (memq 'To nnmail-extra-headers)
8302 (gnus-summary-find-matching
8303 (cons 'extra 'To) address 'all nil nil
8304 not-matching)
8305 (gnus-message
8306 1 "`To' isn't present in `nnmail-extra-headers'")
8307 (sit-for 1)
8310 (if (memq 'Cc nnmail-extra-headers)
8311 (gnus-summary-find-matching
8312 (cons 'extra 'Cc) address 'all nil nil
8313 not-matching)
8314 (gnus-message
8315 1 "`Cc' isn't present in `nnmail-extra-headers'")
8316 (sit-for 1)
8318 (from
8319 (gnus-summary-find-matching "from" address
8320 'all nil nil not-matching))
8321 (articles
8322 (if not-matching
8323 ;; We need the numbers that are in all lists:
8324 (if (eq cc t)
8325 (if (eq to t)
8326 from
8327 (mapcar (lambda (a) (car (memq a from))) to))
8328 (if (eq to t)
8329 (mapcar (lambda (a) (car (memq a from))) cc)
8330 (mapcar (lambda (a) (car (memq a from)))
8331 (mapcar (lambda (a) (car (memq a to)))
8332 cc))))
8333 (nconc (if (eq to t) nil to)
8334 (if (eq cc t) nil cc)
8335 from))))
8336 (unless articles
8337 (error "Found no matches for \"%s\"" address))
8338 (gnus-summary-limit articles))
8339 (gnus-summary-position-point))))
8341 (defun gnus-summary-limit-strange-charsets-predicate (header)
8342 (let ((string (concat (mail-header-subject header)
8343 (mail-header-from header)))
8344 charset found)
8345 (dotimes (i (1- (length string)))
8346 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8347 (when (string-match "unicode\\|big\\|japanese" charset)
8348 (setq found t)))
8349 found))
8351 (defun gnus-summary-limit-to-predicate (predicate)
8352 "Limit to articles where PREDICATE returns non-nil.
8353 PREDICATE will be called with the header structures of the
8354 articles."
8355 (let ((articles nil)
8356 (case-fold-search t))
8357 (dolist (header gnus-newsgroup-headers)
8358 (when (funcall predicate header)
8359 (push (mail-header-number header) articles)))
8360 (gnus-summary-limit (nreverse articles))))
8362 (defun gnus-summary-limit-to-age (age &optional younger-p)
8363 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8364 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8365 articles that are younger than AGE days."
8366 (interactive
8367 (let ((younger current-prefix-arg)
8368 (days-got nil)
8369 days)
8370 (while (not days-got)
8371 (setq days (if younger
8372 (read-string "Limit to articles younger than (in days, older when negative): ")
8373 (read-string
8374 "Limit to articles older than (in days, younger when negative): ")))
8375 (when (> (length days) 0)
8376 (setq days (read days)))
8377 (if (numberp days)
8378 (progn
8379 (setq days-got t)
8380 (when (< days 0)
8381 (setq younger (not younger))
8382 (setq days (* days -1))))
8383 (message "Please enter a number.")
8384 (sleep-for 1)))
8385 (list days younger)))
8386 (prog1
8387 (let ((data gnus-newsgroup-data)
8388 (cutoff (days-to-time age))
8389 articles d date is-younger)
8390 (while (setq d (pop data))
8391 (when (and (vectorp (gnus-data-header d))
8392 (setq date (mail-header-date (gnus-data-header d))))
8393 (setq is-younger (time-less-p
8394 (time-since (gnus-date-get-time date))
8395 cutoff))
8396 (when (if younger-p
8397 is-younger
8398 (not is-younger))
8399 (push (gnus-data-number d) articles))))
8400 (gnus-summary-limit (nreverse articles)))
8401 (gnus-summary-position-point)))
8403 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8404 "Limit the summary buffer to articles that match an `extra' header."
8405 (interactive
8406 (let ((header
8407 (intern
8408 (gnus-completing-read
8409 (if current-prefix-arg
8410 "Exclude extra header"
8411 "Limit extra header")
8412 (mapcar 'symbol-name gnus-extra-headers)
8413 t nil nil
8414 (symbol-name (car gnus-extra-headers))))))
8415 (list header
8416 (read-string (format "%s header %s (regexp): "
8417 (if current-prefix-arg "Exclude" "Limit to")
8418 header))
8419 current-prefix-arg)))
8420 (when (not (equal "" regexp))
8421 (prog1
8422 (let ((articles (gnus-summary-find-matching
8423 (cons 'extra header) regexp 'all nil nil
8424 not-matching)))
8425 (unless articles
8426 (error "Found no matches for \"%s\"" regexp))
8427 (gnus-summary-limit articles))
8428 (gnus-summary-position-point))))
8430 (defun gnus-summary-limit-to-display-predicate ()
8431 "Limit the summary buffer to the predicated in the `display' group parameter."
8432 (interactive)
8433 (unless gnus-newsgroup-display
8434 (error "There is no `display' group parameter"))
8435 (let (articles)
8436 (dolist (gnus-number gnus-newsgroup-articles)
8437 (when (funcall gnus-newsgroup-display)
8438 (push gnus-number articles)))
8439 (gnus-summary-limit articles))
8440 (gnus-summary-position-point))
8442 (defun gnus-summary-limit-to-unread (&optional all)
8443 "Limit the summary buffer to articles that are not marked as read.
8444 If ALL is non-nil, limit strictly to unread articles."
8445 (interactive "P")
8446 (if all
8447 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8448 (gnus-summary-limit-to-marks
8449 ;; Concat all the marks that say that an article is read and have
8450 ;; those removed.
8451 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8452 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8453 gnus-low-score-mark gnus-expirable-mark
8454 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8455 gnus-duplicate-mark)
8456 'reverse)))
8458 (defun gnus-summary-limit-to-headers (match &optional reverse)
8459 "Limit the summary buffer to articles that have headers that match MATCH.
8460 If REVERSE (the prefix), limit to articles that don't match."
8461 (interactive "sMatch headers (regexp): \nP")
8462 (gnus-summary-limit-to-bodies match reverse t))
8464 (declare-function article-goto-body "gnus-art" ())
8466 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8467 "Limit the summary buffer to articles that have bodies that match MATCH.
8468 If REVERSE (the prefix), limit to articles that don't match."
8469 (interactive "sMatch body (regexp): \nP")
8470 (let ((articles nil)
8471 (gnus-select-article-hook nil) ;Disable hook.
8472 (gnus-article-prepare-hook nil)
8473 (gnus-use-article-prefetch nil)
8474 (gnus-keep-backlog nil)
8475 (gnus-break-pages nil)
8476 (gnus-summary-display-arrow nil)
8477 (gnus-updated-mode-lines nil)
8478 (gnus-auto-center-summary nil)
8479 (gnus-display-mime-function nil))
8480 (dolist (data gnus-newsgroup-data)
8481 (let (gnus-mark-article-hook)
8482 (gnus-summary-select-article t t nil (gnus-data-number data)))
8483 (with-current-buffer gnus-article-buffer
8484 (article-goto-body)
8485 (let* ((case-fold-search t)
8486 (found (if headersp
8487 (re-search-backward match nil t)
8488 (re-search-forward match nil t))))
8489 (when (or (and found
8490 (not reverse))
8491 (and (not found)
8492 reverse))
8493 (push (gnus-data-number data) articles)))))
8494 (if (not articles)
8495 (message "No messages matched")
8496 (gnus-summary-limit articles)))
8497 (gnus-summary-position-point))
8499 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8500 "Limit the summary buffer to articles that aren't part on any thread.
8501 If THREADSP (the prefix), limit to articles that are in threads."
8502 (interactive "P")
8503 (let ((articles nil)
8504 thread-articles
8505 threads)
8506 (dolist (thread gnus-newsgroup-threads)
8507 (if (stringp (car thread))
8508 (dolist (thread (cdr thread))
8509 (push thread threads))
8510 (push thread threads)))
8511 (dolist (thread threads)
8512 (setq thread-articles (gnus-articles-in-thread thread))
8513 (when (or (and threadsp
8514 (> (length thread-articles) 1))
8515 (and (not threadsp)
8516 (= (length thread-articles) 1)))
8517 (setq articles (nconc thread-articles articles))))
8518 (if (not articles)
8519 (message "No messages matched")
8520 (gnus-summary-limit articles))
8521 (gnus-summary-position-point)))
8523 (defun gnus-summary-limit-to-replied (&optional unreplied)
8524 "Limit the summary buffer to replied articles.
8525 If UNREPLIED (the prefix), limit to unreplied articles."
8526 (interactive "P")
8527 (if unreplied
8528 (gnus-summary-limit
8529 (gnus-set-difference gnus-newsgroup-articles
8530 gnus-newsgroup-replied))
8531 (gnus-summary-limit gnus-newsgroup-replied))
8532 (gnus-summary-position-point))
8534 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8535 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8536 If REVERSE, limit the summary buffer to articles that are marked
8537 with MARKS. MARKS can either be a string of marks or a list of marks.
8538 Returns how many articles were removed."
8539 (interactive "sMarks: ")
8540 (gnus-summary-limit-to-marks marks t))
8542 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8543 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8544 If REVERSE (the prefix), limit the summary buffer to articles that are
8545 not marked with MARKS. MARKS can either be a string of marks or a
8546 list of marks.
8547 Returns how many articles were removed."
8548 (interactive "sMarks: \nP")
8549 (prog1
8550 (let ((data gnus-newsgroup-data)
8551 (marks (if (listp marks) marks
8552 (append marks nil))) ; Transform to list.
8553 articles)
8554 (while data
8555 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8556 (memq (gnus-data-mark (car data)) marks))
8557 (push (gnus-data-number (car data)) articles))
8558 (setq data (cdr data)))
8559 (gnus-summary-limit articles))
8560 (gnus-summary-position-point)))
8562 (defun gnus-summary-limit-to-score (score)
8563 "Limit to articles with score at or above SCORE."
8564 (interactive "NLimit to articles with score of at least: ")
8565 (let ((data gnus-newsgroup-data)
8566 articles)
8567 (while data
8568 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8569 score)
8570 (push (gnus-data-number (car data)) articles))
8571 (setq data (cdr data)))
8572 (prog1
8573 (gnus-summary-limit articles)
8574 (gnus-summary-position-point))))
8576 (defun gnus-summary-limit-to-unseen ()
8577 "Limit to unseen articles."
8578 (interactive)
8579 (prog1
8580 (gnus-summary-limit gnus-newsgroup-unseen)
8581 (gnus-summary-position-point)))
8583 (defun gnus-summary-limit-include-thread (id &optional thread-only)
8584 "Display all hidden articles belonging to thread ID.
8585 When called interactively, ID is the Message-ID of the current
8586 article. If thread-only is non-nil limit the summary buffer to
8587 these articles."
8588 (interactive (list (mail-header-id (gnus-summary-article-header))))
8589 (let ((articles (gnus-articles-in-thread
8590 (gnus-id-to-thread (gnus-root-id id))))
8591 ;;we REALLY want the whole thread---this prevents cut-threads
8592 ;;from removing the thread we want to include.
8593 (gnus-fetch-old-headers nil)
8594 (gnus-build-sparse-threads nil))
8595 (prog1
8596 (gnus-summary-limit (if thread-only articles
8597 (nconc articles gnus-newsgroup-limit)))
8598 (gnus-summary-limit-include-matching-articles
8599 "subject"
8600 (regexp-quote (gnus-general-simplify-subject
8601 (mail-header-subject (gnus-id-to-header id)))))
8602 ;; the previous two calls each push a limit onto the limit
8603 ;; stack. the first pop remove the articles that match the
8604 ;; subject, while the second pop gets us back to the state
8605 ;; before we started to deal with the thread. presumably we want
8606 ;; to think of the thread and its associated subject matches as
8607 ;; a single thing so that we need to pop only once to get back
8608 ;; to the original view.
8609 (pop gnus-newsgroup-limits)
8610 (gnus-summary-position-point))))
8612 (defun gnus-summary-limit-include-matching-articles (header regexp)
8613 "Display all the hidden articles that have HEADERs that match REGEXP."
8614 (interactive (list (read-string "Match on header: ")
8615 (read-string "Regexp: ")))
8616 (let ((articles (gnus-find-matching-articles header regexp)))
8617 (prog1
8618 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8619 (gnus-summary-position-point))))
8621 (defun gnus-summary-insert-dormant-articles ()
8622 "Insert all the dormant articles for this group into the current buffer."
8623 (interactive)
8624 (let ((gnus-verbose (max 6 gnus-verbose)))
8625 (if (not gnus-newsgroup-dormant)
8626 (gnus-message 3 "No dormant articles for this group")
8627 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8629 (defun gnus-summary-insert-ticked-articles ()
8630 "Insert ticked articles for this group into the current buffer."
8631 (interactive)
8632 (let ((gnus-verbose (max 6 gnus-verbose)))
8633 (if (not gnus-newsgroup-marked)
8634 (gnus-message 3 "No ticked articles for this group")
8635 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8637 (defun gnus-summary-limit-include-dormant ()
8638 "Display all the hidden articles that are marked as dormant.
8639 Note that this command only works on a subset of the articles currently
8640 fetched for this group."
8641 (interactive)
8642 (unless gnus-newsgroup-dormant
8643 (error "There are no dormant articles in this group"))
8644 (prog1
8645 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8646 (gnus-summary-position-point)))
8648 (defun gnus-summary-include-articles (articles)
8649 "Fetch the headers for ARTICLES and then display the summary lines."
8650 (let ((gnus-inhibit-demon t)
8651 (gnus-agent nil)
8652 (gnus-read-all-available-headers t))
8653 (setq gnus-newsgroup-headers
8654 (cl-merge
8655 'list gnus-newsgroup-headers
8656 (gnus-fetch-headers articles nil t)
8657 'gnus-article-sort-by-number))
8658 (setq gnus-newsgroup-articles
8659 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8660 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8662 (defun gnus-summary-limit-exclude-dormant ()
8663 "Hide all dormant articles."
8664 (interactive)
8665 (prog1
8666 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8667 (gnus-summary-position-point)))
8669 (defun gnus-summary-limit-exclude-childless-dormant ()
8670 "Hide all dormant articles that have no children."
8671 (interactive)
8672 (let ((data (gnus-data-list t))
8673 articles d children)
8674 ;; Find all articles that are either not dormant or have
8675 ;; children.
8676 (while (setq d (pop data))
8677 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8678 (and (setq children
8679 (gnus-article-children (gnus-data-number d)))
8680 (let (found)
8681 (while children
8682 (when (memq (car children) articles)
8683 (setq children nil
8684 found t))
8685 (pop children))
8686 found)))
8687 (push (gnus-data-number d) articles)))
8688 ;; Do the limiting.
8689 (prog1
8690 (gnus-summary-limit articles)
8691 (gnus-summary-position-point))))
8693 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8694 "Mark all unread excluded articles as read.
8695 If ALL, mark even excluded ticked and dormants as read."
8696 (interactive "P")
8697 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8698 (let ((articles (gnus-sorted-ndifference
8699 (sort
8700 (mapcar (lambda (h) (mail-header-number h))
8701 gnus-newsgroup-headers)
8703 gnus-newsgroup-limit))
8704 article)
8705 (setq gnus-newsgroup-unreads
8706 (gnus-sorted-intersection gnus-newsgroup-unreads
8707 gnus-newsgroup-limit))
8708 (if all
8709 (setq gnus-newsgroup-dormant nil
8710 gnus-newsgroup-marked nil
8711 gnus-newsgroup-reads
8712 (nconc
8713 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8714 gnus-newsgroup-reads))
8715 (while (setq article (pop articles))
8716 (unless (or (memq article gnus-newsgroup-dormant)
8717 (memq article gnus-newsgroup-marked))
8718 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8720 (defun gnus-summary-limit (articles &optional pop)
8721 (if pop
8722 ;; We pop the previous limit off the stack and use that.
8723 (setq articles (car gnus-newsgroup-limits)
8724 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8725 ;; We use the new limit, so we push the old limit on the stack.
8726 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8727 ;; Set the limit.
8728 (setq gnus-newsgroup-limit articles)
8729 (let ((total (length gnus-newsgroup-data))
8730 (data (gnus-data-find-list (gnus-summary-article-number)))
8731 (gnus-summary-mark-below nil) ; Inhibit this.
8732 found)
8733 ;; This will do all the work of generating the new summary buffer
8734 ;; according to the new limit.
8735 (gnus-summary-prepare)
8736 ;; Hide any threads, possibly.
8737 (gnus-summary-maybe-hide-threads)
8738 ;; Try to return to the article you were at, or one in the
8739 ;; neighborhood.
8740 (when data
8741 ;; We try to find some article after the current one.
8742 (while data
8743 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8744 (setq data nil
8745 found t))
8746 (setq data (cdr data))))
8747 (unless found
8748 ;; If there is no data, that means that we were after the last
8749 ;; article. The same goes when we can't find any articles
8750 ;; after the current one.
8751 (goto-char (point-max))
8752 (gnus-summary-find-prev))
8753 (gnus-set-mode-line 'summary)
8754 ;; We return how many articles were removed from the summary
8755 ;; buffer as a result of the new limit.
8756 (- total (length gnus-newsgroup-data))))
8758 (defsubst gnus-invisible-cut-children (threads)
8759 (let ((num 0))
8760 (while threads
8761 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8762 (incf num))
8763 (pop threads))
8764 (< num 2)))
8766 (defsubst gnus-cut-thread (thread)
8767 "Go forwards in the thread until we find an article that we want to display."
8768 (when (or (eq gnus-fetch-old-headers 'some)
8769 (eq gnus-fetch-old-headers 'invisible)
8770 (numberp gnus-fetch-old-headers)
8771 (eq gnus-build-sparse-threads 'some)
8772 (eq gnus-build-sparse-threads 'more))
8773 ;; Deal with old-fetched headers and sparse threads.
8774 (while (and
8775 thread
8777 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8778 (gnus-summary-article-ancient-p
8779 (mail-header-number (car thread))))
8780 (if (or (<= (length (cdr thread)) 1)
8781 (eq gnus-fetch-old-headers 'invisible))
8782 (setq gnus-newsgroup-limit
8783 (delq (mail-header-number (car thread))
8784 gnus-newsgroup-limit)
8785 thread (cadr thread))
8786 (when (gnus-invisible-cut-children (cdr thread))
8787 (let ((th (cdr thread)))
8788 (while th
8789 (if (memq (mail-header-number (caar th))
8790 gnus-newsgroup-limit)
8791 (setq thread (car th)
8792 th nil)
8793 (setq th (cdr th))))))))))
8794 thread)
8796 (defun gnus-cut-threads (threads)
8797 "Cut off all uninteresting articles from the beginning of THREADS."
8798 (when (or (eq gnus-fetch-old-headers 'some)
8799 (eq gnus-fetch-old-headers 'invisible)
8800 (numberp gnus-fetch-old-headers)
8801 (eq gnus-build-sparse-threads 'some)
8802 (eq gnus-build-sparse-threads 'more))
8803 (let ((th threads))
8804 (while th
8805 (setcar th (gnus-cut-thread (car th)))
8806 (setq th (cdr th)))))
8807 ;; Remove nixed out threads.
8808 (delq nil threads))
8810 (defun gnus-summary-initial-limit (&optional show-if-empty)
8811 "Figure out what the initial limit is supposed to be on group entry.
8812 This entails weeding out unwanted dormants, low-scored articles,
8813 fetch-old-headers verbiage, and so on."
8814 ;; Most groups have nothing to remove.
8815 (unless (or gnus-inhibit-limiting
8816 (and (null gnus-newsgroup-dormant)
8817 (eq gnus-newsgroup-display 'gnus-not-ignore)
8818 (not (eq gnus-fetch-old-headers 'some))
8819 (not (numberp gnus-fetch-old-headers))
8820 (not (eq gnus-fetch-old-headers 'invisible))
8821 (null gnus-summary-expunge-below)
8822 (not (eq gnus-build-sparse-threads 'some))
8823 (not (eq gnus-build-sparse-threads 'more))
8824 (null gnus-thread-expunge-below)))
8825 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8826 (setq gnus-newsgroup-limit nil)
8827 (mapatoms
8828 (lambda (node)
8829 (unless (car (symbol-value node))
8830 ;; These threads have no parents -- they are roots.
8831 (let ((nodes (cdr (symbol-value node)))
8832 thread)
8833 (while nodes
8834 (if (and gnus-thread-expunge-below
8835 (< (gnus-thread-total-score (car nodes))
8836 gnus-thread-expunge-below))
8837 (gnus-expunge-thread (pop nodes))
8838 (setq thread (pop nodes))
8839 (gnus-summary-limit-children thread))))))
8840 gnus-newsgroup-dependencies)
8841 ;; If this limitation resulted in an empty group, we might
8842 ;; pop the previous limit and use it instead.
8843 (when (and (not gnus-newsgroup-limit)
8844 show-if-empty)
8845 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8846 gnus-newsgroup-limit))
8848 (defun gnus-summary-limit-children (thread)
8849 "Return 1 if this subthread is visible and 0 if it is not."
8850 ;; First we get the number of visible children to this thread. This
8851 ;; is done by recursing down the thread using this function, so this
8852 ;; will really go down to a leaf article first, before slowly
8853 ;; working its way up towards the root.
8854 (when thread
8855 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8856 (children
8857 (if (cdr thread)
8858 (apply '+ (mapcar 'gnus-summary-limit-children
8859 (cdr thread)))
8861 (number (mail-header-number (car thread)))
8862 score)
8863 (if (and
8864 (not (memq number gnus-newsgroup-marked))
8866 ;; If this article is dormant and has absolutely no visible
8867 ;; children, then this article isn't visible.
8868 (and (memq number gnus-newsgroup-dormant)
8869 (zerop children))
8870 ;; If this is "fetch-old-headered" and there is no
8871 ;; visible children, then we don't want this article.
8872 (and (or (eq gnus-fetch-old-headers 'some)
8873 (numberp gnus-fetch-old-headers))
8874 (gnus-summary-article-ancient-p number)
8875 (zerop children))
8876 ;; If this is "fetch-old-headered" and `invisible', then
8877 ;; we don't want this article.
8878 (and (eq gnus-fetch-old-headers 'invisible)
8879 (gnus-summary-article-ancient-p number))
8880 ;; If this is a sparsely inserted article with no children,
8881 ;; we don't want it.
8882 (and (eq gnus-build-sparse-threads 'some)
8883 (gnus-summary-article-sparse-p number)
8884 (zerop children))
8885 ;; If we use expunging, and this article is really
8886 ;; low-scored, then we don't want this article.
8887 (when (and gnus-summary-expunge-below
8888 (< (setq score
8889 (or (cdr (assq number gnus-newsgroup-scored))
8890 gnus-summary-default-score))
8891 gnus-summary-expunge-below))
8892 ;; We increase the expunge-tally here, but that has
8893 ;; nothing to do with the limits, really.
8894 (incf gnus-newsgroup-expunged-tally)
8895 ;; We also mark as read here, if that's wanted.
8896 (when (and gnus-summary-mark-below
8897 (< score gnus-summary-mark-below))
8898 (setq gnus-newsgroup-unreads
8899 (delq number gnus-newsgroup-unreads))
8900 (if gnus-newsgroup-auto-expire
8901 (push number gnus-newsgroup-expirable)
8902 (push (cons number gnus-low-score-mark)
8903 gnus-newsgroup-reads)))
8905 ;; Do the `display' group parameter.
8906 (and gnus-newsgroup-display
8907 (let ((gnus-number number))
8908 (not (funcall gnus-newsgroup-display))))))
8909 ;; Nope, invisible article.
8911 ;; Ok, this article is to be visible, so we add it to the limit
8912 ;; and return 1.
8913 (push number gnus-newsgroup-limit)
8914 1))))
8916 (defun gnus-expunge-thread (thread)
8917 "Mark all articles in THREAD as read."
8918 (let* ((number (mail-header-number (car thread))))
8919 (incf gnus-newsgroup-expunged-tally)
8920 ;; We also mark as read here, if that's wanted.
8921 (setq gnus-newsgroup-unreads
8922 (delq number gnus-newsgroup-unreads))
8923 (if gnus-newsgroup-auto-expire
8924 (push number gnus-newsgroup-expirable)
8925 (push (cons number gnus-low-score-mark)
8926 gnus-newsgroup-reads)))
8927 ;; Go recursively through all subthreads.
8928 (mapcar 'gnus-expunge-thread (cdr thread)))
8930 ;; Summary article oriented commands
8932 (defun gnus-summary-refer-parent-article (n)
8933 "Refer parent article N times.
8934 If N is negative, go to ancestor -N instead.
8935 The difference between N and the number of articles fetched is returned."
8936 (interactive "p")
8937 (let ((skip 1)
8938 error header ref)
8939 (when (not (natnump n))
8940 (setq skip (abs n)
8941 n 1))
8942 (while (and (> n 0)
8943 (not error))
8944 (setq header (gnus-summary-article-header))
8945 (if (and (eq (mail-header-number header)
8946 (cdr gnus-article-current))
8947 (equal gnus-newsgroup-name
8948 (car gnus-article-current)))
8949 ;; If we try to find the parent of the currently
8950 ;; displayed article, then we take a look at the actual
8951 ;; References header, since this is slightly more
8952 ;; reliable than the References field we got from the
8953 ;; server.
8954 (with-current-buffer gnus-original-article-buffer
8955 (nnheader-narrow-to-headers)
8956 (unless (setq ref (message-fetch-field "references"))
8957 (when (setq ref (message-fetch-field "in-reply-to"))
8958 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8959 (widen))
8960 (setq ref
8961 ;; It's not the current article, so we take a bet on
8962 ;; the value we got from the server.
8963 (mail-header-references header)))
8964 (if (and ref
8965 (not (equal ref "")))
8966 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8967 (gnus-message 1 "Couldn't find parent"))
8968 (gnus-message 1 "No references in article %d"
8969 (gnus-summary-article-number))
8970 (setq error t))
8971 (decf n))
8972 (gnus-summary-position-point)
8975 (defun gnus-summary-refer-references ()
8976 "Fetch all articles mentioned in the References header.
8977 Return the number of articles fetched."
8978 (interactive)
8979 (let ((ref (mail-header-references (gnus-summary-article-header)))
8980 (current (gnus-summary-article-number))
8981 (n 0))
8982 (if (or (not ref)
8983 (equal ref ""))
8984 (error "No References in the current article")
8985 ;; For each Message-ID in the References header...
8986 (while (string-match "<[^>]*>" ref)
8987 (incf n)
8988 ;; ... fetch that article.
8989 (gnus-summary-refer-article
8990 (prog1 (match-string 0 ref)
8991 (setq ref (substring ref (match-end 0))))))
8992 (gnus-summary-goto-subject current)
8993 (gnus-summary-position-point)
8994 n)))
8996 (defun gnus-delete-duplicate-headers (headers)
8997 ;; First remove leading duplicates.
8998 (while (and (> (length headers) 1)
8999 (= (mail-header-number (car headers))
9000 (mail-header-number (cadr headers))))
9001 (pop headers))
9002 ;; Then the rest.
9003 (let ((result headers))
9004 (while (> (length headers) 1)
9005 (if (= (mail-header-number (car headers))
9006 (mail-header-number (cadr headers)))
9007 (setcdr headers (cddr headers))
9008 (pop headers)))
9009 result))
9011 (defun gnus-summary-refer-thread (&optional limit)
9012 "Fetch all articles in the current thread. For backends that
9013 know how to search for threads (currently only 'nnimap) a
9014 non-numeric prefix arg will use nnir to search the entire
9015 server; without a prefix arg only the current group is
9016 searched. If the variable `gnus-refer-thread-use-nnir' is
9017 non-nil the prefix arg has the reverse meaning. If no
9018 backend-specific 'request-thread function is available fetch
9019 LIMIT (the numerical prefix) old headers. If LIMIT is
9020 non-numeric or nil fetch the number specified by the
9021 `gnus-refer-thread-limit' variable."
9022 (interactive "P")
9023 (let* ((header (gnus-summary-article-header))
9024 (id (mail-header-id header))
9025 (gnus-inhibit-demon t)
9026 (gnus-summary-ignore-duplicates t)
9027 (gnus-read-all-available-headers t)
9028 (gnus-refer-thread-use-nnir
9029 (if (and (not (null limit)) (listp limit))
9030 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9031 (new-headers
9032 (if (gnus-check-backend-function
9033 'request-thread gnus-newsgroup-name)
9034 (gnus-request-thread header gnus-newsgroup-name)
9035 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9036 gnus-refer-thread-limit))
9037 (last (if (numberp limit)
9038 (min (+ (mail-header-number header)
9039 limit)
9040 gnus-newsgroup-highest)
9041 gnus-newsgroup-highest))
9042 (subject (gnus-simplify-subject
9043 (mail-header-subject header)))
9044 (refs (split-string (or (mail-header-references header)
9045 "")))
9046 (gnus-parse-headers-hook
9047 `(lambda () (goto-char (point-min))
9048 (keep-lines
9049 (regexp-opt ',(append refs (list id subject)))))))
9050 (gnus-fetch-headers (list last) (if (numberp limit)
9051 (* 2 limit) limit) t))))
9052 article-ids new-unreads)
9053 (when (listp new-headers)
9054 (dolist (header new-headers)
9055 (push (mail-header-number header) article-ids))
9056 (setq article-ids (nreverse article-ids))
9057 (setq new-unreads
9058 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9059 (setq gnus-newsgroup-unselected
9060 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9061 (setq gnus-newsgroup-unreads
9062 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9063 (setq gnus-newsgroup-headers
9064 (gnus-delete-duplicate-headers
9065 (cl-merge
9066 'list gnus-newsgroup-headers new-headers
9067 'gnus-article-sort-by-number)))
9068 (setq gnus-newsgroup-articles
9069 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9070 (gnus-summary-limit-include-thread id gnus-refer-thread-limit-to-thread)))
9071 (gnus-summary-show-thread))
9073 (defun gnus-summary-open-group-with-article (message-id)
9074 "Open a group containing the article with the given MESSAGE-ID."
9075 (interactive "sMessage-ID: ")
9076 (require 'nndoc)
9077 (with-temp-buffer
9078 ;; Prepare a dummy article
9079 (erase-buffer)
9080 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9082 ;; Prepare pretty modelines for summary and article buffers
9083 (let ((gnus-summary-mode-line-format "Found %G")
9084 (gnus-article-mode-line-format
9085 ;; Group names just get in the way here, especially the
9086 ;; abbreviated ones
9087 (if (string-match "%[gG]" gnus-article-mode-line-format)
9088 (concat (substring gnus-article-mode-line-format
9089 0 (match-beginning 0))
9090 (substring gnus-article-mode-line-format (match-end 0)))
9091 gnus-article-mode-line-format)))
9093 ;; Build an ephemeral group containing the dummy article (hidden)
9094 (gnus-group-read-ephemeral-group
9095 message-id
9096 `(nndoc ,message-id
9097 (nndoc-address ,(current-buffer))
9098 (nndoc-article-type mbox))
9099 :activate
9100 (cons (current-buffer) gnus-current-window-configuration)
9101 (not :request-only)
9102 '(-1) ; :select-articles
9103 (not :parameters)
9104 0)) ; :number
9105 ;; Fetch the desired article
9106 (gnus-summary-refer-article message-id)))
9108 (defun gnus-summary-refer-article (message-id)
9109 "Fetch an article specified by MESSAGE-ID."
9110 (interactive "sMessage-ID: ")
9111 (when (and (stringp message-id)
9112 (not (zerop (length message-id))))
9113 (setq message-id (replace-regexp-in-string " " "" message-id))
9114 ;; Construct the correct Message-ID if necessary.
9115 ;; Suggested by tale@pawl.rpi.edu.
9116 (unless (string-match "^<" message-id)
9117 (setq message-id (concat "<" message-id)))
9118 (unless (string-match ">$" message-id)
9119 (setq message-id (concat message-id ">")))
9120 ;; People often post MIDs from URLs, so unhex it:
9121 (unless (string-match "@" message-id)
9122 (setq message-id (gnus-url-unhex-string message-id)))
9123 (let* ((header (gnus-id-to-header message-id))
9124 (sparse (and header
9125 (gnus-summary-article-sparse-p
9126 (mail-header-number header))
9127 (memq (mail-header-number header)
9128 gnus-newsgroup-limit)))
9129 number)
9130 (cond
9131 ;; If the article is present in the buffer we just go to it.
9132 ((and header
9133 (or (not (gnus-summary-article-sparse-p
9134 (mail-header-number header)))
9135 sparse))
9136 (prog1
9137 (gnus-summary-goto-article
9138 (mail-header-number header) nil t)
9139 (when sparse
9140 (gnus-summary-update-article (mail-header-number header)))))
9142 ;; We fetch the article.
9143 (catch 'found
9144 (dolist (gnus-override-method (gnus-refer-article-methods))
9145 (when (and (gnus-check-server gnus-override-method)
9146 ;; Fetch the header,
9147 (setq number (gnus-summary-insert-subject message-id)))
9148 ;; and display the article.
9149 (gnus-summary-select-article nil nil nil number)
9150 (throw 'found t)))
9151 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9153 (defun gnus-refer-article-methods ()
9154 "Return a list of referable methods."
9155 (cond
9156 ;; No method, so we default to current and native.
9157 ((null gnus-refer-article-method)
9158 (list gnus-current-select-method gnus-select-method))
9159 ;; Current.
9160 ((eq 'current gnus-refer-article-method)
9161 (list gnus-current-select-method))
9162 ;; List of select methods.
9163 ((not (and (symbolp (car gnus-refer-article-method))
9164 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9165 (let (out)
9166 (dolist (method gnus-refer-article-method)
9167 (push (if (eq 'current method)
9168 gnus-current-select-method
9169 (if (eq 'nnir (car method))
9170 (list
9171 'nnir
9172 (or (cadr method)
9173 (gnus-method-to-server gnus-current-select-method)))
9174 method))
9175 out))
9176 (nreverse out)))
9177 ;; One single select method.
9179 (list gnus-refer-article-method))))
9181 (defun gnus-summary-edit-parameters ()
9182 "Edit the group parameters of the current group."
9183 (interactive)
9184 (gnus-group-edit-group gnus-newsgroup-name 'params))
9186 (defun gnus-summary-customize-parameters ()
9187 "Customize the group parameters of the current group."
9188 (interactive)
9189 (gnus-group-customize gnus-newsgroup-name))
9191 (defun gnus-summary-enter-digest-group (&optional force)
9192 "Enter an nndoc group based on the current article.
9193 If FORCE, force a digest interpretation. If not, try to guess
9194 what the document format is.
9196 To control what happens when you exit the group, see the
9197 `gnus-auto-select-on-ephemeral-exit' variable."
9198 (interactive "P")
9199 (let ((conf gnus-current-window-configuration))
9200 (save-window-excursion
9201 (save-excursion
9202 (let (gnus-article-prepare-hook
9203 gnus-display-mime-function
9204 gnus-break-pages)
9205 (gnus-summary-select-article))))
9206 (setq gnus-current-window-configuration conf)
9207 (let* ((name (format "%s-%d"
9208 (gnus-group-prefixed-name
9209 gnus-newsgroup-name (list 'nndoc ""))
9210 (with-current-buffer gnus-summary-buffer
9211 gnus-current-article)))
9212 (ogroup gnus-newsgroup-name)
9213 (params (append (gnus-info-params (gnus-get-info ogroup))
9214 (list (cons 'to-group ogroup))
9215 (list (cons 'parent-group ogroup))
9216 (list (cons 'save-article-group ogroup))))
9217 (case-fold-search t)
9218 (buf (current-buffer))
9219 dig to-address charset)
9220 (with-current-buffer gnus-original-article-buffer
9221 ;; Have the digest group inherit the main mail address of
9222 ;; the parent article.
9223 (when (setq to-address (or (gnus-fetch-field "reply-to")
9224 (gnus-fetch-field "from")))
9225 (setq params
9226 (append
9227 params
9228 (list (cons 'to-address
9229 (funcall gnus-decode-encoded-address-function
9230 to-address))))))
9231 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9232 (insert-buffer-substring gnus-original-article-buffer)
9233 (narrow-to-region
9234 (goto-char (point-min))
9235 (or (search-forward "\n\n" nil t) (point)))
9236 ;; Remove lines that may lead nndoc to misinterpret the
9237 ;; document type.
9238 (goto-char (point-min))
9239 (delete-matching-lines "^Path:\\|^From ")
9240 ;; Parse charset, and decode content transfer encoding.
9241 (setq charset (mail-content-type-get
9242 (mail-header-parse-content-type
9243 (or (gnus-fetch-field "content-type") ""))
9244 'charset))
9245 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9246 (when encoding
9247 (message-remove-header "content-transfer-encoding")
9248 (goto-char (point-max))
9249 (widen)
9250 (narrow-to-region (point) (point-max))
9251 (mm-decode-content-transfer-encoding
9252 (intern (downcase (mail-header-strip-cte encoding))))))
9253 (widen))
9254 (unwind-protect
9255 (if (let ((gnus-newsgroup-ephemeral-charset
9256 (if charset
9257 (intern (downcase (gnus-strip-whitespace charset)))
9258 gnus-newsgroup-charset))
9259 (gnus-newsgroup-ephemeral-ignored-charsets
9260 gnus-newsgroup-ignored-charsets))
9261 (gnus-group-read-ephemeral-group
9262 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9263 (nndoc-article-type
9264 ,(if force 'mbox 'guess)))
9265 t nil nil nil
9266 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9267 "ADAPT")))))
9268 ;; Make all postings to this group go to the parent group.
9269 (nconc (gnus-info-params (gnus-get-info name))
9270 params)
9271 ;; Couldn't select this doc group.
9272 (switch-to-buffer buf)
9273 (gnus-set-global-variables)
9274 (gnus-configure-windows 'summary)
9275 (gnus-message 3 "Article couldn't be entered?"))
9276 (kill-buffer dig)))))
9278 (defun gnus-summary-read-document (n)
9279 "Open a new group based on the current article(s).
9280 This will allow you to read digests and other similar
9281 documents as newsgroups.
9282 Obeys the standard process/prefix convention."
9283 (interactive "P")
9284 (let* ((ogroup gnus-newsgroup-name)
9285 (params (append (gnus-info-params (gnus-get-info ogroup))
9286 (list (cons 'to-group ogroup))))
9287 group egroup groups vgroup)
9288 (dolist (article (gnus-summary-work-articles n))
9289 (setq group (format "%s-%d" gnus-newsgroup-name article))
9290 (gnus-summary-remove-process-mark article)
9291 (when (gnus-summary-display-article article)
9292 (save-excursion ;;What for?
9293 (with-temp-buffer
9294 (insert-buffer-substring gnus-original-article-buffer)
9295 ;; Remove some headers that may lead nndoc to make
9296 ;; the wrong guess.
9297 (message-narrow-to-head)
9298 (goto-char (point-min))
9299 (delete-matching-lines "^Path:\\|^From ")
9300 (widen)
9301 (if (setq egroup
9302 (gnus-group-read-ephemeral-group
9303 group `(nndoc ,group (nndoc-address ,(current-buffer))
9304 (nndoc-article-type guess))
9305 t nil t))
9306 (progn
9307 ;; Make all postings to this group go to the parent group.
9308 (nconc (gnus-info-params (gnus-get-info egroup))
9309 params)
9310 (push egroup groups))
9311 ;; Couldn't select this doc group.
9312 (gnus-error 3 "Article couldn't be entered"))))))
9313 ;; Now we have selected all the documents.
9314 (cond
9315 ((not groups)
9316 (error "None of the articles could be interpreted as documents"))
9317 ((gnus-group-read-ephemeral-group
9318 (setq vgroup (format
9319 "nnvirtual:%s-%s" gnus-newsgroup-name
9320 (format-time-string "%Y%m%dT%H%M%S")))
9321 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9323 (cons (current-buffer) 'summary)))
9325 (error "Couldn't select virtual nndoc group")))))
9327 (defun gnus-summary-widget-forward (arg)
9328 "Move point to the next field or button in the article.
9329 With optional ARG, move across that many fields."
9330 (interactive "p")
9331 (gnus-summary-select-article)
9332 (gnus-configure-windows 'article)
9333 (select-window (gnus-get-buffer-window gnus-article-buffer))
9334 (widget-forward arg))
9336 (defun gnus-summary-widget-backward (arg)
9337 "Move point to the previous field or button in the article.
9338 With optional ARG, move across that many fields."
9339 (interactive "p")
9340 (gnus-summary-select-article)
9341 (gnus-configure-windows 'article)
9342 (select-window (gnus-get-buffer-window gnus-article-buffer))
9343 (unless (widget-at (point))
9344 (goto-char (point-max)))
9345 (widget-backward arg))
9347 (defun gnus-summary-isearch-article (&optional regexp-p)
9348 "Do incremental search forward on the current article.
9349 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9350 (interactive "P")
9351 (gnus-summary-select-article)
9352 (gnus-configure-windows 'article)
9353 (gnus-eval-in-buffer-window gnus-article-buffer
9354 (save-restriction
9355 (widen)
9356 (isearch-forward regexp-p))))
9358 (defun gnus-summary-repeat-search-article-forward ()
9359 "Repeat the previous search forwards."
9360 (interactive)
9361 (unless gnus-last-search-regexp
9362 (error "No previous search"))
9363 (gnus-summary-search-article-forward gnus-last-search-regexp))
9365 (defun gnus-summary-repeat-search-article-backward ()
9366 "Repeat the previous search backwards."
9367 (interactive)
9368 (unless gnus-last-search-regexp
9369 (error "No previous search"))
9370 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9372 (defun gnus-summary-search-article-forward (regexp &optional backward)
9373 "Search for an article containing REGEXP forward.
9374 If BACKWARD, search backward instead."
9375 (interactive
9376 (list (read-string
9377 (format "Search article %s (regexp%s): "
9378 (if current-prefix-arg "backward" "forward")
9379 (if gnus-last-search-regexp
9380 (concat ", default " gnus-last-search-regexp)
9381 "")))
9382 current-prefix-arg))
9383 (if (string-equal regexp "")
9384 (setq regexp (or gnus-last-search-regexp ""))
9385 (setq gnus-last-search-regexp regexp)
9386 (setq gnus-article-before-search gnus-current-article))
9387 ;; Intentionally set gnus-last-article.
9388 (setq gnus-last-article gnus-article-before-search)
9389 (let ((gnus-last-article gnus-last-article))
9390 (if (gnus-summary-search-article regexp backward)
9391 (gnus-summary-show-thread)
9392 (signal 'search-failed (list regexp)))))
9394 (defun gnus-summary-search-article-backward (regexp)
9395 "Search for an article containing REGEXP backward."
9396 (interactive
9397 (list (read-string
9398 (format "Search article backward (regexp%s): "
9399 (if gnus-last-search-regexp
9400 (concat ", default " gnus-last-search-regexp)
9401 "")))))
9402 (gnus-summary-search-article-forward regexp 'backward))
9404 (defun gnus-summary-search-article (regexp &optional backward)
9405 "Search for an article containing REGEXP.
9406 Optional argument BACKWARD means do search for backward.
9407 `gnus-select-article-hook' is not called during the search."
9408 ;; We have to require this here to make sure that the following
9409 ;; dynamic binding isn't shadowed by autoloading.
9410 (require 'gnus-async)
9411 (require 'gnus-art)
9412 (let ((gnus-select-article-hook nil) ;Disable hook.
9413 (gnus-article-prepare-hook nil)
9414 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9415 (gnus-use-article-prefetch nil)
9416 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9417 (gnus-visual nil)
9418 (gnus-keep-backlog nil)
9419 (gnus-break-pages nil)
9420 (gnus-summary-display-arrow nil)
9421 (gnus-updated-mode-lines nil)
9422 (gnus-auto-center-summary nil)
9423 (sum (current-buffer))
9424 (gnus-display-mime-function nil)
9425 (found nil)
9426 point)
9427 (gnus-save-hidden-threads
9428 (gnus-summary-select-article)
9429 (set-buffer gnus-article-buffer)
9430 (goto-char (window-point (get-buffer-window (current-buffer))))
9431 (when backward
9432 (forward-line -1))
9433 (while (not found)
9434 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9435 (if (if backward
9436 (re-search-backward regexp nil t)
9437 (re-search-forward regexp nil t))
9438 ;; We found the regexp.
9439 (progn
9440 (setq found 'found)
9441 (beginning-of-line)
9442 (set-window-start
9443 (get-buffer-window (current-buffer))
9444 (point))
9445 (forward-line 1)
9446 (set-window-point
9447 (get-buffer-window (current-buffer))
9448 (point))
9449 (set-buffer sum)
9450 (setq point (point)))
9451 ;; We didn't find it, so we go to the next article.
9452 (set-buffer sum)
9453 (setq found 'not)
9454 (while (eq found 'not)
9455 (if (not (if backward (gnus-summary-find-prev)
9456 (gnus-summary-find-next)))
9457 ;; No more articles.
9458 (setq found t)
9459 ;; Select the next article and adjust point.
9460 (unless (gnus-summary-article-sparse-p
9461 (gnus-summary-article-number))
9462 (setq found nil)
9463 (gnus-summary-select-article)
9464 (set-buffer gnus-article-buffer)
9465 (widen)
9466 (goto-char (if backward (point-max) (point-min))))))))
9467 (gnus-message 7 ""))
9468 ;; Return whether we found the regexp.
9469 (when (eq found 'found)
9470 (goto-char point)
9471 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9472 (gnus-summary-show-thread)
9473 (gnus-summary-goto-subject gnus-current-article)
9474 (gnus-summary-position-point)
9475 t)))
9477 (defun gnus-find-matching-articles (header regexp)
9478 "Return a list of all articles that match REGEXP on HEADER.
9479 This search includes all articles in the current group that Gnus has
9480 fetched headers for, whether they are displayed or not."
9481 (let ((articles nil)
9482 ;; Can't eta-reduce because it's a macro.
9483 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9484 (case-fold-search t))
9485 (dolist (header gnus-newsgroup-headers)
9486 (when (string-match regexp (funcall func header))
9487 (push (mail-header-number header) articles)))
9488 (nreverse articles)))
9490 (defun gnus-summary-find-matching (header regexp &optional backward unread
9491 not-case-fold not-matching)
9492 "Return a list of all articles that match REGEXP on HEADER.
9493 The search stars on the current article and goes forwards unless
9494 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9495 If UNREAD is non-nil, only unread articles will
9496 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9497 in the comparisons. If NOT-MATCHING, return a list of all articles that
9498 not match REGEXP on HEADER."
9499 (let ((case-fold-search (not not-case-fold))
9500 articles d func)
9501 (if (consp header)
9502 (if (eq (car header) 'extra)
9503 (setq func
9504 `(lambda (h)
9505 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9506 "")))
9507 (error "%s is an invalid header" header))
9508 (unless (fboundp (intern (concat "mail-header-" header)))
9509 (error "%s is not a valid header" header))
9510 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9511 (dolist (d (if (eq backward 'all)
9512 gnus-newsgroup-data
9513 (gnus-data-find-list
9514 (gnus-summary-article-number)
9515 (gnus-data-list backward))))
9516 (when (and (or (not unread) ; We want all articles...
9517 (gnus-data-unread-p d)) ; Or just unreads.
9518 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9519 (if not-matching
9520 (not (string-match
9521 regexp
9522 (funcall func (gnus-data-header d))))
9523 (string-match regexp
9524 (funcall func (gnus-data-header d)))))
9525 (push (gnus-data-number d) articles))) ; Success!
9526 (nreverse articles)))
9528 (defun gnus-summary-execute-command (header regexp command &optional backward)
9529 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9530 If HEADER is an empty string (or nil), the match is done on the entire
9531 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9532 (interactive
9533 (list (let ((completion-ignore-case t))
9534 (gnus-completing-read
9535 "Header name"
9536 (mapcar 'symbol-name
9537 (append
9538 '(Number Subject From Lines Date
9539 Message-ID Xref References Body)
9540 gnus-extra-headers))
9541 'require-match))
9542 (read-string "Regexp: ")
9543 (read-key-sequence "Command: ")
9544 current-prefix-arg))
9545 (when (equal header "Body")
9546 (setq header ""))
9547 ;; Hidden thread subtrees must be searched as well.
9548 (gnus-summary-show-all-threads)
9549 ;; We don't want to change current point nor window configuration.
9550 (save-excursion
9551 (save-window-excursion
9552 (let (gnus-visual
9553 gnus-treat-strip-trailing-blank-lines
9554 gnus-treat-strip-leading-blank-lines
9555 gnus-treat-strip-multiple-blank-lines
9556 gnus-treat-hide-boring-headers
9557 gnus-treat-fold-newsgroups
9558 gnus-article-prepare-hook)
9559 (gnus-message 6 "Executing %s..." (key-description command))
9560 ;; We'd like to execute COMMAND interactively so as to give arguments.
9561 (gnus-execute header regexp
9562 `(call-interactively ',(key-binding command))
9563 backward)
9564 (gnus-message 6 "Executing %s...done" (key-description command))))))
9566 (defun gnus-summary-beginning-of-article ()
9567 "Scroll the article back to the beginning."
9568 (interactive)
9569 (gnus-summary-select-article)
9570 (gnus-configure-windows 'article)
9571 (gnus-eval-in-buffer-window gnus-article-buffer
9572 (widen)
9573 (goto-char (point-min))
9574 (when gnus-break-pages
9575 (gnus-narrow-to-page))))
9577 (defun gnus-summary-end-of-article ()
9578 "Scroll to the end of the article."
9579 (interactive)
9580 (gnus-summary-select-article)
9581 (gnus-configure-windows 'article)
9582 (gnus-eval-in-buffer-window gnus-article-buffer
9583 (widen)
9584 (goto-char (point-max))
9585 (recenter -3)
9586 (when gnus-break-pages
9587 (gnus-narrow-to-page))))
9589 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9590 "Truncate to LEN and quote all \"(\"'s in STRING."
9591 (replace-regexp-in-string "[()]" "\\\\\\&"
9592 (if (and len (> (length string) len))
9593 (substring string 0 len)
9594 string)))
9596 (defun gnus-summary-print-article (&optional filename n)
9597 "Generate and print a PostScript image of the process-marked (mail) articles.
9599 If used interactively, print the current article if none are
9600 process-marked. With prefix arg, prompt the user for the name of the
9601 file to save in.
9603 When used from Lisp, accept two optional args FILENAME and N. N means
9604 to print the next N articles. If N is negative, print the N previous
9605 articles. If N is nil and articles have been marked with the process
9606 mark, print these instead.
9608 If the optional first argument FILENAME is nil, send the image to the
9609 printer. If FILENAME is a string, save the PostScript image in a file with
9610 that name. If FILENAME is a number, prompt the user for the name of the file
9611 to save in."
9612 (interactive (list (ps-print-preprint current-prefix-arg)))
9613 (dolist (article (gnus-summary-work-articles n))
9614 (gnus-summary-select-article nil nil 'pseudo article)
9615 (gnus-eval-in-buffer-window gnus-article-buffer
9616 (gnus-print-buffer))
9617 (gnus-summary-remove-process-mark article))
9618 (ps-despool filename))
9620 (defun gnus-print-buffer ()
9621 (let ((ps-left-header
9622 (list
9623 (concat "("
9624 (gnus-summary-print-truncate-and-quote
9625 (mail-header-subject gnus-current-headers)
9626 66) ")")
9627 (concat "("
9628 (gnus-summary-print-truncate-and-quote
9629 (mail-header-from gnus-current-headers)
9630 45) ")")))
9631 (ps-right-header
9632 (list
9633 "/pagenumberstring load"
9634 (concat "("
9635 (mail-header-date gnus-current-headers) ")"))))
9636 (gnus-run-hooks 'gnus-ps-print-hook)
9637 (save-excursion
9638 (if ps-print-color-p
9639 (ps-spool-buffer-with-faces)
9640 (ps-spool-buffer)))))
9642 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9644 (defun gnus-summary-show-complete-article ()
9645 "Show a complete version of the current article.
9646 This is only useful if you're looking at a partial version of the
9647 article currently."
9648 (interactive)
9649 (let ((gnus-keep-backlog nil)
9650 (gnus-use-cache nil)
9651 (gnus-agent nil)
9652 (variable (intern
9653 (format "%s-fetch-partial-articles"
9654 (car (gnus-find-method-for-group
9655 gnus-newsgroup-name)))
9656 obarray))
9657 old-val)
9658 (unwind-protect
9659 (progn
9660 (setq old-val (symbol-value variable))
9661 (set variable nil)
9662 (gnus-flush-original-article-buffer)
9663 (gnus-summary-show-article))
9664 (set variable old-val))))
9666 (defun gnus-summary-show-article (&optional arg)
9667 "Force redisplaying of the current article.
9668 If ARG (the prefix) is a number, show the article with the charset
9669 defined in `gnus-summary-show-article-charset-alist', or the charset
9670 input.
9671 If ARG (the prefix) is non-nil and not a number, show the article,
9672 but without running any of the article treatment functions
9673 article. Normally, the keystroke is `C-u g'. When using `C-u
9674 C-u g', show the raw article."
9675 (interactive "P")
9676 (cond
9677 ((numberp arg)
9678 (gnus-summary-show-article t)
9679 (let ((gnus-newsgroup-charset
9680 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9681 (read-coding-system
9682 "View as charset: " ;; actually it is coding system.
9683 (with-current-buffer gnus-article-buffer
9684 (mm-detect-coding-region (point) (point-max))))))
9685 (gnus-newsgroup-ignored-charsets 'gnus-all))
9686 (gnus-summary-select-article nil 'force)
9687 (let ((deps gnus-newsgroup-dependencies)
9688 head header lines)
9689 (with-current-buffer gnus-original-article-buffer
9690 (save-restriction
9691 (message-narrow-to-head)
9692 (setq head (buffer-string))
9693 (goto-char (point-min))
9694 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9695 (goto-char (point-max))
9696 (widen)
9697 (setq lines (1- (count-lines (point) (point-max))))))
9698 (with-temp-buffer
9699 (insert (format "211 %d Article retrieved.\n"
9700 (cdr gnus-article-current)))
9701 (insert head)
9702 (if lines (insert (format "Lines: %d\n" lines)))
9703 (insert ".\n")
9704 (let ((nntp-server-buffer (current-buffer)))
9705 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9706 (gnus-data-set-header
9707 (gnus-data-find (cdr gnus-article-current))
9708 header)
9709 (gnus-summary-update-article-line
9710 (cdr gnus-article-current) header)
9711 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9712 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9713 ((not arg)
9714 ;; Select the article the normal way.
9715 (if (eq mm-text-html-renderer 'shr)
9716 (progn
9717 (require 'shr)
9718 (let ((shr-ignore-cache t))
9719 (gnus-summary-select-article nil 'force)))
9720 (gnus-summary-select-article nil 'force)))
9721 ((equal arg '(16))
9722 ;; C-u C-u g
9723 (let ((gnus-inhibit-article-treatments t))
9724 (gnus-summary-select-article nil 'force)))
9726 ;; We have to require this here to make sure that the following
9727 ;; dynamic binding isn't shadowed by autoloading.
9728 (require 'gnus-async)
9729 (require 'gnus-art)
9730 ;; Bind the article treatment functions to nil.
9731 (let ((gnus-have-all-headers t)
9732 gnus-article-prepare-hook
9733 gnus-article-decode-hook
9734 gnus-display-mime-function
9735 gnus-break-pages)
9736 ;; Destroy any MIME parts.
9737 (when (gnus-buffer-live-p gnus-article-buffer)
9738 (with-current-buffer gnus-article-buffer
9739 (gnus-article-stop-animations)
9740 (gnus-stop-downloads)
9741 (mm-destroy-parts gnus-article-mime-handles)
9742 ;; Set it to nil for safety reason.
9743 (setq gnus-article-mime-handle-alist nil)
9744 (setq gnus-article-mime-handles nil)))
9745 (gnus-summary-select-article nil 'force))))
9746 (gnus-summary-goto-subject gnus-current-article)
9747 (gnus-summary-position-point))
9749 (defun gnus-summary-show-raw-article ()
9750 "Show the raw article without any article massaging functions being run."
9751 (interactive)
9752 (gnus-summary-show-article t))
9754 (defun gnus-summary-verbose-headers (&optional arg)
9755 "Toggle permanent full header display.
9756 If ARG is a positive number, turn header display on.
9757 If ARG is a negative number, turn header display off."
9758 (interactive "P")
9759 (setq gnus-show-all-headers
9760 (cond ((or (not (numberp arg))
9761 (zerop arg))
9762 (not gnus-show-all-headers))
9763 ((natnump arg)
9764 t)))
9765 (gnus-summary-show-article))
9767 (declare-function article-narrow-to-head "gnus-art" ())
9768 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9769 (declare-function gnus-delete-wash-type "gnus-art" (type))
9770 (declare-function gnus-mime-buttonize-attachments-in-header
9771 "gnus-art" (&optional interactive))
9773 (defun gnus-summary-toggle-header (&optional arg)
9774 "Show the headers if they are hidden, or hide them if they are shown.
9775 If ARG is a positive number, show the entire header.
9776 If ARG is a negative number, hide the unwanted header lines."
9777 (interactive "P")
9778 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9779 (get-buffer-window gnus-article-buffer t))))
9780 (with-current-buffer gnus-article-buffer
9781 (widen)
9782 (article-narrow-to-head)
9783 (let* ((inhibit-read-only t)
9784 (inhibit-point-motion-hooks t)
9785 (hidden (if (numberp arg)
9786 (>= arg 0)
9788 ;; The case where there's no visible header
9789 ;; that matches `gnus-visible-headers'.
9790 (looking-at "\n?\\'")
9791 (gnus-article-hidden-text-p 'headers))))
9792 s e)
9793 (delete-region (point-min) (point-max))
9794 (with-current-buffer gnus-original-article-buffer
9795 (goto-char (setq s (point-min)))
9796 (setq e (if (search-forward "\n\n" nil t)
9797 (1- (point))
9798 (point-max))))
9799 (insert-buffer-substring gnus-original-article-buffer s e)
9800 (run-hooks 'gnus-article-decode-hook)
9801 (if hidden
9802 (let ((gnus-treat-hide-headers nil)
9803 (gnus-treat-hide-boring-headers nil))
9804 (gnus-delete-wash-type 'headers)
9805 (gnus-treat-article 'head))
9806 (gnus-treat-article 'head)
9807 ;; Add attachment buttons to the header.
9808 (when gnus-mime-display-attachment-buttons-in-header
9809 (gnus-mime-buttonize-attachments-in-header)))
9810 (widen)
9811 (if window
9812 (set-window-start window (goto-char (point-min))))
9813 (if gnus-break-pages
9814 (gnus-narrow-to-page)
9815 (when (gnus-visual-p 'page-marker)
9816 (let ((inhibit-read-only t))
9817 (gnus-remove-text-with-property 'gnus-prev)
9818 (gnus-remove-text-with-property 'gnus-next))))
9819 (gnus-set-mode-line 'article)))))
9821 (defun gnus-summary-show-all-headers ()
9822 "Make all header lines visible."
9823 (interactive)
9824 (gnus-summary-toggle-header 1))
9826 (defun gnus-summary-caesar-message (&optional arg)
9827 "Caesar rotate the current article by 13.
9828 With a non-numerical prefix, also rotate headers. A numerical
9829 prefix specifies how many places to rotate each letter forward."
9830 (interactive "P")
9831 (gnus-summary-select-article)
9832 (let ((mail-header-separator ""))
9833 (gnus-eval-in-buffer-window gnus-article-buffer
9834 (save-restriction
9835 (widen)
9836 (let ((start (window-start))
9837 (inhibit-read-only t))
9838 (if (equal arg '(4))
9839 (message-caesar-buffer-body nil t)
9840 (message-caesar-buffer-body arg))
9841 (set-window-start (get-buffer-window (current-buffer)) start)))))
9842 ;; Create buttons and stuff...
9843 (gnus-treat-article nil))
9845 (defun gnus-summary-idna-message (&optional arg)
9846 "Decode IDNA encoded domain names in the current articles.
9847 IDNA encoded domain names looks like `xn--bar'. If a string
9848 remain unencoded after running this function, it is likely an
9849 invalid IDNA string (`xn--bar' is invalid).
9851 You must have GNU Libidn (URL `https://www.gnu.org/software/libidn/')
9852 installed for this command to work."
9853 (interactive "P")
9854 (gnus-summary-select-article)
9855 (let ((mail-header-separator ""))
9856 (gnus-eval-in-buffer-window gnus-article-buffer
9857 (save-restriction
9858 (widen)
9859 (let ((start (window-start))
9860 buffer-read-only)
9861 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9862 (replace-match (puny-decode-domain (match-string 1))))
9863 (set-window-start (get-buffer-window (current-buffer)) start))))))
9865 (defun gnus-summary-morse-message (&optional arg)
9866 "Morse decode the current article."
9867 (interactive "P")
9868 (gnus-summary-select-article)
9869 (let ((mail-header-separator ""))
9870 (gnus-eval-in-buffer-window gnus-article-buffer
9871 (save-excursion
9872 (save-restriction
9873 (widen)
9874 (let ((pos (window-start))
9875 (inhibit-read-only t))
9876 (goto-char (point-min))
9877 (when (message-goto-body)
9878 (gnus-narrow-to-body))
9879 (goto-char (point-min))
9880 (while (search-forward "·" (point-max) t)
9881 (replace-match "."))
9882 (unmorse-region (point-min) (point-max))
9883 (widen)
9884 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9886 (defun gnus-summary-stop-page-breaking ()
9887 "Stop page breaking in the current article."
9888 (interactive)
9889 (gnus-summary-select-article)
9890 (gnus-eval-in-buffer-window gnus-article-buffer
9891 (widen)
9892 (when (gnus-visual-p 'page-marker)
9893 (let ((inhibit-read-only t))
9894 (gnus-remove-text-with-property 'gnus-prev)
9895 (gnus-remove-text-with-property 'gnus-next))
9896 (setq gnus-page-broken nil))))
9898 (defun gnus-summary-move-article (&optional n to-newsgroup
9899 select-method action)
9900 "Move the current article to a different newsgroup.
9901 If N is a positive number, move the N next articles.
9902 If N is a negative number, move the N previous articles.
9903 If N is nil and any articles have been marked with the process mark,
9904 move those articles instead.
9905 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9906 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9907 re-spool using this method.
9909 When called interactively with TO-NEWSGROUP being nil, the value of
9910 the variable `gnus-move-split-methods' is used for finding a default
9911 for the target newsgroup.
9913 For this function to work, both the current newsgroup and the
9914 newsgroup that you want to move to have to support the `request-move'
9915 and `request-accept' functions.
9917 ACTION can be either `move' (the default), `crosspost' or `copy'."
9918 (interactive "P")
9919 (unless action
9920 (setq action 'move))
9921 ;; Check whether the source group supports the required functions.
9922 (cond ((and (eq action 'move)
9923 (not (gnus-check-backend-function
9924 'request-move-article gnus-newsgroup-name)))
9925 (error "The current group does not support article moving"))
9926 ((and (eq action 'crosspost)
9927 (not (gnus-check-backend-function
9928 'request-replace-article gnus-newsgroup-name)))
9929 (error "The current group does not support article editing")))
9930 (let ((articles (gnus-summary-work-articles n))
9931 (prefix (if (gnus-check-backend-function
9932 'request-move-article gnus-newsgroup-name)
9933 (funcall gnus-move-group-prefix-function
9934 gnus-newsgroup-name)
9935 ""))
9936 (names '((move "Move" "Moving")
9937 (copy "Copy" "Copying")
9938 (crosspost "Crosspost" "Crossposting")))
9939 (copy-buf (save-excursion
9940 (nnheader-set-temp-buffer " *copy article*")))
9941 art-group to-method new-xref article to-groups
9942 articles-to-update-marks encoded)
9943 (unless (assq action names)
9944 (error "Unknown action %s" action))
9945 ;; Read the newsgroup name.
9946 (when (and (not to-newsgroup)
9947 (not select-method))
9948 (if (and gnus-move-split-methods
9949 (not
9950 (and (memq gnus-current-article articles)
9951 (gnus-buffer-live-p gnus-original-article-buffer))))
9952 ;; When `gnus-move-split-methods' is non-nil, we have to
9953 ;; select an article to give `gnus-read-move-group-name' an
9954 ;; opportunity to suggest an appropriate default. However,
9955 ;; we needn't render or mark the article.
9956 (let ((gnus-display-mime-function nil)
9957 (gnus-article-prepare-hook nil)
9958 (gnus-mark-article-hook nil))
9959 (gnus-summary-select-article nil nil nil (car articles))))
9960 (setq to-newsgroup (gnus-read-move-group-name
9961 (cadr (assq action names))
9962 (symbol-value
9963 (intern (format "gnus-current-%s-group" action)))
9964 articles prefix)
9965 encoded to-newsgroup
9966 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9967 (set (intern (format "gnus-current-%s-group" action))
9968 (decode-coding-string
9969 to-newsgroup
9970 (gnus-group-name-charset to-method to-newsgroup))))
9971 (unless to-method
9972 (setq to-method (or select-method
9973 (gnus-server-to-method
9974 (gnus-group-method to-newsgroup)))))
9975 (setq to-newsgroup
9976 (or encoded
9977 (and to-newsgroup
9978 (encode-coding-string
9979 to-newsgroup
9980 (gnus-group-name-charset to-method to-newsgroup)))))
9981 ;; Check the method we are to move this article to...
9982 (unless (gnus-check-backend-function
9983 'request-accept-article (car to-method))
9984 (error "%s does not support article copying" (car to-method)))
9985 (unless (gnus-check-server to-method)
9986 (error "Can't open server %s" (car to-method)))
9987 (gnus-message 6 "%s to %s: %s..."
9988 (caddr (assq action names))
9989 (or (car select-method)
9990 (gnus-group-decoded-name to-newsgroup))
9991 articles)
9992 (while articles
9993 (setq article (pop articles))
9994 ;; Set any marks that may have changed in the summary buffer.
9995 (when gnus-preserve-marks
9996 (gnus-summary-push-marks-to-backend article))
9997 (setq
9998 art-group
9999 (cond
10000 ;; Move the article.
10001 ((eq action 'move)
10002 ;; Remove this article from future suppression.
10003 (gnus-dup-unsuppress-article article)
10004 (let* ((from-method (gnus-find-method-for-group
10005 gnus-newsgroup-name))
10006 (to-method (or select-method
10007 (gnus-find-method-for-group to-newsgroup)))
10008 (move-is-internal (gnus-server-equal from-method to-method)))
10009 (gnus-request-move-article
10010 article ; Article to move
10011 gnus-newsgroup-name ; From newsgroup
10012 (nth 1 (gnus-find-method-for-group
10013 gnus-newsgroup-name)) ; Server
10014 (list 'gnus-request-accept-article
10015 to-newsgroup (list 'quote select-method)
10016 (not articles) t) ; Accept form
10017 (not articles) ; Only save nov last time
10018 (and move-is-internal
10019 to-newsgroup ; Not respooling
10020 ; Is this move internal?
10021 (gnus-group-real-name to-newsgroup)))))
10022 ;; Copy the article.
10023 ((eq action 'copy)
10024 (with-current-buffer copy-buf
10025 (when (gnus-request-article-this-buffer article
10026 gnus-newsgroup-name)
10027 (save-restriction
10028 (nnheader-narrow-to-headers)
10029 (dolist (hdr gnus-copy-article-ignored-headers)
10030 (message-remove-header hdr t)))
10031 (gnus-request-accept-article
10032 to-newsgroup select-method (not articles) t))))
10033 ;; Crosspost the article.
10034 ((eq action 'crosspost)
10035 (let ((xref (message-tokenize-header
10036 (mail-header-xref (gnus-summary-article-header
10037 article))
10038 " ")))
10039 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10040 ":" (number-to-string article)))
10041 (unless xref
10042 (setq xref (list (system-name))))
10043 (setq new-xref
10044 (concat
10045 (mapconcat 'identity
10046 (delete "Xref:" (delete new-xref xref))
10047 " ")
10048 " " new-xref))
10049 (with-current-buffer copy-buf
10050 ;; First put the article in the destination group.
10051 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10052 (when (consp (setq art-group
10053 (gnus-request-accept-article
10054 to-newsgroup select-method (not articles)
10055 t)))
10056 (setq new-xref (concat new-xref " " (car art-group)
10058 (number-to-string (cdr art-group))))
10059 ;; Now we have the new Xrefs header, so we insert
10060 ;; it and replace the new article.
10061 (nnheader-replace-header "Xref" new-xref)
10062 (gnus-request-replace-article
10063 (cdr art-group) to-newsgroup (current-buffer) t)
10064 art-group))))))
10065 (cond
10066 ((not art-group)
10067 (gnus-message 1 "Couldn't %s article %s: %s"
10068 (cadr (assq action names)) article
10069 (nnheader-get-report (car to-method))))
10070 ((eq art-group 'junk)
10071 (when (eq action 'move)
10072 (gnus-summary-mark-article article gnus-canceled-mark)
10073 (gnus-message 4 "Deleted article %s" article)
10074 ;; run the delete hook
10075 (run-hook-with-args 'gnus-summary-article-delete-hook
10076 action
10077 (gnus-data-header
10078 (assoc article (gnus-data-list nil)))
10079 gnus-newsgroup-name nil
10080 select-method)))
10082 (let* ((pto-group (gnus-group-prefixed-name
10083 (car art-group) to-method))
10084 (info (gnus-get-info pto-group))
10085 (to-group (gnus-info-group info))
10086 to-marks)
10087 ;; Update the group that has been moved to.
10088 (when (and info
10089 (memq action '(move copy)))
10090 (unless (member to-group to-groups)
10091 (push to-group to-groups))
10093 (when (and (not (memq article gnus-newsgroup-unreads))
10094 (cdr art-group))
10095 (push 'read to-marks)
10096 (gnus-info-set-read
10097 info (gnus-add-to-range (gnus-info-read info)
10098 (list (cdr art-group)))))
10100 ;; See whether the article is to be put in the cache.
10101 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10102 (marks (if expirable
10103 gnus-article-mark-lists
10104 (delete '(expirable . expire)
10105 (copy-sequence
10106 gnus-article-mark-lists))))
10107 (to-article (cdr art-group)))
10109 ;; Enter the article into the cache in the new group,
10110 ;; if that is required.
10111 (when (and to-article
10112 gnus-use-cache)
10113 (gnus-cache-possibly-enter-article
10114 to-group to-article
10115 (memq article gnus-newsgroup-marked)
10116 (memq article gnus-newsgroup-dormant)
10117 (memq article gnus-newsgroup-unreads)))
10119 (when (and gnus-preserve-marks
10120 to-article)
10121 ;; Copy any marks over to the new group.
10122 (when (and (equal to-group gnus-newsgroup-name)
10123 (not (memq article gnus-newsgroup-unreads)))
10124 ;; Mark this article as read in this group.
10125 (push (cons to-article gnus-read-mark)
10126 gnus-newsgroup-reads)
10127 ;; Increase the active status of this group.
10128 (setcdr (gnus-active to-group) to-article)
10129 (setcdr gnus-newsgroup-active to-article))
10131 (while marks
10132 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10133 (when (memq article (symbol-value
10134 (intern (format "gnus-newsgroup-%s"
10135 (caar marks)))))
10136 (push (cdar marks) to-marks)
10137 ;; If the other group is the same as this group,
10138 ;; then we have to add the mark to the list.
10139 (when (equal to-group gnus-newsgroup-name)
10140 (set (intern (format "gnus-newsgroup-%s"
10141 (caar marks)))
10142 (cons to-article
10143 (symbol-value
10144 (intern (format "gnus-newsgroup-%s"
10145 (caar marks)))))))
10146 ;; Copy the marks to other group.
10147 (gnus-add-marked-articles
10148 to-group (cdar marks) (list to-article) info)))
10149 (setq marks (cdr marks)))
10151 (when (and expirable
10152 gnus-mark-copied-or-moved-articles-as-expirable
10153 (not (memq 'expire to-marks)))
10154 ;; Mark this article as expirable.
10155 (push 'expire to-marks)
10156 (when (equal to-group gnus-newsgroup-name)
10157 (push to-article gnus-newsgroup-expirable))
10158 ;; Copy the expirable mark to other group.
10159 (gnus-add-marked-articles
10160 to-group 'expire (list to-article) info))
10162 (when (and to-marks
10163 (gnus-method-option-p
10164 (gnus-find-method-for-group to-group)
10165 'server-marks))
10166 (gnus-request-set-mark
10167 to-group (list (list (list to-article) 'add to-marks)))))
10169 (gnus-dribble-enter
10170 (concat "(gnus-group-set-info '"
10171 (gnus-prin1-to-string (gnus-get-info to-group))
10172 ")")
10173 (concat "^(gnus-group-set-info '(\""
10174 (regexp-quote to-group) "\""))))
10176 ;; Update the Xref header in this article to point to
10177 ;; the new crossposted article we have just created.
10178 (when (eq action 'crosspost)
10179 (with-current-buffer copy-buf
10180 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10181 (nnheader-replace-header "Xref" new-xref)
10182 (gnus-request-replace-article
10183 article gnus-newsgroup-name (current-buffer) t)))
10185 ;; run the move/copy/crosspost/respool hook
10186 (run-hook-with-args 'gnus-summary-article-move-hook
10187 action
10188 (gnus-data-header
10189 (assoc article (gnus-data-list nil)))
10190 gnus-newsgroup-name
10191 to-newsgroup
10192 select-method))
10194 ;;;!!!Why is this necessary?
10195 (set-buffer gnus-summary-buffer)
10197 (when (eq action 'move)
10198 (save-excursion
10199 (gnus-summary-goto-subject article)
10200 (gnus-summary-mark-article article gnus-canceled-mark)))))
10201 (push article articles-to-update-marks))
10203 (save-excursion
10204 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10205 ;; Re-activate all groups that have been moved to.
10206 (with-current-buffer gnus-group-buffer
10207 (let ((gnus-group-marked to-groups))
10208 (gnus-group-get-new-news-this-group nil t)))
10210 (gnus-kill-buffer copy-buf)
10211 (gnus-summary-position-point)
10212 (gnus-set-mode-line 'summary)))
10214 (defun gnus-summary-push-marks-to-backend (article)
10215 (let ((set nil)
10216 (del nil)
10217 (marks gnus-article-mark-lists))
10218 (unless (memq article gnus-newsgroup-unreads)
10219 (push 'read set))
10220 (while marks
10221 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10222 (memq article (symbol-value
10223 (intern (format "gnus-newsgroup-%s"
10224 (caar marks))))))
10225 (push (cdar marks) set)
10226 (push (cdar marks) del))
10227 (pop marks))
10228 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10229 ((,article) del ,del)))))
10231 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10232 "Copy the current article to some other group.
10233 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10234 When called interactively, if TO-NEWSGROUP is nil, use the value of
10235 the variable `gnus-move-split-methods' for finding a default target
10236 newsgroup.
10237 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10238 re-spool using this method."
10239 (interactive "P")
10240 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10242 (defun gnus-summary-crosspost-article (&optional n)
10243 "Crosspost the current article to some other group."
10244 (interactive "P")
10245 (gnus-summary-move-article n nil nil 'crosspost))
10247 (defcustom gnus-summary-respool-default-method nil
10248 "Default method type for respooling an article.
10249 If nil, use to the current newsgroup method."
10250 :type 'symbol
10251 :group 'gnus-summary-mail)
10253 (defun gnus-summary-respool-article (&optional n method)
10254 "Respool the current article.
10255 The article will be squeezed through the mail spooling process again,
10256 which means that it will be put in some mail newsgroup or other
10257 depending on `nnmail-split-methods'.
10258 If N is a positive number, respool the N next articles.
10259 If N is a negative number, respool the N previous articles.
10260 If N is nil and any articles have been marked with the process mark,
10261 respool those articles instead.
10263 Respooling can be done both from mail groups and \"real\" newsgroups.
10264 In the former case, the articles in question will be moved from the
10265 current group into whatever groups they are destined to. In the
10266 latter case, they will be copied into the relevant groups."
10267 (interactive
10268 (list current-prefix-arg
10269 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10270 (methname
10271 (symbol-name (or gnus-summary-respool-default-method
10272 (car (gnus-find-method-for-group
10273 gnus-newsgroup-name)))))
10274 (method
10275 (gnus-completing-read
10276 "Backend to use when respooling"
10277 methods t nil 'gnus-mail-method-history methname))
10279 (cond
10280 ((zerop (length (setq ms (gnus-servers-using-backend
10281 (intern method)))))
10282 (list (intern method) ""))
10283 ((= 1 (length ms))
10284 (car ms))
10286 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10287 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10288 ms-alist))))))))
10289 (unless method
10290 (error "No method given for respooling"))
10291 (if (assoc (symbol-name
10292 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10293 (gnus-methods-using 'respool))
10294 (gnus-summary-move-article n nil method)
10295 (gnus-summary-copy-article n nil method)))
10297 (defun gnus-summary-import-article (file &optional edit)
10298 "Import an arbitrary file into a mail newsgroup."
10299 (interactive "fImport file: \nP")
10300 (let ((group gnus-newsgroup-name)
10301 atts lines group-art)
10302 (unless (gnus-check-backend-function 'request-accept-article group)
10303 (error "%s does not support article importing" group))
10304 (or (file-readable-p file)
10305 (not (file-regular-p file))
10306 (error "Can't read %s" file))
10307 (with-current-buffer (gnus-get-buffer-create " *import file*")
10308 (erase-buffer)
10309 (nnheader-insert-file-contents file)
10310 (goto-char (point-min))
10311 (if (nnheader-article-p)
10312 (save-restriction
10313 (goto-char (point-min))
10314 (search-forward "\n\n" nil t)
10315 (narrow-to-region (point-min) (1- (point)))
10316 (goto-char (point-min))
10317 (unless (re-search-forward "^date:" nil t)
10318 (goto-char (point-max))
10319 (setq atts (file-attributes file))
10320 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10321 ;; This doesn't look like an article, so we fudge some headers.
10322 (setq atts (file-attributes file)
10323 lines (count-lines (point-min) (point-max)))
10324 (insert "From: " (read-string "From: ") "\n"
10325 "Subject: " (read-string "Subject: ") "\n"
10326 "Date: " (message-make-date (nth 5 atts)) "\n"
10327 "Message-ID: " (message-make-message-id) "\n"
10328 "Lines: " (int-to-string lines) "\n"
10329 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10330 (setq group-art (gnus-request-accept-article group nil t))
10331 (kill-buffer (current-buffer)))
10332 (setq gnus-newsgroup-active (gnus-activate-group group))
10333 (forward-line 1)
10334 (gnus-summary-goto-article (cdr group-art) nil t)
10335 (when edit
10336 (gnus-summary-edit-article))))
10338 (defun gnus-summary-create-article ()
10339 "Create an article in a mail newsgroup."
10340 (interactive)
10341 (let ((group gnus-newsgroup-name)
10342 (now (current-time))
10343 group-art)
10344 (unless (gnus-check-backend-function 'request-accept-article group)
10345 (error "%s does not support article importing" group))
10346 (with-current-buffer (gnus-get-buffer-create " *import file*")
10347 (erase-buffer)
10348 (goto-char (point-min))
10349 ;; This doesn't look like an article, so we fudge some headers.
10350 (insert "From: " (read-string "From: ") "\n"
10351 "Subject: " (read-string "Subject: ") "\n"
10352 "Date: " (message-make-date now) "\n"
10353 "Message-ID: " (message-make-message-id) "\n")
10354 (setq group-art (gnus-request-accept-article group nil t))
10355 (kill-buffer (current-buffer)))
10356 (setq gnus-newsgroup-active (gnus-activate-group group))
10357 (forward-line 1)
10358 (gnus-summary-goto-article (cdr group-art) nil t)
10359 (gnus-summary-edit-article)))
10361 (defun gnus-summary-article-posted-p ()
10362 "Say whether the current (mail) article is available from news as well.
10363 This will be the case if the article has both been mailed and posted."
10364 (interactive)
10365 (let ((id (mail-header-references (gnus-summary-article-header)))
10366 (gnus-override-method (car (gnus-refer-article-methods))))
10367 (if (gnus-request-head id "")
10368 (gnus-message 2 "The current message was found on %s"
10369 gnus-override-method)
10370 (gnus-message 2 "The current message couldn't be found on %s"
10371 gnus-override-method)
10372 nil)))
10374 (defun gnus-summary-expire-articles (&optional now)
10375 "Expire all articles that are marked as expirable in the current group."
10376 (interactive)
10377 (when (and (not gnus-group-is-exiting-without-update-p)
10378 (gnus-check-backend-function
10379 'request-expire-articles gnus-newsgroup-name))
10380 ;; This backend supports expiry.
10381 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10382 (expirable
10383 (gnus-list-range-difference
10384 (if total
10385 (progn
10386 ;; We need to update the info for
10387 ;; this group for `gnus-list-of-read-articles'
10388 ;; to give us the right answer.
10389 (gnus-run-hooks 'gnus-exit-group-hook)
10390 (gnus-summary-update-info)
10391 (gnus-list-of-read-articles gnus-newsgroup-name))
10392 (setq gnus-newsgroup-expirable
10393 (sort gnus-newsgroup-expirable '<)))
10394 gnus-newsgroup-unexist))
10395 (expiry-wait (if now 'immediate
10396 (gnus-group-find-parameter
10397 gnus-newsgroup-name 'expiry-wait)))
10398 (nnmail-expiry-target
10399 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10400 nnmail-expiry-target))
10402 (when expirable
10403 ;; There are expirable articles in this group, so we run them
10404 ;; through the expiry process.
10405 (gnus-message 6 "Expiring articles...")
10406 (when (gnus-check-group gnus-newsgroup-name)
10407 ;; The list of articles that weren't expired is returned.
10408 (save-excursion
10409 (if expiry-wait
10410 (let ((nnmail-expiry-wait-function nil)
10411 (nnmail-expiry-wait expiry-wait))
10412 (setq es (gnus-request-expire-articles
10413 expirable gnus-newsgroup-name)))
10414 (setq es (gnus-request-expire-articles
10415 expirable gnus-newsgroup-name)))
10416 (unless total
10417 (setq gnus-newsgroup-expirable es))
10418 ;; We go through the old list of expirable, and mark all
10419 ;; really expired articles as nonexistent.
10420 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10421 (let ((gnus-use-cache nil))
10422 (dolist (article expirable)
10423 (when (and (not (memq article es))
10424 (gnus-data-find article))
10425 (gnus-summary-mark-article article gnus-canceled-mark)
10426 (run-hook-with-args
10427 'gnus-summary-article-expire-hook
10428 'delete
10429 (gnus-data-header (assoc article (gnus-data-list nil)))
10430 gnus-newsgroup-name
10431 (cond
10432 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10433 ((eq nnmail-expiry-target 'delete) nil)
10435 (let ((rescall (funcall nnmail-expiry-target
10436 gnus-newsgroup-name)))
10437 (if (stringp rescall) rescall nil))))
10438 nil)))))))
10439 (gnus-message 6 "Expiring articles...done")))))
10441 (defun gnus-summary-expire-articles-now ()
10442 "Expunge all expirable articles in the current group.
10443 This means that *all* articles that are marked as expirable will be
10444 deleted forever, right now."
10445 (interactive)
10446 (or gnus-expert-user
10447 (gnus-yes-or-no-p
10448 "Are you really, really sure you want to delete all expirable messages? ")
10449 (error "Phew!"))
10450 (gnus-summary-expire-articles t))
10452 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10453 (defun gnus-summary-delete-article (&optional n)
10454 "Delete the N next (mail) articles.
10455 This command actually deletes articles. This is not a marking
10456 command. The article will disappear forever from your life, never to
10457 return.
10459 If N is negative, delete backwards.
10460 If N is nil and articles have been marked with the process mark,
10461 delete these instead.
10463 If `gnus-novice-user' is non-nil you will be asked for
10464 confirmation before the articles are deleted."
10465 (interactive "P")
10466 (unless (gnus-check-backend-function 'request-expire-articles
10467 gnus-newsgroup-name)
10468 (error "The current newsgroup does not support article deletion"))
10469 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10470 (error "Couldn't open server"))
10471 ;; Compute the list of articles to delete.
10472 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10473 (nnmail-expiry-target 'delete)
10474 not-deleted)
10475 (if (and gnus-novice-user
10476 (not (gnus-yes-or-no-p
10477 (format "Do you really want to delete %s forever? "
10478 (if (> (length articles) 1)
10479 (format "these %s articles" (length articles))
10480 "this article")))))
10482 ;; Delete the articles.
10483 (setq not-deleted (gnus-request-expire-articles
10484 articles gnus-newsgroup-name 'force))
10485 (save-excursion
10486 (while articles
10487 (gnus-summary-remove-process-mark (car articles))
10488 ;; The backend might not have been able to delete the article
10489 ;; after all.
10490 (unless (memq (car articles) not-deleted)
10491 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10492 (let* ((article (car articles))
10493 (ghead (gnus-data-header
10494 (assoc article (gnus-data-list nil)))))
10495 (run-hook-with-args 'gnus-summary-article-delete-hook
10496 'delete ghead gnus-newsgroup-name nil
10497 nil)))
10498 (setq articles (cdr articles))))
10499 (when not-deleted
10500 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10501 (gnus-summary-position-point)
10502 (gnus-set-mode-line 'summary)
10503 not-deleted))
10505 (defun gnus-summary-edit-article (&optional arg)
10506 "Edit the current article.
10507 This will have permanent effect only in mail groups.
10508 If ARG is nil, edit the decoded articles.
10509 If ARG is 1, edit the raw articles.
10510 If ARG is 2, edit the raw articles even in read-only groups.
10511 If ARG is 3, edit the articles with the current handles.
10512 Otherwise, allow editing of articles even in read-only
10513 groups."
10514 (interactive "P")
10515 (let (force raw current-handles)
10516 (cond
10517 ((null arg))
10518 ((eq arg 1)
10519 (setq raw t))
10520 ((eq arg 2)
10521 (setq raw t
10522 force t))
10523 ((eq arg 3)
10524 (setq current-handles
10525 (and (gnus-buffer-live-p gnus-article-buffer)
10526 (with-current-buffer gnus-article-buffer
10527 (prog1
10528 gnus-article-mime-handles
10529 (setq gnus-article-mime-handles nil))))))
10531 (setq force t)))
10532 (when (and raw (not force)
10533 (member gnus-newsgroup-name '("nndraft:delayed"
10534 "nndraft:drafts"
10535 "nndraft:queue")))
10536 (error "Can't edit the raw article in group %s"
10537 gnus-newsgroup-name))
10538 (with-current-buffer gnus-summary-buffer
10539 (let ((mail-parse-charset gnus-newsgroup-charset)
10540 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10541 (gnus-set-global-variables)
10542 (when (and (not force)
10543 (gnus-group-read-only-p))
10544 (error "The current newsgroup does not support article editing"))
10545 (gnus-summary-show-article t)
10546 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10547 (with-current-buffer gnus-article-buffer
10548 (mm-enable-multibyte)))
10549 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10550 (setq raw t))
10551 (gnus-article-edit-article
10552 (if raw 'ignore
10553 `(lambda ()
10554 (let ((mbl mml-buffer-list))
10555 (setq mml-buffer-list nil)
10556 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10557 (mime-to-mml ,'current-handles))
10558 (let ((mbl1 mml-buffer-list))
10559 (setq mml-buffer-list mbl)
10560 (set (make-local-variable 'mml-buffer-list) mbl1))
10561 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10562 `(lambda (no-highlight)
10563 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10564 (message-options message-options)
10565 (message-options-set-recipient)
10566 (mail-parse-ignored-charsets
10567 ',gnus-newsgroup-ignored-charsets)
10568 (rfc2047-header-encoding-alist
10569 ',(let ((charset (gnus-group-name-charset
10570 (gnus-find-method-for-group
10571 gnus-newsgroup-name)
10572 gnus-newsgroup-name)))
10573 (append (list (cons "Newsgroups" charset)
10574 (cons "Followup-To" charset)
10575 (cons "Xref" charset))
10576 rfc2047-header-encoding-alist))))
10577 ,(if (not raw) '(progn
10578 (mml-to-mime)
10579 (mml-destroy-buffers)
10580 (remove-hook 'kill-buffer-hook
10581 'mml-destroy-buffers t)
10582 (kill-local-variable 'mml-buffer-list)))
10583 (gnus-summary-edit-article-done
10584 ,(or (mail-header-references gnus-current-headers) "")
10585 ,(gnus-group-read-only-p)
10586 ,gnus-summary-buffer no-highlight))))))))
10588 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10590 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10591 no-highlight)
10592 "Make edits to the current article permanent."
10593 (interactive)
10594 (save-excursion
10595 ;; The buffer restriction contains the entire article if it exists.
10596 (when (article-goto-body)
10597 (let ((lines (count-lines (point) (point-max)))
10598 (length (- (point-max) (point)))
10599 (case-fold-search t)
10600 (body (point-marker)))
10601 (goto-char (point-min))
10602 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10603 (delete-region (match-beginning 1) (match-end 1))
10604 (insert (number-to-string length)))
10605 (goto-char (point-min))
10606 (when (re-search-forward
10607 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10608 (delete-region (match-beginning 1) (match-end 1))
10609 (insert (number-to-string length)))
10610 (goto-char (point-min))
10611 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10612 (delete-region (match-beginning 1) (match-end 1))
10613 (insert (number-to-string lines))))))
10614 ;; Replace the article.
10615 (let ((buf (current-buffer))
10616 (article (cdr gnus-article-current))
10617 replace-result)
10618 (with-temp-buffer
10619 (insert-buffer-substring buf)
10620 (if (and (not read-only)
10621 (not (setq replace-result
10622 (gnus-request-replace-article
10623 article (car gnus-article-current)
10624 (current-buffer) t))))
10625 (error "Couldn't replace article")
10626 ;; If we got a number back, then that's the new article number
10627 ;; for this article. Otherwise, the article number didn't change.
10628 (when (numberp replace-result)
10629 (with-current-buffer gnus-summary-buffer
10630 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10631 (gnus-summary-limit gnus-newsgroup-limit)
10632 (setq article replace-result)
10633 (gnus-summary-goto-subject article t)))
10634 ;; Update the summary buffer.
10635 (if (and references
10636 (equal (message-tokenize-header references " ")
10637 (message-tokenize-header
10638 (or (message-fetch-field "references") "") " ")))
10639 ;; We only have to update this line.
10640 (save-excursion
10641 (save-restriction
10642 (message-narrow-to-head)
10643 (let ((head (buffer-substring-no-properties
10644 (point-min) (point-max)))
10645 header)
10646 (with-temp-buffer
10647 (insert (format "211 %d Article retrieved.\n" article))
10648 (insert head)
10649 (insert ".\n")
10650 (let ((nntp-server-buffer (current-buffer)))
10651 (setq header (car (gnus-get-newsgroup-headers nil t))))
10652 (with-current-buffer gnus-summary-buffer
10653 (gnus-data-set-header (gnus-data-find article) header)
10654 (gnus-summary-update-article-line article header)
10655 (if (gnus-summary-goto-subject article nil t)
10656 (gnus-summary-update-secondary-mark article)))))))
10657 ;; Update threads.
10658 (set-buffer (or buffer gnus-summary-buffer))
10659 (gnus-summary-update-article article)
10660 (if (gnus-summary-goto-subject article nil t)
10661 (gnus-summary-update-secondary-mark article)))
10662 ;; Prettify the article buffer again.
10663 (unless no-highlight
10664 (with-current-buffer gnus-article-buffer
10665 ;;!!! Fix this -- article should be rehighlighted.
10666 ;;(gnus-run-hooks 'gnus-article-display-hook)
10667 (set-buffer gnus-original-article-buffer)
10668 (gnus-request-article
10669 article (car gnus-article-current) (current-buffer))))
10670 ;; Prettify the summary buffer line.
10671 (when (gnus-visual-p 'summary-highlight 'highlight)
10672 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10674 (defun gnus-summary-edit-wash (key)
10675 "Perform editing command KEY in the article buffer."
10676 (interactive
10677 (list
10678 (progn
10679 (message "%s" (concat (this-command-keys) "- "))
10680 (read-char))))
10681 (message "")
10682 (gnus-summary-edit-article)
10683 (execute-kbd-macro (concat (this-command-keys) key))
10684 (gnus-article-edit-done))
10686 ;;; Respooling
10688 (defvar nnimap-split-fancy)
10689 (defvar nnimap-split-methods)
10691 (defun gnus-summary-respool-query (&optional silent trace)
10692 "Query where the respool algorithm would put this article."
10693 (interactive)
10694 (let (gnus-mark-article-hook)
10695 (gnus-summary-select-article)
10696 (with-current-buffer gnus-original-article-buffer
10697 (let ((groups
10698 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10699 'nnimap)
10700 ;; nnimap has its own splitting variables.
10701 (let ((nnmail-split-methods
10702 (cond
10703 ((eq nnimap-split-methods 'default)
10704 nnmail-split-methods)
10705 (nnimap-split-methods
10706 nnimap-split-methods)
10707 (nnimap-split-fancy
10708 'nnmail-split-fancy)))
10709 (nnmail-split-fancy (or nnimap-split-fancy
10710 nnmail-split-fancy)))
10711 (nnmail-article-group 'identity trace))
10712 (nnmail-article-group 'identity trace))))
10713 (unless silent
10714 (if groups
10715 (message "This message would go to %s"
10716 (mapconcat 'car groups ", "))
10717 (message "This message would go to no groups"))
10718 groups)))))
10720 (defun gnus-summary-respool-trace ()
10721 "Trace where the respool algorithm would put this article.
10722 Display a buffer showing all fancy splitting patterns which matched."
10723 (interactive)
10724 (gnus-summary-respool-query nil t))
10726 ;; Summary marking commands.
10728 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10729 "Mark articles which has the same subject as read, and then select the next.
10730 If UNMARK is positive, remove any kind of mark.
10731 If UNMARK is negative, tick articles."
10732 (interactive "P")
10733 (when unmark
10734 (setq unmark (prefix-numeric-value unmark)))
10735 (let ((count
10736 (gnus-summary-mark-same-subject
10737 (gnus-summary-article-subject) unmark)))
10738 ;; Select next unread article. If auto-select-same mode, should
10739 ;; select the first unread article.
10740 (gnus-summary-next-article t (and gnus-auto-select-same
10741 (gnus-summary-article-subject)))
10742 (gnus-message 7 "%d article%s marked as %s"
10743 count (if (= count 1) " is" "s are")
10744 (if unmark "unread" "read"))))
10746 (defun gnus-summary-kill-same-subject (&optional unmark)
10747 "Mark articles which has the same subject as read.
10748 If UNMARK is positive, remove any kind of mark.
10749 If UNMARK is negative, tick articles."
10750 (interactive "P")
10751 (when unmark
10752 (setq unmark (prefix-numeric-value unmark)))
10753 (let ((count
10754 (gnus-summary-mark-same-subject
10755 (gnus-summary-article-subject) unmark)))
10756 ;; If marked as read, go to next unread subject.
10757 (when (null unmark)
10758 ;; Go to next unread subject.
10759 (gnus-summary-next-subject 1 t))
10760 (gnus-message 7 "%d articles are marked as %s"
10761 count (if unmark "unread" "read"))))
10763 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10764 "Mark articles with same SUBJECT as read, and return marked number.
10765 If optional argument UNMARK is positive, remove any kinds of marks.
10766 If optional argument UNMARK is negative, mark articles as unread instead."
10767 (let ((count 1))
10768 (save-excursion
10769 (cond
10770 ((null unmark) ; Mark as read.
10771 (while (and
10772 (progn
10773 (gnus-summary-mark-article-as-read gnus-killed-mark)
10774 (gnus-summary-show-thread) t)
10775 (gnus-summary-find-subject subject))
10776 (setq count (1+ count))))
10777 ((> unmark 0) ; Tick.
10778 (while (and
10779 (progn
10780 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10781 (gnus-summary-show-thread) t)
10782 (gnus-summary-find-subject subject))
10783 (setq count (1+ count))))
10784 (t ; Mark as unread.
10785 (while (and
10786 (progn
10787 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10788 (gnus-summary-show-thread) t)
10789 (gnus-summary-find-subject subject))
10790 (setq count (1+ count)))))
10791 (gnus-set-mode-line 'summary)
10792 ;; Return the number of marked articles.
10793 count)))
10795 (defun gnus-summary-mark-as-processable (n &optional unmark)
10796 "Set the process mark on the next N articles.
10797 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10798 the process mark instead. The difference between N and the actual
10799 number of articles marked is returned."
10800 (interactive "P")
10801 (if (and (null n) (and transient-mark-mode mark-active))
10802 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10803 (setq n (prefix-numeric-value n))
10804 (let ((backward (< n 0))
10805 (n (abs n)))
10806 (while (and
10807 (> n 0)
10808 (if unmark
10809 (gnus-summary-remove-process-mark
10810 (gnus-summary-article-number))
10811 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10812 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10813 (setq n (1- n)))
10814 (when (/= 0 n)
10815 (gnus-message 7 "No more articles"))
10816 (gnus-summary-recenter)
10817 (gnus-summary-position-point)
10818 n)))
10820 (defun gnus-summary-unmark-as-processable (n)
10821 "Remove the process mark from the next N articles.
10822 If N is negative, unmark backward instead. The difference between N and
10823 the actual number of articles unmarked is returned."
10824 (interactive "P")
10825 (gnus-summary-mark-as-processable n t))
10827 (defun gnus-summary-unmark-all-processable ()
10828 "Remove the process mark from all articles."
10829 (interactive)
10830 (save-excursion
10831 (while gnus-newsgroup-processable
10832 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10833 (gnus-summary-position-point))
10835 (defun gnus-summary-add-mark (article type)
10836 "Mark ARTICLE with a mark of TYPE."
10837 (let ((vtype (car (assq type gnus-article-mark-lists)))
10838 var)
10839 (if (not vtype)
10840 (error "No such mark type: %s" type)
10841 (setq var (intern (format "gnus-newsgroup-%s" type)))
10842 (set var (cons article (symbol-value var)))
10843 (if (memq type '(processable cached replied forwarded recent saved))
10844 (gnus-summary-update-secondary-mark article)
10845 ;;; !!! This is bogus. We should find out what primary
10846 ;;; !!! mark we want to set.
10847 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10849 (defun gnus-summary-mark-as-expirable (n)
10850 "Mark N articles forward as expirable.
10851 If N is negative, mark backward instead. The difference between N and
10852 the actual number of articles marked is returned."
10853 (interactive "p")
10854 (gnus-summary-mark-forward n gnus-expirable-mark))
10856 (defun gnus-summary-mark-as-spam (n)
10857 "Mark N articles forward as spam.
10858 If N is negative, mark backward instead. The difference between N and
10859 the actual number of articles marked is returned."
10860 (interactive "p")
10861 (gnus-summary-mark-forward n gnus-spam-mark))
10863 (defun gnus-summary-mark-article-as-replied (article)
10864 "Mark ARTICLE as replied to and update the summary line.
10865 ARTICLE can also be a list of articles."
10866 (interactive (list (gnus-summary-article-number)))
10867 (let ((articles (if (listp article) article (list article))))
10868 (dolist (article articles)
10869 (unless (numberp article)
10870 (error "%s is not a number" article))
10871 (push article gnus-newsgroup-replied)
10872 (let ((inhibit-read-only t))
10873 (when (gnus-summary-goto-subject article nil t)
10874 (gnus-summary-update-secondary-mark article))))))
10876 (defun gnus-summary-mark-article-as-forwarded (article)
10877 "Mark ARTICLE as forwarded and update the summary line.
10878 ARTICLE can also be a list of articles."
10879 (let ((articles (if (listp article) article (list article))))
10880 (dolist (article articles)
10881 (push article gnus-newsgroup-forwarded)
10882 (let ((inhibit-read-only t))
10883 (when (gnus-summary-goto-subject article nil t)
10884 (gnus-summary-update-secondary-mark article))))))
10886 (defun gnus-summary-set-bookmark (article)
10887 "Set a bookmark in current article."
10888 (interactive (list (gnus-summary-article-number)))
10889 (when (or (not (get-buffer gnus-article-buffer))
10890 (not gnus-current-article)
10891 (not gnus-article-current)
10892 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10893 (error "No current article selected"))
10894 ;; Remove old bookmark, if one exists.
10895 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10896 ;; Set the new bookmark, which is on the form
10897 ;; (article-number . line-number-in-body).
10898 (push
10899 (cons article
10900 (with-current-buffer gnus-article-buffer
10901 (count-lines
10902 (min (point)
10903 (save-excursion
10904 (article-goto-body)
10905 (point)))
10906 (point))))
10907 gnus-newsgroup-bookmarks)
10908 (gnus-message 6 "A bookmark has been added to the current article."))
10910 (defun gnus-summary-remove-bookmark (article)
10911 "Remove the bookmark from the current article."
10912 (interactive (list (gnus-summary-article-number)))
10913 ;; Remove old bookmark, if one exists.
10914 (if (not (assq article gnus-newsgroup-bookmarks))
10915 (gnus-message 6 "No bookmark in current article.")
10916 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10917 (gnus-message 6 "Removed bookmark.")))
10919 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10920 (defun gnus-summary-mark-as-dormant (n)
10921 "Mark N articles forward as dormant.
10922 If N is negative, mark backward instead. The difference between N and
10923 the actual number of articles marked is returned."
10924 (interactive "p")
10925 (gnus-summary-mark-forward n gnus-dormant-mark))
10927 (defun gnus-summary-set-process-mark (article)
10928 "Set the process mark on ARTICLE and update the summary line."
10929 (setq gnus-newsgroup-processable
10930 (cons article
10931 (delq article gnus-newsgroup-processable)))
10932 (when (gnus-summary-goto-subject article)
10933 (gnus-summary-show-thread)
10934 (gnus-summary-goto-subject article)
10935 (gnus-summary-update-secondary-mark article)))
10937 (defun gnus-summary-remove-process-mark (&rest articles)
10938 "Remove the process mark from ARTICLES and update the summary line."
10939 (dolist (article articles)
10940 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10941 (when (gnus-summary-goto-subject article)
10942 (gnus-summary-show-thread)
10943 (gnus-summary-goto-subject article)
10944 (gnus-summary-update-secondary-mark article)))
10947 (defun gnus-summary-set-saved-mark (article)
10948 "Set the process mark on ARTICLE and update the summary line."
10949 (push article gnus-newsgroup-saved)
10950 (when (gnus-summary-goto-subject article)
10951 (gnus-summary-update-secondary-mark article)))
10953 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10954 "Mark N articles as read forwards.
10955 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10956 The difference between N and the actual number of articles marked is
10957 returned.
10958 If NO-EXPIRE, auto-expiry will be inhibited."
10959 (interactive "p")
10960 (gnus-summary-show-thread)
10961 (let ((backward (< n 0))
10962 (gnus-summary-goto-unread
10963 (and gnus-summary-goto-unread
10964 (not (eq gnus-summary-goto-unread 'never))
10965 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10966 gnus-ticked-mark gnus-dormant-mark)))))
10967 (n (abs n))
10968 (mark (or mark gnus-del-mark)))
10969 (while (and (> n 0)
10970 (gnus-summary-mark-article nil mark no-expire)
10971 (zerop (gnus-summary-next-subject
10972 (if backward -1 1)
10973 (and gnus-summary-goto-unread
10974 (not (eq gnus-summary-goto-unread 'never)))
10975 t)))
10976 (setq n (1- n)))
10977 (when (/= 0 n)
10978 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10979 (gnus-summary-recenter)
10980 (gnus-summary-position-point)
10981 (gnus-set-mode-line 'summary)
10984 (defun gnus-summary-mark-article-as-read (mark)
10985 "Mark the current article quickly as read with MARK."
10986 (let ((article (gnus-summary-article-number)))
10987 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10988 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10989 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10990 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10991 (push (cons article mark) gnus-newsgroup-reads)
10992 ;; Possibly remove from cache, if that is used.
10993 (when gnus-use-cache
10994 (gnus-cache-enter-remove-article article))
10995 ;; Allow the backend to change the mark.
10996 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10997 ;; Check for auto-expiry.
10998 (when (and gnus-newsgroup-auto-expire
10999 (memq mark gnus-auto-expirable-marks))
11000 (setq mark gnus-expirable-mark)
11001 ;; Let the backend know about the mark change.
11002 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11003 (push article gnus-newsgroup-expirable))
11004 ;; Set the mark in the buffer.
11005 (gnus-summary-update-mark mark 'unread)
11008 (defun gnus-summary-mark-article-as-unread (mark)
11009 "Mark the current article quickly as unread with MARK."
11010 (let* ((article (gnus-summary-article-number))
11011 (old-mark (gnus-summary-article-mark article)))
11012 ;; Allow the backend to change the mark.
11013 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11014 (if (eq mark old-mark)
11016 (if (<= article 0)
11017 (progn
11018 (gnus-error 1 "Can't mark negative article numbers")
11019 nil)
11020 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11021 (setq gnus-newsgroup-spam-marked
11022 (delq article gnus-newsgroup-spam-marked))
11023 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11024 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11025 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11026 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11027 (cond ((= mark gnus-ticked-mark)
11028 (setq gnus-newsgroup-marked
11029 (gnus-add-to-sorted-list gnus-newsgroup-marked
11030 article)))
11031 ((= mark gnus-spam-mark)
11032 (setq gnus-newsgroup-spam-marked
11033 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11034 article)))
11035 ((= mark gnus-dormant-mark)
11036 (setq gnus-newsgroup-dormant
11037 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11038 article)))
11040 (setq gnus-newsgroup-unreads
11041 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11042 article))))
11043 (gnus-alist-pull article gnus-newsgroup-reads)
11045 ;; See whether the article is to be put in the cache.
11046 (and gnus-use-cache
11047 (vectorp (gnus-summary-article-header article))
11048 (save-excursion
11049 (gnus-cache-possibly-enter-article
11050 gnus-newsgroup-name article
11051 (= mark gnus-ticked-mark)
11052 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11054 ;; Fix the mark.
11055 (gnus-summary-update-mark mark 'unread)
11056 t))))
11058 (defun gnus-summary-mark-article (&optional article mark no-expire)
11059 "Mark ARTICLE with MARK. MARK can be any character.
11060 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11061 `??' (dormant) and `?E' (expirable).
11062 If MARK is nil, then the default character `?r' is used.
11063 If ARTICLE is nil, then the article on the current line will be
11064 marked.
11065 If NO-EXPIRE, auto-expiry will be inhibited."
11066 ;; The mark might be a string.
11067 (when (stringp mark)
11068 (setq mark (aref mark 0)))
11069 ;; If no mark is given, then we check auto-expiring.
11070 (when (null mark)
11071 (setq mark gnus-del-mark))
11072 (when (and (not no-expire)
11073 gnus-newsgroup-auto-expire
11074 (memq mark gnus-auto-expirable-marks))
11075 (setq mark gnus-expirable-mark))
11076 (let ((article (or article (gnus-summary-article-number)))
11077 (old-mark (gnus-summary-article-mark article)))
11078 ;; Allow the backend to change the mark.
11079 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11080 (if (eq mark old-mark)
11082 (unless article
11083 (error "No article on current line"))
11084 (if (not (if (or (= mark gnus-unread-mark)
11085 (= mark gnus-ticked-mark)
11086 (= mark gnus-spam-mark)
11087 (= mark gnus-dormant-mark))
11088 (gnus-mark-article-as-unread article mark)
11089 (gnus-mark-article-as-read article mark)))
11091 ;; See whether the article is to be put in the cache.
11092 (and gnus-use-cache
11093 (not (= mark gnus-canceled-mark))
11094 (vectorp (gnus-summary-article-header article))
11095 (save-excursion
11096 (gnus-cache-possibly-enter-article
11097 gnus-newsgroup-name article
11098 (= mark gnus-ticked-mark)
11099 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11101 (when (gnus-summary-goto-subject article nil t)
11102 (let ((inhibit-read-only t))
11103 (gnus-summary-show-thread)
11104 ;; Fix the mark.
11105 (gnus-summary-update-mark mark 'unread)
11106 t))))))
11108 (defun gnus-summary-update-secondary-mark (article)
11109 "Update the secondary (read, process, cache) mark."
11110 (gnus-summary-update-mark
11111 (cond ((memq article gnus-newsgroup-processable)
11112 gnus-process-mark)
11113 ((memq article gnus-newsgroup-cached)
11114 gnus-cached-mark)
11115 ((memq article gnus-newsgroup-replied)
11116 gnus-replied-mark)
11117 ((memq article gnus-newsgroup-forwarded)
11118 gnus-forwarded-mark)
11119 ((memq article gnus-newsgroup-saved)
11120 gnus-saved-mark)
11121 ((memq article gnus-newsgroup-unseen)
11122 gnus-unseen-mark)
11123 (t gnus-no-mark))
11124 'replied)
11125 (when (gnus-visual-p 'summary-highlight 'highlight)
11126 (gnus-summary-highlight-line)
11127 (gnus-run-hooks 'gnus-summary-update-hook))
11130 (defun gnus-summary-update-download-mark (article)
11131 "Update the download mark."
11132 (gnus-summary-update-mark
11133 (cond ((memq article gnus-newsgroup-undownloaded)
11134 gnus-undownloaded-mark)
11135 (gnus-newsgroup-agentized
11136 gnus-downloaded-mark)
11138 gnus-no-mark))
11139 'download)
11140 (gnus-summary-update-line t)
11143 (defun gnus-summary-update-mark (mark type)
11144 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11145 (inhibit-read-only t))
11146 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11147 (when forward
11148 (when (looking-at "\r")
11149 (incf forward))
11150 (when (<= (+ forward (point)) (point-max))
11151 ;; Go to the right position on the line.
11152 (goto-char (+ forward (point)))
11153 ;; Replace the old mark with the new mark.
11154 (let ((to-insert
11155 (subst-char-in-string
11156 (char-after) mark
11157 (buffer-substring (point) (1+ (point))))))
11158 (delete-region (point) (1+ (point)))
11159 (insert to-insert))
11160 ;; Optionally update the marks by some user rule.
11161 (when (eq type 'unread)
11162 (gnus-data-set-mark
11163 (gnus-data-find (gnus-summary-article-number)) mark)
11164 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11166 (defun gnus-mark-article-as-read (article &optional mark)
11167 "Enter ARTICLE in the pertinent lists and remove it from others."
11168 ;; Make the article expirable.
11169 (let ((mark (or mark gnus-del-mark)))
11170 (setq gnus-newsgroup-expirable
11171 (if (= mark gnus-expirable-mark)
11172 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11173 (delq article gnus-newsgroup-expirable)))
11174 ;; Remove from unread and marked lists.
11175 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11176 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11177 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11178 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11179 (push (cons article mark) gnus-newsgroup-reads)
11180 ;; Possibly remove from cache, if that is used.
11181 (when gnus-use-cache
11182 (gnus-cache-enter-remove-article article))
11185 (defun gnus-mark-article-as-unread (article &optional mark)
11186 "Enter ARTICLE in the pertinent lists and remove it from others."
11187 (let ((mark (or mark gnus-ticked-mark)))
11188 (if (<= article 0)
11189 (progn
11190 (gnus-error 1 "Can't mark negative article numbers")
11191 nil)
11192 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11193 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11194 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11195 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11196 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11198 ;; Unsuppress duplicates?
11199 (when gnus-suppress-duplicates
11200 (gnus-dup-unsuppress-article article))
11202 (cond ((= mark gnus-ticked-mark)
11203 (setq gnus-newsgroup-marked
11204 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11205 ((= mark gnus-spam-mark)
11206 (setq gnus-newsgroup-spam-marked
11207 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11208 article)))
11209 ((= mark gnus-dormant-mark)
11210 (setq gnus-newsgroup-dormant
11211 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11213 (setq gnus-newsgroup-unreads
11214 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11215 (gnus-alist-pull article gnus-newsgroup-reads)
11216 t)))
11218 (defun gnus-summary-tick-article-forward (n)
11219 "Tick N articles forwards.
11220 If N is negative, tick backwards instead.
11221 The difference between N and the number of articles ticked is returned."
11222 (interactive "p")
11223 (gnus-summary-mark-forward n gnus-ticked-mark))
11225 (defun gnus-summary-tick-article-backward (n)
11226 "Tick N articles backwards.
11227 The difference between N and the number of articles ticked is returned."
11228 (interactive "p")
11229 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11231 (defun gnus-summary-tick-article (&optional article clear-mark)
11232 "Mark current article as unread.
11233 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11234 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11235 (interactive)
11236 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11237 gnus-ticked-mark)))
11239 (defun gnus-summary-mark-as-read-forward (n)
11240 "Mark N articles as read forwards.
11241 If N is negative, mark backwards instead.
11242 The difference between N and the actual number of articles marked is
11243 returned."
11244 (interactive "p")
11245 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11247 (defun gnus-summary-mark-as-read-backward (n)
11248 "Mark the N articles as read backwards.
11249 The difference between N and the actual number of articles marked is
11250 returned."
11251 (interactive "p")
11252 (gnus-summary-mark-forward
11253 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11255 (defun gnus-summary-mark-as-read (&optional article mark)
11256 "Mark current article as read.
11257 ARTICLE specifies the article to be marked as read.
11258 MARK specifies a string to be inserted at the beginning of the line."
11259 (gnus-summary-mark-article article mark))
11261 (defun gnus-summary-clear-mark-forward (n)
11262 "Clear marks from N articles forward.
11263 If N is negative, clear backward instead.
11264 The difference between N and the number of marks cleared is returned."
11265 (interactive "p")
11266 (gnus-summary-mark-forward n gnus-unread-mark))
11268 (defun gnus-summary-clear-mark-backward (n)
11269 "Clear marks from N articles backward.
11270 The difference between N and the number of marks cleared is returned."
11271 (interactive "p")
11272 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11274 (defun gnus-summary-mark-unread-as-read ()
11275 "Intended to be used by `gnus-mark-article-hook'."
11276 (when (memq gnus-current-article gnus-newsgroup-unreads)
11277 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11279 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11280 "Intended to be used by `gnus-mark-article-hook'."
11281 (let ((mark (gnus-summary-article-mark)))
11282 (when (or (gnus-unread-mark-p mark)
11283 (gnus-read-mark-p mark))
11284 (gnus-summary-mark-article gnus-current-article
11285 (or new-mark gnus-read-mark)))))
11287 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11288 "Intended to be used by `gnus-mark-article-hook'."
11289 (let ((mark (gnus-summary-article-mark)))
11290 (when (or (gnus-unread-mark-p mark)
11291 (gnus-read-mark-p mark))
11292 (gnus-summary-mark-article (gnus-summary-article-number)
11293 (or new-mark gnus-read-mark)))))
11295 (defun gnus-summary-mark-unread-as-ticked ()
11296 "Intended to be used by `gnus-mark-article-hook'."
11297 (when (memq gnus-current-article gnus-newsgroup-unreads)
11298 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11300 (defun gnus-summary-mark-region-as-read (point mark all)
11301 "Mark all unread articles between point and mark as read.
11302 If given a prefix, mark all articles between point and mark as read,
11303 even ticked and dormant ones."
11304 (interactive "r\nP")
11305 (save-excursion
11306 (let (article)
11307 (goto-char point)
11308 (beginning-of-line)
11309 (while (and
11310 (< (point) mark)
11311 (progn
11312 (when (or all
11313 (memq (setq article (gnus-summary-article-number))
11314 gnus-newsgroup-unreads))
11315 (gnus-summary-mark-article article gnus-del-mark))
11317 (gnus-summary-find-next))))))
11319 (defun gnus-summary-mark-below (score mark)
11320 "Mark articles with score less than SCORE with MARK."
11321 (interactive "P\ncMark: ")
11322 (setq score (if score
11323 (prefix-numeric-value score)
11324 (or gnus-summary-default-score 0)))
11325 (with-current-buffer gnus-summary-buffer
11326 (goto-char (point-min))
11327 (while
11328 (progn
11329 (and (< (gnus-summary-article-score) score)
11330 (gnus-summary-mark-article nil mark))
11331 (gnus-summary-find-next)))))
11333 (defun gnus-summary-kill-below (&optional score)
11334 "Mark articles with score below SCORE as read."
11335 (interactive "P")
11336 (gnus-summary-mark-below score gnus-killed-mark))
11338 (defun gnus-summary-clear-above (&optional score)
11339 "Clear all marks from articles with score above SCORE."
11340 (interactive "P")
11341 (gnus-summary-mark-above score gnus-unread-mark))
11343 (defun gnus-summary-tick-above (&optional score)
11344 "Tick all articles with score above SCORE."
11345 (interactive "P")
11346 (gnus-summary-mark-above score gnus-ticked-mark))
11348 (defun gnus-summary-mark-above (score mark)
11349 "Mark articles with score over SCORE with MARK."
11350 (interactive "P\ncMark: ")
11351 (setq score (if score
11352 (prefix-numeric-value score)
11353 (or gnus-summary-default-score 0)))
11354 (with-current-buffer gnus-summary-buffer
11355 (goto-char (point-min))
11356 (while (and (progn
11357 (when (> (gnus-summary-article-score) score)
11358 (gnus-summary-mark-article nil mark))
11360 (gnus-summary-find-next)))))
11362 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11363 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11364 (defun gnus-summary-limit-include-expunged (&optional no-error)
11365 "Display all the hidden articles that were expunged for low scores."
11366 (interactive)
11367 (let ((inhibit-read-only t))
11368 (let ((scored gnus-newsgroup-scored)
11369 headers h)
11370 (while scored
11371 (unless (gnus-summary-article-header (caar scored))
11372 (and (setq h (gnus-number-to-header (caar scored)))
11373 (< (cdar scored) gnus-summary-expunge-below)
11374 (push h headers)))
11375 (setq scored (cdr scored)))
11376 (if (not headers)
11377 (when (not no-error)
11378 (error "No expunged articles hidden"))
11379 (goto-char (point-min))
11380 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11381 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11382 (dolist (x headers)
11383 (push (mail-header-number x) gnus-newsgroup-limit))
11384 (gnus-summary-prepare-unthreaded (nreverse headers))
11385 (goto-char (point-min))
11386 (gnus-summary-position-point)
11387 t))))
11389 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11390 "Mark all unread articles in this newsgroup as read.
11391 If prefix argument ALL is non-nil, ticked and dormant articles will
11392 also be marked as read.
11393 If QUIETLY is non-nil, no questions will be asked.
11395 If TO-HERE is non-nil, it should be a point in the buffer. All
11396 articles before (after, if REVERSE is set) this point will be marked
11397 as read.
11399 Note that this function will only catch up the unread article
11400 in the current summary buffer limitation.
11402 The number of articles marked as read is returned."
11403 (interactive "P")
11404 (prog1
11405 (save-excursion
11406 (when (or quietly
11407 (not gnus-interactive-catchup) ;Without confirmation?
11408 gnus-expert-user
11409 (gnus-y-or-n-p
11410 (if all
11411 "Mark absolutely all articles as read? "
11412 "Mark all unread articles as read? ")))
11413 (if (and not-mark
11414 (not gnus-newsgroup-adaptive)
11415 (not gnus-newsgroup-auto-expire)
11416 (not gnus-suppress-duplicates)
11417 (or (not gnus-use-cache)
11418 (eq gnus-use-cache 'passive)))
11419 (progn
11420 (when all
11421 (setq gnus-newsgroup-marked nil
11422 gnus-newsgroup-spam-marked nil
11423 gnus-newsgroup-dormant nil))
11424 (setq gnus-newsgroup-unreads
11425 (gnus-sorted-nunion
11426 (gnus-sorted-intersection gnus-newsgroup-unreads
11427 gnus-newsgroup-downloadable)
11428 (gnus-sorted-difference gnus-newsgroup-unfetched
11429 gnus-newsgroup-cached))))
11430 ;; We actually mark all articles as canceled, which we
11431 ;; have to do when using auto-expiry or adaptive scoring.
11432 (gnus-summary-show-all-threads)
11433 (if (and to-here reverse)
11434 (progn
11435 (goto-char to-here)
11436 (gnus-summary-mark-current-read-and-unread-as-read
11437 gnus-catchup-mark)
11438 (while (gnus-summary-find-next (not all))
11439 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11440 (when (gnus-summary-first-subject (not all))
11441 (while (and
11442 (if to-here (< (point) to-here) t)
11443 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11444 (gnus-summary-find-next (not all))))))
11445 (gnus-set-mode-line 'summary))
11447 (gnus-summary-position-point)))
11449 (defun gnus-summary-catchup-to-here (&optional all)
11450 "Mark all unticked articles before the current one as read.
11451 If ALL is non-nil, also mark ticked and dormant articles as read."
11452 (interactive "P")
11453 (save-excursion
11454 (gnus-save-hidden-threads
11455 (let ((beg (point)))
11456 ;; We check that there are unread articles.
11457 (when (or all (gnus-summary-find-prev))
11458 (gnus-summary-catchup all t beg)))))
11459 (gnus-summary-position-point))
11461 (defun gnus-summary-catchup-from-here (&optional all)
11462 "Mark all unticked articles after (and including) the current one as read.
11463 If ALL is non-nil, also mark ticked and dormant articles as read."
11464 (interactive "P")
11465 (save-excursion
11466 (gnus-save-hidden-threads
11467 (let ((beg (point)))
11468 ;; We check that there are unread articles.
11469 (when (or all (gnus-summary-find-next))
11470 (gnus-summary-catchup all t beg nil t)))))
11471 (gnus-summary-position-point))
11473 (defun gnus-summary-catchup-all (&optional quietly)
11474 "Mark all articles in this newsgroup as read.
11475 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11476 instead, which marks only unread articles as read."
11477 (interactive "P")
11478 (gnus-summary-catchup t quietly))
11480 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11481 "Mark all unread articles in this group as read, then exit.
11482 If prefix argument ALL is non-nil, all articles are marked as read.
11483 If QUIETLY is non-nil, no questions will be asked."
11484 (interactive "P")
11485 (when (gnus-summary-catchup all quietly nil 'fast)
11486 ;; Select next newsgroup or exit.
11487 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11488 (eq gnus-auto-select-next 'quietly))
11489 (gnus-summary-next-group nil)
11490 (gnus-summary-exit))))
11492 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11493 "Mark all articles in this newsgroup as read, and then exit.
11494 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11495 instead, which marks only unread articles as read."
11496 (interactive "P")
11497 (gnus-summary-catchup-and-exit t quietly))
11499 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11500 "Mark all articles in this group as read and select the next group.
11501 If given a prefix, mark all articles, unread as well as ticked, as
11502 read."
11503 (interactive "P")
11504 (save-excursion
11505 (gnus-summary-catchup all))
11506 (gnus-summary-next-group))
11508 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11509 "Mark all articles in this group as read and select the previous group.
11510 If given a prefix, mark all articles, unread as well as ticked, as
11511 read."
11512 (interactive "P")
11513 (save-excursion
11514 (gnus-summary-catchup all))
11515 (gnus-summary-next-group nil nil t))
11518 ;;; with article
11521 (defmacro gnus-with-article (article &rest forms)
11522 "Select ARTICLE and perform FORMS in the original article buffer.
11523 Then replace the article with the result."
11524 `(progn
11525 ;; We don't want the article to be marked as read.
11526 (let (gnus-mark-article-hook)
11527 (gnus-summary-select-article t t nil ,article))
11528 (set-buffer gnus-original-article-buffer)
11529 ,@forms
11530 (if (not (gnus-check-backend-function
11531 'request-replace-article (car gnus-article-current)))
11532 (gnus-message 5 "Read-only group; not replacing")
11533 (unless (gnus-request-replace-article
11534 ,article (car gnus-article-current)
11535 (current-buffer) t)
11536 (error "Couldn't replace article")))
11537 ;; The cache and backlog have to be flushed somewhat.
11538 (when gnus-keep-backlog
11539 (gnus-backlog-remove-article
11540 (car gnus-article-current) (cdr gnus-article-current)))
11541 (when gnus-use-cache
11542 (gnus-cache-update-article
11543 (car gnus-article-current) (cdr gnus-article-current)))))
11545 (put 'gnus-with-article 'lisp-indent-function 1)
11546 (put 'gnus-with-article 'edebug-form-spec '(form body))
11548 ;; Thread-based commands.
11550 (defun gnus-summary-articles-in-thread (&optional article)
11551 "Return a list of all articles in the current thread.
11552 If ARTICLE is non-nil, return all articles in the thread that starts
11553 with that article."
11554 (let* ((article (or article (gnus-summary-article-number)))
11555 (data (gnus-data-find-list article))
11556 (top-level (gnus-data-level (car data)))
11557 (top-subject
11558 (cond ((null gnus-thread-operation-ignore-subject)
11559 (gnus-simplify-subject-re
11560 (mail-header-subject (gnus-data-header (car data)))))
11561 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11562 (gnus-simplify-subject-fuzzy
11563 (mail-header-subject (gnus-data-header (car data)))))
11564 (t nil)))
11565 (end-point (save-excursion
11566 (goto-char (gnus-data-pos (car data)))
11567 (if (gnus-summary-go-to-next-thread)
11568 (point) (point-max))))
11569 articles)
11570 (while (and data
11571 (< (gnus-data-pos (car data)) end-point))
11572 (when (or (not top-subject)
11573 (string= top-subject
11574 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11575 (gnus-simplify-subject-fuzzy
11576 (mail-header-subject
11577 (gnus-data-header (car data))))
11578 (gnus-simplify-subject-re
11579 (mail-header-subject
11580 (gnus-data-header (car data)))))))
11581 (push (gnus-data-number (car data)) articles))
11582 (unless (and (setq data (cdr data))
11583 (> (gnus-data-level (car data)) top-level))
11584 (setq data nil)))
11585 ;; Return the list of articles.
11586 (nreverse articles)))
11588 (defun gnus-summary-rethread-current ()
11589 "Rethread the thread the current article is part of."
11590 (interactive)
11591 (let* ((gnus-show-threads t)
11592 (article (gnus-summary-article-number))
11593 (id (mail-header-id (gnus-summary-article-header)))
11594 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11595 (unless id
11596 (error "No article on the current line"))
11597 (gnus-rebuild-thread id)
11598 (gnus-summary-goto-subject article)))
11600 (defun gnus-summary-reparent-thread ()
11601 "Make the current article child of the marked (or previous) article.
11603 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11604 is non-nil or the Subject: of both articles are the same."
11605 (interactive)
11606 (unless (not (gnus-group-read-only-p))
11607 (error "The current newsgroup does not support article editing"))
11608 (unless (<= (length gnus-newsgroup-processable) 1)
11609 (error "No more than one article may be marked"))
11610 (let ((child (gnus-summary-article-number))
11611 ;; First grab the marked article, otherwise one line up.
11612 (parent (if (not (null gnus-newsgroup-processable))
11613 (car gnus-newsgroup-processable)
11614 (save-excursion
11615 (if (eq (forward-line -1) 0)
11616 (gnus-summary-article-number)
11617 (error "Beginning of summary buffer"))))))
11618 (gnus-summary-reparent-children parent (list child))))
11620 (defun gnus-summary-reparent-children (parent children)
11621 "Make PARENT the parent of CHILDREN.
11622 When called interactively, PARENT is the current article and CHILDREN
11623 are the process-marked articles."
11624 (interactive
11625 (list (gnus-summary-article-number)
11626 (gnus-summary-work-articles nil)))
11627 (dolist (child children)
11628 (save-window-excursion
11629 (let ((gnus-article-buffer " *reparent*"))
11630 (unless (not (eq parent child))
11631 (error "An article may not be self-referential"))
11632 (let ((message-id (mail-header-id
11633 (gnus-summary-article-header parent))))
11634 (unless (and message-id (not (equal message-id "")))
11635 (error "No message-id in desired parent"))
11636 (gnus-with-article child
11637 (save-restriction
11638 (goto-char (point-min))
11639 (message-narrow-to-head)
11640 (if (re-search-forward "^References: " nil t)
11641 (progn
11642 (re-search-forward "^[^ \t]" nil t)
11643 (forward-line -1)
11644 (end-of-line)
11645 (insert " " message-id))
11646 (insert "References: " message-id "\n"))))
11647 (set-buffer gnus-summary-buffer)
11648 (gnus-summary-unmark-all-processable)
11649 (gnus-summary-update-article child)
11650 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11651 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11652 (gnus-summary-rethread-current)
11653 (gnus-message 3 "Article %d is now the child of article %d"
11654 child parent))))))
11656 (defun gnus-summary-toggle-threads (&optional arg)
11657 "Toggle showing conversation threads.
11658 If ARG is positive number, turn showing conversation threads on."
11659 (interactive "P")
11660 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11661 (setq gnus-show-threads
11662 (if (null arg) (not gnus-show-threads)
11663 (> (prefix-numeric-value arg) 0)))
11664 (gnus-summary-prepare)
11665 (gnus-summary-goto-subject current)
11666 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11667 (gnus-summary-position-point)))
11669 (defun gnus-summary-show-all-threads ()
11670 "Show all threads."
11671 (interactive)
11672 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11673 (gnus-summary-position-point))
11675 (defsubst gnus-summary--inv (p)
11676 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11678 (defun gnus-summary-show-thread ()
11679 "Show thread subtrees.
11680 Returns nil if no thread was there to be shown."
11681 (interactive)
11682 (let* ((orig (point))
11683 (end (point-at-eol))
11684 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11685 ;; Leave point at bol
11686 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11687 (eoi (and end (next-single-char-property-change end 'invisible))))
11688 (when eoi
11689 (remove-overlays beg eoi 'invisible 'gnus-sum)
11690 (goto-char orig)
11691 (gnus-summary-position-point)
11692 eoi)))
11694 (defun gnus-summary-maybe-hide-threads ()
11695 "If requested, hide the threads that should be hidden."
11696 (when (and gnus-show-threads
11697 gnus-thread-hide-subtree)
11698 (gnus-summary-hide-all-threads
11699 (if (or (consp gnus-thread-hide-subtree)
11700 (functionp gnus-thread-hide-subtree))
11701 (gnus-make-predicate gnus-thread-hide-subtree)
11702 nil))))
11704 ;;; Hiding predicates.
11706 (defun gnus-article-unread-p (header)
11707 (memq (mail-header-number header) gnus-newsgroup-unreads))
11709 (defun gnus-article-unseen-p (header)
11710 (memq (mail-header-number header) gnus-newsgroup-unseen))
11712 (defun gnus-map-articles (predicate articles)
11713 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11714 (apply 'gnus-or (mapcar predicate
11715 (mapcar (lambda (number)
11716 (gnus-summary-article-header number))
11717 articles))))
11719 (defun gnus-summary-hide-all-threads (&optional predicate)
11720 "Hide all thread subtrees.
11721 If PREDICATE is supplied, threads that satisfy this predicate
11722 will not be hidden."
11723 (interactive)
11724 (save-excursion
11725 (goto-char (point-min))
11726 (let ((end nil)
11727 (count 0))
11728 (while (not end)
11729 (incf count)
11730 (when (zerop (mod count 1000))
11731 (message "Hiding all threads... %d" count))
11732 (when (or (not predicate)
11733 (gnus-map-articles
11734 predicate (gnus-summary-article-children)))
11735 (gnus-summary-hide-thread))
11736 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11737 (gnus-summary-position-point))
11739 (defun gnus-summary-hide-thread ()
11740 "Hide thread subtrees.
11741 If PREDICATE is supplied, threads that satisfy this predicate
11742 will not be hidden.
11743 Returns nil if no threads were there to be hidden."
11744 (interactive)
11745 (beginning-of-line)
11746 (let ((start (point))
11747 (starteol (line-end-position))
11748 (article (gnus-summary-article-number)))
11749 ;; Go forward until either the buffer ends or the subthread ends.
11750 (when (and (not (eobp))
11751 (or (zerop (gnus-summary-next-thread 1 t))
11752 (goto-char (point-max))))
11753 (if (and (> (point) start)
11754 ;; FIXME: this should actually search for a non-invisible \n.
11755 (search-backward "\n" start t))
11756 (progn
11757 (when (> (point) starteol)
11758 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11759 (let ((ol (make-overlay starteol (point) nil t nil)))
11760 (overlay-put ol 'invisible 'gnus-sum)
11761 (overlay-put ol 'evaporate t)))
11762 (gnus-summary-goto-subject article)
11763 (when (> start (point))
11764 (message "Hiding the thread moved us backwards, aborting!")
11765 (goto-char (point-max))))
11766 (goto-char start)
11767 nil))))
11769 (defun gnus-summary-go-to-next-thread (&optional previous)
11770 "Go to the same level (or less) next thread.
11771 If PREVIOUS is non-nil, go to previous thread instead.
11772 Return the article number moved to, or nil if moving was impossible."
11773 (let ((level (gnus-summary-thread-level))
11774 (way (if previous -1 1))
11775 (beg (point)))
11776 (forward-line way)
11777 (while (and (not (eobp))
11778 (< level (gnus-summary-thread-level)))
11779 (forward-line way))
11780 (if (eobp)
11781 (progn
11782 (goto-char beg)
11783 nil)
11784 (setq beg (point))
11785 (prog1
11786 (gnus-summary-article-number)
11787 (goto-char beg)))))
11789 (defun gnus-summary-next-thread (n &optional silent)
11790 "Go to the same level next N'th thread.
11791 If N is negative, search backward instead.
11792 Returns the difference between N and the number of skips actually
11793 done.
11795 If SILENT, don't output messages."
11796 (interactive "p")
11797 (let ((backward (< n 0))
11798 (n (abs n)))
11799 (while (and (> n 0)
11800 (gnus-summary-go-to-next-thread backward))
11801 (decf n))
11802 (unless silent
11803 (gnus-summary-position-point))
11804 (when (and (not silent) (/= 0 n))
11805 (gnus-message 7 "No more threads"))
11808 (defun gnus-summary-prev-thread (n)
11809 "Go to the same level previous N'th thread.
11810 Returns the difference between N and the number of skips actually
11811 done."
11812 (interactive "p")
11813 (gnus-summary-next-thread (- n)))
11815 (defun gnus-summary-go-down-thread ()
11816 "Go down one level in the current thread."
11817 (let ((children (gnus-summary-article-children)))
11818 (when children
11819 (gnus-summary-goto-subject (car children)))))
11821 (defun gnus-summary-go-up-thread ()
11822 "Go up one level in the current thread."
11823 (let ((parent (gnus-summary-article-parent)))
11824 (when parent
11825 (gnus-summary-goto-subject parent))))
11827 (defun gnus-summary-down-thread (n)
11828 "Go down thread N steps.
11829 If N is negative, go up instead.
11830 Returns the difference between N and how many steps down that were
11831 taken."
11832 (interactive "p")
11833 (let ((up (< n 0))
11834 (n (abs n)))
11835 (while (and (> n 0)
11836 (if up (gnus-summary-go-up-thread)
11837 (gnus-summary-go-down-thread)))
11838 (setq n (1- n)))
11839 (gnus-summary-position-point)
11840 (when (/= 0 n)
11841 (gnus-message 7 "Can't go further"))
11844 (defun gnus-summary-up-thread (n)
11845 "Go up thread N steps.
11846 If N is negative, go down instead.
11847 Returns the difference between N and how many steps down that were
11848 taken."
11849 (interactive "p")
11850 (gnus-summary-down-thread (- n)))
11852 (defun gnus-summary-top-thread ()
11853 "Go to the top of the thread."
11854 (interactive)
11855 (while (gnus-summary-go-up-thread))
11856 (gnus-summary-article-number))
11858 (defun gnus-summary-expire-thread ()
11859 "Mark articles under current thread as expired."
11860 (interactive)
11861 (gnus-summary-kill-thread 0))
11863 (defun gnus-summary-kill-thread (&optional unmark)
11864 "Mark articles under current thread as read.
11865 If the prefix argument is positive, remove any kinds of marks.
11866 If the prefix argument is zero, mark thread as expired.
11867 If the prefix argument is negative, tick articles instead."
11868 (interactive "P")
11869 (when unmark
11870 (setq unmark (prefix-numeric-value unmark)))
11871 (let ((articles (gnus-summary-articles-in-thread))
11872 (hide (or (null unmark) (= unmark 0))))
11873 (save-excursion
11874 ;; Expand the thread.
11875 (gnus-summary-show-thread)
11876 ;; Mark all the articles.
11877 (while articles
11878 (gnus-summary-goto-subject (car articles))
11879 (cond ((null unmark)
11880 (gnus-summary-mark-article-as-read gnus-killed-mark))
11881 ((> unmark 0)
11882 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11883 ((= unmark 0)
11884 (gnus-summary-mark-article nil gnus-expirable-mark))
11886 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11887 (setq articles (cdr articles))))
11888 ;; Hide killed subtrees when hide is true.
11889 (and hide
11890 gnus-thread-hide-killed
11891 (gnus-summary-hide-thread))
11892 ;; If hide is t, go to next unread subject.
11893 (when hide
11894 ;; Go to next unread subject.
11895 (gnus-summary-next-subject 1 t)))
11896 (gnus-set-mode-line 'summary))
11898 ;; Summary sorting commands
11900 (defun gnus-summary-sort-by-number (&optional reverse)
11901 "Sort the summary buffer by article number.
11902 Argument REVERSE means reverse order."
11903 (interactive "P")
11904 (gnus-summary-sort 'number reverse))
11906 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11907 "Sort the summary buffer by most recent article number.
11908 Argument REVERSE means reverse order."
11909 (interactive "P")
11910 (gnus-summary-sort 'most-recent-number reverse))
11912 (defun gnus-summary-sort-by-random (&optional reverse)
11913 "Randomize the order in the summary buffer.
11914 Argument REVERSE means to randomize in reverse order."
11915 (interactive "P")
11916 (gnus-summary-sort 'random reverse))
11918 (defun gnus-summary-sort-by-author (&optional reverse)
11919 "Sort the summary buffer by author name alphabetically.
11920 If `case-fold-search' is non-nil, case of letters is ignored.
11921 Argument REVERSE means reverse order."
11922 (interactive "P")
11923 (gnus-summary-sort 'author reverse))
11925 (defun gnus-summary-sort-by-recipient (&optional reverse)
11926 "Sort the summary buffer by recipient name alphabetically.
11927 If `case-fold-search' is non-nil, case of letters is ignored.
11928 Argument REVERSE means reverse order."
11929 (interactive "P")
11930 (gnus-summary-sort 'recipient reverse))
11932 (defun gnus-summary-sort-by-subject (&optional reverse)
11933 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11934 If `case-fold-search' is non-nil, case of letters is ignored.
11935 Argument REVERSE means reverse order."
11936 (interactive "P")
11937 (gnus-summary-sort 'subject reverse))
11939 (defun gnus-summary-sort-by-date (&optional reverse)
11940 "Sort the summary buffer by date.
11941 Argument REVERSE means reverse order."
11942 (interactive "P")
11943 (gnus-summary-sort 'date reverse))
11945 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11946 "Sort the summary buffer by most recent date.
11947 Argument REVERSE means reverse order."
11948 (interactive "P")
11949 (gnus-summary-sort 'most-recent-date reverse))
11951 (defun gnus-summary-sort-by-score (&optional reverse)
11952 "Sort the summary buffer by score.
11953 Argument REVERSE means reverse order."
11954 (interactive "P")
11955 (gnus-summary-sort 'score reverse))
11957 (defun gnus-summary-sort-by-lines (&optional reverse)
11958 "Sort the summary buffer by the number of lines.
11959 Argument REVERSE means reverse order."
11960 (interactive "P")
11961 (gnus-summary-sort 'lines reverse))
11963 (defun gnus-summary-sort-by-chars (&optional reverse)
11964 "Sort the summary buffer by article length.
11965 Argument REVERSE means reverse order."
11966 (interactive "P")
11967 (gnus-summary-sort 'chars reverse))
11969 (defun gnus-summary-sort-by-marks (&optional reverse)
11970 "Sort the summary buffer by article marks.
11971 Argument REVERSE means reverse order."
11972 (interactive "P")
11973 (gnus-summary-sort 'marks reverse))
11975 (defun gnus-summary-sort-by-original (&optional reverse)
11976 "Sort the summary buffer using the default sorting method.
11977 Argument REVERSE means reverse order."
11978 (interactive "P")
11979 (let* ((inhibit-read-only t)
11980 (gnus-summary-prepare-hook nil))
11981 ;; We do the sorting by regenerating the threads.
11982 (gnus-summary-prepare)
11983 ;; Hide subthreads if needed.
11984 (gnus-summary-maybe-hide-threads)))
11986 (defun gnus-summary-sort (predicate reverse)
11987 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11988 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11989 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11990 (gnus-thread-sort-functions
11991 (if (not reverse)
11992 thread
11993 `(lambda (t1 t2)
11994 (,thread t2 t1))))
11995 (gnus-sort-gathered-threads-function
11996 gnus-thread-sort-functions)
11997 (gnus-article-sort-functions
11998 (if (not reverse)
11999 article
12000 `(lambda (t1 t2)
12001 (,article t2 t1))))
12002 (inhibit-read-only t)
12003 (gnus-summary-prepare-hook nil))
12004 ;; We do the sorting by regenerating the threads.
12005 (gnus-summary-prepare)
12006 ;; Hide subthreads if needed.
12007 (gnus-summary-maybe-hide-threads)))
12009 ;; Summary saving commands.
12011 (defun gnus-summary-save-article (&optional n not-saved)
12012 "Save the current article using the default saver function.
12013 If N is a positive number, save the N next articles.
12014 If N is a negative number, save the N previous articles.
12015 If N is nil and any articles have been marked with the process mark,
12016 save those articles instead.
12017 The variable `gnus-default-article-saver' specifies the saver function.
12019 If the optional second argument NOT-SAVED is non-nil, articles saved
12020 will not be marked as saved.
12022 The `gnus-prompt-before-saving' variable says how prompting is
12023 performed."
12024 (interactive "P")
12025 (require 'gnus-art)
12026 (let* ((articles (gnus-summary-work-articles n))
12027 (save-buffer (save-excursion
12028 (nnheader-set-temp-buffer " *Gnus Save*")))
12029 (num (length articles))
12030 ;; Whether to save decoded articles or raw articles.
12031 (decode (when gnus-article-save-coding-system
12032 (get gnus-default-article-saver :decode)))
12033 ;; When saving many articles in a single file, use the other
12034 ;; function to save articles other than the first one.
12035 (saver2 (get gnus-default-article-saver :function))
12036 (gnus-prompt-before-saving (if saver2
12038 gnus-prompt-before-saving))
12039 (gnus-default-article-saver gnus-default-article-saver)
12040 header file)
12041 (dolist (article articles)
12042 (setq header (gnus-summary-article-header article))
12043 (if (not (vectorp header))
12044 ;; This is a pseudo-article.
12045 (if (assq 'name header)
12046 (gnus-copy-file (cdr (assq 'name header)))
12047 (gnus-message 1 "Article %d is unsavable" article))
12048 ;; This is a real article.
12049 (save-window-excursion
12050 (gnus-summary-select-article decode decode nil article)
12051 (gnus-summary-goto-subject article))
12052 (with-current-buffer save-buffer
12053 (erase-buffer)
12054 (insert-buffer-substring (if decode
12055 gnus-article-buffer
12056 gnus-original-article-buffer)))
12057 (setq file (gnus-article-save save-buffer file num))
12058 (gnus-summary-remove-process-mark article)
12059 (unless not-saved
12060 (gnus-summary-set-saved-mark article)))
12061 (when saver2
12062 (setq gnus-default-article-saver saver2
12063 saver2 nil)))
12064 (gnus-kill-buffer save-buffer)
12065 (gnus-summary-position-point)
12066 (gnus-set-mode-line 'summary)
12069 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12071 (defun gnus-summary-pipe-output (&optional n sym)
12072 "Pipe the current article to a subprocess.
12073 If N is a positive number, pipe the N next articles.
12074 If N is a negative number, pipe the N previous articles.
12075 If N is nil and any articles have been marked with the process mark,
12076 pipe those articles instead.
12077 The default command to which articles are piped is specified by the
12078 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12079 will be prompted for the command.
12081 The properties `:decode' and `:headers' that are put to the function
12082 symbol `gnus-summary-save-in-pipe' control whether this function
12083 decodes articles and what headers to keep (see the doc string for the
12084 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12085 is neither omitted nor the symbol `r', force including all headers
12086 regardless of the `:headers' property. If it is the symbol `r',
12087 articles that are not decoded and include all headers will be piped
12088 no matter what the properties `:decode' and `:headers' are."
12089 (interactive (gnus-interactive "P\ny"))
12090 (require 'gnus-art)
12091 (let* ((articles (gnus-summary-work-articles n))
12092 (result-buffer "*Shell Command Output*")
12093 (all-headers (not (memq sym '(nil r))))
12094 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12095 (raw (eq sym 'r))
12096 (headers (get 'gnus-summary-save-in-pipe :headers))
12097 command result)
12098 (unless (numberp (car articles))
12099 (error "No article to pipe"))
12100 (setq command (read-shell-command
12101 (concat "Shell command on "
12102 (if (cdr articles)
12103 (format "these %d articles" (length articles))
12104 "this article")
12105 ": ")
12106 gnus-summary-pipe-output-default-command))
12107 (when (string-equal command "")
12108 (error "A command is required"))
12109 (when all-headers
12110 (put 'gnus-summary-save-in-pipe :headers nil))
12111 (unwind-protect
12112 (while articles
12113 (gnus-summary-goto-subject (pop articles))
12114 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12115 (when (and (get-buffer result-buffer)
12116 (not (zerop (buffer-size (get-buffer result-buffer)))))
12117 (setq result (concat result (with-current-buffer result-buffer
12118 (buffer-string))))))
12119 (put 'gnus-summary-save-in-pipe :headers headers))
12120 (unless (zerop (length result))
12121 (if (with-current-buffer (get-buffer-create result-buffer)
12122 (erase-buffer)
12123 (insert result)
12124 (prog1
12125 (and (= (count-lines (point-min) (point)) 1)
12126 (progn
12127 (end-of-line 0)
12128 (<= (current-column)
12129 (window-width (minibuffer-window)))))
12130 (goto-char (point-min))))
12131 (message "%s" (substring result 0 -1))
12132 (message nil)
12133 (gnus-configure-windows 'pipe)))))
12135 (defun gnus-summary-save-article-mail (&optional arg)
12136 "Append the current article to a Unix mail box file.
12137 If N is a positive number, save the N next articles.
12138 If N is a negative number, save the N previous articles.
12139 If N is nil and any articles have been marked with the process mark,
12140 save those articles instead."
12141 (interactive "P")
12142 (require 'gnus-art)
12143 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12144 (gnus-summary-save-article arg)))
12146 (defun gnus-summary-save-article-rmail (&optional arg)
12147 "Append the current article to an rmail file.
12148 If N is a positive number, save the N next articles.
12149 If N is a negative number, save the N previous articles.
12150 If N is nil and any articles have been marked with the process mark,
12151 save those articles instead."
12152 (interactive "P")
12153 (require 'gnus-art)
12154 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12155 (gnus-summary-save-article arg)))
12157 (defun gnus-summary-save-article-file (&optional arg)
12158 "Append the current article to a file.
12159 If N is a positive number, save the N next articles.
12160 If N is a negative number, save the N previous articles.
12161 If N is nil and any articles have been marked with the process mark,
12162 save those articles instead."
12163 (interactive "P")
12164 (require 'gnus-art)
12165 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12166 (gnus-summary-save-article arg)))
12168 (defun gnus-summary-write-article-file (&optional arg)
12169 "Write the current article to a file, deleting the previous file.
12170 If N is a positive number, save the N next articles.
12171 If N is a negative number, save the N previous articles.
12172 If N is nil and any articles have been marked with the process mark,
12173 save those articles instead."
12174 (interactive "P")
12175 (require 'gnus-art)
12176 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12177 (gnus-summary-save-article arg)))
12179 (defun gnus-summary-save-article-body-file (&optional arg)
12180 "Append the current article body to a file.
12181 If N is a positive number, save the N next articles.
12182 If N is a negative number, save the N previous articles.
12183 If N is nil and any articles have been marked with the process mark,
12184 save those articles instead."
12185 (interactive "P")
12186 (require 'gnus-art)
12187 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12188 (gnus-summary-save-article arg)))
12190 (defun gnus-summary-write-article-body-file (&optional arg)
12191 "Write the current article body to a file, deleting the previous file.
12192 If N is a positive number, save the N next articles.
12193 If N is a negative number, save the N previous articles.
12194 If N is nil and any articles have been marked with the process mark,
12195 save those articles instead."
12196 (interactive "P")
12197 (require 'gnus-art)
12198 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12199 (gnus-summary-save-article arg)))
12201 (defun gnus-summary-muttprint (&optional arg)
12202 "Print the current article using Muttprint.
12203 If N is a positive number, save the N next articles.
12204 If N is a negative number, save the N previous articles.
12205 If N is nil and any articles have been marked with the process mark,
12206 save those articles instead."
12207 (interactive "P")
12208 (require 'gnus-art)
12209 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12210 (gnus-summary-save-article arg t)))
12212 (defun gnus-summary-pipe-message (program)
12213 "Pipe the current article through PROGRAM."
12214 (interactive "sProgram: ")
12215 (gnus-summary-select-article)
12216 (let ((mail-header-separator ""))
12217 (gnus-eval-in-buffer-window gnus-article-buffer
12218 (save-restriction
12219 (widen)
12220 (let ((start (window-start))
12221 (inhibit-read-only t))
12222 (message-pipe-buffer-body program)
12223 (set-window-start (get-buffer-window (current-buffer)) start))))))
12225 (defun gnus-get-split-value (methods)
12226 "Return a value based on the split METHODS."
12227 (let (split-name method result match)
12228 (when methods
12229 (with-current-buffer gnus-original-article-buffer
12230 (save-restriction
12231 (nnheader-narrow-to-headers)
12232 (while (and methods (not split-name))
12233 (goto-char (point-min))
12234 (setq method (pop methods))
12235 (setq match (car method))
12236 (when (cond
12237 ((stringp match)
12238 ;; Regular expression.
12239 (ignore-errors
12240 (re-search-forward match nil t)))
12241 ((functionp match)
12242 ;; Function.
12243 (save-restriction
12244 (widen)
12245 (setq result (funcall match gnus-newsgroup-name))))
12246 ((consp match)
12247 ;; Form.
12248 (save-restriction
12249 (widen)
12250 (setq result (eval match)))))
12251 (setq split-name (cdr method))
12252 (cond ((stringp result)
12253 (push (expand-file-name
12254 result gnus-article-save-directory)
12255 split-name))
12256 ((consp result)
12257 (setq split-name (append result split-name)))))))))
12258 (nreverse split-name)))
12260 (defun gnus-valid-move-group-p (group)
12261 (and (symbolp group)
12262 (boundp group)
12263 (symbol-name group)
12264 (symbol-value group)
12265 (gnus-get-function (gnus-find-method-for-group
12266 (symbol-name group)) 'request-accept-article t)))
12268 (defun gnus-read-move-group-name (prompt default articles prefix)
12269 "Read a group name."
12270 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12271 (prom
12272 (format "%s %s to"
12273 prompt
12274 (if (> (length articles) 1)
12275 (format "these %d articles" (length articles))
12276 "this article")))
12277 valid-names
12278 (to-newsgroup
12279 (progn
12280 (mapatoms (lambda (g)
12281 (when (gnus-valid-move-group-p g)
12282 (push g valid-names)))
12283 gnus-active-hashtb)
12284 (cond
12285 ((null split-name)
12286 (gnus-group-completing-read
12287 prom
12288 valid-names
12289 nil prefix nil default))
12290 ((= 1 (length split-name))
12291 (gnus-group-completing-read
12292 prom
12293 valid-names
12294 nil prefix 'gnus-group-history (car split-name)))
12296 (gnus-completing-read
12297 prom (nreverse split-name) nil nil 'gnus-group-history)))))
12298 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12299 encoded)
12300 (when to-newsgroup
12301 (if (or (string= to-newsgroup "")
12302 (string= to-newsgroup prefix))
12303 (setq to-newsgroup default))
12304 (unless to-newsgroup
12305 (error "No group name entered"))
12306 (setq encoded (encode-coding-string
12307 to-newsgroup
12308 (gnus-group-name-charset to-method to-newsgroup)))
12309 (or (gnus-active encoded)
12310 (gnus-activate-group encoded nil nil to-method)
12311 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12312 to-newsgroup))
12313 (or (and (gnus-request-create-group encoded to-method)
12314 (gnus-activate-group encoded nil nil to-method)
12315 (gnus-subscribe-group encoded))
12316 (error "Couldn't create group %s" to-newsgroup)))
12317 (error "No such group: %s" to-newsgroup))
12318 encoded)))
12320 (defvar gnus-summary-save-parts-counter)
12321 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12323 (defun gnus-summary-save-parts (type dir n &optional reverse)
12324 "Save parts matching TYPE to DIR.
12325 If REVERSE, save parts that do not match TYPE."
12326 (interactive
12327 (list (read-string "Save parts of type: "
12328 (or (car gnus-summary-save-parts-type-history)
12329 gnus-summary-save-parts-default-mime)
12330 'gnus-summary-save-parts-type-history)
12331 (setq gnus-summary-save-parts-last-directory
12332 (read-directory-name "Save to directory: "
12333 gnus-summary-save-parts-last-directory
12334 nil t))
12335 current-prefix-arg))
12336 (gnus-summary-iterate n
12337 (let ((gnus-display-mime-function nil)
12338 gnus-article-prepare-hook
12339 gnus-article-decode-hook
12340 gnus-display-mime-function
12341 gnus-break-pages
12342 (gnus-inhibit-treatment t))
12343 (gnus-summary-select-article))
12344 (with-current-buffer gnus-article-buffer
12345 (let ((handles (or gnus-article-mime-handles
12346 (mm-dissect-buffer nil gnus-article-loose-mime)
12347 (and gnus-article-emulate-mime
12348 (mm-uu-dissect))))
12349 (gnus-summary-save-parts-counter 1))
12350 (when handles
12351 (gnus-summary-save-parts-1 type dir handles reverse)
12352 (unless gnus-article-mime-handles ;; Don't destroy this case.
12353 (mm-destroy-parts handles)))))))
12355 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12356 (if (stringp (car handle))
12357 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12358 (cdr handle))
12359 (when (if reverse
12360 (not (string-match type (mm-handle-media-type handle)))
12361 (string-match type (mm-handle-media-type handle)))
12362 (let ((file (expand-file-name
12363 (gnus-map-function
12364 mm-file-name-rewrite-functions
12365 (file-name-nondirectory
12367 (mm-handle-filename handle)
12368 (format "%s.%d.%d" gnus-newsgroup-name
12369 (cdr gnus-article-current)
12370 gnus-summary-save-parts-counter))))
12371 dir)))
12372 (incf gnus-summary-save-parts-counter)
12373 (unless (file-exists-p file)
12374 (mm-save-part-to-file handle file))))))
12376 ;; Summary extract commands
12378 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12379 (let ((inhibit-read-only t)
12380 (article (gnus-summary-article-number))
12381 after-article b e)
12382 (unless (gnus-summary-goto-subject article)
12383 (error "No such article: %d" article))
12384 (gnus-summary-position-point)
12385 ;; If all commands are to be bunched up on one line, we collect
12386 ;; them here.
12387 (unless gnus-view-pseudos-separately
12388 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12389 files action)
12390 (while ps
12391 (setq action (cdr (assq 'action (car ps))))
12392 (setq files (list (cdr (assq 'name (car ps)))))
12393 (while (and ps (cdr ps)
12394 (string= (or action "1")
12395 (or (cdr (assq 'action (cadr ps))) "2")))
12396 (push (cdr (assq 'name (cadr ps))) files)
12397 (setcdr ps (cddr ps)))
12398 (when files
12399 (when (not (string-match "%s" action))
12400 (push " " files))
12401 (push " " files)
12402 (when (assq 'execute (car ps))
12403 (setcdr (assq 'execute (car ps))
12404 (funcall (if (string-match "%s" action)
12405 'format 'concat)
12406 action
12407 (mapconcat
12408 (lambda (f)
12409 (if (equal f " ")
12411 (shell-quote-argument f)))
12412 files " ")))))
12413 (setq ps (cdr ps)))))
12414 (if (and gnus-view-pseudos (not not-view))
12415 (while pslist
12416 (when (assq 'execute (car pslist))
12417 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12418 (eq gnus-view-pseudos 'not-confirm)))
12419 (setq pslist (cdr pslist)))
12420 (save-excursion
12421 (while pslist
12422 (setq after-article (or (cdr (assq 'article (car pslist)))
12423 (gnus-summary-article-number)))
12424 (gnus-summary-goto-subject after-article)
12425 (forward-line 1)
12426 (setq b (point))
12427 (insert " " (file-name-nondirectory
12428 (cdr (assq 'name (car pslist))))
12429 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12430 (setq e (point))
12431 (forward-line -1) ; back to `b'
12432 (add-text-properties
12433 b (1- e) (list 'gnus-number gnus-reffed-article-number
12434 'mouse-face gnus-mouse-face))
12435 (gnus-data-enter
12436 after-article gnus-reffed-article-number
12437 gnus-unread-mark b (car pslist) 0 (- e b))
12438 (setq gnus-newsgroup-unreads
12439 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12440 gnus-reffed-article-number))
12441 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12442 (setq pslist (cdr pslist)))))))
12444 (defun gnus-pseudos< (p1 p2)
12445 (let ((c1 (cdr (assq 'action p1)))
12446 (c2 (cdr (assq 'action p2))))
12447 (and c1 c2 (string< c1 c2))))
12449 (defun gnus-request-pseudo-article (props)
12450 (cond ((assq 'execute props)
12451 (gnus-execute-command (cdr (assq 'execute props)))))
12452 (let ((gnus-current-article (gnus-summary-article-number)))
12453 (gnus-run-hooks 'gnus-mark-article-hook)))
12455 (defun gnus-execute-command (command &optional automatic)
12456 (save-excursion
12457 (gnus-article-setup-buffer)
12458 (set-buffer gnus-article-buffer)
12459 (setq buffer-read-only nil)
12460 (let ((command (if automatic command
12461 (read-string "Command: " (cons command 0)))))
12462 (erase-buffer)
12463 (insert "$ " command "\n\n")
12464 (if gnus-view-pseudo-asynchronously
12465 (start-process "gnus-execute" (current-buffer) shell-file-name
12466 shell-command-switch command)
12467 (call-process shell-file-name nil t nil
12468 shell-command-switch command)))))
12470 ;; Summary kill commands.
12472 (defun gnus-summary-edit-global-kill (article)
12473 "Edit the \"global\" kill file."
12474 (interactive (list (gnus-summary-article-number)))
12475 (gnus-group-edit-global-kill article))
12477 (defun gnus-summary-edit-local-kill ()
12478 "Edit a local kill file applied to the current newsgroup."
12479 (interactive)
12480 (setq gnus-current-headers (gnus-summary-article-header))
12481 (gnus-group-edit-local-kill
12482 (gnus-summary-article-number) gnus-newsgroup-name))
12484 ;;; Header reading.
12486 (defun gnus-read-header (id &optional header)
12487 "Read the headers of article ID and enter them into the Gnus system."
12488 (let ((group gnus-newsgroup-name)
12489 (gnus-override-method
12491 gnus-override-method
12492 (and (gnus-news-group-p gnus-newsgroup-name)
12493 (car (gnus-refer-article-methods)))))
12494 where)
12495 ;; First we check to see whether the header in question is already
12496 ;; fetched.
12497 (if (stringp id)
12498 ;; This is a Message-ID.
12499 (setq header (or header (gnus-id-to-header id)))
12500 ;; This is an article number.
12501 (setq header (or header (gnus-summary-article-header id))))
12502 (if (and header
12503 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12504 ;; We have found the header.
12505 header
12506 ;; We have to really fetch the header to this article.
12507 (with-current-buffer nntp-server-buffer
12508 (when (setq where (gnus-request-head id group))
12509 (nnheader-fold-continuation-lines)
12510 (goto-char (point-max))
12511 (insert ".\n")
12512 (goto-char (point-min))
12513 (insert "211 ")
12514 (princ (cond
12515 ((numberp id) id)
12516 ((cdr where) (cdr where))
12517 (header (mail-header-number header))
12518 (t gnus-reffed-article-number))
12519 (current-buffer))
12520 (insert " Article retrieved.\n"))
12521 (if (or (not where)
12522 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12523 () ; Malformed head.
12524 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12525 (when (and (bound-and-true-p gnus-registry-enabled)
12526 (not (gnus-ephemeral-group-p (car where))))
12527 (gnus-registry-handle-action
12528 (mail-header-id header) nil
12529 (gnus-group-prefixed-name
12530 (car where)
12531 (or gnus-override-method (gnus-find-method-for-group group)))
12532 (mail-header-subject header)
12533 (mail-header-from header)))
12534 (when (and (stringp id)
12536 (not (string= (gnus-group-real-name group)
12537 (car where)))
12538 (not (gnus-server-equal gnus-override-method
12539 (gnus-group-method group)))))
12540 ;; If we fetched by Message-ID and the article came from
12541 ;; a different group (or server), we fudge some bogus
12542 ;; article numbers for this article.
12543 (mail-header-set-number header gnus-reffed-article-number))
12544 (with-current-buffer gnus-summary-buffer
12545 (decf gnus-reffed-article-number)
12546 (gnus-remove-header (mail-header-number header))
12547 (push header gnus-newsgroup-headers)
12548 (setq gnus-current-headers header)
12549 (push (mail-header-number header) gnus-newsgroup-limit)))
12550 header)))))
12552 (defun gnus-remove-header (number)
12553 "Remove header NUMBER from `gnus-newsgroup-headers'."
12554 (if (and gnus-newsgroup-headers
12555 (= number (mail-header-number (car gnus-newsgroup-headers))))
12556 (pop gnus-newsgroup-headers)
12557 (let ((headers gnus-newsgroup-headers))
12558 (while (and (cdr headers)
12559 (not (= number (mail-header-number (cadr headers)))))
12560 (pop headers))
12561 (when (cdr headers)
12562 (setcdr headers (cddr headers))))))
12565 ;;; summary highlights
12568 (defun gnus-highlight-selected-summary ()
12569 "Highlight selected article in summary buffer."
12570 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12571 (when gnus-summary-selected-face
12572 (save-excursion
12573 (let* ((beg (point-at-bol))
12574 (end (point-at-eol))
12575 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12576 (from (if (get-text-property beg 'mouse-face)
12578 (or (next-single-property-change
12579 beg 'mouse-face nil end)
12580 beg)))
12582 (if (= from end)
12583 (- from 2)
12584 (or (next-single-property-change
12585 from 'mouse-face nil end)
12586 end))))
12587 ;; If no mouse-face prop on line we will have to = from = end,
12588 ;; so we highlight the entire line instead.
12589 (when (= (+ to 2) from)
12590 (setq from beg)
12591 (setq to end))
12592 (if gnus-newsgroup-selected-overlay
12593 ;; Move old overlay.
12594 (move-overlay
12595 gnus-newsgroup-selected-overlay from to (current-buffer))
12596 ;; Create new overlay.
12597 (overlay-put
12598 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12599 'face gnus-summary-selected-face))))))
12601 (defvar gnus-summary-highlight-line-cached nil)
12602 (defvar gnus-summary-highlight-line-trigger nil)
12604 (defun gnus-summary-highlight-line-0 ()
12605 (if (and (eq gnus-summary-highlight-line-trigger
12606 gnus-summary-highlight)
12607 gnus-summary-highlight-line-cached)
12608 gnus-summary-highlight-line-cached
12609 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12610 gnus-summary-highlight-line-cached
12611 (let* ((cond (list 'cond))
12612 (c cond)
12613 (list gnus-summary-highlight))
12614 (while list
12615 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12616 nil))
12617 (setq c (cdr c)
12618 list (cdr list)))
12619 (gnus-byte-compile (list 'lambda nil cond))))))
12621 (defun gnus-summary-highlight-line ()
12622 "Highlight current line according to `gnus-summary-highlight'."
12623 (let* ((beg (point-at-bol))
12624 (article (or (gnus-summary-article-number) gnus-current-article))
12625 (score (or (cdr (assq article
12626 gnus-newsgroup-scored))
12627 gnus-summary-default-score 0))
12628 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12629 (inhibit-read-only t)
12630 (default gnus-summary-default-score)
12631 (default-high gnus-summary-default-high-score)
12632 (default-low gnus-summary-default-low-score)
12633 (uncached (and gnus-summary-use-undownloaded-faces
12634 (memq article gnus-newsgroup-undownloaded)
12635 (not (memq article gnus-newsgroup-cached)))))
12636 (let ((face (funcall (gnus-summary-highlight-line-0))))
12637 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12638 (gnus-put-text-property-excluding-characters-with-faces
12639 beg (point-at-eol) 'face
12640 (setq face (if (boundp face) (symbol-value face) face)))
12641 (when gnus-summary-highlight-line-function
12642 (funcall gnus-summary-highlight-line-function article face))))))
12644 (defun gnus-update-read-articles (group unread &optional compute)
12645 "Update the list of read articles in GROUP.
12646 UNREAD is a sorted list."
12647 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12648 (info (gnus-get-info group))
12649 (prev 1)
12650 read)
12651 (if (or (not info) (not active))
12652 ;; There is no info on this group if it was, in fact,
12653 ;; killed. Gnus stores no information on killed groups, so
12654 ;; there's nothing to be done.
12655 ;; One could store the information somewhere temporarily,
12656 ;; perhaps... Hmmm...
12658 ;; Remove any negative articles numbers.
12659 (while (and unread (< (car unread) 0))
12660 (setq unread (cdr unread)))
12661 ;; Remove any expired article numbers
12662 (while (and unread (< (car unread) (car active)))
12663 (setq unread (cdr unread)))
12664 ;; Compute the ranges of read articles by looking at the list of
12665 ;; unread articles.
12666 (while unread
12667 (when (/= (car unread) prev)
12668 (push (if (= prev (1- (car unread))) prev
12669 (cons prev (1- (car unread))))
12670 read))
12671 (setq prev (1+ (car unread)))
12672 (setq unread (cdr unread)))
12673 (when (<= prev (cdr active))
12674 (push (cons prev (cdr active)) read))
12675 (setq read (if (> (length read) 1) (nreverse read) read))
12676 (if compute
12677 read
12678 (save-excursion
12679 (let (setmarkundo)
12680 ;; Propagate the read marks to the backend.
12681 (when (and (gnus-method-option-p
12682 (gnus-find-method-for-group group)
12683 'server-marks)
12684 (gnus-check-backend-function 'request-set-mark group))
12685 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12686 (add (gnus-remove-from-range read (gnus-info-read info))))
12687 (when (or add del)
12688 (unless (gnus-check-group group)
12689 (error "Can't open server for %s" group))
12690 (gnus-request-set-mark
12691 group (delq nil (list (if add (list add 'add '(read)))
12692 (if del (list del 'del '(read))))))
12693 (setq setmarkundo
12694 `(gnus-request-set-mark
12695 ,group
12696 ',(delq nil (list
12697 (if del (list del 'add '(read)))
12698 (if add (list add 'del '(read))))))))))
12699 (set-buffer gnus-group-buffer)
12700 (gnus-undo-register
12701 `(progn
12702 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12703 (gnus-info-set-read ',info ',(gnus-info-read info))
12704 (gnus-get-unread-articles-in-group ',info
12705 (gnus-active ,group))
12706 (gnus-group-update-group ,group t)
12707 ,setmarkundo))))
12708 ;; Enter this list into the group info.
12709 (gnus-info-set-read info read)
12710 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12711 (gnus-get-unread-articles-in-group info (gnus-active group))
12712 t))))
12714 (defun gnus-offer-save-summaries ()
12715 "Offer to save all active summary buffers."
12716 (let (buffers)
12717 ;; Go through all buffers and find all summaries.
12718 (dolist (buffer (buffer-list))
12719 (when (and (setq buffer (buffer-name buffer))
12720 (string-match "Summary" buffer)
12721 (with-current-buffer buffer
12722 ;; We check that this is, indeed, a summary buffer.
12723 (and (derived-mode-p 'gnus-summary-mode)
12724 ;; Also make sure this isn't bogus.
12725 gnus-newsgroup-prepared
12726 ;; Also make sure that this isn't a
12727 ;; dead summary buffer.
12728 (not gnus-dead-summary-mode))))
12729 (push buffer buffers)))
12730 ;; Go through all these summary buffers and offer to save them.
12731 (when buffers
12732 (save-excursion
12733 (if (eq gnus-interactive-exit 'quiet)
12734 (dolist (buffer buffers)
12735 (switch-to-buffer buffer)
12736 (gnus-summary-exit))
12737 (map-y-or-n-p
12738 "Update summary buffer %s? "
12739 (lambda (buf)
12740 (switch-to-buffer buf)
12741 (gnus-summary-exit))
12742 buffers))))))
12744 (defun gnus-summary-setup-default-charset ()
12745 "Setup newsgroup default charset."
12746 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12747 (setq gnus-newsgroup-charset nil)
12748 (let* ((ignored-charsets
12749 (or gnus-newsgroup-ephemeral-ignored-charsets
12750 (append
12751 (and gnus-newsgroup-name
12752 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12753 gnus-newsgroup-ignored-charsets))))
12754 (setq gnus-newsgroup-charset
12755 (or gnus-newsgroup-ephemeral-charset
12756 (and gnus-newsgroup-name
12757 (gnus-parameter-charset gnus-newsgroup-name))
12758 gnus-default-charset))
12759 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12760 ignored-charsets))))
12763 ;;; Mime Commands
12766 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12767 "Display the current article buffer fully MIME-buttonized.
12768 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12769 treated as multipart/mixed."
12770 (interactive "P")
12771 (require 'gnus-art)
12772 (let ((gnus-unbuttonized-mime-types nil)
12773 (gnus-mime-display-multipart-as-mixed show-all-parts))
12774 (gnus-summary-show-article)))
12776 (defun gnus-summary-repair-multipart (article)
12777 "Add a Content-Type header to a multipart article without one."
12778 (interactive (list (gnus-summary-article-number)))
12779 (gnus-with-article article
12780 (message-narrow-to-head)
12781 (message-remove-header "Mime-Version")
12782 (goto-char (point-max))
12783 (insert "Mime-Version: 1.0\n")
12784 (widen)
12785 (when (search-forward "\n--" nil t)
12786 (let ((separator (buffer-substring (point) (point-at-eol))))
12787 (message-narrow-to-head)
12788 (message-remove-header "Content-Type")
12789 (goto-char (point-max))
12790 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12791 separator))
12792 (widen))))
12793 (let (gnus-mark-article-hook)
12794 (gnus-summary-select-article t t nil article)))
12796 (defun gnus-summary-toggle-display-buttonized ()
12797 "Toggle the buttonizing of the article buffer."
12798 (interactive)
12799 (require 'gnus-art)
12800 (if (setq gnus-inhibit-mime-unbuttonizing
12801 (not gnus-inhibit-mime-unbuttonizing))
12802 (let ((gnus-unbuttonized-mime-types nil))
12803 (gnus-summary-show-article))
12804 (gnus-summary-show-article)))
12807 ;;; Generic summary marking commands
12810 (defvar gnus-summary-marking-alist
12811 '((read gnus-del-mark "d")
12812 (unread gnus-unread-mark "u")
12813 (ticked gnus-ticked-mark "!")
12814 (dormant gnus-dormant-mark "?")
12815 (expirable gnus-expirable-mark "e"))
12816 "An alist of names/marks/keystrokes.")
12818 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12819 (defvar gnus-summary-mark-map)
12821 (defun gnus-summary-make-all-marking-commands ()
12822 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12823 (dolist (elem gnus-summary-marking-alist)
12824 (apply 'gnus-summary-make-marking-command elem)))
12826 (defun gnus-summary-make-marking-command (name mark keystroke)
12827 (let ((map (make-sparse-keymap)))
12828 (define-key gnus-summary-generic-mark-map keystroke map)
12829 (dolist (lway `((next "next" next nil "n")
12830 (next-unread "next unread" next t "N")
12831 (prev "previous" prev nil "p")
12832 (prev-unread "previous unread" prev t "P")
12833 (nomove "" nil nil ,keystroke)))
12834 (let ((func (gnus-summary-make-marking-command-1
12835 mark (car lway) lway name)))
12836 (setq func (eval func))
12837 (define-key map (nth 4 lway) func)))))
12839 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12840 `(defun ,(intern
12841 (format "gnus-summary-put-mark-as-%s%s"
12842 name (if (eq way 'nomove)
12844 (concat "-" (symbol-name way)))))
12846 ,(format
12847 "Mark the current article as %s%s.
12848 If N, the prefix, then repeat N times.
12849 If N is negative, move in reverse order.
12850 The difference between N and the actual number of articles marked is
12851 returned."
12852 name (cadr lway))
12853 (interactive "p")
12854 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12856 (defun gnus-summary-generic-mark (n mark move unread)
12857 "Mark N articles with MARK."
12858 (unless (derived-mode-p 'gnus-summary-mode)
12859 (error "This command can only be used in the summary buffer"))
12860 (gnus-summary-show-thread)
12861 (let ((nummove
12862 (cond
12863 ((eq move 'next) 1)
12864 ((eq move 'prev) -1)
12865 (t 0))))
12866 (if (zerop nummove)
12867 (setq n 1)
12868 (when (< n 0)
12869 (setq n (abs n)
12870 nummove (* -1 nummove))))
12871 (while (and (> n 0)
12872 (gnus-summary-mark-article nil mark)
12873 (zerop (gnus-summary-next-subject nummove unread t)))
12874 (setq n (1- n)))
12875 (when (/= 0 n)
12876 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12877 (gnus-summary-recenter)
12878 (gnus-summary-position-point)
12879 (gnus-set-mode-line 'summary)
12882 (defun gnus-summary-insert-articles (articles)
12883 (when (setq articles
12884 (gnus-sorted-difference articles
12885 (mapcar (lambda (h)
12886 (mail-header-number h))
12887 gnus-newsgroup-headers)))
12888 (setq gnus-newsgroup-headers
12889 (cl-merge 'list
12890 gnus-newsgroup-headers
12891 (gnus-fetch-headers articles nil t)
12892 'gnus-article-sort-by-number))
12893 (setq gnus-newsgroup-articles
12894 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12895 ;; Suppress duplicates?
12896 (when gnus-suppress-duplicates
12897 (gnus-dup-suppress-articles))
12899 (if (and gnus-fetch-old-headers
12900 (eq gnus-headers-retrieved-by 'nov))
12901 ;; We might want to build some more threads first.
12902 (if (eq gnus-fetch-old-headers 'invisible)
12903 (gnus-build-all-threads)
12904 (gnus-build-old-threads))
12905 ;; Mark the inserted articles that are unread as unread.
12906 (setq gnus-newsgroup-unreads
12907 (gnus-sorted-nunion
12908 gnus-newsgroup-unreads
12909 (gnus-sorted-nintersection
12910 (gnus-list-of-unread-articles gnus-newsgroup-name)
12911 articles)))
12912 ;; Mark the inserted articles as selected so that the information
12913 ;; of the marks having been changed by a user may be updated when
12914 ;; exiting this group. See `gnus-summary-update-info'.
12915 (dolist (art articles)
12916 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12917 ;; Let the Gnus agent mark articles as read.
12918 (when gnus-agent
12919 (gnus-agent-get-undownloaded-list))
12920 ;; Remove list identifiers from subject
12921 (gnus-summary-remove-list-identifiers)
12922 ;; First and last article in this newsgroup.
12923 (when gnus-newsgroup-headers
12924 (setq gnus-newsgroup-begin
12925 (mail-header-number (car gnus-newsgroup-headers))
12926 gnus-newsgroup-end
12927 (mail-header-number
12928 (car (last gnus-newsgroup-headers)))))
12929 (when gnus-use-scoring
12930 (gnus-possibly-score-headers))))
12932 (defun gnus-summary-insert-old-articles (&optional all)
12933 "Insert all old articles in this group.
12934 If ALL is non-nil, already read articles become readable.
12935 If ALL is a number, fetch this number of articles."
12936 (interactive "P")
12937 (prog1
12938 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12939 older len)
12940 (setq older
12941 ;; Some nntp servers lie about their active range. When
12942 ;; this happens, the active range can be in the millions.
12943 ;; Use a compressed range to avoid creating a huge list.
12944 (gnus-range-difference
12945 (gnus-range-difference (list gnus-newsgroup-active) old)
12946 gnus-newsgroup-unexist))
12947 (setq len (gnus-range-length older))
12948 (cond
12949 ((null older) nil)
12950 ((numberp all)
12951 (if (< all len)
12952 (let ((older-range (nreverse older)))
12953 (setq older nil)
12955 (while (> all 0)
12956 (let* ((r (pop older-range))
12957 (min (if (numberp r) r (car r)))
12958 (max (if (numberp r) r (cdr r))))
12959 (while (and (<= min max)
12960 (> all 0))
12961 (push max older)
12962 (setq all (1- all)
12963 max (1- max))))))
12964 (setq older (gnus-uncompress-range older))))
12965 (all
12966 (setq older (gnus-uncompress-range older)))
12968 (when (and (numberp gnus-large-newsgroup)
12969 (> len gnus-large-newsgroup))
12970 (let* ((cursor-in-echo-area nil)
12971 (initial (gnus-parameter-large-newsgroup-initial
12972 gnus-newsgroup-name))
12973 (input
12974 (read-string
12975 (format
12976 "How many articles from %s (%s %d): "
12977 (gnus-group-decoded-name gnus-newsgroup-name)
12978 (if initial "max" "default")
12979 len)
12980 nil nil
12981 (and initial
12982 (number-to-string initial)))))
12983 (unless (string-match "^[ \t]*$" input)
12984 (setq all (string-to-number input))
12985 (if (< all len)
12986 (let ((older-range (nreverse older)))
12987 (setq older nil)
12989 (while (> all 0)
12990 (let* ((r (pop older-range))
12991 (min (if (numberp r) r (car r)))
12992 (max (if (numberp r) r (cdr r))))
12993 (while (and (<= min max)
12994 (> all 0))
12995 (push max older)
12996 (setq all (1- all)
12997 max (1- max))))))))))
12998 (setq older (gnus-uncompress-range older))))
12999 (if (not older)
13000 (message "No old news.")
13001 (gnus-summary-insert-articles older)
13002 (gnus-summary-limit (gnus-sorted-nunion old older))))
13003 (gnus-summary-position-point)))
13005 (defun gnus-summary-insert-new-articles ()
13006 "Insert all new articles in this group."
13007 (interactive)
13008 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13009 (old-high gnus-newsgroup-highest)
13010 (nnmail-fetched-sources (list t))
13011 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13012 i new)
13013 (unless new-active
13014 (error "Couldn't fetch new data"))
13015 (setq gnus-newsgroup-active (copy-tree new-active))
13016 (setq i (cdr gnus-newsgroup-active)
13017 gnus-newsgroup-highest i)
13018 (while (> i old-high)
13019 (push i new)
13020 (decf i))
13021 (if (not new)
13022 (message "No gnus is bad news")
13023 (gnus-summary-insert-articles new)
13024 (setq gnus-newsgroup-unreads
13025 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13026 (gnus-summary-limit (gnus-sorted-nunion old new))))
13027 (gnus-summary-position-point))
13029 ;;; Bookmark support for Gnus.
13030 (declare-function gnus-article-show-summary "gnus-art" ())
13031 (declare-function bookmark-make-record-default
13032 "bookmark" (&optional no-file no-context posn))
13033 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13034 (declare-function bookmark-default-handler "bookmark" (bmk))
13035 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13036 (defvar bookmark-yank-point)
13037 (defvar bookmark-current-buffer)
13039 (defun gnus-summary-bookmark-make-record ()
13040 "Make a bookmark entry for a Gnus summary buffer."
13041 (let (pos buf)
13042 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13043 (save-restriction ; FIXME is it necessary to widen?
13044 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13045 (setq buf "art") ; We are recording bookmark from article buffer.
13046 (setq bookmark-yank-point (point))
13047 (setq bookmark-current-buffer (current-buffer))
13048 (gnus-article-show-summary)) ; Go back in summary buffer.
13049 ;; We are now recording bookmark from summary buffer.
13050 (unless buf (setq buf "sum"))
13051 (let* ((subject (elt (gnus-summary-article-header) 1))
13052 (grp (car gnus-article-current))
13053 (art (cdr gnus-article-current))
13054 (head (gnus-summary-article-header art))
13055 (id (mail-header-id head)))
13056 `(,subject
13057 ,@(condition-case nil
13058 (bookmark-make-record-default 'no-file 'no-context pos)
13059 (wrong-number-of-arguments
13060 (bookmark-make-record-default 'point-only)))
13061 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13062 (group . ,grp) (article . ,art)
13063 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13065 ;;;###autoload
13066 (defun gnus-summary-bookmark-jump (bookmark)
13067 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13068 BOOKMARK is a bookmark name or a bookmark record."
13069 (let ((group (bookmark-prop-get bookmark 'group))
13070 (article (bookmark-prop-get bookmark 'article))
13071 (id (bookmark-prop-get bookmark 'message-id))
13072 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13073 (gnus-fetch-group group (list article))
13074 (gnus-summary-insert-cached-articles)
13075 (gnus-summary-goto-article id nil 'force)
13076 ;; FIXME we have to wait article buffer is ready (only large buffer)
13077 ;; Is there a better solution to know that?
13078 ;; If we don't wait `bookmark-default-handler' will have no chance
13079 ;; to set position. However there is no error, just wrong pos.
13080 (sit-for 1)
13081 (when (string= buf "Gnus-art")
13082 (other-window 1))
13083 (bookmark-default-handler
13084 `(""
13085 (buffer . ,(current-buffer))
13086 . ,(bookmark-get-bookmark-record bookmark)))))
13088 (gnus-summary-make-all-marking-commands)
13090 (provide 'gnus-sum)
13092 (run-hooks 'gnus-sum-load-hook)
13094 ;; Local Variables:
13095 ;; coding: utf-8
13096 ;; End:
13098 ;;; gnus-sum.el ends here