* font.c (clear_font_cache): New function, stripped from...
[emacs.git] / lisp / gnus / gnus-sum.el
blob94f4e703180e12488daea4dd88da0c5f4b5f68e8
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2013 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 ;; For Emacs <22.2 and XEmacs.
28 (eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30 (eval-when-compile
31 (require 'cl))
32 (eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
39 (require 'gnus)
40 (require 'gnus-group)
41 (require 'gnus-spec)
42 (require 'gnus-range)
43 (require 'gnus-int)
44 (require 'gnus-undo)
45 (require 'gnus-util)
46 (require 'gmm-utils)
47 (require 'mm-decode)
48 (require 'nnoo)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
78 :type 'boolean)
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
84 :version "24.1"
85 :type 'boolean)
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
108 (const :tag "on" t)
109 (const some)
110 (const invisible)
111 number
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
124 current group."
125 :version "24.1"
126 :group 'gnus-thread
127 :type 'boolean)
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
140 `dummy' or `empty'.
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
151 :group 'gnus-thread
152 :type '(choice (const :tag "off" nil)
153 (const none)
154 (const dummy)
155 (const adopt)
156 (const empty)))
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
160 :version "22.1"
161 :group 'gnus-thread
162 :type 'boolean)
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
169 :group 'gnus-thread
170 :type 'regexp)
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
181 comparing subjects."
182 :group 'gnus-thread
183 :type '(choice (const :tag "off" nil)
184 (const fuzzy)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
194 :group 'gnus-thread
195 :type '(repeat function))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 regexp))
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
208 :group 'gnus-thread
209 :type '(choice (const :tag "off" nil)
210 (const some)
211 (const more)
212 (sexp :menu-tag "all" t)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
221 :group 'gnus-thread
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
231 :type 'string)
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
243 :version "24.1"
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
247 (const never)
248 (sexp :menu-tag "on" t)))
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
256 integer))
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
261 than this score."
262 :version "22.1"
263 :group 'gnus-score-default
264 :type 'integer)
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
269 than this score."
270 :version "22.1"
271 :group 'gnus-score-default
272 :type 'integer)
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
277 will not be marked."
278 :group 'gnus-summary-format
279 :type 'integer)
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
286 :group 'gnus-thread
287 :type '(repeat regexp))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
291 :group 'gnus-thread
292 :type 'boolean)
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
299 :group 'gnus-thread
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
303 :value t)
304 (const nil)
305 (sexp :tag "Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
309 :group 'gnus-thread
310 :type 'boolean)
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
316 :group 'gnus-thread
317 :type 'boolean)
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
328 :group 'gnus-thread
329 :type '(choice (const :tag "off" nil)
330 (const fuzzy)
331 (sexp :tag "on" t)))
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
335 :group 'gnus-thread
336 :type 'integer)
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
341 :type 'boolean)
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
373 :version "24.1"
374 :group 'gnus-group-select
375 :type '(choice (const best)
376 (const unread)
377 (const first)
378 (const unseen)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
395 (const quietly)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
405 :type 'boolean)
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
411 `next'
412 Select the next article.
413 `next-unread'
414 Select the next unread article.
415 `next-noselect'
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
440 :version "22.1"
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
452 :type 'boolean)
454 (defcustom gnus-auto-center-summary
455 (max (or (bound-and-true-p scroll-margin) 0) 2)
456 "*If non-nil, always center the current summary buffer.
457 In particular, if `vertical' do only vertical recentering. If non-nil
458 and non-`vertical', do both horizontal and vertical recentering."
459 :group 'gnus-summary-maneuvering
460 :type '(choice (const :tag "none" nil)
461 (const vertical)
462 (integer :tag "height")
463 (sexp :menu-tag "both" t)))
465 (defcustom gnus-auto-center-group t
466 "If non-nil, always center the group buffer."
467 :group 'gnus-summary-maneuvering
468 :type 'boolean)
470 (defcustom gnus-show-all-headers nil
471 "*If non-nil, don't hide any headers."
472 :group 'gnus-article-hiding
473 :group 'gnus-article-headers
474 :type 'boolean)
476 (defcustom gnus-summary-ignore-duplicates nil
477 "*If non-nil, ignore articles with identical Message-ID headers."
478 :group 'gnus-summary
479 :type 'boolean)
481 (defcustom gnus-single-article-buffer nil
482 "*If non-nil, display all articles in the same buffer.
483 If nil, each group will get its own article buffer."
484 :version "24.1"
485 :group 'gnus-article-various
486 :type 'boolean)
488 (defcustom gnus-widen-article-window nil
489 "If non-nil, selecting the article buffer will display only the article buffer."
490 :version "24.1"
491 :group 'gnus-article-various
492 :type 'boolean)
494 (defcustom gnus-break-pages t
495 "*If non-nil, do page breaking on articles.
496 The page delimiter is specified by the `gnus-page-delimiter'
497 variable."
498 :group 'gnus-article-various
499 :type 'boolean)
501 (defcustom gnus-move-split-methods nil
502 "*Variable used to suggest where articles are to be moved to.
503 It uses the same syntax as the `gnus-split-methods' variable.
504 However, whereas `gnus-split-methods' specifies file names as targets,
505 this variable specifies group names."
506 :group 'gnus-summary-mail
507 :type '(repeat (choice (list :value (fun) function)
508 (cons :value ("" "") regexp (repeat string))
509 (sexp :value nil))))
511 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
512 "Function used to compute default prefix for article move/copy/etc prompts.
513 The function should take one argument, a group name, and return a
514 string with the suggested prefix."
515 :group 'gnus-summary-mail
516 :type 'function)
518 ;; FIXME: Although the custom type is `character' for the following variables,
519 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
521 (defcustom gnus-unread-mark ? ;Whitespace
522 "*Mark used for unread articles."
523 :group 'gnus-summary-marks
524 :type 'character)
526 (defcustom gnus-ticked-mark ?!
527 "*Mark used for ticked articles."
528 :group 'gnus-summary-marks
529 :type 'character)
531 (defcustom gnus-dormant-mark ??
532 "*Mark used for dormant articles."
533 :group 'gnus-summary-marks
534 :type 'character)
536 (defcustom gnus-del-mark ?r
537 "*Mark used for del'd articles."
538 :group 'gnus-summary-marks
539 :type 'character)
541 (defcustom gnus-read-mark ?R
542 "*Mark used for read articles."
543 :group 'gnus-summary-marks
544 :type 'character)
546 (defcustom gnus-expirable-mark ?E
547 "*Mark used for expirable articles."
548 :group 'gnus-summary-marks
549 :type 'character)
551 (defcustom gnus-killed-mark ?K
552 "*Mark used for killed articles."
553 :group 'gnus-summary-marks
554 :type 'character)
556 (defcustom gnus-spam-mark ?$
557 "*Mark used for spam articles."
558 :version "22.1"
559 :group 'gnus-summary-marks
560 :type 'character)
562 (defcustom gnus-kill-file-mark ?X
563 "*Mark used for articles killed by kill files."
564 :group 'gnus-summary-marks
565 :type 'character)
567 (defcustom gnus-low-score-mark ?Y
568 "*Mark used for articles with a low score."
569 :group 'gnus-summary-marks
570 :type 'character)
572 (defcustom gnus-catchup-mark ?C
573 "*Mark used for articles that are caught up."
574 :group 'gnus-summary-marks
575 :type 'character)
577 (defcustom gnus-replied-mark ?A
578 "*Mark used for articles that have been replied to."
579 :group 'gnus-summary-marks
580 :type 'character)
582 (defcustom gnus-forwarded-mark ?F
583 "*Mark used for articles that have been forwarded."
584 :version "22.1"
585 :group 'gnus-summary-marks
586 :type 'character)
588 (defcustom gnus-recent-mark ?N
589 "*Mark used for articles that are recent."
590 :version "22.1"
591 :group 'gnus-summary-marks
592 :type 'character)
594 (defcustom gnus-cached-mark ?*
595 "*Mark used for articles that are in the cache."
596 :group 'gnus-summary-marks
597 :type 'character)
599 (defcustom gnus-saved-mark ?S
600 "*Mark used for articles that have been saved."
601 :group 'gnus-summary-marks
602 :type 'character)
604 (defcustom gnus-unseen-mark ?.
605 "*Mark used for articles that haven't been seen."
606 :version "22.1"
607 :group 'gnus-summary-marks
608 :type 'character)
610 (defcustom gnus-no-mark ? ;Whitespace
611 "*Mark used for articles that have no other secondary mark."
612 :version "22.1"
613 :group 'gnus-summary-marks
614 :type 'character)
616 (defcustom gnus-ancient-mark ?O
617 "*Mark used for ancient articles."
618 :group 'gnus-summary-marks
619 :type 'character)
621 (defcustom gnus-sparse-mark ?Q
622 "*Mark used for sparsely reffed articles."
623 :group 'gnus-summary-marks
624 :type 'character)
626 (defcustom gnus-canceled-mark ?G
627 "*Mark used for canceled articles."
628 :group 'gnus-summary-marks
629 :type 'character)
631 (defcustom gnus-duplicate-mark ?M
632 "*Mark used for duplicate articles."
633 :group 'gnus-summary-marks
634 :type 'character)
636 (defcustom gnus-undownloaded-mark ?-
637 "*Mark used for articles that weren't downloaded."
638 :version "22.1"
639 :group 'gnus-summary-marks
640 :type 'character)
642 (defcustom gnus-downloaded-mark ?+
643 "*Mark used for articles that were downloaded."
644 :group 'gnus-summary-marks
645 :type 'character)
647 (defcustom gnus-downloadable-mark ?%
648 "*Mark used for articles that are to be downloaded."
649 :group 'gnus-summary-marks
650 :type 'character)
652 (defcustom gnus-unsendable-mark ?=
653 "*Mark used for articles that won't be sent."
654 :group 'gnus-summary-marks
655 :type 'character)
657 (defcustom gnus-score-over-mark ?+
658 "*Score mark used for articles with high scores."
659 :group 'gnus-summary-marks
660 :type 'character)
662 (defcustom gnus-score-below-mark ?-
663 "*Score mark used for articles with low scores."
664 :group 'gnus-summary-marks
665 :type 'character)
667 (defcustom gnus-empty-thread-mark ? ;Whitespace
668 "*There is no thread under the article."
669 :group 'gnus-summary-marks
670 :type 'character)
672 (defcustom gnus-not-empty-thread-mark ?=
673 "*There is a thread under the article."
674 :group 'gnus-summary-marks
675 :type 'character)
677 (defcustom gnus-view-pseudo-asynchronously nil
678 "*If non-nil, Gnus will view pseudo-articles asynchronously."
679 :group 'gnus-extract-view
680 :type 'boolean)
682 (defcustom gnus-auto-expirable-marks
683 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
684 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
685 gnus-duplicate-mark)
686 "*The list of marks converted into expiration if a group is auto-expirable."
687 :version "24.1"
688 :group 'gnus-summary
689 :type '(repeat character))
691 (defcustom gnus-inhibit-user-auto-expire t
692 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
693 :version "21.1"
694 :group 'gnus-summary
695 :type 'boolean)
697 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
698 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
699 If nil, the expirable marks will be unchanged except that the marks
700 will be removed when copying or moving articles to a group that has
701 not turned auto-expire on. If non-nil, articles that have been read
702 will be marked as expirable when being copied or moved to a group in
703 which auto-expire is turned on."
704 :version "23.2"
705 :type 'boolean
706 :group 'gnus-summary-marks)
708 (defcustom gnus-view-pseudos nil
709 "*If `automatic', pseudo-articles will be viewed automatically.
710 If `not-confirm', pseudos will be viewed automatically, and the user
711 will not be asked to confirm the command."
712 :group 'gnus-extract-view
713 :type '(choice (const :tag "off" nil)
714 (const automatic)
715 (const not-confirm)))
717 (defcustom gnus-view-pseudos-separately t
718 "*If non-nil, one pseudo-article will be created for each file to be viewed.
719 If nil, all files that use the same viewing command will be given as a
720 list of parameters to that command."
721 :group 'gnus-extract-view
722 :type 'boolean)
724 (defcustom gnus-insert-pseudo-articles t
725 "*If non-nil, insert pseudo-articles when decoding articles."
726 :group 'gnus-extract-view
727 :type 'boolean)
729 (defcustom gnus-summary-dummy-line-format
730 " %(: :%) %S\n"
731 "*The format specification for the dummy roots in the summary buffer.
732 It works along the same lines as a normal formatting string,
733 with some simple extensions.
735 %S The subject
737 General format specifiers can also be used.
738 See `(gnus)Formatting Variables'."
739 :link '(custom-manual "(gnus)Formatting Variables")
740 :group 'gnus-threading
741 :type 'string)
743 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
744 "*The format specification for the summary mode line.
745 It works along the same lines as a normal formatting string,
746 with some simple extensions:
748 %G Group name
749 %p Unprefixed group name
750 %A Current article number
751 %z Current article score
752 %V Gnus version
753 %U Number of unread articles in the group
754 %e Number of unselected articles in the group
755 %Z A string with unread/unselected article counts
756 %g Shortish group name
757 %S Subject of the current article
758 %u User-defined spec
759 %s Current score file name
760 %d Number of dormant articles
761 %r Number of articles that have been marked as read in this session
762 %E Number of articles expunged by the score files"
763 :group 'gnus-summary-format
764 :type 'string)
766 (defcustom gnus-list-identifiers nil
767 "Regexp that matches list identifiers to be removed from subject.
768 This can also be a list of regexps."
769 :version "21.1"
770 :group 'gnus-summary-format
771 :group 'gnus-article-hiding
772 :type '(choice (const :tag "none" nil)
773 (regexp :value ".*")
774 (repeat :value (".*") regexp)))
776 (defcustom gnus-summary-mark-below 0
777 "*Mark all articles with a score below this variable as read.
778 This variable is local to each summary buffer and usually set by the
779 score file."
780 :group 'gnus-score-default
781 :type 'integer)
783 (defun gnus-widget-reversible-match (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
786 ;; (debug value)
787 (or (symbolp value)
788 (and (listp value)
789 (eq (length value) 2)
790 (eq (nth 0 value) 'not)
791 (symbolp (nth 1 value)))))
793 (defun gnus-widget-reversible-to-internal (widget value)
794 "Ignoring WIDGET, convert VALUE to internal form.
795 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
796 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
797 ;; (debug value)
798 (if (atom value)
799 (list value nil)
800 (list (nth 1 value) t)))
802 (defun gnus-widget-reversible-to-external (widget value)
803 "Ignoring WIDGET, convert VALUE to external form.
804 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
805 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
806 ;; (debug value)
807 (if (nth 1 value)
808 (list 'not (nth 0 value))
809 (nth 0 value)))
811 (define-widget 'gnus-widget-reversible 'group
812 "A `group' that convert values."
813 :match 'gnus-widget-reversible-match
814 :value-to-internal 'gnus-widget-reversible-to-internal
815 :value-to-external 'gnus-widget-reversible-to-external)
817 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
818 "*List of functions used for sorting articles in the summary buffer.
820 Each function takes two articles and returns non-nil if the first
821 article should be sorted before the other. If you use more than one
822 function, the primary sort function should be the last. You should
823 probably always include `gnus-article-sort-by-number' in the list of
824 sorting functions -- preferably first. Also note that sorting by date
825 is often much slower than sorting by number, and the sorting order is
826 very similar. (Sorting by date means sorting by the time the message
827 was sent, sorting by number means sorting by arrival time.)
829 Each item can also be a list `(not F)' where F is a function;
830 this reverses the sort order.
832 Ready-made functions include `gnus-article-sort-by-number',
833 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
834 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
835 and `gnus-article-sort-by-score'.
837 When threading is turned on, the variable `gnus-thread-sort-functions'
838 controls how articles are sorted."
839 :group 'gnus-summary-sort
840 :type '(repeat (gnus-widget-reversible
841 (choice (function-item gnus-article-sort-by-number)
842 (function-item gnus-article-sort-by-author)
843 (function-item gnus-article-sort-by-subject)
844 (function-item gnus-article-sort-by-date)
845 (function-item gnus-article-sort-by-score)
846 (function-item gnus-article-sort-by-random)
847 (function :tag "other"))
848 (boolean :tag "Reverse order"))))
850 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
851 "*List of functions used for sorting threads in the summary buffer.
852 By default, threads are sorted by article number.
854 Each function takes two threads and returns non-nil if the first
855 thread should be sorted before the other. If you use more than one
856 function, the primary sort function should be the last. You should
857 probably always include `gnus-thread-sort-by-number' in the list of
858 sorting functions -- preferably first. Also note that sorting by date
859 is often much slower than sorting by number, and the sorting order is
860 very similar. (Sorting by date means sorting by the time the message
861 was sent, sorting by number means sorting by arrival time.)
863 Each list item can also be a list `(not F)' where F is a
864 function; this specifies reversed sort order.
866 Ready-made functions include `gnus-thread-sort-by-number',
867 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
868 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
869 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
870 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
871 and `gnus-thread-sort-by-total-score' (see
872 `gnus-thread-score-function').
874 When threading is turned off, the variable
875 `gnus-article-sort-functions' controls how articles are sorted.
877 By default, threads and their subthreads are sorted according to
878 the value of this variable. To use a different sorting order for
879 subthreads, customize `gnus-subthread-sort-functions'."
880 :group 'gnus-summary-sort
881 :type '(repeat
882 (gnus-widget-reversible
883 (choice (function-item gnus-thread-sort-by-number)
884 (function-item gnus-thread-sort-by-author)
885 (function-item gnus-thread-sort-by-recipient)
886 (function-item gnus-thread-sort-by-subject)
887 (function-item gnus-thread-sort-by-date)
888 (function-item gnus-thread-sort-by-score)
889 (function-item gnus-thread-sort-by-most-recent-number)
890 (function-item gnus-thread-sort-by-most-recent-date)
891 (function-item gnus-thread-sort-by-random)
892 (function-item gnus-thread-sort-by-total-score)
893 (function :tag "other"))
894 (boolean :tag "Reverse order"))))
896 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
897 "*List of functions used for sorting subthreads in the summary buffer.
898 By default, subthreads are sorted the same as threads, i.e.,
899 according to the value of `gnus-thread-sort-functions'."
900 :group 'gnus-summary-sort
901 :type '(choice
902 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
903 (repeat
904 (gnus-widget-reversible
905 (choice (function-item gnus-thread-sort-by-number)
906 (function-item gnus-thread-sort-by-author)
907 (function-item gnus-thread-sort-by-recipient)
908 (function-item gnus-thread-sort-by-subject)
909 (function-item gnus-thread-sort-by-date)
910 (function-item gnus-thread-sort-by-score)
911 (function-item gnus-thread-sort-by-most-recent-number)
912 (function-item gnus-thread-sort-by-most-recent-date)
913 (function-item gnus-thread-sort-by-random)
914 (function-item gnus-thread-sort-by-total-score)
915 (function :tag "other"))
916 (boolean :tag "Reverse order")))))
918 (defcustom gnus-thread-score-function '+
919 "*Function used for calculating the total score of a thread.
921 The function is called with the scores of the article and each
922 subthread and should then return the score of the thread.
924 Some functions you can use are `+', `max', or `min'."
925 :group 'gnus-summary-sort
926 :type 'function)
928 (defcustom gnus-summary-expunge-below nil
929 "All articles that have a score less than this variable will be expunged.
930 This variable is local to the summary buffers."
931 :group 'gnus-score-default
932 :type '(choice (const :tag "off" nil)
933 integer))
935 (defcustom gnus-thread-expunge-below nil
936 "All threads that have a total score less than this variable will be expunged.
937 See `gnus-thread-score-function' for en explanation of what a
938 \"thread score\" is.
940 This variable is local to the summary buffers."
941 :group 'gnus-threading
942 :group 'gnus-score-default
943 :type '(choice (const :tag "off" nil)
944 integer))
946 (defcustom gnus-summary-mode-hook nil
947 "*A hook for Gnus summary mode.
948 This hook is run before any variables are set in the summary buffer."
949 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
950 :group 'gnus-summary-various
951 :type 'hook)
953 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
954 (when (featurep 'xemacs)
955 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
956 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
957 (add-hook 'gnus-summary-mode-hook
958 'gnus-xmas-switch-horizontal-scrollbar-off))
960 (defcustom gnus-summary-menu-hook nil
961 "*Hook run after the creation of the summary mode menu."
962 :group 'gnus-summary-visual
963 :type 'hook)
965 (defcustom gnus-summary-exit-hook nil
966 "*A hook called on exit from the summary buffer.
967 It will be called with point in the group buffer."
968 :group 'gnus-summary-exit
969 :type 'hook)
971 (defcustom gnus-summary-prepare-hook nil
972 "*A hook called after the summary buffer has been generated.
973 If you want to modify the summary buffer, you can use this hook."
974 :group 'gnus-summary-various
975 :type 'hook)
977 (defcustom gnus-summary-prepared-hook nil
978 "*A hook called as the last thing after the summary buffer has been generated."
979 :group 'gnus-summary-various
980 :type 'hook)
982 (defcustom gnus-summary-generate-hook nil
983 "*A hook run just before generating the summary buffer.
984 This hook is commonly used to customize threading variables and the
985 like."
986 :group 'gnus-summary-various
987 :type 'hook)
989 (defcustom gnus-select-group-hook nil
990 "*A hook called when a newsgroup is selected.
992 If you'd like to simplify subjects like the
993 `gnus-summary-next-same-subject' command does, you can use the
994 following hook:
996 (add-hook gnus-select-group-hook
997 (lambda ()
998 (mapcar (lambda (header)
999 (mail-header-set-subject
1000 header
1001 (gnus-simplify-subject
1002 (mail-header-subject header) 're-only)))
1003 gnus-newsgroup-headers)))"
1004 :group 'gnus-group-select
1005 :type 'hook)
1007 (defcustom gnus-select-article-hook nil
1008 "*A hook called when an article is selected."
1009 :group 'gnus-summary-choose
1010 :options '(gnus-agent-fetch-selected-article)
1011 :type 'hook)
1013 (defcustom gnus-visual-mark-article-hook
1014 (list 'gnus-highlight-selected-summary)
1015 "*Hook run after selecting an article in the summary buffer.
1016 It is meant to be used for highlighting the article in some way. It
1017 is not run if `gnus-visual' is nil."
1018 :group 'gnus-summary-visual
1019 :type 'hook)
1021 (defcustom gnus-parse-headers-hook nil
1022 "*A hook called before parsing the headers."
1023 :group 'gnus-various
1024 :type 'hook)
1026 (defcustom gnus-exit-group-hook nil
1027 "*A hook called when exiting summary mode.
1028 This hook is not called from the non-updating exit commands like `Q'."
1029 :group 'gnus-various
1030 :type 'hook)
1032 (defcustom gnus-summary-update-hook nil
1033 "*A hook called when a summary line is changed.
1034 The hook will not be called if `gnus-visual' is nil.
1036 The default function `gnus-summary-highlight-line' will
1037 highlight the line according to the `gnus-summary-highlight'
1038 variable."
1039 :group 'gnus-summary-visual
1040 :type 'hook)
1042 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1043 "*A hook called when an article is selected for the first time.
1044 The hook is intended to mark an article as read (or unread)
1045 automatically when it is selected."
1046 :group 'gnus-summary-choose
1047 :type 'hook)
1049 (defcustom gnus-group-no-more-groups-hook nil
1050 "*A hook run when returning to group mode having no more (unread) groups."
1051 :group 'gnus-group-select
1052 :type 'hook)
1054 (defcustom gnus-ps-print-hook nil
1055 "*A hook run before ps-printing something from Gnus."
1056 :group 'gnus-summary
1057 :type 'hook)
1059 (defcustom gnus-summary-article-move-hook nil
1060 "*A hook called after an article is moved, copied, respooled, or crossposted."
1061 :version "22.1"
1062 :group 'gnus-summary
1063 :type 'hook)
1065 (defcustom gnus-summary-article-delete-hook nil
1066 "*A hook called after an article is deleted."
1067 :version "22.1"
1068 :group 'gnus-summary
1069 :type 'hook)
1071 (defcustom gnus-summary-article-expire-hook nil
1072 "*A hook called after an article is expired."
1073 :version "22.1"
1074 :group 'gnus-summary
1075 :type 'hook)
1077 (defcustom gnus-summary-display-arrow
1078 (and (fboundp 'display-graphic-p)
1079 (display-graphic-p))
1080 "*If non-nil, display an arrow highlighting the current article."
1081 :version "22.1"
1082 :group 'gnus-summary
1083 :type 'boolean)
1085 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1086 "Face used for highlighting the current article in the summary buffer."
1087 :group 'gnus-summary-visual
1088 :type 'face)
1090 (defvar gnus-tmp-downloaded nil)
1092 (defcustom gnus-summary-highlight
1093 '(((eq mark gnus-canceled-mark)
1094 . gnus-summary-cancelled)
1095 ((and uncached (> score default-high))
1096 . gnus-summary-high-undownloaded)
1097 ((and uncached (< score default-low))
1098 . gnus-summary-low-undownloaded)
1099 (uncached
1100 . gnus-summary-normal-undownloaded)
1101 ((and (> score default-high)
1102 (or (eq mark gnus-dormant-mark)
1103 (eq mark gnus-ticked-mark)))
1104 . gnus-summary-high-ticked)
1105 ((and (< score default-low)
1106 (or (eq mark gnus-dormant-mark)
1107 (eq mark gnus-ticked-mark)))
1108 . gnus-summary-low-ticked)
1109 ((or (eq mark gnus-dormant-mark)
1110 (eq mark gnus-ticked-mark))
1111 . gnus-summary-normal-ticked)
1112 ((and (> score default-high) (eq mark gnus-ancient-mark))
1113 . gnus-summary-high-ancient)
1114 ((and (< score default-low) (eq mark gnus-ancient-mark))
1115 . gnus-summary-low-ancient)
1116 ((eq mark gnus-ancient-mark)
1117 . gnus-summary-normal-ancient)
1118 ((and (> score default-high) (eq mark gnus-unread-mark))
1119 . gnus-summary-high-unread)
1120 ((and (< score default-low) (eq mark gnus-unread-mark))
1121 . gnus-summary-low-unread)
1122 ((eq mark gnus-unread-mark)
1123 . gnus-summary-normal-unread)
1124 ((> score default-high)
1125 . gnus-summary-high-read)
1126 ((< score default-low)
1127 . gnus-summary-low-read)
1129 . gnus-summary-normal-read))
1130 "*Controls the highlighting of summary buffer lines.
1132 A list of (FORM . FACE) pairs. When deciding how a particular
1133 summary line should be displayed, each form is evaluated. The content
1134 of the face field after the first true form is used. You can change
1135 how those summary lines are displayed, by editing the face field.
1137 You can use the following variables in the FORM field.
1139 score: The article's score.
1140 default: The default article score.
1141 default-high: The default score for high scored articles.
1142 default-low: The default score for low scored articles.
1143 below: The score below which articles are automatically marked as read.
1144 mark: The article's mark.
1145 uncached: Non-nil if the article is uncached."
1146 :group 'gnus-summary-visual
1147 :type '(repeat (cons (sexp :tag "Form" nil)
1148 face)))
1149 (put 'gnus-summary-highlight 'risky-local-variable t)
1151 (defcustom gnus-alter-header-function nil
1152 "Function called to allow alteration of article header structures.
1153 The function is called with one parameter, the article header vector,
1154 which it may alter in any way."
1155 :type '(choice (const :tag "None" nil)
1156 function)
1157 :group 'gnus-summary)
1159 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1160 "Function used to decode a string with encoded words.")
1162 (defvar gnus-decode-encoded-address-function
1163 'mail-decode-encoded-address-string
1164 "Function used to decode addresses with encoded words.")
1166 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1167 "*Extra headers to parse."
1168 :version "24.1" ; added Cc Keywords Gcc
1169 :group 'gnus-summary
1170 :type '(repeat symbol))
1172 (defcustom gnus-ignored-from-addresses
1173 (and user-mail-address
1174 (not (string= user-mail-address ""))
1175 (regexp-quote user-mail-address))
1176 "*From headers that may be suppressed in favor of To headers.
1177 This can be a regexp or a list of regexps."
1178 :version "21.1"
1179 :group 'gnus-summary
1180 :type '(choice regexp
1181 (repeat :tag "Regexp List" regexp)))
1183 (defsubst gnus-ignored-from-addresses ()
1184 (gmm-regexp-concat gnus-ignored-from-addresses))
1186 (defcustom gnus-summary-to-prefix "-> "
1187 "*String prefixed to the To field in the summary line when
1188 using `gnus-ignored-from-addresses'."
1189 :version "22.1"
1190 :group 'gnus-summary
1191 :type 'string)
1193 (defcustom gnus-summary-newsgroup-prefix "=> "
1194 "*String prefixed to the Newsgroup field in the summary
1195 line when using the option `gnus-ignored-from-addresses'."
1196 :version "22.1"
1197 :group 'gnus-summary
1198 :type 'string)
1200 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1201 "List of charsets that should be ignored.
1202 When these charsets are used in the \"charset\" parameter, the
1203 default charset will be used instead."
1204 :version "21.1"
1205 :type '(repeat symbol)
1206 :group 'gnus-charset)
1208 (defcustom gnus-newsgroup-maximum-articles nil
1209 "The maximum number of articles a newsgroup.
1210 If this is a number, old articles in a newsgroup exceeding this number
1211 are silently ignored. If it is nil, no article is ignored. Note that
1212 setting this variable to a number might prevent you from reading very
1213 old articles."
1214 :group 'gnus-group-select
1215 :version "22.2"
1216 :type '(choice (const :tag "No limit" nil)
1217 integer))
1219 (gnus-define-group-parameter
1220 ignored-charsets
1221 :type list
1222 :function-document
1223 "Return the ignored charsets of GROUP."
1224 :variable gnus-group-ignored-charsets-alist
1225 :variable-default
1226 '(("alt\\.chinese\\.text" iso-8859-1))
1227 :variable-document
1228 "Alist of regexps (to match group names) and charsets that should be ignored.
1229 When these charsets are used in the \"charset\" parameter, the
1230 default charset will be used instead."
1231 :variable-group gnus-charset
1232 :variable-type '(repeat (cons (regexp :tag "Group")
1233 (repeat symbol)))
1234 :parameter-type '(choice :tag "Ignored charsets"
1235 :value nil
1236 (repeat (symbol)))
1237 :parameter-document "\
1238 List of charsets that should be ignored.
1240 When these charsets are used in the \"charset\" parameter, the
1241 default charset will be used instead.")
1243 (defcustom gnus-group-highlight-words-alist nil
1244 "Alist of group regexps and highlight regexps.
1245 This variable uses the same syntax as `gnus-emphasis-alist'."
1246 :version "21.1"
1247 :type '(repeat (cons (regexp :tag "Group")
1248 (repeat (list (regexp :tag "Highlight regexp")
1249 (number :tag "Group for entire word" 0)
1250 (number :tag "Group for displayed part" 0)
1251 (symbol :tag "Face"
1252 gnus-emphasis-highlight-words)))))
1253 :group 'gnus-summary-visual)
1255 (defcustom gnus-summary-show-article-charset-alist
1257 "Alist of number and charset.
1258 The article will be shown with the charset corresponding to the
1259 numbered argument.
1260 For example: ((1 . cn-gb-2312) (2 . big5))."
1261 :version "21.1"
1262 :type '(repeat (cons (number :tag "Argument" 1)
1263 (symbol :tag "Charset")))
1264 :group 'gnus-charset)
1266 (defcustom gnus-preserve-marks t
1267 "Whether marks are preserved when moving, copying and respooling messages."
1268 :version "21.1"
1269 :type 'boolean
1270 :group 'gnus-summary-marks)
1272 (defcustom gnus-alter-articles-to-read-function nil
1273 "Function to be called to alter the list of articles to be selected."
1274 :type '(choice (const nil) function)
1275 :group 'gnus-summary)
1277 (defcustom gnus-orphan-score nil
1278 "*All orphans get this score added. Set in the score file."
1279 :group 'gnus-score-default
1280 :type '(choice (const nil)
1281 integer))
1283 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1284 "*A regexp to match MIME parts when saving multiple parts of a
1285 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1286 This regexp will be used by default when prompting the user for which
1287 type of files to save."
1288 :group 'gnus-summary
1289 :type 'regexp)
1291 (defcustom gnus-read-all-available-headers nil
1292 "Whether Gnus should parse all headers made available to it.
1293 This is mostly relevant for slow back ends where the user may
1294 wish to widen the summary buffer to include all headers
1295 that were fetched."
1296 :version "22.1"
1297 :group 'gnus-summary
1298 :type '(choice boolean regexp))
1300 (defcustom gnus-summary-pipe-output-default-command nil
1301 "Command (and optional arguments) used to pipe article to subprocess.
1302 This will be used as the default command if it is non-nil. The value
1303 will be updated if you modify it when executing the command
1304 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1305 :version "23.1" ;; No Gnus
1306 :group 'gnus-summary
1307 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1309 (defcustom gnus-summary-muttprint-program "muttprint"
1310 "Command (and optional arguments) used to run Muttprint.
1311 The value will be updated if you modify it when executing the command
1312 `gnus-summary-muttprint'."
1313 :version "22.1"
1314 :group 'gnus-summary
1315 :type 'string)
1317 (defcustom gnus-article-loose-mime t
1318 "If non-nil, don't require MIME-Version header.
1319 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1320 supply the MIME-Version header or deliberately strip it from the mail.
1321 If non-nil (the default), Gnus will treat some articles as MIME
1322 even if the MIME-Version header is missing."
1323 :version "22.1"
1324 :type 'boolean
1325 :group 'gnus-article-mime)
1327 (defcustom gnus-article-emulate-mime t
1328 "If non-nil, use MIME emulation for uuencode and the like.
1329 This means that Gnus will search message bodies for text that look
1330 like uuencoded bits, yEncoded bits, and so on, and present that using
1331 the normal Gnus MIME machinery."
1332 :version "22.1"
1333 :type 'boolean
1334 :group 'gnus-article-mime)
1336 ;;; Internal variables
1338 (defvar gnus-summary-display-cache nil)
1339 (defvar gnus-article-mime-handles nil)
1340 (defvar gnus-article-decoded-p nil)
1341 (defvar gnus-article-charset nil)
1342 (defvar gnus-article-ignored-charsets nil)
1343 (defvar gnus-scores-exclude-files nil)
1344 (defvar gnus-page-broken nil)
1346 (defvar gnus-original-article nil)
1347 (defvar gnus-article-internal-prepare-hook nil)
1348 (defvar gnus-newsgroup-process-stack nil)
1350 (defvar gnus-thread-indent-array nil)
1351 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1352 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1353 "Function called to sort the articles within a thread after it has been gathered together.")
1355 (defvar gnus-summary-save-parts-type-history nil)
1356 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1358 ;; Avoid highlighting in kill files.
1359 (defvar gnus-summary-inhibit-highlight nil)
1360 (defvar gnus-newsgroup-selected-overlay nil)
1361 (defvar gnus-inhibit-limiting nil)
1362 (defvar gnus-newsgroup-adaptive-score-file nil)
1363 (defvar gnus-current-score-file nil)
1364 (defvar gnus-current-move-group nil)
1365 (defvar gnus-current-copy-group nil)
1366 (defvar gnus-current-crosspost-group nil)
1367 (defvar gnus-newsgroup-display nil)
1369 (defvar gnus-newsgroup-dependencies nil)
1370 (defvar gnus-newsgroup-adaptive nil)
1371 (defvar gnus-summary-display-article-function nil)
1372 (defvar gnus-summary-highlight-line-function nil
1373 "Function called after highlighting a summary line.")
1375 (defvar gnus-summary-line-format-alist
1376 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1377 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1378 (?s gnus-tmp-subject-or-nil ?s)
1379 (?n gnus-tmp-name ?s)
1380 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1382 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1383 gnus-tmp-from) ?s)
1384 (?F gnus-tmp-from ?s)
1385 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1386 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1387 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1388 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1389 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1390 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1391 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1392 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1393 (?L gnus-tmp-lines ?s)
1394 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1395 0) ?d)
1396 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1397 "") ?s)
1398 (?g (or (gnus-group-short-name
1399 (nnir-article-group (mail-header-number gnus-tmp-header)))
1400 "") ?s)
1401 (?O gnus-tmp-downloaded ?c)
1402 (?I gnus-tmp-indentation ?s)
1403 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1404 (?R gnus-tmp-replied ?c)
1405 (?\[ gnus-tmp-opening-bracket ?c)
1406 (?\] gnus-tmp-closing-bracket ?c)
1407 (?\> (make-string gnus-tmp-level ? ) ?s)
1408 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1409 (?i gnus-tmp-score ?d)
1410 (?z gnus-tmp-score-char ?c)
1411 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1412 (?U gnus-tmp-unread ?c)
1413 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1415 (?t (gnus-summary-number-of-articles-in-thread
1416 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1418 (?e (gnus-summary-number-of-articles-in-thread
1419 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1421 (?u gnus-tmp-user-defined ?s)
1422 (?P (gnus-pick-line-number) ?d)
1423 (?B gnus-tmp-thread-tree-header-string ?s)
1424 (user-date (gnus-user-date
1425 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1426 "An alist of format specifications that can appear in summary lines.
1427 These are paired with what variables they correspond with, along with
1428 the type of the variable (string, integer, character, etc).")
1430 (defvar gnus-summary-dummy-line-format-alist
1431 `((?S gnus-tmp-subject ?s)
1432 (?N gnus-tmp-number ?d)
1433 (?u gnus-tmp-user-defined ?s)))
1435 (defvar gnus-summary-mode-line-format-alist
1436 `((?G gnus-tmp-group-name ?s)
1437 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1438 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1439 (?A gnus-tmp-article-number ?d)
1440 (?Z gnus-tmp-unread-and-unselected ?s)
1441 (?V gnus-version ?s)
1442 (?U gnus-tmp-unread-and-unticked ?d)
1443 (?S gnus-tmp-subject ?s)
1444 (?e gnus-tmp-unselected ?d)
1445 (?u gnus-tmp-user-defined ?s)
1446 (?d (length gnus-newsgroup-dormant) ?d)
1447 (?t (length gnus-newsgroup-marked) ?d)
1448 (?h (length gnus-newsgroup-spam-marked) ?d)
1449 (?r (length gnus-newsgroup-reads) ?d)
1450 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1451 (?E gnus-newsgroup-expunged-tally ?d)
1452 (?s (gnus-current-score-file-nondirectory) ?s)))
1454 ;; This is here rather than in gnus-art for compilation reasons.
1455 (defvar gnus-article-mode-line-format-alist
1456 (nconc '((?w (gnus-article-wash-status) ?s)
1457 (?m (gnus-article-mime-part-status) ?s))
1458 gnus-summary-mode-line-format-alist))
1460 (defvar gnus-last-search-regexp nil
1461 "Default regexp for article search command.")
1463 (defvar gnus-last-shell-command nil
1464 "Default shell command on article.")
1466 (defvar gnus-newsgroup-agentized nil
1467 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1468 (defvar gnus-newsgroup-begin nil)
1469 (defvar gnus-newsgroup-end nil)
1470 (defvar gnus-newsgroup-last-rmail nil)
1471 (defvar gnus-newsgroup-last-mail nil)
1472 (defvar gnus-newsgroup-last-folder nil)
1473 (defvar gnus-newsgroup-last-file nil)
1474 (defvar gnus-newsgroup-last-directory nil)
1475 (defvar gnus-newsgroup-auto-expire nil)
1476 (defvar gnus-newsgroup-active nil)
1477 (defvar gnus-newsgroup-highest nil)
1479 (defvar gnus-newsgroup-data nil)
1480 (defvar gnus-newsgroup-data-reverse nil)
1481 (defvar gnus-newsgroup-limit nil)
1482 (defvar gnus-newsgroup-limits nil)
1483 (defvar gnus-summary-use-undownloaded-faces nil)
1485 (defvar gnus-newsgroup-unreads nil
1486 "Sorted list of unread articles in the current newsgroup.")
1488 (defvar gnus-newsgroup-unselected nil
1489 "Sorted list of unselected unread articles in the current newsgroup.")
1491 (defvar gnus-newsgroup-reads nil
1492 "Alist of read articles and article marks in the current newsgroup.")
1494 (defvar gnus-newsgroup-expunged-tally nil)
1496 (defvar gnus-newsgroup-marked nil
1497 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1499 (defvar gnus-newsgroup-spam-marked nil
1500 "List of ranges of articles that have been marked as spam.")
1502 (defvar gnus-newsgroup-killed nil
1503 "List of ranges of articles that have been through the scoring process.")
1505 (defvar gnus-newsgroup-cached nil
1506 "Sorted list of articles that come from the article cache.")
1508 (defvar gnus-newsgroup-saved nil
1509 "List of articles that have been saved.")
1511 (defvar gnus-newsgroup-kill-headers nil)
1513 (defvar gnus-newsgroup-replied nil
1514 "List of articles that have been replied to in the current newsgroup.")
1516 (defvar gnus-newsgroup-forwarded nil
1517 "List of articles that have been forwarded in the current newsgroup.")
1519 (defvar gnus-newsgroup-expirable nil
1520 "Sorted list of articles in the current newsgroup that can be expired.")
1522 (defvar gnus-newsgroup-processable nil
1523 "List of articles in the current newsgroup that can be processed.")
1525 (defvar gnus-newsgroup-downloadable nil
1526 "Sorted list of articles in the current newsgroup that can be processed.")
1528 (defvar gnus-newsgroup-unfetched nil
1529 "Sorted list of articles in the current newsgroup whose headers have
1530 not been fetched into the agent.
1532 This list will always be a subset of gnus-newsgroup-undownloaded.")
1534 (defvar gnus-newsgroup-undownloaded nil
1535 "List of articles in the current newsgroup that haven't been downloaded.")
1537 (defvar gnus-newsgroup-unsendable nil
1538 "List of articles in the current newsgroup that won't be sent.")
1540 (defvar gnus-newsgroup-bookmarks nil
1541 "List of articles in the current newsgroup that have bookmarks.")
1543 (defvar gnus-newsgroup-dormant nil
1544 "Sorted list of dormant articles in the current newsgroup.")
1546 (defvar gnus-newsgroup-unseen nil
1547 "List of unseen articles in the current newsgroup.")
1549 (defvar gnus-newsgroup-seen nil
1550 "Range of seen articles in the current newsgroup.")
1552 (defvar gnus-newsgroup-unexist nil
1553 "Range of unexisting articles in the current newsgroup.")
1555 (defvar gnus-newsgroup-articles nil
1556 "List of articles in the current newsgroup.")
1558 (defvar gnus-newsgroup-scored nil
1559 "List of scored articles in the current newsgroup.")
1561 (defvar gnus-newsgroup-headers nil
1562 "List of article headers in the current newsgroup.")
1564 (defvar gnus-newsgroup-threads nil)
1566 (defvar gnus-newsgroup-prepared nil
1567 "Whether the current group has been prepared properly.")
1569 (defvar gnus-newsgroup-ancient nil
1570 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1572 (defvar gnus-newsgroup-sparse nil)
1574 (defvar gnus-current-article nil)
1575 (defvar gnus-article-current nil)
1576 (defvar gnus-current-headers nil)
1577 (defvar gnus-have-all-headers nil)
1578 (defvar gnus-last-article nil)
1579 (defvar gnus-newsgroup-history nil)
1580 (defvar gnus-newsgroup-charset nil)
1581 (defvar gnus-newsgroup-ephemeral-charset nil)
1582 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1584 (defvar gnus-article-before-search nil)
1586 (defvar gnus-summary-local-variables
1587 '(gnus-newsgroup-name
1589 ;; Marks lists
1590 gnus-newsgroup-unreads
1591 gnus-newsgroup-unselected
1592 gnus-newsgroup-marked
1593 gnus-newsgroup-spam-marked
1594 gnus-newsgroup-reads
1595 gnus-newsgroup-saved
1596 gnus-newsgroup-replied
1597 gnus-newsgroup-forwarded
1598 gnus-newsgroup-expirable
1599 gnus-newsgroup-killed
1600 gnus-newsgroup-unseen
1601 gnus-newsgroup-seen
1602 gnus-newsgroup-unexist
1603 gnus-newsgroup-cached
1604 gnus-newsgroup-downloadable
1605 gnus-newsgroup-undownloaded
1606 gnus-newsgroup-unsendable
1608 gnus-newsgroup-begin gnus-newsgroup-end
1609 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1610 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1611 gnus-newsgroup-last-directory
1612 gnus-newsgroup-auto-expire
1613 gnus-newsgroup-processable
1614 gnus-newsgroup-unfetched
1615 gnus-newsgroup-articles
1616 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1617 gnus-newsgroup-headers gnus-newsgroup-threads
1618 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1619 gnus-current-article gnus-current-headers gnus-have-all-headers
1620 gnus-last-article gnus-article-internal-prepare-hook
1621 (gnus-summary-article-delete-hook . global)
1622 (gnus-summary-article-move-hook . global)
1623 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1624 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1625 gnus-thread-expunge-below
1626 gnus-score-alist gnus-current-score-file
1627 (gnus-summary-expunge-below . global)
1628 (gnus-summary-mark-below . global)
1629 (gnus-orphan-score . global)
1630 gnus-newsgroup-active gnus-scores-exclude-files
1631 gnus-newsgroup-highest
1632 gnus-newsgroup-history gnus-newsgroup-ancient
1633 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1634 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1635 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1636 (gnus-newsgroup-expunged-tally . 0)
1637 gnus-cache-removable-articles
1638 gnus-newsgroup-data gnus-newsgroup-data-reverse
1639 gnus-newsgroup-limit gnus-newsgroup-limits
1640 gnus-newsgroup-charset gnus-newsgroup-display
1641 gnus-summary-use-undownloaded-faces)
1642 "Variables that are buffer-local to the summary buffers.")
1644 (defvar gnus-newsgroup-variables nil
1645 "A list of variables that have separate values in different newsgroups.
1646 A list of newsgroup (summary buffer) local variables, or cons of
1647 variables and their default expressions to be evalled (when the default
1648 values are not nil), that should be made global while the summary buffer
1649 is active.
1651 Note: The default expressions will be evaluated (using function `eval')
1652 before assignment to the local variable rather than just assigned to it.
1653 If the default expression is the symbol `global', that symbol will not
1654 be evaluated but the global value of the local variable will be used
1655 instead.
1657 These variables can be used to set variables in the group parameters
1658 while still allowing them to affect operations done in other buffers.
1659 For example:
1661 \(setq gnus-newsgroup-variables
1662 '(message-use-followup-to
1663 (gnus-visible-headers .
1664 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1667 (eval-when-compile
1668 ;; Bind features so that require will believe that gnus-sum has
1669 ;; already been loaded (avoids infinite recursion)
1670 (let ((features (cons 'gnus-sum features)))
1671 (require 'gnus-art)))
1673 ;; MIME stuff.
1675 (defvar gnus-decode-encoded-word-methods
1676 '(mail-decode-encoded-word-string)
1677 "List of methods used to decode encoded words.
1679 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1680 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1681 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1682 whose names match REGEXP.
1684 For example:
1685 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1686 mail-decode-encoded-word-string
1687 (\"chinese\" . rfc1843-decode-string))")
1689 (defvar gnus-decode-encoded-word-methods-cache nil)
1691 (defun gnus-multi-decode-encoded-word-string (string)
1692 "Apply the functions from `gnus-encoded-word-methods' that match."
1693 (unless (and gnus-decode-encoded-word-methods-cache
1694 (eq gnus-newsgroup-name
1695 (car gnus-decode-encoded-word-methods-cache)))
1696 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1697 (dolist (method gnus-decode-encoded-word-methods)
1698 (if (symbolp method)
1699 (nconc gnus-decode-encoded-word-methods-cache (list method))
1700 (if (and gnus-newsgroup-name
1701 (string-match (car method) gnus-newsgroup-name))
1702 (nconc gnus-decode-encoded-word-methods-cache
1703 (list (cdr method)))))))
1704 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1705 (setq string (funcall method string))))
1707 ;; Subject simplification.
1709 (defun gnus-simplify-whitespace (str)
1710 "Remove excessive whitespace from STR."
1711 ;; Multiple spaces.
1712 (while (string-match "[ \t][ \t]+" str)
1713 (setq str (concat (substring str 0 (match-beginning 0))
1715 (substring str (match-end 0)))))
1716 ;; Leading spaces.
1717 (when (string-match "^[ \t]+" str)
1718 (setq str (substring str (match-end 0))))
1719 ;; Trailing spaces.
1720 (when (string-match "[ \t]+$" str)
1721 (setq str (substring str 0 (match-beginning 0))))
1722 str)
1724 (defun gnus-simplify-all-whitespace (str)
1725 "Remove all whitespace from STR."
1726 (while (string-match "[ \t\n]+" str)
1727 (setq str (replace-match "" nil nil str)))
1728 str)
1730 (defsubst gnus-simplify-subject-re (subject)
1731 "Remove \"Re:\" from subject lines."
1732 (if (string-match message-subject-re-regexp subject)
1733 (substring subject (match-end 0))
1734 subject))
1736 (defun gnus-simplify-subject (subject &optional re-only)
1737 "Remove `Re:' and words in parentheses.
1738 If RE-ONLY is non-nil, strip leading `Re:'s only."
1739 (let ((case-fold-search t)) ;Ignore case.
1740 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1741 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1742 (setq subject (substring subject (match-end 0))))
1743 ;; Remove uninteresting prefixes.
1744 (when (and (not re-only)
1745 gnus-simplify-ignored-prefixes
1746 (string-match gnus-simplify-ignored-prefixes subject))
1747 (setq subject (substring subject (match-end 0))))
1748 ;; Remove words in parentheses from end.
1749 (unless re-only
1750 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1751 (setq subject (substring subject 0 (match-beginning 0)))))
1752 ;; Return subject string.
1753 subject))
1755 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1756 ;; all whitespace.
1757 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1758 (goto-char (point-min))
1759 (while (re-search-forward regexp nil t)
1760 (replace-match (or newtext ""))))
1762 (defun gnus-simplify-buffer-fuzzy (regexp)
1763 "Simplify string in the buffer fuzzily.
1764 The string in the accessible portion of the current buffer is simplified.
1765 It is assumed to be a single-line subject.
1766 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1767 matter is removed. Additional things can be deleted by setting
1768 `gnus-simplify-subject-fuzzy-regexp'."
1769 (let ((case-fold-search t)
1770 (modified-tick))
1771 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1773 (while (not (eq modified-tick (buffer-modified-tick)))
1774 (setq modified-tick (buffer-modified-tick))
1775 (cond
1776 ((listp regexp)
1777 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1778 (regexp
1779 (gnus-simplify-buffer-fuzzy-step regexp)))
1780 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1781 (gnus-simplify-buffer-fuzzy-step
1782 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1783 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1785 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1786 (gnus-simplify-buffer-fuzzy-step " +" " ")
1787 (gnus-simplify-buffer-fuzzy-step " $")
1788 (gnus-simplify-buffer-fuzzy-step "^ +")))
1790 (defun gnus-simplify-subject-fuzzy (subject)
1791 "Simplify a subject string fuzzily.
1792 See `gnus-simplify-buffer-fuzzy' for details."
1793 (save-excursion
1794 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1795 (gnus-set-work-buffer)
1796 (let ((case-fold-search t))
1797 ;; Remove uninteresting prefixes.
1798 (when (and gnus-simplify-ignored-prefixes
1799 (string-match gnus-simplify-ignored-prefixes subject))
1800 (setq subject (substring subject (match-end 0))))
1801 (insert subject)
1802 (inline (gnus-simplify-buffer-fuzzy regexp))
1803 (buffer-string)))))
1805 (defsubst gnus-simplify-subject-fully (subject)
1806 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1807 (cond
1808 (gnus-simplify-subject-functions
1809 (gnus-map-function gnus-simplify-subject-functions subject))
1810 ((null gnus-summary-gather-subject-limit)
1811 (gnus-simplify-subject-re subject))
1812 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1813 (gnus-simplify-subject-fuzzy subject))
1814 ((numberp gnus-summary-gather-subject-limit)
1815 (truncate-string-to-width (gnus-simplify-subject-re subject)
1816 gnus-summary-gather-subject-limit))
1818 subject)))
1820 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1821 "Check whether two subjects are equal.
1822 If optional argument SIMPLE-FIRST is t, first argument is already
1823 simplified."
1824 (cond
1825 ((null simple-first)
1826 (equal (gnus-simplify-subject-fully s1)
1827 (gnus-simplify-subject-fully s2)))
1829 (equal s1
1830 (gnus-simplify-subject-fully s2)))))
1832 (defun gnus-summary-bubble-group ()
1833 "Increase the score of the current group.
1834 This is a handy function to add to `gnus-summary-exit-hook' to
1835 increase the score of each group you read."
1836 (gnus-group-add-score gnus-newsgroup-name))
1840 ;;; Gnus summary mode
1843 (put 'gnus-summary-mode 'mode-class 'special)
1845 (defvar gnus-article-commands-menu)
1847 ;; Non-orthogonal keys
1849 (gnus-define-keys gnus-summary-mode-map
1850 " " gnus-summary-next-page
1851 [?\S-\ ] gnus-summary-prev-page
1852 "\177" gnus-summary-prev-page
1853 [delete] gnus-summary-prev-page
1854 [backspace] 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" gnus-summary-toggle-truncation
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-a" gnus-summary-sort-by-author
1911 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1912 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1913 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1914 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1915 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1916 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1917 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1918 "=" gnus-summary-expand-window
1919 "\C-x\C-s" gnus-summary-reselect-current-group
1920 "\M-g" gnus-summary-rescan-group
1921 "\C-c\C-r" gnus-summary-caesar-message
1922 "f" gnus-summary-followup
1923 "F" gnus-summary-followup-with-original
1924 "C" gnus-summary-cancel-article
1925 "r" gnus-summary-reply
1926 "R" gnus-summary-reply-with-original
1927 "\C-c\C-f" gnus-summary-mail-forward
1928 "o" gnus-summary-save-article
1929 "\C-o" gnus-summary-save-article-mail
1930 "|" gnus-summary-pipe-output
1931 "\M-k" gnus-summary-edit-local-kill
1932 "\M-K" gnus-summary-edit-global-kill
1933 ;; "V" gnus-version
1934 "\C-c\C-d" gnus-summary-describe-group
1935 "q" gnus-summary-exit
1936 "Q" gnus-summary-exit-no-update
1937 "\C-c\C-i" gnus-info-find-node
1938 gnus-mouse-2 gnus-mouse-pick-article
1939 [follow-link] mouse-face
1940 "m" gnus-summary-mail-other-window
1941 "a" gnus-summary-post-news
1942 "x" gnus-summary-limit-to-unread
1943 "s" gnus-summary-isearch-article
1944 "\t" gnus-summary-widget-forward
1945 [backtab] gnus-summary-widget-backward
1946 "t" gnus-summary-toggle-header
1947 "g" gnus-summary-show-article
1948 "l" gnus-summary-goto-last-article
1949 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1950 "\C-d" gnus-summary-enter-digest-group
1951 "\M-\C-d" gnus-summary-read-document
1952 "\M-\C-e" gnus-summary-edit-parameters
1953 "\M-\C-a" gnus-summary-customize-parameters
1954 "\C-c\C-b" gnus-bug
1955 "*" gnus-cache-enter-article
1956 "\M-*" gnus-cache-remove-article
1957 "\M-&" gnus-summary-universal-argument
1958 "\C-l" gnus-recenter
1959 "I" gnus-summary-increase-score
1960 "L" gnus-summary-lower-score
1961 "\M-i" gnus-symbolic-argument
1962 "h" gnus-summary-select-article-buffer
1964 "b" gnus-article-view-part
1965 "\M-t" gnus-summary-toggle-display-buttonized
1967 "V" gnus-summary-score-map
1968 "X" gnus-uu-extract-map
1969 "S" gnus-summary-send-map)
1971 ;; Sort of orthogonal keymap
1972 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1973 "t" gnus-summary-tick-article-forward
1974 "!" gnus-summary-tick-article-forward
1975 "d" gnus-summary-mark-as-read-forward
1976 "r" gnus-summary-mark-as-read-forward
1977 "c" gnus-summary-clear-mark-forward
1978 " " gnus-summary-clear-mark-forward
1979 "e" gnus-summary-mark-as-expirable
1980 "x" gnus-summary-mark-as-expirable
1981 "?" gnus-summary-mark-as-dormant
1982 "b" gnus-summary-set-bookmark
1983 "B" gnus-summary-remove-bookmark
1984 "#" gnus-summary-mark-as-processable
1985 "\M-#" gnus-summary-unmark-as-processable
1986 "S" gnus-summary-limit-include-expunged
1987 "C" gnus-summary-catchup
1988 "H" gnus-summary-catchup-to-here
1989 "h" gnus-summary-catchup-from-here
1990 "\C-c" gnus-summary-catchup-all
1991 "k" gnus-summary-kill-same-subject-and-select
1992 "K" gnus-summary-kill-same-subject
1993 "P" gnus-uu-mark-map)
1995 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1996 "c" gnus-summary-clear-above
1997 "u" gnus-summary-tick-above
1998 "m" gnus-summary-mark-above
1999 "k" gnus-summary-kill-below)
2001 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
2002 "/" gnus-summary-limit-to-subject
2003 "n" gnus-summary-limit-to-articles
2004 "b" gnus-summary-limit-to-bodies
2005 "h" gnus-summary-limit-to-headers
2006 "w" gnus-summary-pop-limit
2007 "s" gnus-summary-limit-to-subject
2008 "a" gnus-summary-limit-to-author
2009 "u" gnus-summary-limit-to-unread
2010 "m" gnus-summary-limit-to-marks
2011 "M" gnus-summary-limit-exclude-marks
2012 "v" gnus-summary-limit-to-score
2013 "*" gnus-summary-limit-include-cached
2014 "D" gnus-summary-limit-include-dormant
2015 "T" gnus-summary-limit-include-thread
2016 "d" gnus-summary-limit-exclude-dormant
2017 "t" gnus-summary-limit-to-age
2018 "." gnus-summary-limit-to-unseen
2019 "x" gnus-summary-limit-to-extra
2020 "p" gnus-summary-limit-to-display-predicate
2021 "E" gnus-summary-limit-include-expunged
2022 "c" gnus-summary-limit-exclude-childless-dormant
2023 "C" gnus-summary-limit-mark-excluded-as-read
2024 "o" gnus-summary-insert-old-articles
2025 "N" gnus-summary-insert-new-articles
2026 "S" gnus-summary-limit-to-singletons
2027 "r" gnus-summary-limit-to-replied
2028 "R" gnus-summary-limit-to-recipient
2029 "A" gnus-summary-limit-to-address)
2031 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2032 "n" gnus-summary-next-unread-article
2033 "p" gnus-summary-prev-unread-article
2034 "N" gnus-summary-next-article
2035 "P" gnus-summary-prev-article
2036 "\C-n" gnus-summary-next-same-subject
2037 "\C-p" gnus-summary-prev-same-subject
2038 "\M-n" gnus-summary-next-unread-subject
2039 "\M-p" gnus-summary-prev-unread-subject
2040 "f" gnus-summary-first-unread-article
2041 "b" gnus-summary-best-unread-article
2042 "j" gnus-summary-goto-article
2043 "g" gnus-summary-goto-subject
2044 "l" gnus-summary-goto-last-article
2045 "o" gnus-summary-pop-article)
2047 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2048 "k" gnus-summary-kill-thread
2049 "E" gnus-summary-expire-thread
2050 "l" gnus-summary-lower-thread
2051 "i" gnus-summary-raise-thread
2052 "T" gnus-summary-toggle-threads
2053 "t" gnus-summary-rethread-current
2054 "^" gnus-summary-reparent-thread
2055 "\M-^" gnus-summary-reparent-children
2056 "s" gnus-summary-show-thread
2057 "S" gnus-summary-show-all-threads
2058 "h" gnus-summary-hide-thread
2059 "H" gnus-summary-hide-all-threads
2060 "n" gnus-summary-next-thread
2061 "p" gnus-summary-prev-thread
2062 "u" gnus-summary-up-thread
2063 "o" gnus-summary-top-thread
2064 "d" gnus-summary-down-thread
2065 "#" gnus-uu-mark-thread
2066 "\M-#" gnus-uu-unmark-thread)
2068 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2069 "g" gnus-summary-prepare
2070 "c" gnus-summary-insert-cached-articles
2071 "d" gnus-summary-insert-dormant-articles
2072 "t" gnus-summary-insert-ticked-articles)
2074 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2075 "c" gnus-summary-catchup-and-exit
2076 "C" gnus-summary-catchup-all-and-exit
2077 "E" gnus-summary-exit-no-update
2078 "Q" gnus-summary-exit
2079 "Z" gnus-summary-exit
2080 "n" gnus-summary-catchup-and-goto-next-group
2081 "p" gnus-summary-catchup-and-goto-prev-group
2082 "R" gnus-summary-reselect-current-group
2083 "G" gnus-summary-rescan-group
2084 "N" gnus-summary-next-group
2085 "s" gnus-summary-save-newsrc
2086 "P" gnus-summary-prev-group)
2088 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2089 " " gnus-summary-next-page
2090 "n" gnus-summary-next-page
2091 [?\S-\ ] gnus-summary-prev-page
2092 "\177" gnus-summary-prev-page
2093 [delete] gnus-summary-prev-page
2094 "p" gnus-summary-prev-page
2095 "\r" gnus-summary-scroll-up
2096 "\M-\r" gnus-summary-scroll-down
2097 "<" gnus-summary-beginning-of-article
2098 ">" gnus-summary-end-of-article
2099 "b" gnus-summary-beginning-of-article
2100 "e" gnus-summary-end-of-article
2101 "^" gnus-summary-refer-parent-article
2102 "r" gnus-summary-refer-parent-article
2103 "C" gnus-summary-show-complete-article
2104 "D" gnus-summary-enter-digest-group
2105 "R" gnus-summary-refer-references
2106 "T" gnus-summary-refer-thread
2107 "W" gnus-warp-to-article
2108 "g" gnus-summary-show-article
2109 "s" gnus-summary-isearch-article
2110 "\t" gnus-summary-widget-forward
2111 [backtab] gnus-summary-widget-backward
2112 "P" gnus-summary-print-article
2113 "S" gnus-sticky-article
2114 "M" gnus-mailing-list-insinuate
2115 "t" gnus-article-babel)
2117 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2118 "b" gnus-article-add-buttons
2119 "B" gnus-article-add-buttons-to-head
2120 "o" gnus-article-treat-overstrike
2121 "e" gnus-article-emphasize
2122 "w" gnus-article-fill-cited-article
2123 "Q" gnus-article-fill-long-lines
2124 "L" gnus-article-toggle-truncate-lines
2125 "C" gnus-article-capitalize-sentences
2126 "c" gnus-article-remove-cr
2127 "q" gnus-article-de-quoted-unreadable
2128 "6" gnus-article-de-base64-unreadable
2129 "Z" gnus-article-decode-HZ
2130 "A" gnus-article-treat-ansi-sequences
2131 "h" gnus-article-wash-html
2132 "u" gnus-article-unsplit-urls
2133 "s" gnus-summary-force-verify-and-decrypt
2134 "f" gnus-article-display-x-face
2135 "l" gnus-summary-stop-page-breaking
2136 "r" gnus-summary-caesar-message
2137 "m" gnus-summary-morse-message
2138 "t" gnus-summary-toggle-header
2139 "g" gnus-treat-smiley
2140 "v" gnus-summary-verbose-headers
2141 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2142 "p" gnus-article-verify-x-pgp-sig
2143 "d" gnus-article-treat-dumbquotes
2144 "U" gnus-article-treat-non-ascii
2145 "i" gnus-summary-idna-message)
2147 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2148 ;; mnemonic: deuglif*Y*
2149 "u" gnus-article-outlook-unwrap-lines
2150 "a" gnus-article-outlook-repair-attribution
2151 "c" gnus-article-outlook-rearrange-citation
2152 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2154 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2155 "a" gnus-article-hide
2156 "h" gnus-article-hide-headers
2157 "b" gnus-article-hide-boring-headers
2158 "s" gnus-article-hide-signature
2159 "c" gnus-article-hide-citation
2160 "C" gnus-article-hide-citation-in-followups
2161 "l" gnus-article-hide-list-identifiers
2162 "B" gnus-article-strip-banner
2163 "P" gnus-article-hide-pem
2164 "\C-c" gnus-article-hide-citation-maybe)
2166 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2167 "a" gnus-article-highlight
2168 "h" gnus-article-highlight-headers
2169 "c" gnus-article-highlight-citation
2170 "s" gnus-article-highlight-signature)
2172 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2173 "f" gnus-article-treat-fold-headers
2174 "u" gnus-article-treat-unfold-headers
2175 "n" gnus-article-treat-fold-newsgroups)
2177 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2178 "x" gnus-article-display-x-face
2179 "d" gnus-article-display-face
2180 "s" gnus-treat-smiley
2181 "D" gnus-article-remove-images
2182 "W" gnus-article-show-images
2183 "f" gnus-treat-from-picon
2184 "m" gnus-treat-mail-picon
2185 "n" gnus-treat-newsgroups-picon
2186 "g" gnus-treat-from-gravatar
2187 "h" gnus-treat-mail-gravatar)
2189 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2190 "w" gnus-article-decode-mime-words
2191 "c" gnus-article-decode-charset
2192 "v" gnus-mime-view-all-parts
2193 "b" gnus-article-view-part)
2195 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2196 "z" gnus-article-date-ut
2197 "u" gnus-article-date-ut
2198 "l" gnus-article-date-local
2199 "p" gnus-article-date-english
2200 "e" gnus-article-date-lapsed
2201 "o" gnus-article-date-original
2202 "i" gnus-article-date-iso8601
2203 "s" gnus-article-date-user)
2205 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2206 "t" gnus-article-remove-trailing-blank-lines
2207 "l" gnus-article-strip-leading-blank-lines
2208 "m" gnus-article-strip-multiple-blank-lines
2209 "a" gnus-article-strip-blank-lines
2210 "A" gnus-article-strip-all-blank-lines
2211 "s" gnus-article-strip-leading-space
2212 "e" gnus-article-strip-trailing-space
2213 "w" gnus-article-remove-leading-whitespace)
2215 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2216 "v" gnus-version
2217 "d" gnus-summary-describe-group
2218 "h" gnus-summary-describe-briefly
2219 "i" gnus-info-find-node)
2221 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2222 "e" gnus-summary-expire-articles
2223 "\M-\C-e" gnus-summary-expire-articles-now
2224 "\177" gnus-summary-delete-article
2225 [delete] gnus-summary-delete-article
2226 [backspace] gnus-summary-delete-article
2227 "m" gnus-summary-move-article
2228 "r" gnus-summary-respool-article
2229 "w" gnus-summary-edit-article
2230 "c" gnus-summary-copy-article
2231 "B" gnus-summary-crosspost-article
2232 "q" gnus-summary-respool-query
2233 "t" gnus-summary-respool-trace
2234 "i" gnus-summary-import-article
2235 "I" gnus-summary-create-article
2236 "p" gnus-summary-article-posted-p)
2238 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2239 "o" gnus-summary-save-article
2240 "m" gnus-summary-save-article-mail
2241 "F" gnus-summary-write-article-file
2242 "r" gnus-summary-save-article-rmail
2243 "f" gnus-summary-save-article-file
2244 "b" gnus-summary-save-article-body-file
2245 "B" gnus-summary-write-article-body-file
2246 "h" gnus-summary-save-article-folder
2247 "v" gnus-summary-save-article-vm
2248 "p" gnus-summary-pipe-output
2249 "P" gnus-summary-muttprint)
2251 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2252 "b" gnus-summary-display-buttonized
2253 "m" gnus-summary-repair-multipart
2254 "v" gnus-article-view-part
2255 "o" gnus-article-save-part
2256 "O" gnus-article-save-part-and-strip
2257 "r" gnus-article-replace-part
2258 "d" gnus-article-delete-part
2259 "t" gnus-article-view-part-as-type
2260 "j" gnus-article-jump-to-part
2261 "c" gnus-article-copy-part
2262 "C" gnus-article-view-part-as-charset
2263 "e" gnus-article-view-part-externally
2264 "H" gnus-article-browse-html-article
2265 "E" gnus-article-encrypt-body
2266 "i" gnus-article-inline-part
2267 "|" gnus-article-pipe-part)
2269 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2270 "p" gnus-summary-mark-as-processable
2271 "u" gnus-summary-unmark-as-processable
2272 "U" gnus-summary-unmark-all-processable
2273 "v" gnus-uu-mark-over
2274 "s" gnus-uu-mark-series
2275 "r" gnus-uu-mark-region
2276 "g" gnus-uu-unmark-region
2277 "R" gnus-uu-mark-by-regexp
2278 "G" gnus-uu-unmark-by-regexp
2279 "t" gnus-uu-mark-thread
2280 "T" gnus-uu-unmark-thread
2281 "a" gnus-uu-mark-all
2282 "b" gnus-uu-mark-buffer
2283 "S" gnus-uu-mark-sparse
2284 "k" gnus-summary-kill-process-mark
2285 "y" gnus-summary-yank-process-mark
2286 "w" gnus-summary-save-process-mark
2287 "i" gnus-uu-invert-processable)
2289 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2290 ;;"x" gnus-uu-extract-any
2291 "m" gnus-summary-save-parts
2292 "u" gnus-uu-decode-uu
2293 "U" gnus-uu-decode-uu-and-save
2294 "s" gnus-uu-decode-unshar
2295 "S" gnus-uu-decode-unshar-and-save
2296 "o" gnus-uu-decode-save
2297 "O" gnus-uu-decode-save
2298 "b" gnus-uu-decode-binhex
2299 "B" gnus-uu-decode-binhex
2300 "Y" gnus-uu-decode-yenc
2301 "p" gnus-uu-decode-postscript
2302 "P" gnus-uu-decode-postscript-and-save)
2304 (gnus-define-keys
2305 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2306 "u" gnus-uu-decode-uu-view
2307 "U" gnus-uu-decode-uu-and-save-view
2308 "s" gnus-uu-decode-unshar-view
2309 "S" gnus-uu-decode-unshar-and-save-view
2310 "o" gnus-uu-decode-save-view
2311 "O" gnus-uu-decode-save-view
2312 "b" gnus-uu-decode-binhex-view
2313 "B" gnus-uu-decode-binhex-view
2314 "p" gnus-uu-decode-postscript-view
2315 "P" gnus-uu-decode-postscript-and-save-view)
2317 (defvar gnus-article-post-menu nil)
2319 (defconst gnus-summary-menu-maxlen 20)
2321 (defun gnus-summary-menu-split (menu)
2322 ;; If we have lots of elements, divide them into groups of 20
2323 ;; and make a pane (or submenu) for each one.
2324 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2325 (let ((menu menu) sublists next
2326 (i 1))
2327 (while menu
2328 ;; Pull off the next gnus-summary-menu-maxlen elements
2329 ;; and make them the next element of sublist.
2330 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2331 (if next
2332 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2333 nil))
2334 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2335 (aref (car (last menu)) 0)) menu)
2336 sublists))
2337 (setq i (1+ i))
2338 (setq menu next))
2339 (nreverse sublists))
2340 ;; Few elements--put them all in one pane.
2341 menu))
2343 (defun gnus-summary-make-menu-bar ()
2344 (gnus-turn-off-edit-menu 'summary)
2346 (unless (boundp 'gnus-summary-misc-menu)
2348 (easy-menu-define
2349 gnus-summary-kill-menu gnus-summary-mode-map ""
2350 (cons
2351 "Score"
2352 (nconc
2353 (list
2354 ["Customize" gnus-score-customize t])
2355 (gnus-make-score-map 'increase)
2356 (gnus-make-score-map 'lower)
2357 '(("Mark"
2358 ["Kill below" gnus-summary-kill-below t]
2359 ["Mark above" gnus-summary-mark-above t]
2360 ["Tick above" gnus-summary-tick-above t]
2361 ["Clear above" gnus-summary-clear-above t])
2362 ["Current article score" gnus-summary-current-score t]
2363 ["Current thread score" (gnus-summary-current-score 'total) t]
2364 ["Set score" gnus-summary-set-score t]
2365 ["Switch current score file..." gnus-score-change-score-file t]
2366 ["Set mark below..." gnus-score-set-mark-below t]
2367 ["Set expunge below..." gnus-score-set-expunge-below t]
2368 ["Edit current score file" gnus-score-edit-current-scores t]
2369 ["Edit score file..." gnus-score-edit-file t]
2370 ["Trace score" gnus-score-find-trace t]
2371 ["Find words" gnus-score-find-favourite-words t]
2372 ["Rescore buffer" gnus-summary-rescore t]
2373 ["Increase score..." gnus-summary-increase-score t]
2374 ["Lower score..." gnus-summary-lower-score t]))))
2376 ;; Define both the Article menu in the summary buffer and the
2377 ;; equivalent Commands menu in the article buffer here for
2378 ;; consistency.
2379 (let ((innards
2380 `(("Hide"
2381 ["All" gnus-article-hide t]
2382 ["Headers" gnus-article-hide-headers t]
2383 ["Signature" gnus-article-hide-signature t]
2384 ["Citation" gnus-article-hide-citation t]
2385 ["List identifiers" gnus-article-hide-list-identifiers t]
2386 ["Banner" gnus-article-strip-banner t]
2387 ["Boring headers" gnus-article-hide-boring-headers t])
2388 ("Highlight"
2389 ["All" gnus-article-highlight t]
2390 ["Headers" gnus-article-highlight-headers t]
2391 ["Signature" gnus-article-highlight-signature t]
2392 ["Citation" gnus-article-highlight-citation t])
2393 ("MIME"
2394 ["Words" gnus-article-decode-mime-words t]
2395 ["Charset" gnus-article-decode-charset t]
2396 ["QP" gnus-article-de-quoted-unreadable t]
2397 ["Base64" gnus-article-de-base64-unreadable t]
2398 ["View MIME buttons" gnus-summary-display-buttonized t]
2399 ["View all" gnus-mime-view-all-parts t]
2400 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2401 ["Encrypt body" gnus-article-encrypt-body
2402 :active (not (gnus-group-read-only-p))
2403 ,@(if (featurep 'xemacs) nil
2404 '(:help "Encrypt the message body on disk"))]
2405 ["Extract all parts..." gnus-summary-save-parts t]
2406 ("Multipart"
2407 ["Repair multipart" gnus-summary-repair-multipart t]
2408 ["Pipe part..." gnus-article-pipe-part t]
2409 ["Inline part" gnus-article-inline-part t]
2410 ["View part as type..." gnus-article-view-part-as-type t]
2411 ["Encrypt body" gnus-article-encrypt-body
2412 :active (not (gnus-group-read-only-p))
2413 ,@(if (featurep 'xemacs) nil
2414 '(:help "Encrypt the message body on disk"))]
2415 ["View part externally" gnus-article-view-part-externally t]
2416 ["View HTML parts in browser" gnus-article-browse-html-article t]
2417 ["View part with charset..." gnus-article-view-part-as-charset t]
2418 ["Copy part" gnus-article-copy-part t]
2419 ["Save part..." gnus-article-save-part t]
2420 ["View part" gnus-article-view-part t]))
2421 ("Date"
2422 ["Local" gnus-article-date-local t]
2423 ["ISO8601" gnus-article-date-iso8601 t]
2424 ["UT" gnus-article-date-ut t]
2425 ["Original" gnus-article-date-original t]
2426 ["Lapsed" gnus-article-date-lapsed t]
2427 ["User-defined" gnus-article-date-user t])
2428 ("Display"
2429 ["Remove images" gnus-article-remove-images t]
2430 ["Toggle smiley" gnus-treat-smiley t]
2431 ["Show X-Face" gnus-article-display-x-face t]
2432 ["Show picons in From" gnus-treat-from-picon t]
2433 ["Show picons in mail headers" gnus-treat-mail-picon t]
2434 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2435 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2436 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2437 ("View as different encoding"
2438 ,@(gnus-summary-menu-split
2439 (mapcar
2440 (lambda (cs)
2441 ;; Since easymenu under Emacs doesn't allow
2442 ;; lambda forms for menu commands, we should
2443 ;; provide intern'ed function symbols.
2444 (let ((command (intern (format "\
2445 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2446 (fset command
2447 `(lambda ()
2448 (interactive)
2449 (let ((gnus-summary-show-article-charset-alist
2450 '((1 . ,cs))))
2451 (gnus-summary-show-article 1))))
2452 `[,(symbol-name cs) ,command t]))
2453 (sort (if (fboundp 'coding-system-list)
2454 (coding-system-list)
2455 (mapcar 'car mm-mime-mule-charset-alist))
2456 '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 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "\"Caesar rotate\" article by 13"))]
2482 ["De-IDNA" gnus-summary-idna-message t]
2483 ["Morse decode" gnus-summary-morse-message t]
2484 ["Unix pipe..." gnus-summary-pipe-message t]
2485 ["Add buttons" gnus-article-add-buttons t]
2486 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2487 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2488 ["Verbose header" gnus-summary-verbose-headers t]
2489 ["Toggle header" gnus-summary-toggle-header t]
2490 ["Unfold headers" gnus-article-treat-unfold-headers t]
2491 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2492 ["Html" gnus-article-wash-html t]
2493 ["Unsplit URLs" gnus-article-unsplit-urls t]
2494 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2495 ["Decode HZ" gnus-article-decode-HZ t]
2496 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2497 ("(Outlook) Deuglify"
2498 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2499 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2500 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2501 ["Full (Outlook) deuglify"
2502 gnus-article-outlook-deuglify-article t])
2504 ("Output"
2505 ["Save in default format..." gnus-summary-save-article
2506 ,@(if (featurep 'xemacs) '(t)
2507 '(:help "Save article using default method"))]
2508 ["Save in file..." gnus-summary-save-article-file
2509 ,@(if (featurep 'xemacs) '(t)
2510 '(:help "Save article in file"))]
2511 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2512 ["Save in MH folder..." gnus-summary-save-article-folder t]
2513 ["Save in VM folder..." gnus-summary-save-article-vm t]
2514 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2515 ["Save body in file..." gnus-summary-save-article-body-file t]
2516 ["Pipe through a filter..." gnus-summary-pipe-output t]
2517 ["Print with Muttprint..." gnus-summary-muttprint t]
2518 ["Print" gnus-summary-print-article
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Generate and print a PostScript image"))])
2521 ("Copy, move,... (Backend)"
2522 ,@(if (featurep 'xemacs) nil
2523 '(:help "Copying, moving, expiring articles..."))
2524 ["Respool article..." gnus-summary-respool-article t]
2525 ["Move article..." gnus-summary-move-article
2526 (gnus-check-backend-function
2527 'request-move-article gnus-newsgroup-name)]
2528 ["Copy article..." gnus-summary-copy-article t]
2529 ["Crosspost article..." gnus-summary-crosspost-article
2530 (gnus-check-backend-function
2531 'request-replace-article gnus-newsgroup-name)]
2532 ["Import file..." gnus-summary-import-article
2533 (gnus-check-backend-function
2534 'request-accept-article gnus-newsgroup-name)]
2535 ["Create article..." gnus-summary-create-article
2536 (gnus-check-backend-function
2537 'request-accept-article gnus-newsgroup-name)]
2538 ["Check if posted" gnus-summary-article-posted-p t]
2539 ["Edit article" gnus-summary-edit-article
2540 (not (gnus-group-read-only-p))]
2541 ["Delete article" gnus-summary-delete-article
2542 (gnus-check-backend-function
2543 'request-expire-articles gnus-newsgroup-name)]
2544 ["Query respool" gnus-summary-respool-query t]
2545 ["Trace respool" gnus-summary-respool-trace t]
2546 ["Delete expirable articles" gnus-summary-expire-articles-now
2547 (gnus-check-backend-function
2548 'request-expire-articles gnus-newsgroup-name)])
2549 ("Extract"
2550 ["Uudecode" gnus-uu-decode-uu
2551 ,@(if (featurep 'xemacs) '(t)
2552 '(:help "Decode uuencoded article(s)"))]
2553 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2554 ["Unshar" gnus-uu-decode-unshar t]
2555 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2556 ["Save" gnus-uu-decode-save t]
2557 ["Binhex" gnus-uu-decode-binhex t]
2558 ["PostScript" gnus-uu-decode-postscript t]
2559 ["All MIME parts" gnus-summary-save-parts t])
2560 ("Cache"
2561 ["Enter article" gnus-cache-enter-article t]
2562 ["Remove article" gnus-cache-remove-article t])
2563 ["Translate" gnus-article-babel t]
2564 ["Select article buffer" gnus-summary-select-article-buffer t]
2565 ["Make article buffer sticky" gnus-sticky-article t]
2566 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2567 ["Isearch article..." gnus-summary-isearch-article t]
2568 ["Beginning of the article" gnus-summary-beginning-of-article t]
2569 ["End of the article" gnus-summary-end-of-article t]
2570 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2571 ["Fetch referenced articles" gnus-summary-refer-references t]
2572 ["Fetch current thread" gnus-summary-refer-thread t]
2573 ["Fetch article with id..." gnus-summary-refer-article t]
2574 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2575 ["Redisplay" gnus-summary-show-article t]
2576 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2577 (easy-menu-define
2578 gnus-summary-article-menu gnus-summary-mode-map ""
2579 (cons "Article" innards))
2581 (if (not (keymapp gnus-summary-article-menu))
2582 (easy-menu-define
2583 gnus-article-commands-menu gnus-article-mode-map ""
2584 (cons "Commands" innards))
2585 ;; in Emacs, don't share menu.
2586 (setq gnus-article-commands-menu
2587 (copy-keymap gnus-summary-article-menu))
2588 (define-key gnus-article-mode-map [menu-bar commands]
2589 (cons "Commands" gnus-article-commands-menu))))
2591 (easy-menu-define
2592 gnus-summary-thread-menu gnus-summary-mode-map ""
2593 '("Threads"
2594 ["Find all messages in thread" gnus-summary-refer-thread t]
2595 ["Toggle threading" gnus-summary-toggle-threads t]
2596 ["Hide threads" gnus-summary-hide-all-threads t]
2597 ["Show threads" gnus-summary-show-all-threads t]
2598 ["Hide thread" gnus-summary-hide-thread t]
2599 ["Show thread" gnus-summary-show-thread t]
2600 ["Go to next thread" gnus-summary-next-thread t]
2601 ["Go to previous thread" gnus-summary-prev-thread t]
2602 ["Go down thread" gnus-summary-down-thread t]
2603 ["Go up thread" gnus-summary-up-thread t]
2604 ["Top of thread" gnus-summary-top-thread t]
2605 ["Mark thread as read" gnus-summary-kill-thread t]
2606 ["Mark thread as expired" gnus-summary-expire-thread t]
2607 ["Lower thread score" gnus-summary-lower-thread t]
2608 ["Raise thread score" gnus-summary-raise-thread t]
2609 ["Rethread current" gnus-summary-rethread-current t]))
2611 (easy-menu-define
2612 gnus-summary-post-menu gnus-summary-mode-map ""
2613 `("Post"
2614 ["Send a message (mail or news)" gnus-summary-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Compose a new message (mail or news)"))]
2617 ["Followup" gnus-summary-followup
2618 ,@(if (featurep 'xemacs) '(t)
2619 '(:help "Post followup to this article"))]
2620 ["Followup and yank" gnus-summary-followup-with-original
2621 ,@(if (featurep 'xemacs) '(t)
2622 '(:help "Post followup to this article, quoting its contents"))]
2623 ["Supersede article" gnus-summary-supersede-article t]
2624 ["Cancel article" gnus-summary-cancel-article
2625 ,@(if (featurep 'xemacs) '(t)
2626 '(:help "Cancel an article you posted"))]
2627 ["Reply" gnus-summary-reply t]
2628 ["Reply and yank" gnus-summary-reply-with-original t]
2629 ["Wide reply" gnus-summary-wide-reply t]
2630 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2631 ,@(if (featurep 'xemacs) '(t)
2632 '(:help "Mail a reply, quoting this article"))]
2633 ["Very wide reply" gnus-summary-very-wide-reply t]
2634 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2635 ,@(if (featurep 'xemacs) '(t)
2636 '(:help "Mail a very wide reply, quoting this article"))]
2637 ["Mail forward" gnus-summary-mail-forward t]
2638 ["Post forward" gnus-summary-post-forward t]
2639 ["Digest and mail" gnus-uu-digest-mail-forward t]
2640 ["Digest and post" gnus-uu-digest-post-forward t]
2641 ["Resend message" gnus-summary-resend-message t]
2642 ["Resend message edit" gnus-summary-resend-message-edit t]
2643 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2644 ["Send a mail" gnus-summary-mail-other-window t]
2645 ["Create a local message" gnus-summary-news-other-window t]
2646 ["Uuencode and post" gnus-uu-post-news
2647 ,@(if (featurep 'xemacs) '(t)
2648 '(:help "Post a uuencoded article"))]
2649 ["Followup via news" gnus-summary-followup-to-mail t]
2650 ["Followup via news and yank"
2651 gnus-summary-followup-to-mail-with-original t]
2652 ["Strip signature on reply"
2653 (lambda ()
2654 (interactive)
2655 (if (not (memq message-cite-function
2656 '(message-cite-original-without-signature
2657 message-cite-original)))
2658 ;; Stupid workaround for XEmacs not honoring :visible.
2659 (message "Can't toggle this value of `message-cite-function'")
2660 (setq message-cite-function
2661 (if (eq message-cite-function
2662 'message-cite-original-without-signature)
2663 'message-cite-original
2664 'message-cite-original-without-signature))))
2665 ;; XEmacs barfs on :visible.
2666 ,@(if (featurep 'xemacs) nil
2667 '(:visible (memq message-cite-function
2668 '(message-cite-original-without-signature
2669 message-cite-original))))
2670 :style toggle
2671 :selected (eq message-cite-function
2672 'message-cite-original-without-signature)
2673 ,@(if (featurep 'xemacs) nil
2674 '(:help "Strip signature from cited article when replying."))]
2675 ;;("Draft"
2676 ;;["Send" gnus-summary-send-draft t]
2677 ;;["Send bounced" gnus-resend-bounced-mail t])
2680 (cond
2681 ((not (keymapp gnus-summary-post-menu))
2682 (setq gnus-article-post-menu gnus-summary-post-menu))
2683 ((not gnus-article-post-menu)
2684 ;; Don't share post menu.
2685 (setq gnus-article-post-menu
2686 (copy-keymap gnus-summary-post-menu))))
2687 (define-key gnus-article-mode-map [menu-bar post]
2688 (cons "Post" gnus-article-post-menu))
2690 (easy-menu-define
2691 gnus-summary-misc-menu gnus-summary-mode-map ""
2692 `("Gnus"
2693 ("Mark Read"
2694 ["Mark as read" gnus-summary-mark-as-read-forward t]
2695 ["Mark same subject and select"
2696 gnus-summary-kill-same-subject-and-select t]
2697 ["Mark same subject" gnus-summary-kill-same-subject t]
2698 ["Catchup" gnus-summary-catchup
2699 ,@(if (featurep 'xemacs) '(t)
2700 '(:help "Mark unread articles in this group as read"))]
2701 ["Catchup all" gnus-summary-catchup-all t]
2702 ["Catchup to here" gnus-summary-catchup-to-here t]
2703 ["Catchup from here" gnus-summary-catchup-from-here t]
2704 ["Catchup region" gnus-summary-mark-region-as-read
2705 (gnus-mark-active-p)]
2706 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2707 ("Mark Various"
2708 ["Tick" gnus-summary-tick-article-forward t]
2709 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2710 ["Remove marks" gnus-summary-clear-mark-forward t]
2711 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2712 ["Set bookmark" gnus-summary-set-bookmark t]
2713 ["Remove bookmark" gnus-summary-remove-bookmark t])
2714 ("Limit to"
2715 ["Marks..." gnus-summary-limit-to-marks t]
2716 ["Subject..." gnus-summary-limit-to-subject t]
2717 ["Author..." gnus-summary-limit-to-author t]
2718 ["Recipient..." gnus-summary-limit-to-recipient t]
2719 ["Address..." gnus-summary-limit-to-address t]
2720 ["Age..." gnus-summary-limit-to-age t]
2721 ["Extra..." gnus-summary-limit-to-extra t]
2722 ["Score..." gnus-summary-limit-to-score t]
2723 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2724 ["Unread" gnus-summary-limit-to-unread t]
2725 ["Unseen" gnus-summary-limit-to-unseen t]
2726 ["Singletons" gnus-summary-limit-to-singletons t]
2727 ["Replied" gnus-summary-limit-to-replied t]
2728 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2729 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2730 ["Pop limit" gnus-summary-pop-limit t]
2731 ["Show dormant" gnus-summary-limit-include-dormant t]
2732 ["Hide childless dormant"
2733 gnus-summary-limit-exclude-childless-dormant t]
2734 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2735 ["Hide marked" gnus-summary-limit-exclude-marks t]
2736 ["Show expunged" gnus-summary-limit-include-expunged t])
2737 ("Process Mark"
2738 ["Set mark" gnus-summary-mark-as-processable t]
2739 ["Remove mark" gnus-summary-unmark-as-processable t]
2740 ["Remove all marks" gnus-summary-unmark-all-processable t]
2741 ["Invert marks" gnus-uu-invert-processable t]
2742 ["Mark above" gnus-uu-mark-over t]
2743 ["Mark series" gnus-uu-mark-series t]
2744 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2745 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2746 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2747 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2748 ["Mark all" gnus-uu-mark-all t]
2749 ["Mark buffer" gnus-uu-mark-buffer t]
2750 ["Mark sparse" gnus-uu-mark-sparse t]
2751 ["Mark thread" gnus-uu-mark-thread t]
2752 ["Unmark thread" gnus-uu-unmark-thread t]
2753 ("Process Mark Sets"
2754 ["Kill" gnus-summary-kill-process-mark t]
2755 ["Yank" gnus-summary-yank-process-mark
2756 gnus-newsgroup-process-stack]
2757 ["Save" gnus-summary-save-process-mark t]
2758 ["Run command on marked..." gnus-summary-universal-argument t]))
2759 ("Registry Marks")
2760 ("Scroll article"
2761 ["Page forward" gnus-summary-next-page
2762 ,@(if (featurep 'xemacs) '(t)
2763 '(:help "Show next page of article"))]
2764 ["Page backward" gnus-summary-prev-page
2765 ,@(if (featurep 'xemacs) '(t)
2766 '(:help "Show previous page of article"))]
2767 ["Line forward" gnus-summary-scroll-up t])
2768 ("Move"
2769 ["Next unread article" gnus-summary-next-unread-article t]
2770 ["Previous unread article" gnus-summary-prev-unread-article t]
2771 ["Next article" gnus-summary-next-article t]
2772 ["Previous article" gnus-summary-prev-article t]
2773 ["Next unread subject" gnus-summary-next-unread-subject t]
2774 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2775 ["Next article same subject" gnus-summary-next-same-subject t]
2776 ["Previous article same subject" gnus-summary-prev-same-subject t]
2777 ["First unread article" gnus-summary-first-unread-article t]
2778 ["Best unread article" gnus-summary-best-unread-article t]
2779 ["Go to subject number..." gnus-summary-goto-subject t]
2780 ["Go to article number..." gnus-summary-goto-article t]
2781 ["Go to the last article" gnus-summary-goto-last-article t]
2782 ["Pop article off history" gnus-summary-pop-article t])
2783 ("Sort"
2784 ["Sort by number" gnus-summary-sort-by-number t]
2785 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2786 ["Sort by author" gnus-summary-sort-by-author t]
2787 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2788 ["Sort by subject" gnus-summary-sort-by-subject t]
2789 ["Sort by date" gnus-summary-sort-by-date t]
2790 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2791 ["Sort by score" gnus-summary-sort-by-score t]
2792 ["Sort by lines" gnus-summary-sort-by-lines t]
2793 ["Sort by characters" gnus-summary-sort-by-chars t]
2794 ["Randomize" gnus-summary-sort-by-random t]
2795 ["Original sort" gnus-summary-sort-by-original t])
2796 ("Help"
2797 ["Describe group" gnus-summary-describe-group t]
2798 ["Read manual" gnus-info-find-node t])
2799 ("Modes"
2800 ["Pick and read" gnus-pick-mode t]
2801 ["Binary" gnus-binary-mode t])
2802 ("Regeneration"
2803 ["Regenerate" gnus-summary-prepare t]
2804 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2805 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2806 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2807 ["Toggle threading" gnus-summary-toggle-threads t])
2808 ["See old articles" gnus-summary-insert-old-articles t]
2809 ["See new articles" gnus-summary-insert-new-articles t]
2810 ["Filter articles..." gnus-summary-execute-command t]
2811 ["Run command on articles..." gnus-summary-universal-argument t]
2812 ["Search articles forward..." gnus-summary-search-article-forward t]
2813 ["Search articles backward..." gnus-summary-search-article-backward t]
2814 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2815 ["Expand window" gnus-summary-expand-window t]
2816 ["Expire expirable articles" gnus-summary-expire-articles
2817 (gnus-check-backend-function
2818 'request-expire-articles gnus-newsgroup-name)]
2819 ["Edit local kill file" gnus-summary-edit-local-kill t]
2820 ["Edit main kill file" gnus-summary-edit-global-kill t]
2821 ["Edit group parameters" gnus-summary-edit-parameters t]
2822 ["Customize group parameters" gnus-summary-customize-parameters t]
2823 ["Send a bug report" gnus-bug t]
2824 ("Exit"
2825 ["Catchup and exit" gnus-summary-catchup-and-exit
2826 ,@(if (featurep 'xemacs) '(t)
2827 '(:help "Mark unread articles in this group as read, then exit"))]
2828 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2829 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2830 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2831 ["Exit group" gnus-summary-exit
2832 ,@(if (featurep 'xemacs) '(t)
2833 '(:help "Exit current group, return to group selection mode"))]
2834 ["Exit group without updating" gnus-summary-exit-no-update t]
2835 ["Exit and goto next group" gnus-summary-next-group t]
2836 ["Exit and goto prev group" gnus-summary-prev-group t]
2837 ["Reselect group" gnus-summary-reselect-current-group t]
2838 ["Rescan group" gnus-summary-rescan-group t]
2839 ["Update dribble" gnus-summary-save-newsrc t])))
2841 (gnus-run-hooks 'gnus-summary-menu-hook)))
2843 (defvar gnus-summary-tool-bar-map nil)
2845 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2846 ;; affect _new_ message buffers. We might add a function that walks thru all
2847 ;; summary-mode buffers and force the update.
2848 (defun gnus-summary-tool-bar-update (&optional symbol value)
2849 "Update summary mode toolbar.
2850 Setter function for custom variables."
2851 (setq-default gnus-summary-tool-bar-map nil)
2852 (when symbol
2853 ;; When used as ":set" function:
2854 (set-default symbol value))
2855 (when (gnus-buffer-live-p gnus-summary-buffer)
2856 (with-current-buffer gnus-summary-buffer
2857 (gnus-summary-make-tool-bar))))
2859 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2860 'gnus-summary-tool-bar-gnome
2861 'gnus-summary-tool-bar-retro)
2862 "Specifies the Gnus summary tool bar.
2864 It can be either a list or a symbol referring to a list. See
2865 `gmm-tool-bar-from-list' for the format of the list. The
2866 default key map is `gnus-summary-mode-map'.
2868 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2869 `gnus-summary-tool-bar-retro'."
2870 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2871 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2872 (repeat :tag "User defined list" gmm-tool-bar-item)
2873 (symbol))
2874 :version "23.1" ;; No Gnus
2875 :initialize 'custom-initialize-default
2876 :set 'gnus-summary-tool-bar-update
2877 :group 'gnus-summary)
2879 (defcustom gnus-summary-tool-bar-gnome
2880 '((gnus-summary-post-news "mail/compose" nil)
2881 (gnus-summary-insert-new-articles "mail/inbox" nil
2882 :visible (or (not gnus-agent)
2883 gnus-plugged))
2884 (gnus-summary-reply-with-original "mail/reply")
2885 (gnus-summary-reply "mail/reply" nil :visible nil)
2886 (gnus-summary-followup-with-original "mail/reply-all")
2887 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2888 (gnus-summary-mail-forward "mail/forward")
2889 (gnus-summary-save-article "mail/save")
2890 (gnus-summary-search-article-forward "search" nil :visible nil)
2891 (gnus-summary-print-article "print")
2892 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2893 ;; Some new commands that may need more suitable icons:
2894 (gnus-summary-save-newsrc "save" nil :visible nil)
2895 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2896 (gnus-summary-prev-article "left-arrow")
2897 (gnus-summary-next-article "right-arrow")
2898 (gnus-summary-next-page "next-page")
2899 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2901 ;; Maybe some sort-by-... could be added:
2902 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2903 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2904 (gnus-summary-mark-as-expirable
2905 "delete" nil
2906 :visible (gnus-check-backend-function 'request-expire-articles
2907 gnus-newsgroup-name))
2908 (gnus-summary-mark-as-spam
2909 "mail/spam" t
2910 :visible (and (fboundp 'spam-group-ham-contents-p)
2911 (spam-group-ham-contents-p gnus-newsgroup-name))
2912 :help "Mark as spam")
2913 (gnus-summary-mark-as-read-forward
2914 "mail/not-spam" nil
2915 :visible (and (fboundp 'spam-group-spam-contents-p)
2916 (spam-group-spam-contents-p gnus-newsgroup-name)))
2918 (gnus-summary-exit "exit")
2919 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2920 (gnus-info-find-node "help"))
2921 "List of functions for the summary tool bar (GNOME style).
2923 See `gmm-tool-bar-from-list' for the format of the list."
2924 :type '(repeat gmm-tool-bar-item)
2925 :version "23.1" ;; No Gnus
2926 :initialize 'custom-initialize-default
2927 :set 'gnus-summary-tool-bar-update
2928 :group 'gnus-summary)
2930 (defcustom gnus-summary-tool-bar-retro
2931 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2932 (gnus-summary-next-unread-article "gnus/next-ur")
2933 (gnus-summary-post-news "gnus/post")
2934 (gnus-summary-followup-with-original "gnus/fuwo")
2935 (gnus-summary-followup "gnus/followup")
2936 (gnus-summary-reply-with-original "gnus/reply-wo")
2937 (gnus-summary-reply "gnus/reply")
2938 (gnus-summary-caesar-message "gnus/rot13")
2939 (gnus-uu-decode-uu "gnus/uu-decode")
2940 (gnus-summary-save-article-file "gnus/save-aif")
2941 (gnus-summary-save-article "gnus/save-art")
2942 (gnus-uu-post-news "gnus/uu-post")
2943 (gnus-summary-catchup "gnus/catchup")
2944 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2945 (gnus-summary-exit "gnus/exit-summ")
2946 ;; Some new command that may need more suitable icons:
2947 (gnus-summary-print-article "gnus/print" nil :visible nil)
2948 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2949 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2950 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2951 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2952 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2953 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2955 (gnus-info-find-node "gnus/help" nil :visible nil))
2956 "List of functions for the summary tool bar (retro look).
2958 See `gmm-tool-bar-from-list' for the format of the list."
2959 :type '(repeat gmm-tool-bar-item)
2960 :version "23.1" ;; No Gnus
2961 :initialize 'custom-initialize-default
2962 :set 'gnus-summary-tool-bar-update
2963 :group 'gnus-summary)
2965 (defcustom gnus-summary-tool-bar-zap-list t
2966 "List of icon items from the global tool bar.
2967 These items are not displayed in the Gnus summary mode tool bar.
2969 See `gmm-tool-bar-from-list' for the format of the list."
2970 :type 'gmm-tool-bar-zap-list
2971 :version "23.1" ;; No Gnus
2972 :initialize 'custom-initialize-default
2973 :set 'gnus-summary-tool-bar-update
2974 :group 'gnus-summary)
2976 (defvar image-load-path)
2977 (defvar tool-bar-map)
2979 (defun gnus-summary-make-tool-bar (&optional force)
2980 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2981 When FORCE, rebuild the tool bar."
2982 (when (and (not (featurep 'xemacs))
2983 (boundp 'tool-bar-mode)
2984 tool-bar-mode
2985 (or (not gnus-summary-tool-bar-map) force))
2986 (let* ((load-path
2987 (gmm-image-load-path-for-library "gnus"
2988 "mail/save.xpm"
2989 nil t))
2990 (image-load-path (cons (car load-path)
2991 (when (boundp 'image-load-path)
2992 image-load-path)))
2993 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2994 gnus-summary-tool-bar-zap-list
2995 'gnus-summary-mode-map)))
2996 (when map
2997 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2998 ;; uses its value.
2999 (setq gnus-summary-tool-bar-map map))))
3000 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3002 (defun gnus-make-score-map (type)
3003 "Make a summary score map of type TYPE."
3004 (if t
3006 (let ((headers '(("author" "from" string)
3007 ("subject" "subject" string)
3008 ("article body" "body" string)
3009 ("article head" "head" string)
3010 ("xref" "xref" string)
3011 ("extra header" "extra" string)
3012 ("lines" "lines" number)
3013 ("followups to author" "followup" string)))
3014 (types '((number ("less than" <)
3015 ("greater than" >)
3016 ("equal" =))
3017 (string ("substring" s)
3018 ("exact string" e)
3019 ("fuzzy string" f)
3020 ("regexp" r))))
3021 (perms '(("temporary" (current-time-string))
3022 ("permanent" nil)
3023 ("immediate" now)))
3024 header)
3025 (list
3026 (apply
3027 'nconc
3028 (list
3029 (if (eq type 'lower)
3030 "Lower score"
3031 "Increase score"))
3032 (let (outh)
3033 (while headers
3034 (setq header (car headers))
3035 (setq outh
3036 (cons
3037 (apply
3038 'nconc
3039 (list (car header))
3040 (let ((ts (cdr (assoc (nth 2 header) types)))
3041 outt)
3042 (while ts
3043 (setq outt
3044 (cons
3045 (apply
3046 'nconc
3047 (list (caar ts))
3048 (let ((ps perms)
3049 outp)
3050 (while ps
3051 (setq outp
3052 (cons
3053 (vector
3054 (caar ps)
3055 (list
3056 'gnus-summary-score-entry
3057 (nth 1 header)
3058 (if (or (string= (nth 1 header)
3059 "head")
3060 (string= (nth 1 header)
3061 "body"))
3063 (list 'gnus-summary-header
3064 (nth 1 header)))
3065 (list 'quote (nth 1 (car ts)))
3066 (list 'gnus-score-delta-default
3067 nil)
3068 (nth 1 (car ps))
3071 outp))
3072 (setq ps (cdr ps)))
3073 (list (nreverse outp))))
3074 outt))
3075 (setq ts (cdr ts)))
3076 (list (nreverse outt))))
3077 outh))
3078 (setq headers (cdr headers)))
3079 (list (nreverse outh))))))))
3082 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3083 (defvar bookmark-make-record-function)
3085 (defvar bidi-paragraph-direction)
3087 (defun gnus-summary-mode (&optional group)
3088 "Major mode for reading articles.
3090 All normal editing commands are switched off.
3091 \\<gnus-summary-mode-map>
3092 Each line in this buffer represents one article. To read an
3093 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3094 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3095 respectively.
3097 You can also post articles and send mail from this buffer. To
3098 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3099 of an article, type `\\[gnus-summary-reply]'.
3101 There are approx. one gazillion commands you can execute in this
3102 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3104 The following commands are available:
3106 \\{gnus-summary-mode-map}"
3107 (interactive)
3108 (kill-all-local-variables)
3109 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3110 (gnus-summary-make-local-variables))
3111 (gnus-summary-make-local-variables)
3112 (setq gnus-newsgroup-name group)
3113 (when (gnus-visual-p 'summary-menu 'menu)
3114 (gnus-summary-make-menu-bar)
3115 (gnus-summary-make-tool-bar))
3116 (gnus-make-thread-indent-array)
3117 (gnus-simplify-mode-line)
3118 (setq major-mode 'gnus-summary-mode)
3119 (setq mode-name "Summary")
3120 (use-local-map gnus-summary-mode-map)
3121 (buffer-disable-undo)
3122 (setq buffer-read-only t ;Disable modification
3123 show-trailing-whitespace nil)
3124 (setq truncate-lines t)
3125 ;; Force paragraph direction to be left-to-right. Don't make it
3126 ;; bound globally in old Emacsen and XEmacsen.
3127 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3128 (add-to-invisibility-spec '(gnus-sum . t))
3129 (gnus-summary-set-display-table)
3130 (gnus-set-default-directory)
3131 (make-local-variable 'gnus-summary-line-format)
3132 (make-local-variable 'gnus-summary-line-format-spec)
3133 (make-local-variable 'gnus-summary-dummy-line-format)
3134 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3135 (make-local-variable 'gnus-summary-mark-positions)
3136 (gnus-make-local-hook 'pre-command-hook)
3137 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3138 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3139 (turn-on-gnus-mailing-list-mode)
3140 (mm-enable-multibyte)
3141 (set (make-local-variable 'bookmark-make-record-function)
3142 'gnus-summary-bookmark-make-record)
3143 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3144 (gnus-update-summary-mark-positions))
3146 (defun gnus-summary-make-local-variables ()
3147 "Make all the local summary buffer variables."
3148 (let (global)
3149 (dolist (local gnus-summary-local-variables)
3150 (if (consp local)
3151 (progn
3152 (if (eq (cdr local) 'global)
3153 ;; Copy the global value of the variable.
3154 (setq global (symbol-value (car local)))
3155 ;; Use the value from the list.
3156 (setq global (eval (cdr local))))
3157 (set (make-local-variable (car local)) global))
3158 ;; Simple nil-valued local variable.
3159 (set (make-local-variable local) nil)))))
3161 ;; Summary data functions.
3163 (defmacro gnus-data-number (data)
3164 `(car ,data))
3166 (defmacro gnus-data-set-number (data number)
3167 `(setcar ,data ,number))
3169 (defmacro gnus-data-mark (data)
3170 `(nth 1 ,data))
3172 (defmacro gnus-data-set-mark (data mark)
3173 `(setcar (nthcdr 1 ,data) ,mark))
3175 (defmacro gnus-data-pos (data)
3176 `(nth 2 ,data))
3178 (defmacro gnus-data-set-pos (data pos)
3179 `(setcar (nthcdr 2 ,data) ,pos))
3181 (defmacro gnus-data-header (data)
3182 `(nth 3 ,data))
3184 (defmacro gnus-data-set-header (data header)
3185 `(setf (nth 3 ,data) ,header))
3187 (defmacro gnus-data-level (data)
3188 `(nth 4 ,data))
3190 (defmacro gnus-data-unread-p (data)
3191 `(= (nth 1 ,data) gnus-unread-mark))
3193 (defmacro gnus-data-read-p (data)
3194 `(/= (nth 1 ,data) gnus-unread-mark))
3196 (defmacro gnus-data-pseudo-p (data)
3197 `(consp (nth 3 ,data)))
3199 (defmacro gnus-data-find (number)
3200 `(assq ,number gnus-newsgroup-data))
3202 (defmacro gnus-data-find-list (number &optional data)
3203 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3204 (memq (assq ,number bdata)
3205 bdata)))
3207 (defmacro gnus-data-make (number mark pos header level)
3208 `(list ,number ,mark ,pos ,header ,level))
3210 (defun gnus-data-enter (after-article number mark pos header level offset)
3211 (let ((data (gnus-data-find-list after-article)))
3212 (unless data
3213 (error "No such article: %d" after-article))
3214 (setcdr data (cons (gnus-data-make number mark pos header level)
3215 (cdr data)))
3216 (setq gnus-newsgroup-data-reverse nil)
3217 (gnus-data-update-list (cddr data) offset)))
3219 (defun gnus-data-enter-list (after-article list &optional offset)
3220 (when list
3221 (let ((data (and after-article (gnus-data-find-list after-article)))
3222 (ilist list))
3223 (if (not (or data
3224 after-article))
3225 (let ((odata gnus-newsgroup-data))
3226 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3227 (when offset
3228 (gnus-data-update-list odata offset)))
3229 ;; Find the last element in the list to be spliced into the main
3230 ;; list.
3231 (setq list (last list))
3232 (if (not data)
3233 (progn
3234 (setcdr list gnus-newsgroup-data)
3235 (setq gnus-newsgroup-data ilist)
3236 (when offset
3237 (gnus-data-update-list (cdr list) offset)))
3238 (setcdr list (cdr data))
3239 (setcdr data ilist)
3240 (when offset
3241 (gnus-data-update-list (cdr list) offset))))
3242 (setq gnus-newsgroup-data-reverse nil))))
3244 (defun gnus-data-remove (article &optional offset)
3245 (let ((data gnus-newsgroup-data))
3246 (if (= (gnus-data-number (car data)) article)
3247 (progn
3248 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3249 gnus-newsgroup-data-reverse nil)
3250 (when offset
3251 (gnus-data-update-list gnus-newsgroup-data offset)))
3252 (while (cdr data)
3253 (when (= (gnus-data-number (cadr data)) article)
3254 (setcdr data (cddr data))
3255 (when offset
3256 (gnus-data-update-list (cdr data) offset))
3257 (setq data nil
3258 gnus-newsgroup-data-reverse nil))
3259 (setq data (cdr data))))))
3261 (defmacro gnus-data-list (backward)
3262 `(if ,backward
3263 (or gnus-newsgroup-data-reverse
3264 (setq gnus-newsgroup-data-reverse
3265 (reverse gnus-newsgroup-data)))
3266 gnus-newsgroup-data))
3268 (defun gnus-data-update-list (data offset)
3269 "Add OFFSET to the POS of all data entries in DATA."
3270 (setq gnus-newsgroup-data-reverse nil)
3271 (while data
3272 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3273 (setq data (cdr data))))
3275 (defun gnus-summary-article-pseudo-p (article)
3276 "Say whether this article is a pseudo article or not."
3277 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3279 (defmacro gnus-summary-article-sparse-p (article)
3280 "Say whether this article is a sparse article or not."
3281 `(memq ,article gnus-newsgroup-sparse))
3283 (defmacro gnus-summary-article-ancient-p (article)
3284 "Say whether this article is a sparse article or not."
3285 `(memq ,article gnus-newsgroup-ancient))
3287 (defun gnus-article-children (number)
3288 "Return a list of all children to NUMBER."
3289 (let* ((data (gnus-data-find-list number))
3290 (level (gnus-data-level (car data)))
3291 children)
3292 (setq data (cdr data))
3293 (while (and data
3294 (= (gnus-data-level (car data)) (1+ level)))
3295 (push (gnus-data-number (car data)) children)
3296 (setq data (cdr data)))
3297 children))
3299 (defmacro gnus-summary-skip-intangible ()
3300 "If the current article is intangible, then jump to a different article."
3301 '(let ((to (get-text-property (point) 'gnus-intangible)))
3302 (and to (gnus-summary-goto-subject to))))
3304 (defmacro gnus-summary-article-intangible-p ()
3305 "Say whether this article is intangible or not."
3306 '(get-text-property (point) 'gnus-intangible))
3308 ;; Some summary mode macros.
3310 (defmacro gnus-summary-article-number ()
3311 "The article number of the article on the current line.
3312 If there isn't an article number here, then we return the current
3313 article number."
3314 '(progn
3315 (gnus-summary-skip-intangible)
3316 (or (get-text-property (point) 'gnus-number)
3317 (gnus-summary-last-subject))))
3319 (defmacro gnus-summary-article-header (&optional number)
3320 "Return the header of article NUMBER."
3321 `(gnus-data-header (gnus-data-find
3322 ,(or number '(gnus-summary-article-number)))))
3324 (defmacro gnus-summary-thread-level (&optional number)
3325 "Return the level of thread that starts with article NUMBER."
3326 `(if (and (eq gnus-summary-make-false-root 'dummy)
3327 (get-text-property (point) 'gnus-intangible))
3329 (gnus-data-level (gnus-data-find
3330 ,(or number '(gnus-summary-article-number))))))
3332 (defmacro gnus-summary-article-mark (&optional number)
3333 "Return the mark of article NUMBER."
3334 `(gnus-data-mark (gnus-data-find
3335 ,(or number '(gnus-summary-article-number)))))
3337 (defmacro gnus-summary-article-pos (&optional number)
3338 "Return the position of the line of article NUMBER."
3339 `(gnus-data-pos (gnus-data-find
3340 ,(or number '(gnus-summary-article-number)))))
3342 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3343 (defmacro gnus-summary-article-subject (&optional number)
3344 "Return current subject string or nil if nothing."
3345 `(let ((headers
3346 ,(if number
3347 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3348 '(gnus-data-header (assq (gnus-summary-article-number)
3349 gnus-newsgroup-data)))))
3350 (and headers
3351 (vectorp headers)
3352 (mail-header-subject headers))))
3354 (defmacro gnus-summary-article-score (&optional number)
3355 "Return current article score."
3356 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3357 gnus-newsgroup-scored))
3358 gnus-summary-default-score 0))
3360 (defun gnus-summary-article-children (&optional number)
3361 "Return a list of article numbers that are children of article NUMBER."
3362 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3363 (level (gnus-data-level (car data)))
3364 l children)
3365 (while (and (setq data (cdr data))
3366 (> (setq l (gnus-data-level (car data))) level))
3367 (and (= (1+ level) l)
3368 (push (gnus-data-number (car data))
3369 children)))
3370 (nreverse children)))
3372 (defun gnus-summary-article-parent (&optional number)
3373 "Return the article number of the parent of article NUMBER."
3374 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3375 (gnus-data-list t)))
3376 (level (gnus-data-level (car data))))
3377 (if (zerop level)
3378 () ; This is a root.
3379 ;; We search until we find an article with a level less than
3380 ;; this one. That function has to be the parent.
3381 (while (and (setq data (cdr data))
3382 (not (< (gnus-data-level (car data)) level))))
3383 (and data (gnus-data-number (car data))))))
3385 (defun gnus-unread-mark-p (mark)
3386 "Say whether MARK is the unread mark."
3387 (= mark gnus-unread-mark))
3389 (defun gnus-read-mark-p (mark)
3390 "Say whether MARK is one of the marks that mark as read.
3391 This is all marks except unread, ticked, dormant, and expirable."
3392 (not (or (= mark gnus-unread-mark)
3393 (= mark gnus-ticked-mark)
3394 (= mark gnus-spam-mark)
3395 (= mark gnus-dormant-mark)
3396 (= mark gnus-expirable-mark))))
3398 (defmacro gnus-article-mark (number)
3399 "Return the MARK of article NUMBER.
3400 This macro should only be used when computing the mark the \"first\"
3401 time; i.e., when generating the summary lines. After that,
3402 `gnus-summary-article-mark' should be used to examine the
3403 marks of articles."
3404 `(cond
3405 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3406 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3407 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3408 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3409 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3410 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3411 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3412 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3413 gnus-ancient-mark))))
3415 ;; Saving hidden threads.
3417 (defmacro gnus-save-hidden-threads (&rest forms)
3418 "Save hidden threads, eval FORMS, and restore the hidden threads."
3419 (let ((config (make-symbol "config")))
3420 `(let ((,config (gnus-hidden-threads-configuration)))
3421 (unwind-protect
3422 (save-excursion
3423 ,@forms)
3424 (gnus-restore-hidden-threads-configuration ,config)))))
3425 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3426 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3428 (defun gnus-data-compute-positions ()
3429 "Compute the positions of all articles."
3430 (setq gnus-newsgroup-data-reverse nil)
3431 (let ((data gnus-newsgroup-data))
3432 (save-excursion
3433 (gnus-save-hidden-threads
3434 (gnus-summary-show-all-threads)
3435 (goto-char (point-min))
3436 (while data
3437 (while (get-text-property (point) 'gnus-intangible)
3438 (forward-line 1))
3439 (gnus-data-set-pos (car data) (+ (point) 3))
3440 (setq data (cdr data))
3441 (forward-line 1))))))
3443 (defun gnus-hidden-threads-configuration ()
3444 "Return the current hidden threads configuration."
3445 (save-excursion
3446 (let (config)
3447 (goto-char (point-min))
3448 (while (not (eobp))
3449 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3450 (push (save-excursion (forward-line 0) (point)) config))
3451 (forward-line 1))
3452 config)))
3454 (defun gnus-restore-hidden-threads-configuration (config)
3455 "Restore hidden threads configuration from CONFIG."
3456 (save-excursion
3457 (let (point (inhibit-read-only t))
3458 (while (setq point (pop config))
3459 (goto-char point)
3460 (gnus-summary-hide-thread)))))
3462 ;; Various summary mode internalish functions.
3464 (defun gnus-mouse-pick-article (e)
3465 (interactive "e")
3466 (mouse-set-point e)
3467 (gnus-summary-next-page nil t))
3469 (defun gnus-summary-set-display-table ()
3470 "Change the display table.
3471 Odd characters have a tendency to mess
3472 up nicely formatted displays - we make all possible glyphs
3473 display only a single character."
3475 ;; We start from the standard display table, if any.
3476 (let ((table (or (copy-sequence standard-display-table)
3477 (make-display-table)))
3478 (i 32))
3479 ;; Nix out all the control chars...
3480 (while (>= (setq i (1- i)) 0)
3481 (gnus-put-display-table i [??] table))
3482 ;; ... but not newline and cr, of course. (cr is necessary for the
3483 ;; selective display).
3484 (gnus-put-display-table ?\n nil table)
3485 (gnus-put-display-table ?\r nil table)
3486 ;; We keep TAB as well.
3487 (gnus-put-display-table ?\t nil table)
3488 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3489 ;; Emacs 23 (unicode), that are not set already.
3490 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3492 256)))
3493 (while (>= (setq i (1- i)) 127)
3494 ;; Only modify if the entry is nil.
3495 (unless (gnus-get-display-table i table)
3496 (gnus-put-display-table i [??] table))))
3497 (setq buffer-display-table table)))
3499 (defun gnus-summary-set-article-display-arrow (pos)
3500 "Update the overlay arrow to point to line at position POS."
3501 (when gnus-summary-display-arrow
3502 (make-local-variable 'overlay-arrow-position)
3503 (make-local-variable 'overlay-arrow-string)
3504 (save-excursion
3505 (goto-char pos)
3506 (beginning-of-line)
3507 (unless overlay-arrow-position
3508 (setq overlay-arrow-position (make-marker)))
3509 (setq overlay-arrow-string "=>"
3510 overlay-arrow-position (set-marker overlay-arrow-position
3511 (point)
3512 (current-buffer))))))
3514 (defun gnus-summary-setup-buffer (group)
3515 "Initialize summary buffer.
3516 If the setup was successful, non-nil is returned."
3517 (let ((buffer (gnus-summary-buffer-name group))
3518 (dead-name (concat "*Dead Summary "
3519 (gnus-group-decoded-name group) "*")))
3520 ;; If a dead summary buffer exists, we kill it.
3521 (when (gnus-buffer-live-p dead-name)
3522 (gnus-kill-buffer dead-name))
3523 (if (get-buffer buffer)
3524 (progn
3525 (set-buffer buffer)
3526 (setq gnus-summary-buffer (current-buffer))
3527 (not gnus-newsgroup-prepared))
3528 (set-buffer (gnus-get-buffer-create buffer))
3529 (setq gnus-summary-buffer (current-buffer))
3530 (gnus-summary-mode group)
3531 (when (gnus-group-quit-config group)
3532 (set (make-local-variable 'gnus-single-article-buffer) nil))
3533 (make-local-variable 'gnus-article-buffer)
3534 (make-local-variable 'gnus-article-current)
3535 (make-local-variable 'gnus-original-article-buffer)
3536 (setq gnus-newsgroup-name group)
3537 ;; Set any local variables in the group parameters.
3538 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3539 t)))
3541 (defun gnus-set-global-variables ()
3542 "Set the global equivalents of the buffer-local variables.
3543 They are set to the latest values they had. These reflect the summary
3544 buffer that was in action when the last article was fetched."
3545 (when (eq major-mode 'gnus-summary-mode)
3546 (setq gnus-summary-buffer (current-buffer))
3547 (let ((name gnus-newsgroup-name)
3548 (marked gnus-newsgroup-marked)
3549 (spam gnus-newsgroup-spam-marked)
3550 (unread gnus-newsgroup-unreads)
3551 (headers gnus-current-headers)
3552 (data gnus-newsgroup-data)
3553 (summary gnus-summary-buffer)
3554 (article-buffer gnus-article-buffer)
3555 (original gnus-original-article-buffer)
3556 (gac gnus-article-current)
3557 (reffed gnus-reffed-article-number)
3558 (score-file gnus-current-score-file)
3559 (default-charset gnus-newsgroup-charset)
3560 vlist)
3561 (let ((locals gnus-newsgroup-variables))
3562 (while locals
3563 (if (consp (car locals))
3564 (push (eval (caar locals)) vlist)
3565 (push (eval (car locals)) vlist))
3566 (setq locals (cdr locals)))
3567 (setq vlist (nreverse vlist)))
3568 (with-temp-buffer
3569 (setq gnus-newsgroup-name name
3570 gnus-newsgroup-marked marked
3571 gnus-newsgroup-spam-marked spam
3572 gnus-newsgroup-unreads unread
3573 gnus-current-headers headers
3574 gnus-newsgroup-data data
3575 gnus-article-current gac
3576 gnus-summary-buffer summary
3577 gnus-article-buffer article-buffer
3578 gnus-original-article-buffer original
3579 gnus-reffed-article-number reffed
3580 gnus-current-score-file score-file
3581 gnus-newsgroup-charset default-charset)
3582 (let ((locals gnus-newsgroup-variables))
3583 (while locals
3584 (if (consp (car locals))
3585 (set (caar locals) (pop vlist))
3586 (set (car locals) (pop vlist)))
3587 (setq locals (cdr locals))))))))
3589 (defun gnus-summary-article-unread-p (article)
3590 "Say whether ARTICLE is unread or not."
3591 (memq article gnus-newsgroup-unreads))
3593 (defun gnus-summary-first-article-p (&optional article)
3594 "Return whether ARTICLE is the first article in the buffer."
3595 (if (not (setq article (or article (gnus-summary-article-number))))
3597 (eq article (caar gnus-newsgroup-data))))
3599 (defun gnus-summary-last-article-p (&optional article)
3600 "Return whether ARTICLE is the last article in the buffer."
3601 (if (not (setq article (or article (gnus-summary-article-number))))
3602 ;; All non-existent numbers are the last article. :-)
3604 (not (cdr (gnus-data-find-list article)))))
3606 (defun gnus-make-thread-indent-array (&optional n)
3607 (when (or n
3608 (progn (setq n 200) nil)
3609 (null gnus-thread-indent-array)
3610 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3611 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3612 gnus-thread-indent-array-level gnus-thread-indent-level)
3613 (while (>= n 0)
3614 (aset gnus-thread-indent-array n
3615 (make-string (* n gnus-thread-indent-level) ? ))
3616 (setq n (1- n)))))
3618 (defun gnus-update-summary-mark-positions ()
3619 "Compute where the summary marks are to go."
3620 (save-excursion
3621 (when (gnus-buffer-exists-p gnus-summary-buffer)
3622 (set-buffer gnus-summary-buffer))
3623 (let ((spec gnus-summary-line-format-spec)
3624 pos)
3625 (save-excursion
3626 (gnus-set-work-buffer)
3627 (let ((gnus-tmp-unread ?Z)
3628 (gnus-replied-mark ?Z)
3629 (gnus-score-below-mark ?Z)
3630 (gnus-score-over-mark ?Z)
3631 (gnus-undownloaded-mark ?Z)
3632 (gnus-summary-line-format-spec spec)
3633 (gnus-newsgroup-downloadable '(0))
3634 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3635 case-fold-search ignores)
3636 ;; Here, all marks are bound to Z.
3637 (gnus-summary-insert-line header
3638 0 nil t gnus-tmp-unread t nil "" nil 1)
3639 (goto-char (point-min))
3640 ;; Memorize the positions of the same characters as dummy marks.
3641 (while (re-search-forward "[A-D]" nil t)
3642 (push (point) ignores))
3643 (erase-buffer)
3644 ;; We use A-D as dummy marks in order to know column positions
3645 ;; where marks should be inserted.
3646 (setq gnus-tmp-unread ?A
3647 gnus-replied-mark ?B
3648 gnus-score-below-mark ?C
3649 gnus-score-over-mark ?C
3650 gnus-undownloaded-mark ?D)
3651 (gnus-summary-insert-line header
3652 0 nil t gnus-tmp-unread t nil "" nil 1)
3653 ;; Ignore characters which aren't dummy marks.
3654 (dolist (p ignores)
3655 (delete-region (goto-char (1- p)) p)
3656 (insert ?Z))
3657 (goto-char (point-min))
3658 (setq pos (list (cons 'unread
3659 (and (search-forward "A" nil t)
3660 (- (point) (point-min) 1)))))
3661 (goto-char (point-min))
3662 (push (cons 'replied (and (search-forward "B" nil t)
3663 (- (point) (point-min) 1)))
3664 pos)
3665 (goto-char (point-min))
3666 (push (cons 'score (and (search-forward "C" nil t)
3667 (- (point) (point-min) 1)))
3668 pos)
3669 (goto-char (point-min))
3670 (push (cons 'download (and (search-forward "D" nil t)
3671 (- (point) (point-min) 1)))
3672 pos)))
3673 (setq gnus-summary-mark-positions pos))))
3675 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3676 "Insert a dummy root in the summary buffer."
3677 (beginning-of-line)
3678 (gnus-add-text-properties
3679 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3680 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3682 (defun gnus-summary-extract-address-component (from)
3683 (or (car (funcall gnus-extract-address-components from))
3684 from))
3686 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3687 (let ((mail-parse-charset gnus-newsgroup-charset)
3688 (ignored-from-addresses (gnus-ignored-from-addresses))
3689 ;; Is it really necessary to do this next part for each summary line?
3690 ;; Luckily, doesn't seem to slow things down much.
3691 (mail-parse-ignored-charsets
3692 (with-current-buffer gnus-summary-buffer
3693 gnus-newsgroup-ignored-charsets)))
3695 (and ignored-from-addresses
3696 (string-match ignored-from-addresses gnus-tmp-from)
3697 (let ((extra-headers (mail-header-extra header))
3699 newsgroups)
3700 (cond
3701 ((setq to (cdr (assq 'To extra-headers)))
3702 (concat gnus-summary-to-prefix
3703 (inline
3704 (gnus-summary-extract-address-component
3705 (funcall gnus-decode-encoded-address-function to)))))
3706 ((setq newsgroups
3708 (cdr (assq 'Newsgroups extra-headers))
3709 (and
3710 (memq 'Newsgroups gnus-extra-headers)
3711 (eq (car (gnus-find-method-for-group
3712 gnus-newsgroup-name)) 'nntp)
3713 (gnus-group-real-name gnus-newsgroup-name))))
3714 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3715 (gnus-string-mark-left-to-right
3716 (inline
3717 (gnus-summary-extract-address-component gnus-tmp-from))))))
3719 (defun gnus-summary-insert-line (gnus-tmp-header
3720 gnus-tmp-level gnus-tmp-current
3721 undownloaded gnus-tmp-unread gnus-tmp-replied
3722 gnus-tmp-expirable gnus-tmp-subject-or-nil
3723 &optional gnus-tmp-dummy gnus-tmp-score
3724 gnus-tmp-process)
3725 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3726 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3727 gnus-tmp-level)))
3728 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3729 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3730 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3731 (gnus-tmp-score-char
3732 (if (or (null gnus-summary-default-score)
3733 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3734 gnus-summary-zcore-fuzz))
3735 ? ;Whitespace
3736 (if (< gnus-tmp-score gnus-summary-default-score)
3737 gnus-score-below-mark gnus-score-over-mark)))
3738 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3739 (gnus-tmp-replied
3740 (cond (gnus-tmp-process gnus-process-mark)
3741 ((memq gnus-tmp-current gnus-newsgroup-cached)
3742 gnus-cached-mark)
3743 (gnus-tmp-replied gnus-replied-mark)
3744 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3745 gnus-forwarded-mark)
3746 ((memq gnus-tmp-current gnus-newsgroup-saved)
3747 gnus-saved-mark)
3748 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3749 gnus-unseen-mark)
3750 (t gnus-no-mark)))
3751 (gnus-tmp-downloaded
3752 (cond (undownloaded
3753 gnus-undownloaded-mark)
3754 (gnus-newsgroup-agentized
3755 gnus-downloaded-mark)
3757 gnus-no-mark)))
3758 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3759 (gnus-tmp-name
3760 (cond
3761 ((string-match "<[^>]+> *$" gnus-tmp-from)
3762 (let ((beg (match-beginning 0)))
3763 (or (and (string-match "^\".+\"" gnus-tmp-from)
3764 (substring gnus-tmp-from 1 (1- (match-end 0))))
3765 (substring gnus-tmp-from 0 beg))))
3766 ((string-match "(.+)" gnus-tmp-from)
3767 (substring gnus-tmp-from
3768 (1+ (match-beginning 0)) (1- (match-end 0))))
3769 (t gnus-tmp-from)))
3770 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3771 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3772 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3773 (inhibit-read-only t))
3774 (when (string= gnus-tmp-name "")
3775 (setq gnus-tmp-name gnus-tmp-from))
3776 (unless (numberp gnus-tmp-lines)
3777 (setq gnus-tmp-lines -1))
3778 (if (= gnus-tmp-lines -1)
3779 (setq gnus-tmp-lines "?")
3780 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3781 (condition-case ()
3782 (gnus-put-text-property
3783 (point)
3784 (progn (eval gnus-summary-line-format-spec) (point))
3785 'gnus-number gnus-tmp-number)
3786 (error (gnus-message 5 "Error updating the summary line")))
3787 (when (gnus-visual-p 'summary-highlight 'highlight)
3788 (forward-line -1)
3789 (gnus-summary-highlight-line)
3790 (gnus-run-hooks 'gnus-summary-update-hook)
3791 (forward-line 1))))
3793 (defun gnus-summary-update-line (&optional dont-update)
3794 "Update summary line after change."
3795 (when (and gnus-summary-default-score
3796 (not gnus-summary-inhibit-highlight))
3797 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3798 (article (gnus-summary-article-number))
3799 (score (gnus-summary-article-score article)))
3800 (unless dont-update
3801 (if (and gnus-summary-mark-below
3802 (< (gnus-summary-article-score)
3803 gnus-summary-mark-below))
3804 ;; This article has a low score, so we mark it as read.
3805 (when (memq article gnus-newsgroup-unreads)
3806 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3807 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3808 ;; This article was previously marked as read on account
3809 ;; of a low score, but now it has risen, so we mark it as
3810 ;; unread.
3811 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3812 (gnus-summary-update-mark
3813 (if (or (null gnus-summary-default-score)
3814 (<= (abs (- score gnus-summary-default-score))
3815 gnus-summary-zcore-fuzz))
3816 ? ;Whitespace
3817 (if (< score gnus-summary-default-score)
3818 gnus-score-below-mark gnus-score-over-mark))
3819 'score))
3820 ;; Do visual highlighting.
3821 (when (gnus-visual-p 'summary-highlight 'highlight)
3822 (gnus-summary-highlight-line)
3823 (gnus-run-hooks 'gnus-summary-update-hook)))))
3825 (defvar gnus-tmp-new-adopts nil)
3827 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3828 "Return the number of articles in THREAD.
3829 This may be 0 in some cases -- if none of the articles in
3830 the thread are to be displayed."
3831 (let* ((number
3832 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3833 (cond
3834 ((not (listp thread))
3836 ((and (consp thread) (cdr thread))
3837 (apply
3838 '+ 1 (mapcar
3839 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3840 ((null thread)
3842 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3844 (t 0))))
3845 (when (and level (zerop level) gnus-tmp-new-adopts)
3846 (incf number
3847 (apply '+ (mapcar
3848 'gnus-summary-number-of-articles-in-thread
3849 gnus-tmp-new-adopts))))
3850 (if char
3851 (if (> number 1) gnus-not-empty-thread-mark
3852 gnus-empty-thread-mark)
3853 number)))
3855 (defsubst gnus-summary-line-message-size (head)
3856 "Return pretty-printed version of message size.
3857 This function is intended to be used in
3858 `gnus-summary-line-format-alist'."
3859 (let ((c (or (mail-header-chars head) -1)))
3860 (cond ((< c 0) "n/a") ; chars not available
3861 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3862 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3863 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3864 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3866 (defcustom gnus-user-date-format-alist
3867 '(((gnus-seconds-today) . "Today, %H:%M")
3868 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3869 (604800 . "%A %H:%M") ; That's one week
3870 ((gnus-seconds-month) . "%A %d")
3871 ((gnus-seconds-year) . "%B %d")
3872 (t . "%b %d %Y")) ; This one is used when no other
3873 ; does match
3874 "Specifies date format depending on age of article.
3875 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3876 seconds) or a Lisp expression evaluating to a number. When the age of
3877 the article is less than this number, then use `format-time-string'
3878 with the corresponding FORMAT for displaying the date of the article.
3879 If AGE is not a number or a Lisp expression evaluating to a
3880 non-number, then the corresponding FORMAT is used as a default value.
3882 Note that the list is processed from the beginning, so it should be
3883 sorted by ascending AGE. Also note that items following the first
3884 non-number AGE will be ignored.
3886 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3887 and `gnus-seconds-year' in the AGE spec. They return the number of
3888 seconds passed since the start of today, of this month, of this year,
3889 respectively."
3890 :version "24.1"
3891 :group 'gnus-summary-format
3892 :type '(alist :key-type sexp :value-type string))
3894 (defun gnus-user-date (messy-date)
3895 "Format the messy-date according to `gnus-user-date-format-alist'.
3896 Returns \" ? \" if there's bad input or if another error occurs.
3897 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3898 (condition-case ()
3899 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3900 (now (gnus-float-time))
3901 ;;If we don't find something suitable we'll use this one
3902 (my-format "%b %d '%y"))
3903 (let* ((difference (- now messy-date))
3904 (templist gnus-user-date-format-alist)
3905 (top (eval (caar templist))))
3906 (while (if (numberp top) (< top difference) (not top))
3907 (progn
3908 (setq templist (cdr templist))
3909 (setq top (eval (caar templist)))))
3910 (if (stringp (cdr (car templist)))
3911 (setq my-format (cdr (car templist)))))
3912 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3913 (error " ? ")))
3915 (defun gnus-summary-set-local-parameters (group)
3916 "Go through the local params of GROUP and set all variable specs in that list."
3917 (let ((vars '(quit-config active))) ; Ignore things that aren't
3918 ; really variables.
3919 (dolist (elem (gnus-group-find-parameter group))
3920 (and (consp elem) ; Has to be a cons.
3921 (consp (cdr elem)) ; The cdr has to be a list.
3922 (symbolp (car elem)) ; Has to be a symbol in there.
3923 (not (memq (car elem) vars))
3924 (ignore-errors
3925 (push (car elem) vars)
3926 ;; Variables like `gnus-show-threads' that are globally
3927 ;; bound, if used as group parameters, need to get to be
3928 ;; buffer-local, whereas just parameters like `gcc-self',
3929 ;; `timestamp', etc. should not be bound as variables.
3930 (if (boundp (car elem))
3931 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3932 (eval (nth 1 elem))))))))
3934 (defun gnus-summary-read-group (group &optional show-all no-article
3935 kill-buffer no-display backward
3936 select-articles)
3937 "Start reading news in newsgroup GROUP.
3938 If SHOW-ALL is non-nil, already read articles are also listed.
3939 If NO-ARTICLE is non-nil, no article is selected initially.
3940 If NO-DISPLAY, don't generate the summary buffer contents.
3941 If KILL-BUFFER, it should be a buffer that's killed once the new
3942 summary buffer has been generated.
3943 If BACKWARD, move point to the previous group in the group buffer
3944 If SELECT-ARTICLES, only select those articles from GROUP."
3945 (let (result)
3946 (while (and group
3947 (null (setq result
3948 (let ((gnus-auto-select-next nil))
3949 (or (gnus-summary-read-group-1
3950 group show-all no-article
3951 kill-buffer no-display
3952 select-articles)
3953 (setq show-all nil
3954 select-articles nil)))))
3955 (eq gnus-auto-select-next 'quietly))
3956 (set-buffer gnus-group-buffer)
3957 ;; The entry function called above goes to the next
3958 ;; group automatically, so we go two groups back
3959 ;; if we are searching for the previous group.
3960 (when backward
3961 (gnus-group-prev-unread-group 2))
3962 (if (not (equal group (gnus-group-group-name)))
3963 (setq group (gnus-group-group-name))
3964 (setq group nil)))
3965 result))
3967 (defun gnus-summary-read-group-1 (group show-all no-article
3968 kill-buffer no-display
3969 &optional select-articles)
3970 ;; Killed foreign groups can't be entered.
3971 ;; (when (and (not (gnus-group-native-p group))
3972 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3973 ;; (error "Dead non-native groups can't be entered"))
3974 (gnus-message 7 "Retrieving newsgroup: %s..."
3975 (gnus-group-decoded-name group))
3976 (let* ((new-group (gnus-summary-setup-buffer group))
3977 (quit-config (gnus-group-quit-config group))
3978 (did-select (and new-group (gnus-select-newsgroup
3979 group show-all select-articles))))
3980 (cond
3981 ;; This summary buffer exists already, so we just select it.
3982 ((not new-group)
3983 (gnus-set-global-variables)
3984 (when kill-buffer
3985 (gnus-kill-or-deaden-summary kill-buffer))
3986 (gnus-configure-windows 'summary 'force)
3987 (gnus-set-mode-line 'summary)
3988 (gnus-summary-position-point)
3989 (message "")
3991 ;; We couldn't select this group.
3992 ((null did-select)
3993 (when (and (eq major-mode 'gnus-summary-mode)
3994 (not (equal (current-buffer) kill-buffer)))
3995 (kill-buffer (current-buffer))
3996 (if (not quit-config)
3997 (progn
3998 ;; Update the info -- marks might need to be removed,
3999 ;; for instance.
4000 (gnus-summary-update-info)
4001 (set-buffer gnus-group-buffer)
4002 (gnus-group-jump-to-group group)
4003 (gnus-group-next-unread-group 1))
4004 (gnus-handle-ephemeral-exit quit-config)))
4005 (if (null (gnus-list-of-unread-articles group))
4006 (gnus-message 3 "Group %s contains no messages" group)
4007 (gnus-message 3 "Can't select group"))
4008 nil)
4009 ;; The user did a `C-g' while prompting for number of articles,
4010 ;; so we exit this group.
4011 ((eq did-select 'quit)
4012 (and (eq major-mode 'gnus-summary-mode)
4013 (not (equal (current-buffer) kill-buffer))
4014 (kill-buffer (current-buffer)))
4015 (when kill-buffer
4016 (gnus-kill-or-deaden-summary kill-buffer))
4017 (if (not quit-config)
4018 (progn
4019 (set-buffer gnus-group-buffer)
4020 (gnus-group-jump-to-group group)
4021 (gnus-configure-windows 'group 'force))
4022 (gnus-handle-ephemeral-exit quit-config))
4023 ;; Finally signal the quit.
4024 (signal 'quit nil))
4025 ;; The group was successfully selected.
4027 (gnus-set-global-variables)
4028 ;; Save the active value in effect when the group was entered.
4029 (setq gnus-newsgroup-active
4030 (gnus-copy-sequence
4031 (gnus-active gnus-newsgroup-name)))
4032 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4033 ;; You can change the summary buffer in some way with this hook.
4034 (gnus-run-hooks 'gnus-select-group-hook)
4035 (when (memq 'summary (gnus-update-format-specifications
4036 nil 'summary 'summary-mode 'summary-dummy))
4037 ;; The format specification for the summary line was updated,
4038 ;; so we need to update the mark positions as well.
4039 (gnus-update-summary-mark-positions))
4040 ;; Do score processing.
4041 (when gnus-use-scoring
4042 (gnus-possibly-score-headers))
4043 ;; Check whether to fill in the gaps in the threads.
4044 (when gnus-build-sparse-threads
4045 (gnus-build-sparse-threads))
4046 ;; Find the initial limit.
4047 (if show-all
4048 (let ((gnus-newsgroup-dormant nil))
4049 (gnus-summary-initial-limit show-all))
4050 (gnus-summary-initial-limit show-all))
4051 ;; Generate the summary buffer.
4052 (unless no-display
4053 (gnus-summary-prepare))
4054 (when gnus-use-trees
4055 (gnus-tree-open group)
4056 (setq gnus-summary-highlight-line-function
4057 'gnus-tree-highlight-article))
4058 ;; If the summary buffer is empty, but there are some low-scored
4059 ;; articles or some excluded dormants, we include these in the
4060 ;; buffer.
4061 (when (and (zerop (buffer-size))
4062 (not no-display))
4063 (cond (gnus-newsgroup-dormant
4064 (gnus-summary-limit-include-dormant))
4065 ((and gnus-newsgroup-scored show-all)
4066 (gnus-summary-limit-include-expunged t))))
4067 ;; Function `gnus-apply-kill-file' must be called in this hook.
4068 (gnus-run-hooks 'gnus-apply-kill-hook)
4069 (if (and (zerop (buffer-size))
4070 (not no-display))
4071 (progn
4072 ;; This newsgroup is empty.
4073 (gnus-summary-catchup-and-exit nil t)
4074 (gnus-message 6 "No unread news")
4075 (when kill-buffer
4076 (gnus-kill-or-deaden-summary kill-buffer))
4077 ;; Return nil from this function.
4078 nil)
4079 ;; Hide conversation thread subtrees. We cannot do this in
4080 ;; gnus-summary-prepare-hook since kill processing may not
4081 ;; work with hidden articles.
4082 (gnus-summary-maybe-hide-threads)
4083 (gnus-configure-windows 'summary)
4084 (when kill-buffer
4085 (gnus-kill-or-deaden-summary kill-buffer))
4086 (gnus-summary-auto-select-subject)
4087 ;; Show first unread article if requested.
4088 (if (and (not no-article)
4089 (not no-display)
4090 gnus-newsgroup-unreads
4091 gnus-auto-select-first)
4092 (progn
4093 (let ((art (gnus-summary-article-number)))
4094 (when (and art
4095 gnus-plugged
4096 (not (memq art gnus-newsgroup-undownloaded))
4097 (not (memq art gnus-newsgroup-downloadable)))
4098 (gnus-summary-goto-article art))))
4099 ;; Don't select any articles.
4100 (gnus-summary-position-point)
4101 (gnus-configure-windows 'summary 'force)
4102 (gnus-set-mode-line 'summary))
4103 (when (and gnus-auto-center-group
4104 (get-buffer-window gnus-group-buffer t))
4105 ;; Gotta use windows, because recenter does weird stuff if
4106 ;; the current buffer ain't the displayed window.
4107 (let ((owin (selected-window)))
4108 (select-window (get-buffer-window gnus-group-buffer t))
4109 (when (gnus-group-goto-group group)
4110 (recenter))
4111 (select-window owin)))
4112 ;; Mark this buffer as "prepared".
4113 (setq gnus-newsgroup-prepared t)
4114 (gnus-run-hooks 'gnus-summary-prepared-hook)
4115 (unless (gnus-ephemeral-group-p group)
4116 (gnus-group-update-group group nil t))
4117 t)))))
4119 (defun gnus-summary-auto-select-subject ()
4120 "Select the subject line on initial group entry."
4121 (goto-char (point-min))
4122 (cond
4123 ((eq gnus-auto-select-subject 'best)
4124 (gnus-summary-best-unread-subject))
4125 ((eq gnus-auto-select-subject 'unread)
4126 (gnus-summary-first-unread-subject))
4127 ((eq gnus-auto-select-subject 'unseen)
4128 (gnus-summary-first-unseen-subject))
4129 ((eq gnus-auto-select-subject 'unseen-or-unread)
4130 (gnus-summary-first-unseen-or-unread-subject))
4131 ((eq gnus-auto-select-subject 'first)
4132 ;; Do nothing.
4134 ((functionp gnus-auto-select-subject)
4135 (funcall gnus-auto-select-subject))))
4137 (defun gnus-summary-prepare ()
4138 "Generate the summary buffer."
4139 (interactive)
4140 (let ((inhibit-read-only t))
4141 (erase-buffer)
4142 (setq gnus-newsgroup-data nil
4143 gnus-newsgroup-data-reverse nil)
4144 (gnus-run-hooks 'gnus-summary-generate-hook)
4145 ;; Generate the buffer, either with threads or without.
4146 (when gnus-newsgroup-headers
4147 (gnus-summary-prepare-threads
4148 (if gnus-show-threads
4149 (gnus-sort-gathered-threads
4150 (funcall gnus-summary-thread-gathering-function
4151 (gnus-sort-threads
4152 (gnus-cut-threads (gnus-make-threads)))))
4153 ;; Unthreaded display.
4154 (gnus-sort-articles gnus-newsgroup-headers))))
4155 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4156 ;; Call hooks for modifying summary buffer.
4157 (goto-char (point-min))
4158 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4160 (defsubst gnus-general-simplify-subject (subject)
4161 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4162 (setq subject
4163 (cond
4164 ;; Truncate the subject.
4165 (gnus-simplify-subject-functions
4166 (gnus-map-function gnus-simplify-subject-functions subject))
4167 ((numberp gnus-summary-gather-subject-limit)
4168 (setq subject (gnus-simplify-subject-re subject))
4169 (if (> (length subject) gnus-summary-gather-subject-limit)
4170 (substring subject 0 gnus-summary-gather-subject-limit)
4171 subject))
4172 ;; Fuzzily simplify it.
4173 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4174 (gnus-simplify-subject-fuzzy subject))
4175 ;; Just remove the leading "Re:".
4177 (gnus-simplify-subject-re subject))))
4179 (if (and gnus-summary-gather-exclude-subject
4180 (string-match gnus-summary-gather-exclude-subject subject))
4181 nil ; This article shouldn't be gathered
4182 subject))
4184 (defun gnus-summary-simplify-subject-query ()
4185 "Query where the respool algorithm would put this article."
4186 (interactive)
4187 (gnus-summary-select-article)
4188 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4190 (defun gnus-gather-threads-by-subject (threads)
4191 "Gather threads by looking at Subject headers."
4192 (if (not gnus-summary-make-false-root)
4193 threads
4194 (let ((hashtb (gnus-make-hashtable 1024))
4195 (prev threads)
4196 (result threads)
4197 subject hthread whole-subject)
4198 (while threads
4199 (setq subject (gnus-general-simplify-subject
4200 (setq whole-subject (mail-header-subject
4201 (caar threads)))))
4202 (when subject
4203 (if (setq hthread (gnus-gethash subject hashtb))
4204 (progn
4205 ;; We enter a dummy root into the thread, if we
4206 ;; haven't done that already.
4207 (unless (stringp (caar hthread))
4208 (setcar hthread (list whole-subject (car hthread))))
4209 ;; We add this new gathered thread to this gathered
4210 ;; thread.
4211 (setcdr (car hthread)
4212 (nconc (cdar hthread) (list (car threads))))
4213 ;; Remove it from the list of threads.
4214 (setcdr prev (cdr threads))
4215 (setq threads prev))
4216 ;; Enter this thread into the hash table.
4217 (gnus-sethash subject
4218 (if gnus-summary-make-false-root-always
4219 (progn
4220 ;; If you want a dummy root above all
4221 ;; threads...
4222 (setcar threads (list whole-subject
4223 (car threads)))
4224 threads)
4225 threads)
4226 hashtb)))
4227 (setq prev threads)
4228 (setq threads (cdr threads)))
4229 result)))
4231 (defun gnus-gather-threads-by-references (threads)
4232 "Gather threads by looking at References headers."
4233 (let ((idhashtb (gnus-make-hashtable 1024))
4234 (thhashtb (gnus-make-hashtable 1024))
4235 (prev threads)
4236 (result threads)
4237 ids references id gthread gid entered ref)
4238 (while threads
4239 (when (setq references (mail-header-references (caar threads)))
4240 (setq id (mail-header-id (caar threads))
4241 ids (inline (gnus-split-references references))
4242 entered nil)
4243 (while (setq ref (pop ids))
4244 (setq ids (delete ref ids))
4245 (if (not (setq gid (gnus-gethash ref idhashtb)))
4246 (progn
4247 (gnus-sethash ref id idhashtb)
4248 (gnus-sethash id threads thhashtb))
4249 (setq gthread (gnus-gethash gid thhashtb))
4250 (unless entered
4251 ;; We enter a dummy root into the thread, if we
4252 ;; haven't done that already.
4253 (unless (stringp (caar gthread))
4254 (setcar gthread (list (mail-header-subject (caar gthread))
4255 (car gthread))))
4256 ;; We add this new gathered thread to this gathered
4257 ;; thread.
4258 (setcdr (car gthread)
4259 (nconc (cdar gthread) (list (car threads)))))
4260 ;; Add it into the thread hash table.
4261 (gnus-sethash id gthread thhashtb)
4262 (setq entered t)
4263 ;; Remove it from the list of threads.
4264 (setcdr prev (cdr threads))
4265 (setq threads prev))))
4266 (setq prev threads)
4267 (setq threads (cdr threads)))
4268 result))
4270 (defun gnus-sort-gathered-threads (threads)
4271 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4272 (let ((result threads))
4273 (while threads
4274 (when (stringp (caar threads))
4275 (setcdr (car threads)
4276 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4277 (setq threads (cdr threads)))
4278 result))
4280 (defun gnus-thread-loop-p (root thread)
4281 "Say whether ROOT is in THREAD."
4282 (let ((stack (list thread))
4283 (infloop 0)
4285 (while (setq thread (pop stack))
4286 (setq th (cdr thread))
4287 (while (and th
4288 (not (eq (caar th) root)))
4289 (pop th))
4290 (if th
4291 ;; We have found a loop.
4292 (let (ref-dep)
4293 (setcdr thread (delq (car th) (cdr thread)))
4294 (if (boundp (setq ref-dep (intern "none"
4295 gnus-newsgroup-dependencies)))
4296 (setcdr (symbol-value ref-dep)
4297 (nconc (cdr (symbol-value ref-dep))
4298 (list (car th))))
4299 (set ref-dep (list nil (car th))))
4300 (setq infloop 1
4301 stack nil))
4302 ;; Push all the subthreads onto the stack.
4303 (push (cdr thread) stack)))
4304 infloop))
4306 (defun gnus-make-threads ()
4307 "Go through the dependency hashtb and find the roots. Return all threads."
4308 (let (threads)
4309 (while (catch 'infloop
4310 (mapatoms
4311 (lambda (refs)
4312 ;; Deal with self-referencing References loops.
4313 (when (and (car (symbol-value refs))
4314 (not (zerop
4315 (apply
4317 (mapcar
4318 (lambda (thread)
4319 (gnus-thread-loop-p
4320 (car (symbol-value refs)) thread))
4321 (cdr (symbol-value refs)))))))
4322 (setq threads nil)
4323 (throw 'infloop t))
4324 (unless (car (symbol-value refs))
4325 ;; These threads do not refer back to any other
4326 ;; articles, so they're roots.
4327 (setq threads (append (cdr (symbol-value refs)) threads))))
4328 gnus-newsgroup-dependencies)))
4329 threads))
4331 ;; Build the thread tree.
4332 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4333 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4335 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4336 if it was already present.
4338 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4339 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4340 Message-IDs will be renamed to a unique Message-ID before being
4341 entered.
4343 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4344 (let* ((id (mail-header-id header))
4345 (id-dep (and id (intern id dependencies)))
4346 parent-id ref ref-dep ref-header replaced)
4347 ;; Enter this `header' in the `dependencies' table.
4348 (cond
4349 ((not id-dep)
4350 (setq header nil))
4351 ;; The first two cases do the normal part: enter a new `header'
4352 ;; in the `dependencies' table.
4353 ((not (boundp id-dep))
4354 (set id-dep (list header)))
4355 ((null (car (symbol-value id-dep)))
4356 (setcar (symbol-value id-dep) header))
4358 ;; From here the `header' was already present in the
4359 ;; `dependencies' table.
4360 (force-new
4361 ;; Overrides an existing entry;
4362 ;; just set the header part of the entry.
4363 (setcar (symbol-value id-dep) header)
4364 (setq replaced t))
4366 ;; Renames the existing `header' to a unique Message-ID.
4367 ((not gnus-summary-ignore-duplicates)
4368 ;; An article with this Message-ID has already been seen.
4369 ;; We rename the Message-ID.
4370 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4371 (list header))
4372 (mail-header-set-id header id))
4374 ;; The last case ignores an existing entry, except it adds any
4375 ;; additional Xrefs (in case the two articles came from different
4376 ;; servers.
4377 ;; Also sets `header' to `nil' meaning that the `dependencies'
4378 ;; table was *not* modified.
4380 (mail-header-set-xref
4381 (car (symbol-value id-dep))
4382 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4384 (or (mail-header-xref header) "")))
4385 (setq header nil)))
4387 (when (and header (not replaced))
4388 ;; First check that we are not creating a References loop.
4389 (setq parent-id (gnus-parent-id (mail-header-references header)))
4390 (setq ref parent-id)
4391 (while (and ref
4392 (setq ref-dep (intern-soft ref dependencies))
4393 (boundp ref-dep)
4394 (setq ref-header (car (symbol-value ref-dep))))
4395 (if (string= id ref)
4396 ;; Yuk! This is a reference loop. Make the article be a
4397 ;; root article.
4398 (progn
4399 (mail-header-set-references (car (symbol-value id-dep)) "none")
4400 (setq ref nil)
4401 (setq parent-id nil))
4402 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4403 (setq ref-dep (intern (or parent-id "none") dependencies))
4404 (if (boundp ref-dep)
4405 (setcdr (symbol-value ref-dep)
4406 (nconc (cdr (symbol-value ref-dep))
4407 (list (symbol-value id-dep))))
4408 (set ref-dep (list nil (symbol-value id-dep)))))
4409 header))
4411 (defun gnus-extract-message-id-from-in-reply-to (string)
4412 (if (string-match "<[^>]+>" string)
4413 (substring string (match-beginning 0) (match-end 0))
4414 nil))
4416 (defun gnus-build-sparse-threads ()
4417 (let ((headers gnus-newsgroup-headers)
4418 (mail-parse-charset gnus-newsgroup-charset)
4419 (gnus-summary-ignore-duplicates t)
4420 header references generation relations
4421 subject child end new-child date)
4422 ;; First we create an alist of generations/relations, where
4423 ;; generations is how much we trust the relation, and the relation
4424 ;; is parent/child.
4425 (gnus-message 7 "Making sparse threads...")
4426 (save-excursion
4427 (nnheader-set-temp-buffer " *gnus sparse threads*")
4428 (while (setq header (pop headers))
4429 (when (and (setq references (mail-header-references header))
4430 (not (string= references "")))
4431 (insert references)
4432 (setq child (mail-header-id header)
4433 subject (mail-header-subject header)
4434 date (mail-header-date header)
4435 generation 0)
4436 (while (search-backward ">" nil t)
4437 (setq end (1+ (point)))
4438 (when (search-backward "<" nil t)
4439 (setq new-child (buffer-substring (point) end))
4440 (push (list (incf generation)
4441 child (setq child new-child)
4442 subject date)
4443 relations)))
4444 (when child
4445 (push (list (1+ generation) child nil subject) relations))
4446 (erase-buffer)))
4447 (kill-buffer (current-buffer)))
4448 ;; Sort over trustworthiness.
4449 (dolist (relation (sort relations 'car-less-than-car))
4450 (when (gnus-dependencies-add-header
4451 (make-full-mail-header
4452 gnus-reffed-article-number
4453 (nth 3 relation) "" (or (nth 4 relation) "")
4454 (nth 1 relation)
4455 (or (nth 2 relation) "") 0 0 "")
4456 gnus-newsgroup-dependencies nil)
4457 (push gnus-reffed-article-number gnus-newsgroup-limit)
4458 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4459 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4460 gnus-newsgroup-reads)
4461 (decf gnus-reffed-article-number)))
4462 (gnus-message 7 "Making sparse threads...done")))
4464 (defun gnus-build-old-threads ()
4465 ;; Look at all the articles that refer back to old articles, and
4466 ;; fetch the headers for the articles that aren't there. This will
4467 ;; build complete threads - if the roots haven't been expired by the
4468 ;; server, that is.
4469 (let ((mail-parse-charset gnus-newsgroup-charset)
4470 id heads)
4471 (mapatoms
4472 (lambda (refs)
4473 (when (not (car (symbol-value refs)))
4474 (setq heads (cdr (symbol-value refs)))
4475 (while heads
4476 (if (memq (mail-header-number (caar heads))
4477 gnus-newsgroup-dormant)
4478 (setq heads (cdr heads))
4479 (setq id (symbol-name refs))
4480 (while (and (setq id (gnus-build-get-header id))
4481 (not (car (gnus-id-to-thread id)))))
4482 (setq heads nil)))))
4483 gnus-newsgroup-dependencies)))
4485 (defsubst gnus-remove-odd-characters (string)
4486 "Translate STRING into something that doesn't contain weird characters."
4487 (mm-subst-char-in-string
4488 ?\r ?\-
4489 (mm-subst-char-in-string ?\n ?\- string t) t))
4491 ;; This function has to be called with point after the article number
4492 ;; on the beginning of the line.
4493 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4494 (let ((eol (point-at-eol))
4495 (buffer (current-buffer))
4496 header references in-reply-to)
4498 ;; overview: [num subject from date id refs chars lines misc]
4499 (unwind-protect
4500 (let (x)
4501 (narrow-to-region (point) eol)
4502 (unless (eobp)
4503 (forward-char))
4505 (setq header
4506 (make-full-mail-header
4507 number ; number
4508 (condition-case () ; subject
4509 (gnus-remove-odd-characters
4510 (funcall gnus-decode-encoded-word-function
4511 (setq x (nnheader-nov-field))))
4512 (error x))
4513 (condition-case () ; from
4514 (gnus-remove-odd-characters
4515 (funcall gnus-decode-encoded-address-function
4516 (setq x (nnheader-nov-field))))
4517 (error x))
4518 (nnheader-nov-field) ; date
4519 (nnheader-nov-read-message-id number) ; id
4520 (setq references (nnheader-nov-field)) ; refs
4521 (nnheader-nov-read-integer) ; chars
4522 (nnheader-nov-read-integer) ; lines
4523 (unless (eobp)
4524 (if (looking-at "Xref: ")
4525 (goto-char (match-end 0)))
4526 (nnheader-nov-field)) ; Xref
4527 (nnheader-nov-parse-extra)))) ; extra
4529 (widen))
4531 (when (and (string= references "")
4532 (setq in-reply-to (mail-header-extra header))
4533 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4534 (mail-header-set-references
4535 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4537 (when gnus-alter-header-function
4538 (funcall gnus-alter-header-function header))
4539 (gnus-dependencies-add-header header dependencies force-new)))
4541 (defun gnus-build-get-header (id)
4542 "Look through the buffer of NOV lines and find the header to ID.
4543 Enter this line into the dependencies hash table, and return
4544 the id of the parent article (if any)."
4545 (let ((deps gnus-newsgroup-dependencies)
4546 found header)
4547 (prog1
4548 (with-current-buffer nntp-server-buffer
4549 (let ((case-fold-search nil))
4550 (goto-char (point-min))
4551 (while (and (not found)
4552 (search-forward id nil t))
4553 (beginning-of-line)
4554 (setq found (looking-at
4555 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4556 (regexp-quote id))))
4557 (or found (beginning-of-line 2)))
4558 (when found
4559 (beginning-of-line)
4560 (and
4561 (setq header (gnus-nov-parse-line
4562 (read (current-buffer)) deps))
4563 (gnus-parent-id (mail-header-references header))))))
4564 (when header
4565 (let ((number (mail-header-number header)))
4566 (push number gnus-newsgroup-limit)
4567 (push header gnus-newsgroup-headers)
4568 (if (memq number gnus-newsgroup-unselected)
4569 (progn
4570 (setq gnus-newsgroup-unreads
4571 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4572 number))
4573 (setq gnus-newsgroup-unselected
4574 (delq number gnus-newsgroup-unselected)))
4575 (push number gnus-newsgroup-ancient)))))))
4577 (defun gnus-build-all-threads ()
4578 "Read all the headers."
4579 (let ((gnus-summary-ignore-duplicates t)
4580 (mail-parse-charset gnus-newsgroup-charset)
4581 (dependencies gnus-newsgroup-dependencies)
4582 header article)
4583 (with-current-buffer nntp-server-buffer
4584 (let ((case-fold-search nil))
4585 (goto-char (point-min))
4586 (while (not (eobp))
4587 (ignore-errors
4588 (setq article (read (current-buffer))
4589 header (gnus-nov-parse-line article dependencies t)))
4590 (when header
4591 (with-current-buffer gnus-summary-buffer
4592 (push header gnus-newsgroup-headers)
4593 (if (memq (setq article (mail-header-number header))
4594 gnus-newsgroup-unselected)
4595 (progn
4596 (setq gnus-newsgroup-unreads
4597 (gnus-add-to-sorted-list
4598 gnus-newsgroup-unreads article))
4599 (setq gnus-newsgroup-unselected
4600 (delq article gnus-newsgroup-unselected)))
4601 (push article gnus-newsgroup-ancient)))
4602 (forward-line 1)))))))
4604 (defun gnus-summary-update-article-line (article header)
4605 "Update the line for ARTICLE using HEADER."
4606 (let* ((id (mail-header-id header))
4607 (thread (gnus-id-to-thread id)))
4608 (unless thread
4609 (error "Article in no thread"))
4610 ;; Update the thread.
4611 (setcar thread header)
4612 (gnus-summary-goto-subject article)
4613 (let* ((datal (gnus-data-find-list article))
4614 (data (car datal))
4615 (inhibit-read-only t)
4616 (level (gnus-summary-thread-level)))
4617 (gnus-delete-line)
4618 (let ((inserted (- (point)
4619 (progn
4620 (gnus-summary-insert-line
4621 header level nil
4622 (memq article gnus-newsgroup-undownloaded)
4623 (gnus-article-mark article)
4624 (memq article gnus-newsgroup-replied)
4625 (memq article gnus-newsgroup-expirable)
4626 ;; Only insert the Subject string when it's different
4627 ;; from the previous Subject string.
4628 (if (and
4629 gnus-show-threads
4630 (gnus-subject-equal
4631 (condition-case ()
4632 (mail-header-subject
4633 (gnus-data-header
4634 (cadr
4635 (gnus-data-find-list
4636 article
4637 (gnus-data-list t)))))
4638 ;; Error on the side of excessive subjects.
4639 (error ""))
4640 (mail-header-subject header)))
4642 (mail-header-subject header))
4643 nil (cdr (assq article gnus-newsgroup-scored))
4644 (memq article gnus-newsgroup-processable))
4645 (point)))))
4646 (when (cdr datal)
4647 (gnus-data-update-list
4648 (cdr datal)
4649 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4651 (defun gnus-summary-update-article (article &optional iheader)
4652 "Update ARTICLE in the summary buffer."
4653 (set-buffer gnus-summary-buffer)
4654 (let* ((header (gnus-summary-article-header article))
4655 (id (mail-header-id header))
4656 (data (gnus-data-find article))
4657 (thread (gnus-id-to-thread id))
4658 (references (mail-header-references header))
4659 (parent
4660 (gnus-id-to-thread
4661 (or (gnus-parent-id
4662 (when (and references
4663 (not (equal "" references)))
4664 references))
4665 "none")))
4666 (inhibit-read-only t)
4667 (old (car thread)))
4668 (when thread
4669 (unless iheader
4670 (setcar thread nil)
4671 (when parent
4672 (delq thread parent)))
4673 (if (gnus-summary-insert-subject id header)
4674 ;; Set the (possibly) new article number in the data structure.
4675 (gnus-data-set-number data (gnus-id-to-article id))
4676 (setcar thread old)
4677 nil))))
4679 (defun gnus-rebuild-thread (id &optional line)
4680 "Rebuild the thread containing ID.
4681 If LINE, insert the rebuilt thread starting on line LINE."
4682 (let ((inhibit-read-only t)
4683 old-pos current thread data)
4684 (if (not gnus-show-threads)
4685 (setq thread (list (car (gnus-id-to-thread id))))
4686 ;; Get the thread this article is part of.
4687 (setq thread (gnus-remove-thread id)))
4688 (setq old-pos (point-at-bol))
4689 (setq current (save-excursion
4690 (and (re-search-backward "[\r\n]" nil t)
4691 (gnus-summary-article-number))))
4692 ;; If this is a gathered thread, we have to go some re-gathering.
4693 (when (stringp (car thread))
4694 (let ((subject (car thread))
4695 roots thr)
4696 (setq thread (cdr thread))
4697 (while thread
4698 (unless (memq (setq thr (gnus-id-to-thread
4699 (gnus-root-id
4700 (mail-header-id (caar thread)))))
4701 roots)
4702 (push thr roots))
4703 (setq thread (cdr thread)))
4704 ;; We now have all (unique) roots.
4705 (if (= (length roots) 1)
4706 ;; All the loose roots are now one solid root.
4707 (setq thread (car roots))
4708 (setq thread (cons subject (gnus-sort-threads roots))))))
4709 (let (threads)
4710 ;; We then insert this thread into the summary buffer.
4711 (when line
4712 (goto-char (point-min))
4713 (forward-line (1- line)))
4714 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4715 (if gnus-show-threads
4716 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4717 (gnus-summary-prepare-unthreaded thread))
4718 (setq data (nreverse gnus-newsgroup-data))
4719 (setq threads gnus-newsgroup-threads))
4720 ;; We splice the new data into the data structure.
4721 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4722 ;;!!! then we want to insert at the beginning of the buffer.
4723 ;;!!! That happens to be true with Gnus now, but that may
4724 ;;!!! change in the future. Perhaps.
4725 (gnus-data-enter-list
4726 (if line nil current) data (- (point) old-pos))
4727 (setq gnus-newsgroup-threads
4728 (nconc threads gnus-newsgroup-threads))
4729 (gnus-data-compute-positions))))
4731 (defun gnus-number-to-header (number)
4732 "Return the header for article NUMBER."
4733 (let ((headers gnus-newsgroup-headers))
4734 (while (and headers
4735 (not (= number (mail-header-number (car headers)))))
4736 (pop headers))
4737 (when headers
4738 (car headers))))
4740 (defun gnus-parent-headers (in-headers &optional generation)
4741 "Return the headers of the GENERATIONth parent of HEADERS."
4742 (unless generation
4743 (setq generation 1))
4744 (let ((parent t)
4745 (headers in-headers)
4746 references)
4747 (while (and parent
4748 (not (zerop generation))
4749 (setq references (mail-header-references headers)))
4750 (setq headers (if (and references
4751 (setq parent (gnus-parent-id references)))
4752 (car (gnus-id-to-thread parent))
4753 nil))
4754 (decf generation))
4755 (and (not (eq headers in-headers))
4756 headers)))
4758 (defun gnus-id-to-thread (id)
4759 "Return the (sub-)thread where ID appears."
4760 (gnus-gethash id gnus-newsgroup-dependencies))
4762 (defun gnus-id-to-article (id)
4763 "Return the article number of ID."
4764 (let ((thread (gnus-id-to-thread id)))
4765 (when (and thread
4766 (car thread))
4767 (mail-header-number (car thread)))))
4769 (defun gnus-id-to-header (id)
4770 "Return the article headers of ID."
4771 (car (gnus-id-to-thread id)))
4773 (defun gnus-article-displayed-root-p (article)
4774 "Say whether ARTICLE is a root(ish) article."
4775 (let ((level (gnus-summary-thread-level article))
4776 (refs (mail-header-references (gnus-summary-article-header article)))
4777 particle)
4778 (cond
4779 ((null level) nil)
4780 ((zerop level) t)
4781 ((null refs) t)
4782 ((null (gnus-parent-id refs)) t)
4783 ((and (= 1 level)
4784 (null (setq particle (gnus-id-to-article
4785 (gnus-parent-id refs))))
4786 (null (gnus-summary-thread-level particle)))))))
4788 (defun gnus-root-id (id)
4789 "Return the id of the root of the thread where ID appears."
4790 (let (last-id prev)
4791 (while (and id (setq prev (car (gnus-id-to-thread id))))
4792 (setq last-id id
4793 id (gnus-parent-id (mail-header-references prev))))
4794 last-id))
4796 (defun gnus-articles-in-thread (thread)
4797 "Return the list of articles in THREAD."
4798 (cons (mail-header-number (car thread))
4799 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4801 (defun gnus-remove-thread (id &optional dont-remove)
4802 "Remove the thread that has ID in it."
4803 (let (headers thread last-id)
4804 ;; First go up in this thread until we find the root.
4805 (setq last-id (gnus-root-id id)
4806 headers (message-flatten-list (gnus-id-to-thread last-id)))
4807 ;; We have now found the real root of this thread. It might have
4808 ;; been gathered into some loose thread, so we have to search
4809 ;; through the threads to find the thread we wanted.
4810 (let ((threads gnus-newsgroup-threads)
4811 sub)
4812 (while threads
4813 (setq sub (car threads))
4814 (if (stringp (car sub))
4815 ;; This is a gathered thread, so we look at the roots
4816 ;; below it to find whether this article is in this
4817 ;; gathered root.
4818 (progn
4819 (setq sub (cdr sub))
4820 (while sub
4821 (when (member (caar sub) headers)
4822 (setq thread (car threads)
4823 threads nil
4824 sub nil))
4825 (setq sub (cdr sub))))
4826 ;; It's an ordinary thread, so we check it.
4827 (when (eq (car sub) (car headers))
4828 (setq thread sub
4829 threads nil)))
4830 (setq threads (cdr threads)))
4831 ;; If this article is in no thread, then it's a root.
4832 (if thread
4833 (unless dont-remove
4834 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4835 (setq thread (gnus-id-to-thread last-id)))
4836 (when thread
4837 (prog1
4838 thread ; We return this thread.
4839 (unless dont-remove
4840 (if (stringp (car thread))
4841 (progn
4842 ;; If we use dummy roots, then we have to remove the
4843 ;; dummy root as well.
4844 (when (eq gnus-summary-make-false-root 'dummy)
4845 ;; We go to the dummy root by going to
4846 ;; the first sub-"thread", and then one line up.
4847 (gnus-summary-goto-article
4848 (mail-header-number (caadr thread)))
4849 (forward-line -1)
4850 (gnus-delete-line)
4851 (gnus-data-compute-positions))
4852 (setq thread (cdr thread))
4853 (while thread
4854 (gnus-remove-thread-1 (car thread))
4855 (setq thread (cdr thread))))
4856 (gnus-remove-thread-1 thread))))))))
4858 (defun gnus-remove-thread-1 (thread)
4859 "Remove the thread THREAD recursively."
4860 (let ((number (mail-header-number (pop thread)))
4862 (setq thread (reverse thread))
4863 (while thread
4864 (gnus-remove-thread-1 (pop thread)))
4865 (when (setq d (gnus-data-find number))
4866 (goto-char (gnus-data-pos d))
4867 (gnus-summary-show-thread)
4868 (gnus-data-remove
4869 number
4870 (- (point-at-bol)
4871 (prog1
4872 (1+ (point-at-eol))
4873 (gnus-delete-line)))))))
4875 (defun gnus-sort-threads-recursive (threads func)
4876 ;; Responsible for sorting the root articles of threads.
4877 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4878 'gnus-thread-sort-functions)
4879 func
4880 (gnus-make-sort-function
4881 gnus-subthread-sort-functions))))
4882 (sort (mapcar (lambda (thread)
4883 (cons (car thread)
4884 (and (cdr thread)
4885 (gnus-sort-subthreads-recursive
4886 (cdr thread) subthread-sort-func))))
4887 threads) func)))
4889 (defun gnus-sort-subthreads-recursive (threads func)
4890 ;; Responsible for sorting subthreads.
4891 (sort (mapcar (lambda (thread)
4892 (cons (car thread)
4893 (and (cdr thread)
4894 (gnus-sort-subthreads-recursive (cdr thread) func))))
4895 threads) func))
4897 (defun gnus-sort-threads-loop (threads func)
4898 (let* ((superthread (cons nil threads))
4899 (stack (list (cons superthread threads)))
4900 remaining-threads thread)
4901 (while stack
4902 (setq remaining-threads (cdr (car stack)))
4903 (if remaining-threads
4904 (progn (setq thread (car remaining-threads))
4905 (setcdr (car stack) (cdr remaining-threads))
4906 (if (cdr thread)
4907 (push (cons thread (cdr thread)) stack)))
4908 (setq thread (caar stack))
4909 (setcdr thread (sort (cdr thread) func))
4910 (pop stack)))
4911 (cdr superthread)))
4913 (defun gnus-sort-threads (threads)
4914 "Sort THREADS."
4915 (if (not gnus-thread-sort-functions)
4916 threads
4917 (gnus-message 8 "Sorting threads...")
4918 (prog1
4919 (condition-case nil
4920 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4921 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4922 (gnus-sort-threads-recursive threads sort-func))
4923 ;; Even after binding max-lisp-eval-depth, the recursive
4924 ;; sorter might fail for very long threads. In that case,
4925 ;; try using a (less well-tested) non-recursive sorter.
4926 (error (gnus-message 9 "Sorting threads with loop...")
4927 (gnus-sort-threads-loop
4928 threads (gnus-make-sort-function
4929 gnus-thread-sort-functions))))
4930 (gnus-message 8 "Sorting threads...done"))))
4932 (defun gnus-sort-articles (articles)
4933 "Sort ARTICLES."
4934 (when gnus-article-sort-functions
4935 (gnus-message 7 "Sorting articles...")
4936 (prog1
4937 (setq gnus-newsgroup-headers
4938 (sort articles (gnus-make-sort-function
4939 gnus-article-sort-functions)))
4940 (gnus-message 7 "Sorting articles...done"))))
4942 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4943 (defmacro gnus-thread-header (thread)
4944 "Return header of first article in THREAD.
4945 Note that THREAD must never, ever be anything else than a variable -
4946 using some other form will lead to serious barfage."
4947 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4948 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4949 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4950 (vector thread) 2))
4952 (defsubst gnus-article-sort-by-number (h1 h2)
4953 "Sort articles by article number."
4954 (< (mail-header-number h1)
4955 (mail-header-number h2)))
4957 (defun gnus-thread-sort-by-number (h1 h2)
4958 "Sort threads by root article number."
4959 (gnus-article-sort-by-number
4960 (gnus-thread-header h1) (gnus-thread-header h2)))
4962 (defsubst gnus-article-sort-by-random (h1 h2)
4963 "Sort articles randomly."
4964 (zerop (random 2)))
4966 (defun gnus-thread-sort-by-random (h1 h2)
4967 "Sort threads randomly."
4968 (gnus-article-sort-by-random
4969 (gnus-thread-header h1) (gnus-thread-header h2)))
4971 (defsubst gnus-article-sort-by-lines (h1 h2)
4972 "Sort articles by article Lines header."
4973 (< (mail-header-lines h1)
4974 (mail-header-lines h2)))
4976 (defun gnus-thread-sort-by-lines (h1 h2)
4977 "Sort threads by root article Lines header."
4978 (gnus-article-sort-by-lines
4979 (gnus-thread-header h1) (gnus-thread-header h2)))
4981 (defsubst gnus-article-sort-by-chars (h1 h2)
4982 "Sort articles by octet length."
4983 (< (mail-header-chars h1)
4984 (mail-header-chars h2)))
4986 (defun gnus-thread-sort-by-chars (h1 h2)
4987 "Sort threads by root article octet length."
4988 (gnus-article-sort-by-chars
4989 (gnus-thread-header h1) (gnus-thread-header h2)))
4991 (defsubst gnus-article-sort-by-author (h1 h2)
4992 "Sort articles by root author."
4993 (gnus-string<
4994 (let ((extract (funcall
4995 gnus-extract-address-components
4996 (mail-header-from h1))))
4997 (or (car extract) (cadr extract) ""))
4998 (let ((extract (funcall
4999 gnus-extract-address-components
5000 (mail-header-from h2))))
5001 (or (car extract) (cadr extract) ""))))
5003 (defun gnus-thread-sort-by-author (h1 h2)
5004 "Sort threads by root author."
5005 (gnus-article-sort-by-author
5006 (gnus-thread-header h1) (gnus-thread-header h2)))
5008 (defsubst gnus-article-sort-by-recipient (h1 h2)
5009 "Sort articles by recipient."
5010 (gnus-string<
5011 (let ((extract (funcall
5012 gnus-extract-address-components
5013 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5014 (or (car extract) (cadr extract)))
5015 (let ((extract (funcall
5016 gnus-extract-address-components
5017 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5018 (or (car extract) (cadr extract)))))
5020 (defun gnus-thread-sort-by-recipient (h1 h2)
5021 "Sort threads by root recipient."
5022 (gnus-article-sort-by-recipient
5023 (gnus-thread-header h1) (gnus-thread-header h2)))
5025 (defsubst gnus-article-sort-by-subject (h1 h2)
5026 "Sort articles by root subject."
5027 (gnus-string<
5028 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5029 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5031 (defun gnus-thread-sort-by-subject (h1 h2)
5032 "Sort threads by root subject."
5033 (gnus-article-sort-by-subject
5034 (gnus-thread-header h1) (gnus-thread-header h2)))
5036 (defsubst gnus-article-sort-by-date (h1 h2)
5037 "Sort articles by root article date."
5038 (time-less-p
5039 (gnus-date-get-time (mail-header-date h1))
5040 (gnus-date-get-time (mail-header-date h2))))
5042 (defun gnus-thread-sort-by-date (h1 h2)
5043 "Sort threads by root article date."
5044 (gnus-article-sort-by-date
5045 (gnus-thread-header h1) (gnus-thread-header h2)))
5047 (defsubst gnus-article-sort-by-score (h1 h2)
5048 "Sort articles by root article score.
5049 Unscored articles will be counted as having a score of zero."
5050 (> (or (cdr (assq (mail-header-number h1)
5051 gnus-newsgroup-scored))
5052 gnus-summary-default-score 0)
5053 (or (cdr (assq (mail-header-number h2)
5054 gnus-newsgroup-scored))
5055 gnus-summary-default-score 0)))
5057 (defun gnus-thread-sort-by-score (h1 h2)
5058 "Sort threads by root article score."
5059 (gnus-article-sort-by-score
5060 (gnus-thread-header h1) (gnus-thread-header h2)))
5062 (defun gnus-thread-sort-by-total-score (h1 h2)
5063 "Sort threads by the sum of all scores in the thread.
5064 Unscored articles will be counted as having a score of zero."
5065 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5067 (defun gnus-thread-total-score (thread)
5068 ;; This function find the total score of THREAD.
5069 (cond
5070 ((null thread)
5072 ((consp thread)
5073 (if (stringp (car thread))
5074 (apply gnus-thread-score-function 0
5075 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5076 (gnus-thread-total-score-1 thread)))
5078 (gnus-thread-total-score-1 (list thread)))))
5080 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5081 "Sort articles by number."
5082 (gnus-article-sort-by-number h1 h2))
5084 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5085 "Sort threads such that the thread with the most recently arrived article comes first."
5086 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5088 (defun gnus-thread-highest-number (thread)
5089 "Return the highest article number in THREAD."
5090 (apply 'max (mapcar (lambda (header)
5091 (mail-header-number header))
5092 (message-flatten-list thread))))
5094 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5095 "Sort articles by number."
5096 (gnus-article-sort-by-date h1 h2))
5098 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5099 "Sort threads such that the thread with the most recently dated article comes first."
5100 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5102 ; Since this is called not only to sort the top-level threads, but
5103 ; also in recursive sorts to order the articles within a thread, each
5104 ; article will be processed many times. Thus it speeds things up
5105 ; quite a bit to use gnus-date-get-time, which caches the time value.
5106 (defun gnus-thread-latest-date (thread)
5107 "Return the highest article date in THREAD."
5108 (apply 'max
5109 (mapcar (lambda (header) (gnus-float-time
5110 (gnus-date-get-time
5111 (mail-header-date header))))
5112 (message-flatten-list thread))))
5114 (defun gnus-thread-total-score-1 (root)
5115 ;; This function find the total score of the thread below ROOT.
5116 (setq root (car root))
5117 (apply gnus-thread-score-function
5118 (or (append
5119 (mapcar 'gnus-thread-total-score
5120 (cdr (gnus-id-to-thread (mail-header-id root))))
5121 (when (> (mail-header-number root) 0)
5122 (list (or (cdr (assq (mail-header-number root)
5123 gnus-newsgroup-scored))
5124 gnus-summary-default-score 0))))
5125 (list gnus-summary-default-score)
5126 '(0))))
5128 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5129 (defvar gnus-tmp-prev-subject nil)
5130 (defvar gnus-tmp-false-parent nil)
5131 (defvar gnus-tmp-root-expunged nil)
5132 (defvar gnus-tmp-dummy-line nil)
5134 (defun gnus-extra-header (type &optional header)
5135 "Return the extra header of TYPE."
5136 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5137 ""))
5139 (defvar gnus-tmp-thread-tree-header-string "")
5141 (defcustom gnus-sum-thread-tree-root "> "
5142 "With %B spec, used for the root of a thread.
5143 If nil, use subject instead."
5144 :version "22.1"
5145 :type '(radio (const :format "%v " nil) string)
5146 :group 'gnus-thread)
5148 (defcustom gnus-sum-thread-tree-false-root "> "
5149 "With %B spec, used for a false root of a thread.
5150 If nil, use subject instead."
5151 :version "22.1"
5152 :type '(radio (const :format "%v " nil) string)
5153 :group 'gnus-thread)
5155 (defcustom gnus-sum-thread-tree-single-indent ""
5156 "With %B spec, used for a thread with just one message.
5157 If nil, use subject instead."
5158 :version "22.1"
5159 :type '(radio (const :format "%v " nil) string)
5160 :group 'gnus-thread)
5162 (defcustom gnus-sum-thread-tree-vertical "| "
5163 "With %B spec, used for drawing a vertical line."
5164 :version "22.1"
5165 :type 'string
5166 :group 'gnus-thread)
5168 (defcustom gnus-sum-thread-tree-indent " "
5169 "With %B spec, used for indenting."
5170 :version "22.1"
5171 :type 'string
5172 :group 'gnus-thread)
5174 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5175 "With %B spec, used for a leaf with brothers."
5176 :version "22.1"
5177 :type 'string
5178 :group 'gnus-thread)
5180 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5181 "With %B spec, used for a leaf without brothers."
5182 :version "22.1"
5183 :type 'string
5184 :group 'gnus-thread)
5186 (defcustom gnus-summary-display-while-building nil
5187 "If non-nil, show and update the summary buffer as it's being built.
5188 If the value is t, update the buffer after every line is inserted. If
5189 the value is an integer (N), update the display every N lines."
5190 :version "22.1"
5191 :group 'gnus-thread
5192 :type '(choice (const :tag "off" nil)
5193 number
5194 (const :tag "frequently" t)))
5196 (defun gnus-summary-prepare-threads (threads)
5197 "Prepare summary buffer from THREADS and indentation LEVEL.
5198 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5199 or a straight list of headers."
5200 (gnus-message 7 "Generating summary...")
5202 (setq gnus-newsgroup-threads threads)
5203 (beginning-of-line)
5205 (let ((gnus-tmp-level 0)
5206 (default-score (or gnus-summary-default-score 0))
5207 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5208 (building-line-count gnus-summary-display-while-building)
5209 (building-count (integerp gnus-summary-display-while-building))
5210 thread number subject stack state gnus-tmp-gathered beg-match
5211 new-roots gnus-tmp-new-adopts thread-end simp-subject
5212 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5213 gnus-tmp-replied gnus-tmp-subject-or-nil
5214 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5215 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5216 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5217 tree-stack)
5219 (setq gnus-tmp-prev-subject nil
5220 gnus-tmp-thread-tree-header-string "")
5222 (if (vectorp (car threads))
5223 ;; If this is a straight (sic) list of headers, then a
5224 ;; threaded summary display isn't required, so we just create
5225 ;; an unthreaded one.
5226 (gnus-summary-prepare-unthreaded threads)
5228 ;; Do the threaded display.
5230 (if gnus-summary-display-while-building
5231 (switch-to-buffer (buffer-name)))
5232 (while (or threads stack gnus-tmp-new-adopts new-roots)
5234 (if (and (= gnus-tmp-level 0)
5235 (or (not stack)
5236 (= (caar stack) 0))
5237 (not gnus-tmp-false-parent)
5238 (or gnus-tmp-new-adopts new-roots))
5239 (if gnus-tmp-new-adopts
5240 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5241 thread (list (car gnus-tmp-new-adopts))
5242 gnus-tmp-header (caar thread)
5243 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5244 (when new-roots
5245 (setq thread (list (car new-roots))
5246 gnus-tmp-header (caar thread)
5247 new-roots (cdr new-roots))))
5249 (if threads
5250 ;; If there are some threads, we do them before the
5251 ;; threads on the stack.
5252 (setq thread threads
5253 gnus-tmp-header (caar thread))
5254 ;; There were no current threads, so we pop something off
5255 ;; the stack.
5256 (setq state (car stack)
5257 gnus-tmp-level (car state)
5258 tree-stack (cadr state)
5259 thread (caddr state)
5260 stack (cdr stack)
5261 gnus-tmp-header (caar thread))))
5263 (setq gnus-tmp-false-parent nil)
5264 (setq gnus-tmp-root-expunged nil)
5265 (setq thread-end nil)
5267 (if (stringp gnus-tmp-header)
5268 ;; The header is a dummy root.
5269 (cond
5270 ((eq gnus-summary-make-false-root 'adopt)
5271 ;; We let the first article adopt the rest.
5272 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5273 (cddar thread)))
5274 (setq gnus-tmp-gathered
5275 (nconc (mapcar
5276 (lambda (h) (mail-header-number (car h)))
5277 (cddar thread))
5278 gnus-tmp-gathered))
5279 (setq thread (cons (list (caar thread)
5280 (cadar thread))
5281 (cdr thread)))
5282 (setq gnus-tmp-level -1
5283 gnus-tmp-false-parent t))
5284 ((eq gnus-summary-make-false-root 'empty)
5285 ;; We print adopted articles with empty subject fields.
5286 (setq gnus-tmp-gathered
5287 (nconc (mapcar
5288 (lambda (h) (mail-header-number (car h)))
5289 (cddar thread))
5290 gnus-tmp-gathered))
5291 (setq gnus-tmp-level -1))
5292 ((eq gnus-summary-make-false-root 'dummy)
5293 ;; We remember that we probably want to output a dummy
5294 ;; root.
5295 (setq gnus-tmp-dummy-line gnus-tmp-header)
5296 (setq gnus-tmp-prev-subject gnus-tmp-header))
5298 ;; We do not make a root for the gathered
5299 ;; sub-threads at all.
5300 (setq gnus-tmp-level -1)))
5302 (setq number (mail-header-number gnus-tmp-header)
5303 subject (mail-header-subject gnus-tmp-header)
5304 simp-subject (gnus-simplify-subject-fully subject))
5306 (cond
5307 ;; If the thread has changed subject, we might want to make
5308 ;; this subthread into a root.
5309 ((and (null gnus-thread-ignore-subject)
5310 (not (zerop gnus-tmp-level))
5311 gnus-tmp-prev-subject
5312 (not (string= gnus-tmp-prev-subject simp-subject)))
5313 (setq new-roots (nconc new-roots (list (car thread)))
5314 thread-end t
5315 gnus-tmp-header nil))
5316 ;; If the article lies outside the current limit,
5317 ;; then we do not display it.
5318 ((not (memq number gnus-newsgroup-limit))
5319 (setq gnus-tmp-gathered
5320 (nconc (mapcar
5321 (lambda (h) (mail-header-number (car h)))
5322 (cdar thread))
5323 gnus-tmp-gathered))
5324 (setq gnus-tmp-new-adopts (if (cdar thread)
5325 (append gnus-tmp-new-adopts
5326 (cdar thread))
5327 gnus-tmp-new-adopts)
5328 thread-end t
5329 gnus-tmp-header nil)
5330 (when (zerop gnus-tmp-level)
5331 (setq gnus-tmp-root-expunged t)))
5332 ;; Perhaps this article is to be marked as read?
5333 ((and gnus-summary-mark-below
5334 (< (or (cdr (assq number gnus-newsgroup-scored))
5335 default-score)
5336 gnus-summary-mark-below)
5337 ;; Don't touch sparse articles.
5338 (not (gnus-summary-article-sparse-p number))
5339 (not (gnus-summary-article-ancient-p number)))
5340 (setq gnus-newsgroup-unreads
5341 (delq number gnus-newsgroup-unreads))
5342 (if gnus-newsgroup-auto-expire
5343 (setq gnus-newsgroup-expirable
5344 (gnus-add-to-sorted-list
5345 gnus-newsgroup-expirable number))
5346 (push (cons number gnus-low-score-mark)
5347 gnus-newsgroup-reads))))
5349 (when gnus-tmp-header
5350 ;; We may have an old dummy line to output before this
5351 ;; article.
5352 (when (and gnus-tmp-dummy-line
5353 (gnus-subject-equal
5354 gnus-tmp-dummy-line
5355 (mail-header-subject gnus-tmp-header)))
5356 (gnus-summary-insert-dummy-line
5357 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5358 (setq gnus-tmp-dummy-line nil))
5360 ;; Compute the mark.
5361 (setq gnus-tmp-unread (gnus-article-mark number))
5363 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5364 gnus-tmp-header gnus-tmp-level)
5365 gnus-newsgroup-data)
5367 ;; Actually insert the line.
5368 (setq
5369 gnus-tmp-subject-or-nil
5370 (cond
5371 ((and gnus-thread-ignore-subject
5372 gnus-tmp-prev-subject
5373 (not (string= gnus-tmp-prev-subject simp-subject)))
5374 subject)
5375 ((zerop gnus-tmp-level)
5376 (if (and (eq gnus-summary-make-false-root 'empty)
5377 (memq number gnus-tmp-gathered)
5378 gnus-tmp-prev-subject
5379 (string= gnus-tmp-prev-subject simp-subject))
5380 gnus-summary-same-subject
5381 subject))
5382 (t gnus-summary-same-subject)))
5383 (if (and (eq gnus-summary-make-false-root 'adopt)
5384 (= gnus-tmp-level 1)
5385 (memq number gnus-tmp-gathered))
5386 (setq gnus-tmp-opening-bracket ?\<
5387 gnus-tmp-closing-bracket ?\>)
5388 (setq gnus-tmp-opening-bracket ?\[
5389 gnus-tmp-closing-bracket ?\]))
5390 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5391 (gnus-make-thread-indent-array
5392 (max (* 2 (length gnus-thread-indent-array))
5393 gnus-tmp-level)))
5394 (setq
5395 gnus-tmp-indentation
5396 (aref gnus-thread-indent-array gnus-tmp-level)
5397 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5398 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5399 gnus-summary-default-score 0)
5400 gnus-tmp-score-char
5401 (if (or (null gnus-summary-default-score)
5402 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5403 gnus-summary-zcore-fuzz))
5404 ? ;Whitespace
5405 (if (< gnus-tmp-score gnus-summary-default-score)
5406 gnus-score-below-mark gnus-score-over-mark))
5407 gnus-tmp-replied
5408 (cond ((memq number gnus-newsgroup-processable)
5409 gnus-process-mark)
5410 ((memq number gnus-newsgroup-cached)
5411 gnus-cached-mark)
5412 ((memq number gnus-newsgroup-replied)
5413 gnus-replied-mark)
5414 ((memq number gnus-newsgroup-forwarded)
5415 gnus-forwarded-mark)
5416 ((memq number gnus-newsgroup-saved)
5417 gnus-saved-mark)
5418 ((memq number gnus-newsgroup-unseen)
5419 gnus-unseen-mark)
5420 (t gnus-no-mark))
5421 gnus-tmp-downloaded
5422 (cond ((memq number gnus-newsgroup-undownloaded)
5423 gnus-undownloaded-mark)
5424 (gnus-newsgroup-agentized
5425 gnus-downloaded-mark)
5427 gnus-no-mark))
5428 gnus-tmp-from (mail-header-from gnus-tmp-header)
5429 gnus-tmp-name
5430 (cond
5431 ((string-match "<[^>]+> *$" gnus-tmp-from)
5432 (setq beg-match (match-beginning 0))
5433 (or (and (string-match "^\".+\"" gnus-tmp-from)
5434 (substring gnus-tmp-from 1 (1- (match-end 0))))
5435 (substring gnus-tmp-from 0 beg-match)))
5436 ((string-match "(.+)" gnus-tmp-from)
5437 (substring gnus-tmp-from
5438 (1+ (match-beginning 0)) (1- (match-end 0))))
5439 (t gnus-tmp-from))
5441 ;; Do the %B string
5442 gnus-tmp-thread-tree-header-string
5443 (cond
5444 ((not gnus-show-threads) "")
5445 ((zerop gnus-tmp-level)
5446 (cond ((cdar thread)
5447 (or gnus-sum-thread-tree-root subject))
5448 (gnus-tmp-new-adopts
5449 (or gnus-sum-thread-tree-false-root subject))
5451 (or gnus-sum-thread-tree-single-indent subject))))
5453 (concat (apply 'concat
5454 (mapcar (lambda (item)
5455 (if (= item 1)
5456 gnus-sum-thread-tree-vertical
5457 gnus-sum-thread-tree-indent))
5458 (cdr (reverse tree-stack))))
5459 (if (nth 1 thread)
5460 gnus-sum-thread-tree-leaf-with-other
5461 gnus-sum-thread-tree-single-leaf)))))
5462 (when (string= gnus-tmp-name "")
5463 (setq gnus-tmp-name gnus-tmp-from))
5464 (unless (numberp gnus-tmp-lines)
5465 (setq gnus-tmp-lines -1))
5466 (if (= gnus-tmp-lines -1)
5467 (setq gnus-tmp-lines "?")
5468 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5469 (gnus-put-text-property
5470 (point)
5471 (progn (eval gnus-summary-line-format-spec) (point))
5472 'gnus-number number)
5473 (when gnus-visual-p
5474 (forward-line -1)
5475 (gnus-summary-highlight-line)
5476 (when gnus-summary-update-hook
5477 (gnus-run-hooks 'gnus-summary-update-hook))
5478 (forward-line 1))
5480 (setq gnus-tmp-prev-subject simp-subject)))
5482 (when (nth 1 thread)
5483 (push (list (max 0 gnus-tmp-level)
5484 (copy-sequence tree-stack)
5485 (nthcdr 1 thread))
5486 stack))
5487 (push (if (nth 1 thread) 1 0) tree-stack)
5488 (incf gnus-tmp-level)
5489 (setq threads (if thread-end nil (cdar thread)))
5490 (if gnus-summary-display-while-building
5491 (if building-count
5492 (progn
5493 ;; use a set frequency
5494 (setq building-line-count (1- building-line-count))
5495 (when (= building-line-count 0)
5496 (sit-for 0)
5497 (setq building-line-count
5498 gnus-summary-display-while-building)))
5499 ;; always
5500 (sit-for 0)))
5501 (unless threads
5502 (setq gnus-tmp-level 0)))))
5503 (gnus-message 7 "Generating summary...done"))
5505 (defun gnus-summary-prepare-unthreaded (headers)
5506 "Generate an unthreaded summary buffer based on HEADERS."
5507 (let (header number mark)
5509 (beginning-of-line)
5511 (while headers
5512 ;; We may have to root out some bad articles...
5513 (when (memq (setq number (mail-header-number
5514 (setq header (pop headers))))
5515 gnus-newsgroup-limit)
5516 ;; Mark article as read when it has a low score.
5517 (when (and gnus-summary-mark-below
5518 (< (or (cdr (assq number gnus-newsgroup-scored))
5519 gnus-summary-default-score 0)
5520 gnus-summary-mark-below)
5521 (not (gnus-summary-article-ancient-p number)))
5522 (setq gnus-newsgroup-unreads
5523 (delq number gnus-newsgroup-unreads))
5524 (if gnus-newsgroup-auto-expire
5525 (push number gnus-newsgroup-expirable)
5526 (push (cons number gnus-low-score-mark)
5527 gnus-newsgroup-reads)))
5529 (setq mark (gnus-article-mark number))
5530 (push (gnus-data-make number mark (1+ (point)) header 0)
5531 gnus-newsgroup-data)
5532 (gnus-summary-insert-line
5533 header 0 number
5534 (memq number gnus-newsgroup-undownloaded)
5535 mark (memq number gnus-newsgroup-replied)
5536 (memq number gnus-newsgroup-expirable)
5537 (mail-header-subject header) nil
5538 (cdr (assq number gnus-newsgroup-scored))
5539 (memq number gnus-newsgroup-processable))))))
5541 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5543 (defun gnus-group-get-list-identifiers (group)
5544 "Get list identifier regexp for GROUP."
5545 (or (gnus-parameter-list-identifier group)
5546 (if (consp gnus-list-identifiers)
5547 (mapconcat 'identity gnus-list-identifiers " *\\|")
5548 gnus-list-identifiers)))
5550 (defun gnus-summary-remove-list-identifiers ()
5551 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5552 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5553 changed subject)
5554 (when regexp
5555 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5556 (dolist (header gnus-newsgroup-headers)
5557 (setq subject (mail-header-subject header)
5558 changed nil)
5559 (while (string-match regexp subject)
5560 (setq subject
5561 (concat (substring subject 0 (match-beginning 1))
5562 (substring subject (match-end 0)))
5563 changed t))
5564 (when changed
5565 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5566 (setq subject
5567 (concat (substring subject 0 (match-beginning 1))
5568 (substring subject (match-end 1)))))
5569 (mail-header-set-subject header subject))))))
5571 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5572 "Fetch headers of ARTICLES."
5573 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5574 (gnus-message 7 "Fetching headers for %s..." name)
5575 (prog1
5576 (if (eq 'nov
5577 (setq gnus-headers-retrieved-by
5578 (gnus-retrieve-headers
5579 articles gnus-newsgroup-name
5580 (or limit
5581 ;; We might want to fetch old headers, but
5582 ;; not if there is only 1 article.
5583 (and (or (and
5584 (not (eq gnus-fetch-old-headers 'some))
5585 (not (numberp gnus-fetch-old-headers)))
5586 (> (length articles) 1))
5587 gnus-fetch-old-headers)))))
5588 (gnus-get-newsgroup-headers-xover
5589 articles force-new dependencies gnus-newsgroup-name t)
5590 (gnus-get-newsgroup-headers dependencies force-new))
5591 (gnus-message 7 "Fetching headers for %s...done" name))))
5593 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5594 "Select newsgroup GROUP.
5595 If READ-ALL is non-nil, all articles in the group are selected.
5596 If SELECT-ARTICLES, only select those articles from GROUP."
5597 (let* ((entry (gnus-group-entry group))
5598 ;;!!! Dirty hack; should be removed.
5599 (gnus-summary-ignore-duplicates
5600 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5602 gnus-summary-ignore-duplicates))
5603 (info (nth 2 entry))
5604 charset articles fetched-articles cached)
5606 (unless (gnus-check-server
5607 (set (make-local-variable 'gnus-current-select-method)
5608 (gnus-find-method-for-group group)))
5609 (error "Couldn't open server"))
5610 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5612 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5613 (gnus-activate-group group) ; Or we can activate it...
5614 (progn ; Or we bug out.
5615 (when (equal major-mode 'gnus-summary-mode)
5616 (gnus-kill-buffer (current-buffer)))
5617 (error
5618 "Couldn't activate group %s: %s"
5619 (mm-decode-coding-string group charset)
5620 (mm-decode-coding-string (gnus-status-message group) charset))))
5622 (unless (gnus-request-group group t)
5623 (when (equal major-mode 'gnus-summary-mode)
5624 (gnus-kill-buffer (current-buffer)))
5625 (error "Couldn't request group %s: %s"
5626 (mm-decode-coding-string group charset)
5627 (mm-decode-coding-string (gnus-status-message group) charset)))
5629 (when (and gnus-agent
5630 (gnus-active group))
5631 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5633 (setq gnus-summary-use-undownloaded-faces
5634 (gnus-agent-find-parameter
5635 group
5636 'agent-enable-undownloaded-faces)))
5638 (setq gnus-newsgroup-name group
5639 gnus-newsgroup-unselected nil
5640 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5642 (let ((display (gnus-group-find-parameter group 'display)))
5643 (setq gnus-newsgroup-display
5644 (cond
5645 ((not (zerop (or (car-safe read-all) 0)))
5646 ;; The user entered the group with C-u SPC/RET, let's show
5647 ;; all articles.
5648 'gnus-not-ignore)
5649 ((eq display 'all)
5650 'gnus-not-ignore)
5651 ((arrayp display)
5652 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5653 ((numberp display)
5654 ;; The following is probably the "correct" solution, but
5655 ;; it makes Gnus fetch all headers and then limit the
5656 ;; articles (which is slow), so instead we hack the
5657 ;; select-articles parameter instead. -- Simon Josefsson
5658 ;; <jas@kth.se>
5660 ;; (gnus-byte-compile
5661 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5662 ;; display)))))
5663 (setq select-articles
5664 (gnus-uncompress-range
5665 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5666 (if (> tmp 0)
5669 (cdr (gnus-active group)))))
5670 nil)
5672 nil))))
5674 (gnus-summary-setup-default-charset)
5676 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5677 (when (gnus-virtual-group-p group)
5678 (setq cached gnus-newsgroup-cached))
5680 (setq gnus-newsgroup-unreads
5681 (gnus-sorted-ndifference
5682 (gnus-sorted-ndifference gnus-newsgroup-unreads
5683 gnus-newsgroup-marked)
5684 gnus-newsgroup-dormant))
5686 (setq gnus-newsgroup-processable nil)
5688 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5690 ;; Adjust and set lists of article marks.
5691 (when info
5692 (gnus-adjust-marked-articles info))
5693 (if (setq articles select-articles)
5694 (setq gnus-newsgroup-unselected
5695 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5696 (setq articles (gnus-articles-to-read group read-all)))
5698 (cond
5699 ((null articles)
5700 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5701 'quit)
5702 ((eq articles 0) nil)
5704 ;; Init the dependencies hash table.
5705 (setq gnus-newsgroup-dependencies
5706 (gnus-make-hashtable (length articles)))
5707 (if (gnus-buffer-live-p gnus-group-buffer)
5708 (gnus-set-global-variables)
5709 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5710 ;; Retrieve the headers and read them in.
5712 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5714 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5715 (when cached
5716 (setq gnus-newsgroup-cached cached))
5718 ;; Suppress duplicates?
5719 (when gnus-suppress-duplicates
5720 (gnus-dup-suppress-articles))
5722 ;; Set the initial limit.
5723 (setq gnus-newsgroup-limit (copy-sequence articles))
5724 ;; Remove canceled articles from the list of unread articles.
5725 (setq fetched-articles
5726 (mapcar (lambda (headers) (mail-header-number headers))
5727 gnus-newsgroup-headers))
5728 (setq gnus-newsgroup-articles fetched-articles)
5729 (setq gnus-newsgroup-unreads
5730 (gnus-sorted-nintersection
5731 gnus-newsgroup-unreads fetched-articles))
5732 (gnus-compute-unseen-list)
5734 ;; Removed marked articles that do not exist.
5735 (gnus-update-missing-marks
5736 (gnus-sorted-difference articles fetched-articles))
5737 ;; We might want to build some more threads first.
5738 (when (and gnus-fetch-old-headers
5739 (eq gnus-headers-retrieved-by 'nov))
5740 (if (eq gnus-fetch-old-headers 'invisible)
5741 (gnus-build-all-threads)
5742 (gnus-build-old-threads)))
5743 ;; Let the Gnus agent mark articles as read.
5744 (when gnus-agent
5745 (gnus-agent-get-undownloaded-list))
5746 ;; Remove list identifiers from subject
5747 (gnus-summary-remove-list-identifiers)
5748 ;; Check whether auto-expire is to be done in this group.
5749 (setq gnus-newsgroup-auto-expire
5750 (and (gnus-group-auto-expirable-p group)
5751 (not (gnus-group-read-only-p group))))
5752 ;; Set up the article buffer now, if necessary.
5753 (unless (and gnus-single-article-buffer
5754 (equal gnus-article-buffer "*Article*"))
5755 (gnus-article-setup-buffer))
5756 ;; First and last article in this newsgroup.
5757 (when gnus-newsgroup-headers
5758 (setq gnus-newsgroup-begin
5759 (mail-header-number (car gnus-newsgroup-headers))
5760 gnus-newsgroup-end
5761 (mail-header-number
5762 (gnus-last-element gnus-newsgroup-headers))))
5763 ;; GROUP is successfully selected.
5764 (or gnus-newsgroup-headers t)))))
5766 (defun gnus-compute-unseen-list ()
5767 ;; The `seen' marks are treated specially.
5768 (if (not gnus-newsgroup-seen)
5769 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5770 (setq gnus-newsgroup-unseen
5771 (gnus-inverse-list-range-intersection
5772 gnus-newsgroup-articles gnus-newsgroup-seen))))
5774 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5776 (defun gnus-summary-display-make-predicate (display)
5777 (require 'gnus-agent)
5778 (when (= (length display) 1)
5779 (setq display (car display)))
5780 (unless gnus-summary-display-cache
5781 (dolist (elem (append '((unread . unread)
5782 (read . read)
5783 (unseen . unseen))
5784 gnus-article-mark-lists))
5785 (push (cons (cdr elem)
5786 (gnus-byte-compile ;Why bother?
5787 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5788 gnus-summary-display-cache)))
5789 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5790 (gnus-category-predicate-cache gnus-summary-display-cache))
5791 (gnus-get-predicate display)))
5793 ;; Uses the dynamically bound `gnus-number' variable.
5794 (defvar gnus-number)
5795 (defun gnus-article-marked-p (type &optional article)
5796 (let ((article (or article gnus-number)))
5797 (cond
5798 ((eq type 'tick)
5799 (memq article gnus-newsgroup-marked))
5800 ((eq type 'spam)
5801 (memq article gnus-newsgroup-spam-marked))
5802 ((eq type 'unsend)
5803 (memq article gnus-newsgroup-unsendable))
5804 ((eq type 'undownload)
5805 (memq article gnus-newsgroup-undownloaded))
5806 ((eq type 'download)
5807 (memq article gnus-newsgroup-downloadable))
5808 ((eq type 'unread)
5809 (memq article gnus-newsgroup-unreads))
5810 ((eq type 'read)
5811 (memq article gnus-newsgroup-reads))
5812 ((eq type 'dormant)
5813 (memq article gnus-newsgroup-dormant) )
5814 ((eq type 'expire)
5815 (memq article gnus-newsgroup-expirable))
5816 ((eq type 'reply)
5817 (memq article gnus-newsgroup-replied))
5818 ((eq type 'killed)
5819 (memq article gnus-newsgroup-killed))
5820 ((eq type 'bookmark)
5821 (assq article gnus-newsgroup-bookmarks))
5822 ((eq type 'score)
5823 (assq article gnus-newsgroup-scored))
5824 ((eq type 'save)
5825 (memq article gnus-newsgroup-saved))
5826 ((eq type 'cache)
5827 (memq article gnus-newsgroup-cached))
5828 ((eq type 'forward)
5829 (memq article gnus-newsgroup-forwarded))
5830 ((eq type 'seen)
5831 (not (memq article gnus-newsgroup-unseen)))
5832 (t t))))
5834 (defun gnus-articles-to-read (group &optional read-all)
5835 "Find out what articles the user wants to read."
5836 (let* ((only-read-p t)
5837 (articles
5838 (gnus-list-range-difference
5839 ;; Select all articles if `read-all' is non-nil, or if there
5840 ;; are no unread articles.
5841 (if (or read-all
5842 (and (zerop (length gnus-newsgroup-marked))
5843 (zerop (length gnus-newsgroup-unreads)))
5844 ;; Fetch all if the predicate is non-nil.
5845 gnus-newsgroup-display)
5846 ;; We want to select the headers for all the articles in
5847 ;; the group, so we select either all the active
5848 ;; articles in the group, or (if that's nil), the
5849 ;; articles in the cache.
5851 (if gnus-newsgroup-maximum-articles
5852 (let ((active (gnus-active group)))
5853 (gnus-uncompress-range
5854 (cons (max (car active)
5855 (- (cdr active)
5856 gnus-newsgroup-maximum-articles
5857 -1))
5858 (cdr active))))
5859 (gnus-uncompress-range (gnus-active group)))
5860 (gnus-cache-articles-in-group group))
5861 ;; Select only the "normal" subset of articles.
5862 (setq only-read-p nil)
5863 (gnus-sorted-nunion
5864 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5865 gnus-newsgroup-unreads))
5866 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5867 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5868 (scored (length scored-list))
5869 (number (length articles))
5870 (marked (+ (length gnus-newsgroup-marked)
5871 (length gnus-newsgroup-dormant)))
5872 (select
5873 (cond
5874 ((numberp read-all)
5875 read-all)
5876 ((numberp gnus-newsgroup-display)
5877 gnus-newsgroup-display)
5879 (condition-case ()
5880 (cond
5881 ((and (or (<= scored marked) (= scored number))
5882 (numberp gnus-large-newsgroup)
5883 (> number gnus-large-newsgroup))
5884 (let* ((cursor-in-echo-area nil)
5885 (initial (gnus-parameter-large-newsgroup-initial
5886 gnus-newsgroup-name))
5887 (default (if only-read-p
5888 (or initial gnus-large-newsgroup)
5889 number))
5890 (input
5891 (read-string
5892 (if only-read-p
5893 (format
5894 "How many articles from %s (available %d, default %d): "
5895 (gnus-group-decoded-name
5896 (gnus-group-real-name gnus-newsgroup-name))
5897 number default)
5898 (format
5899 "How many articles from %s (%d default): "
5900 (gnus-group-decoded-name
5901 (gnus-group-real-name gnus-newsgroup-name))
5902 default))
5905 (number-to-string default))))
5906 (if (string-match "^[ \t]*$" input) number input)))
5907 ((and (> scored marked) (< scored number)
5908 (> (- scored number) 20))
5909 (let ((input
5910 (read-string
5911 (format "%s %s (%d scored, %d total): "
5912 "How many articles from"
5913 (gnus-group-decoded-name
5914 (gnus-group-real-name gnus-newsgroup-name))
5915 scored number))))
5916 (if (string-match "^[ \t]*$" input)
5917 number input)))
5918 (t number))
5919 (quit
5920 (message "Quit getting the articles to read")
5921 nil))))))
5922 (setq select (if (stringp select) (string-to-number select) select))
5923 (if (or (null select) (zerop select))
5924 select
5925 (if (and (not (zerop scored)) (<= (abs select) scored))
5926 (progn
5927 (setq articles (sort scored-list '<))
5928 (setq number (length articles)))
5929 (setq articles (copy-sequence articles)))
5931 (when (< (abs select) number)
5932 (if (< select 0)
5933 ;; Select the N oldest articles.
5934 (setcdr (nthcdr (1- (abs select)) articles) nil)
5935 ;; Select the N most recent articles.
5936 (setq articles (nthcdr (- number select) articles))))
5937 (setq gnus-newsgroup-unselected
5938 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5939 (when gnus-alter-articles-to-read-function
5940 (setq articles
5941 (sort
5942 (funcall gnus-alter-articles-to-read-function
5943 gnus-newsgroup-name articles)
5944 '<)))
5945 articles)))
5947 (defun gnus-killed-articles (killed articles)
5948 (let (out)
5949 (while articles
5950 (when (inline (gnus-member-of-range (car articles) killed))
5951 (push (car articles) out))
5952 (setq articles (cdr articles)))
5953 out))
5955 (defun gnus-article-mark-to-type (mark)
5956 "Return the type of MARK."
5957 (or (cadr (assq mark gnus-article-special-mark-lists))
5958 'list))
5960 (defun gnus-article-unpropagatable-p (mark)
5961 "Return whether MARK should be propagated to back end."
5962 (memq mark gnus-article-unpropagated-mark-lists))
5964 (defun gnus-adjust-marked-articles (info)
5965 "Set all article lists and remove all marks that are no longer valid."
5966 (let* ((marked-lists (gnus-info-marks info))
5967 (active (gnus-active (gnus-info-group info)))
5968 (min (car active))
5969 (max (cdr active))
5970 (types gnus-article-mark-lists)
5971 marks var articles article mark mark-type
5972 bgn end)
5973 ;; Hack to avoid adjusting marks for imap.
5974 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5975 'nnimap)
5976 (setq min 1))
5978 (dolist (marks marked-lists)
5979 (setq mark (car marks)
5980 mark-type (gnus-article-mark-to-type mark)
5981 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5982 ;; We set the variable according to the type of the marks list,
5983 ;; and then adjust the marks to a subset of the active articles.
5984 (cond
5985 ;; Adjust "simple" lists - compressed yet unsorted
5986 ((eq mark-type 'list)
5987 ;; Simultaneously uncompress and clip to active range
5988 ;; See gnus-uncompress-range for a description of possible marks
5989 (let (l lh)
5990 (if (not (cadr marks))
5991 (set var nil)
5992 (setq articles (if (numberp (cddr marks))
5993 (list (cdr marks))
5994 (cdr marks))
5995 lh (cons nil nil)
5996 l lh)
5998 (while (setq article (pop articles))
5999 (cond ((consp article)
6000 (setq bgn (max (car article) min)
6001 end (min (cdr article) max))
6002 (while (<= bgn end)
6003 (setq l (setcdr l (cons bgn nil))
6004 bgn (1+ bgn))))
6005 ((and (<= min article)
6006 (>= max article))
6007 (setq l (setcdr l (cons article nil))))))
6008 (set var (cdr lh)))))
6009 ;; Adjust assocs.
6010 ((eq mark-type 'tuple)
6011 (set var (setq articles (cdr marks)))
6012 (when (not (listp (cdr (symbol-value var))))
6013 (set var (list (symbol-value var))))
6014 (when (not (listp (cdr articles)))
6015 (setq articles (list articles)))
6016 (while articles
6017 (when (or (not (consp (setq article (pop articles))))
6018 (< (car article) min)
6019 (> (car article) max))
6020 (set var (delq article (symbol-value var))))))
6021 ;; Adjust ranges (sloppily).
6022 ((eq mark-type 'range)
6023 (cond
6024 ((eq mark 'seen)
6025 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6026 ;; It should be (seen (NUM1 . NUM2)).
6027 (when (numberp (cddr marks))
6028 (setcdr marks (list (cdr marks))))
6029 (setq articles (cdr marks))
6030 (while (and articles
6031 (or (and (consp (car articles))
6032 (> min (cdar articles)))
6033 (and (numberp (car articles))
6034 (> min (car articles)))))
6035 (pop articles))
6036 (set var articles))
6037 ((eq mark 'unexist)
6038 (set var (cdr marks)))))))))
6040 (defun gnus-update-missing-marks (missing)
6041 "Go through the list of MISSING articles and remove them from the mark lists."
6042 (when missing
6043 (let (var m)
6044 ;; Go through all types.
6045 (dolist (elem gnus-article-mark-lists)
6046 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6047 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6048 (when (symbol-value var)
6049 ;; This list has articles. So we delete all missing
6050 ;; articles from it.
6051 (setq m missing)
6052 (while m
6053 (set var (delq (pop m) (symbol-value var))))))))))
6055 (defun gnus-update-marks ()
6056 "Enter the various lists of marked articles into the newsgroup info list."
6057 (let ((types gnus-article-mark-lists)
6058 (info (gnus-get-info gnus-newsgroup-name))
6059 type list newmarked symbol delta-marks)
6060 (when info
6061 ;; Add all marks lists to the list of marks lists.
6062 (while (setq type (pop types))
6063 (setq list (symbol-value
6064 (setq symbol
6065 (intern (format "gnus-newsgroup-%s" (car type))))))
6067 (when list
6068 ;; Get rid of the entries of the articles that have the
6069 ;; default score.
6070 (when (and (eq (cdr type) 'score)
6071 gnus-save-score
6072 list)
6073 (let* ((arts list)
6074 (prev (cons nil list))
6075 (all prev))
6076 (while arts
6077 (if (or (not (consp (car arts)))
6078 (= (cdar arts) gnus-summary-default-score))
6079 (setcdr prev (cdr arts))
6080 (setq prev arts))
6081 (setq arts (cdr arts)))
6082 (setq list (cdr all)))))
6084 (when (eq (cdr type) 'seen)
6085 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6087 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6088 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6090 (when (and (gnus-check-backend-function
6091 'request-set-mark gnus-newsgroup-name)
6092 (not (gnus-article-unpropagatable-p (cdr type))))
6093 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6094 ;; Don't do anything about marks for articles we
6095 ;; didn't actually get any headers for.
6096 (del
6097 (gnus-list-range-intersection
6098 gnus-newsgroup-articles
6099 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6100 (add
6101 (gnus-list-range-intersection
6102 gnus-newsgroup-articles
6103 (gnus-remove-from-range
6104 (gnus-copy-sequence list) old))))
6105 (when add
6106 (push (list add 'add (list (cdr type))) delta-marks))
6107 (when del
6108 ;; Don't delete marks from outside the active range.
6109 ;; This shouldn't happen, but is a sanity check.
6110 (setq del (gnus-sorted-range-intersection
6111 (gnus-active gnus-newsgroup-name) del))
6112 (push (list del 'del (list (cdr type))) delta-marks))))
6114 (when (or list
6115 (eq (cdr type) 'unexist))
6116 (push (cons (cdr type) list) newmarked)))
6118 (when delta-marks
6119 (unless (gnus-check-group gnus-newsgroup-name)
6120 (error "Can't open server for %s" gnus-newsgroup-name))
6121 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6123 ;; Enter these new marks into the info of the group.
6124 (if (nthcdr 3 info)
6125 (setcar (nthcdr 3 info) newmarked)
6126 ;; Add the marks lists to the end of the info.
6127 (when newmarked
6128 (setcdr (nthcdr 2 info) (list newmarked))))
6130 ;; Cut off the end of the info if there's nothing else there.
6131 (let ((i 5))
6132 (while (and (> i 2)
6133 (not (nth i info)))
6134 (when (nthcdr (decf i) info)
6135 (setcdr (nthcdr i info) nil)))))))
6137 (defun gnus-set-mode-line (where)
6138 "Set the mode line of the article or summary buffers.
6139 If WHERE is `summary', the summary mode line format will be used."
6140 ;; Is this mode line one we keep updated?
6141 (when (and (memq where gnus-updated-mode-lines)
6142 (symbol-value
6143 (intern (format "gnus-%s-mode-line-format-spec" where))))
6144 (let (mode-string)
6145 ;; We evaluate this in the summary buffer since these
6146 ;; variables are buffer-local to that buffer.
6147 (with-current-buffer gnus-summary-buffer
6148 ;; We bind all these variables that are used in the `eval' form
6149 ;; below.
6150 (let* ((mformat (symbol-value
6151 (intern
6152 (format "gnus-%s-mode-line-format-spec" where))))
6153 (gnus-tmp-group-name (gnus-mode-string-quote
6154 (gnus-group-decoded-name
6155 gnus-newsgroup-name)))
6156 (gnus-tmp-article-number (or gnus-current-article 0))
6157 (gnus-tmp-unread gnus-newsgroup-unreads)
6158 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6159 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6160 (gnus-tmp-unread-and-unselected
6161 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6162 (zerop gnus-tmp-unselected))
6164 ((zerop gnus-tmp-unselected)
6165 (format "{%d more}" gnus-tmp-unread-and-unticked))
6166 (t (format "{%d(+%d) more}"
6167 gnus-tmp-unread-and-unticked
6168 gnus-tmp-unselected))))
6169 (gnus-tmp-subject
6170 (if (and gnus-current-headers
6171 (vectorp gnus-current-headers))
6172 (gnus-mode-string-quote
6173 (mail-header-subject gnus-current-headers))
6174 ""))
6175 bufname-length max-len
6176 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6177 (setq mode-string (eval mformat))
6178 (setq bufname-length (if (string-match "%b" mode-string)
6179 (- (length
6180 (buffer-name
6181 (if (eq where 'summary)
6183 (get-buffer gnus-article-buffer))))
6186 (setq max-len (max 4 (if gnus-mode-non-string-length
6187 (- (window-width)
6188 gnus-mode-non-string-length
6189 bufname-length)
6190 (length mode-string))))
6191 ;; We might have to chop a bit of the string off...
6192 (when (> (length mode-string) max-len)
6193 (setq mode-string
6194 (concat (truncate-string-to-width mode-string (- max-len 3))
6195 "...")))))
6196 ;; Update the mode line.
6197 (setq mode-line-buffer-identification
6198 (gnus-mode-line-buffer-identification (list mode-string)))
6199 (set-buffer-modified-p t))))
6201 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6202 "Go through the HEADERS list and add all Xrefs to a hash table.
6203 The resulting hash table is returned, or nil if no Xrefs were found."
6204 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6205 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6206 (xref-hashtb (gnus-make-hashtable))
6207 start group entry number xrefs header)
6208 (while headers
6209 (setq header (pop headers))
6210 (when (and (setq xrefs (mail-header-xref header))
6211 (not (memq (setq number (mail-header-number header))
6212 unreads)))
6213 (setq start 0)
6214 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6215 (setq start (match-end 0))
6216 (setq group (if prefix
6217 (concat prefix (substring xrefs (match-beginning 1)
6218 (match-end 1)))
6219 (substring xrefs (match-beginning 1) (match-end 1))))
6220 (setq number
6221 (string-to-number (substring xrefs (match-beginning 2)
6222 (match-end 2))))
6223 (if (setq entry (gnus-gethash group xref-hashtb))
6224 (setcdr entry (cons number (cdr entry)))
6225 (gnus-sethash group (cons number nil) xref-hashtb)))))
6226 (and start xref-hashtb)))
6228 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6229 "Look through all the headers and mark the Xrefs as read."
6230 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6231 name info xref-hashtb idlist method nth4)
6232 (with-current-buffer gnus-group-buffer
6233 (when (setq xref-hashtb
6234 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6235 (mapatoms
6236 (lambda (group)
6237 (unless (string= from-newsgroup (setq name (symbol-name group)))
6238 (setq idlist (symbol-value group))
6239 ;; Dead groups are not updated.
6240 (and (prog1
6241 (setq info (gnus-get-info name))
6242 (when (stringp (setq nth4 (gnus-info-method info)))
6243 (setq nth4 (gnus-server-to-method nth4))))
6244 ;; Only do the xrefs if the group has the same
6245 ;; select method as the group we have just read.
6246 (or (gnus-methods-equal-p
6247 nth4 (gnus-find-method-for-group from-newsgroup))
6248 virtual
6249 (equal nth4 (setq method (gnus-find-method-for-group
6250 from-newsgroup)))
6251 (and (equal (car nth4) (car method))
6252 (equal (nth 1 nth4) (nth 1 method))))
6253 gnus-use-cross-reference
6254 (or (not (eq gnus-use-cross-reference t))
6255 virtual
6256 ;; Only do cross-references on subscribed
6257 ;; groups, if that is what is wanted.
6258 (<= (gnus-info-level info) gnus-level-subscribed))
6259 (gnus-group-make-articles-read name idlist))))
6260 xref-hashtb)))))
6262 (defun gnus-compute-read-articles (group articles)
6263 (let* ((entry (gnus-group-entry group))
6264 (info (nth 2 entry))
6265 (active (gnus-active group))
6266 ninfo)
6267 (when entry
6268 ;; First peel off all invalid article numbers.
6269 (when active
6270 (let ((ids articles)
6271 id first)
6272 (while (setq id (pop ids))
6273 (when (and first (> id (cdr active)))
6274 ;; We'll end up in this situation in one particular
6275 ;; obscure situation. If you re-scan a group and get
6276 ;; a new article that is cross-posted to a different
6277 ;; group that has not been re-scanned, you might get
6278 ;; crossposted article that has a higher number than
6279 ;; Gnus believes possible. So we re-activate this
6280 ;; group as well. This might mean doing the
6281 ;; crossposting thingy will *increase* the number
6282 ;; of articles in some groups. Tsk, tsk.
6283 (setq active (or (gnus-activate-group group) active)))
6284 (when (or (> id (cdr active))
6285 (< id (car active)))
6286 (setq articles (delq id articles))))))
6287 ;; If the read list is nil, we init it.
6288 (if (and active
6289 (null (gnus-info-read info))
6290 (> (car active) 1))
6291 (setq ninfo (cons 1 (1- (car active))))
6292 (setq ninfo (gnus-info-read info)))
6293 ;; Then we add the read articles to the range.
6294 (gnus-add-to-range
6295 ninfo (setq articles (sort articles '<))))))
6297 (defun gnus-group-make-articles-read (group articles)
6298 "Update the info of GROUP to say that ARTICLES are read."
6299 (let* ((num 0)
6300 (entry (gnus-group-entry group))
6301 (info (nth 2 entry))
6302 (active (gnus-active group))
6303 (set-marks
6304 (gnus-method-option-p
6305 (gnus-find-method-for-group group)
6306 'server-marks))
6307 range)
6308 (if (not entry)
6309 ;; Group that Gnus doesn't know exists, but still allow the
6310 ;; backend to set marks.
6311 (when set-marks
6312 (gnus-request-set-mark
6313 group (list (list (gnus-compress-sequence (sort articles #'<))
6314 'add '(read)))))
6315 ;; Normal, subscribed groups.
6316 (setq range (gnus-compute-read-articles group articles))
6317 (with-current-buffer gnus-group-buffer
6318 (gnus-undo-register
6319 `(progn
6320 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6321 (gnus-info-set-read ',info ',(gnus-info-read info))
6322 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6323 (when ,set-marks
6324 (gnus-request-set-mark
6325 ,group (list (list ',range 'del '(read)))))
6326 (gnus-group-update-group ,group t))))
6327 ;; Add the read articles to the range.
6328 (gnus-info-set-read info range)
6329 (when set-marks
6330 (gnus-request-set-mark group (list (list range 'add '(read)))))
6331 ;; Then we have to re-compute how many unread
6332 ;; articles there are in this group.
6333 (when active
6334 (cond
6335 ((not range)
6336 (setq num (- (1+ (cdr active)) (car active))))
6337 ((not (listp (cdr range)))
6338 (setq num (- (cdr active) (- (1+ (cdr range))
6339 (car range)))))
6341 (while range
6342 (if (numberp (car range))
6343 (setq num (1+ num))
6344 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6345 (setq range (cdr range)))
6346 (setq num (- (cdr active) num))))
6347 ;; Update the number of unread articles.
6348 (setcar entry num)
6349 ;; Update the group buffer.
6350 (unless (gnus-ephemeral-group-p group)
6351 (gnus-group-update-group group t))))))
6353 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6354 (let ((cur nntp-server-buffer)
6355 (dependencies
6356 (or dependencies
6357 (with-current-buffer gnus-summary-buffer
6358 gnus-newsgroup-dependencies)))
6359 headers id end ref number
6360 (mail-parse-charset gnus-newsgroup-charset)
6361 (mail-parse-ignored-charsets
6362 (save-current-buffer (condition-case nil
6363 (set-buffer gnus-summary-buffer)
6364 (error))
6365 gnus-newsgroup-ignored-charsets)))
6366 (with-current-buffer nntp-server-buffer
6367 ;; Translate all TAB characters into SPACE characters.
6368 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6369 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6370 (ietf-drums-unfold-fws)
6371 (gnus-run-hooks 'gnus-parse-headers-hook)
6372 (let ((case-fold-search t)
6373 in-reply-to header p lines chars)
6374 (goto-char (point-min))
6375 ;; Search to the beginning of the next header. Error messages
6376 ;; do not begin with 2 or 3.
6377 (while (re-search-forward "^[23][0-9]+ " nil t)
6378 (setq id nil
6379 ref nil)
6380 ;; This implementation of this function, with nine
6381 ;; search-forwards instead of the one re-search-forward and
6382 ;; a case (which basically was the old function) is actually
6383 ;; about twice as fast, even though it looks messier. You
6384 ;; can't have everything, I guess. Speed and elegance
6385 ;; doesn't always go hand in hand.
6386 (setq
6387 header
6388 (vector
6389 ;; Number.
6390 (prog1
6391 (setq number (read cur))
6392 (end-of-line)
6393 (setq p (point))
6394 (narrow-to-region (point)
6395 (or (and (search-forward "\n.\n" nil t)
6396 (- (point) 2))
6397 (point))))
6398 ;; Subject.
6399 (progn
6400 (goto-char p)
6401 (if (search-forward "\nsubject:" nil t)
6402 (funcall gnus-decode-encoded-word-function
6403 (nnheader-header-value))
6404 "(none)"))
6405 ;; From.
6406 (progn
6407 (goto-char p)
6408 (if (search-forward "\nfrom:" nil t)
6409 (funcall gnus-decode-encoded-address-function
6410 (nnheader-header-value))
6411 "(nobody)"))
6412 ;; Date.
6413 (progn
6414 (goto-char p)
6415 (if (search-forward "\ndate:" nil t)
6416 (nnheader-header-value) ""))
6417 ;; Message-ID.
6418 (progn
6419 (goto-char p)
6420 (setq id (if (re-search-forward
6421 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6422 ;; We do it this way to make sure the Message-ID
6423 ;; is (somewhat) syntactically valid.
6424 (buffer-substring (match-beginning 1)
6425 (match-end 1))
6426 ;; If there was no message-id, we just fake one
6427 ;; to make subsequent routines simpler.
6428 (nnheader-generate-fake-message-id number))))
6429 ;; References.
6430 (progn
6431 (goto-char p)
6432 (if (search-forward "\nreferences:" nil t)
6433 (progn
6434 (setq end (point))
6435 (prog1
6436 (nnheader-header-value)
6437 (setq ref
6438 (buffer-substring
6439 (progn
6440 (end-of-line)
6441 (search-backward ">" end t)
6442 (1+ (point)))
6443 (progn
6444 (search-backward "<" end t)
6445 (point))))))
6446 ;; Get the references from the in-reply-to header if there
6447 ;; were no references and the in-reply-to header looks
6448 ;; promising.
6449 (if (and (search-forward "\nin-reply-to:" nil t)
6450 (setq in-reply-to (nnheader-header-value))
6451 (string-match "<[^>]+>" in-reply-to))
6452 (let (ref2)
6453 (setq ref (substring in-reply-to (match-beginning 0)
6454 (match-end 0)))
6455 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6456 (setq ref2 (substring in-reply-to (match-beginning 0)
6457 (match-end 0)))
6458 (when (> (length ref2) (length ref))
6459 (setq ref ref2)))
6460 ref)
6461 (setq ref nil))))
6462 ;; Chars.
6463 (progn
6464 (goto-char p)
6465 (if (search-forward "\nchars: " nil t)
6466 (if (numberp (setq chars (ignore-errors (read cur))))
6467 chars -1)
6468 -1))
6469 ;; Lines.
6470 (progn
6471 (goto-char p)
6472 (if (search-forward "\nlines: " nil t)
6473 (if (numberp (setq lines (ignore-errors (read cur))))
6474 lines -1)
6475 -1))
6476 ;; Xref.
6477 (progn
6478 (goto-char p)
6479 (and (search-forward "\nxref:" nil t)
6480 (nnheader-header-value)))
6481 ;; Extra.
6482 (when gnus-extra-headers
6483 (let ((extra gnus-extra-headers)
6484 out)
6485 (while extra
6486 (goto-char p)
6487 (when (search-forward
6488 (concat "\n" (symbol-name (car extra)) ":") nil t)
6489 (push (cons (car extra) (nnheader-header-value))
6490 out))
6491 (pop extra))
6492 out))))
6493 (when (equal id ref)
6494 (setq ref nil))
6496 (when gnus-alter-header-function
6497 (funcall gnus-alter-header-function header)
6498 (setq id (mail-header-id header)
6499 ref (gnus-parent-id (mail-header-references header))))
6501 (when (setq header
6502 (gnus-dependencies-add-header
6503 header dependencies force-new))
6504 (push header headers))
6505 (goto-char (point-max))
6506 (widen))
6507 (nreverse headers)))))
6509 ;; Goes through the xover lines and returns a list of vectors
6510 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6511 force-new dependencies
6512 group also-fetch-heads)
6513 "Parse the news overview data in the server buffer.
6514 Return a list of headers that match SEQUENCE (see
6515 `nntp-retrieve-headers')."
6516 ;; Get the Xref when the users reads the articles since most/some
6517 ;; NNTP servers do not include Xrefs when using XOVER.
6518 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6519 (let ((mail-parse-charset gnus-newsgroup-charset)
6520 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6521 (cur nntp-server-buffer)
6522 (dependencies (or dependencies gnus-newsgroup-dependencies))
6523 (allp (cond
6524 ((eq gnus-read-all-available-headers t)
6526 ((and (stringp gnus-read-all-available-headers)
6527 group)
6528 (string-match gnus-read-all-available-headers group))
6530 nil)))
6531 number headers header)
6532 (with-current-buffer nntp-server-buffer
6533 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6534 ;; Allow the user to mangle the headers before parsing them.
6535 (gnus-run-hooks 'gnus-parse-headers-hook)
6536 (goto-char (point-min))
6537 (gnus-parse-without-error
6538 (while (and (or sequence allp)
6539 (not (eobp)))
6540 (setq number (read cur))
6541 (when (not allp)
6542 (while (and sequence
6543 (< (car sequence) number))
6544 (setq sequence (cdr sequence))))
6545 (when (and (or allp
6546 (and sequence
6547 (eq number (car sequence))))
6548 (progn
6549 (setq sequence (cdr sequence))
6550 (setq header (inline
6551 (gnus-nov-parse-line
6552 number dependencies force-new)))))
6553 (push header headers))
6554 (forward-line 1)))
6555 ;; A common bug in inn is that if you have posted an article and
6556 ;; then retrieves the active file, it will answer correctly --
6557 ;; the new article is included. However, a NOV entry for the
6558 ;; article may not have been generated yet, so this may fail.
6559 ;; We work around this problem by retrieving the last few
6560 ;; headers using HEAD.
6561 (if (or (not also-fetch-heads)
6562 (not sequence))
6563 ;; We (probably) got all the headers.
6564 (nreverse headers)
6565 (let ((gnus-nov-is-evil t))
6566 (nconc
6567 (nreverse headers)
6568 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6569 (gnus-get-newsgroup-headers))))))))
6571 (defun gnus-article-get-xrefs ()
6572 "Fill in the Xref value in `gnus-current-headers', if necessary.
6573 This is meant to be called in `gnus-article-internal-prepare-hook'."
6574 (let ((headers (with-current-buffer gnus-summary-buffer
6575 gnus-current-headers)))
6576 (or (not gnus-use-cross-reference)
6577 (not headers)
6578 (and (mail-header-xref headers)
6579 (not (string= (mail-header-xref headers) "")))
6580 (let ((case-fold-search t)
6581 xref)
6582 (save-restriction
6583 (nnheader-narrow-to-headers)
6584 (goto-char (point-min))
6585 (when (or (and (not (eobp))
6586 (eq (downcase (char-after)) ?x)
6587 (looking-at "Xref:"))
6588 (search-forward "\nXref:" nil t))
6589 (goto-char (1+ (match-end 0)))
6590 (setq xref (buffer-substring (point) (point-at-eol)))
6591 (mail-header-set-xref headers xref)))))))
6593 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6594 "Find article ID and insert the summary line for that article.
6595 OLD-HEADER can either be a header or a line number to insert
6596 the subject line on.
6597 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6598 and OLD-HEADER will be used when the summary line is inserted,
6599 too, instead of trying to fetch new headers."
6600 (let* ((line (and (numberp old-header) old-header))
6601 (old-header (and (vectorp old-header) old-header))
6602 (header (cond ((and old-header use-old-header)
6603 old-header)
6604 ((and (numberp id)
6605 (gnus-number-to-header id))
6606 (gnus-number-to-header id))
6608 (gnus-read-header id))))
6609 (number (and (numberp id) id))
6611 (when header
6612 ;; Rebuild the thread that this article is part of and go to the
6613 ;; article we have fetched.
6614 (when (and (not gnus-show-threads)
6615 old-header)
6616 (when (and number
6617 (setq d (gnus-data-find (mail-header-number old-header))))
6618 (goto-char (gnus-data-pos d))
6619 (gnus-data-remove
6620 number
6621 (- (point-at-bol)
6622 (prog1
6623 (1+ (point-at-eol))
6624 (gnus-delete-line))))))
6625 ;; Remove list identifiers from subject.
6626 (let ((gnus-newsgroup-headers (list header)))
6627 (gnus-summary-remove-list-identifiers))
6628 (when old-header
6629 (mail-header-set-number header (mail-header-number old-header)))
6630 (setq gnus-newsgroup-sparse
6631 (delq (setq number (mail-header-number header))
6632 gnus-newsgroup-sparse))
6633 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6634 (push number gnus-newsgroup-limit)
6635 (gnus-rebuild-thread (mail-header-id header) line)
6636 (gnus-summary-goto-subject number nil t))
6637 (when (and (numberp number)
6638 (> number 0))
6639 ;; We have to update the boundaries even if we can't fetch the
6640 ;; article if ID is a number -- so that the next `P' or `N'
6641 ;; command will fetch the previous (or next) article even
6642 ;; if the one we tried to fetch this time has been canceled.
6643 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6644 (setq gnus-newsgroup-end number))
6645 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6646 (setq gnus-newsgroup-begin number))
6647 (setq gnus-newsgroup-unselected
6648 (delq number gnus-newsgroup-unselected)))
6649 ;; Report back a success?
6650 (and header (mail-header-number header))))
6652 ;;; Process/prefix in the summary buffer
6654 (defun gnus-summary-work-articles (n)
6655 "Return a list of articles to be worked upon.
6656 The prefix argument, the list of process marked articles, and the
6657 current article will be taken into consideration."
6658 (with-current-buffer gnus-summary-buffer
6659 (cond
6661 ;; A numerical prefix has been given.
6662 (setq n (prefix-numeric-value n))
6663 (let ((backward (< n 0))
6664 (n (abs (prefix-numeric-value n)))
6665 articles article)
6666 (save-excursion
6667 (while
6668 (and (> n 0)
6669 (push (setq article (gnus-summary-article-number))
6670 articles)
6671 (if backward
6672 (gnus-summary-find-prev nil article)
6673 (gnus-summary-find-next nil article)))
6674 (decf n)))
6675 (nreverse articles)))
6676 ((and (gnus-region-active-p) (mark))
6677 (message "region active")
6678 ;; Work on the region between point and mark.
6679 (let ((max (max (point) (mark)))
6680 articles article)
6681 (save-excursion
6682 (goto-char (min (point) (mark)))
6683 (while
6684 (and
6685 (push (setq article (gnus-summary-article-number)) articles)
6686 (gnus-summary-find-next nil article)
6687 (< (point) max)))
6688 (nreverse articles))))
6689 (gnus-newsgroup-processable
6690 ;; There are process-marked articles present.
6691 ;; Save current state.
6692 (gnus-summary-save-process-mark)
6693 ;; Return the list.
6694 (reverse gnus-newsgroup-processable))
6696 ;; Just return the current article.
6697 (list (gnus-summary-article-number))))))
6699 (defmacro gnus-summary-iterate (arg &rest forms)
6700 "Iterate over the process/prefixed articles and do FORMS.
6701 ARG is the interactive prefix given to the command. FORMS will be
6702 executed with point over the summary line of the articles."
6703 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6704 `(let ((,articles (gnus-summary-work-articles ,arg)))
6705 (while ,articles
6706 (gnus-summary-goto-subject (car ,articles))
6707 ,@forms
6708 (pop ,articles)))))
6710 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6711 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6713 (defun gnus-summary-save-process-mark ()
6714 "Push the current set of process marked articles on the stack."
6715 (interactive)
6716 (push (copy-sequence gnus-newsgroup-processable)
6717 gnus-newsgroup-process-stack))
6719 (defun gnus-summary-kill-process-mark ()
6720 "Push the current set of process marked articles on the stack and unmark."
6721 (interactive)
6722 (gnus-summary-save-process-mark)
6723 (gnus-summary-unmark-all-processable))
6725 (defun gnus-summary-yank-process-mark ()
6726 "Pop the last process mark state off the stack and restore it."
6727 (interactive)
6728 (unless gnus-newsgroup-process-stack
6729 (error "Empty mark stack"))
6730 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6732 (defun gnus-summary-process-mark-set (set)
6733 "Make SET into the current process marked articles."
6734 (gnus-summary-unmark-all-processable)
6735 (mapc 'gnus-summary-set-process-mark set))
6737 ;;; Searching and stuff
6739 (defun gnus-summary-search-group (&optional backward use-level)
6740 "Search for next unread newsgroup.
6741 If optional argument BACKWARD is non-nil, search backward instead."
6742 (with-current-buffer gnus-group-buffer
6743 (when (gnus-group-search-forward
6744 backward nil (if use-level (gnus-group-group-level) nil))
6745 (gnus-group-group-name))))
6747 (defun gnus-summary-best-group (&optional exclude-group)
6748 "Find the name of the best unread group.
6749 If EXCLUDE-GROUP, do not go to this group."
6750 (with-current-buffer gnus-group-buffer
6751 (save-excursion
6752 (gnus-group-best-unread-group exclude-group))))
6754 (defun gnus-summary-find-next (&optional unread article backward)
6755 (if backward
6756 (gnus-summary-find-prev unread article)
6757 (let* ((dummy (gnus-summary-article-intangible-p))
6758 (article (or article (gnus-summary-article-number)))
6759 (data (gnus-data-find-list article))
6760 result)
6761 (when (and (not dummy)
6762 (or (not gnus-summary-check-current)
6763 (not unread)
6764 (not (gnus-data-unread-p (car data)))))
6765 (setq data (cdr data)))
6766 (when (setq result
6767 (if unread
6768 (progn
6769 (while data
6770 (unless (memq (gnus-data-number (car data))
6771 (cond
6772 ((eq gnus-auto-goto-ignores
6773 'always-undownloaded)
6774 gnus-newsgroup-undownloaded)
6775 (gnus-plugged
6776 nil)
6777 ((eq gnus-auto-goto-ignores
6778 'unfetched)
6779 gnus-newsgroup-unfetched)
6780 ((eq gnus-auto-goto-ignores
6781 'undownloaded)
6782 gnus-newsgroup-undownloaded)))
6783 (when (gnus-data-unread-p (car data))
6784 (setq result (car data)
6785 data nil)))
6786 (setq data (cdr data)))
6787 result)
6788 (car data)))
6789 (goto-char (gnus-data-pos result))
6790 (gnus-data-number result)))))
6792 (defun gnus-summary-find-prev (&optional unread article)
6793 (let* ((eobp (eobp))
6794 (article (or article (gnus-summary-article-number)))
6795 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6796 result)
6797 (when (and (not eobp)
6798 (or (not gnus-summary-check-current)
6799 (not unread)
6800 (not (gnus-data-unread-p (car data)))))
6801 (setq data (cdr data)))
6802 (when (setq result
6803 (if unread
6804 (progn
6805 (while data
6806 (unless (memq (gnus-data-number (car data))
6807 (cond
6808 ((eq gnus-auto-goto-ignores
6809 'always-undownloaded)
6810 gnus-newsgroup-undownloaded)
6811 (gnus-plugged
6812 nil)
6813 ((eq gnus-auto-goto-ignores
6814 'unfetched)
6815 gnus-newsgroup-unfetched)
6816 ((eq gnus-auto-goto-ignores
6817 'undownloaded)
6818 gnus-newsgroup-undownloaded)))
6819 (when (gnus-data-unread-p (car data))
6820 (setq result (car data)
6821 data nil)))
6822 (setq data (cdr data)))
6823 result)
6824 (car data)))
6825 (goto-char (gnus-data-pos result))
6826 (gnus-data-number result))))
6828 (defun gnus-summary-find-subject (subject &optional unread backward article)
6829 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6830 (article (or article (gnus-summary-article-number)))
6831 (articles (gnus-data-list backward))
6832 (arts (gnus-data-find-list article articles))
6833 result)
6834 (when (or (not gnus-summary-check-current)
6835 (not unread)
6836 (not (gnus-data-unread-p (car arts))))
6837 (setq arts (cdr arts)))
6838 (while arts
6839 (and (or (not unread)
6840 (gnus-data-unread-p (car arts)))
6841 (vectorp (gnus-data-header (car arts)))
6842 (gnus-subject-equal
6843 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6844 (setq result (car arts)
6845 arts nil))
6846 (setq arts (cdr arts)))
6847 (and result
6848 (goto-char (gnus-data-pos result))
6849 (gnus-data-number result))))
6851 (defun gnus-summary-search-forward (&optional unread subject backward)
6852 "Search forward for an article.
6853 If UNREAD, look for unread articles. If SUBJECT, look for
6854 articles with that subject. If BACKWARD, search backward instead."
6855 (cond (subject (gnus-summary-find-subject subject unread backward))
6856 (backward (gnus-summary-find-prev unread))
6857 (t (gnus-summary-find-next unread))))
6859 (defun gnus-recenter (&optional n)
6860 "Center point in window and redisplay frame.
6861 Also do horizontal recentering."
6862 (interactive "P")
6863 (when (and gnus-auto-center-summary
6864 (not (eq gnus-auto-center-summary 'vertical)))
6865 (gnus-horizontal-recenter))
6866 (if (fboundp 'recenter-top-bottom)
6867 (recenter-top-bottom n)
6868 (recenter n)))
6870 (put 'gnus-recenter 'isearch-scroll t)
6872 (defun gnus-forward-line-ignore-invisible (n)
6873 "Move N lines forward (backward if N is negative).
6874 Like forward-line, but skip over (and don't count) invisible lines."
6875 (let (done)
6876 (while (and (> n 0) (not done))
6877 ;; If the following character is currently invisible,
6878 ;; skip all characters with that same `invisible' property value.
6879 (while (gnus-invisible-p (point))
6880 (goto-char (gnus-next-char-property-change (point))))
6881 (forward-line 1)
6882 (if (eobp)
6883 (setq done t)
6884 (setq n (1- n))))
6885 (while (and (< n 0) (not done))
6886 (forward-line -1)
6887 (if (bobp) (setq done t)
6888 (setq n (1+ n))
6889 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6890 (goto-char (gnus-previous-char-property-change (point))))))))
6892 (defun gnus-summary-recenter ()
6893 "Center point in the summary window.
6894 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6895 displayed, no centering will be performed."
6896 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6897 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6898 (interactive)
6899 ;; The user has to want it.
6900 (when gnus-auto-center-summary
6901 (let* ((top (cond ((< (window-height) 4) 0)
6902 ((< (window-height) 7) 1)
6903 (t (if (numberp gnus-auto-center-summary)
6904 gnus-auto-center-summary
6905 (/ (1- (window-height)) 2)))))
6906 (height (1- (window-height)))
6907 (bottom (save-excursion
6908 (goto-char (point-max))
6909 (gnus-forward-line-ignore-invisible (- height))
6910 (point)))
6911 (window (get-buffer-window (current-buffer))))
6912 (when (get-buffer-window gnus-article-buffer)
6913 ;; Only do recentering when the article buffer is displayed,
6914 ;; Set the window start to either `bottom', which is the biggest
6915 ;; possible valid number, or the second line from the top,
6916 ;; whichever is the least.
6917 (let ((top-pos (save-excursion
6918 (gnus-forward-line-ignore-invisible (- top))
6919 (point))))
6920 (if (> bottom top-pos)
6921 ;; Keep the second line from the top visible
6922 (set-window-start window top-pos)
6923 ;; Try to keep the bottom line visible; if it's partially
6924 ;; obscured, either scroll one more line to make it fully
6925 ;; visible, or revert to using TOP-POS.
6926 (save-excursion
6927 (goto-char (point-max))
6928 (gnus-forward-line-ignore-invisible -1)
6929 (let ((last-line-start (point)))
6930 (goto-char bottom)
6931 (set-window-start window (point) t)
6932 (when (not (pos-visible-in-window-p last-line-start window))
6933 (gnus-forward-line-ignore-invisible 1)
6934 (set-window-start window (min (point) top-pos) t)))))))
6935 ;; Do horizontal recentering while we're at it.
6936 (when (and (get-buffer-window (current-buffer) t)
6937 (not (eq gnus-auto-center-summary 'vertical)))
6938 (let ((selected (selected-window)))
6939 (select-window (get-buffer-window (current-buffer) t))
6940 (gnus-summary-position-point)
6941 (gnus-horizontal-recenter)
6942 (select-window selected))))))
6944 (defun gnus-summary-jump-to-group (newsgroup)
6945 "Move point to NEWSGROUP in group mode buffer."
6946 ;; Keep update point of group mode buffer if visible.
6947 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6948 (save-window-excursion
6949 ;; Take care of tree window mode.
6950 (when (get-buffer-window gnus-group-buffer)
6951 (pop-to-buffer gnus-group-buffer))
6952 (gnus-group-jump-to-group newsgroup))
6953 (save-excursion
6954 ;; Take care of tree window mode.
6955 (if (get-buffer-window gnus-group-buffer 0)
6956 (pop-to-buffer gnus-group-buffer)
6957 (set-buffer gnus-group-buffer))
6958 (gnus-group-jump-to-group newsgroup))))
6960 ;; This function returns a list of article numbers based on the
6961 ;; difference between the ranges of read articles in this group and
6962 ;; the range of active articles.
6963 (defun gnus-list-of-unread-articles (group)
6964 (let* ((read (gnus-info-read (gnus-get-info group)))
6965 (active (or (gnus-active group) (gnus-activate-group group)))
6966 (last (or (cdr active)
6967 (error "Group %s couldn't be activated " group)))
6968 (bottom (if gnus-newsgroup-maximum-articles
6969 (max (car active)
6970 (- last gnus-newsgroup-maximum-articles -1))
6971 (car active)))
6972 first nlast unread)
6973 ;; If none are read, then all are unread.
6974 (if (not read)
6975 (setq first bottom)
6976 ;; If the range of read articles is a single range, then the
6977 ;; first unread article is the article after the last read
6978 ;; article. Sounds logical, doesn't it?
6979 (if (and (not (listp (cdr read)))
6980 (or (< (car read) bottom)
6981 (progn (setq read (list read))
6982 nil)))
6983 (setq first (max bottom (1+ (cdr read))))
6984 ;; `read' is a list of ranges.
6985 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6986 (caar read)))
6988 (setq first bottom))
6989 (while read
6990 (when first
6991 (while (< first nlast)
6992 (setq unread (cons first unread)
6993 first (1+ first))))
6994 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6995 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6996 (setq read (cdr read)))))
6997 ;; And add the last unread articles.
6998 (while (<= first last)
6999 (setq unread (cons first unread)
7000 first (1+ first)))
7001 ;; Return the list of unread articles.
7002 (delq 0 (nreverse unread))))
7004 (defun gnus-list-of-read-articles (group)
7005 "Return a list of unread, unticked and non-dormant articles."
7006 (let* ((info (gnus-get-info group))
7007 (marked (gnus-info-marks info))
7008 (active (gnus-active group)))
7009 (and info active
7010 (gnus-list-range-difference
7011 (gnus-list-range-difference
7012 (gnus-sorted-complement
7013 (gnus-uncompress-range
7014 (if gnus-newsgroup-maximum-articles
7015 (cons (max (car active)
7016 (- (cdr active)
7017 gnus-newsgroup-maximum-articles
7018 -1))
7019 (cdr active))
7020 active))
7021 (gnus-list-of-unread-articles group))
7022 (cdr (assq 'dormant marked)))
7023 (cdr (assq 'tick marked))))))
7025 ;; This function returns a sequence of article numbers based on the
7026 ;; difference between the ranges of read articles in this group and
7027 ;; the range of active articles.
7028 (defun gnus-sequence-of-unread-articles (group)
7029 (let* ((read (gnus-info-read (gnus-get-info group)))
7030 (active (or (gnus-active group) (gnus-activate-group group)))
7031 (last (cdr active))
7032 (bottom (if gnus-newsgroup-maximum-articles
7033 (max (car active)
7034 (- last gnus-newsgroup-maximum-articles -1))
7035 (car active)))
7036 first nlast unread)
7037 ;; If none are read, then all are unread.
7038 (if (not read)
7039 (setq first bottom)
7040 ;; If the range of read articles is a single range, then the
7041 ;; first unread article is the article after the last read
7042 ;; article. Sounds logical, doesn't it?
7043 (if (and (not (listp (cdr read)))
7044 (or (< (car read) bottom)
7045 (progn (setq read (list read))
7046 nil)))
7047 (setq first (max bottom (1+ (cdr read))))
7048 ;; `read' is a list of ranges.
7049 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7050 (caar read)))
7052 (setq first bottom))
7053 (while read
7054 (when first
7055 (push (cons first nlast) unread))
7056 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7057 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7058 (setq read (cdr read)))))
7059 ;; And add the last unread articles.
7060 (cond ((not (and first last))
7061 nil)
7062 ((< first last)
7063 (push (cons first last) unread))
7064 ((= first last)
7065 (push first unread)))
7066 ;; Return the sequence of unread articles.
7067 (delq 0 (nreverse unread))))
7069 ;; Various summary commands
7071 (defun gnus-summary-select-article-buffer ()
7072 "Reconfigure windows to show the article buffer.
7073 If `gnus-widen-article-window' is set, show only the article
7074 buffer."
7075 (interactive)
7076 (if (not (gnus-buffer-live-p gnus-article-buffer))
7077 (error "There is no article buffer for this summary buffer")
7078 (unless (get-buffer-window gnus-article-buffer)
7079 (gnus-summary-show-article))
7080 (gnus-configure-windows
7081 (if gnus-widen-article-window
7082 'only-article
7083 'article)
7085 (select-window (get-buffer-window gnus-article-buffer))))
7087 (defun gnus-summary-universal-argument (arg)
7088 "Perform any operation on all articles that are process/prefixed."
7089 (interactive "P")
7090 (let ((articles (gnus-summary-work-articles arg))
7091 func article)
7092 (if (eq
7093 (setq
7094 func
7095 (key-binding
7096 (read-key-sequence
7097 (substitute-command-keys
7098 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7099 'undefined)
7100 (gnus-error 1 "Undefined key")
7101 (save-excursion
7102 (while articles
7103 (gnus-summary-goto-subject (setq article (pop articles)))
7104 (let (gnus-newsgroup-processable)
7105 (command-execute func))
7106 (gnus-summary-remove-process-mark article)))))
7107 (gnus-summary-position-point))
7109 (defun gnus-summary-toggle-truncation (&optional arg)
7110 "Toggle truncation of summary lines.
7111 With ARG, turn line truncation on if ARG is positive."
7112 (interactive "P")
7113 (setq truncate-lines
7114 (if (null arg) (not truncate-lines)
7115 (> (prefix-numeric-value arg) 0)))
7116 (redraw-display))
7118 (defun gnus-summary-find-for-reselect ()
7119 "Return the number of an article to stay on across a reselect.
7120 The current article is considered, then following articles, then previous
7121 articles. An article is sought which is not canceled and isn't a temporary
7122 insertion from another group. If there's no such then return a dummy 0."
7123 (let (found)
7124 (dolist (rev '(nil t))
7125 (unless found ; don't demand the reverse list if we don't need it
7126 (let ((data (gnus-data-find-list
7127 (gnus-summary-article-number) (gnus-data-list rev))))
7128 (while (and data (not found))
7129 (if (and (< 0 (gnus-data-number (car data)))
7130 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7131 (setq found (gnus-data-number (car data))))
7132 (setq data (cdr data))))))
7133 (or found 0)))
7135 (defun gnus-summary-reselect-current-group (&optional all rescan)
7136 "Exit and then reselect the current newsgroup.
7137 The prefix argument ALL means to select all articles."
7138 (interactive "P")
7139 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7140 (error "Ephemeral groups can't be reselected"))
7141 (let ((current-subject (gnus-summary-find-for-reselect))
7142 (group gnus-newsgroup-name))
7143 (setq gnus-newsgroup-begin nil)
7144 (gnus-summary-exit nil 'leave-hidden)
7145 ;; We have to adjust the point of group mode buffer because
7146 ;; point was moved to the next unread newsgroup by exiting.
7147 (gnus-summary-jump-to-group group)
7148 (when rescan
7149 (save-excursion
7150 (gnus-group-get-new-news-this-group 1)))
7151 (gnus-group-read-group all t)
7152 (gnus-summary-goto-subject current-subject nil t)))
7154 (defun gnus-summary-rescan-group (&optional all)
7155 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7156 (interactive "P")
7157 (let ((config gnus-current-window-configuration))
7158 (gnus-summary-reselect-current-group all t)
7159 (gnus-configure-windows config)
7160 (when (eq config 'article)
7161 (gnus-summary-select-article))))
7163 (defun gnus-summary-update-info (&optional non-destructive)
7164 (save-excursion
7165 (let ((group gnus-newsgroup-name))
7166 (when group
7167 (when gnus-newsgroup-kill-headers
7168 (setq gnus-newsgroup-killed
7169 (gnus-compress-sequence
7170 (gnus-sorted-union
7171 (gnus-list-range-intersection
7172 gnus-newsgroup-unselected gnus-newsgroup-killed)
7173 gnus-newsgroup-unreads)
7174 t)))
7175 (unless (listp (cdr gnus-newsgroup-killed))
7176 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7177 (let ((headers gnus-newsgroup-headers)
7178 (ephemeral-p (gnus-ephemeral-group-p group))
7179 info)
7180 (unless ephemeral-p
7181 (setq info (copy-sequence (gnus-get-info group))
7182 info (delq (gnus-info-params info) info)))
7183 ;; Set the new ranges of read articles.
7184 (with-current-buffer gnus-group-buffer
7185 (gnus-undo-force-boundary))
7186 (gnus-update-read-articles
7187 group (gnus-sorted-union
7188 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7189 ;; Set the current article marks.
7190 (let ((gnus-newsgroup-scored
7191 (if (and (not gnus-save-score)
7192 (not non-destructive))
7194 gnus-newsgroup-scored)))
7195 (save-excursion
7196 (gnus-update-marks)))
7197 ;; Do the cross-ref thing.
7198 (when gnus-use-cross-reference
7199 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7200 ;; Do not switch windows but change the buffer to work.
7201 (set-buffer gnus-group-buffer)
7202 (unless ephemeral-p
7203 (gnus-group-update-group
7204 group nil
7205 (equal info
7206 (setq info (copy-sequence (gnus-get-info group))
7207 info (delq (gnus-info-params info) info))))))))))
7209 (defun gnus-summary-save-newsrc (&optional force)
7210 "Save the current number of read/marked articles in the dribble buffer.
7211 The dribble buffer will then be saved.
7212 If FORCE (the prefix), also save the .newsrc file(s)."
7213 (interactive "P")
7214 (gnus-summary-update-info t)
7215 (if force
7216 (gnus-save-newsrc-file)
7217 (gnus-dribble-save)))
7219 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7221 (defun gnus-summary-exit (&optional temporary leave-hidden)
7222 "Exit reading current newsgroup, and then return to group selection mode.
7223 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7224 (interactive)
7225 (gnus-set-global-variables)
7226 (when (gnus-buffer-live-p gnus-article-buffer)
7227 (with-current-buffer gnus-article-buffer
7228 (mm-destroy-parts gnus-article-mime-handles)
7229 ;; Set it to nil for safety reason.
7230 (setq gnus-article-mime-handle-alist nil)
7231 (setq gnus-article-mime-handles nil)))
7232 (gnus-kill-save-kill-buffer)
7233 (gnus-async-halt-prefetch)
7234 (let* ((group gnus-newsgroup-name)
7235 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7236 (gnus-group-is-exiting-p t)
7237 (article-buffer gnus-article-buffer)
7238 (original-article-buffer gnus-original-article-buffer)
7239 (mode major-mode)
7240 (group-point nil)
7241 (buf (current-buffer))
7242 ;; `gnus-single-article-buffer' is nil buffer-locally in
7243 ;; ephemeral group of which summary buffer will be killed,
7244 ;; but the global value may be non-nil.
7245 (single-article-buffer gnus-single-article-buffer))
7246 (unless quit-config
7247 ;; Do adaptive scoring, and possibly save score files.
7248 (when gnus-newsgroup-adaptive
7249 (gnus-score-adaptive))
7250 (when gnus-use-scoring
7251 (gnus-score-save)))
7252 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7253 (when gnus-use-cache
7254 (gnus-cache-possibly-remove-articles)
7255 (gnus-cache-save-buffers))
7256 (gnus-async-prefetch-remove-group group)
7257 (when gnus-suppress-duplicates
7258 (gnus-dup-enter-articles))
7259 (when gnus-use-trees
7260 (gnus-tree-close group))
7261 (when gnus-use-cache
7262 (gnus-cache-write-active))
7263 ;; Remove entries for this group.
7264 (nnmail-purge-split-history (gnus-group-real-name group))
7265 ;; Make all changes in this group permanent.
7266 (unless quit-config
7267 (gnus-run-hooks 'gnus-exit-group-hook)
7268 (gnus-summary-update-info))
7269 (gnus-close-group group)
7270 ;; Make sure where we were, and go to next newsgroup.
7271 (when (buffer-live-p (get-buffer gnus-group-buffer))
7272 (set-buffer gnus-group-buffer))
7273 (unless quit-config
7274 (gnus-group-jump-to-group group))
7275 (gnus-run-hooks 'gnus-summary-exit-hook)
7276 (unless (or quit-config
7277 (not gnus-summary-next-group-on-exit)
7278 ;; If this group has disappeared from the summary
7279 ;; buffer, don't skip forwards.
7280 (not (string= group (gnus-group-group-name))))
7281 (gnus-group-next-unread-group 1))
7282 (setq group-point (point))
7283 (if temporary
7284 nil ;Nothing to do.
7285 (set-buffer buf)
7286 (if (not gnus-kill-summary-on-exit)
7287 (progn
7288 (gnus-deaden-summary)
7289 (setq mode nil))
7290 (when (get-buffer gnus-article-buffer)
7291 (bury-buffer gnus-article-buffer))
7292 ;; Return to group mode buffer.
7293 (when (eq mode 'gnus-summary-mode)
7294 (gnus-kill-buffer buf)))
7296 (setq gnus-current-select-method gnus-select-method)
7297 (when (gnus-buffer-live-p gnus-group-buffer)
7298 (set-buffer gnus-group-buffer))
7299 (if quit-config
7300 (gnus-handle-ephemeral-exit quit-config)
7301 (goto-char group-point)
7302 ;; If gnus-group-buffer is already displayed, make sure we also move
7303 ;; the cursor in the window that displays it.
7304 (let ((win (get-buffer-window (current-buffer) 0)))
7305 (if win (set-window-point win (point))))
7306 (unless leave-hidden
7307 (gnus-configure-windows 'group 'force)))
7309 ;; If we have several article buffers, we kill them at exit.
7310 (unless single-article-buffer
7311 (when (gnus-buffer-live-p article-buffer)
7312 (with-current-buffer article-buffer
7313 ;; Don't kill sticky article buffers
7314 (unless (eq major-mode 'gnus-sticky-article-mode)
7315 (gnus-kill-buffer article-buffer)
7316 (setq gnus-article-current nil))))
7317 (gnus-kill-buffer original-article-buffer))
7319 ;; Clear the current group name.
7320 (unless quit-config
7321 (setq gnus-newsgroup-name nil)))))
7323 (declare-function gnus-article-stop-animations "gnus-art" ())
7324 (declare-function gnus-stop-downloads "gnus-art" ())
7326 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7327 (defun gnus-summary-exit-no-update (&optional no-questions)
7328 "Quit reading current newsgroup without updating read article info."
7329 (interactive)
7330 (let* ((group gnus-newsgroup-name)
7331 (gnus-group-is-exiting-p t)
7332 (gnus-group-is-exiting-without-update-p t)
7333 (quit-config (gnus-group-quit-config group)))
7334 (when (or no-questions
7335 gnus-expert-user
7336 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7337 (gnus-async-halt-prefetch)
7338 (run-hooks 'gnus-summary-prepare-exit-hook)
7339 (when (gnus-buffer-live-p gnus-article-buffer)
7340 (with-current-buffer gnus-article-buffer
7341 (gnus-article-stop-animations)
7342 (gnus-stop-downloads)
7343 (mm-destroy-parts gnus-article-mime-handles)
7344 ;; Set it to nil for safety reason.
7345 (setq gnus-article-mime-handle-alist nil)
7346 (setq gnus-article-mime-handles nil)))
7347 ;; If we have several article buffers, we kill them at exit.
7348 (unless gnus-single-article-buffer
7349 (gnus-kill-buffer gnus-article-buffer)
7350 (gnus-kill-buffer gnus-original-article-buffer)
7351 (setq gnus-article-current nil))
7352 ;; Return to the group buffer.
7353 (if (not gnus-kill-summary-on-exit)
7354 (progn
7355 (gnus-deaden-summary)
7356 (gnus-configure-windows 'group 'force))
7357 (gnus-configure-windows 'group 'force)
7358 (gnus-close-group group)
7359 (gnus-kill-buffer gnus-summary-buffer))
7360 (unless gnus-single-article-buffer
7361 (setq gnus-article-current nil))
7362 (when gnus-use-trees
7363 (gnus-tree-close group))
7364 (gnus-async-prefetch-remove-group group)
7365 (when (get-buffer gnus-article-buffer)
7366 (bury-buffer gnus-article-buffer))
7367 ;; Clear the current group name.
7368 (setq gnus-newsgroup-name nil)
7369 (unless (gnus-ephemeral-group-p group)
7370 (gnus-group-update-group group nil t))
7371 (when (equal (gnus-group-group-name) group)
7372 (gnus-group-next-unread-group 1))
7373 (when quit-config
7374 (gnus-handle-ephemeral-exit quit-config)))))
7376 (defun gnus-handle-ephemeral-exit (quit-config)
7377 "Handle movement when leaving an ephemeral group.
7378 The state which existed when entering the ephemeral is reset."
7379 (if (not (buffer-live-p (car quit-config)))
7380 (when (gnus-buffer-live-p gnus-group-buffer)
7381 (gnus-configure-windows 'group 'force))
7382 (set-buffer (car quit-config))
7383 (unless (eq (cdr quit-config) 'group)
7384 (setq gnus-current-select-method
7385 (gnus-find-method-for-group gnus-newsgroup-name)))
7386 (cond ((eq major-mode 'gnus-summary-mode)
7387 (gnus-set-global-variables))
7388 ((eq major-mode 'gnus-article-mode)
7389 (save-current-buffer
7390 ;; The `gnus-summary-buffer' variable may point
7391 ;; to the old summary buffer when using a single
7392 ;; article buffer.
7393 (unless (gnus-buffer-live-p gnus-summary-buffer)
7394 (set-buffer gnus-group-buffer))
7395 (set-buffer gnus-summary-buffer)
7396 (gnus-set-global-variables))))
7397 (if (or (eq (cdr quit-config) 'article)
7398 (eq (cdr quit-config) 'pick))
7399 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7400 (gnus-configure-windows 'pick 'force)
7401 (gnus-configure-windows (cdr quit-config) 'force))
7402 (gnus-configure-windows (cdr quit-config) 'force))
7403 (when (eq major-mode 'gnus-summary-mode)
7404 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7405 next-unread-noselect))
7406 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7407 'next-noselect)
7408 (gnus-summary-next-subject 1 nil t))
7409 ((eq gnus-auto-select-on-ephemeral-exit
7410 'next-unread-noselect)
7411 (gnus-summary-next-subject 1 t t))))
7412 ;; Hide the article buffer which displays the article different
7413 ;; from the one that the cursor points to in the summary buffer.
7414 (gnus-configure-windows 'summary 'force))
7415 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7416 (gnus-summary-next-subject 1))
7417 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7418 (gnus-summary-next-subject 1 t))))
7419 (gnus-summary-recenter)
7420 (gnus-summary-position-point))))
7422 ;;; Dead summaries.
7424 (defvar gnus-dead-summary-mode-map
7425 (let ((map (make-keymap)))
7426 (suppress-keymap map)
7427 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7428 (dolist (key '("\C-d" "\r" "\177" [delete]))
7429 (define-key map key 'gnus-summary-wake-up-the-dead))
7430 (dolist (key '("q" "Q"))
7431 (define-key map key 'bury-buffer))
7432 map))
7434 (define-minor-mode gnus-dead-summary-mode
7435 "Minor mode for Gnus summary buffers."
7436 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7437 (unless (derived-mode-p 'gnus-summary-mode)
7438 (setq gnus-dead-summary-mode nil)))
7440 (defun gnus-deaden-summary ()
7441 "Make the current summary buffer into a dead summary buffer."
7442 ;; Kill any previous dead summary buffer.
7443 (when (and gnus-dead-summary
7444 (buffer-name gnus-dead-summary))
7445 (with-current-buffer gnus-dead-summary
7446 (when gnus-dead-summary-mode
7447 (kill-buffer (current-buffer)))))
7448 ;; Make this the current dead summary.
7449 (setq gnus-dead-summary (current-buffer))
7450 (gnus-dead-summary-mode 1)
7451 (let ((name (buffer-name)))
7452 (when (string-match "Summary" name)
7453 (rename-buffer
7454 (concat (substring name 0 (match-beginning 0)) "Dead "
7455 (substring name (match-beginning 0)))
7457 (bury-buffer))))
7459 (defun gnus-kill-or-deaden-summary (buffer)
7460 "Kill or deaden the summary BUFFER."
7461 (save-excursion
7462 (when (and (buffer-name buffer)
7463 (not gnus-single-article-buffer))
7464 (with-current-buffer buffer
7465 (gnus-kill-buffer gnus-article-buffer)
7466 (gnus-kill-buffer gnus-original-article-buffer)))
7467 (cond
7468 ;; Kill the buffer.
7469 (gnus-kill-summary-on-exit
7470 (when (and gnus-use-trees
7471 (gnus-buffer-exists-p buffer))
7472 (with-current-buffer buffer
7473 (gnus-tree-close gnus-newsgroup-name)))
7474 (gnus-kill-buffer buffer))
7475 ;; Deaden the buffer.
7476 ((gnus-buffer-exists-p buffer)
7477 (with-current-buffer buffer
7478 (gnus-deaden-summary))))))
7480 (defun gnus-summary-wake-up-the-dead (&rest args)
7481 "Wake up the dead summary buffer."
7482 (interactive)
7483 (gnus-dead-summary-mode -1)
7484 (let ((name (buffer-name)))
7485 (when (string-match "Dead " name)
7486 (rename-buffer
7487 (concat (substring name 0 (match-beginning 0))
7488 (substring name (match-end 0)))
7489 t)))
7490 (gnus-message 3 "This dead summary is now alive again"))
7492 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7493 (defun gnus-summary-describe-group (&optional force)
7494 "Describe the current newsgroup."
7495 (interactive "P")
7496 (gnus-group-describe-group force gnus-newsgroup-name))
7498 (defun gnus-summary-describe-briefly ()
7499 "Describe summary mode commands briefly."
7500 (interactive)
7501 (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")))
7503 ;; Walking around group mode buffer from summary mode.
7505 (defun gnus-summary-next-group (&optional no-article target-group backward)
7506 "Exit current newsgroup and then select next unread newsgroup.
7507 If prefix argument NO-ARTICLE is non-nil, no article is selected
7508 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7509 previous group instead."
7510 (interactive "P")
7511 ;; Stop pre-fetching.
7512 (gnus-async-halt-prefetch)
7513 (let ((current-group gnus-newsgroup-name)
7514 (current-buffer (current-buffer))
7515 entered)
7516 ;; First we semi-exit this group to update Xrefs and all variables.
7517 ;; We can't do a real exit, because the window conf must remain
7518 ;; the same in case the user is prompted for info, and we don't
7519 ;; want the window conf to change before that...
7520 (gnus-summary-exit t)
7521 (while (not entered)
7522 ;; Then we find what group we are supposed to enter.
7523 (set-buffer gnus-group-buffer)
7524 (gnus-group-jump-to-group current-group)
7525 (setq target-group
7526 (or target-group
7527 (if (eq gnus-keep-same-level 'best)
7528 (gnus-summary-best-group gnus-newsgroup-name)
7529 (gnus-summary-search-group backward gnus-keep-same-level))))
7530 (if (not target-group)
7531 ;; There are no further groups, so we return to the group
7532 ;; buffer.
7533 (progn
7534 (gnus-message 5 "Returning to the group buffer")
7535 (setq entered t)
7536 (when (gnus-buffer-live-p current-buffer)
7537 (set-buffer current-buffer)
7538 (gnus-summary-exit))
7539 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7540 ;; We try to enter the target group.
7541 (gnus-group-jump-to-group target-group)
7542 (let ((unreads (gnus-group-group-unread)))
7543 (if (and (or (eq t unreads)
7544 (and unreads (not (zerop unreads))))
7545 (gnus-summary-read-group
7546 target-group nil no-article
7547 (and (buffer-name current-buffer) current-buffer)
7548 nil backward))
7549 (setq entered t)
7550 (setq current-group target-group
7551 target-group nil)))))))
7553 (defun gnus-summary-prev-group (&optional no-article)
7554 "Exit current newsgroup and then select previous unread newsgroup.
7555 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7556 (interactive "P")
7557 (gnus-summary-next-group no-article nil t))
7559 ;; Walking around summary lines.
7561 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7562 "Go to the first subject satisfying any non-nil constraint.
7563 If UNREAD is non-nil, the article should be unread.
7564 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7565 If UNSEEN is non-nil, the article should be unseen as well as unread.
7566 Returns the article selected or nil if there are no matching articles."
7567 (interactive "P")
7568 (cond
7569 ;; Empty summary.
7570 ((null gnus-newsgroup-data)
7571 (gnus-message 3 "No articles in the group")
7572 nil)
7573 ;; Pick the first article.
7574 ((not (or unread undownloaded unseen))
7575 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7576 (gnus-data-number (car gnus-newsgroup-data)))
7577 ;; Find the first unread article.
7579 (let ((data gnus-newsgroup-data))
7580 (while (and data
7581 (let ((num (gnus-data-number (car data))))
7582 (or (memq num gnus-newsgroup-unfetched)
7583 (not (or (and unread
7584 (memq num gnus-newsgroup-unreads))
7585 (and undownloaded
7586 (memq num gnus-newsgroup-undownloaded))
7587 (and unseen
7588 (memq num gnus-newsgroup-unseen)
7589 (memq num gnus-newsgroup-unreads)))))))
7590 (setq data (cdr data)))
7591 (prog1
7592 (if data
7593 (progn
7594 (goto-char (gnus-data-pos (car data)))
7595 (gnus-data-number (car data)))
7596 (gnus-message 3 "No more%s articles"
7597 (let* ((r (when unread " unread"))
7598 (d (when undownloaded " undownloaded"))
7599 (s (when unseen " unseen"))
7600 (l (delq nil (list r d s))))
7601 (cond ((= 3 (length l))
7602 (concat r "," d ", or" s))
7603 ((= 2 (length l))
7604 (concat (car l) ", or" (cadr l)))
7605 ((= 1 (length l))
7606 (car l))
7608 ""))))
7611 (gnus-summary-position-point))))))
7613 (defun gnus-summary-next-subject (n &optional unread dont-display)
7614 "Go to next N'th summary line.
7615 If N is negative, go to the previous N'th subject line.
7616 If UNREAD is non-nil, only unread articles are selected.
7617 The difference between N and the actual number of steps taken is
7618 returned."
7619 (interactive "p")
7620 (let ((backward (< n 0))
7621 (n (abs n)))
7622 (while (and (> n 0)
7623 (if backward
7624 (gnus-summary-find-prev unread)
7625 (gnus-summary-find-next unread)))
7626 (unless (zerop (setq n (1- n)))
7627 (gnus-summary-show-thread)))
7628 (when (/= 0 n)
7629 (gnus-message 7 "No more%s articles"
7630 (if unread " unread" "")))
7631 (unless dont-display
7632 (gnus-summary-recenter)
7633 (gnus-summary-position-point))
7636 (defun gnus-summary-next-unread-subject (n)
7637 "Go to next N'th unread summary line."
7638 (interactive "p")
7639 (gnus-summary-next-subject n t))
7641 (defun gnus-summary-prev-subject (n &optional unread)
7642 "Go to previous N'th summary line.
7643 If optional argument UNREAD is non-nil, only unread article is selected."
7644 (interactive "p")
7645 (gnus-summary-next-subject (- n) unread))
7647 (defun gnus-summary-prev-unread-subject (n)
7648 "Go to previous N'th unread summary line."
7649 (interactive "p")
7650 (gnus-summary-next-subject (- n) t))
7652 (defun gnus-summary-goto-subjects (articles)
7653 "Insert the subject header for ARTICLES in the current buffer."
7654 (save-excursion
7655 (dolist (article articles)
7656 (gnus-summary-goto-subject article t)))
7657 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7658 (gnus-summary-position-point))
7660 (defun gnus-summary-goto-subject (article &optional force silent)
7661 "Go to the subject line of ARTICLE.
7662 If FORCE, also allow jumping to articles not currently shown."
7663 (interactive "nArticle number: ")
7664 (unless (numberp article)
7665 (error "Article %s is not a number" article))
7666 (let ((b (point))
7667 (data (gnus-data-find article)))
7668 ;; We read in the article if we have to.
7669 (and (not data)
7670 force
7671 (gnus-summary-insert-subject
7672 article
7673 (if (or (numberp force) (vectorp force)) force)
7675 (setq data (gnus-data-find article)))
7676 (goto-char b)
7677 (if (not data)
7678 (progn
7679 (unless silent
7680 (gnus-message 3 "Can't find article %d" article))
7681 nil)
7682 (let ((pt (gnus-data-pos data)))
7683 (goto-char pt)
7684 (gnus-summary-set-article-display-arrow pt))
7685 (gnus-summary-position-point)
7686 article)))
7688 ;; Walking around summary lines with displaying articles.
7690 (defun gnus-summary-expand-window (&optional arg)
7691 "Make the summary buffer take up the entire Emacs frame.
7692 Given a prefix, will force an `article' buffer configuration."
7693 (interactive "P")
7694 (if arg
7695 (gnus-configure-windows 'article 'force)
7696 (gnus-configure-windows 'summary 'force)))
7698 (defun gnus-summary-display-article (article &optional all-header)
7699 "Display ARTICLE in article buffer."
7700 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7701 (with-current-buffer gnus-article-buffer
7702 (eq major-mode 'gnus-article-mode)))
7703 (gnus-article-setup-buffer))
7704 (gnus-set-global-variables)
7705 (with-current-buffer gnus-article-buffer
7706 (setq gnus-article-charset gnus-newsgroup-charset)
7707 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7708 (mm-enable-multibyte))
7709 (if (null article)
7711 (prog1
7712 (if gnus-summary-display-article-function
7713 (funcall gnus-summary-display-article-function article all-header)
7714 (gnus-article-prepare article all-header))
7715 (gnus-run-hooks 'gnus-select-article-hook)
7716 (when (and gnus-current-article
7717 (not (zerop gnus-current-article)))
7718 (gnus-summary-goto-subject gnus-current-article))
7719 (gnus-summary-recenter)
7720 (when (and gnus-use-trees gnus-show-threads)
7721 (gnus-possibly-generate-tree article)
7722 (gnus-highlight-selected-tree article))
7723 ;; Successfully display article.
7724 (gnus-article-set-window-start
7725 (cdr (assq article gnus-newsgroup-bookmarks))))))
7727 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7728 "Select the current article.
7729 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7730 non-nil, the article will be re-fetched even if it already present in
7731 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7732 be displayed."
7733 ;; Make sure we are in the summary buffer to work around bbdb bug.
7734 (unless (eq major-mode 'gnus-summary-mode)
7735 (set-buffer gnus-summary-buffer))
7736 (let ((article (or article (gnus-summary-article-number)))
7737 (all-headers (not (not all-headers))) ;Must be t or nil.
7738 gnus-summary-display-article-function)
7739 (and (not pseudo)
7740 (gnus-summary-article-pseudo-p article)
7741 (error "This is a pseudo-article"))
7742 (with-current-buffer gnus-summary-buffer
7743 (if (or (and gnus-single-article-buffer
7744 (or (null gnus-current-article)
7745 (null gnus-article-current)
7746 (null (get-buffer gnus-article-buffer))
7747 (not (eq article (cdr gnus-article-current)))
7748 (not (equal (car gnus-article-current)
7749 gnus-newsgroup-name))
7750 (not (get-buffer gnus-original-article-buffer))))
7751 (and (not gnus-single-article-buffer)
7752 (or (null gnus-current-article)
7753 (not (get-buffer gnus-original-article-buffer))
7754 (not (eq gnus-current-article article))))
7755 force)
7756 ;; The requested article is different from the current article.
7757 (progn
7758 (gnus-summary-display-article article all-headers)
7759 (when (gnus-buffer-live-p gnus-article-buffer)
7760 (with-current-buffer gnus-article-buffer
7761 (if (not gnus-article-decoded-p) ;; a local variable
7762 (mm-disable-multibyte))))
7763 (gnus-article-set-window-start
7764 (cdr (assq article gnus-newsgroup-bookmarks)))
7765 article)
7766 'old))))
7768 (defun gnus-summary-force-verify-and-decrypt ()
7769 "Display buttons for signed/encrypted parts and verify/decrypt them."
7770 (interactive)
7771 (let ((mm-verify-option 'known)
7772 (mm-decrypt-option 'known)
7773 (gnus-article-emulate-mime t)
7774 (gnus-buttonized-mime-types (append (list "multipart/signed"
7775 "multipart/encrypted")
7776 gnus-buttonized-mime-types)))
7777 (gnus-summary-select-article nil 'force)))
7779 (defun gnus-summary-next-article (&optional unread subject backward push)
7780 "Select the next article.
7781 If UNREAD, only unread articles are selected.
7782 If SUBJECT, only articles with SUBJECT are selected.
7783 If BACKWARD, the previous article is selected instead of the next."
7784 (interactive "P")
7785 ;; Make sure we are in the summary buffer.
7786 (unless (eq major-mode 'gnus-summary-mode)
7787 (set-buffer gnus-summary-buffer))
7788 (cond
7789 ;; Is there such an article?
7790 ((and (gnus-summary-search-forward unread subject backward)
7791 (or (gnus-summary-display-article (gnus-summary-article-number))
7792 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7793 (gnus-summary-position-point))
7794 ;; If not, we try the first unread, if that is wanted.
7795 ((and subject
7796 gnus-auto-select-same
7797 (gnus-summary-first-unread-article))
7798 (gnus-summary-position-point)
7799 (gnus-message 6 "Wrapped"))
7800 ;; Try to get next/previous article not displayed in this group.
7801 ((and gnus-auto-extend-newsgroup
7802 (not unread) (not subject))
7803 (gnus-summary-goto-article
7804 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7805 nil (count-lines (point-min) (point))))
7806 ;; Go to next/previous group.
7808 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7809 (gnus-summary-jump-to-group gnus-newsgroup-name))
7810 (let ((cmd (if (featurep 'xemacs)
7811 last-command-char
7812 last-command-event))
7813 (point
7814 (with-current-buffer gnus-group-buffer
7815 (point)))
7816 (current-summary (current-buffer))
7817 (group
7818 (if (eq gnus-keep-same-level 'best)
7819 (gnus-summary-best-group gnus-newsgroup-name)
7820 (gnus-summary-search-group backward gnus-keep-same-level))))
7821 ;; Select next unread newsgroup automagically.
7822 (cond
7823 ((or (not gnus-auto-select-next)
7824 (not cmd))
7825 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7826 ((or (eq gnus-auto-select-next 'quietly)
7827 (and (eq gnus-auto-select-next 'slightly-quietly)
7828 push)
7829 (and (eq gnus-auto-select-next 'almost-quietly)
7830 (gnus-summary-last-article-p)))
7831 ;; Select quietly.
7832 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7833 (gnus-summary-exit)
7834 (gnus-message 7 "No more%s articles (%s)..."
7835 (if unread " unread" "")
7836 (if group (concat "selecting " group)
7837 "exiting"))
7838 (gnus-summary-next-group nil group backward)))
7840 (when (gnus-key-press-event-p last-input-event)
7841 ;; Somehow or other, we may now have selected a different
7842 ;; window. Make point go back to the summary buffer.
7843 (when (eq current-summary (current-buffer))
7844 ;; FIXME: This burps when get-buffer-window returns nil.
7845 (select-window (get-buffer-window current-summary 0)))
7846 (gnus-summary-walk-group-buffer
7847 gnus-newsgroup-name cmd unread backward point))))))))
7849 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7850 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7851 (?\C-p (gnus-group-prev-unread-group 1))))
7852 (cursor-in-echo-area t)
7853 keve key group ended prompt)
7854 (with-current-buffer gnus-group-buffer
7855 (goto-char start)
7856 (setq group
7857 (if (eq gnus-keep-same-level 'best)
7858 (gnus-summary-best-group gnus-newsgroup-name)
7859 (gnus-summary-search-group backward gnus-keep-same-level))))
7860 (while (not ended)
7861 (setq prompt
7862 (format
7863 "No more%s articles%s " (if unread " unread" "")
7864 (if (and group
7865 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7866 (format " (Type %s for %s [%s])"
7867 (single-key-description cmd)
7868 (gnus-group-decoded-name group)
7869 (gnus-group-unread group))
7870 (format " (Type %s to exit %s)"
7871 (single-key-description cmd)
7872 (gnus-group-decoded-name gnus-newsgroup-name)))))
7873 ;; Confirm auto selection.
7874 (setq key (car (setq keve (gnus-read-event-char prompt)))
7875 ended t)
7876 (cond
7877 ((assq key keystrokes)
7878 (let ((obuf (current-buffer)))
7879 (switch-to-buffer gnus-group-buffer)
7880 (when group
7881 (gnus-group-jump-to-group group))
7882 (eval (cadr (assq key keystrokes)))
7883 (setq group (gnus-group-group-name))
7884 (switch-to-buffer obuf))
7885 (setq ended nil))
7886 ((equal key cmd)
7887 (if (or (not group)
7888 (gnus-ephemeral-group-p gnus-newsgroup-name))
7889 (gnus-summary-exit)
7890 (gnus-summary-next-group nil group backward)))
7892 (push (cdr keve) unread-command-events))))))
7894 (defun gnus-summary-next-unread-article ()
7895 "Select unread article after current one."
7896 (interactive)
7897 (gnus-summary-next-article
7898 (or (not (eq gnus-summary-goto-unread 'never))
7899 (gnus-summary-last-article-p (gnus-summary-article-number)))
7900 (and gnus-auto-select-same
7901 (gnus-summary-article-subject))))
7903 (defun gnus-summary-prev-article (&optional unread subject)
7904 "Select the article before the current one.
7905 If UNREAD is non-nil, only unread articles are selected."
7906 (interactive "P")
7907 (gnus-summary-next-article unread subject t))
7909 (defun gnus-summary-prev-unread-article ()
7910 "Select unread article before current one."
7911 (interactive)
7912 (gnus-summary-prev-article
7913 (or (not (eq gnus-summary-goto-unread 'never))
7914 (gnus-summary-first-article-p (gnus-summary-article-number)))
7915 (and gnus-auto-select-same
7916 (gnus-summary-article-subject))))
7918 (declare-function gnus-article-only-boring-p "gnus-art" ())
7920 (defun gnus-summary-next-page (&optional lines circular stop)
7921 "Show next page of the selected article.
7922 If at the end of the current article, select the next article.
7923 LINES says how many lines should be scrolled up.
7925 If CIRCULAR is non-nil, go to the start of the article instead of
7926 selecting the next article when reaching the end of the current
7927 article.
7929 If STOP is non-nil, just stop when reaching the end of the message.
7931 Also see the variable `gnus-article-skip-boring'."
7932 (interactive "P")
7933 (gnus-set-global-variables)
7934 (let ((article (gnus-summary-article-number))
7935 (article-window (get-buffer-window gnus-article-buffer t))
7936 endp)
7937 ;; If the buffer is empty, we have no article.
7938 (unless article
7939 (error "No article to select"))
7940 (gnus-configure-windows 'article)
7941 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
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 (if (or (null gnus-current-article)
7947 (null gnus-article-current)
7948 (/= article (cdr gnus-article-current))
7949 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7950 ;; Selected subject is different from current article's.
7951 (gnus-summary-display-article article)
7952 (when article-window
7953 (gnus-eval-in-buffer-window gnus-article-buffer
7954 (setq endp (or (gnus-article-next-page lines)
7955 (gnus-article-only-boring-p))))
7956 (when endp
7957 (cond ((or stop gnus-summary-stop-at-end-of-message)
7958 (gnus-message 3 "End of message"))
7959 (circular
7960 (gnus-summary-beginning-of-article))
7961 (lines
7962 (gnus-message 3 "End of message"))
7963 ((null lines)
7964 (if (and (eq gnus-summary-goto-unread 'never)
7965 (not (gnus-summary-last-article-p article)))
7966 (gnus-summary-next-article)
7967 (gnus-summary-next-unread-article))))))))
7968 (gnus-summary-recenter)
7969 (gnus-summary-position-point)))
7971 (defun gnus-summary-prev-page (&optional lines move)
7972 "Show previous page of selected article.
7973 Argument LINES specifies lines to be scrolled down.
7974 If MOVE, move to the previous unread article if point is at
7975 the beginning of the buffer."
7976 (interactive "P")
7977 (let ((article (gnus-summary-article-number))
7978 (article-window (get-buffer-window gnus-article-buffer t))
7979 endp)
7980 (gnus-configure-windows 'article)
7981 (if (or (null gnus-current-article)
7982 (null gnus-article-current)
7983 (/= article (cdr gnus-article-current))
7984 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7985 ;; Selected subject is different from current article's.
7986 (gnus-summary-display-article article)
7987 (gnus-summary-recenter)
7988 (when article-window
7989 (gnus-eval-in-buffer-window gnus-article-buffer
7990 (setq endp (gnus-article-prev-page lines)))
7991 (when (and move endp)
7992 (cond (lines
7993 (gnus-message 3 "Beginning of message"))
7994 ((null lines)
7995 (if (and (eq gnus-summary-goto-unread 'never)
7996 (not (gnus-summary-first-article-p article)))
7997 (gnus-summary-prev-article)
7998 (gnus-summary-prev-unread-article))))))))
7999 (gnus-summary-position-point))
8001 (defun gnus-summary-prev-page-or-article (&optional lines)
8002 "Show previous page of selected article.
8003 Argument LINES specifies lines to be scrolled down.
8004 If at the beginning of the article, go to the next article."
8005 (interactive "P")
8006 (gnus-summary-prev-page lines t))
8008 (defun gnus-summary-scroll-up (lines)
8009 "Scroll up (or down) one line current article.
8010 Argument LINES specifies lines to be scrolled up (or down if negative).
8011 If no article is selected, then the current article will be selected first."
8012 (interactive "p")
8013 (gnus-configure-windows 'article)
8014 (gnus-summary-show-thread)
8015 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8016 (gnus-eval-in-buffer-window gnus-article-buffer
8017 (cond ((> lines 0)
8018 (when (gnus-article-next-page lines)
8019 (gnus-message 3 "End of message")))
8020 ((< lines 0)
8021 (gnus-article-prev-page (- lines))))))
8022 (gnus-summary-recenter)
8023 (gnus-summary-position-point))
8025 (defun gnus-summary-scroll-down (lines)
8026 "Scroll down (or up) one line current article.
8027 Argument LINES specifies lines to be scrolled down (or up if negative).
8028 If no article is selected, then the current article will be selected first."
8029 (interactive "p")
8030 (gnus-summary-scroll-up (- lines)))
8032 (defun gnus-summary-next-same-subject ()
8033 "Select next article which has the same subject as current one."
8034 (interactive)
8035 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8037 (defun gnus-summary-prev-same-subject ()
8038 "Select previous article which has the same subject as current one."
8039 (interactive)
8040 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8042 (defun gnus-summary-next-unread-same-subject ()
8043 "Select next unread article which has the same subject as current one."
8044 (interactive)
8045 (gnus-summary-next-article t (gnus-summary-article-subject)))
8047 (defun gnus-summary-prev-unread-same-subject ()
8048 "Select previous unread article which has the same subject as current one."
8049 (interactive)
8050 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8052 (defun gnus-summary-first-unread-article ()
8053 "Select the first unread article.
8054 Return nil if there are no unread articles."
8055 (interactive)
8056 (prog1
8057 (when (gnus-summary-first-subject t)
8058 (gnus-summary-show-thread)
8059 (gnus-summary-first-subject t)
8060 (gnus-summary-display-article (gnus-summary-article-number)))
8061 (gnus-summary-position-point)))
8063 (defun gnus-summary-first-unread-subject ()
8064 "Place the point on the subject line of the first unread article.
8065 Return nil if there are no unread articles."
8066 (interactive)
8067 (prog1
8068 (when (gnus-summary-first-subject t)
8069 (gnus-summary-show-thread)
8070 (gnus-summary-first-subject t))
8071 (gnus-summary-position-point)))
8073 (defun gnus-summary-first-unseen-subject ()
8074 "Place the point on the subject line of the first unseen article.
8075 Return nil if there are no unseen articles."
8076 (interactive)
8077 (prog1
8078 (when (gnus-summary-first-subject nil nil t)
8079 (gnus-summary-show-thread)
8080 (gnus-summary-first-subject nil nil t))
8081 (gnus-summary-position-point)))
8083 (defun gnus-summary-first-unseen-or-unread-subject ()
8084 "Place the point on the subject line of the first unseen and unread article.
8085 If all article have been seen, on the subject line of the first unread
8086 article."
8087 (interactive)
8088 (prog1
8089 (unless (when (gnus-summary-first-subject nil nil t)
8090 (gnus-summary-show-thread)
8091 (gnus-summary-first-subject nil nil t))
8092 (when (gnus-summary-first-subject t)
8093 (gnus-summary-show-thread)
8094 (gnus-summary-first-subject t)))
8095 (gnus-summary-position-point)))
8097 (defun gnus-summary-first-article ()
8098 "Select the first article.
8099 Return nil if there are no articles."
8100 (interactive)
8101 (prog1
8102 (when (gnus-summary-first-subject)
8103 (gnus-summary-show-thread)
8104 (gnus-summary-first-subject)
8105 (gnus-summary-display-article (gnus-summary-article-number)))
8106 (gnus-summary-position-point)))
8108 (defun gnus-summary-best-unread-article (&optional arg)
8109 "Select the unread article with the highest score.
8110 If given a prefix argument, select the next unread article that has a
8111 score higher than the default score."
8112 (interactive "P")
8113 (let ((article (if arg
8114 (gnus-summary-better-unread-subject)
8115 (gnus-summary-best-unread-subject))))
8116 (if article
8117 (gnus-summary-goto-article article)
8118 (error "No unread articles"))))
8120 (defun gnus-summary-best-unread-subject ()
8121 "Select the unread subject with the highest score."
8122 (interactive)
8123 (let ((best -1000000)
8124 (data gnus-newsgroup-data)
8125 article score)
8126 (while data
8127 (and (gnus-data-unread-p (car data))
8128 (> (setq score
8129 (gnus-summary-article-score (gnus-data-number (car data))))
8130 best)
8131 (setq best score
8132 article (gnus-data-number (car data))))
8133 (setq data (cdr data)))
8134 (when article
8135 (gnus-summary-goto-subject article))
8136 (gnus-summary-position-point)
8137 article))
8139 (defun gnus-summary-better-unread-subject ()
8140 "Select the first unread subject that has a score over the default score."
8141 (interactive)
8142 (let ((data gnus-newsgroup-data)
8143 article score)
8144 (while (and (setq article (gnus-data-number (car data)))
8145 (or (gnus-data-read-p (car data))
8146 (not (> (gnus-summary-article-score article)
8147 gnus-summary-default-score))))
8148 (setq data (cdr data)))
8149 (when article
8150 (gnus-summary-goto-subject article))
8151 (gnus-summary-position-point)
8152 article))
8154 (defun gnus-summary-last-subject ()
8155 "Go to the last displayed subject line in the group."
8156 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8157 (when article
8158 (gnus-summary-goto-subject article))))
8160 (defun gnus-summary-goto-article (article &optional all-headers force)
8161 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8162 If ALL-HEADERS is non-nil, no header lines are hidden.
8163 If FORCE, go to the article even if it isn't displayed. If FORCE
8164 is a number, it is the line the article is to be displayed on."
8165 (interactive
8166 (list
8167 (gnus-completing-read
8168 "Article number or Message-ID"
8169 (mapcar 'int-to-string gnus-newsgroup-limit))
8170 current-prefix-arg
8172 (prog1
8173 (if (and (stringp article)
8174 (string-match "@\\|%40" article))
8175 (gnus-summary-refer-article article)
8176 (when (stringp article)
8177 (setq article (string-to-number article)))
8178 (if (gnus-summary-goto-subject article force)
8179 (gnus-summary-display-article article all-headers)
8180 (gnus-message 4 "Couldn't go to article %s" article) nil))
8181 (gnus-summary-position-point)))
8183 (defun gnus-summary-goto-last-article ()
8184 "Go to the previously read article."
8185 (interactive)
8186 (prog1
8187 (when gnus-last-article
8188 (gnus-summary-goto-article gnus-last-article nil t))
8189 (gnus-summary-position-point)))
8191 (defun gnus-summary-pop-article (number)
8192 "Pop one article off the history and go to the previous.
8193 NUMBER articles will be popped off."
8194 (interactive "p")
8195 (let (to)
8196 (setq gnus-newsgroup-history
8197 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8198 (if to
8199 (gnus-summary-goto-article (car to) nil t)
8200 (error "Article history empty")))
8201 (gnus-summary-position-point))
8203 ;; Summary commands and functions for limiting the summary buffer.
8205 (defun gnus-summary-limit-to-articles (n)
8206 "Limit the summary buffer to the next N articles.
8207 If not given a prefix, use the process marked articles instead."
8208 (interactive "P")
8209 (prog1
8210 (let ((articles (gnus-summary-work-articles n)))
8211 (setq gnus-newsgroup-processable nil)
8212 (gnus-summary-limit articles))
8213 (gnus-summary-position-point)))
8215 (defun gnus-summary-pop-limit (&optional total)
8216 "Restore the previous limit.
8217 If given a prefix, remove all limits."
8218 (interactive "P")
8219 (when total
8220 (setq gnus-newsgroup-limits
8221 (list (mapcar (lambda (h) (mail-header-number h))
8222 gnus-newsgroup-headers))))
8223 (unless gnus-newsgroup-limits
8224 (error "No limit to pop"))
8225 (prog1
8226 (gnus-summary-limit nil 'pop)
8227 (gnus-summary-position-point)))
8229 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8230 "Limit the summary buffer to articles that have subjects that match a regexp.
8231 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8232 (interactive
8233 (list (read-string (if current-prefix-arg
8234 "Exclude subject (regexp): "
8235 "Limit to subject (regexp): "))
8236 nil current-prefix-arg))
8237 (unless header
8238 (setq header "subject"))
8239 (when (not (equal "" subject))
8240 (prog1
8241 (let ((articles (gnus-summary-find-matching
8242 (or header "subject") subject 'all nil nil
8243 not-matching)))
8244 (unless articles
8245 (error "Found no matches for \"%s\"" subject))
8246 (gnus-summary-limit articles))
8247 (gnus-summary-position-point))))
8249 (defun gnus-summary-limit-to-author (from &optional not-matching)
8250 "Limit the summary buffer to articles that have authors that match a regexp.
8251 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8252 (interactive
8253 (list (let* ((header (gnus-summary-article-header))
8254 (default (and header (car (mail-header-parse-address
8255 (mail-header-from header))))))
8256 (read-string (concat (if current-prefix-arg
8257 "Exclude author (regexp"
8258 "Limit to author (regexp")
8259 (if default
8260 (concat ", default \"" default "\"): ")
8261 "): "))
8262 nil nil
8263 default))
8264 current-prefix-arg))
8265 (gnus-summary-limit-to-subject from "from" not-matching))
8267 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8268 "Limit the summary buffer to articles with the given RECIPIENT.
8270 If NOT-MATCHING, exclude RECIPIENT.
8272 To and Cc headers are checked. You need to include them in
8273 `nnmail-extra-headers'."
8274 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8275 (interactive
8276 (list (read-string (format "%s recipient (regexp): "
8277 (if current-prefix-arg "Exclude" "Limit to")))
8278 current-prefix-arg))
8279 (when (not (equal "" recipient))
8280 (prog1 (let* ((to
8281 (if (memq 'To nnmail-extra-headers)
8282 (gnus-summary-find-matching
8283 (cons 'extra 'To) recipient 'all nil nil
8284 not-matching)
8285 (gnus-message
8286 1 "`To' isn't present in `nnmail-extra-headers'")
8287 (sit-for 1)
8288 nil))
8290 (if (memq 'Cc nnmail-extra-headers)
8291 (gnus-summary-find-matching
8292 (cons 'extra 'Cc) recipient 'all nil nil
8293 not-matching)
8294 (gnus-message
8295 1 "`Cc' isn't present in `nnmail-extra-headers'")
8296 (sit-for 1)
8297 nil))
8298 (articles
8299 (if not-matching
8300 ;; We need the numbers that are in both lists:
8301 (mapcar (lambda (a)
8302 (and (memq a to) a))
8304 (nconc to cc))))
8305 (unless articles
8306 (error "Found no matches for \"%s\"" recipient))
8307 (gnus-summary-limit articles))
8308 (gnus-summary-position-point))))
8310 (defun gnus-summary-limit-to-address (address &optional not-matching)
8311 "Limit the summary buffer to articles with the given ADDRESS.
8313 If NOT-MATCHING, exclude ADDRESS.
8315 To, Cc and From headers are checked. You need to include `To' and `Cc'
8316 in `nnmail-extra-headers'."
8317 (interactive
8318 (list (read-string (format "%s address (regexp): "
8319 (if current-prefix-arg "Exclude" "Limit to")))
8320 current-prefix-arg))
8321 (when (not (equal "" address))
8322 (prog1 (let* ((to
8323 (if (memq 'To nnmail-extra-headers)
8324 (gnus-summary-find-matching
8325 (cons 'extra 'To) address 'all nil nil
8326 not-matching)
8327 (gnus-message
8328 1 "`To' isn't present in `nnmail-extra-headers'")
8329 (sit-for 1)
8332 (if (memq 'Cc nnmail-extra-headers)
8333 (gnus-summary-find-matching
8334 (cons 'extra 'Cc) address 'all nil nil
8335 not-matching)
8336 (gnus-message
8337 1 "`Cc' isn't present in `nnmail-extra-headers'")
8338 (sit-for 1)
8340 (from
8341 (gnus-summary-find-matching "from" address
8342 'all nil nil not-matching))
8343 (articles
8344 (if not-matching
8345 ;; We need the numbers that are in all lists:
8346 (if (eq cc t)
8347 (if (eq to t)
8348 from
8349 (mapcar (lambda (a) (car (memq a from))) to))
8350 (if (eq to t)
8351 (mapcar (lambda (a) (car (memq a from))) cc)
8352 (mapcar (lambda (a) (car (memq a from)))
8353 (mapcar (lambda (a) (car (memq a to)))
8354 cc))))
8355 (nconc (if (eq to t) nil to)
8356 (if (eq cc t) nil cc)
8357 from))))
8358 (unless articles
8359 (error "Found no matches for \"%s\"" address))
8360 (gnus-summary-limit articles))
8361 (gnus-summary-position-point))))
8363 (defun gnus-summary-limit-strange-charsets-predicate (header)
8364 (when (fboundp 'char-charset)
8365 (let ((string (concat (mail-header-subject header)
8366 (mail-header-from header)))
8367 charset found)
8368 (dotimes (i (1- (length string)))
8369 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8370 (when (string-match "unicode\\|big\\|japanese" charset)
8371 (setq found t)))
8372 found)))
8374 (defun gnus-summary-limit-to-predicate (predicate)
8375 "Limit to articles where PREDICATE returns non-nil.
8376 PREDICATE will be called with the header structures of the
8377 articles."
8378 (let ((articles nil)
8379 (case-fold-search t))
8380 (dolist (header gnus-newsgroup-headers)
8381 (when (funcall predicate header)
8382 (push (mail-header-number header) articles)))
8383 (gnus-summary-limit (nreverse articles))))
8385 (defun gnus-summary-limit-to-age (age &optional younger-p)
8386 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8387 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8388 articles that are younger than AGE days."
8389 (interactive
8390 (let ((younger current-prefix-arg)
8391 (days-got nil)
8392 days)
8393 (while (not days-got)
8394 (setq days (if younger
8395 (read-string "Limit to articles younger than (in days, older when negative): ")
8396 (read-string
8397 "Limit to articles older than (in days, younger when negative): ")))
8398 (when (> (length days) 0)
8399 (setq days (read days)))
8400 (if (numberp days)
8401 (progn
8402 (setq days-got t)
8403 (when (< days 0)
8404 (setq younger (not younger))
8405 (setq days (* days -1))))
8406 (message "Please enter a number.")
8407 (sleep-for 1)))
8408 (list days younger)))
8409 (prog1
8410 (let ((data gnus-newsgroup-data)
8411 (cutoff (days-to-time age))
8412 articles d date is-younger)
8413 (while (setq d (pop data))
8414 (when (and (vectorp (gnus-data-header d))
8415 (setq date (mail-header-date (gnus-data-header d))))
8416 (setq is-younger (time-less-p
8417 (time-since (gnus-date-get-time date))
8418 cutoff))
8419 (when (if younger-p
8420 is-younger
8421 (not is-younger))
8422 (push (gnus-data-number d) articles))))
8423 (gnus-summary-limit (nreverse articles)))
8424 (gnus-summary-position-point)))
8426 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8427 "Limit the summary buffer to articles that match an 'extra' header."
8428 (interactive
8429 (let ((header
8430 (intern
8431 (gnus-completing-read
8432 (if current-prefix-arg
8433 "Exclude extra header"
8434 "Limit extra header")
8435 (mapcar 'symbol-name gnus-extra-headers)
8436 t nil nil
8437 (symbol-name (car gnus-extra-headers))))))
8438 (list header
8439 (read-string (format "%s header %s (regexp): "
8440 (if current-prefix-arg "Exclude" "Limit to")
8441 header))
8442 current-prefix-arg)))
8443 (when (not (equal "" regexp))
8444 (prog1
8445 (let ((articles (gnus-summary-find-matching
8446 (cons 'extra header) regexp 'all nil nil
8447 not-matching)))
8448 (unless articles
8449 (error "Found no matches for \"%s\"" regexp))
8450 (gnus-summary-limit articles))
8451 (gnus-summary-position-point))))
8453 (defun gnus-summary-limit-to-display-predicate ()
8454 "Limit the summary buffer to the predicated in the `display' group parameter."
8455 (interactive)
8456 (unless gnus-newsgroup-display
8457 (error "There is no `display' group parameter"))
8458 (let (articles)
8459 (dolist (gnus-number gnus-newsgroup-articles)
8460 (when (funcall gnus-newsgroup-display)
8461 (push gnus-number articles)))
8462 (gnus-summary-limit articles))
8463 (gnus-summary-position-point))
8465 (defun gnus-summary-limit-to-unread (&optional all)
8466 "Limit the summary buffer to articles that are not marked as read.
8467 If ALL is non-nil, limit strictly to unread articles."
8468 (interactive "P")
8469 (if all
8470 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8471 (gnus-summary-limit-to-marks
8472 ;; Concat all the marks that say that an article is read and have
8473 ;; those removed.
8474 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8475 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8476 gnus-low-score-mark gnus-expirable-mark
8477 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8478 gnus-duplicate-mark)
8479 'reverse)))
8481 (defun gnus-summary-limit-to-headers (match &optional reverse)
8482 "Limit the summary buffer to articles that have headers that match MATCH.
8483 If REVERSE (the prefix), limit to articles that don't match."
8484 (interactive "sMatch headers (regexp): \nP")
8485 (gnus-summary-limit-to-bodies match reverse t))
8487 (declare-function article-goto-body "gnus-art" ())
8489 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8490 "Limit the summary buffer to articles that have bodies that match MATCH.
8491 If REVERSE (the prefix), limit to articles that don't match."
8492 (interactive "sMatch body (regexp): \nP")
8493 (let ((articles nil)
8494 (gnus-select-article-hook nil) ;Disable hook.
8495 (gnus-article-prepare-hook nil)
8496 (gnus-use-article-prefetch nil)
8497 (gnus-keep-backlog nil)
8498 (gnus-break-pages nil)
8499 (gnus-summary-display-arrow nil)
8500 (gnus-updated-mode-lines nil)
8501 (gnus-auto-center-summary nil)
8502 (gnus-display-mime-function nil))
8503 (dolist (data gnus-newsgroup-data)
8504 (let (gnus-mark-article-hook)
8505 (gnus-summary-select-article t t nil (gnus-data-number data)))
8506 (with-current-buffer gnus-article-buffer
8507 (article-goto-body)
8508 (let* ((case-fold-search t)
8509 (found (if headersp
8510 (re-search-backward match nil t)
8511 (re-search-forward match nil t))))
8512 (when (or (and found
8513 (not reverse))
8514 (and (not found)
8515 reverse))
8516 (push (gnus-data-number data) articles)))))
8517 (if (not articles)
8518 (message "No messages matched")
8519 (gnus-summary-limit articles)))
8520 (gnus-summary-position-point))
8522 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8523 "Limit the summary buffer to articles that aren't part on any thread.
8524 If THREADSP (the prefix), limit to articles that are in threads."
8525 (interactive "P")
8526 (let ((articles nil)
8527 thread-articles
8528 threads)
8529 (dolist (thread gnus-newsgroup-threads)
8530 (if (stringp (car thread))
8531 (dolist (thread (cdr thread))
8532 (push thread threads))
8533 (push thread threads)))
8534 (dolist (thread threads)
8535 (setq thread-articles (gnus-articles-in-thread thread))
8536 (when (or (and threadsp
8537 (> (length thread-articles) 1))
8538 (and (not threadsp)
8539 (= (length thread-articles) 1)))
8540 (setq articles (nconc thread-articles articles))))
8541 (if (not articles)
8542 (message "No messages matched")
8543 (gnus-summary-limit articles))
8544 (gnus-summary-position-point)))
8546 (defun gnus-summary-limit-to-replied (&optional unreplied)
8547 "Limit the summary buffer to replied articles.
8548 If UNREPLIED (the prefix), limit to unreplied articles."
8549 (interactive "P")
8550 (if unreplied
8551 (gnus-summary-limit
8552 (gnus-set-difference gnus-newsgroup-articles
8553 gnus-newsgroup-replied))
8554 (gnus-summary-limit gnus-newsgroup-replied))
8555 (gnus-summary-position-point))
8557 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8558 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8559 If REVERSE, limit the summary buffer to articles that are marked
8560 with MARKS. MARKS can either be a string of marks or a list of marks.
8561 Returns how many articles were removed."
8562 (interactive "sMarks: ")
8563 (gnus-summary-limit-to-marks marks t))
8565 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8566 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8567 If REVERSE (the prefix), limit the summary buffer to articles that are
8568 not marked with MARKS. MARKS can either be a string of marks or a
8569 list of marks.
8570 Returns how many articles were removed."
8571 (interactive "sMarks: \nP")
8572 (prog1
8573 (let ((data gnus-newsgroup-data)
8574 (marks (if (listp marks) marks
8575 (append marks nil))) ; Transform to list.
8576 articles)
8577 (while data
8578 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8579 (memq (gnus-data-mark (car data)) marks))
8580 (push (gnus-data-number (car data)) articles))
8581 (setq data (cdr data)))
8582 (gnus-summary-limit articles))
8583 (gnus-summary-position-point)))
8585 (defun gnus-summary-limit-to-score (score)
8586 "Limit to articles with score at or above SCORE."
8587 (interactive "NLimit to articles with score of at least: ")
8588 (let ((data gnus-newsgroup-data)
8589 articles)
8590 (while data
8591 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8592 score)
8593 (push (gnus-data-number (car data)) articles))
8594 (setq data (cdr data)))
8595 (prog1
8596 (gnus-summary-limit articles)
8597 (gnus-summary-position-point))))
8599 (defun gnus-summary-limit-to-unseen ()
8600 "Limit to unseen articles."
8601 (interactive)
8602 (prog1
8603 (gnus-summary-limit gnus-newsgroup-unseen)
8604 (gnus-summary-position-point)))
8606 (defun gnus-summary-limit-include-thread (id)
8607 "Display all the hidden articles that is in the thread with ID in it.
8608 When called interactively, ID is the Message-ID of the current
8609 article."
8610 (interactive (list (mail-header-id (gnus-summary-article-header))))
8611 (let ((articles (gnus-articles-in-thread
8612 (gnus-id-to-thread (gnus-root-id id))))
8613 ;;we REALLY want the whole thread---this prevents cut-threads
8614 ;;from removing the thread we want to include.
8615 (gnus-fetch-old-headers nil)
8616 (gnus-build-sparse-threads nil))
8617 (prog1
8618 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8619 (gnus-summary-limit-include-matching-articles
8620 "subject"
8621 (regexp-quote (gnus-simplify-subject-re
8622 (mail-header-subject (gnus-id-to-header id)))))
8623 (gnus-summary-position-point))))
8625 (defun gnus-summary-limit-include-matching-articles (header regexp)
8626 "Display all the hidden articles that have HEADERs that match REGEXP."
8627 (interactive (list (read-string "Match on header: ")
8628 (read-string "Regexp: ")))
8629 (let ((articles (gnus-find-matching-articles header regexp)))
8630 (prog1
8631 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8632 (gnus-summary-position-point))))
8634 (defun gnus-summary-insert-dormant-articles ()
8635 "Insert all the dormant articles for this group into the current buffer."
8636 (interactive)
8637 (let ((gnus-verbose (max 6 gnus-verbose)))
8638 (if (not gnus-newsgroup-dormant)
8639 (gnus-message 3 "No dormant articles for this group")
8640 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8642 (defun gnus-summary-insert-ticked-articles ()
8643 "Insert ticked articles for this group into the current buffer."
8644 (interactive)
8645 (let ((gnus-verbose (max 6 gnus-verbose)))
8646 (if (not gnus-newsgroup-marked)
8647 (gnus-message 3 "No ticked articles for this group")
8648 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8650 (defun gnus-summary-limit-include-dormant ()
8651 "Display all the hidden articles that are marked as dormant.
8652 Note that this command only works on a subset of the articles currently
8653 fetched for this group."
8654 (interactive)
8655 (unless gnus-newsgroup-dormant
8656 (error "There are no dormant articles in this group"))
8657 (prog1
8658 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8659 (gnus-summary-position-point)))
8661 (defun gnus-summary-include-articles (articles)
8662 "Fetch the headers for ARTICLES and then display the summary lines."
8663 (let ((gnus-inhibit-demon t)
8664 (gnus-agent nil)
8665 (gnus-read-all-available-headers t))
8666 (setq gnus-newsgroup-headers
8667 (gnus-merge
8668 'list gnus-newsgroup-headers
8669 (gnus-fetch-headers articles nil t)
8670 'gnus-article-sort-by-number))
8671 (setq gnus-newsgroup-articles
8672 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8673 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8675 (defun gnus-summary-limit-exclude-dormant ()
8676 "Hide all dormant articles."
8677 (interactive)
8678 (prog1
8679 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8680 (gnus-summary-position-point)))
8682 (defun gnus-summary-limit-exclude-childless-dormant ()
8683 "Hide all dormant articles that have no children."
8684 (interactive)
8685 (let ((data (gnus-data-list t))
8686 articles d children)
8687 ;; Find all articles that are either not dormant or have
8688 ;; children.
8689 (while (setq d (pop data))
8690 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8691 (and (setq children
8692 (gnus-article-children (gnus-data-number d)))
8693 (let (found)
8694 (while children
8695 (when (memq (car children) articles)
8696 (setq children nil
8697 found t))
8698 (pop children))
8699 found)))
8700 (push (gnus-data-number d) articles)))
8701 ;; Do the limiting.
8702 (prog1
8703 (gnus-summary-limit articles)
8704 (gnus-summary-position-point))))
8706 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8707 "Mark all unread excluded articles as read.
8708 If ALL, mark even excluded ticked and dormants as read."
8709 (interactive "P")
8710 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8711 (let ((articles (gnus-sorted-ndifference
8712 (sort
8713 (mapcar (lambda (h) (mail-header-number h))
8714 gnus-newsgroup-headers)
8716 gnus-newsgroup-limit))
8717 article)
8718 (setq gnus-newsgroup-unreads
8719 (gnus-sorted-intersection gnus-newsgroup-unreads
8720 gnus-newsgroup-limit))
8721 (if all
8722 (setq gnus-newsgroup-dormant nil
8723 gnus-newsgroup-marked nil
8724 gnus-newsgroup-reads
8725 (nconc
8726 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8727 gnus-newsgroup-reads))
8728 (while (setq article (pop articles))
8729 (unless (or (memq article gnus-newsgroup-dormant)
8730 (memq article gnus-newsgroup-marked))
8731 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8733 (defun gnus-summary-limit (articles &optional pop)
8734 (if pop
8735 ;; We pop the previous limit off the stack and use that.
8736 (setq articles (car gnus-newsgroup-limits)
8737 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8738 ;; We use the new limit, so we push the old limit on the stack.
8739 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8740 ;; Set the limit.
8741 (setq gnus-newsgroup-limit articles)
8742 (let ((total (length gnus-newsgroup-data))
8743 (data (gnus-data-find-list (gnus-summary-article-number)))
8744 (gnus-summary-mark-below nil) ; Inhibit this.
8745 found)
8746 ;; This will do all the work of generating the new summary buffer
8747 ;; according to the new limit.
8748 (gnus-summary-prepare)
8749 ;; Hide any threads, possibly.
8750 (gnus-summary-maybe-hide-threads)
8751 ;; Try to return to the article you were at, or one in the
8752 ;; neighborhood.
8753 (when data
8754 ;; We try to find some article after the current one.
8755 (while data
8756 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8757 (setq data nil
8758 found t))
8759 (setq data (cdr data))))
8760 (unless found
8761 ;; If there is no data, that means that we were after the last
8762 ;; article. The same goes when we can't find any articles
8763 ;; after the current one.
8764 (goto-char (point-max))
8765 (gnus-summary-find-prev))
8766 (gnus-set-mode-line 'summary)
8767 ;; We return how many articles were removed from the summary
8768 ;; buffer as a result of the new limit.
8769 (- total (length gnus-newsgroup-data))))
8771 (defsubst gnus-invisible-cut-children (threads)
8772 (let ((num 0))
8773 (while threads
8774 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8775 (incf num))
8776 (pop threads))
8777 (< num 2)))
8779 (defsubst gnus-cut-thread (thread)
8780 "Go forwards in the thread until we find an article that we want to display."
8781 (when (or (eq gnus-fetch-old-headers 'some)
8782 (eq gnus-fetch-old-headers 'invisible)
8783 (numberp gnus-fetch-old-headers)
8784 (eq gnus-build-sparse-threads 'some)
8785 (eq gnus-build-sparse-threads 'more))
8786 ;; Deal with old-fetched headers and sparse threads.
8787 (while (and
8788 thread
8790 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8791 (gnus-summary-article-ancient-p
8792 (mail-header-number (car thread))))
8793 (if (or (<= (length (cdr thread)) 1)
8794 (eq gnus-fetch-old-headers 'invisible))
8795 (setq gnus-newsgroup-limit
8796 (delq (mail-header-number (car thread))
8797 gnus-newsgroup-limit)
8798 thread (cadr thread))
8799 (when (gnus-invisible-cut-children (cdr thread))
8800 (let ((th (cdr thread)))
8801 (while th
8802 (if (memq (mail-header-number (caar th))
8803 gnus-newsgroup-limit)
8804 (setq thread (car th)
8805 th nil)
8806 (setq th (cdr th))))))))))
8807 thread)
8809 (defun gnus-cut-threads (threads)
8810 "Cut off all uninteresting articles from the beginning of THREADS."
8811 (when (or (eq gnus-fetch-old-headers 'some)
8812 (eq gnus-fetch-old-headers 'invisible)
8813 (numberp gnus-fetch-old-headers)
8814 (eq gnus-build-sparse-threads 'some)
8815 (eq gnus-build-sparse-threads 'more))
8816 (let ((th threads))
8817 (while th
8818 (setcar th (gnus-cut-thread (car th)))
8819 (setq th (cdr th)))))
8820 ;; Remove nixed out threads.
8821 (delq nil threads))
8823 (defun gnus-summary-initial-limit (&optional show-if-empty)
8824 "Figure out what the initial limit is supposed to be on group entry.
8825 This entails weeding out unwanted dormants, low-scored articles,
8826 fetch-old-headers verbiage, and so on."
8827 ;; Most groups have nothing to remove.
8828 (unless (or gnus-inhibit-limiting
8829 (and (null gnus-newsgroup-dormant)
8830 (eq gnus-newsgroup-display 'gnus-not-ignore)
8831 (not (eq gnus-fetch-old-headers 'some))
8832 (not (numberp gnus-fetch-old-headers))
8833 (not (eq gnus-fetch-old-headers 'invisible))
8834 (null gnus-summary-expunge-below)
8835 (not (eq gnus-build-sparse-threads 'some))
8836 (not (eq gnus-build-sparse-threads 'more))
8837 (null gnus-thread-expunge-below)))
8838 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8839 (setq gnus-newsgroup-limit nil)
8840 (mapatoms
8841 (lambda (node)
8842 (unless (car (symbol-value node))
8843 ;; These threads have no parents -- they are roots.
8844 (let ((nodes (cdr (symbol-value node)))
8845 thread)
8846 (while nodes
8847 (if (and gnus-thread-expunge-below
8848 (< (gnus-thread-total-score (car nodes))
8849 gnus-thread-expunge-below))
8850 (gnus-expunge-thread (pop nodes))
8851 (setq thread (pop nodes))
8852 (gnus-summary-limit-children thread))))))
8853 gnus-newsgroup-dependencies)
8854 ;; If this limitation resulted in an empty group, we might
8855 ;; pop the previous limit and use it instead.
8856 (when (and (not gnus-newsgroup-limit)
8857 show-if-empty)
8858 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8859 gnus-newsgroup-limit))
8861 (defun gnus-summary-limit-children (thread)
8862 "Return 1 if this subthread is visible and 0 if it is not."
8863 ;; First we get the number of visible children to this thread. This
8864 ;; is done by recursing down the thread using this function, so this
8865 ;; will really go down to a leaf article first, before slowly
8866 ;; working its way up towards the root.
8867 (when thread
8868 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8869 (children
8870 (if (cdr thread)
8871 (apply '+ (mapcar 'gnus-summary-limit-children
8872 (cdr thread)))
8874 (number (mail-header-number (car thread)))
8875 score)
8876 (if (and
8877 (not (memq number gnus-newsgroup-marked))
8879 ;; If this article is dormant and has absolutely no visible
8880 ;; children, then this article isn't visible.
8881 (and (memq number gnus-newsgroup-dormant)
8882 (zerop children))
8883 ;; If this is "fetch-old-headered" and there is no
8884 ;; visible children, then we don't want this article.
8885 (and (or (eq gnus-fetch-old-headers 'some)
8886 (numberp gnus-fetch-old-headers))
8887 (gnus-summary-article-ancient-p number)
8888 (zerop children))
8889 ;; If this is "fetch-old-headered" and `invisible', then
8890 ;; we don't want this article.
8891 (and (eq gnus-fetch-old-headers 'invisible)
8892 (gnus-summary-article-ancient-p number))
8893 ;; If this is a sparsely inserted article with no children,
8894 ;; we don't want it.
8895 (and (eq gnus-build-sparse-threads 'some)
8896 (gnus-summary-article-sparse-p number)
8897 (zerop children))
8898 ;; If we use expunging, and this article is really
8899 ;; low-scored, then we don't want this article.
8900 (when (and gnus-summary-expunge-below
8901 (< (setq score
8902 (or (cdr (assq number gnus-newsgroup-scored))
8903 gnus-summary-default-score))
8904 gnus-summary-expunge-below))
8905 ;; We increase the expunge-tally here, but that has
8906 ;; nothing to do with the limits, really.
8907 (incf gnus-newsgroup-expunged-tally)
8908 ;; We also mark as read here, if that's wanted.
8909 (when (and gnus-summary-mark-below
8910 (< score gnus-summary-mark-below))
8911 (setq gnus-newsgroup-unreads
8912 (delq number gnus-newsgroup-unreads))
8913 (if gnus-newsgroup-auto-expire
8914 (push number gnus-newsgroup-expirable)
8915 (push (cons number gnus-low-score-mark)
8916 gnus-newsgroup-reads)))
8918 ;; Do the `display' group parameter.
8919 (and gnus-newsgroup-display
8920 (let ((gnus-number number))
8921 (not (funcall gnus-newsgroup-display))))))
8922 ;; Nope, invisible article.
8924 ;; Ok, this article is to be visible, so we add it to the limit
8925 ;; and return 1.
8926 (push number gnus-newsgroup-limit)
8927 1))))
8929 (defun gnus-expunge-thread (thread)
8930 "Mark all articles in THREAD as read."
8931 (let* ((number (mail-header-number (car thread))))
8932 (incf gnus-newsgroup-expunged-tally)
8933 ;; We also mark as read here, if that's wanted.
8934 (setq gnus-newsgroup-unreads
8935 (delq number gnus-newsgroup-unreads))
8936 (if gnus-newsgroup-auto-expire
8937 (push number gnus-newsgroup-expirable)
8938 (push (cons number gnus-low-score-mark)
8939 gnus-newsgroup-reads)))
8940 ;; Go recursively through all subthreads.
8941 (mapcar 'gnus-expunge-thread (cdr thread)))
8943 ;; Summary article oriented commands
8945 (defun gnus-summary-refer-parent-article (n)
8946 "Refer parent article N times.
8947 If N is negative, go to ancestor -N instead.
8948 The difference between N and the number of articles fetched is returned."
8949 (interactive "p")
8950 (let ((skip 1)
8951 error header ref)
8952 (when (not (natnump n))
8953 (setq skip (abs n)
8954 n 1))
8955 (while (and (> n 0)
8956 (not error))
8957 (setq header (gnus-summary-article-header))
8958 (if (and (eq (mail-header-number header)
8959 (cdr gnus-article-current))
8960 (equal gnus-newsgroup-name
8961 (car gnus-article-current)))
8962 ;; If we try to find the parent of the currently
8963 ;; displayed article, then we take a look at the actual
8964 ;; References header, since this is slightly more
8965 ;; reliable than the References field we got from the
8966 ;; server.
8967 (with-current-buffer gnus-original-article-buffer
8968 (nnheader-narrow-to-headers)
8969 (unless (setq ref (message-fetch-field "references"))
8970 (when (setq ref (message-fetch-field "in-reply-to"))
8971 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8972 (widen))
8973 (setq ref
8974 ;; It's not the current article, so we take a bet on
8975 ;; the value we got from the server.
8976 (mail-header-references header)))
8977 (if (and ref
8978 (not (equal ref "")))
8979 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8980 (gnus-message 1 "Couldn't find parent"))
8981 (gnus-message 1 "No references in article %d"
8982 (gnus-summary-article-number))
8983 (setq error t))
8984 (decf n))
8985 (gnus-summary-position-point)
8988 (defun gnus-summary-refer-references ()
8989 "Fetch all articles mentioned in the References header.
8990 Return the number of articles fetched."
8991 (interactive)
8992 (let ((ref (mail-header-references (gnus-summary-article-header)))
8993 (current (gnus-summary-article-number))
8994 (n 0))
8995 (if (or (not ref)
8996 (equal ref ""))
8997 (error "No References in the current article")
8998 ;; For each Message-ID in the References header...
8999 (while (string-match "<[^>]*>" ref)
9000 (incf n)
9001 ;; ... fetch that article.
9002 (gnus-summary-refer-article
9003 (prog1 (match-string 0 ref)
9004 (setq ref (substring ref (match-end 0))))))
9005 (gnus-summary-goto-subject current)
9006 (gnus-summary-position-point)
9007 n)))
9009 (defun gnus-delete-duplicate-headers (headers)
9010 ;; First remove leading duplicates.
9011 (while (and (> (length headers) 1)
9012 (= (mail-header-number (car headers))
9013 (mail-header-number (cadr headers))))
9014 (pop headers))
9015 ;; Then the rest.
9016 (let ((result headers))
9017 (while (> (length headers) 1)
9018 (if (= (mail-header-number (car headers))
9019 (mail-header-number (cadr headers)))
9020 (setcdr headers (cddr headers))
9021 (pop headers)))
9022 result))
9024 (defun gnus-summary-refer-thread (&optional limit)
9025 "Fetch all articles in the current thread. For backends that
9026 know how to search for threads (currently only 'nnimap) a
9027 non-numeric prefix arg will use nnir to search the entire
9028 server; without a prefix arg only the current group is
9029 searched. If the variable `gnus-refer-thread-use-nnir' is
9030 non-nil the prefix arg has the reverse meaning. If no
9031 backend-specific 'request-thread function is available fetch
9032 LIMIT (the numerical prefix) old headers. If LIMIT is
9033 non-numeric or nil fetch the number specified by the
9034 `gnus-refer-thread-limit' variable."
9035 (interactive "P")
9036 (gnus-warp-to-article)
9037 (let* ((header (gnus-summary-article-header))
9038 (id (mail-header-id header))
9039 (gnus-inhibit-demon t)
9040 (gnus-summary-ignore-duplicates t)
9041 (gnus-read-all-available-headers t)
9042 (gnus-refer-thread-use-nnir
9043 (if (and (not (null limit)) (listp limit))
9044 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9045 (new-headers
9046 (if (gnus-check-backend-function
9047 'request-thread gnus-newsgroup-name)
9048 (gnus-request-thread header gnus-newsgroup-name)
9049 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9050 gnus-refer-thread-limit))
9051 (last (if (numberp limit)
9052 (min (+ (mail-header-number header)
9053 limit)
9054 gnus-newsgroup-highest)
9055 gnus-newsgroup-highest))
9056 (subject (gnus-simplify-subject
9057 (mail-header-subject header)))
9058 (refs (split-string (or (mail-header-references header)
9059 "")))
9060 (gnus-parse-headers-hook
9061 `(lambda () (goto-char (point-min))
9062 (keep-lines
9063 (regexp-opt ',(append refs (list id subject)))))))
9064 (gnus-fetch-headers (list last) (if (numberp limit)
9065 (* 2 limit) limit) t))))
9066 article-ids)
9067 (when (listp new-headers)
9068 (dolist (header new-headers)
9069 (push (mail-header-number header) article-ids)
9070 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9071 (push (mail-header-number header) gnus-newsgroup-unreads)
9072 (setq gnus-newsgroup-unselected
9073 (delete (mail-header-number header)
9074 gnus-newsgroup-unselected))))
9075 (setq gnus-newsgroup-headers
9076 (gnus-delete-duplicate-headers
9077 (gnus-merge
9078 'list gnus-newsgroup-headers new-headers
9079 'gnus-article-sort-by-number)))
9080 (setq gnus-newsgroup-articles
9081 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9082 (gnus-summary-limit-include-thread id)))
9083 (gnus-summary-show-thread))
9085 (defun gnus-summary-refer-article (message-id)
9086 "Fetch an article specified by MESSAGE-ID."
9087 (interactive "sMessage-ID: ")
9088 (gnus-warp-to-article)
9089 (when (and (stringp message-id)
9090 (not (zerop (length message-id))))
9091 (setq message-id (gnus-replace-in-string message-id " " ""))
9092 ;; Construct the correct Message-ID if necessary.
9093 ;; Suggested by tale@pawl.rpi.edu.
9094 (unless (string-match "^<" message-id)
9095 (setq message-id (concat "<" message-id)))
9096 (unless (string-match ">$" message-id)
9097 (setq message-id (concat message-id ">")))
9098 ;; People often post MIDs from URLs, so unhex it:
9099 (unless (string-match "@" message-id)
9100 (setq message-id (gnus-url-unhex-string message-id)))
9101 (let* ((header (gnus-id-to-header message-id))
9102 (sparse (and header
9103 (gnus-summary-article-sparse-p
9104 (mail-header-number header))
9105 (memq (mail-header-number header)
9106 gnus-newsgroup-limit)))
9107 number)
9108 (cond
9109 ;; If the article is present in the buffer we just go to it.
9110 ((and header
9111 (or (not (gnus-summary-article-sparse-p
9112 (mail-header-number header)))
9113 sparse))
9114 (prog1
9115 (gnus-summary-goto-article
9116 (mail-header-number header) nil t)
9117 (when sparse
9118 (gnus-summary-update-article (mail-header-number header)))))
9120 ;; We fetch the article.
9121 (catch 'found
9122 (dolist (gnus-override-method (gnus-refer-article-methods))
9123 (when (and (gnus-check-server gnus-override-method)
9124 ;; Fetch the header,
9125 (setq number (gnus-summary-insert-subject message-id)))
9126 ;; and display the article.
9127 (gnus-summary-select-article nil nil nil number)
9128 (throw 'found t)))
9129 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9131 (defun gnus-refer-article-methods ()
9132 "Return a list of referable methods."
9133 (cond
9134 ;; No method, so we default to current and native.
9135 ((null gnus-refer-article-method)
9136 (list gnus-current-select-method gnus-select-method))
9137 ;; Current.
9138 ((eq 'current gnus-refer-article-method)
9139 (list gnus-current-select-method))
9140 ;; List of select methods.
9141 ((not (and (symbolp (car gnus-refer-article-method))
9142 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9143 (let (out)
9144 (dolist (method gnus-refer-article-method)
9145 (push (if (eq 'current method)
9146 gnus-current-select-method
9147 (if (eq 'nnir (car method))
9148 (list
9149 'nnir
9150 (or (cadr method)
9151 (gnus-method-to-server gnus-current-select-method)))
9152 method))
9153 out))
9154 (nreverse out)))
9155 ;; One single select method.
9157 (list gnus-refer-article-method))))
9159 (defun gnus-summary-edit-parameters ()
9160 "Edit the group parameters of the current group."
9161 (interactive)
9162 (gnus-group-edit-group gnus-newsgroup-name 'params))
9164 (defun gnus-summary-customize-parameters ()
9165 "Customize the group parameters of the current group."
9166 (interactive)
9167 (gnus-group-customize gnus-newsgroup-name))
9169 (defun gnus-summary-enter-digest-group (&optional force)
9170 "Enter an nndoc group based on the current article.
9171 If FORCE, force a digest interpretation. If not, try to guess
9172 what the document format is.
9174 To control what happens when you exit the group, see the
9175 `gnus-auto-select-on-ephemeral-exit' variable."
9176 (interactive "P")
9177 (let ((conf gnus-current-window-configuration))
9178 (save-window-excursion
9179 (save-excursion
9180 (let (gnus-article-prepare-hook
9181 gnus-display-mime-function
9182 gnus-break-pages)
9183 (gnus-summary-select-article))))
9184 (setq gnus-current-window-configuration conf)
9185 (let* ((name (format "%s-%d"
9186 (gnus-group-prefixed-name
9187 gnus-newsgroup-name (list 'nndoc ""))
9188 (with-current-buffer gnus-summary-buffer
9189 gnus-current-article)))
9190 (ogroup gnus-newsgroup-name)
9191 (params (append (gnus-info-params (gnus-get-info ogroup))
9192 (list (cons 'to-group ogroup))
9193 (list (cons 'parent-group ogroup))
9194 (list (cons 'save-article-group ogroup))))
9195 (case-fold-search t)
9196 (buf (current-buffer))
9197 dig to-address charset)
9198 (with-current-buffer gnus-original-article-buffer
9199 ;; Have the digest group inherit the main mail address of
9200 ;; the parent article.
9201 (when (setq to-address (or (gnus-fetch-field "reply-to")
9202 (gnus-fetch-field "from")))
9203 (setq params
9204 (append
9205 (list (cons 'to-address
9206 (funcall gnus-decode-encoded-address-function
9207 to-address))))))
9208 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9209 (insert-buffer-substring gnus-original-article-buffer)
9210 (narrow-to-region
9211 (goto-char (point-min))
9212 (or (search-forward "\n\n" nil t) (point)))
9213 ;; Remove lines that may lead nndoc to misinterpret the
9214 ;; document type.
9215 (goto-char (point-min))
9216 (delete-matching-lines "^Path:\\|^From ")
9217 ;; Parse charset, and decode content transfer encoding.
9218 (setq charset (mail-content-type-get
9219 (mail-header-parse-content-type
9220 (or (gnus-fetch-field "content-type") ""))
9221 'charset))
9222 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9223 (when encoding
9224 (message-remove-header "content-transfer-encoding")
9225 (goto-char (point-max))
9226 (widen)
9227 (narrow-to-region (point) (point-max))
9228 (mm-decode-content-transfer-encoding
9229 (intern (downcase (mail-header-strip encoding))))))
9230 (widen))
9231 (unwind-protect
9232 (if (let ((gnus-newsgroup-ephemeral-charset
9233 (if charset
9234 (intern (downcase (gnus-strip-whitespace charset)))
9235 gnus-newsgroup-charset))
9236 (gnus-newsgroup-ephemeral-ignored-charsets
9237 gnus-newsgroup-ignored-charsets))
9238 (gnus-group-read-ephemeral-group
9239 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9240 (nndoc-article-type
9241 ,(if force 'mbox 'guess)))
9242 t nil nil nil
9243 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9244 "ADAPT")))))
9245 ;; Make all postings to this group go to the parent group.
9246 (nconc (gnus-info-params (gnus-get-info name))
9247 params)
9248 ;; Couldn't select this doc group.
9249 (switch-to-buffer buf)
9250 (gnus-set-global-variables)
9251 (gnus-configure-windows 'summary)
9252 (gnus-message 3 "Article couldn't be entered?"))
9253 (kill-buffer dig)))))
9255 (defun gnus-summary-read-document (n)
9256 "Open a new group based on the current article(s).
9257 This will allow you to read digests and other similar
9258 documents as newsgroups.
9259 Obeys the standard process/prefix convention."
9260 (interactive "P")
9261 (let* ((ogroup gnus-newsgroup-name)
9262 (params (append (gnus-info-params (gnus-get-info ogroup))
9263 (list (cons 'to-group ogroup))))
9264 group egroup groups vgroup)
9265 (dolist (article (gnus-summary-work-articles n))
9266 (setq group (format "%s-%d" gnus-newsgroup-name article))
9267 (gnus-summary-remove-process-mark article)
9268 (when (gnus-summary-display-article article)
9269 (save-excursion ;;What for?
9270 (with-temp-buffer
9271 (insert-buffer-substring gnus-original-article-buffer)
9272 ;; Remove some headers that may lead nndoc to make
9273 ;; the wrong guess.
9274 (message-narrow-to-head)
9275 (goto-char (point-min))
9276 (delete-matching-lines "^Path:\\|^From ")
9277 (widen)
9278 (if (setq egroup
9279 (gnus-group-read-ephemeral-group
9280 group `(nndoc ,group (nndoc-address ,(current-buffer))
9281 (nndoc-article-type guess))
9282 t nil t))
9283 (progn
9284 ;; Make all postings to this group go to the parent group.
9285 (nconc (gnus-info-params (gnus-get-info egroup))
9286 params)
9287 (push egroup groups))
9288 ;; Couldn't select this doc group.
9289 (gnus-error 3 "Article couldn't be entered"))))))
9290 ;; Now we have selected all the documents.
9291 (cond
9292 ((not groups)
9293 (error "None of the articles could be interpreted as documents"))
9294 ((gnus-group-read-ephemeral-group
9295 (setq vgroup (format
9296 "nnvirtual:%s-%s" gnus-newsgroup-name
9297 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9298 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9300 (cons (current-buffer) 'summary)))
9302 (error "Couldn't select virtual nndoc group")))))
9304 (defun gnus-summary-widget-forward (arg)
9305 "Move point to the next field or button in the article.
9306 With optional ARG, move across that many fields."
9307 (interactive "p")
9308 (gnus-summary-select-article)
9309 (gnus-configure-windows 'article)
9310 (select-window (gnus-get-buffer-window gnus-article-buffer))
9311 (widget-forward arg))
9313 (defun gnus-summary-widget-backward (arg)
9314 "Move point to the previous field or button in the article.
9315 With optional ARG, move across that many fields."
9316 (interactive "p")
9317 (gnus-summary-select-article)
9318 (gnus-configure-windows 'article)
9319 (select-window (gnus-get-buffer-window gnus-article-buffer))
9320 (unless (widget-at (point))
9321 (goto-char (point-max)))
9322 (widget-backward arg))
9324 (defun gnus-summary-isearch-article (&optional regexp-p)
9325 "Do incremental search forward on the current article.
9326 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9327 (interactive "P")
9328 (gnus-summary-select-article)
9329 (gnus-configure-windows 'article)
9330 (gnus-eval-in-buffer-window gnus-article-buffer
9331 (save-restriction
9332 (widen)
9333 (isearch-forward regexp-p))))
9335 (defun gnus-summary-repeat-search-article-forward ()
9336 "Repeat the previous search forwards."
9337 (interactive)
9338 (unless gnus-last-search-regexp
9339 (error "No previous search"))
9340 (gnus-summary-search-article-forward gnus-last-search-regexp))
9342 (defun gnus-summary-repeat-search-article-backward ()
9343 "Repeat the previous search backwards."
9344 (interactive)
9345 (unless gnus-last-search-regexp
9346 (error "No previous search"))
9347 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9349 (defun gnus-summary-search-article-forward (regexp &optional backward)
9350 "Search for an article containing REGEXP forward.
9351 If BACKWARD, search backward instead."
9352 (interactive
9353 (list (read-string
9354 (format "Search article %s (regexp%s): "
9355 (if current-prefix-arg "backward" "forward")
9356 (if gnus-last-search-regexp
9357 (concat ", default " gnus-last-search-regexp)
9358 "")))
9359 current-prefix-arg))
9360 (if (string-equal regexp "")
9361 (setq regexp (or gnus-last-search-regexp ""))
9362 (setq gnus-last-search-regexp regexp)
9363 (setq gnus-article-before-search gnus-current-article))
9364 ;; Intentionally set gnus-last-article.
9365 (setq gnus-last-article gnus-article-before-search)
9366 (let ((gnus-last-article gnus-last-article))
9367 (if (gnus-summary-search-article regexp backward)
9368 (gnus-summary-show-thread)
9369 (signal 'search-failed (list regexp)))))
9371 (defun gnus-summary-search-article-backward (regexp)
9372 "Search for an article containing REGEXP backward."
9373 (interactive
9374 (list (read-string
9375 (format "Search article backward (regexp%s): "
9376 (if gnus-last-search-regexp
9377 (concat ", default " gnus-last-search-regexp)
9378 "")))))
9379 (gnus-summary-search-article-forward regexp 'backward))
9381 (defun gnus-summary-search-article (regexp &optional backward)
9382 "Search for an article containing REGEXP.
9383 Optional argument BACKWARD means do search for backward.
9384 `gnus-select-article-hook' is not called during the search."
9385 ;; We have to require this here to make sure that the following
9386 ;; dynamic binding isn't shadowed by autoloading.
9387 (require 'gnus-async)
9388 (require 'gnus-art)
9389 (let ((gnus-select-article-hook nil) ;Disable hook.
9390 (gnus-article-prepare-hook nil)
9391 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9392 (gnus-use-article-prefetch nil)
9393 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9394 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9395 (gnus-visual nil)
9396 (gnus-keep-backlog nil)
9397 (gnus-break-pages nil)
9398 (gnus-summary-display-arrow nil)
9399 (gnus-updated-mode-lines nil)
9400 (gnus-auto-center-summary nil)
9401 (sum (current-buffer))
9402 (gnus-display-mime-function nil)
9403 (found nil)
9404 point)
9405 (gnus-save-hidden-threads
9406 (gnus-summary-select-article)
9407 (set-buffer gnus-article-buffer)
9408 (goto-char (window-point (get-buffer-window (current-buffer))))
9409 (when backward
9410 (forward-line -1))
9411 (while (not found)
9412 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9413 (if (if backward
9414 (re-search-backward regexp nil t)
9415 (re-search-forward regexp nil t))
9416 ;; We found the regexp.
9417 (progn
9418 (setq found 'found)
9419 (beginning-of-line)
9420 (set-window-start
9421 (get-buffer-window (current-buffer))
9422 (point))
9423 (forward-line 1)
9424 (set-window-point
9425 (get-buffer-window (current-buffer))
9426 (point))
9427 (set-buffer sum)
9428 (setq point (point)))
9429 ;; We didn't find it, so we go to the next article.
9430 (set-buffer sum)
9431 (setq found 'not)
9432 (while (eq found 'not)
9433 (if (not (if backward (gnus-summary-find-prev)
9434 (gnus-summary-find-next)))
9435 ;; No more articles.
9436 (setq found t)
9437 ;; Select the next article and adjust point.
9438 (unless (gnus-summary-article-sparse-p
9439 (gnus-summary-article-number))
9440 (setq found nil)
9441 (gnus-summary-select-article)
9442 (set-buffer gnus-article-buffer)
9443 (widen)
9444 (goto-char (if backward (point-max) (point-min))))))))
9445 (gnus-message 7 ""))
9446 ;; Return whether we found the regexp.
9447 (when (eq found 'found)
9448 (goto-char point)
9449 (gnus-summary-show-thread)
9450 (gnus-summary-goto-subject gnus-current-article)
9451 (gnus-summary-position-point)
9452 t)))
9454 (defun gnus-find-matching-articles (header regexp)
9455 "Return a list of all articles that match REGEXP on HEADER.
9456 This search includes all articles in the current group that Gnus has
9457 fetched headers for, whether they are displayed or not."
9458 (let ((articles nil)
9459 ;; Can't eta-reduce because it's a macro.
9460 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9461 (case-fold-search t))
9462 (dolist (header gnus-newsgroup-headers)
9463 (when (string-match regexp (funcall func header))
9464 (push (mail-header-number header) articles)))
9465 (nreverse articles)))
9467 (defun gnus-summary-find-matching (header regexp &optional backward unread
9468 not-case-fold not-matching)
9469 "Return a list of all articles that match REGEXP on HEADER.
9470 The search stars on the current article and goes forwards unless
9471 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9472 If UNREAD is non-nil, only unread articles will
9473 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9474 in the comparisons. If NOT-MATCHING, return a list of all articles that
9475 not match REGEXP on HEADER."
9476 (let ((case-fold-search (not not-case-fold))
9477 articles d func)
9478 (if (consp header)
9479 (if (eq (car header) 'extra)
9480 (setq func
9481 `(lambda (h)
9482 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9483 "")))
9484 (error "%s is an invalid header" header))
9485 (unless (fboundp (intern (concat "mail-header-" header)))
9486 (error "%s is not a valid header" header))
9487 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9488 (dolist (d (if (eq backward 'all)
9489 gnus-newsgroup-data
9490 (gnus-data-find-list
9491 (gnus-summary-article-number)
9492 (gnus-data-list backward))))
9493 (when (and (or (not unread) ; We want all articles...
9494 (gnus-data-unread-p d)) ; Or just unreads.
9495 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9496 (if not-matching
9497 (not (string-match
9498 regexp
9499 (funcall func (gnus-data-header d))))
9500 (string-match regexp
9501 (funcall func (gnus-data-header d)))))
9502 (push (gnus-data-number d) articles))) ; Success!
9503 (nreverse articles)))
9505 (defun gnus-summary-execute-command (header regexp command &optional backward)
9506 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9507 If HEADER is an empty string (or nil), the match is done on the entire
9508 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9509 (interactive
9510 (list (let ((completion-ignore-case t))
9511 (gnus-completing-read
9512 "Header name"
9513 (mapcar 'symbol-name
9514 (append
9515 '(Number Subject From Lines Date
9516 Message-ID Xref References Body)
9517 gnus-extra-headers))
9518 'require-match))
9519 (read-string "Regexp: ")
9520 (read-key-sequence "Command: ")
9521 current-prefix-arg))
9522 (when (equal header "Body")
9523 (setq header ""))
9524 ;; Hidden thread subtrees must be searched as well.
9525 (gnus-summary-show-all-threads)
9526 ;; We don't want to change current point nor window configuration.
9527 (save-excursion
9528 (save-window-excursion
9529 (let (gnus-visual
9530 gnus-treat-strip-trailing-blank-lines
9531 gnus-treat-strip-leading-blank-lines
9532 gnus-treat-strip-multiple-blank-lines
9533 gnus-treat-hide-boring-headers
9534 gnus-treat-fold-newsgroups
9535 gnus-article-prepare-hook)
9536 (gnus-message 6 "Executing %s..." (key-description command))
9537 ;; We'd like to execute COMMAND interactively so as to give arguments.
9538 (gnus-execute header regexp
9539 `(call-interactively ',(key-binding command))
9540 backward)
9541 (gnus-message 6 "Executing %s...done" (key-description command))))))
9543 (defun gnus-summary-beginning-of-article ()
9544 "Scroll the article back to the beginning."
9545 (interactive)
9546 (gnus-summary-select-article)
9547 (gnus-configure-windows 'article)
9548 (gnus-eval-in-buffer-window gnus-article-buffer
9549 (widen)
9550 (goto-char (point-min))
9551 (when gnus-break-pages
9552 (gnus-narrow-to-page))))
9554 (defun gnus-summary-end-of-article ()
9555 "Scroll to the end of the article."
9556 (interactive)
9557 (gnus-summary-select-article)
9558 (gnus-configure-windows 'article)
9559 (gnus-eval-in-buffer-window gnus-article-buffer
9560 (widen)
9561 (goto-char (point-max))
9562 (recenter -3)
9563 (when gnus-break-pages
9564 (gnus-narrow-to-page))))
9566 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9567 "Truncate to LEN and quote all \"(\"'s in STRING."
9568 (gnus-replace-in-string (if (and len (> (length string) len))
9569 (substring string 0 len)
9570 string)
9571 "[()]" "\\\\\\&"))
9573 (defun gnus-summary-print-article (&optional filename n)
9574 "Generate and print a PostScript image of the process-marked (mail) articles.
9576 If used interactively, print the current article if none are
9577 process-marked. With prefix arg, prompt the user for the name of the
9578 file to save in.
9580 When used from Lisp, accept two optional args FILENAME and N. N means
9581 to print the next N articles. If N is negative, print the N previous
9582 articles. If N is nil and articles have been marked with the process
9583 mark, print these instead.
9585 If the optional first argument FILENAME is nil, send the image to the
9586 printer. If FILENAME is a string, save the PostScript image in a file with
9587 that name. If FILENAME is a number, prompt the user for the name of the file
9588 to save in."
9589 (interactive (list (ps-print-preprint current-prefix-arg)))
9590 (dolist (article (gnus-summary-work-articles n))
9591 (gnus-summary-select-article nil nil 'pseudo article)
9592 (gnus-eval-in-buffer-window gnus-article-buffer
9593 (gnus-print-buffer))
9594 (gnus-summary-remove-process-mark article))
9595 (ps-despool filename))
9597 (defun gnus-print-buffer ()
9598 (let ((ps-left-header
9599 (list
9600 (concat "("
9601 (gnus-summary-print-truncate-and-quote
9602 (mail-header-subject gnus-current-headers)
9603 66) ")")
9604 (concat "("
9605 (gnus-summary-print-truncate-and-quote
9606 (mail-header-from gnus-current-headers)
9607 45) ")")))
9608 (ps-right-header
9609 (list
9610 "/pagenumberstring load"
9611 (concat "("
9612 (mail-header-date gnus-current-headers) ")"))))
9613 (gnus-run-hooks 'gnus-ps-print-hook)
9614 (save-excursion
9615 (if ps-print-color-p
9616 (ps-spool-buffer-with-faces)
9617 (ps-spool-buffer)))))
9619 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9621 (defun gnus-summary-show-complete-article ()
9622 "Show a complete version of the current article.
9623 This is only useful if you're looking at a partial version of the
9624 article currently."
9625 (interactive)
9626 (let ((gnus-keep-backlog nil)
9627 (gnus-use-cache nil)
9628 (gnus-agent nil)
9629 (variable (intern
9630 (format "%s-fetch-partial-articles"
9631 (car (gnus-find-method-for-group
9632 gnus-newsgroup-name)))
9633 obarray))
9634 old-val)
9635 (unwind-protect
9636 (progn
9637 (setq old-val (symbol-value variable))
9638 (set variable nil)
9639 (gnus-flush-original-article-buffer)
9640 (gnus-summary-show-article))
9641 (set variable old-val))))
9643 (defun gnus-summary-show-article (&optional arg)
9644 "Force redisplaying of the current article.
9645 If ARG (the prefix) is a number, show the article with the charset
9646 defined in `gnus-summary-show-article-charset-alist', or the charset
9647 input.
9648 If ARG (the prefix) is non-nil and not a number, show the article,
9649 but without running any of the article treatment functions
9650 article. Normally, the keystroke is `C-u g'. When using `C-u
9651 C-u g', show the raw article."
9652 (interactive "P")
9653 (cond
9654 ((numberp arg)
9655 (gnus-summary-show-article t)
9656 (let ((gnus-newsgroup-charset
9657 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9658 (mm-read-coding-system
9659 "View as charset: " ;; actually it is coding system.
9660 (with-current-buffer gnus-article-buffer
9661 (mm-detect-coding-region (point) (point-max))))))
9662 (gnus-newsgroup-ignored-charsets 'gnus-all))
9663 (gnus-summary-select-article nil 'force)
9664 (let ((deps gnus-newsgroup-dependencies)
9665 head header lines)
9666 (with-current-buffer gnus-original-article-buffer
9667 (save-restriction
9668 (message-narrow-to-head)
9669 (setq head (buffer-string))
9670 (goto-char (point-min))
9671 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9672 (goto-char (point-max))
9673 (widen)
9674 (setq lines (1- (count-lines (point) (point-max))))))
9675 (with-temp-buffer
9676 (insert (format "211 %d Article retrieved.\n"
9677 (cdr gnus-article-current)))
9678 (insert head)
9679 (if lines (insert (format "Lines: %d\n" lines)))
9680 (insert ".\n")
9681 (let ((nntp-server-buffer (current-buffer)))
9682 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9683 (gnus-data-set-header
9684 (gnus-data-find (cdr gnus-article-current))
9685 header)
9686 (gnus-summary-update-article-line
9687 (cdr gnus-article-current) header)
9688 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9689 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9690 ((not arg)
9691 ;; Select the article the normal way.
9692 (if (eq mm-text-html-renderer 'shr)
9693 (progn
9694 (require 'shr)
9695 (let ((shr-ignore-cache t))
9696 (gnus-summary-select-article nil 'force)))
9697 (gnus-summary-select-article nil 'force)))
9698 ((equal arg '(16))
9699 ;; C-u C-u g
9700 (let ((gnus-inhibit-article-treatments t))
9701 (gnus-summary-select-article nil 'force)))
9703 ;; We have to require this here to make sure that the following
9704 ;; dynamic binding isn't shadowed by autoloading.
9705 (require 'gnus-async)
9706 (require 'gnus-art)
9707 ;; Bind the article treatment functions to nil.
9708 (let ((gnus-have-all-headers t)
9709 gnus-article-prepare-hook
9710 gnus-article-decode-hook
9711 gnus-display-mime-function
9712 gnus-break-pages)
9713 ;; Destroy any MIME parts.
9714 (when (gnus-buffer-live-p gnus-article-buffer)
9715 (with-current-buffer gnus-article-buffer
9716 (gnus-article-stop-animations)
9717 (gnus-stop-downloads)
9718 (mm-destroy-parts gnus-article-mime-handles)
9719 ;; Set it to nil for safety reason.
9720 (setq gnus-article-mime-handle-alist nil)
9721 (setq gnus-article-mime-handles nil)))
9722 (gnus-summary-select-article nil 'force))))
9723 (gnus-summary-goto-subject gnus-current-article)
9724 (gnus-summary-position-point))
9726 (defun gnus-summary-show-raw-article ()
9727 "Show the raw article without any article massaging functions being run."
9728 (interactive)
9729 (gnus-summary-show-article t))
9731 (defun gnus-summary-verbose-headers (&optional arg)
9732 "Toggle permanent full header display.
9733 If ARG is a positive number, turn header display on.
9734 If ARG is a negative number, turn header display off."
9735 (interactive "P")
9736 (setq gnus-show-all-headers
9737 (cond ((or (not (numberp arg))
9738 (zerop arg))
9739 (not gnus-show-all-headers))
9740 ((natnump arg)
9741 t)))
9742 (gnus-summary-show-article))
9744 (declare-function article-narrow-to-head "gnus-art" ())
9745 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9746 (declare-function gnus-delete-wash-type "gnus-art" (type))
9748 (defun gnus-summary-toggle-header (&optional arg)
9749 "Show the headers if they are hidden, or hide them if they are shown.
9750 If ARG is a positive number, show the entire header.
9751 If ARG is a negative number, hide the unwanted header lines."
9752 (interactive "P")
9753 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9754 (get-buffer-window gnus-article-buffer t))))
9755 (with-current-buffer gnus-article-buffer
9756 (widen)
9757 (article-narrow-to-head)
9758 (let* ((inhibit-read-only t)
9759 (inhibit-point-motion-hooks t)
9760 (hidden (if (numberp arg)
9761 (>= arg 0)
9762 (or (not (looking-at "[^ \t\n]+:"))
9763 (gnus-article-hidden-text-p 'headers))))
9764 s e)
9765 (delete-region (point-min) (point-max))
9766 (with-current-buffer gnus-original-article-buffer
9767 (goto-char (setq s (point-min)))
9768 (setq e (if (search-forward "\n\n" nil t)
9769 (1- (point))
9770 (point-max))))
9771 (insert-buffer-substring gnus-original-article-buffer s e)
9772 (run-hooks 'gnus-article-decode-hook)
9773 (if hidden
9774 (let ((gnus-treat-hide-headers nil)
9775 (gnus-treat-hide-boring-headers nil))
9776 (gnus-delete-wash-type 'headers)
9777 (gnus-treat-article 'head))
9778 (gnus-treat-article 'head))
9779 (widen)
9780 (if window
9781 (set-window-start window (goto-char (point-min))))
9782 (if gnus-break-pages
9783 (gnus-narrow-to-page)
9784 (when (gnus-visual-p 'page-marker)
9785 (let ((inhibit-read-only t))
9786 (gnus-remove-text-with-property 'gnus-prev)
9787 (gnus-remove-text-with-property 'gnus-next))))
9788 (gnus-set-mode-line 'article)))))
9790 (defun gnus-summary-show-all-headers ()
9791 "Make all header lines visible."
9792 (interactive)
9793 (gnus-summary-toggle-header 1))
9795 (defun gnus-summary-caesar-message (&optional arg)
9796 "Caesar rotate the current article by 13.
9797 With a non-numerical prefix, also rotate headers. A numerical
9798 prefix specifies how many places to rotate each letter forward."
9799 (interactive "P")
9800 (gnus-summary-select-article)
9801 (let ((mail-header-separator ""))
9802 (gnus-eval-in-buffer-window gnus-article-buffer
9803 (save-restriction
9804 (widen)
9805 (let ((start (window-start))
9806 (inhibit-read-only t))
9807 (if (equal arg '(4))
9808 (message-caesar-buffer-body nil t)
9809 (message-caesar-buffer-body arg))
9810 (set-window-start (get-buffer-window (current-buffer)) start)))))
9811 ;; Create buttons and stuff...
9812 (gnus-treat-article nil))
9814 (declare-function idna-to-unicode "ext:idna" (str))
9816 (defun gnus-summary-idna-message (&optional arg)
9817 "Decode IDNA encoded domain names in the current articles.
9818 IDNA encoded domain names looks like `xn--bar'. If a string
9819 remain unencoded after running this function, it is likely an
9820 invalid IDNA string (`xn--bar' is invalid).
9822 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9823 installed for this command to work."
9824 (interactive "P")
9825 (if (not (and (condition-case nil (require 'idna)
9826 (file-error))
9827 (mm-coding-system-p 'utf-8)
9828 (executable-find (symbol-value 'idna-program))))
9829 (gnus-message
9830 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9831 (gnus-summary-select-article)
9832 (let ((mail-header-separator ""))
9833 (gnus-eval-in-buffer-window gnus-article-buffer
9834 (save-restriction
9835 (widen)
9836 (let ((start (window-start))
9837 buffer-read-only)
9838 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9839 (replace-match (idna-to-unicode (match-string 1))))
9840 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9842 (defun gnus-summary-morse-message (&optional arg)
9843 "Morse decode the current article."
9844 (interactive "P")
9845 (gnus-summary-select-article)
9846 (let ((mail-header-separator ""))
9847 (gnus-eval-in-buffer-window gnus-article-buffer
9848 (save-excursion
9849 (save-restriction
9850 (widen)
9851 (let ((pos (window-start))
9852 (inhibit-read-only t))
9853 (goto-char (point-min))
9854 (when (message-goto-body)
9855 (gnus-narrow-to-body))
9856 (goto-char (point-min))
9857 (while (search-forward "·" (point-max) t)
9858 (replace-match "."))
9859 (unmorse-region (point-min) (point-max))
9860 (widen)
9861 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9863 (defun gnus-summary-stop-page-breaking ()
9864 "Stop page breaking in the current article."
9865 (interactive)
9866 (gnus-summary-select-article)
9867 (gnus-eval-in-buffer-window gnus-article-buffer
9868 (widen)
9869 (when (gnus-visual-p 'page-marker)
9870 (let ((inhibit-read-only t))
9871 (gnus-remove-text-with-property 'gnus-prev)
9872 (gnus-remove-text-with-property 'gnus-next))
9873 (setq gnus-page-broken nil))))
9875 (defun gnus-summary-move-article (&optional n to-newsgroup
9876 select-method action)
9877 "Move the current article to a different newsgroup.
9878 If N is a positive number, move the N next articles.
9879 If N is a negative number, move the N previous articles.
9880 If N is nil and any articles have been marked with the process mark,
9881 move those articles instead.
9882 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9883 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9884 re-spool using this method.
9886 When called interactively with TO-NEWSGROUP being nil, the value of
9887 the variable `gnus-move-split-methods' is used for finding a default
9888 for the target newsgroup.
9890 For this function to work, both the current newsgroup and the
9891 newsgroup that you want to move to have to support the `request-move'
9892 and `request-accept' functions.
9894 ACTION can be either `move' (the default), `crosspost' or `copy'."
9895 (interactive "P")
9896 (unless action
9897 (setq action 'move))
9898 ;; Check whether the source group supports the required functions.
9899 (cond ((and (eq action 'move)
9900 (not (gnus-check-backend-function
9901 'request-move-article gnus-newsgroup-name)))
9902 (error "The current group does not support article moving"))
9903 ((and (eq action 'crosspost)
9904 (not (gnus-check-backend-function
9905 'request-replace-article gnus-newsgroup-name)))
9906 (error "The current group does not support article editing")))
9907 (let ((articles (gnus-summary-work-articles n))
9908 (prefix (if (gnus-check-backend-function
9909 'request-move-article gnus-newsgroup-name)
9910 (funcall gnus-move-group-prefix-function
9911 gnus-newsgroup-name)
9912 ""))
9913 (names '((move "Move" "Moving")
9914 (copy "Copy" "Copying")
9915 (crosspost "Crosspost" "Crossposting")))
9916 (copy-buf (save-excursion
9917 (nnheader-set-temp-buffer " *copy article*")))
9918 art-group to-method new-xref article to-groups
9919 articles-to-update-marks encoded)
9920 (unless (assq action names)
9921 (error "Unknown action %s" action))
9922 ;; Read the newsgroup name.
9923 (when (and (not to-newsgroup)
9924 (not select-method))
9925 (if (and gnus-move-split-methods
9926 (not
9927 (and (memq gnus-current-article articles)
9928 (gnus-buffer-live-p gnus-original-article-buffer))))
9929 ;; When `gnus-move-split-methods' is non-nil, we have to
9930 ;; select an article to give `gnus-read-move-group-name' an
9931 ;; opportunity to suggest an appropriate default. However,
9932 ;; we needn't render or mark the article.
9933 (let ((gnus-display-mime-function nil)
9934 (gnus-article-prepare-hook nil)
9935 (gnus-mark-article-hook nil))
9936 (gnus-summary-select-article nil nil nil (car articles))))
9937 (setq to-newsgroup (gnus-read-move-group-name
9938 (cadr (assq action names))
9939 (symbol-value
9940 (intern (format "gnus-current-%s-group" action)))
9941 articles prefix)
9942 encoded to-newsgroup
9943 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9944 (set (intern (format "gnus-current-%s-group" action))
9945 (mm-decode-coding-string
9946 to-newsgroup
9947 (gnus-group-name-charset to-method to-newsgroup))))
9948 (unless to-method
9949 (setq to-method (or select-method
9950 (gnus-server-to-method
9951 (gnus-group-method to-newsgroup)))))
9952 (setq to-newsgroup
9953 (or encoded
9954 (and to-newsgroup
9955 (mm-encode-coding-string
9956 to-newsgroup
9957 (gnus-group-name-charset to-method to-newsgroup)))))
9958 ;; Check the method we are to move this article to...
9959 (unless (gnus-check-backend-function
9960 'request-accept-article (car to-method))
9961 (error "%s does not support article copying" (car to-method)))
9962 (unless (gnus-check-server to-method)
9963 (error "Can't open server %s" (car to-method)))
9964 (gnus-message 6 "%s to %s: %s..."
9965 (caddr (assq action names))
9966 (or (car select-method)
9967 (gnus-group-decoded-name to-newsgroup))
9968 articles)
9969 (while articles
9970 (setq article (pop articles))
9971 ;; Set any marks that may have changed in the summary buffer.
9972 (when gnus-preserve-marks
9973 (gnus-summary-push-marks-to-backend article))
9974 (setq
9975 art-group
9976 (cond
9977 ;; Move the article.
9978 ((eq action 'move)
9979 ;; Remove this article from future suppression.
9980 (gnus-dup-unsuppress-article article)
9981 (let* ((from-method (gnus-find-method-for-group
9982 gnus-newsgroup-name))
9983 (to-method (or select-method
9984 (gnus-find-method-for-group to-newsgroup)))
9985 (move-is-internal (gnus-server-equal from-method to-method)))
9986 (gnus-request-move-article
9987 article ; Article to move
9988 gnus-newsgroup-name ; From newsgroup
9989 (nth 1 (gnus-find-method-for-group
9990 gnus-newsgroup-name)) ; Server
9991 (list 'gnus-request-accept-article
9992 to-newsgroup (list 'quote select-method)
9993 (not articles) t) ; Accept form
9994 (not articles) ; Only save nov last time
9995 (and move-is-internal
9996 to-newsgroup ; Not respooling
9997 ; Is this move internal?
9998 (gnus-group-real-name to-newsgroup)))))
9999 ;; Copy the article.
10000 ((eq action 'copy)
10001 (with-current-buffer copy-buf
10002 (when (gnus-request-article-this-buffer article
10003 gnus-newsgroup-name)
10004 (save-restriction
10005 (nnheader-narrow-to-headers)
10006 (dolist (hdr gnus-copy-article-ignored-headers)
10007 (message-remove-header hdr t)))
10008 (gnus-request-accept-article
10009 to-newsgroup select-method (not articles) t))))
10010 ;; Crosspost the article.
10011 ((eq action 'crosspost)
10012 (let ((xref (message-tokenize-header
10013 (mail-header-xref (gnus-summary-article-header
10014 article))
10015 " ")))
10016 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10017 ":" (number-to-string article)))
10018 (unless xref
10019 (setq xref (list (system-name))))
10020 (setq new-xref
10021 (concat
10022 (mapconcat 'identity
10023 (delete "Xref:" (delete new-xref xref))
10024 " ")
10025 " " new-xref))
10026 (with-current-buffer copy-buf
10027 ;; First put the article in the destination group.
10028 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10029 (when (consp (setq art-group
10030 (gnus-request-accept-article
10031 to-newsgroup select-method (not articles)
10032 t)))
10033 (setq new-xref (concat new-xref " " (car art-group)
10035 (number-to-string (cdr art-group))))
10036 ;; Now we have the new Xrefs header, so we insert
10037 ;; it and replace the new article.
10038 (nnheader-replace-header "Xref" new-xref)
10039 (gnus-request-replace-article
10040 (cdr art-group) to-newsgroup (current-buffer) t)
10041 art-group))))))
10042 (cond
10043 ((not art-group)
10044 (gnus-message 1 "Couldn't %s article %s: %s"
10045 (cadr (assq action names)) article
10046 (nnheader-get-report (car to-method))))
10047 ((eq art-group 'junk)
10048 (when (eq action 'move)
10049 (gnus-summary-mark-article article gnus-canceled-mark)
10050 (gnus-message 4 "Deleted article %s" article)
10051 ;; run the delete hook
10052 (run-hook-with-args 'gnus-summary-article-delete-hook
10053 action
10054 (gnus-data-header
10055 (assoc article (gnus-data-list nil)))
10056 gnus-newsgroup-name nil
10057 select-method)))
10059 (let* ((pto-group (gnus-group-prefixed-name
10060 (car art-group) to-method))
10061 (info (gnus-get-info pto-group))
10062 (to-group (gnus-info-group info))
10063 to-marks)
10064 ;; Update the group that has been moved to.
10065 (when (and info
10066 (memq action '(move copy)))
10067 (unless (member to-group to-groups)
10068 (push to-group to-groups))
10070 (when (and (not (memq article gnus-newsgroup-unreads))
10071 (cdr art-group))
10072 (push 'read to-marks)
10073 (gnus-info-set-read
10074 info (gnus-add-to-range (gnus-info-read info)
10075 (list (cdr art-group)))))
10077 ;; See whether the article is to be put in the cache.
10078 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10079 (marks (if expirable
10080 gnus-article-mark-lists
10081 (delete '(expirable . expire)
10082 (copy-sequence
10083 gnus-article-mark-lists))))
10084 (to-article (cdr art-group)))
10086 ;; Enter the article into the cache in the new group,
10087 ;; if that is required.
10088 (when (and to-article
10089 gnus-use-cache)
10090 (gnus-cache-possibly-enter-article
10091 to-group to-article
10092 (memq article gnus-newsgroup-marked)
10093 (memq article gnus-newsgroup-dormant)
10094 (memq article gnus-newsgroup-unreads)))
10096 (when (and gnus-preserve-marks
10097 to-article)
10098 ;; Copy any marks over to the new group.
10099 (when (and (equal to-group gnus-newsgroup-name)
10100 (not (memq article gnus-newsgroup-unreads)))
10101 ;; Mark this article as read in this group.
10102 (push (cons to-article gnus-read-mark)
10103 gnus-newsgroup-reads)
10104 ;; Increase the active status of this group.
10105 (setcdr (gnus-active to-group) to-article)
10106 (setcdr gnus-newsgroup-active to-article))
10108 (while marks
10109 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10110 (when (memq article (symbol-value
10111 (intern (format "gnus-newsgroup-%s"
10112 (caar marks)))))
10113 (push (cdar marks) to-marks)
10114 ;; If the other group is the same as this group,
10115 ;; then we have to add the mark to the list.
10116 (when (equal to-group gnus-newsgroup-name)
10117 (set (intern (format "gnus-newsgroup-%s"
10118 (caar marks)))
10119 (cons to-article
10120 (symbol-value
10121 (intern (format "gnus-newsgroup-%s"
10122 (caar marks)))))))
10123 ;; Copy the marks to other group.
10124 (gnus-add-marked-articles
10125 to-group (cdar marks) (list to-article) info)))
10126 (setq marks (cdr marks)))
10128 (when (and expirable
10129 gnus-mark-copied-or-moved-articles-as-expirable
10130 (not (memq 'expire to-marks)))
10131 ;; Mark this article as expirable.
10132 (push 'expire to-marks)
10133 (when (equal to-group gnus-newsgroup-name)
10134 (push to-article gnus-newsgroup-expirable))
10135 ;; Copy the expirable mark to other group.
10136 (gnus-add-marked-articles
10137 to-group 'expire (list to-article) info))
10139 (when (and to-marks
10140 (gnus-method-option-p
10141 (gnus-find-method-for-group to-group)
10142 'server-marks))
10143 (gnus-request-set-mark
10144 to-group (list (list (list to-article) 'add to-marks)))))
10146 (gnus-dribble-enter
10147 (concat "(gnus-group-set-info '"
10148 (gnus-prin1-to-string (gnus-get-info to-group))
10149 ")")
10150 (concat "^(gnus-group-set-info '(\""
10151 (regexp-quote to-group) "\""))))
10153 ;; Update the Xref header in this article to point to
10154 ;; the new crossposted article we have just created.
10155 (when (eq action 'crosspost)
10156 (with-current-buffer copy-buf
10157 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10158 (nnheader-replace-header "Xref" new-xref)
10159 (gnus-request-replace-article
10160 article gnus-newsgroup-name (current-buffer) t)))
10162 ;; run the move/copy/crosspost/respool hook
10163 (run-hook-with-args 'gnus-summary-article-move-hook
10164 action
10165 (gnus-data-header
10166 (assoc article (gnus-data-list nil)))
10167 gnus-newsgroup-name
10168 to-newsgroup
10169 select-method))
10171 ;;;!!!Why is this necessary?
10172 (set-buffer gnus-summary-buffer)
10174 (when (eq action 'move)
10175 (save-excursion
10176 (gnus-summary-goto-subject article)
10177 (gnus-summary-mark-article article gnus-canceled-mark)))))
10178 (push article articles-to-update-marks))
10180 (save-excursion
10181 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10182 ;; Re-activate all groups that have been moved to.
10183 (with-current-buffer gnus-group-buffer
10184 (let ((gnus-group-marked to-groups))
10185 (gnus-group-get-new-news-this-group nil t)))
10187 (gnus-kill-buffer copy-buf)
10188 (gnus-summary-position-point)
10189 (gnus-set-mode-line 'summary)))
10191 (defun gnus-summary-push-marks-to-backend (article)
10192 (let ((set nil)
10193 (del nil)
10194 (marks gnus-article-mark-lists))
10195 (unless (memq article gnus-newsgroup-unreads)
10196 (push 'read set))
10197 (while marks
10198 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10199 (memq article (symbol-value
10200 (intern (format "gnus-newsgroup-%s"
10201 (caar marks))))))
10202 (push (cdar marks) set)
10203 (push (cdar marks) del))
10204 (pop marks))
10205 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10206 ((,article) del ,del)))))
10208 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10209 "Copy the current article to some other group.
10210 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10211 When called interactively, if TO-NEWSGROUP is nil, use the value of
10212 the variable `gnus-move-split-methods' for finding a default target
10213 newsgroup.
10214 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10215 re-spool using this method."
10216 (interactive "P")
10217 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10219 (defun gnus-summary-crosspost-article (&optional n)
10220 "Crosspost the current article to some other group."
10221 (interactive "P")
10222 (gnus-summary-move-article n nil nil 'crosspost))
10224 (defcustom gnus-summary-respool-default-method nil
10225 "Default method type for respooling an article.
10226 If nil, use to the current newsgroup method."
10227 :type 'symbol
10228 :group 'gnus-summary-mail)
10230 (defun gnus-summary-respool-article (&optional n method)
10231 "Respool the current article.
10232 The article will be squeezed through the mail spooling process again,
10233 which means that it will be put in some mail newsgroup or other
10234 depending on `nnmail-split-methods'.
10235 If N is a positive number, respool the N next articles.
10236 If N is a negative number, respool the N previous articles.
10237 If N is nil and any articles have been marked with the process mark,
10238 respool those articles instead.
10240 Respooling can be done both from mail groups and \"real\" newsgroups.
10241 In the former case, the articles in question will be moved from the
10242 current group into whatever groups they are destined to. In the
10243 latter case, they will be copied into the relevant groups."
10244 (interactive
10245 (list current-prefix-arg
10246 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10247 (methname
10248 (symbol-name (or gnus-summary-respool-default-method
10249 (car (gnus-find-method-for-group
10250 gnus-newsgroup-name)))))
10251 (method
10252 (gnus-completing-read
10253 "Backend to use when respooling"
10254 methods t nil 'gnus-mail-method-history methname))
10256 (cond
10257 ((zerop (length (setq ms (gnus-servers-using-backend
10258 (intern method)))))
10259 (list (intern method) ""))
10260 ((= 1 (length ms))
10261 (car ms))
10263 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10264 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10265 ms-alist))))))))
10266 (unless method
10267 (error "No method given for respooling"))
10268 (if (assoc (symbol-name
10269 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10270 (gnus-methods-using 'respool))
10271 (gnus-summary-move-article n nil method)
10272 (gnus-summary-copy-article n nil method)))
10274 (defun gnus-summary-import-article (file &optional edit)
10275 "Import an arbitrary file into a mail newsgroup."
10276 (interactive "fImport file: \nP")
10277 (let ((group gnus-newsgroup-name)
10278 (now (current-time))
10279 atts lines group-art)
10280 (unless (gnus-check-backend-function 'request-accept-article group)
10281 (error "%s does not support article importing" group))
10282 (or (file-readable-p file)
10283 (not (file-regular-p file))
10284 (error "Can't read %s" file))
10285 (with-current-buffer (gnus-get-buffer-create " *import file*")
10286 (erase-buffer)
10287 (nnheader-insert-file-contents file)
10288 (goto-char (point-min))
10289 (if (nnheader-article-p)
10290 (save-restriction
10291 (goto-char (point-min))
10292 (search-forward "\n\n" nil t)
10293 (narrow-to-region (point-min) (1- (point)))
10294 (goto-char (point-min))
10295 (unless (re-search-forward "^date:" nil t)
10296 (goto-char (point-max))
10297 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10298 ;; This doesn't look like an article, so we fudge some headers.
10299 (setq atts (file-attributes file)
10300 lines (count-lines (point-min) (point-max)))
10301 (insert "From: " (read-string "From: ") "\n"
10302 "Subject: " (read-string "Subject: ") "\n"
10303 "Date: " (message-make-date (nth 5 atts)) "\n"
10304 "Message-ID: " (message-make-message-id) "\n"
10305 "Lines: " (int-to-string lines) "\n"
10306 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10307 (setq group-art (gnus-request-accept-article group nil t))
10308 (kill-buffer (current-buffer)))
10309 (setq gnus-newsgroup-active (gnus-activate-group group))
10310 (forward-line 1)
10311 (gnus-summary-goto-article (cdr group-art) nil t)
10312 (when edit
10313 (gnus-summary-edit-article))))
10315 (defun gnus-summary-create-article ()
10316 "Create an article in a mail newsgroup."
10317 (interactive)
10318 (let ((group gnus-newsgroup-name)
10319 (now (current-time))
10320 group-art)
10321 (unless (gnus-check-backend-function 'request-accept-article group)
10322 (error "%s does not support article importing" group))
10323 (with-current-buffer (gnus-get-buffer-create " *import file*")
10324 (erase-buffer)
10325 (goto-char (point-min))
10326 ;; This doesn't look like an article, so we fudge some headers.
10327 (insert "From: " (read-string "From: ") "\n"
10328 "Subject: " (read-string "Subject: ") "\n"
10329 "Date: " (message-make-date now) "\n"
10330 "Message-ID: " (message-make-message-id) "\n")
10331 (setq group-art (gnus-request-accept-article group nil t))
10332 (kill-buffer (current-buffer)))
10333 (setq gnus-newsgroup-active (gnus-activate-group group))
10334 (forward-line 1)
10335 (gnus-summary-goto-article (cdr group-art) nil t)
10336 (gnus-summary-edit-article)))
10338 (defun gnus-summary-article-posted-p ()
10339 "Say whether the current (mail) article is available from news as well.
10340 This will be the case if the article has both been mailed and posted."
10341 (interactive)
10342 (let ((id (mail-header-references (gnus-summary-article-header)))
10343 (gnus-override-method (car (gnus-refer-article-methods))))
10344 (if (gnus-request-head id "")
10345 (gnus-message 2 "The current message was found on %s"
10346 gnus-override-method)
10347 (gnus-message 2 "The current message couldn't be found on %s"
10348 gnus-override-method)
10349 nil)))
10351 (defun gnus-summary-expire-articles (&optional now)
10352 "Expire all articles that are marked as expirable in the current group."
10353 (interactive)
10354 (when (and (not gnus-group-is-exiting-without-update-p)
10355 (gnus-check-backend-function
10356 'request-expire-articles gnus-newsgroup-name))
10357 ;; This backend supports expiry.
10358 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10359 (expirable
10360 (gnus-list-range-difference
10361 (if total
10362 (progn
10363 ;; We need to update the info for
10364 ;; this group for `gnus-list-of-read-articles'
10365 ;; to give us the right answer.
10366 (gnus-run-hooks 'gnus-exit-group-hook)
10367 (gnus-summary-update-info)
10368 (gnus-list-of-read-articles gnus-newsgroup-name))
10369 (setq gnus-newsgroup-expirable
10370 (sort gnus-newsgroup-expirable '<)))
10371 gnus-newsgroup-unexist))
10372 (expiry-wait (if now 'immediate
10373 (gnus-group-find-parameter
10374 gnus-newsgroup-name 'expiry-wait)))
10375 (nnmail-expiry-target
10376 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10377 nnmail-expiry-target))
10379 (when expirable
10380 ;; There are expirable articles in this group, so we run them
10381 ;; through the expiry process.
10382 (gnus-message 6 "Expiring articles...")
10383 (when (gnus-check-group gnus-newsgroup-name)
10384 ;; The list of articles that weren't expired is returned.
10385 (save-excursion
10386 (if expiry-wait
10387 (let ((nnmail-expiry-wait-function nil)
10388 (nnmail-expiry-wait expiry-wait))
10389 (setq es (gnus-request-expire-articles
10390 expirable gnus-newsgroup-name)))
10391 (setq es (gnus-request-expire-articles
10392 expirable gnus-newsgroup-name)))
10393 (unless total
10394 (setq gnus-newsgroup-expirable es))
10395 ;; We go through the old list of expirable, and mark all
10396 ;; really expired articles as nonexistent.
10397 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10398 (let ((gnus-use-cache nil))
10399 (dolist (article expirable)
10400 (when (and (not (memq article es))
10401 (gnus-data-find article))
10402 (gnus-summary-mark-article article gnus-canceled-mark)
10403 (run-hook-with-args 'gnus-summary-article-expire-hook
10404 'delete
10405 (gnus-data-header
10406 (assoc article (gnus-data-list nil)))
10407 gnus-newsgroup-name
10409 nil)))))))
10410 (gnus-message 6 "Expiring articles...done")))))
10412 (defun gnus-summary-expire-articles-now ()
10413 "Expunge all expirable articles in the current group.
10414 This means that *all* articles that are marked as expirable will be
10415 deleted forever, right now."
10416 (interactive)
10417 (or gnus-expert-user
10418 (gnus-yes-or-no-p
10419 "Are you really, really sure you want to delete all expirable messages? ")
10420 (error "Phew!"))
10421 (gnus-summary-expire-articles t))
10423 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10424 (defun gnus-summary-delete-article (&optional n)
10425 "Delete the N next (mail) articles.
10426 This command actually deletes articles. This is not a marking
10427 command. The article will disappear forever from your life, never to
10428 return.
10430 If N is negative, delete backwards.
10431 If N is nil and articles have been marked with the process mark,
10432 delete these instead.
10434 If `gnus-novice-user' is non-nil you will be asked for
10435 confirmation before the articles are deleted."
10436 (interactive "P")
10437 (unless (gnus-check-backend-function 'request-expire-articles
10438 gnus-newsgroup-name)
10439 (error "The current newsgroup does not support article deletion"))
10440 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10441 (error "Couldn't open server"))
10442 ;; Compute the list of articles to delete.
10443 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10444 (nnmail-expiry-target 'delete)
10445 not-deleted)
10446 (if (and gnus-novice-user
10447 (not (gnus-yes-or-no-p
10448 (format "Do you really want to delete %s forever? "
10449 (if (> (length articles) 1)
10450 (format "these %s articles" (length articles))
10451 "this article")))))
10453 ;; Delete the articles.
10454 (setq not-deleted (gnus-request-expire-articles
10455 articles gnus-newsgroup-name 'force))
10456 (save-excursion
10457 (while articles
10458 (gnus-summary-remove-process-mark (car articles))
10459 ;; The backend might not have been able to delete the article
10460 ;; after all.
10461 (unless (memq (car articles) not-deleted)
10462 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10463 (let* ((article (car articles))
10464 (ghead (gnus-data-header
10465 (assoc article (gnus-data-list nil)))))
10466 (run-hook-with-args 'gnus-summary-article-delete-hook
10467 'delete ghead gnus-newsgroup-name nil
10468 nil)))
10469 (setq articles (cdr articles))))
10470 (when not-deleted
10471 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10472 (gnus-summary-position-point)
10473 (gnus-set-mode-line 'summary)
10474 not-deleted))
10476 (defun gnus-summary-edit-article (&optional arg)
10477 "Edit the current article.
10478 This will have permanent effect only in mail groups.
10479 If ARG is nil, edit the decoded articles.
10480 If ARG is 1, edit the raw articles.
10481 If ARG is 2, edit the raw articles even in read-only groups.
10482 If ARG is 3, edit the articles with the current handles.
10483 Otherwise, allow editing of articles even in read-only
10484 groups."
10485 (interactive "P")
10486 (let (force raw current-handles)
10487 (cond
10488 ((null arg))
10489 ((eq arg 1)
10490 (setq raw t))
10491 ((eq arg 2)
10492 (setq raw t
10493 force t))
10494 ((eq arg 3)
10495 (setq current-handles
10496 (and (gnus-buffer-live-p gnus-article-buffer)
10497 (with-current-buffer gnus-article-buffer
10498 (prog1
10499 gnus-article-mime-handles
10500 (setq gnus-article-mime-handles nil))))))
10502 (setq force t)))
10503 (when (and raw (not force)
10504 (member gnus-newsgroup-name '("nndraft:delayed"
10505 "nndraft:drafts"
10506 "nndraft:queue")))
10507 (error "Can't edit the raw article in group %s"
10508 gnus-newsgroup-name))
10509 (with-current-buffer gnus-summary-buffer
10510 (let ((mail-parse-charset gnus-newsgroup-charset)
10511 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10512 (gnus-set-global-variables)
10513 (when (and (not force)
10514 (gnus-group-read-only-p))
10515 (error "The current newsgroup does not support article editing"))
10516 (gnus-summary-show-article t)
10517 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10518 (with-current-buffer gnus-article-buffer
10519 (mm-enable-multibyte)))
10520 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10521 (setq raw t))
10522 (gnus-article-edit-article
10523 (if raw 'ignore
10524 `(lambda ()
10525 (let ((mbl mml-buffer-list))
10526 (setq mml-buffer-list nil)
10527 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10528 (mime-to-mml ,'current-handles))
10529 (let ((mbl1 mml-buffer-list))
10530 (setq mml-buffer-list mbl)
10531 (set (make-local-variable 'mml-buffer-list) mbl1))
10532 (gnus-make-local-hook 'kill-buffer-hook)
10533 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10534 `(lambda (no-highlight)
10535 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10536 (message-options message-options)
10537 (message-options-set-recipient)
10538 (mail-parse-ignored-charsets
10539 ',gnus-newsgroup-ignored-charsets)
10540 (rfc2047-header-encoding-alist
10541 ',(let ((charset (gnus-group-name-charset
10542 (gnus-find-method-for-group
10543 gnus-newsgroup-name)
10544 gnus-newsgroup-name)))
10545 (append (list (cons "Newsgroups" charset)
10546 (cons "Followup-To" charset)
10547 (cons "Xref" charset))
10548 rfc2047-header-encoding-alist))))
10549 ,(if (not raw) '(progn
10550 (mml-to-mime)
10551 (mml-destroy-buffers)
10552 (remove-hook 'kill-buffer-hook
10553 'mml-destroy-buffers t)
10554 (kill-local-variable 'mml-buffer-list)))
10555 (gnus-summary-edit-article-done
10556 ,(or (mail-header-references gnus-current-headers) "")
10557 ,(gnus-group-read-only-p)
10558 ,gnus-summary-buffer no-highlight))))))))
10560 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10562 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10563 no-highlight)
10564 "Make edits to the current article permanent."
10565 (interactive)
10566 (save-excursion
10567 ;; The buffer restriction contains the entire article if it exists.
10568 (when (article-goto-body)
10569 (let ((lines (count-lines (point) (point-max)))
10570 (length (- (point-max) (point)))
10571 (case-fold-search t)
10572 (body (copy-marker (point))))
10573 (goto-char (point-min))
10574 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10575 (delete-region (match-beginning 1) (match-end 1))
10576 (insert (number-to-string length)))
10577 (goto-char (point-min))
10578 (when (re-search-forward
10579 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10580 (delete-region (match-beginning 1) (match-end 1))
10581 (insert (number-to-string length)))
10582 (goto-char (point-min))
10583 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10584 (delete-region (match-beginning 1) (match-end 1))
10585 (insert (number-to-string lines))))))
10586 ;; Replace the article.
10587 (let ((buf (current-buffer))
10588 (article (cdr gnus-article-current))
10589 replace-result)
10590 (with-temp-buffer
10591 (insert-buffer-substring buf)
10592 (if (and (not read-only)
10593 (not (setq replace-result
10594 (gnus-request-replace-article
10595 article (car gnus-article-current)
10596 (current-buffer) t))))
10597 (error "Couldn't replace article")
10598 ;; If we got a number back, then that's the new article number
10599 ;; for this article. Otherwise, the article number didn't change.
10600 (when (numberp replace-result)
10601 (with-current-buffer gnus-summary-buffer
10602 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10603 (gnus-summary-limit gnus-newsgroup-limit)
10604 (setq article replace-result)
10605 (gnus-summary-goto-subject article t)))
10606 ;; Update the summary buffer.
10607 (if (and references
10608 (equal (message-tokenize-header references " ")
10609 (message-tokenize-header
10610 (or (message-fetch-field "references") "") " ")))
10611 ;; We only have to update this line.
10612 (save-excursion
10613 (save-restriction
10614 (message-narrow-to-head)
10615 (let ((head (buffer-substring-no-properties
10616 (point-min) (point-max)))
10617 header)
10618 (with-temp-buffer
10619 (insert (format "211 %d Article retrieved.\n" article))
10620 (insert head)
10621 (insert ".\n")
10622 (let ((nntp-server-buffer (current-buffer)))
10623 (setq header (car (gnus-get-newsgroup-headers nil t))))
10624 (with-current-buffer gnus-summary-buffer
10625 (gnus-data-set-header (gnus-data-find article) header)
10626 (gnus-summary-update-article-line article header)
10627 (if (gnus-summary-goto-subject article nil t)
10628 (gnus-summary-update-secondary-mark article)))))))
10629 ;; Update threads.
10630 (set-buffer (or buffer gnus-summary-buffer))
10631 (gnus-summary-update-article article)
10632 (if (gnus-summary-goto-subject article nil t)
10633 (gnus-summary-update-secondary-mark article)))
10634 ;; Prettify the article buffer again.
10635 (unless no-highlight
10636 (with-current-buffer gnus-article-buffer
10637 ;;!!! Fix this -- article should be rehighlighted.
10638 ;;(gnus-run-hooks 'gnus-article-display-hook)
10639 (set-buffer gnus-original-article-buffer)
10640 (gnus-request-article
10641 article (car gnus-article-current) (current-buffer))))
10642 ;; Prettify the summary buffer line.
10643 (when (gnus-visual-p 'summary-highlight 'highlight)
10644 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10646 (defun gnus-summary-edit-wash (key)
10647 "Perform editing command KEY in the article buffer."
10648 (interactive
10649 (list
10650 (progn
10651 (message "%s" (concat (this-command-keys) "- "))
10652 (read-char))))
10653 (message "")
10654 (gnus-summary-edit-article)
10655 (execute-kbd-macro (concat (this-command-keys) key))
10656 (gnus-article-edit-done))
10658 ;;; Respooling
10660 (defun gnus-summary-respool-query (&optional silent trace)
10661 "Query where the respool algorithm would put this article."
10662 (interactive)
10663 (let (gnus-mark-article-hook)
10664 (gnus-summary-select-article)
10665 (with-current-buffer gnus-original-article-buffer
10666 (let ((groups (nnmail-article-group 'identity trace)))
10667 (unless silent
10668 (if groups
10669 (message "This message would go to %s"
10670 (mapconcat 'car groups ", "))
10671 (message "This message would go to no groups"))
10672 groups)))))
10674 (defun gnus-summary-respool-trace ()
10675 "Trace where the respool algorithm would put this article.
10676 Display a buffer showing all fancy splitting patterns which matched."
10677 (interactive)
10678 (gnus-summary-respool-query nil t))
10680 ;; Summary marking commands.
10682 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10683 "Mark articles which has the same subject as read, and then select the next.
10684 If UNMARK is positive, remove any kind of mark.
10685 If UNMARK is negative, tick articles."
10686 (interactive "P")
10687 (when unmark
10688 (setq unmark (prefix-numeric-value unmark)))
10689 (let ((count
10690 (gnus-summary-mark-same-subject
10691 (gnus-summary-article-subject) unmark)))
10692 ;; Select next unread article. If auto-select-same mode, should
10693 ;; select the first unread article.
10694 (gnus-summary-next-article t (and gnus-auto-select-same
10695 (gnus-summary-article-subject)))
10696 (gnus-message 7 "%d article%s marked as %s"
10697 count (if (= count 1) " is" "s are")
10698 (if unmark "unread" "read"))))
10700 (defun gnus-summary-kill-same-subject (&optional unmark)
10701 "Mark articles which has the same subject as read.
10702 If UNMARK is positive, remove any kind of mark.
10703 If UNMARK is negative, tick articles."
10704 (interactive "P")
10705 (when unmark
10706 (setq unmark (prefix-numeric-value unmark)))
10707 (let ((count
10708 (gnus-summary-mark-same-subject
10709 (gnus-summary-article-subject) unmark)))
10710 ;; If marked as read, go to next unread subject.
10711 (when (null unmark)
10712 ;; Go to next unread subject.
10713 (gnus-summary-next-subject 1 t))
10714 (gnus-message 7 "%d articles are marked as %s"
10715 count (if unmark "unread" "read"))))
10717 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10718 "Mark articles with same SUBJECT as read, and return marked number.
10719 If optional argument UNMARK is positive, remove any kinds of marks.
10720 If optional argument UNMARK is negative, mark articles as unread instead."
10721 (let ((count 1))
10722 (save-excursion
10723 (cond
10724 ((null unmark) ; Mark as read.
10725 (while (and
10726 (progn
10727 (gnus-summary-mark-article-as-read gnus-killed-mark)
10728 (gnus-summary-show-thread) t)
10729 (gnus-summary-find-subject subject))
10730 (setq count (1+ count))))
10731 ((> unmark 0) ; Tick.
10732 (while (and
10733 (progn
10734 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10735 (gnus-summary-show-thread) t)
10736 (gnus-summary-find-subject subject))
10737 (setq count (1+ count))))
10738 (t ; Mark as unread.
10739 (while (and
10740 (progn
10741 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10742 (gnus-summary-show-thread) t)
10743 (gnus-summary-find-subject subject))
10744 (setq count (1+ count)))))
10745 (gnus-set-mode-line 'summary)
10746 ;; Return the number of marked articles.
10747 count)))
10749 (defun gnus-summary-mark-as-processable (n &optional unmark)
10750 "Set the process mark on the next N articles.
10751 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10752 the process mark instead. The difference between N and the actual
10753 number of articles marked is returned."
10754 (interactive "P")
10755 (if (and (null n) (gnus-region-active-p))
10756 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10757 (setq n (prefix-numeric-value n))
10758 (let ((backward (< n 0))
10759 (n (abs n)))
10760 (while (and
10761 (> n 0)
10762 (if unmark
10763 (gnus-summary-remove-process-mark
10764 (gnus-summary-article-number))
10765 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10766 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10767 (setq n (1- n)))
10768 (when (/= 0 n)
10769 (gnus-message 7 "No more articles"))
10770 (gnus-summary-recenter)
10771 (gnus-summary-position-point)
10772 n)))
10774 (defun gnus-summary-unmark-as-processable (n)
10775 "Remove the process mark from the next N articles.
10776 If N is negative, unmark backward instead. The difference between N and
10777 the actual number of articles unmarked is returned."
10778 (interactive "P")
10779 (gnus-summary-mark-as-processable n t))
10781 (defun gnus-summary-unmark-all-processable ()
10782 "Remove the process mark from all articles."
10783 (interactive)
10784 (save-excursion
10785 (while gnus-newsgroup-processable
10786 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10787 (gnus-summary-position-point))
10789 (defun gnus-summary-add-mark (article type)
10790 "Mark ARTICLE with a mark of TYPE."
10791 (let ((vtype (car (assq type gnus-article-mark-lists)))
10792 var)
10793 (if (not vtype)
10794 (error "No such mark type: %s" type)
10795 (setq var (intern (format "gnus-newsgroup-%s" type)))
10796 (set var (cons article (symbol-value var)))
10797 (if (memq type '(processable cached replied forwarded recent saved))
10798 (gnus-summary-update-secondary-mark article)
10799 ;;; !!! This is bogus. We should find out what primary
10800 ;;; !!! mark we want to set.
10801 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10803 (defun gnus-summary-mark-as-expirable (n)
10804 "Mark N articles forward as expirable.
10805 If N is negative, mark backward instead. The difference between N and
10806 the actual number of articles marked is returned."
10807 (interactive "p")
10808 (gnus-summary-mark-forward n gnus-expirable-mark))
10810 (defun gnus-summary-mark-as-spam (n)
10811 "Mark N articles forward as spam.
10812 If N is negative, mark backward instead. The difference between N and
10813 the actual number of articles marked is returned."
10814 (interactive "p")
10815 (gnus-summary-mark-forward n gnus-spam-mark))
10817 (defun gnus-summary-mark-article-as-replied (article)
10818 "Mark ARTICLE as replied to and update the summary line.
10819 ARTICLE can also be a list of articles."
10820 (interactive (list (gnus-summary-article-number)))
10821 (let ((articles (if (listp article) article (list article))))
10822 (dolist (article articles)
10823 (unless (numberp article)
10824 (error "%s is not a number" article))
10825 (push article gnus-newsgroup-replied)
10826 (let ((inhibit-read-only t))
10827 (when (gnus-summary-goto-subject article nil t)
10828 (gnus-summary-update-secondary-mark article))))))
10830 (defun gnus-summary-mark-article-as-forwarded (article)
10831 "Mark ARTICLE as forwarded and update the summary line.
10832 ARTICLE can also be a list of articles."
10833 (let ((articles (if (listp article) article (list article))))
10834 (dolist (article articles)
10835 (push article gnus-newsgroup-forwarded)
10836 (let ((inhibit-read-only t))
10837 (when (gnus-summary-goto-subject article nil t)
10838 (gnus-summary-update-secondary-mark article))))))
10840 (defun gnus-summary-set-bookmark (article)
10841 "Set a bookmark in current article."
10842 (interactive (list (gnus-summary-article-number)))
10843 (when (or (not (get-buffer gnus-article-buffer))
10844 (not gnus-current-article)
10845 (not gnus-article-current)
10846 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10847 (error "No current article selected"))
10848 ;; Remove old bookmark, if one exists.
10849 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10850 ;; Set the new bookmark, which is on the form
10851 ;; (article-number . line-number-in-body).
10852 (push
10853 (cons article
10854 (with-current-buffer gnus-article-buffer
10855 (count-lines
10856 (min (point)
10857 (save-excursion
10858 (article-goto-body)
10859 (point)))
10860 (point))))
10861 gnus-newsgroup-bookmarks)
10862 (gnus-message 6 "A bookmark has been added to the current article."))
10864 (defun gnus-summary-remove-bookmark (article)
10865 "Remove the bookmark from the current article."
10866 (interactive (list (gnus-summary-article-number)))
10867 ;; Remove old bookmark, if one exists.
10868 (if (not (assq article gnus-newsgroup-bookmarks))
10869 (gnus-message 6 "No bookmark in current article.")
10870 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10871 (gnus-message 6 "Removed bookmark.")))
10873 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10874 (defun gnus-summary-mark-as-dormant (n)
10875 "Mark N articles forward as dormant.
10876 If N is negative, mark backward instead. The difference between N and
10877 the actual number of articles marked is returned."
10878 (interactive "p")
10879 (gnus-summary-mark-forward n gnus-dormant-mark))
10881 (defun gnus-summary-set-process-mark (article)
10882 "Set the process mark on ARTICLE and update the summary line."
10883 (setq gnus-newsgroup-processable
10884 (cons article
10885 (delq article gnus-newsgroup-processable)))
10886 (when (gnus-summary-goto-subject article)
10887 (gnus-summary-show-thread)
10888 (gnus-summary-goto-subject article)
10889 (gnus-summary-update-secondary-mark article)))
10891 (defun gnus-summary-remove-process-mark (&rest articles)
10892 "Remove the process mark from ARTICLES and update the summary line."
10893 (dolist (article articles)
10894 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10895 (when (gnus-summary-goto-subject article)
10896 (gnus-summary-show-thread)
10897 (gnus-summary-goto-subject article)
10898 (gnus-summary-update-secondary-mark article)))
10901 (defun gnus-summary-set-saved-mark (article)
10902 "Set the process mark on ARTICLE and update the summary line."
10903 (push article gnus-newsgroup-saved)
10904 (when (gnus-summary-goto-subject article)
10905 (gnus-summary-update-secondary-mark article)))
10907 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10908 "Mark N articles as read forwards.
10909 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10910 The difference between N and the actual number of articles marked is
10911 returned.
10912 If NO-EXPIRE, auto-expiry will be inhibited."
10913 (interactive "p")
10914 (gnus-summary-show-thread)
10915 (let ((backward (< n 0))
10916 (gnus-summary-goto-unread
10917 (and gnus-summary-goto-unread
10918 (not (eq gnus-summary-goto-unread 'never))
10919 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10920 gnus-ticked-mark gnus-dormant-mark)))))
10921 (n (abs n))
10922 (mark (or mark gnus-del-mark)))
10923 (while (and (> n 0)
10924 (gnus-summary-mark-article nil mark no-expire)
10925 (zerop (gnus-summary-next-subject
10926 (if backward -1 1)
10927 (and gnus-summary-goto-unread
10928 (not (eq gnus-summary-goto-unread 'never)))
10929 t)))
10930 (setq n (1- n)))
10931 (when (/= 0 n)
10932 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10933 (gnus-summary-recenter)
10934 (gnus-summary-position-point)
10935 (gnus-set-mode-line 'summary)
10938 (defun gnus-summary-mark-article-as-read (mark)
10939 "Mark the current article quickly as read with MARK."
10940 (let ((article (gnus-summary-article-number)))
10941 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10942 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10943 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10944 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10945 (push (cons article mark) gnus-newsgroup-reads)
10946 ;; Possibly remove from cache, if that is used.
10947 (when gnus-use-cache
10948 (gnus-cache-enter-remove-article article))
10949 ;; Allow the backend to change the mark.
10950 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10951 ;; Check for auto-expiry.
10952 (when (and gnus-newsgroup-auto-expire
10953 (memq mark gnus-auto-expirable-marks))
10954 (setq mark gnus-expirable-mark)
10955 ;; Let the backend know about the mark change.
10956 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10957 (push article gnus-newsgroup-expirable))
10958 ;; Set the mark in the buffer.
10959 (gnus-summary-update-mark mark 'unread)
10962 (defun gnus-summary-mark-article-as-unread (mark)
10963 "Mark the current article quickly as unread with MARK."
10964 (let* ((article (gnus-summary-article-number))
10965 (old-mark (gnus-summary-article-mark article)))
10966 ;; Allow the backend to change the mark.
10967 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10968 (if (eq mark old-mark)
10970 (if (<= article 0)
10971 (progn
10972 (gnus-error 1 "Can't mark negative article numbers")
10973 nil)
10974 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10975 (setq gnus-newsgroup-spam-marked
10976 (delq article gnus-newsgroup-spam-marked))
10977 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10978 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10979 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10980 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10981 (cond ((= mark gnus-ticked-mark)
10982 (setq gnus-newsgroup-marked
10983 (gnus-add-to-sorted-list gnus-newsgroup-marked
10984 article)))
10985 ((= mark gnus-spam-mark)
10986 (setq gnus-newsgroup-spam-marked
10987 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10988 article)))
10989 ((= mark gnus-dormant-mark)
10990 (setq gnus-newsgroup-dormant
10991 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10992 article)))
10994 (setq gnus-newsgroup-unreads
10995 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10996 article))))
10997 (gnus-alist-pull article gnus-newsgroup-reads)
10999 ;; See whether the article is to be put in the cache.
11000 (and gnus-use-cache
11001 (vectorp (gnus-summary-article-header article))
11002 (save-excursion
11003 (gnus-cache-possibly-enter-article
11004 gnus-newsgroup-name article
11005 (= mark gnus-ticked-mark)
11006 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11008 ;; Fix the mark.
11009 (gnus-summary-update-mark mark 'unread)
11010 t))))
11012 (defun gnus-summary-mark-article (&optional article mark no-expire)
11013 "Mark ARTICLE with MARK. MARK can be any character.
11014 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11015 `??' (dormant) and `?E' (expirable).
11016 If MARK is nil, then the default character `?r' is used.
11017 If ARTICLE is nil, then the article on the current line will be
11018 marked.
11019 If NO-EXPIRE, auto-expiry will be inhibited."
11020 ;; The mark might be a string.
11021 (when (stringp mark)
11022 (setq mark (aref mark 0)))
11023 ;; If no mark is given, then we check auto-expiring.
11024 (when (null mark)
11025 (setq mark gnus-del-mark))
11026 (when (and (not no-expire)
11027 gnus-newsgroup-auto-expire
11028 (memq mark gnus-auto-expirable-marks))
11029 (setq mark gnus-expirable-mark))
11030 (let ((article (or article (gnus-summary-article-number)))
11031 (old-mark (gnus-summary-article-mark article)))
11032 ;; Allow the backend to change the mark.
11033 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11034 (if (eq mark old-mark)
11036 (unless article
11037 (error "No article on current line"))
11038 (if (not (if (or (= mark gnus-unread-mark)
11039 (= mark gnus-ticked-mark)
11040 (= mark gnus-spam-mark)
11041 (= mark gnus-dormant-mark))
11042 (gnus-mark-article-as-unread article mark)
11043 (gnus-mark-article-as-read article mark)))
11045 ;; See whether the article is to be put in the cache.
11046 (and gnus-use-cache
11047 (not (= mark gnus-canceled-mark))
11048 (vectorp (gnus-summary-article-header article))
11049 (save-excursion
11050 (gnus-cache-possibly-enter-article
11051 gnus-newsgroup-name article
11052 (= mark gnus-ticked-mark)
11053 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11055 (when (gnus-summary-goto-subject article nil t)
11056 (let ((inhibit-read-only t))
11057 (gnus-summary-show-thread)
11058 ;; Fix the mark.
11059 (gnus-summary-update-mark mark 'unread)
11060 t))))))
11062 (defun gnus-summary-update-secondary-mark (article)
11063 "Update the secondary (read, process, cache) mark."
11064 (gnus-summary-update-mark
11065 (cond ((memq article gnus-newsgroup-processable)
11066 gnus-process-mark)
11067 ((memq article gnus-newsgroup-cached)
11068 gnus-cached-mark)
11069 ((memq article gnus-newsgroup-replied)
11070 gnus-replied-mark)
11071 ((memq article gnus-newsgroup-forwarded)
11072 gnus-forwarded-mark)
11073 ((memq article gnus-newsgroup-saved)
11074 gnus-saved-mark)
11075 ((memq article gnus-newsgroup-unseen)
11076 gnus-unseen-mark)
11077 (t gnus-no-mark))
11078 'replied)
11079 (when (gnus-visual-p 'summary-highlight 'highlight)
11080 (gnus-summary-highlight-line)
11081 (gnus-run-hooks 'gnus-summary-update-hook))
11084 (defun gnus-summary-update-download-mark (article)
11085 "Update the download mark."
11086 (gnus-summary-update-mark
11087 (cond ((memq article gnus-newsgroup-undownloaded)
11088 gnus-undownloaded-mark)
11089 (gnus-newsgroup-agentized
11090 gnus-downloaded-mark)
11092 gnus-no-mark))
11093 'download)
11094 (gnus-summary-update-line t)
11097 (defun gnus-summary-update-mark (mark type)
11098 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11099 (inhibit-read-only t))
11100 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11101 (when forward
11102 (when (looking-at "\r")
11103 (incf forward))
11104 (when (<= (+ forward (point)) (point-max))
11105 ;; Go to the right position on the line.
11106 (goto-char (+ forward (point)))
11107 ;; Replace the old mark with the new mark.
11108 (let ((to-insert
11109 (mm-subst-char-in-string
11110 (char-after) mark
11111 (buffer-substring (point) (1+ (point))))))
11112 (delete-region (point) (1+ (point)))
11113 (insert to-insert))
11114 ;; Optionally update the marks by some user rule.
11115 (when (eq type 'unread)
11116 (gnus-data-set-mark
11117 (gnus-data-find (gnus-summary-article-number)) mark)
11118 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11120 (defun gnus-mark-article-as-read (article &optional mark)
11121 "Enter ARTICLE in the pertinent lists and remove it from others."
11122 ;; Make the article expirable.
11123 (let ((mark (or mark gnus-del-mark)))
11124 (setq gnus-newsgroup-expirable
11125 (if (= mark gnus-expirable-mark)
11126 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11127 (delq article gnus-newsgroup-expirable)))
11128 ;; Remove from unread and marked lists.
11129 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11130 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11131 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11132 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11133 (push (cons article mark) gnus-newsgroup-reads)
11134 ;; Possibly remove from cache, if that is used.
11135 (when gnus-use-cache
11136 (gnus-cache-enter-remove-article article))
11139 (defun gnus-mark-article-as-unread (article &optional mark)
11140 "Enter ARTICLE in the pertinent lists and remove it from others."
11141 (let ((mark (or mark gnus-ticked-mark)))
11142 (if (<= article 0)
11143 (progn
11144 (gnus-error 1 "Can't mark negative article numbers")
11145 nil)
11146 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11147 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11148 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11149 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11150 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11152 ;; Unsuppress duplicates?
11153 (when gnus-suppress-duplicates
11154 (gnus-dup-unsuppress-article article))
11156 (cond ((= mark gnus-ticked-mark)
11157 (setq gnus-newsgroup-marked
11158 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11159 ((= mark gnus-spam-mark)
11160 (setq gnus-newsgroup-spam-marked
11161 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11162 article)))
11163 ((= mark gnus-dormant-mark)
11164 (setq gnus-newsgroup-dormant
11165 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11167 (setq gnus-newsgroup-unreads
11168 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11169 (gnus-alist-pull article gnus-newsgroup-reads)
11170 t)))
11172 (defun gnus-summary-tick-article-forward (n)
11173 "Tick N articles forwards.
11174 If N is negative, tick backwards instead.
11175 The difference between N and the number of articles ticked is returned."
11176 (interactive "p")
11177 (gnus-summary-mark-forward n gnus-ticked-mark))
11179 (defun gnus-summary-tick-article-backward (n)
11180 "Tick N articles backwards.
11181 The difference between N and the number of articles ticked is returned."
11182 (interactive "p")
11183 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11185 (defun gnus-summary-tick-article (&optional article clear-mark)
11186 "Mark current article as unread.
11187 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11188 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11189 (interactive)
11190 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11191 gnus-ticked-mark)))
11193 (defun gnus-summary-mark-as-read-forward (n)
11194 "Mark N articles as read forwards.
11195 If N is negative, mark backwards instead.
11196 The difference between N and the actual number of articles marked is
11197 returned."
11198 (interactive "p")
11199 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11201 (defun gnus-summary-mark-as-read-backward (n)
11202 "Mark the N articles as read backwards.
11203 The difference between N and the actual number of articles marked is
11204 returned."
11205 (interactive "p")
11206 (gnus-summary-mark-forward
11207 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11209 (defun gnus-summary-mark-as-read (&optional article mark)
11210 "Mark current article as read.
11211 ARTICLE specifies the article to be marked as read.
11212 MARK specifies a string to be inserted at the beginning of the line."
11213 (gnus-summary-mark-article article mark))
11215 (defun gnus-summary-clear-mark-forward (n)
11216 "Clear marks from N articles forward.
11217 If N is negative, clear backward instead.
11218 The difference between N and the number of marks cleared is returned."
11219 (interactive "p")
11220 (gnus-summary-mark-forward n gnus-unread-mark))
11222 (defun gnus-summary-clear-mark-backward (n)
11223 "Clear marks from N articles backward.
11224 The difference between N and the number of marks cleared is returned."
11225 (interactive "p")
11226 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11228 (defun gnus-summary-mark-unread-as-read ()
11229 "Intended to be used by `gnus-mark-article-hook'."
11230 (when (memq gnus-current-article gnus-newsgroup-unreads)
11231 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11233 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11234 "Intended to be used by `gnus-mark-article-hook'."
11235 (let ((mark (gnus-summary-article-mark)))
11236 (when (or (gnus-unread-mark-p mark)
11237 (gnus-read-mark-p mark))
11238 (gnus-summary-mark-article gnus-current-article
11239 (or new-mark gnus-read-mark)))))
11241 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11242 "Intended to be used by `gnus-mark-article-hook'."
11243 (let ((mark (gnus-summary-article-mark)))
11244 (when (or (gnus-unread-mark-p mark)
11245 (gnus-read-mark-p mark))
11246 (gnus-summary-mark-article (gnus-summary-article-number)
11247 (or new-mark gnus-read-mark)))))
11249 (defun gnus-summary-mark-unread-as-ticked ()
11250 "Intended to be used by `gnus-mark-article-hook'."
11251 (when (memq gnus-current-article gnus-newsgroup-unreads)
11252 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11254 (defun gnus-summary-mark-region-as-read (point mark all)
11255 "Mark all unread articles between point and mark as read.
11256 If given a prefix, mark all articles between point and mark as read,
11257 even ticked and dormant ones."
11258 (interactive "r\nP")
11259 (save-excursion
11260 (let (article)
11261 (goto-char point)
11262 (beginning-of-line)
11263 (while (and
11264 (< (point) mark)
11265 (progn
11266 (when (or all
11267 (memq (setq article (gnus-summary-article-number))
11268 gnus-newsgroup-unreads))
11269 (gnus-summary-mark-article article gnus-del-mark))
11271 (gnus-summary-find-next))))))
11273 (defun gnus-summary-mark-below (score mark)
11274 "Mark articles with score less than SCORE with MARK."
11275 (interactive "P\ncMark: ")
11276 (setq score (if score
11277 (prefix-numeric-value score)
11278 (or gnus-summary-default-score 0)))
11279 (with-current-buffer gnus-summary-buffer
11280 (goto-char (point-min))
11281 (while
11282 (progn
11283 (and (< (gnus-summary-article-score) score)
11284 (gnus-summary-mark-article nil mark))
11285 (gnus-summary-find-next)))))
11287 (defun gnus-summary-kill-below (&optional score)
11288 "Mark articles with score below SCORE as read."
11289 (interactive "P")
11290 (gnus-summary-mark-below score gnus-killed-mark))
11292 (defun gnus-summary-clear-above (&optional score)
11293 "Clear all marks from articles with score above SCORE."
11294 (interactive "P")
11295 (gnus-summary-mark-above score gnus-unread-mark))
11297 (defun gnus-summary-tick-above (&optional score)
11298 "Tick all articles with score above SCORE."
11299 (interactive "P")
11300 (gnus-summary-mark-above score gnus-ticked-mark))
11302 (defun gnus-summary-mark-above (score mark)
11303 "Mark articles with score over SCORE with MARK."
11304 (interactive "P\ncMark: ")
11305 (setq score (if score
11306 (prefix-numeric-value score)
11307 (or gnus-summary-default-score 0)))
11308 (with-current-buffer gnus-summary-buffer
11309 (goto-char (point-min))
11310 (while (and (progn
11311 (when (> (gnus-summary-article-score) score)
11312 (gnus-summary-mark-article nil mark))
11314 (gnus-summary-find-next)))))
11316 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11317 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11318 (defun gnus-summary-limit-include-expunged (&optional no-error)
11319 "Display all the hidden articles that were expunged for low scores."
11320 (interactive)
11321 (let ((inhibit-read-only t))
11322 (let ((scored gnus-newsgroup-scored)
11323 headers h)
11324 (while scored
11325 (unless (gnus-summary-article-header (caar scored))
11326 (and (setq h (gnus-number-to-header (caar scored)))
11327 (< (cdar scored) gnus-summary-expunge-below)
11328 (push h headers)))
11329 (setq scored (cdr scored)))
11330 (if (not headers)
11331 (when (not no-error)
11332 (error "No expunged articles hidden"))
11333 (goto-char (point-min))
11334 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11335 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11336 (dolist (x headers)
11337 (push (mail-header-number x) gnus-newsgroup-limit))
11338 (gnus-summary-prepare-unthreaded (nreverse headers))
11339 (goto-char (point-min))
11340 (gnus-summary-position-point)
11341 t))))
11343 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11344 "Mark all unread articles in this newsgroup as read.
11345 If prefix argument ALL is non-nil, ticked and dormant articles will
11346 also be marked as read.
11347 If QUIETLY is non-nil, no questions will be asked.
11349 If TO-HERE is non-nil, it should be a point in the buffer. All
11350 articles before (after, if REVERSE is set) this point will be marked
11351 as read.
11353 Note that this function will only catch up the unread article
11354 in the current summary buffer limitation.
11356 The number of articles marked as read is returned."
11357 (interactive "P")
11358 (prog1
11359 (save-excursion
11360 (when (or quietly
11361 (not gnus-interactive-catchup) ;Without confirmation?
11362 gnus-expert-user
11363 (gnus-y-or-n-p
11364 (if all
11365 "Mark absolutely all articles as read? "
11366 "Mark all unread articles as read? ")))
11367 (if (and not-mark
11368 (not gnus-newsgroup-adaptive)
11369 (not gnus-newsgroup-auto-expire)
11370 (not gnus-suppress-duplicates)
11371 (or (not gnus-use-cache)
11372 (eq gnus-use-cache 'passive)))
11373 (progn
11374 (when all
11375 (setq gnus-newsgroup-marked nil
11376 gnus-newsgroup-spam-marked nil
11377 gnus-newsgroup-dormant nil))
11378 (setq gnus-newsgroup-unreads
11379 (gnus-sorted-nunion
11380 (gnus-sorted-intersection gnus-newsgroup-unreads
11381 gnus-newsgroup-downloadable)
11382 (gnus-sorted-difference gnus-newsgroup-unfetched
11383 gnus-newsgroup-cached))))
11384 ;; We actually mark all articles as canceled, which we
11385 ;; have to do when using auto-expiry or adaptive scoring.
11386 (gnus-summary-show-all-threads)
11387 (if (and to-here reverse)
11388 (progn
11389 (goto-char to-here)
11390 (gnus-summary-mark-current-read-and-unread-as-read
11391 gnus-catchup-mark)
11392 (while (gnus-summary-find-next (not all))
11393 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11394 (when (gnus-summary-first-subject (not all))
11395 (while (and
11396 (if to-here (< (point) to-here) t)
11397 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11398 (gnus-summary-find-next (not all))))))
11399 (gnus-set-mode-line 'summary))
11401 (gnus-summary-position-point)))
11403 (defun gnus-summary-catchup-to-here (&optional all)
11404 "Mark all unticked articles before the current one as read.
11405 If ALL is non-nil, also mark ticked and dormant articles as read."
11406 (interactive "P")
11407 (save-excursion
11408 (gnus-save-hidden-threads
11409 (let ((beg (point)))
11410 ;; We check that there are unread articles.
11411 (when (or all (gnus-summary-find-prev))
11412 (gnus-summary-catchup all t beg)))))
11413 (gnus-summary-position-point))
11415 (defun gnus-summary-catchup-from-here (&optional all)
11416 "Mark all unticked articles after (and including) the current one as read.
11417 If ALL is non-nil, also mark ticked and dormant articles as read."
11418 (interactive "P")
11419 (save-excursion
11420 (gnus-save-hidden-threads
11421 (let ((beg (point)))
11422 ;; We check that there are unread articles.
11423 (when (or all (gnus-summary-find-next))
11424 (gnus-summary-catchup all t beg nil t)))))
11425 (gnus-summary-position-point))
11427 (defun gnus-summary-catchup-all (&optional quietly)
11428 "Mark all articles in this newsgroup as read.
11429 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11430 instead, which marks only unread articles as read."
11431 (interactive "P")
11432 (gnus-summary-catchup t quietly))
11434 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11435 "Mark all unread articles in this group as read, then exit.
11436 If prefix argument ALL is non-nil, all articles are marked as read.
11437 If QUIETLY is non-nil, no questions will be asked."
11438 (interactive "P")
11439 (when (gnus-summary-catchup all quietly nil 'fast)
11440 ;; Select next newsgroup or exit.
11441 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11442 (eq gnus-auto-select-next 'quietly))
11443 (gnus-summary-next-group nil)
11444 (gnus-summary-exit))))
11446 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11447 "Mark all articles in this newsgroup as read, and then exit.
11448 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11449 instead, which marks only unread articles as read."
11450 (interactive "P")
11451 (gnus-summary-catchup-and-exit t quietly))
11453 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11454 "Mark all articles in this group as read and select the next group.
11455 If given a prefix, mark all articles, unread as well as ticked, as
11456 read."
11457 (interactive "P")
11458 (save-excursion
11459 (gnus-summary-catchup all))
11460 (gnus-summary-next-group))
11462 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11463 "Mark all articles in this group as read and select the previous group.
11464 If given a prefix, mark all articles, unread as well as ticked, as
11465 read."
11466 (interactive "P")
11467 (save-excursion
11468 (gnus-summary-catchup all))
11469 (gnus-summary-next-group nil nil t))
11472 ;;; with article
11475 (defmacro gnus-with-article (article &rest forms)
11476 "Select ARTICLE and perform FORMS in the original article buffer.
11477 Then replace the article with the result."
11478 `(progn
11479 ;; We don't want the article to be marked as read.
11480 (let (gnus-mark-article-hook)
11481 (gnus-summary-select-article t t nil ,article))
11482 (set-buffer gnus-original-article-buffer)
11483 ,@forms
11484 (if (not (gnus-check-backend-function
11485 'request-replace-article (car gnus-article-current)))
11486 (gnus-message 5 "Read-only group; not replacing")
11487 (unless (gnus-request-replace-article
11488 ,article (car gnus-article-current)
11489 (current-buffer) t)
11490 (error "Couldn't replace article")))
11491 ;; The cache and backlog have to be flushed somewhat.
11492 (when gnus-keep-backlog
11493 (gnus-backlog-remove-article
11494 (car gnus-article-current) (cdr gnus-article-current)))
11495 (when gnus-use-cache
11496 (gnus-cache-update-article
11497 (car gnus-article-current) (cdr gnus-article-current)))))
11499 (put 'gnus-with-article 'lisp-indent-function 1)
11500 (put 'gnus-with-article 'edebug-form-spec '(form body))
11502 ;; Thread-based commands.
11504 (defun gnus-summary-articles-in-thread (&optional article)
11505 "Return a list of all articles in the current thread.
11506 If ARTICLE is non-nil, return all articles in the thread that starts
11507 with that article."
11508 (let* ((article (or article (gnus-summary-article-number)))
11509 (data (gnus-data-find-list article))
11510 (top-level (gnus-data-level (car data)))
11511 (top-subject
11512 (cond ((null gnus-thread-operation-ignore-subject)
11513 (gnus-simplify-subject-re
11514 (mail-header-subject (gnus-data-header (car data)))))
11515 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11516 (gnus-simplify-subject-fuzzy
11517 (mail-header-subject (gnus-data-header (car data)))))
11518 (t nil)))
11519 (end-point (save-excursion
11520 (goto-char (gnus-data-pos (car data)))
11521 (if (gnus-summary-go-to-next-thread)
11522 (point) (point-max))))
11523 articles)
11524 (while (and data
11525 (< (gnus-data-pos (car data)) end-point))
11526 (when (or (not top-subject)
11527 (string= top-subject
11528 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11529 (gnus-simplify-subject-fuzzy
11530 (mail-header-subject
11531 (gnus-data-header (car data))))
11532 (gnus-simplify-subject-re
11533 (mail-header-subject
11534 (gnus-data-header (car data)))))))
11535 (push (gnus-data-number (car data)) articles))
11536 (unless (and (setq data (cdr data))
11537 (> (gnus-data-level (car data)) top-level))
11538 (setq data nil)))
11539 ;; Return the list of articles.
11540 (nreverse articles)))
11542 (defun gnus-summary-rethread-current ()
11543 "Rethread the thread the current article is part of."
11544 (interactive)
11545 (let* ((gnus-show-threads t)
11546 (article (gnus-summary-article-number))
11547 (id (mail-header-id (gnus-summary-article-header)))
11548 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11549 (unless id
11550 (error "No article on the current line"))
11551 (gnus-rebuild-thread id)
11552 (gnus-summary-goto-subject article)))
11554 (defun gnus-summary-reparent-thread ()
11555 "Make the current article child of the marked (or previous) article.
11557 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11558 is non-nil or the Subject: of both articles are the same."
11559 (interactive)
11560 (unless (not (gnus-group-read-only-p))
11561 (error "The current newsgroup does not support article editing"))
11562 (unless (<= (length gnus-newsgroup-processable) 1)
11563 (error "No more than one article may be marked"))
11564 (let ((child (gnus-summary-article-number))
11565 ;; First grab the marked article, otherwise one line up.
11566 (parent (if (not (null gnus-newsgroup-processable))
11567 (car gnus-newsgroup-processable)
11568 (save-excursion
11569 (if (eq (forward-line -1) 0)
11570 (gnus-summary-article-number)
11571 (error "Beginning of summary buffer"))))))
11572 (gnus-summary-reparent-children parent (list child))))
11574 (defun gnus-summary-reparent-children (parent children)
11575 "Make PARENT the parent of CHILDREN.
11576 When called interactively, PARENT is the current article and CHILDREN
11577 are the process-marked articles."
11578 (interactive
11579 (list (gnus-summary-article-number)
11580 (gnus-summary-work-articles nil)))
11581 (dolist (child children)
11582 (save-window-excursion
11583 (let ((gnus-article-buffer " *reparent*"))
11584 (unless (not (eq parent child))
11585 (error "An article may not be self-referential"))
11586 (let ((message-id (mail-header-id
11587 (gnus-summary-article-header parent))))
11588 (unless (and message-id (not (equal message-id "")))
11589 (error "No message-id in desired parent"))
11590 (gnus-with-article child
11591 (save-restriction
11592 (goto-char (point-min))
11593 (message-narrow-to-head)
11594 (if (re-search-forward "^References: " nil t)
11595 (progn
11596 (re-search-forward "^[^ \t]" nil t)
11597 (forward-line -1)
11598 (end-of-line)
11599 (insert " " message-id))
11600 (insert "References: " message-id "\n"))))
11601 (set-buffer gnus-summary-buffer)
11602 (gnus-summary-unmark-all-processable)
11603 (gnus-summary-update-article child)
11604 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11605 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11606 (gnus-summary-rethread-current)
11607 (gnus-message 3 "Article %d is now the child of article %d"
11608 child parent))))))
11610 (defun gnus-summary-toggle-threads (&optional arg)
11611 "Toggle showing conversation threads.
11612 If ARG is positive number, turn showing conversation threads on."
11613 (interactive "P")
11614 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11615 (setq gnus-show-threads
11616 (if (null arg) (not gnus-show-threads)
11617 (> (prefix-numeric-value arg) 0)))
11618 (gnus-summary-prepare)
11619 (gnus-summary-goto-subject current)
11620 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11621 (gnus-summary-position-point)))
11623 (eval-and-compile
11624 (if (fboundp 'remove-overlays)
11625 (defalias 'gnus-remove-overlays 'remove-overlays)
11626 (defun gnus-remove-overlays (beg end name val)
11627 "Clear BEG and END of overlays whose property NAME has value VAL.
11628 For compatibility with XEmacs."
11629 (dolist (ov (gnus-overlays-in beg end))
11630 (when (eq (gnus-overlay-get ov name) val)
11631 (gnus-delete-overlay ov))))))
11633 (defun gnus-summary-show-all-threads ()
11634 "Show all threads."
11635 (interactive)
11636 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11637 (gnus-summary-position-point))
11639 (defsubst gnus-summary--inv (p)
11640 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11642 (defun gnus-summary-show-thread ()
11643 "Show thread subtrees.
11644 Returns nil if no thread was there to be shown."
11645 (interactive)
11646 (let* ((orig (point))
11647 (end (point-at-eol))
11648 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11649 ;; Leave point at bol
11650 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11651 (eoi (when end
11652 (if (fboundp 'next-single-char-property-change)
11653 ;; Note: XEmacs version of n-s-c-p-c may return nil
11654 (or (next-single-char-property-change end 'invisible)
11655 (point-max))
11656 (while (progn
11657 (end-of-line 2)
11658 (and (not (eobp))
11659 (eq (get-char-property (point) 'invisible)
11660 'gnus-sum))))
11661 (point)))))
11662 (when eoi
11663 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11664 (goto-char orig)
11665 (gnus-summary-position-point)
11666 eoi)))
11668 (defun gnus-summary-maybe-hide-threads ()
11669 "If requested, hide the threads that should be hidden."
11670 (when (and gnus-show-threads
11671 gnus-thread-hide-subtree)
11672 (gnus-summary-hide-all-threads
11673 (if (or (consp gnus-thread-hide-subtree)
11674 (functionp gnus-thread-hide-subtree))
11675 (gnus-make-predicate gnus-thread-hide-subtree)
11676 nil))))
11678 ;;; Hiding predicates.
11680 (defun gnus-article-unread-p (header)
11681 (memq (mail-header-number header) gnus-newsgroup-unreads))
11683 (defun gnus-article-unseen-p (header)
11684 (memq (mail-header-number header) gnus-newsgroup-unseen))
11686 (defun gnus-map-articles (predicate articles)
11687 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11688 (apply 'gnus-or (mapcar predicate
11689 (mapcar (lambda (number)
11690 (gnus-summary-article-header number))
11691 articles))))
11693 (defun gnus-summary-hide-all-threads (&optional predicate)
11694 "Hide all thread subtrees.
11695 If PREDICATE is supplied, threads that satisfy this predicate
11696 will not be hidden."
11697 (interactive)
11698 (save-excursion
11699 (goto-char (point-min))
11700 (let ((end nil)
11701 (count 0))
11702 (while (not end)
11703 (incf count)
11704 (when (zerop (mod count 1000))
11705 (message "Hiding all threads... %d" count))
11706 (when (or (not predicate)
11707 (gnus-map-articles
11708 predicate (gnus-summary-article-children)))
11709 (gnus-summary-hide-thread))
11710 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11711 (gnus-summary-position-point))
11713 (defun gnus-summary-hide-thread ()
11714 "Hide thread subtrees.
11715 If PREDICATE is supplied, threads that satisfy this predicate
11716 will not be hidden.
11717 Returns nil if no threads were there to be hidden."
11718 (interactive)
11719 (beginning-of-line)
11720 (let ((start (point))
11721 (starteol (line-end-position))
11722 (article (gnus-summary-article-number)))
11723 ;; Go forward until either the buffer ends or the subthread ends.
11724 (when (and (not (eobp))
11725 (or (zerop (gnus-summary-next-thread 1 t))
11726 (goto-char (point-max))))
11727 (if (and (> (point) start)
11728 ;; FIXME: this should actually search for a non-invisible \n.
11729 (search-backward "\n" start t))
11730 (progn
11731 (when (> (point) starteol)
11732 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11733 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11734 (gnus-overlay-put ol 'invisible 'gnus-sum)
11735 (gnus-overlay-put ol 'evaporate t)))
11736 (gnus-summary-goto-subject article)
11737 (when (> start (point))
11738 (message "Hiding the thread moved us backwards, aborting!")
11739 (goto-char (point-max))))
11740 (goto-char start)
11741 nil))))
11743 (defun gnus-summary-go-to-next-thread (&optional previous)
11744 "Go to the same level (or less) next thread.
11745 If PREVIOUS is non-nil, go to previous thread instead.
11746 Return the article number moved to, or nil if moving was impossible."
11747 (let ((level (gnus-summary-thread-level))
11748 (way (if previous -1 1))
11749 (beg (point)))
11750 (forward-line way)
11751 (while (and (not (eobp))
11752 (< level (gnus-summary-thread-level)))
11753 (forward-line way))
11754 (if (eobp)
11755 (progn
11756 (goto-char beg)
11757 nil)
11758 (setq beg (point))
11759 (prog1
11760 (gnus-summary-article-number)
11761 (goto-char beg)))))
11763 (defun gnus-summary-next-thread (n &optional silent)
11764 "Go to the same level next N'th thread.
11765 If N is negative, search backward instead.
11766 Returns the difference between N and the number of skips actually
11767 done.
11769 If SILENT, don't output messages."
11770 (interactive "p")
11771 (let ((backward (< n 0))
11772 (n (abs n)))
11773 (while (and (> n 0)
11774 (gnus-summary-go-to-next-thread backward))
11775 (decf n))
11776 (unless silent
11777 (gnus-summary-position-point))
11778 (when (and (not silent) (/= 0 n))
11779 (gnus-message 7 "No more threads"))
11782 (defun gnus-summary-prev-thread (n)
11783 "Go to the same level previous N'th thread.
11784 Returns the difference between N and the number of skips actually
11785 done."
11786 (interactive "p")
11787 (gnus-summary-next-thread (- n)))
11789 (defun gnus-summary-go-down-thread ()
11790 "Go down one level in the current thread."
11791 (let ((children (gnus-summary-article-children)))
11792 (when children
11793 (gnus-summary-goto-subject (car children)))))
11795 (defun gnus-summary-go-up-thread ()
11796 "Go up one level in the current thread."
11797 (let ((parent (gnus-summary-article-parent)))
11798 (when parent
11799 (gnus-summary-goto-subject parent))))
11801 (defun gnus-summary-down-thread (n)
11802 "Go down thread N steps.
11803 If N is negative, go up instead.
11804 Returns the difference between N and how many steps down that were
11805 taken."
11806 (interactive "p")
11807 (let ((up (< n 0))
11808 (n (abs n)))
11809 (while (and (> n 0)
11810 (if up (gnus-summary-go-up-thread)
11811 (gnus-summary-go-down-thread)))
11812 (setq n (1- n)))
11813 (gnus-summary-position-point)
11814 (when (/= 0 n)
11815 (gnus-message 7 "Can't go further"))
11818 (defun gnus-summary-up-thread (n)
11819 "Go up thread N steps.
11820 If N is negative, go down instead.
11821 Returns the difference between N and how many steps down that were
11822 taken."
11823 (interactive "p")
11824 (gnus-summary-down-thread (- n)))
11826 (defun gnus-summary-top-thread ()
11827 "Go to the top of the thread."
11828 (interactive)
11829 (while (gnus-summary-go-up-thread))
11830 (gnus-summary-article-number))
11832 (defun gnus-summary-expire-thread ()
11833 "Mark articles under current thread as expired."
11834 (interactive)
11835 (gnus-summary-kill-thread 0))
11837 (defun gnus-summary-kill-thread (&optional unmark)
11838 "Mark articles under current thread as read.
11839 If the prefix argument is positive, remove any kinds of marks.
11840 If the prefix argument is zero, mark thread as expired.
11841 If the prefix argument is negative, tick articles instead."
11842 (interactive "P")
11843 (when unmark
11844 (setq unmark (prefix-numeric-value unmark)))
11845 (let ((articles (gnus-summary-articles-in-thread))
11846 (hide (or (null unmark) (= unmark 0))))
11847 (save-excursion
11848 ;; Expand the thread.
11849 (gnus-summary-show-thread)
11850 ;; Mark all the articles.
11851 (while articles
11852 (gnus-summary-goto-subject (car articles))
11853 (cond ((null unmark)
11854 (gnus-summary-mark-article-as-read gnus-killed-mark))
11855 ((> unmark 0)
11856 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11857 ((= unmark 0)
11858 (gnus-summary-mark-article nil gnus-expirable-mark))
11860 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11861 (setq articles (cdr articles))))
11862 ;; Hide killed subtrees when hide is true.
11863 (and hide
11864 gnus-thread-hide-killed
11865 (gnus-summary-hide-thread))
11866 ;; If hide is t, go to next unread subject.
11867 (when hide
11868 ;; Go to next unread subject.
11869 (gnus-summary-next-subject 1 t)))
11870 (gnus-set-mode-line 'summary))
11872 ;; Summary sorting commands
11874 (defun gnus-summary-sort-by-number (&optional reverse)
11875 "Sort the summary buffer by article number.
11876 Argument REVERSE means reverse order."
11877 (interactive "P")
11878 (gnus-summary-sort 'number reverse))
11880 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11881 "Sort the summary buffer by most recent article number.
11882 Argument REVERSE means reverse order."
11883 (interactive "P")
11884 (gnus-summary-sort 'most-recent-number reverse))
11886 (defun gnus-summary-sort-by-random (&optional reverse)
11887 "Randomize the order in the summary buffer.
11888 Argument REVERSE means to randomize in reverse order."
11889 (interactive "P")
11890 (gnus-summary-sort 'random reverse))
11892 (defun gnus-summary-sort-by-author (&optional reverse)
11893 "Sort the summary buffer by author name alphabetically.
11894 If `case-fold-search' is non-nil, case of letters is ignored.
11895 Argument REVERSE means reverse order."
11896 (interactive "P")
11897 (gnus-summary-sort 'author reverse))
11899 (defun gnus-summary-sort-by-recipient (&optional reverse)
11900 "Sort the summary buffer by recipient name alphabetically.
11901 If `case-fold-search' is non-nil, case of letters is ignored.
11902 Argument REVERSE means reverse order."
11903 (interactive "P")
11904 (gnus-summary-sort 'recipient reverse))
11906 (defun gnus-summary-sort-by-subject (&optional reverse)
11907 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11908 If `case-fold-search' is non-nil, case of letters is ignored.
11909 Argument REVERSE means reverse order."
11910 (interactive "P")
11911 (gnus-summary-sort 'subject reverse))
11913 (defun gnus-summary-sort-by-date (&optional reverse)
11914 "Sort the summary buffer by date.
11915 Argument REVERSE means reverse order."
11916 (interactive "P")
11917 (gnus-summary-sort 'date reverse))
11919 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11920 "Sort the summary buffer by most recent date.
11921 Argument REVERSE means reverse order."
11922 (interactive "P")
11923 (gnus-summary-sort 'most-recent-date reverse))
11925 (defun gnus-summary-sort-by-score (&optional reverse)
11926 "Sort the summary buffer by score.
11927 Argument REVERSE means reverse order."
11928 (interactive "P")
11929 (gnus-summary-sort 'score reverse))
11931 (defun gnus-summary-sort-by-lines (&optional reverse)
11932 "Sort the summary buffer by the number of lines.
11933 Argument REVERSE means reverse order."
11934 (interactive "P")
11935 (gnus-summary-sort 'lines reverse))
11937 (defun gnus-summary-sort-by-chars (&optional reverse)
11938 "Sort the summary buffer by article length.
11939 Argument REVERSE means reverse order."
11940 (interactive "P")
11941 (gnus-summary-sort 'chars reverse))
11943 (defun gnus-summary-sort-by-original (&optional reverse)
11944 "Sort the summary buffer using the default sorting method.
11945 Argument REVERSE means reverse order."
11946 (interactive "P")
11947 (let* ((inhibit-read-only t)
11948 (gnus-summary-prepare-hook nil))
11949 ;; We do the sorting by regenerating the threads.
11950 (gnus-summary-prepare)
11951 ;; Hide subthreads if needed.
11952 (gnus-summary-maybe-hide-threads)))
11954 (defun gnus-summary-sort (predicate reverse)
11955 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11956 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11957 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11958 (gnus-thread-sort-functions
11959 (if (not reverse)
11960 thread
11961 `(lambda (t1 t2)
11962 (,thread t2 t1))))
11963 (gnus-sort-gathered-threads-function
11964 gnus-thread-sort-functions)
11965 (gnus-article-sort-functions
11966 (if (not reverse)
11967 article
11968 `(lambda (t1 t2)
11969 (,article t2 t1))))
11970 (inhibit-read-only t)
11971 (gnus-summary-prepare-hook nil))
11972 ;; We do the sorting by regenerating the threads.
11973 (gnus-summary-prepare)
11974 ;; Hide subthreads if needed.
11975 (gnus-summary-maybe-hide-threads)))
11977 ;; Summary saving commands.
11979 (defun gnus-summary-save-article (&optional n not-saved)
11980 "Save the current article using the default saver function.
11981 If N is a positive number, save the N next articles.
11982 If N is a negative number, save the N previous articles.
11983 If N is nil and any articles have been marked with the process mark,
11984 save those articles instead.
11985 The variable `gnus-default-article-saver' specifies the saver function.
11987 If the optional second argument NOT-SAVED is non-nil, articles saved
11988 will not be marked as saved."
11989 (interactive "P")
11990 (require 'gnus-art)
11991 (let* ((articles (gnus-summary-work-articles n))
11992 (save-buffer (save-excursion
11993 (nnheader-set-temp-buffer " *Gnus Save*")))
11994 (num (length articles))
11995 ;; Whether to save decoded articles or raw articles.
11996 (decode (when gnus-article-save-coding-system
11997 (get gnus-default-article-saver :decode)))
11998 ;; When saving many articles in a single file, use the other
11999 ;; function to save articles other than the first one.
12000 (saver2 (get gnus-default-article-saver :function))
12001 (gnus-prompt-before-saving (if saver2
12003 gnus-prompt-before-saving))
12004 (gnus-default-article-saver gnus-default-article-saver)
12005 header file)
12006 (dolist (article articles)
12007 (setq header (gnus-summary-article-header article))
12008 (if (not (vectorp header))
12009 ;; This is a pseudo-article.
12010 (if (assq 'name header)
12011 (gnus-copy-file (cdr (assq 'name header)))
12012 (gnus-message 1 "Article %d is unsavable" article))
12013 ;; This is a real article.
12014 (save-window-excursion
12015 (gnus-summary-select-article decode decode nil article)
12016 (gnus-summary-goto-subject article))
12017 (with-current-buffer save-buffer
12018 (erase-buffer)
12019 (insert-buffer-substring (if decode
12020 gnus-article-buffer
12021 gnus-original-article-buffer)))
12022 (setq file (gnus-article-save save-buffer file num))
12023 (gnus-summary-remove-process-mark article)
12024 (unless not-saved
12025 (gnus-summary-set-saved-mark article)))
12026 (when saver2
12027 (setq gnus-default-article-saver saver2
12028 saver2 nil)))
12029 (gnus-kill-buffer save-buffer)
12030 (gnus-summary-position-point)
12031 (gnus-set-mode-line 'summary)
12034 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12036 (defun gnus-summary-pipe-output (&optional n sym)
12037 "Pipe the current article to a subprocess.
12038 If N is a positive number, pipe the N next articles.
12039 If N is a negative number, pipe the N previous articles.
12040 If N is nil and any articles have been marked with the process mark,
12041 pipe those articles instead.
12042 The default command to which articles are piped is specified by the
12043 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12044 will be prompted for the command.
12046 The properties `:decode' and `:headers' that are put to the function
12047 symbol `gnus-summary-save-in-pipe' control whether this function
12048 decodes articles and what headers to keep (see the doc string for the
12049 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12050 is neither omitted nor the symbol `r', force including all headers
12051 regardless of the `:headers' property. If it is the symbol `r',
12052 articles that are not decoded and include all headers will be piped
12053 no matter what the properties `:decode' and `:headers' are."
12054 (interactive (gnus-interactive "P\ny"))
12055 (require 'gnus-art)
12056 (let* ((articles (gnus-summary-work-articles n))
12057 (result-buffer "*Shell Command Output*")
12058 (all-headers (not (memq sym '(nil r))))
12059 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12060 (raw (eq sym 'r))
12061 (headers (get 'gnus-summary-save-in-pipe :headers))
12062 command result)
12063 (unless (numberp (car articles))
12064 (error "No article to pipe"))
12065 (setq command (gnus-read-shell-command
12066 (concat "Shell command on "
12067 (if (cdr articles)
12068 (format "these %d articles" (length articles))
12069 "this article")
12070 ": ")
12071 gnus-summary-pipe-output-default-command))
12072 (when (string-equal command "")
12073 (error "A command is required"))
12074 (when all-headers
12075 (put 'gnus-summary-save-in-pipe :headers nil))
12076 (unwind-protect
12077 (while articles
12078 (gnus-summary-goto-subject (pop articles))
12079 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12080 (when (and (get-buffer result-buffer)
12081 (not (zerop (buffer-size (get-buffer result-buffer)))))
12082 (setq result (concat result (with-current-buffer result-buffer
12083 (buffer-string))))))
12084 (put 'gnus-summary-save-in-pipe :headers headers))
12085 (unless (zerop (length result))
12086 (if (with-current-buffer (get-buffer-create result-buffer)
12087 (erase-buffer)
12088 (insert result)
12089 (prog1
12090 (and (= (count-lines (point-min) (point)) 1)
12091 (progn
12092 (end-of-line 0)
12093 (<= (current-column)
12094 (window-width (minibuffer-window)))))
12095 (goto-char (point-min))))
12096 (message "%s" (substring result 0 -1))
12097 (message nil)
12098 (gnus-configure-windows 'pipe)))))
12100 (defun gnus-summary-save-article-mail (&optional arg)
12101 "Append the current article to a Unix mail box file.
12102 If N is a positive number, save the N next articles.
12103 If N is a negative number, save the N previous articles.
12104 If N is nil and any articles have been marked with the process mark,
12105 save those articles instead."
12106 (interactive "P")
12107 (require 'gnus-art)
12108 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12109 (gnus-summary-save-article arg)))
12111 (defun gnus-summary-save-article-rmail (&optional arg)
12112 "Append the current article to an rmail file.
12113 If N is a positive number, save the N next articles.
12114 If N is a negative number, save the N previous articles.
12115 If N is nil and any articles have been marked with the process mark,
12116 save those articles instead."
12117 (interactive "P")
12118 (require 'gnus-art)
12119 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12120 (gnus-summary-save-article arg)))
12122 (defun gnus-summary-save-article-file (&optional arg)
12123 "Append the current article to a file.
12124 If N is a positive number, save the N next articles.
12125 If N is a negative number, save the N previous articles.
12126 If N is nil and any articles have been marked with the process mark,
12127 save those articles instead."
12128 (interactive "P")
12129 (require 'gnus-art)
12130 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12131 (gnus-summary-save-article arg)))
12133 (defun gnus-summary-write-article-file (&optional arg)
12134 "Write the current article to a file, deleting the previous file.
12135 If N is a positive number, save the N next articles.
12136 If N is a negative number, save the N previous articles.
12137 If N is nil and any articles have been marked with the process mark,
12138 save those articles instead."
12139 (interactive "P")
12140 (require 'gnus-art)
12141 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12142 (gnus-summary-save-article arg)))
12144 (defun gnus-summary-save-article-body-file (&optional arg)
12145 "Append the current article body to a file.
12146 If N is a positive number, save the N next articles.
12147 If N is a negative number, save the N previous articles.
12148 If N is nil and any articles have been marked with the process mark,
12149 save those articles instead."
12150 (interactive "P")
12151 (require 'gnus-art)
12152 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12153 (gnus-summary-save-article arg)))
12155 (defun gnus-summary-write-article-body-file (&optional arg)
12156 "Write the current article body to a file, deleting the previous file.
12157 If N is a positive number, save the N next articles.
12158 If N is a negative number, save the N previous articles.
12159 If N is nil and any articles have been marked with the process mark,
12160 save those articles instead."
12161 (interactive "P")
12162 (require 'gnus-art)
12163 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12164 (gnus-summary-save-article arg)))
12166 (defun gnus-summary-muttprint (&optional arg)
12167 "Print the current article using Muttprint.
12168 If N is a positive number, save the N next articles.
12169 If N is a negative number, save the N previous articles.
12170 If N is nil and any articles have been marked with the process mark,
12171 save those articles instead."
12172 (interactive "P")
12173 (require 'gnus-art)
12174 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12175 (gnus-summary-save-article arg t)))
12177 (defun gnus-summary-pipe-message (program)
12178 "Pipe the current article through PROGRAM."
12179 (interactive "sProgram: ")
12180 (gnus-summary-select-article)
12181 (let ((mail-header-separator ""))
12182 (gnus-eval-in-buffer-window gnus-article-buffer
12183 (save-restriction
12184 (widen)
12185 (let ((start (window-start))
12186 (inhibit-read-only t))
12187 (message-pipe-buffer-body program)
12188 (set-window-start (get-buffer-window (current-buffer)) start))))))
12190 (defun gnus-get-split-value (methods)
12191 "Return a value based on the split METHODS."
12192 (let (split-name method result match)
12193 (when methods
12194 (with-current-buffer gnus-original-article-buffer
12195 (save-restriction
12196 (nnheader-narrow-to-headers)
12197 (while (and methods (not split-name))
12198 (goto-char (point-min))
12199 (setq method (pop methods))
12200 (setq match (car method))
12201 (when (cond
12202 ((stringp match)
12203 ;; Regular expression.
12204 (ignore-errors
12205 (re-search-forward match nil t)))
12206 ((functionp match)
12207 ;; Function.
12208 (save-restriction
12209 (widen)
12210 (setq result (funcall match gnus-newsgroup-name))))
12211 ((consp match)
12212 ;; Form.
12213 (save-restriction
12214 (widen)
12215 (setq result (eval match)))))
12216 (setq split-name (cdr method))
12217 (cond ((stringp result)
12218 (push (expand-file-name
12219 result gnus-article-save-directory)
12220 split-name))
12221 ((consp result)
12222 (setq split-name (append result split-name)))))))))
12223 (nreverse split-name)))
12225 (defun gnus-valid-move-group-p (group)
12226 (and (symbolp group)
12227 (boundp group)
12228 (symbol-name group)
12229 (symbol-value group)
12230 (gnus-get-function (gnus-find-method-for-group
12231 (symbol-name group)) 'request-accept-article t)))
12233 (defun gnus-read-move-group-name (prompt default articles prefix)
12234 "Read a group name."
12235 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12236 (minibuffer-confirm-incomplete nil) ; XEmacs
12237 (prom
12238 (format "%s %s to"
12239 prompt
12240 (if (> (length articles) 1)
12241 (format "these %d articles" (length articles))
12242 "this article")))
12243 (to-newsgroup
12244 (cond
12245 ((null split-name)
12246 (gnus-group-completing-read
12247 prom
12248 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12249 nil prefix nil default))
12250 ((= 1 (length split-name))
12251 (gnus-group-completing-read
12252 prom
12253 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12254 nil prefix 'gnus-group-history (car split-name)))
12256 (gnus-completing-read
12257 prom (nreverse split-name) nil nil 'gnus-group-history))))
12258 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12259 encoded)
12260 (when to-newsgroup
12261 (if (or (string= to-newsgroup "")
12262 (string= to-newsgroup prefix))
12263 (setq to-newsgroup default))
12264 (unless to-newsgroup
12265 (error "No group name entered"))
12266 (setq encoded (mm-encode-coding-string
12267 to-newsgroup
12268 (gnus-group-name-charset to-method to-newsgroup)))
12269 (or (gnus-active encoded)
12270 (gnus-activate-group encoded nil nil to-method)
12271 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12272 to-newsgroup))
12273 (or (and (gnus-request-create-group encoded to-method)
12274 (gnus-activate-group encoded nil nil to-method)
12275 (gnus-subscribe-group encoded))
12276 (error "Couldn't create group %s" to-newsgroup)))
12277 (error "No such group: %s" to-newsgroup))
12278 encoded)))
12280 (defvar gnus-summary-save-parts-counter)
12281 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12283 (defun gnus-summary-save-parts (type dir n &optional reverse)
12284 "Save parts matching TYPE to DIR.
12285 If REVERSE, save parts that do not match TYPE."
12286 (interactive
12287 (list (read-string "Save parts of type: "
12288 (or (car gnus-summary-save-parts-type-history)
12289 gnus-summary-save-parts-default-mime)
12290 'gnus-summary-save-parts-type-history)
12291 (setq gnus-summary-save-parts-last-directory
12292 (read-directory-name "Save to directory: "
12293 gnus-summary-save-parts-last-directory
12294 nil t))
12295 current-prefix-arg))
12296 (gnus-summary-iterate n
12297 (let ((gnus-display-mime-function nil)
12298 gnus-article-prepare-hook
12299 gnus-article-decode-hook
12300 gnus-display-mime-function
12301 gnus-break-pages
12302 (gnus-inhibit-treatment t))
12303 (gnus-summary-select-article))
12304 (with-current-buffer gnus-article-buffer
12305 (let ((handles (or gnus-article-mime-handles
12306 (mm-dissect-buffer nil gnus-article-loose-mime)
12307 (and gnus-article-emulate-mime
12308 (mm-uu-dissect))))
12309 (gnus-summary-save-parts-counter 1))
12310 (when handles
12311 (gnus-summary-save-parts-1 type dir handles reverse)
12312 (unless gnus-article-mime-handles ;; Don't destroy this case.
12313 (mm-destroy-parts handles)))))))
12315 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12316 (if (stringp (car handle))
12317 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12318 (cdr handle))
12319 (when (if reverse
12320 (not (string-match type (mm-handle-media-type handle)))
12321 (string-match type (mm-handle-media-type handle)))
12322 (let ((file (expand-file-name
12323 (gnus-map-function
12324 mm-file-name-rewrite-functions
12325 (file-name-nondirectory
12327 (mm-handle-filename handle)
12328 (format "%s.%d.%d" gnus-newsgroup-name
12329 (cdr gnus-article-current)
12330 gnus-summary-save-parts-counter))))
12331 dir)))
12332 (incf gnus-summary-save-parts-counter)
12333 (unless (file-exists-p file)
12334 (mm-save-part-to-file handle file))))))
12336 ;; Summary extract commands
12338 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12339 (let ((inhibit-read-only t)
12340 (article (gnus-summary-article-number))
12341 after-article b e)
12342 (unless (gnus-summary-goto-subject article)
12343 (error "No such article: %d" article))
12344 (gnus-summary-position-point)
12345 ;; If all commands are to be bunched up on one line, we collect
12346 ;; them here.
12347 (unless gnus-view-pseudos-separately
12348 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12349 files action)
12350 (while ps
12351 (setq action (cdr (assq 'action (car ps))))
12352 (setq files (list (cdr (assq 'name (car ps)))))
12353 (while (and ps (cdr ps)
12354 (string= (or action "1")
12355 (or (cdr (assq 'action (cadr ps))) "2")))
12356 (push (cdr (assq 'name (cadr ps))) files)
12357 (setcdr ps (cddr ps)))
12358 (when files
12359 (when (not (string-match "%s" action))
12360 (push " " files))
12361 (push " " files)
12362 (when (assq 'execute (car ps))
12363 (setcdr (assq 'execute (car ps))
12364 (funcall (if (string-match "%s" action)
12365 'format 'concat)
12366 action
12367 (mapconcat
12368 (lambda (f)
12369 (if (equal f " ")
12371 (shell-quote-argument f)))
12372 files " ")))))
12373 (setq ps (cdr ps)))))
12374 (if (and gnus-view-pseudos (not not-view))
12375 (while pslist
12376 (when (assq 'execute (car pslist))
12377 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12378 (eq gnus-view-pseudos 'not-confirm)))
12379 (setq pslist (cdr pslist)))
12380 (save-excursion
12381 (while pslist
12382 (setq after-article (or (cdr (assq 'article (car pslist)))
12383 (gnus-summary-article-number)))
12384 (gnus-summary-goto-subject after-article)
12385 (forward-line 1)
12386 (setq b (point))
12387 (insert " " (file-name-nondirectory
12388 (cdr (assq 'name (car pslist))))
12389 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12390 (setq e (point))
12391 (forward-line -1) ; back to `b'
12392 (gnus-add-text-properties
12393 b (1- e) (list 'gnus-number gnus-reffed-article-number
12394 gnus-mouse-face-prop gnus-mouse-face))
12395 (gnus-data-enter
12396 after-article gnus-reffed-article-number
12397 gnus-unread-mark b (car pslist) 0 (- e b))
12398 (setq gnus-newsgroup-unreads
12399 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12400 gnus-reffed-article-number))
12401 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12402 (setq pslist (cdr pslist)))))))
12404 (defun gnus-pseudos< (p1 p2)
12405 (let ((c1 (cdr (assq 'action p1)))
12406 (c2 (cdr (assq 'action p2))))
12407 (and c1 c2 (string< c1 c2))))
12409 (defun gnus-request-pseudo-article (props)
12410 (cond ((assq 'execute props)
12411 (gnus-execute-command (cdr (assq 'execute props)))))
12412 (let ((gnus-current-article (gnus-summary-article-number)))
12413 (gnus-run-hooks 'gnus-mark-article-hook)))
12415 (defun gnus-execute-command (command &optional automatic)
12416 (save-excursion
12417 (gnus-article-setup-buffer)
12418 (set-buffer gnus-article-buffer)
12419 (setq buffer-read-only nil)
12420 (let ((command (if automatic command
12421 (read-string "Command: " (cons command 0)))))
12422 (erase-buffer)
12423 (insert "$ " command "\n\n")
12424 (if gnus-view-pseudo-asynchronously
12425 (start-process "gnus-execute" (current-buffer) shell-file-name
12426 shell-command-switch command)
12427 (call-process shell-file-name nil t nil
12428 shell-command-switch command)))))
12430 ;; Summary kill commands.
12432 (defun gnus-summary-edit-global-kill (article)
12433 "Edit the \"global\" kill file."
12434 (interactive (list (gnus-summary-article-number)))
12435 (gnus-group-edit-global-kill article))
12437 (defun gnus-summary-edit-local-kill ()
12438 "Edit a local kill file applied to the current newsgroup."
12439 (interactive)
12440 (setq gnus-current-headers (gnus-summary-article-header))
12441 (gnus-group-edit-local-kill
12442 (gnus-summary-article-number) gnus-newsgroup-name))
12444 ;;; Header reading.
12446 (defun gnus-read-header (id &optional header)
12447 "Read the headers of article ID and enter them into the Gnus system."
12448 (let ((group gnus-newsgroup-name)
12449 (gnus-override-method
12451 gnus-override-method
12452 (and (gnus-news-group-p gnus-newsgroup-name)
12453 (car (gnus-refer-article-methods)))))
12454 where)
12455 ;; First we check to see whether the header in question is already
12456 ;; fetched.
12457 (if (stringp id)
12458 ;; This is a Message-ID.
12459 (setq header (or header (gnus-id-to-header id)))
12460 ;; This is an article number.
12461 (setq header (or header (gnus-summary-article-header id))))
12462 (if (and header
12463 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12464 ;; We have found the header.
12465 header
12466 ;; We have to really fetch the header to this article.
12467 (with-current-buffer nntp-server-buffer
12468 (when (setq where (gnus-request-head id group))
12469 (nnheader-fold-continuation-lines)
12470 (goto-char (point-max))
12471 (insert ".\n")
12472 (goto-char (point-min))
12473 (insert "211 ")
12474 (princ (cond
12475 ((numberp id) id)
12476 ((cdr where) (cdr where))
12477 (header (mail-header-number header))
12478 (t gnus-reffed-article-number))
12479 (current-buffer))
12480 (insert " Article retrieved.\n"))
12481 (if (or (not where)
12482 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12483 () ; Malformed head.
12484 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12485 (when (and (bound-and-true-p gnus-registry-enabled)
12486 (not (gnus-ephemeral-group-p (car where))))
12487 (gnus-registry-handle-action
12488 (mail-header-id header) nil
12489 (gnus-group-prefixed-name
12490 (car where)
12491 (or gnus-override-method (gnus-find-method-for-group group)))
12492 (mail-header-subject header)
12493 (mail-header-from header)))
12494 (when (and (stringp id)
12496 (not (string= (gnus-group-real-name group)
12497 (car where)))
12498 (not (gnus-server-equal gnus-override-method
12499 (gnus-group-method group)))))
12500 ;; If we fetched by Message-ID and the article came from
12501 ;; a different group (or server), we fudge some bogus
12502 ;; article numbers for this article.
12503 (mail-header-set-number header gnus-reffed-article-number))
12504 (with-current-buffer gnus-summary-buffer
12505 (decf gnus-reffed-article-number)
12506 (gnus-remove-header (mail-header-number header))
12507 (push header gnus-newsgroup-headers)
12508 (setq gnus-current-headers header)
12509 (push (mail-header-number header) gnus-newsgroup-limit)))
12510 header)))))
12512 (defun gnus-remove-header (number)
12513 "Remove header NUMBER from `gnus-newsgroup-headers'."
12514 (if (and gnus-newsgroup-headers
12515 (= number (mail-header-number (car gnus-newsgroup-headers))))
12516 (pop gnus-newsgroup-headers)
12517 (let ((headers gnus-newsgroup-headers))
12518 (while (and (cdr headers)
12519 (not (= number (mail-header-number (cadr headers)))))
12520 (pop headers))
12521 (when (cdr headers)
12522 (setcdr headers (cddr headers))))))
12525 ;;; summary highlights
12528 (defun gnus-highlight-selected-summary ()
12529 "Highlight selected article in summary buffer."
12530 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12531 (when gnus-summary-selected-face
12532 (save-excursion
12533 (let* ((beg (point-at-bol))
12534 (end (point-at-eol))
12535 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12536 (from (if (get-text-property beg gnus-mouse-face-prop)
12538 (or (next-single-property-change
12539 beg gnus-mouse-face-prop nil end)
12540 beg)))
12542 (if (= from end)
12543 (- from 2)
12544 (or (next-single-property-change
12545 from gnus-mouse-face-prop nil end)
12546 end))))
12547 ;; If no mouse-face prop on line we will have to = from = end,
12548 ;; so we highlight the entire line instead.
12549 (when (= (+ to 2) from)
12550 (setq from beg)
12551 (setq to end))
12552 (if gnus-newsgroup-selected-overlay
12553 ;; Move old overlay.
12554 (gnus-move-overlay
12555 gnus-newsgroup-selected-overlay from to (current-buffer))
12556 ;; Create new overlay.
12557 (gnus-overlay-put
12558 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12559 'face gnus-summary-selected-face))))))
12561 (defvar gnus-summary-highlight-line-cached nil)
12562 (defvar gnus-summary-highlight-line-trigger nil)
12564 (defun gnus-summary-highlight-line-0 ()
12565 (if (and (eq gnus-summary-highlight-line-trigger
12566 gnus-summary-highlight)
12567 gnus-summary-highlight-line-cached)
12568 gnus-summary-highlight-line-cached
12569 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12570 gnus-summary-highlight-line-cached
12571 (let* ((cond (list 'cond))
12572 (c cond)
12573 (list gnus-summary-highlight))
12574 (while list
12575 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12576 nil))
12577 (setq c (cdr c)
12578 list (cdr list)))
12579 (gnus-byte-compile (list 'lambda nil cond))))))
12581 (defun gnus-summary-highlight-line ()
12582 "Highlight current line according to `gnus-summary-highlight'."
12583 (let* ((beg (point-at-bol))
12584 (article (or (gnus-summary-article-number) gnus-current-article))
12585 (score (or (cdr (assq article
12586 gnus-newsgroup-scored))
12587 gnus-summary-default-score 0))
12588 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12589 (inhibit-read-only t)
12590 (default gnus-summary-default-score)
12591 (default-high gnus-summary-default-high-score)
12592 (default-low gnus-summary-default-low-score)
12593 (uncached (and gnus-summary-use-undownloaded-faces
12594 (memq article gnus-newsgroup-undownloaded)
12595 (not (memq article gnus-newsgroup-cached)))))
12596 (let ((face (funcall (gnus-summary-highlight-line-0))))
12597 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12598 (gnus-put-text-property-excluding-characters-with-faces
12599 beg (point-at-eol) 'face
12600 (setq face (if (boundp face) (symbol-value face) face)))
12601 (when gnus-summary-highlight-line-function
12602 (funcall gnus-summary-highlight-line-function article face))))))
12604 (defun gnus-update-read-articles (group unread &optional compute)
12605 "Update the list of read articles in GROUP.
12606 UNREAD is a sorted list."
12607 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12608 (info (gnus-get-info group))
12609 (prev 1)
12610 read)
12611 (if (or (not info) (not active))
12612 ;; There is no info on this group if it was, in fact,
12613 ;; killed. Gnus stores no information on killed groups, so
12614 ;; there's nothing to be done.
12615 ;; One could store the information somewhere temporarily,
12616 ;; perhaps... Hmmm...
12618 ;; Remove any negative articles numbers.
12619 (while (and unread (< (car unread) 0))
12620 (setq unread (cdr unread)))
12621 ;; Remove any expired article numbers
12622 (while (and unread (< (car unread) (car active)))
12623 (setq unread (cdr unread)))
12624 ;; Compute the ranges of read articles by looking at the list of
12625 ;; unread articles.
12626 (while unread
12627 (when (/= (car unread) prev)
12628 (push (if (= prev (1- (car unread))) prev
12629 (cons prev (1- (car unread))))
12630 read))
12631 (setq prev (1+ (car unread)))
12632 (setq unread (cdr unread)))
12633 (when (<= prev (cdr active))
12634 (push (cons prev (cdr active)) read))
12635 (setq read (if (> (length read) 1) (nreverse read) read))
12636 (if compute
12637 read
12638 (save-excursion
12639 (let (setmarkundo)
12640 ;; Propagate the read marks to the backend.
12641 (when (and (gnus-method-option-p
12642 (gnus-find-method-for-group group)
12643 'server-marks)
12644 (gnus-check-backend-function 'request-set-mark group))
12645 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12646 (add (gnus-remove-from-range read (gnus-info-read info))))
12647 (when (or add del)
12648 (unless (gnus-check-group group)
12649 (error "Can't open server for %s" group))
12650 (gnus-request-set-mark
12651 group (delq nil (list (if add (list add 'add '(read)))
12652 (if del (list del 'del '(read))))))
12653 (setq setmarkundo
12654 `(gnus-request-set-mark
12655 ,group
12656 ',(delq nil (list
12657 (if del (list del 'add '(read)))
12658 (if add (list add 'del '(read))))))))))
12659 (set-buffer gnus-group-buffer)
12660 (gnus-undo-register
12661 `(progn
12662 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12663 (gnus-info-set-read ',info ',(gnus-info-read info))
12664 (gnus-get-unread-articles-in-group ',info
12665 (gnus-active ,group))
12666 (gnus-group-update-group ,group t)
12667 ,setmarkundo))))
12668 ;; Enter this list into the group info.
12669 (gnus-info-set-read info read)
12670 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12671 (gnus-get-unread-articles-in-group info (gnus-active group))
12672 t))))
12674 (defun gnus-offer-save-summaries ()
12675 "Offer to save all active summary buffers."
12676 (let (buffers)
12677 ;; Go through all buffers and find all summaries.
12678 (dolist (buffer (buffer-list))
12679 (when (and (setq buffer (buffer-name buffer))
12680 (string-match "Summary" buffer)
12681 (with-current-buffer buffer
12682 ;; We check that this is, indeed, a summary buffer.
12683 (and (eq major-mode 'gnus-summary-mode)
12684 ;; Also make sure this isn't bogus.
12685 gnus-newsgroup-prepared
12686 ;; Also make sure that this isn't a
12687 ;; dead summary buffer.
12688 (not gnus-dead-summary-mode))))
12689 (push buffer buffers)))
12690 ;; Go through all these summary buffers and offer to save them.
12691 (when buffers
12692 (save-excursion
12693 (if (eq gnus-interactive-exit 'quiet)
12694 (dolist (buffer buffers)
12695 (switch-to-buffer buffer)
12696 (gnus-summary-exit))
12697 (map-y-or-n-p
12698 "Update summary buffer %s? "
12699 (lambda (buf)
12700 (switch-to-buffer buf)
12701 (gnus-summary-exit))
12702 buffers))))))
12704 (defun gnus-summary-setup-default-charset ()
12705 "Setup newsgroup default charset."
12706 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12707 (setq gnus-newsgroup-charset nil)
12708 (let* ((ignored-charsets
12709 (or gnus-newsgroup-ephemeral-ignored-charsets
12710 (append
12711 (and gnus-newsgroup-name
12712 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12713 gnus-newsgroup-ignored-charsets))))
12714 (setq gnus-newsgroup-charset
12715 (or gnus-newsgroup-ephemeral-charset
12716 (and gnus-newsgroup-name
12717 (gnus-parameter-charset gnus-newsgroup-name))
12718 gnus-default-charset))
12719 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12720 ignored-charsets))))
12723 ;;; Mime Commands
12726 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12727 "Display the current article buffer fully MIME-buttonized.
12728 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12729 treated as multipart/mixed."
12730 (interactive "P")
12731 (require 'gnus-art)
12732 (let ((gnus-unbuttonized-mime-types nil)
12733 (gnus-mime-display-multipart-as-mixed show-all-parts))
12734 (gnus-summary-show-article)))
12736 (defun gnus-summary-repair-multipart (article)
12737 "Add a Content-Type header to a multipart article without one."
12738 (interactive (list (gnus-summary-article-number)))
12739 (gnus-with-article article
12740 (message-narrow-to-head)
12741 (message-remove-header "Mime-Version")
12742 (goto-char (point-max))
12743 (insert "Mime-Version: 1.0\n")
12744 (widen)
12745 (when (search-forward "\n--" nil t)
12746 (let ((separator (buffer-substring (point) (point-at-eol))))
12747 (message-narrow-to-head)
12748 (message-remove-header "Content-Type")
12749 (goto-char (point-max))
12750 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12751 separator))
12752 (widen))))
12753 (let (gnus-mark-article-hook)
12754 (gnus-summary-select-article t t nil article)))
12756 (defun gnus-summary-toggle-display-buttonized ()
12757 "Toggle the buttonizing of the article buffer."
12758 (interactive)
12759 (require 'gnus-art)
12760 (if (setq gnus-inhibit-mime-unbuttonizing
12761 (not gnus-inhibit-mime-unbuttonizing))
12762 (let ((gnus-unbuttonized-mime-types nil))
12763 (gnus-summary-show-article))
12764 (gnus-summary-show-article)))
12767 ;;; Generic summary marking commands
12770 (defvar gnus-summary-marking-alist
12771 '((read gnus-del-mark "d")
12772 (unread gnus-unread-mark "u")
12773 (ticked gnus-ticked-mark "!")
12774 (dormant gnus-dormant-mark "?")
12775 (expirable gnus-expirable-mark "e"))
12776 "An alist of names/marks/keystrokes.")
12778 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12779 (defvar gnus-summary-mark-map)
12781 (defun gnus-summary-make-all-marking-commands ()
12782 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12783 (dolist (elem gnus-summary-marking-alist)
12784 (apply 'gnus-summary-make-marking-command elem)))
12786 (defun gnus-summary-make-marking-command (name mark keystroke)
12787 (let ((map (make-sparse-keymap)))
12788 (define-key gnus-summary-generic-mark-map keystroke map)
12789 (dolist (lway `((next "next" next nil "n")
12790 (next-unread "next unread" next t "N")
12791 (prev "previous" prev nil "p")
12792 (prev-unread "previous unread" prev t "P")
12793 (nomove "" nil nil ,keystroke)))
12794 (let ((func (gnus-summary-make-marking-command-1
12795 mark (car lway) lway name)))
12796 (setq func (eval func))
12797 (define-key map (nth 4 lway) func)))))
12799 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12800 `(defun ,(intern
12801 (format "gnus-summary-put-mark-as-%s%s"
12802 name (if (eq way 'nomove)
12804 (concat "-" (symbol-name way)))))
12806 ,(format
12807 "Mark the current article as %s%s.
12808 If N, the prefix, then repeat N times.
12809 If N is negative, move in reverse order.
12810 The difference between N and the actual number of articles marked is
12811 returned."
12812 name (cadr lway))
12813 (interactive "p")
12814 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12816 (defun gnus-summary-generic-mark (n mark move unread)
12817 "Mark N articles with MARK."
12818 (unless (eq major-mode 'gnus-summary-mode)
12819 (error "This command can only be used in the summary buffer"))
12820 (gnus-summary-show-thread)
12821 (let ((nummove
12822 (cond
12823 ((eq move 'next) 1)
12824 ((eq move 'prev) -1)
12825 (t 0))))
12826 (if (zerop nummove)
12827 (setq n 1)
12828 (when (< n 0)
12829 (setq n (abs n)
12830 nummove (* -1 nummove))))
12831 (while (and (> n 0)
12832 (gnus-summary-mark-article nil mark)
12833 (zerop (gnus-summary-next-subject nummove unread t)))
12834 (setq n (1- n)))
12835 (when (/= 0 n)
12836 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12837 (gnus-summary-recenter)
12838 (gnus-summary-position-point)
12839 (gnus-set-mode-line 'summary)
12842 (defun gnus-summary-insert-articles (articles)
12843 (when (setq articles
12844 (gnus-sorted-difference articles
12845 (mapcar (lambda (h)
12846 (mail-header-number h))
12847 gnus-newsgroup-headers)))
12848 (setq gnus-newsgroup-headers
12849 (gnus-merge 'list
12850 gnus-newsgroup-headers
12851 (gnus-fetch-headers articles nil t)
12852 'gnus-article-sort-by-number))
12853 (setq gnus-newsgroup-articles
12854 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12855 ;; Suppress duplicates?
12856 (when gnus-suppress-duplicates
12857 (gnus-dup-suppress-articles))
12859 (if (and gnus-fetch-old-headers
12860 (eq gnus-headers-retrieved-by 'nov))
12861 ;; We might want to build some more threads first.
12862 (if (eq gnus-fetch-old-headers 'invisible)
12863 (gnus-build-all-threads)
12864 (gnus-build-old-threads))
12865 ;; Mark the inserted articles that are unread as unread.
12866 (setq gnus-newsgroup-unreads
12867 (gnus-sorted-nunion
12868 gnus-newsgroup-unreads
12869 (gnus-sorted-nintersection
12870 (gnus-list-of-unread-articles gnus-newsgroup-name)
12871 articles)))
12872 ;; Mark the inserted articles as selected so that the information
12873 ;; of the marks having been changed by a user may be updated when
12874 ;; exiting this group. See `gnus-summary-update-info'.
12875 (dolist (art articles)
12876 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12877 ;; Let the Gnus agent mark articles as read.
12878 (when gnus-agent
12879 (gnus-agent-get-undownloaded-list))
12880 ;; Remove list identifiers from subject
12881 (gnus-summary-remove-list-identifiers)
12882 ;; First and last article in this newsgroup.
12883 (when gnus-newsgroup-headers
12884 (setq gnus-newsgroup-begin
12885 (mail-header-number (car gnus-newsgroup-headers))
12886 gnus-newsgroup-end
12887 (mail-header-number
12888 (gnus-last-element gnus-newsgroup-headers))))
12889 (when gnus-use-scoring
12890 (gnus-possibly-score-headers))))
12892 (defun gnus-summary-insert-old-articles (&optional all)
12893 "Insert all old articles in this group.
12894 If ALL is non-nil, already read articles become readable.
12895 If ALL is a number, fetch this number of articles."
12896 (interactive "P")
12897 (prog1
12898 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12899 older len)
12900 (setq older
12901 ;; Some nntp servers lie about their active range. When
12902 ;; this happens, the active range can be in the millions.
12903 ;; Use a compressed range to avoid creating a huge list.
12904 (gnus-range-difference
12905 (gnus-range-difference (list gnus-newsgroup-active) old)
12906 gnus-newsgroup-unexist))
12907 (setq len (gnus-range-length older))
12908 (cond
12909 ((null older) nil)
12910 ((numberp all)
12911 (if (< all len)
12912 (let ((older-range (nreverse older)))
12913 (setq older nil)
12915 (while (> all 0)
12916 (let* ((r (pop older-range))
12917 (min (if (numberp r) r (car r)))
12918 (max (if (numberp r) r (cdr r))))
12919 (while (and (<= min max)
12920 (> all 0))
12921 (push max older)
12922 (setq all (1- all)
12923 max (1- max))))))
12924 (setq older (gnus-uncompress-range older))))
12925 (all
12926 (setq older (gnus-uncompress-range older)))
12928 (when (and (numberp gnus-large-newsgroup)
12929 (> len gnus-large-newsgroup))
12930 (let* ((cursor-in-echo-area nil)
12931 (initial (gnus-parameter-large-newsgroup-initial
12932 gnus-newsgroup-name))
12933 (input
12934 (read-string
12935 (format
12936 "How many articles from %s (%s %d): "
12937 (gnus-group-decoded-name gnus-newsgroup-name)
12938 (if initial "max" "default")
12939 len)
12940 nil nil
12941 (and initial
12942 (number-to-string initial)))))
12943 (unless (string-match "^[ \t]*$" input)
12944 (setq all (string-to-number input))
12945 (if (< all len)
12946 (let ((older-range (nreverse older)))
12947 (setq older nil)
12949 (while (> all 0)
12950 (let* ((r (pop older-range))
12951 (min (if (numberp r) r (car r)))
12952 (max (if (numberp r) r (cdr r))))
12953 (while (and (<= min max)
12954 (> all 0))
12955 (push max older)
12956 (setq all (1- all)
12957 max (1- max))))))))))
12958 (setq older (gnus-uncompress-range older))))
12959 (if (not older)
12960 (message "No old news.")
12961 (gnus-summary-insert-articles older)
12962 (gnus-summary-limit (gnus-sorted-nunion old older))))
12963 (gnus-summary-position-point)))
12965 (defun gnus-summary-insert-new-articles ()
12966 "Insert all new articles in this group."
12967 (interactive)
12968 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12969 (old-high gnus-newsgroup-highest)
12970 (nnmail-fetched-sources (list t))
12971 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12972 i new)
12973 (unless new-active
12974 (error "Couldn't fetch new data"))
12975 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12976 (setq i (cdr gnus-newsgroup-active)
12977 gnus-newsgroup-highest i)
12978 (while (> i old-high)
12979 (push i new)
12980 (decf i))
12981 (if (not new)
12982 (message "No gnus is bad news")
12983 (gnus-summary-insert-articles new)
12984 (setq gnus-newsgroup-unreads
12985 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12986 (gnus-summary-limit (gnus-sorted-nunion old new))))
12987 (gnus-summary-position-point))
12989 ;;; Bookmark support for Gnus.
12990 (declare-function gnus-article-show-summary "gnus-art" ())
12991 (declare-function bookmark-make-record-default
12992 "bookmark" (&optional no-file no-context posn))
12993 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12994 (declare-function bookmark-default-handler "bookmark" (bmk))
12995 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12996 (defvar bookmark-yank-point)
12997 (defvar bookmark-current-buffer)
12999 (defun gnus-summary-bookmark-make-record ()
13000 "Make a bookmark entry for a Gnus summary buffer."
13001 (let (pos buf)
13002 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13003 (save-restriction ; FIXME is it necessary to widen?
13004 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13005 (setq buf "art") ; We are recording bookmark from article buffer.
13006 (setq bookmark-yank-point (point))
13007 (setq bookmark-current-buffer (current-buffer))
13008 (gnus-article-show-summary)) ; Go back in summary buffer.
13009 ;; We are now recording bookmark from summary buffer.
13010 (unless buf (setq buf "sum"))
13011 (let* ((subject (elt (gnus-summary-article-header) 1))
13012 (grp (car gnus-article-current))
13013 (art (cdr gnus-article-current))
13014 (head (gnus-summary-article-header art))
13015 (id (mail-header-id head)))
13016 `(,subject
13017 ,@(condition-case nil
13018 (bookmark-make-record-default 'no-file 'no-context pos)
13019 (wrong-number-of-arguments
13020 (bookmark-make-record-default 'point-only)))
13021 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13022 (group . ,grp) (article . ,art)
13023 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13025 ;;;###autoload
13026 (defun gnus-summary-bookmark-jump (bookmark)
13027 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13028 BOOKMARK is a bookmark name or a bookmark record."
13029 (let ((group (bookmark-prop-get bookmark 'group))
13030 (article (bookmark-prop-get bookmark 'article))
13031 (id (bookmark-prop-get bookmark 'message-id))
13032 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13033 (gnus-fetch-group group (list article))
13034 (gnus-summary-insert-cached-articles)
13035 (gnus-summary-goto-article id nil 'force)
13036 ;; FIXME we have to wait article buffer is ready (only large buffer)
13037 ;; Is there a better solution to know that?
13038 ;; If we don't wait `bookmark-default-handler' will have no chance
13039 ;; to set position. However there is no error, just wrong pos.
13040 (sit-for 1)
13041 (when (string= buf "Gnus-art")
13042 (other-window 1))
13043 (bookmark-default-handler
13044 `(""
13045 (buffer . ,(current-buffer))
13046 . ,(bookmark-get-bookmark-record bookmark)))))
13048 (gnus-summary-make-all-marking-commands)
13050 (gnus-ems-redefine)
13052 (provide 'gnus-sum)
13054 (run-hooks 'gnus-sum-load-hook)
13056 ;; Local Variables:
13057 ;; coding: utf-8
13058 ;; End:
13060 ;;; gnus-sum.el ends here