shr.el (shr-insert): Don't insert double spaces.
[emacs.git] / lisp / gnus / gnus-sum.el
bloba0566900757f2c0ab5ff5e8705c5f0039ef70a6c
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;;; Code:
28 ;; For Emacs < 22.2.
29 (eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
31 (eval-when-compile
32 (require 'cl))
33 (eval-when-compile
34 (when (featurep 'xemacs)
35 (require 'easy-mmode))) ; for `define-minor-mode'
37 (defvar tool-bar-mode)
38 (defvar gnus-tmp-header)
40 (require 'gnus)
41 (require 'gnus-group)
42 (require 'gnus-spec)
43 (require 'gnus-range)
44 (require 'gnus-int)
45 (require 'gnus-undo)
46 (require 'gnus-util)
47 (require 'gmm-utils)
48 (require 'mm-decode)
49 (require 'nnoo)
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-cache-write-active "gnus-cache")
53 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
54 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
55 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
60 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
64 (defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66 If nil, the summary will become a \"*Dead Summary*\" buffer, and
67 it will be killed sometime later."
68 :group 'gnus-summary-exit
69 :type 'boolean)
71 (defcustom gnus-summary-next-group-on-exit t
72 "If non-nil, go to the next unread newsgroup on summary exit.
73 See `gnus-group-goto-unread'."
74 :link '(custom-manual "(gnus)Group Maneuvering")
75 :group 'gnus-summary-exit
76 :version "23.1" ;; No Gnus
77 :type 'boolean)
79 (defcustom gnus-summary-stop-at-end-of-message nil
80 "If non-nil, don't select the next message when using `SPC'."
81 :link '(custom-manual "(gnus)Group Maneuvering")
82 :group 'gnus-summary-maneuvering
83 :version "24.1"
84 :type 'boolean)
86 (defcustom gnus-fetch-old-headers nil
87 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
88 If an unread article in the group refers to an older, already
89 read (or just marked as read) article, the old article will not
90 normally be displayed in the Summary buffer. If this variable is
91 t, Gnus will attempt to grab the headers to the old articles, and
92 thereby build complete threads. If it has the value `some', all
93 old headers will be fetched but only enough headers to connect
94 otherwise loose threads will be displayed. This variable can
95 also be a number. In that case, no more than that number of old
96 headers will be fetched. If it has the value `invisible', all
97 old headers will be fetched, but none will be displayed.
99 The server has to support NOV for any of this to work.
101 This feature can seriously impact performance it ignores all
102 locally cached header entries. Setting it to t for groups for a
103 server that doesn't expire articles (such as news.gmane.org),
104 leads to very slow summary generation."
105 :group 'gnus-thread
106 :type '(choice (const :tag "off" nil)
107 (const :tag "on" t)
108 (const some)
109 (const invisible)
110 number
111 (sexp :menu-tag "other" t)))
113 (defcustom gnus-refer-thread-limit 500
114 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
115 If t, fetch all the available old headers."
116 :group 'gnus-thread
117 :type '(choice number
118 (sexp :menu-tag "other" t)))
120 (defcustom gnus-summary-make-false-root 'adopt
121 "*nil means that Gnus won't gather loose threads.
122 If the root of a thread has expired or been read in a previous
123 session, the information necessary to build a complete thread has been
124 lost. Instead of having many small sub-threads from this original thread
125 scattered all over the summary buffer, Gnus can gather them.
127 If non-nil, Gnus will try to gather all loose sub-threads from an
128 original thread into one large thread.
130 If this variable is non-nil, it should be one of `none', `adopt',
131 `dummy' or `empty'.
133 If this variable is `none', Gnus will not make a false root, but just
134 present the sub-threads after another.
135 If this variable is `dummy', Gnus will create a dummy root that will
136 have all the sub-threads as children.
137 If this variable is `adopt', Gnus will make one of the \"children\"
138 the parent and mark all the step-children as such.
139 If this variable is `empty', the \"children\" are printed with empty
140 subject fields. (Or rather, they will be printed with a string
141 given by the `gnus-summary-same-subject' variable.)"
142 :group 'gnus-thread
143 :type '(choice (const :tag "off" nil)
144 (const none)
145 (const dummy)
146 (const adopt)
147 (const empty)))
149 (defcustom gnus-summary-make-false-root-always nil
150 "Always make a false dummy root."
151 :version "22.1"
152 :group 'gnus-thread
153 :type 'boolean)
155 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
156 "*A regexp to match subjects to be excluded from loose thread gathering.
157 As loose thread gathering is done on subjects only, that means that
158 there can be many false gatherings performed. By rooting out certain
159 common subjects, gathering might become saner."
160 :group 'gnus-thread
161 :type 'regexp)
163 (defcustom gnus-summary-gather-subject-limit nil
164 "*Maximum length of subject comparisons when gathering loose threads.
165 Use nil to compare full subjects. Setting this variable to a low
166 number will help gather threads that have been corrupted by
167 newsreaders chopping off subject lines, but it might also mean that
168 unrelated articles that have subject that happen to begin with the
169 same few characters will be incorrectly gathered.
171 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
172 comparing subjects."
173 :group 'gnus-thread
174 :type '(choice (const :tag "off" nil)
175 (const fuzzy)
176 (sexp :menu-tag "on" t)))
178 (defcustom gnus-simplify-subject-functions nil
179 "List of functions taking a string argument that simplify subjects.
180 The functions are applied recursively.
182 Useful functions to put in this list include:
183 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
184 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
185 :group 'gnus-thread
186 :type '(repeat function))
188 (defcustom gnus-simplify-ignored-prefixes nil
189 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
190 :group 'gnus-thread
191 :type '(choice (const :tag "off" nil)
192 regexp))
194 (defcustom gnus-build-sparse-threads nil
195 "*If non-nil, fill in the gaps in threads.
196 If `some', only fill in the gaps that are needed to tie loose threads
197 together. If `more', fill in all leaf nodes that Gnus can find. If
198 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 (const some)
202 (const more)
203 (sexp :menu-tag "all" t)))
205 (defcustom gnus-summary-thread-gathering-function
206 'gnus-gather-threads-by-subject
207 "*Function used for gathering loose threads.
208 There are two pre-defined functions: `gnus-gather-threads-by-subject',
209 which only takes Subjects into consideration; and
210 `gnus-gather-threads-by-references', which compared the References
211 headers of the articles to find matches."
212 :group 'gnus-thread
213 :type '(radio (function-item gnus-gather-threads-by-subject)
214 (function-item gnus-gather-threads-by-references)
215 (function :tag "other")))
217 (defcustom gnus-summary-same-subject ""
218 "*String indicating that the current article has the same subject as the previous.
219 This variable will only be used if the value of
220 `gnus-summary-make-false-root' is `empty'."
221 :group 'gnus-summary-format
222 :type 'string)
224 (defcustom gnus-summary-goto-unread nil
225 "*If t, many commands will go to the next unread article.
226 This applies to marking commands as well as other commands that
227 \"naturally\" select the next article, like, for instance, `SPC' at
228 the end of an article.
230 If nil, the marking commands do NOT go to the next unread article
231 \(they go to the next article instead). If `never', commands that
232 usually go to the next unread article, will go to the next article,
233 whether it is read or not."
234 :version "24.1"
235 :group 'gnus-summary-marks
236 :link '(custom-manual "(gnus)Setting Marks")
237 :type '(choice (const :tag "off" nil)
238 (const never)
239 (sexp :menu-tag "on" t)))
241 (defcustom gnus-summary-default-score 0
242 "*Default article score level.
243 All scores generated by the score files will be added to this score.
244 If this variable is nil, scoring will be disabled."
245 :group 'gnus-score-default
246 :type '(choice (const :tag "disable")
247 integer))
249 (defcustom gnus-summary-default-high-score 0
250 "*Default threshold for a high scored article.
251 An article will be highlighted as high scored if its score is greater
252 than this score."
253 :version "22.1"
254 :group 'gnus-score-default
255 :type 'integer)
257 (defcustom gnus-summary-default-low-score 0
258 "*Default threshold for a low scored article.
259 An article will be highlighted as low scored if its score is smaller
260 than this score."
261 :version "22.1"
262 :group 'gnus-score-default
263 :type 'integer)
265 (defcustom gnus-summary-zcore-fuzz 0
266 "*Fuzziness factor for the zcore in the summary buffer.
267 Articles with scores closer than this to `gnus-summary-default-score'
268 will not be marked."
269 :group 'gnus-summary-format
270 :type 'integer)
272 (defcustom gnus-simplify-subject-fuzzy-regexp nil
273 "*Strings to be removed when doing fuzzy matches.
274 This can either be a regular expression or list of regular expressions
275 that will be removed from subject strings if fuzzy subject
276 simplification is selected."
277 :group 'gnus-thread
278 :type '(repeat regexp))
280 (defcustom gnus-show-threads t
281 "*If non-nil, display threads in summary mode."
282 :group 'gnus-thread
283 :type 'boolean)
285 (defcustom gnus-thread-hide-subtree nil
286 "*If non-nil, hide all threads initially.
287 This can be a predicate specifier which says which threads to hide.
288 If threads are hidden, you have to run the command
289 `gnus-summary-show-thread' by hand or select an article."
290 :group 'gnus-thread
291 :type '(radio (sexp :format "Non-nil\n"
292 :match (lambda (widget value)
293 (not (or (consp value) (functionp value))))
294 :value t)
295 (const nil)
296 (sexp :tag "Predicate specifier")))
298 (defcustom gnus-thread-hide-killed t
299 "*If non-nil, hide killed threads automatically."
300 :group 'gnus-thread
301 :type 'boolean)
303 (defcustom gnus-thread-ignore-subject t
304 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
305 If nil, articles that have different subjects from their parents will
306 start separate threads."
307 :group 'gnus-thread
308 :type 'boolean)
310 (defcustom gnus-thread-operation-ignore-subject t
311 "*If non-nil, subjects will be ignored when doing thread commands.
312 This affects commands like `gnus-summary-kill-thread' and
313 `gnus-summary-lower-thread'.
315 If this variable is nil, articles in the same thread with different
316 subjects will not be included in the operation in question. If this
317 variable is `fuzzy', only articles that have subjects that are fuzzily
318 equal will be included."
319 :group 'gnus-thread
320 :type '(choice (const :tag "off" nil)
321 (const fuzzy)
322 (sexp :tag "on" t)))
324 (defcustom gnus-thread-indent-level 4
325 "*Number that says how much each sub-thread should be indented."
326 :group 'gnus-thread
327 :type 'integer)
329 (defcustom gnus-auto-extend-newsgroup t
330 "*If non-nil, extend newsgroup forward and backward when requested."
331 :group 'gnus-summary-choose
332 :type 'boolean)
334 (defcustom gnus-auto-select-first t
335 "If non-nil, select an article on group entry.
336 An article is selected automatically when entering a group
337 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
338 `gnus-summary-catchup-and-goto-next-group'.
340 Which article is selected is controlled by the variable
341 `gnus-auto-select-subject'.
343 If you want to prevent automatic selection of articles in some
344 newsgroups, set the variable to nil in `gnus-select-group-hook'."
345 ;; Commands include...
346 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
347 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
349 :group 'gnus-group-select
350 :type '(choice (const :tag "none" nil)
351 (sexp :menu-tag "first" t)))
353 (defcustom gnus-auto-select-subject 'unseen-or-unread
354 "*Says what subject to place under point when entering a group.
356 This variable can either be the symbols `first' (place point on the
357 first subject), `unread' (place point on the subject line of the first
358 unread article), `best' (place point on the subject line of the
359 higest-scored article), `unseen' (place point on the subject line of
360 the first unseen article), `unseen-or-unread' (place point on the subject
361 line of the first unseen article or, if all article have been seen, on the
362 subject line of the first unread article), or a function to be called to
363 place point on some subject line."
364 :version "24.1"
365 :group 'gnus-group-select
366 :type '(choice (const best)
367 (const unread)
368 (const first)
369 (const unseen)
370 (const unseen-or-unread)))
372 (defcustom gnus-auto-select-next t
373 "*If non-nil, offer to go to the next group from the end of the previous.
374 If the value is t and the next newsgroup is empty, Gnus will exit
375 summary mode and go back to group mode. If the value is neither nil
376 nor t, Gnus will select the following unread newsgroup. In
377 particular, if the value is the symbol `quietly', the next unread
378 newsgroup will be selected without any confirmation, and if it is
379 `almost-quietly', the next group will be selected without any
380 confirmation if you are located on the last article in the group.
381 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
382 will go to the next group without confirmation."
383 :group 'gnus-summary-maneuvering
384 :type '(choice (const :tag "off" nil)
385 (const quietly)
386 (const almost-quietly)
387 (const slightly-quietly)
388 (sexp :menu-tag "on" t)))
390 (defcustom gnus-auto-select-same nil
391 "*If non-nil, select the next article with the same subject.
392 If there are no more articles with the same subject, go to
393 the first unread article."
394 :group 'gnus-summary-maneuvering
395 :type 'boolean)
397 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
398 "What article should be selected after exiting an ephemeral group.
399 Valid values include:
401 `next'
402 Select the next article.
403 `next-unread'
404 Select the next unread article.
405 `next-noselect'
406 Move the cursor to the next article. This is the default.
407 `next-unread-noselect'
408 Move the cursor to the next unread article.
410 If it has any other value or there is no next (unread) article, the
411 article selected before entering to the ephemeral group will appear."
412 :version "23.1" ;; No Gnus
413 :group 'gnus-summary-maneuvering
414 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
415 (const next) (const next-unread)
416 (const next-noselect) (const next-unread-noselect)
417 (sexp :tag "other" :value nil)))
419 (defcustom gnus-auto-goto-ignores 'unfetched
420 "*Says how to handle unfetched articles when maneuvering.
422 This variable can either be the symbols nil (maneuver to any
423 article), `undownloaded' (maneuvering while unplugged ignores articles
424 that have not been fetched), `always-undownloaded' (maneuvering always
425 ignores articles that have not been fetched), `unfetched' (maneuvering
426 ignores articles whose headers have not been fetched).
428 NOTE: The list of unfetched articles will always be nil when plugged
429 and, when unplugged, a subset of the undownloaded article list."
430 :version "22.1"
431 :group 'gnus-summary-maneuvering
432 :type '(choice (const :tag "None" nil)
433 (const :tag "Undownloaded when unplugged" undownloaded)
434 (const :tag "Undownloaded" always-undownloaded)
435 (const :tag "Unfetched" unfetched)))
437 (defcustom gnus-summary-check-current nil
438 "*If non-nil, consider the current article when moving.
439 The \"unread\" movement commands will stay on the same line if the
440 current article is unread."
441 :group 'gnus-summary-maneuvering
442 :type 'boolean)
444 (defcustom gnus-auto-center-summary 2
445 "*If non-nil, always center the current summary buffer.
446 In particular, if `vertical' do only vertical recentering. If non-nil
447 and non-`vertical', do both horizontal and vertical recentering."
448 :group 'gnus-summary-maneuvering
449 :type '(choice (const :tag "none" nil)
450 (const vertical)
451 (integer :tag "height")
452 (sexp :menu-tag "both" t)))
454 (defcustom gnus-auto-center-group t
455 "If non-nil, always center the group buffer."
456 :group 'gnus-summary-maneuvering
457 :type 'boolean)
459 (defcustom gnus-show-all-headers nil
460 "*If non-nil, don't hide any headers."
461 :group 'gnus-article-hiding
462 :group 'gnus-article-headers
463 :type 'boolean)
465 (defcustom gnus-summary-ignore-duplicates nil
466 "*If non-nil, ignore articles with identical Message-ID headers."
467 :group 'gnus-summary
468 :type 'boolean)
470 (defcustom gnus-single-article-buffer nil
471 "*If non-nil, display all articles in the same buffer.
472 If nil, each group will get its own article buffer."
473 :version "24.1"
474 :group 'gnus-article-various
475 :type 'boolean)
477 (defcustom gnus-widen-article-window nil
478 "If non-nil, selecting the article buffer will display only the article buffer."
479 :version "24.1"
480 :group 'gnus-article-various
481 :type 'boolean)
483 (defcustom gnus-break-pages t
484 "*If non-nil, do page breaking on articles.
485 The page delimiter is specified by the `gnus-page-delimiter'
486 variable."
487 :group 'gnus-article-various
488 :type 'boolean)
490 (defcustom gnus-move-split-methods nil
491 "*Variable used to suggest where articles are to be moved to.
492 It uses the same syntax as the `gnus-split-methods' variable.
493 However, whereas `gnus-split-methods' specifies file names as targets,
494 this variable specifies group names."
495 :group 'gnus-summary-mail
496 :type '(repeat (choice (list :value (fun) function)
497 (cons :value ("" "") regexp (repeat string))
498 (sexp :value nil))))
500 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
501 "Function used to compute default prefix for article move/copy/etc prompts.
502 The function should take one argument, a group name, and return a
503 string with the suggested prefix."
504 :group 'gnus-summary-mail
505 :type 'function)
507 ;; FIXME: Although the custom type is `character' for the following variables,
508 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
510 (defcustom gnus-unread-mark ? ;Whitespace
511 "*Mark used for unread articles."
512 :group 'gnus-summary-marks
513 :type 'character)
515 (defcustom gnus-ticked-mark ?!
516 "*Mark used for ticked articles."
517 :group 'gnus-summary-marks
518 :type 'character)
520 (defcustom gnus-dormant-mark ??
521 "*Mark used for dormant articles."
522 :group 'gnus-summary-marks
523 :type 'character)
525 (defcustom gnus-del-mark ?r
526 "*Mark used for del'd articles."
527 :group 'gnus-summary-marks
528 :type 'character)
530 (defcustom gnus-read-mark ?R
531 "*Mark used for read articles."
532 :group 'gnus-summary-marks
533 :type 'character)
535 (defcustom gnus-expirable-mark ?E
536 "*Mark used for expirable articles."
537 :group 'gnus-summary-marks
538 :type 'character)
540 (defcustom gnus-killed-mark ?K
541 "*Mark used for killed articles."
542 :group 'gnus-summary-marks
543 :type 'character)
545 (defcustom gnus-spam-mark ?$
546 "*Mark used for spam articles."
547 :version "22.1"
548 :group 'gnus-summary-marks
549 :type 'character)
551 (defcustom gnus-kill-file-mark ?X
552 "*Mark used for articles killed by kill files."
553 :group 'gnus-summary-marks
554 :type 'character)
556 (defcustom gnus-low-score-mark ?Y
557 "*Mark used for articles with a low score."
558 :group 'gnus-summary-marks
559 :type 'character)
561 (defcustom gnus-catchup-mark ?C
562 "*Mark used for articles that are caught up."
563 :group 'gnus-summary-marks
564 :type 'character)
566 (defcustom gnus-replied-mark ?A
567 "*Mark used for articles that have been replied to."
568 :group 'gnus-summary-marks
569 :type 'character)
571 (defcustom gnus-forwarded-mark ?F
572 "*Mark used for articles that have been forwarded."
573 :version "22.1"
574 :group 'gnus-summary-marks
575 :type 'character)
577 (defcustom gnus-recent-mark ?N
578 "*Mark used for articles that are recent."
579 :version "22.1"
580 :group 'gnus-summary-marks
581 :type 'character)
583 (defcustom gnus-cached-mark ?*
584 "*Mark used for articles that are in the cache."
585 :group 'gnus-summary-marks
586 :type 'character)
588 (defcustom gnus-saved-mark ?S
589 "*Mark used for articles that have been saved."
590 :group 'gnus-summary-marks
591 :type 'character)
593 (defcustom gnus-unseen-mark ?.
594 "*Mark used for articles that haven't been seen."
595 :version "22.1"
596 :group 'gnus-summary-marks
597 :type 'character)
599 (defcustom gnus-no-mark ? ;Whitespace
600 "*Mark used for articles that have no other secondary mark."
601 :version "22.1"
602 :group 'gnus-summary-marks
603 :type 'character)
605 (defcustom gnus-ancient-mark ?O
606 "*Mark used for ancient articles."
607 :group 'gnus-summary-marks
608 :type 'character)
610 (defcustom gnus-sparse-mark ?Q
611 "*Mark used for sparsely reffed articles."
612 :group 'gnus-summary-marks
613 :type 'character)
615 (defcustom gnus-canceled-mark ?G
616 "*Mark used for canceled articles."
617 :group 'gnus-summary-marks
618 :type 'character)
620 (defcustom gnus-duplicate-mark ?M
621 "*Mark used for duplicate articles."
622 :group 'gnus-summary-marks
623 :type 'character)
625 (defcustom gnus-undownloaded-mark ?-
626 "*Mark used for articles that weren't downloaded."
627 :version "22.1"
628 :group 'gnus-summary-marks
629 :type 'character)
631 (defcustom gnus-downloaded-mark ?+
632 "*Mark used for articles that were downloaded."
633 :group 'gnus-summary-marks
634 :type 'character)
636 (defcustom gnus-downloadable-mark ?%
637 "*Mark used for articles that are to be downloaded."
638 :group 'gnus-summary-marks
639 :type 'character)
641 (defcustom gnus-unsendable-mark ?=
642 "*Mark used for articles that won't be sent."
643 :group 'gnus-summary-marks
644 :type 'character)
646 (defcustom gnus-score-over-mark ?+
647 "*Score mark used for articles with high scores."
648 :group 'gnus-summary-marks
649 :type 'character)
651 (defcustom gnus-score-below-mark ?-
652 "*Score mark used for articles with low scores."
653 :group 'gnus-summary-marks
654 :type 'character)
656 (defcustom gnus-empty-thread-mark ? ;Whitespace
657 "*There is no thread under the article."
658 :group 'gnus-summary-marks
659 :type 'character)
661 (defcustom gnus-not-empty-thread-mark ?=
662 "*There is a thread under the article."
663 :group 'gnus-summary-marks
664 :type 'character)
666 (defcustom gnus-view-pseudo-asynchronously nil
667 "*If non-nil, Gnus will view pseudo-articles asynchronously."
668 :group 'gnus-extract-view
669 :type 'boolean)
671 (defcustom gnus-auto-expirable-marks
672 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
673 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
674 gnus-duplicate-mark)
675 "*The list of marks converted into expiration if a group is auto-expirable."
676 :version "24.1"
677 :group 'gnus-summary
678 :type '(repeat character))
680 (defcustom gnus-inhibit-user-auto-expire t
681 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
682 :version "21.1"
683 :group 'gnus-summary
684 :type 'boolean)
686 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
687 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
688 If nil, the expirable marks will be unchanged except that the marks
689 will be removed when copying or moving articles to a group that has
690 not turned auto-expire on. If non-nil, articles that have been read
691 will be marked as expirable when being copied or moved to a group in
692 which auto-expire is turned on."
693 :version "23.2"
694 :type 'boolean
695 :group 'gnus-summary-marks)
697 (defcustom gnus-view-pseudos nil
698 "*If `automatic', pseudo-articles will be viewed automatically.
699 If `not-confirm', pseudos will be viewed automatically, and the user
700 will not be asked to confirm the command."
701 :group 'gnus-extract-view
702 :type '(choice (const :tag "off" nil)
703 (const automatic)
704 (const not-confirm)))
706 (defcustom gnus-view-pseudos-separately t
707 "*If non-nil, one pseudo-article will be created for each file to be viewed.
708 If nil, all files that use the same viewing command will be given as a
709 list of parameters to that command."
710 :group 'gnus-extract-view
711 :type 'boolean)
713 (defcustom gnus-insert-pseudo-articles t
714 "*If non-nil, insert pseudo-articles when decoding articles."
715 :group 'gnus-extract-view
716 :type 'boolean)
718 (defcustom gnus-summary-dummy-line-format
719 " %(: :%) %S\n"
720 "*The format specification for the dummy roots in the summary buffer.
721 It works along the same lines as a normal formatting string,
722 with some simple extensions.
724 %S The subject
726 General format specifiers can also be used.
727 See `(gnus)Formatting Variables'."
728 :link '(custom-manual "(gnus)Formatting Variables")
729 :group 'gnus-threading
730 :type 'string)
732 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
733 "*The format specification for the summary mode line.
734 It works along the same lines as a normal formatting string,
735 with some simple extensions:
737 %G Group name
738 %p Unprefixed group name
739 %A Current article number
740 %z Current article score
741 %V Gnus version
742 %U Number of unread articles in the group
743 %e Number of unselected articles in the group
744 %Z A string with unread/unselected article counts
745 %g Shortish group name
746 %S Subject of the current article
747 %u User-defined spec
748 %s Current score file name
749 %d Number of dormant articles
750 %r Number of articles that have been marked as read in this session
751 %E Number of articles expunged by the score files"
752 :group 'gnus-summary-format
753 :type 'string)
755 (defcustom gnus-list-identifiers nil
756 "Regexp that matches list identifiers to be removed from subject.
757 This can also be a list of regexps."
758 :version "21.1"
759 :group 'gnus-summary-format
760 :group 'gnus-article-hiding
761 :type '(choice (const :tag "none" nil)
762 (regexp :value ".*")
763 (repeat :value (".*") regexp)))
765 (defcustom gnus-summary-mark-below 0
766 "*Mark all articles with a score below this variable as read.
767 This variable is local to each summary buffer and usually set by the
768 score file."
769 :group 'gnus-score-default
770 :type 'integer)
772 (defun gnus-widget-reversible-match (widget value)
773 "Ignoring WIDGET, convert VALUE to internal form.
774 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
775 ;; (debug value)
776 (or (symbolp value)
777 (and (listp value)
778 (eq (length value) 2)
779 (eq (nth 0 value) 'not)
780 (symbolp (nth 1 value)))))
782 (defun gnus-widget-reversible-to-internal (widget value)
783 "Ignoring WIDGET, convert VALUE to internal form.
784 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
785 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
786 ;; (debug value)
787 (if (atom value)
788 (list value nil)
789 (list (nth 1 value) t)))
791 (defun gnus-widget-reversible-to-external (widget value)
792 "Ignoring WIDGET, convert VALUE to external form.
793 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
794 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
795 ;; (debug value)
796 (if (nth 1 value)
797 (list 'not (nth 0 value))
798 (nth 0 value)))
800 (define-widget 'gnus-widget-reversible 'group
801 "A `group' that convert values."
802 :match 'gnus-widget-reversible-match
803 :value-to-internal 'gnus-widget-reversible-to-internal
804 :value-to-external 'gnus-widget-reversible-to-external)
806 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
807 "*List of functions used for sorting articles in the summary buffer.
809 Each function takes two articles and returns non-nil if the first
810 article should be sorted before the other. If you use more than one
811 function, the primary sort function should be the last. You should
812 probably always include `gnus-article-sort-by-number' in the list of
813 sorting functions -- preferably first. Also note that sorting by date
814 is often much slower than sorting by number, and the sorting order is
815 very similar. (Sorting by date means sorting by the time the message
816 was sent, sorting by number means sorting by arrival time.)
818 Each item can also be a list `(not F)' where F is a function;
819 this reverses the sort order.
821 Ready-made functions include `gnus-article-sort-by-number',
822 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
823 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
824 and `gnus-article-sort-by-score'.
826 When threading is turned on, the variable `gnus-thread-sort-functions'
827 controls how articles are sorted."
828 :group 'gnus-summary-sort
829 :type '(repeat (gnus-widget-reversible
830 (choice (function-item gnus-article-sort-by-number)
831 (function-item gnus-article-sort-by-author)
832 (function-item gnus-article-sort-by-subject)
833 (function-item gnus-article-sort-by-date)
834 (function-item gnus-article-sort-by-score)
835 (function-item gnus-article-sort-by-random)
836 (function :tag "other"))
837 (boolean :tag "Reverse order"))))
840 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
841 "*List of functions used for sorting threads in the summary buffer.
842 By default, threads are sorted by article number.
844 Each function takes two threads and returns non-nil if the first
845 thread should be sorted before the other. If you use more than one
846 function, the primary sort function should be the last. You should
847 probably always include `gnus-thread-sort-by-number' in the list of
848 sorting functions -- preferably first. Also note that sorting by date
849 is often much slower than sorting by number, and the sorting order is
850 very similar. (Sorting by date means sorting by the time the message
851 was sent, sorting by number means sorting by arrival time.)
853 Each list item can also be a list `(not F)' where F is a
854 function; this specifies reversed sort order.
856 Ready-made functions include `gnus-thread-sort-by-number',
857 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
858 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
859 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
860 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
861 and `gnus-thread-sort-by-total-score' (see
862 `gnus-thread-score-function').
864 When threading is turned off, the variable
865 `gnus-article-sort-functions' controls how articles are sorted."
866 :group 'gnus-summary-sort
867 :type '(repeat
868 (gnus-widget-reversible
869 (choice (function-item gnus-thread-sort-by-number)
870 (function-item gnus-thread-sort-by-author)
871 (function-item gnus-thread-sort-by-recipient)
872 (function-item gnus-thread-sort-by-subject)
873 (function-item gnus-thread-sort-by-date)
874 (function-item gnus-thread-sort-by-score)
875 (function-item gnus-thread-sort-by-most-recent-number)
876 (function-item gnus-thread-sort-by-most-recent-date)
877 (function-item gnus-thread-sort-by-random)
878 (function-item gnus-thread-sort-by-total-score)
879 (function :tag "other"))
880 (boolean :tag "Reverse order"))))
882 (defcustom gnus-thread-score-function '+
883 "*Function used for calculating the total score of a thread.
885 The function is called with the scores of the article and each
886 subthread and should then return the score of the thread.
888 Some functions you can use are `+', `max', or `min'."
889 :group 'gnus-summary-sort
890 :type 'function)
892 (defcustom gnus-summary-expunge-below nil
893 "All articles that have a score less than this variable will be expunged.
894 This variable is local to the summary buffers."
895 :group 'gnus-score-default
896 :type '(choice (const :tag "off" nil)
897 integer))
899 (defcustom gnus-thread-expunge-below nil
900 "All threads that have a total score less than this variable will be expunged.
901 See `gnus-thread-score-function' for en explanation of what a
902 \"thread score\" is.
904 This variable is local to the summary buffers."
905 :group 'gnus-threading
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
908 integer))
910 (defcustom gnus-summary-mode-hook nil
911 "*A hook for Gnus summary mode.
912 This hook is run before any variables are set in the summary buffer."
913 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
914 :group 'gnus-summary-various
915 :type 'hook)
917 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
918 (when (featurep 'xemacs)
919 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
920 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
921 (add-hook 'gnus-summary-mode-hook
922 'gnus-xmas-switch-horizontal-scrollbar-off))
924 (defcustom gnus-summary-menu-hook nil
925 "*Hook run after the creation of the summary mode menu."
926 :group 'gnus-summary-visual
927 :type 'hook)
929 (defcustom gnus-summary-exit-hook nil
930 "*A hook called on exit from the summary buffer.
931 It will be called with point in the group buffer."
932 :group 'gnus-summary-exit
933 :type 'hook)
935 (defcustom gnus-summary-prepare-hook nil
936 "*A hook called after the summary buffer has been generated.
937 If you want to modify the summary buffer, you can use this hook."
938 :group 'gnus-summary-various
939 :type 'hook)
941 (defcustom gnus-summary-prepared-hook nil
942 "*A hook called as the last thing after the summary buffer has been generated."
943 :group 'gnus-summary-various
944 :type 'hook)
946 (defcustom gnus-summary-generate-hook nil
947 "*A hook run just before generating the summary buffer.
948 This hook is commonly used to customize threading variables and the
949 like."
950 :group 'gnus-summary-various
951 :type 'hook)
953 (defcustom gnus-select-group-hook nil
954 "*A hook called when a newsgroup is selected.
956 If you'd like to simplify subjects like the
957 `gnus-summary-next-same-subject' command does, you can use the
958 following hook:
960 (add-hook gnus-select-group-hook
961 (lambda ()
962 (mapcar (lambda (header)
963 (mail-header-set-subject
964 header
965 (gnus-simplify-subject
966 (mail-header-subject header) 're-only)))
967 gnus-newsgroup-headers)))"
968 :group 'gnus-group-select
969 :type 'hook)
971 (defcustom gnus-select-article-hook nil
972 "*A hook called when an article is selected."
973 :group 'gnus-summary-choose
974 :options '(gnus-agent-fetch-selected-article)
975 :type 'hook)
977 (defcustom gnus-visual-mark-article-hook
978 (list 'gnus-highlight-selected-summary)
979 "*Hook run after selecting an article in the summary buffer.
980 It is meant to be used for highlighting the article in some way. It
981 is not run if `gnus-visual' is nil."
982 :group 'gnus-summary-visual
983 :type 'hook)
985 (defcustom gnus-parse-headers-hook nil
986 "*A hook called before parsing the headers."
987 :group 'gnus-various
988 :type 'hook)
990 (defcustom gnus-exit-group-hook nil
991 "*A hook called when exiting summary mode.
992 This hook is not called from the non-updating exit commands like `Q'."
993 :group 'gnus-various
994 :type 'hook)
996 (defcustom gnus-summary-update-hook nil
997 "*A hook called when a summary line is changed.
998 The hook will not be called if `gnus-visual' is nil.
1000 The default function `gnus-summary-highlight-line' will
1001 highlight the line according to the `gnus-summary-highlight'
1002 variable."
1003 :group 'gnus-summary-visual
1004 :type 'hook)
1006 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1007 "*A hook called when an article is selected for the first time.
1008 The hook is intended to mark an article as read (or unread)
1009 automatically when it is selected."
1010 :group 'gnus-summary-choose
1011 :type 'hook)
1013 (defcustom gnus-group-no-more-groups-hook nil
1014 "*A hook run when returning to group mode having no more (unread) groups."
1015 :group 'gnus-group-select
1016 :type 'hook)
1018 (defcustom gnus-ps-print-hook nil
1019 "*A hook run before ps-printing something from Gnus."
1020 :group 'gnus-summary
1021 :type 'hook)
1023 (defcustom gnus-summary-article-move-hook nil
1024 "*A hook called after an article is moved, copied, respooled, or crossposted."
1025 :version "22.1"
1026 :group 'gnus-summary
1027 :type 'hook)
1029 (defcustom gnus-summary-article-delete-hook nil
1030 "*A hook called after an article is deleted."
1031 :version "22.1"
1032 :group 'gnus-summary
1033 :type 'hook)
1035 (defcustom gnus-summary-article-expire-hook nil
1036 "*A hook called after an article is expired."
1037 :version "22.1"
1038 :group 'gnus-summary
1039 :type 'hook)
1041 (defcustom gnus-summary-display-arrow
1042 (and (fboundp 'display-graphic-p)
1043 (display-graphic-p))
1044 "*If non-nil, display an arrow highlighting the current article."
1045 :version "22.1"
1046 :group 'gnus-summary
1047 :type 'boolean)
1049 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1050 "Face used for highlighting the current article in the summary buffer."
1051 :group 'gnus-summary-visual
1052 :type 'face)
1054 (defvar gnus-tmp-downloaded nil)
1056 (defcustom gnus-summary-highlight
1057 '(((eq mark gnus-canceled-mark)
1058 . gnus-summary-cancelled)
1059 ((and uncached (> score default-high))
1060 . gnus-summary-high-undownloaded)
1061 ((and uncached (< score default-low))
1062 . gnus-summary-low-undownloaded)
1063 (uncached
1064 . gnus-summary-normal-undownloaded)
1065 ((and (> score default-high)
1066 (or (eq mark gnus-dormant-mark)
1067 (eq mark gnus-ticked-mark)))
1068 . gnus-summary-high-ticked)
1069 ((and (< score default-low)
1070 (or (eq mark gnus-dormant-mark)
1071 (eq mark gnus-ticked-mark)))
1072 . gnus-summary-low-ticked)
1073 ((or (eq mark gnus-dormant-mark)
1074 (eq mark gnus-ticked-mark))
1075 . gnus-summary-normal-ticked)
1076 ((and (> score default-high) (eq mark gnus-ancient-mark))
1077 . gnus-summary-high-ancient)
1078 ((and (< score default-low) (eq mark gnus-ancient-mark))
1079 . gnus-summary-low-ancient)
1080 ((eq mark gnus-ancient-mark)
1081 . gnus-summary-normal-ancient)
1082 ((and (> score default-high) (eq mark gnus-unread-mark))
1083 . gnus-summary-high-unread)
1084 ((and (< score default-low) (eq mark gnus-unread-mark))
1085 . gnus-summary-low-unread)
1086 ((eq mark gnus-unread-mark)
1087 . gnus-summary-normal-unread)
1088 ((> score default-high)
1089 . gnus-summary-high-read)
1090 ((< score default-low)
1091 . gnus-summary-low-read)
1093 . gnus-summary-normal-read))
1094 "*Controls the highlighting of summary buffer lines.
1096 A list of (FORM . FACE) pairs. When deciding how a particular
1097 summary line should be displayed, each form is evaluated. The content
1098 of the face field after the first true form is used. You can change
1099 how those summary lines are displayed, by editing the face field.
1101 You can use the following variables in the FORM field.
1103 score: The article's score.
1104 default: The default article score.
1105 default-high: The default score for high scored articles.
1106 default-low: The default score for low scored articles.
1107 below: The score below which articles are automatically marked as read.
1108 mark: The article's mark.
1109 uncached: Non-nil if the article is uncached."
1110 :group 'gnus-summary-visual
1111 :type '(repeat (cons (sexp :tag "Form" nil)
1112 face)))
1113 (put 'gnus-summary-highlight 'risky-local-variable t)
1115 (defcustom gnus-alter-header-function nil
1116 "Function called to allow alteration of article header structures.
1117 The function is called with one parameter, the article header vector,
1118 which it may alter in any way."
1119 :type '(choice (const :tag "None" nil)
1120 function)
1121 :group 'gnus-summary)
1123 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1124 "Function used to decode a string with encoded words.")
1126 (defvar gnus-decode-encoded-address-function
1127 'mail-decode-encoded-address-string
1128 "Function used to decode addresses with encoded words.")
1130 (defcustom gnus-extra-headers '(To Newsgroups)
1131 "*Extra headers to parse."
1132 :version "21.1"
1133 :group 'gnus-summary
1134 :type '(repeat symbol))
1136 (defcustom gnus-ignored-from-addresses
1137 (and user-mail-address
1138 (not (string= user-mail-address ""))
1139 (regexp-quote user-mail-address))
1140 "*From headers that may be suppressed in favor of To headers.
1141 This can be a regexp or a list of regexps."
1142 :version "21.1"
1143 :group 'gnus-summary
1144 :type '(choice regexp
1145 (repeat :tag "Regexp List" regexp)))
1147 (defsubst gnus-ignored-from-addresses ()
1148 (gmm-regexp-concat gnus-ignored-from-addresses))
1150 (defcustom gnus-summary-to-prefix "-> "
1151 "*String prefixed to the To field in the summary line when
1152 using `gnus-ignored-from-addresses'."
1153 :version "22.1"
1154 :group 'gnus-summary
1155 :type 'string)
1157 (defcustom gnus-summary-newsgroup-prefix "=> "
1158 "*String prefixed to the Newsgroup field in the summary
1159 line when using `gnus-ignored-from-addresses'."
1160 :version "22.1"
1161 :group 'gnus-summary
1162 :type 'string)
1164 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1165 "List of charsets that should be ignored.
1166 When these charsets are used in the \"charset\" parameter, the
1167 default charset will be used instead."
1168 :version "21.1"
1169 :type '(repeat symbol)
1170 :group 'gnus-charset)
1172 (defcustom gnus-newsgroup-maximum-articles nil
1173 "The maximum number of articles a newsgroup.
1174 If this is a number, old articles in a newsgroup exceeding this number
1175 are silently ignored. If it is nil, no article is ignored. Note that
1176 setting this variable to a number might prevent you from reading very
1177 old articles."
1178 :group 'gnus-group-select
1179 :version "22.2"
1180 :type '(choice (const :tag "No limit" nil)
1181 integer))
1183 (gnus-define-group-parameter
1184 ignored-charsets
1185 :type list
1186 :function-document
1187 "Return the ignored charsets of GROUP."
1188 :variable gnus-group-ignored-charsets-alist
1189 :variable-default
1190 '(("alt\\.chinese\\.text" iso-8859-1))
1191 :variable-document
1192 "Alist of regexps (to match group names) and charsets that should be ignored.
1193 When these charsets are used in the \"charset\" parameter, the
1194 default charset will be used instead."
1195 :variable-group gnus-charset
1196 :variable-type '(repeat (cons (regexp :tag "Group")
1197 (repeat symbol)))
1198 :parameter-type '(choice :tag "Ignored charsets"
1199 :value nil
1200 (repeat (symbol)))
1201 :parameter-document "\
1202 List of charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead.")
1207 (defcustom gnus-group-highlight-words-alist nil
1208 "Alist of group regexps and highlight regexps.
1209 This variable uses the same syntax as `gnus-emphasis-alist'."
1210 :version "21.1"
1211 :type '(repeat (cons (regexp :tag "Group")
1212 (repeat (list (regexp :tag "Highlight regexp")
1213 (number :tag "Group for entire word" 0)
1214 (number :tag "Group for displayed part" 0)
1215 (symbol :tag "Face"
1216 gnus-emphasis-highlight-words)))))
1217 :group 'gnus-summary-visual)
1219 (defcustom gnus-summary-show-article-charset-alist
1221 "Alist of number and charset.
1222 The article will be shown with the charset corresponding to the
1223 numbered argument.
1224 For example: ((1 . cn-gb-2312) (2 . big5))."
1225 :version "21.1"
1226 :type '(repeat (cons (number :tag "Argument" 1)
1227 (symbol :tag "Charset")))
1228 :group 'gnus-charset)
1230 (defcustom gnus-preserve-marks t
1231 "Whether marks are preserved when moving, copying and respooling messages."
1232 :version "21.1"
1233 :type 'boolean
1234 :group 'gnus-summary-marks)
1236 (defcustom gnus-propagate-marks t
1237 "If non-nil, do not propagate marks to the backends."
1238 :version "23.1" ;; No Gnus
1239 :type 'boolean
1240 :group 'gnus-summary-marks)
1242 (defcustom gnus-alter-articles-to-read-function nil
1243 "Function to be called to alter the list of articles to be selected."
1244 :type '(choice (const nil) function)
1245 :group 'gnus-summary)
1247 (defcustom gnus-orphan-score nil
1248 "*All orphans get this score added. Set in the score file."
1249 :group 'gnus-score-default
1250 :type '(choice (const nil)
1251 integer))
1253 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1254 "*A regexp to match MIME parts when saving multiple parts of a
1255 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1256 This regexp will be used by default when prompting the user for which
1257 type of files to save."
1258 :group 'gnus-summary
1259 :type 'regexp)
1261 (defcustom gnus-read-all-available-headers nil
1262 "Whether Gnus should parse all headers made available to it.
1263 This is mostly relevant for slow back ends where the user may
1264 wish to widen the summary buffer to include all headers
1265 that were fetched."
1266 :version "22.1"
1267 :group 'gnus-summary
1268 :type '(choice boolean regexp))
1270 (defcustom gnus-summary-pipe-output-default-command nil
1271 "Command (and optional arguments) used to pipe article to subprocess.
1272 This will be used as the default command if it is non-nil. The value
1273 will be updated if you modify it when executing the command
1274 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1275 :version "23.1" ;; No Gnus
1276 :group 'gnus-summary
1277 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1279 (defcustom gnus-summary-muttprint-program "muttprint"
1280 "Command (and optional arguments) used to run Muttprint.
1281 The value will be updated if you modify it when executing the command
1282 `gnus-summary-muttprint'."
1283 :version "22.1"
1284 :group 'gnus-summary
1285 :type 'string)
1287 (defcustom gnus-article-loose-mime t
1288 "If non-nil, don't require MIME-Version header.
1289 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1290 supply the MIME-Version header or deliberately strip it from the mail.
1291 If non-nil (the default), Gnus will treat some articles as MIME
1292 even if the MIME-Version header is missing."
1293 :version "22.1"
1294 :type 'boolean
1295 :group 'gnus-article-mime)
1297 (defcustom gnus-article-emulate-mime t
1298 "If non-nil, use MIME emulation for uuencode and the like.
1299 This means that Gnus will search message bodies for text that look
1300 like uuencoded bits, yEncoded bits, and so on, and present that using
1301 the normal Gnus MIME machinery."
1302 :version "22.1"
1303 :type 'boolean
1304 :group 'gnus-article-mime)
1306 ;;; Internal variables
1308 (defvar gnus-summary-display-cache nil)
1309 (defvar gnus-article-mime-handles nil)
1310 (defvar gnus-article-decoded-p nil)
1311 (defvar gnus-article-charset nil)
1312 (defvar gnus-article-ignored-charsets nil)
1313 (defvar gnus-scores-exclude-files nil)
1314 (defvar gnus-page-broken nil)
1316 (defvar gnus-original-article nil)
1317 (defvar gnus-article-internal-prepare-hook nil)
1318 (defvar gnus-newsgroup-process-stack nil)
1320 (defvar gnus-thread-indent-array nil)
1321 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1322 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1323 "Function called to sort the articles within a thread after it has been gathered together.")
1325 (defvar gnus-summary-save-parts-type-history nil)
1326 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1328 ;; Avoid highlighting in kill files.
1329 (defvar gnus-summary-inhibit-highlight nil)
1330 (defvar gnus-newsgroup-selected-overlay nil)
1331 (defvar gnus-inhibit-limiting nil)
1332 (defvar gnus-newsgroup-adaptive-score-file nil)
1333 (defvar gnus-current-score-file nil)
1334 (defvar gnus-current-move-group nil)
1335 (defvar gnus-current-copy-group nil)
1336 (defvar gnus-current-crosspost-group nil)
1337 (defvar gnus-newsgroup-display nil)
1339 (defvar gnus-newsgroup-dependencies nil)
1340 (defvar gnus-newsgroup-adaptive nil)
1341 (defvar gnus-summary-display-article-function nil)
1342 (defvar gnus-summary-highlight-line-function nil
1343 "Function called after highlighting a summary line.")
1345 (defvar gnus-summary-line-format-alist
1346 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1347 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1348 (?s gnus-tmp-subject-or-nil ?s)
1349 (?n gnus-tmp-name ?s)
1350 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1352 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1353 gnus-tmp-from) ?s)
1354 (?F gnus-tmp-from ?s)
1355 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1356 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1357 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1358 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1359 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1360 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1361 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1362 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1363 (?L gnus-tmp-lines ?s)
1364 (?O gnus-tmp-downloaded ?c)
1365 (?I gnus-tmp-indentation ?s)
1366 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1367 (?R gnus-tmp-replied ?c)
1368 (?\[ gnus-tmp-opening-bracket ?c)
1369 (?\] gnus-tmp-closing-bracket ?c)
1370 (?\> (make-string gnus-tmp-level ? ) ?s)
1371 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1372 (?i gnus-tmp-score ?d)
1373 (?z gnus-tmp-score-char ?c)
1374 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1375 (?U gnus-tmp-unread ?c)
1376 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1378 (?t (gnus-summary-number-of-articles-in-thread
1379 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1381 (?e (gnus-summary-number-of-articles-in-thread
1382 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1384 (?u gnus-tmp-user-defined ?s)
1385 (?P (gnus-pick-line-number) ?d)
1386 (?B gnus-tmp-thread-tree-header-string ?s)
1387 (user-date (gnus-user-date
1388 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1389 "An alist of format specifications that can appear in summary lines.
1390 These are paired with what variables they correspond with, along with
1391 the type of the variable (string, integer, character, etc).")
1393 (defvar gnus-summary-dummy-line-format-alist
1394 `((?S gnus-tmp-subject ?s)
1395 (?N gnus-tmp-number ?d)
1396 (?u gnus-tmp-user-defined ?s)))
1398 (defvar gnus-summary-mode-line-format-alist
1399 `((?G gnus-tmp-group-name ?s)
1400 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1401 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1402 (?A gnus-tmp-article-number ?d)
1403 (?Z gnus-tmp-unread-and-unselected ?s)
1404 (?V gnus-version ?s)
1405 (?U gnus-tmp-unread-and-unticked ?d)
1406 (?S gnus-tmp-subject ?s)
1407 (?e gnus-tmp-unselected ?d)
1408 (?u gnus-tmp-user-defined ?s)
1409 (?d (length gnus-newsgroup-dormant) ?d)
1410 (?t (length gnus-newsgroup-marked) ?d)
1411 (?h (length gnus-newsgroup-spam-marked) ?d)
1412 (?r (length gnus-newsgroup-reads) ?d)
1413 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1414 (?E gnus-newsgroup-expunged-tally ?d)
1415 (?s (gnus-current-score-file-nondirectory) ?s)))
1417 ;; This is here rather than in gnus-art for compilation reasons.
1418 (defvar gnus-article-mode-line-format-alist
1419 (nconc '((?w (gnus-article-wash-status) ?s)
1420 (?m (gnus-article-mime-part-status) ?s))
1421 gnus-summary-mode-line-format-alist))
1423 (defvar gnus-last-search-regexp nil
1424 "Default regexp for article search command.")
1426 (defvar gnus-last-shell-command nil
1427 "Default shell command on article.")
1429 (defvar gnus-newsgroup-agentized nil
1430 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1431 (defvar gnus-newsgroup-begin nil)
1432 (defvar gnus-newsgroup-end nil)
1433 (defvar gnus-newsgroup-last-rmail nil)
1434 (defvar gnus-newsgroup-last-mail nil)
1435 (defvar gnus-newsgroup-last-folder nil)
1436 (defvar gnus-newsgroup-last-file nil)
1437 (defvar gnus-newsgroup-last-directory nil)
1438 (defvar gnus-newsgroup-auto-expire nil)
1439 (defvar gnus-newsgroup-active nil)
1440 (defvar gnus-newsgroup-highest nil)
1442 (defvar gnus-newsgroup-data nil)
1443 (defvar gnus-newsgroup-data-reverse nil)
1444 (defvar gnus-newsgroup-limit nil)
1445 (defvar gnus-newsgroup-limits nil)
1446 (defvar gnus-summary-use-undownloaded-faces nil)
1448 (defvar gnus-newsgroup-unreads nil
1449 "Sorted list of unread articles in the current newsgroup.")
1451 (defvar gnus-newsgroup-unselected nil
1452 "Sorted list of unselected unread articles in the current newsgroup.")
1454 (defvar gnus-newsgroup-reads nil
1455 "Alist of read articles and article marks in the current newsgroup.")
1457 (defvar gnus-newsgroup-expunged-tally nil)
1459 (defvar gnus-newsgroup-marked nil
1460 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1462 (defvar gnus-newsgroup-spam-marked nil
1463 "List of ranges of articles that have been marked as spam.")
1465 (defvar gnus-newsgroup-killed nil
1466 "List of ranges of articles that have been through the scoring process.")
1468 (defvar gnus-newsgroup-cached nil
1469 "Sorted list of articles that come from the article cache.")
1471 (defvar gnus-newsgroup-saved nil
1472 "List of articles that have been saved.")
1474 (defvar gnus-newsgroup-kill-headers nil)
1476 (defvar gnus-newsgroup-replied nil
1477 "List of articles that have been replied to in the current newsgroup.")
1479 (defvar gnus-newsgroup-forwarded nil
1480 "List of articles that have been forwarded in the current newsgroup.")
1482 (defvar gnus-newsgroup-recent nil
1483 "List of articles that have are recent in the current newsgroup.")
1485 (defvar gnus-newsgroup-expirable nil
1486 "Sorted list of articles in the current newsgroup that can be expired.")
1488 (defvar gnus-newsgroup-processable nil
1489 "List of articles in the current newsgroup that can be processed.")
1491 (defvar gnus-newsgroup-downloadable nil
1492 "Sorted list of articles in the current newsgroup that can be processed.")
1494 (defvar gnus-newsgroup-unfetched nil
1495 "Sorted list of articles in the current newsgroup whose headers have
1496 not been fetched into the agent.
1498 This list will always be a subset of gnus-newsgroup-undownloaded.")
1500 (defvar gnus-newsgroup-undownloaded nil
1501 "List of articles in the current newsgroup that haven't been downloaded.")
1503 (defvar gnus-newsgroup-unsendable nil
1504 "List of articles in the current newsgroup that won't be sent.")
1506 (defvar gnus-newsgroup-bookmarks nil
1507 "List of articles in the current newsgroup that have bookmarks.")
1509 (defvar gnus-newsgroup-dormant nil
1510 "Sorted list of dormant articles in the current newsgroup.")
1512 (defvar gnus-newsgroup-unseen nil
1513 "List of unseen articles in the current newsgroup.")
1515 (defvar gnus-newsgroup-seen nil
1516 "Range of seen articles in the current newsgroup.")
1518 (defvar gnus-newsgroup-articles nil
1519 "List of articles in the current newsgroup.")
1521 (defvar gnus-newsgroup-scored nil
1522 "List of scored articles in the current newsgroup.")
1524 (defvar gnus-newsgroup-headers nil
1525 "List of article headers in the current newsgroup.")
1527 (defvar gnus-newsgroup-threads nil)
1529 (defvar gnus-newsgroup-prepared nil
1530 "Whether the current group has been prepared properly.")
1532 (defvar gnus-newsgroup-ancient nil
1533 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1535 (defvar gnus-newsgroup-sparse nil)
1537 (defvar gnus-current-article nil)
1538 (defvar gnus-article-current nil)
1539 (defvar gnus-current-headers nil)
1540 (defvar gnus-have-all-headers nil)
1541 (defvar gnus-last-article nil)
1542 (defvar gnus-newsgroup-history nil)
1543 (defvar gnus-newsgroup-charset nil)
1544 (defvar gnus-newsgroup-ephemeral-charset nil)
1545 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1547 (defvar gnus-article-before-search nil)
1549 (defvar gnus-summary-local-variables
1550 '(gnus-newsgroup-name
1552 ;; Marks lists
1553 gnus-newsgroup-unreads
1554 gnus-newsgroup-unselected
1555 gnus-newsgroup-marked
1556 gnus-newsgroup-spam-marked
1557 gnus-newsgroup-reads
1558 gnus-newsgroup-saved
1559 gnus-newsgroup-replied
1560 gnus-newsgroup-forwarded
1561 gnus-newsgroup-recent
1562 gnus-newsgroup-expirable
1563 gnus-newsgroup-killed
1564 gnus-newsgroup-unseen
1565 gnus-newsgroup-seen
1566 gnus-newsgroup-cached
1567 gnus-newsgroup-downloadable
1568 gnus-newsgroup-undownloaded
1569 gnus-newsgroup-unsendable
1571 gnus-newsgroup-begin gnus-newsgroup-end
1572 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1573 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1574 gnus-newsgroup-last-directory
1575 gnus-newsgroup-auto-expire
1576 gnus-newsgroup-processable
1577 gnus-newsgroup-unfetched
1578 gnus-newsgroup-articles
1579 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1580 gnus-newsgroup-headers gnus-newsgroup-threads
1581 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1582 gnus-current-article gnus-current-headers gnus-have-all-headers
1583 gnus-last-article gnus-article-internal-prepare-hook
1584 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1585 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1586 gnus-thread-expunge-below
1587 gnus-score-alist gnus-current-score-file
1588 (gnus-summary-expunge-below . global)
1589 (gnus-summary-mark-below . global)
1590 (gnus-orphan-score . global)
1591 gnus-newsgroup-active gnus-scores-exclude-files
1592 gnus-newsgroup-highest
1593 gnus-newsgroup-history gnus-newsgroup-ancient
1594 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1595 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1596 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1597 (gnus-newsgroup-expunged-tally . 0)
1598 gnus-cache-removable-articles
1599 gnus-newsgroup-data gnus-newsgroup-data-reverse
1600 gnus-newsgroup-limit gnus-newsgroup-limits
1601 gnus-newsgroup-charset gnus-newsgroup-display
1602 gnus-summary-use-undownloaded-faces)
1603 "Variables that are buffer-local to the summary buffers.")
1605 (defvar gnus-newsgroup-variables nil
1606 "A list of variables that have separate values in different newsgroups.
1607 A list of newsgroup (summary buffer) local variables, or cons of
1608 variables and their default expressions to be evalled (when the default
1609 values are not nil), that should be made global while the summary buffer
1610 is active.
1612 Note: The default expressions will be evaluated (using function `eval')
1613 before assignment to the local variable rather than just assigned to it.
1614 If the default expression is the symbol `global', that symbol will not
1615 be evaluated but the global value of the local variable will be used
1616 instead.
1618 These variables can be used to set variables in the group parameters
1619 while still allowing them to affect operations done in other buffers.
1620 For example:
1622 \(setq gnus-newsgroup-variables
1623 '(message-use-followup-to
1624 (gnus-visible-headers .
1625 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1628 (eval-when-compile
1629 ;; Bind features so that require will believe that gnus-sum has
1630 ;; already been loaded (avoids infinite recursion)
1631 (let ((features (cons 'gnus-sum features)))
1632 (require 'gnus-art)))
1634 ;; MIME stuff.
1636 (defvar gnus-decode-encoded-word-methods
1637 '(mail-decode-encoded-word-string)
1638 "List of methods used to decode encoded words.
1640 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1641 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1642 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1643 whose names match REGEXP.
1645 For example:
1646 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1647 mail-decode-encoded-word-string
1648 (\"chinese\" . rfc1843-decode-string))")
1650 (defvar gnus-decode-encoded-word-methods-cache nil)
1652 (defun gnus-multi-decode-encoded-word-string (string)
1653 "Apply the functions from `gnus-encoded-word-methods' that match."
1654 (unless (and gnus-decode-encoded-word-methods-cache
1655 (eq gnus-newsgroup-name
1656 (car gnus-decode-encoded-word-methods-cache)))
1657 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1658 (dolist (method gnus-decode-encoded-word-methods)
1659 (if (symbolp method)
1660 (nconc gnus-decode-encoded-word-methods-cache (list method))
1661 (if (and gnus-newsgroup-name
1662 (string-match (car method) gnus-newsgroup-name))
1663 (nconc gnus-decode-encoded-word-methods-cache
1664 (list (cdr method)))))))
1665 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1666 (setq string (funcall method string))))
1668 ;; Subject simplification.
1670 (defun gnus-simplify-whitespace (str)
1671 "Remove excessive whitespace from STR."
1672 ;; Multiple spaces.
1673 (while (string-match "[ \t][ \t]+" str)
1674 (setq str (concat (substring str 0 (match-beginning 0))
1676 (substring str (match-end 0)))))
1677 ;; Leading spaces.
1678 (when (string-match "^[ \t]+" str)
1679 (setq str (substring str (match-end 0))))
1680 ;; Trailing spaces.
1681 (when (string-match "[ \t]+$" str)
1682 (setq str (substring str 0 (match-beginning 0))))
1683 str)
1685 (defun gnus-simplify-all-whitespace (str)
1686 "Remove all whitespace from STR."
1687 (while (string-match "[ \t\n]+" str)
1688 (setq str (replace-match "" nil nil str)))
1689 str)
1691 (defsubst gnus-simplify-subject-re (subject)
1692 "Remove \"Re:\" from subject lines."
1693 (if (string-match message-subject-re-regexp subject)
1694 (substring subject (match-end 0))
1695 subject))
1697 (defun gnus-simplify-subject (subject &optional re-only)
1698 "Remove `Re:' and words in parentheses.
1699 If RE-ONLY is non-nil, strip leading `Re:'s only."
1700 (let ((case-fold-search t)) ;Ignore case.
1701 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1702 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1703 (setq subject (substring subject (match-end 0))))
1704 ;; Remove uninteresting prefixes.
1705 (when (and (not re-only)
1706 gnus-simplify-ignored-prefixes
1707 (string-match gnus-simplify-ignored-prefixes subject))
1708 (setq subject (substring subject (match-end 0))))
1709 ;; Remove words in parentheses from end.
1710 (unless re-only
1711 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1712 (setq subject (substring subject 0 (match-beginning 0)))))
1713 ;; Return subject string.
1714 subject))
1716 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1717 ;; all whitespace.
1718 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1719 (goto-char (point-min))
1720 (while (re-search-forward regexp nil t)
1721 (replace-match (or newtext ""))))
1723 (defun gnus-simplify-buffer-fuzzy ()
1724 "Simplify string in the buffer fuzzily.
1725 The string in the accessible portion of the current buffer is simplified.
1726 It is assumed to be a single-line subject.
1727 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1728 matter is removed. Additional things can be deleted by setting
1729 `gnus-simplify-subject-fuzzy-regexp'."
1730 (let ((case-fold-search t)
1731 (modified-tick))
1732 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1734 (while (not (eq modified-tick (buffer-modified-tick)))
1735 (setq modified-tick (buffer-modified-tick))
1736 (cond
1737 ((listp gnus-simplify-subject-fuzzy-regexp)
1738 (mapc 'gnus-simplify-buffer-fuzzy-step
1739 gnus-simplify-subject-fuzzy-regexp))
1740 (gnus-simplify-subject-fuzzy-regexp
1741 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1742 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1743 (gnus-simplify-buffer-fuzzy-step
1744 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1745 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1747 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1748 (gnus-simplify-buffer-fuzzy-step " +" " ")
1749 (gnus-simplify-buffer-fuzzy-step " $")
1750 (gnus-simplify-buffer-fuzzy-step "^ +")))
1752 (defun gnus-simplify-subject-fuzzy (subject)
1753 "Simplify a subject string fuzzily.
1754 See `gnus-simplify-buffer-fuzzy' for details."
1755 (save-excursion
1756 (gnus-set-work-buffer)
1757 (let ((case-fold-search t))
1758 ;; Remove uninteresting prefixes.
1759 (when (and gnus-simplify-ignored-prefixes
1760 (string-match gnus-simplify-ignored-prefixes subject))
1761 (setq subject (substring subject (match-end 0))))
1762 (insert subject)
1763 (inline (gnus-simplify-buffer-fuzzy))
1764 (buffer-string))))
1766 (defsubst gnus-simplify-subject-fully (subject)
1767 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1768 (cond
1769 (gnus-simplify-subject-functions
1770 (gnus-map-function gnus-simplify-subject-functions subject))
1771 ((null gnus-summary-gather-subject-limit)
1772 (gnus-simplify-subject-re subject))
1773 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1774 (gnus-simplify-subject-fuzzy subject))
1775 ((numberp gnus-summary-gather-subject-limit)
1776 (truncate-string-to-width (gnus-simplify-subject-re subject)
1777 gnus-summary-gather-subject-limit))
1779 subject)))
1781 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1782 "Check whether two subjects are equal.
1783 If optional argument SIMPLE-FIRST is t, first argument is already
1784 simplified."
1785 (cond
1786 ((null simple-first)
1787 (equal (gnus-simplify-subject-fully s1)
1788 (gnus-simplify-subject-fully s2)))
1790 (equal s1
1791 (gnus-simplify-subject-fully s2)))))
1793 (defun gnus-summary-bubble-group ()
1794 "Increase the score of the current group.
1795 This is a handy function to add to `gnus-summary-exit-hook' to
1796 increase the score of each group you read."
1797 (gnus-group-add-score gnus-newsgroup-name))
1801 ;;; Gnus summary mode
1804 (put 'gnus-summary-mode 'mode-class 'special)
1806 (defvar gnus-article-commands-menu)
1808 ;; Non-orthogonal keys
1810 (gnus-define-keys gnus-summary-mode-map
1811 " " gnus-summary-next-page
1812 "\177" gnus-summary-prev-page
1813 [delete] gnus-summary-prev-page
1814 [backspace] gnus-summary-prev-page
1815 "\r" gnus-summary-scroll-up
1816 "\M-\r" gnus-summary-scroll-down
1817 "n" gnus-summary-next-unread-article
1818 "p" gnus-summary-prev-unread-article
1819 "N" gnus-summary-next-article
1820 "P" gnus-summary-prev-article
1821 "\M-\C-n" gnus-summary-next-same-subject
1822 "\M-\C-p" gnus-summary-prev-same-subject
1823 "\M-n" gnus-summary-next-unread-subject
1824 "\M-p" gnus-summary-prev-unread-subject
1825 "." gnus-summary-first-unread-article
1826 "," gnus-summary-best-unread-article
1827 "\M-s" gnus-summary-search-article-forward
1828 "\M-r" gnus-summary-search-article-backward
1829 "\M-S" gnus-summary-repeat-search-article-forward
1830 "\M-R" gnus-summary-repeat-search-article-backward
1831 "<" gnus-summary-beginning-of-article
1832 ">" gnus-summary-end-of-article
1833 "j" gnus-summary-goto-article
1834 "^" gnus-summary-refer-parent-article
1835 "\M-^" gnus-summary-refer-article
1836 "u" gnus-summary-tick-article-forward
1837 "!" gnus-summary-tick-article-forward
1838 "U" gnus-summary-tick-article-backward
1839 "d" gnus-summary-mark-as-read-forward
1840 "D" gnus-summary-mark-as-read-backward
1841 "E" gnus-summary-mark-as-expirable
1842 "\M-u" gnus-summary-clear-mark-forward
1843 "\M-U" gnus-summary-clear-mark-backward
1844 "k" gnus-summary-kill-same-subject-and-select
1845 "\C-k" gnus-summary-kill-same-subject
1846 "\M-\C-k" gnus-summary-kill-thread
1847 "\M-\C-l" gnus-summary-lower-thread
1848 "e" gnus-summary-edit-article
1849 "#" gnus-summary-mark-as-processable
1850 "\M-#" gnus-summary-unmark-as-processable
1851 "\M-\C-t" gnus-summary-toggle-threads
1852 "\M-\C-s" gnus-summary-show-thread
1853 "\M-\C-h" gnus-summary-hide-thread
1854 "\M-\C-f" gnus-summary-next-thread
1855 "\M-\C-b" gnus-summary-prev-thread
1856 [(meta down)] gnus-summary-next-thread
1857 [(meta up)] gnus-summary-prev-thread
1858 "\M-\C-u" gnus-summary-up-thread
1859 "\M-\C-d" gnus-summary-down-thread
1860 "&" gnus-summary-execute-command
1861 "c" gnus-summary-catchup-and-exit
1862 "\C-w" gnus-summary-mark-region-as-read
1863 "\C-t" gnus-summary-toggle-truncation
1864 "?" gnus-summary-mark-as-dormant
1865 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1866 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1867 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1868 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1869 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1870 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1871 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1872 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1873 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1874 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1875 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1876 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1877 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1878 "=" gnus-summary-expand-window
1879 "\C-x\C-s" gnus-summary-reselect-current-group
1880 "\M-g" gnus-summary-rescan-group
1881 "\C-c\C-r" gnus-summary-caesar-message
1882 "f" gnus-summary-followup
1883 "F" gnus-summary-followup-with-original
1884 "C" gnus-summary-cancel-article
1885 "r" gnus-summary-reply
1886 "R" gnus-summary-reply-with-original
1887 "\C-c\C-f" gnus-summary-mail-forward
1888 "o" gnus-summary-save-article
1889 "\C-o" gnus-summary-save-article-mail
1890 "|" gnus-summary-pipe-output
1891 "\M-k" gnus-summary-edit-local-kill
1892 "\M-K" gnus-summary-edit-global-kill
1893 ;; "V" gnus-version
1894 "\C-c\C-d" gnus-summary-describe-group
1895 "q" gnus-summary-exit
1896 "Q" gnus-summary-exit-no-update
1897 "\C-c\C-i" gnus-info-find-node
1898 gnus-mouse-2 gnus-mouse-pick-article
1899 [follow-link] mouse-face
1900 "m" gnus-summary-mail-other-window
1901 "a" gnus-summary-post-news
1902 "x" gnus-summary-limit-to-unread
1903 "s" gnus-summary-isearch-article
1904 "t" gnus-summary-toggle-header
1905 "g" gnus-summary-show-article
1906 "l" gnus-summary-goto-last-article
1907 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1908 "\C-d" gnus-summary-enter-digest-group
1909 "\M-\C-d" gnus-summary-read-document
1910 "\M-\C-e" gnus-summary-edit-parameters
1911 "\M-\C-a" gnus-summary-customize-parameters
1912 "\C-c\C-b" gnus-bug
1913 "*" gnus-cache-enter-article
1914 "\M-*" gnus-cache-remove-article
1915 "\M-&" gnus-summary-universal-argument
1916 "\C-l" gnus-recenter
1917 "I" gnus-summary-increase-score
1918 "L" gnus-summary-lower-score
1919 "\M-i" gnus-symbolic-argument
1920 "h" gnus-summary-select-article-buffer
1922 "b" gnus-article-view-part
1923 "\M-t" gnus-summary-toggle-display-buttonized
1925 "V" gnus-summary-score-map
1926 "X" gnus-uu-extract-map
1927 "S" gnus-summary-send-map)
1929 ;; Sort of orthogonal keymap
1930 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1931 "t" gnus-summary-tick-article-forward
1932 "!" gnus-summary-tick-article-forward
1933 "d" gnus-summary-mark-as-read-forward
1934 "r" gnus-summary-mark-as-read-forward
1935 "c" gnus-summary-clear-mark-forward
1936 " " gnus-summary-clear-mark-forward
1937 "e" gnus-summary-mark-as-expirable
1938 "x" gnus-summary-mark-as-expirable
1939 "?" gnus-summary-mark-as-dormant
1940 "b" gnus-summary-set-bookmark
1941 "B" gnus-summary-remove-bookmark
1942 "#" gnus-summary-mark-as-processable
1943 "\M-#" gnus-summary-unmark-as-processable
1944 "S" gnus-summary-limit-include-expunged
1945 "C" gnus-summary-catchup
1946 "H" gnus-summary-catchup-to-here
1947 "h" gnus-summary-catchup-from-here
1948 "\C-c" gnus-summary-catchup-all
1949 "k" gnus-summary-kill-same-subject-and-select
1950 "K" gnus-summary-kill-same-subject
1951 "P" gnus-uu-mark-map)
1953 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1954 "c" gnus-summary-clear-above
1955 "u" gnus-summary-tick-above
1956 "m" gnus-summary-mark-above
1957 "k" gnus-summary-kill-below)
1959 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1960 "/" gnus-summary-limit-to-subject
1961 "n" gnus-summary-limit-to-articles
1962 "b" gnus-summary-limit-to-bodies
1963 "h" gnus-summary-limit-to-headers
1964 "w" gnus-summary-pop-limit
1965 "s" gnus-summary-limit-to-subject
1966 "a" gnus-summary-limit-to-author
1967 "u" gnus-summary-limit-to-unread
1968 "m" gnus-summary-limit-to-marks
1969 "M" gnus-summary-limit-exclude-marks
1970 "v" gnus-summary-limit-to-score
1971 "*" gnus-summary-limit-include-cached
1972 "D" gnus-summary-limit-include-dormant
1973 "T" gnus-summary-limit-include-thread
1974 "d" gnus-summary-limit-exclude-dormant
1975 "t" gnus-summary-limit-to-age
1976 "." gnus-summary-limit-to-unseen
1977 "x" gnus-summary-limit-to-extra
1978 "p" gnus-summary-limit-to-display-predicate
1979 "E" gnus-summary-limit-include-expunged
1980 "c" gnus-summary-limit-exclude-childless-dormant
1981 "C" gnus-summary-limit-mark-excluded-as-read
1982 "o" gnus-summary-insert-old-articles
1983 "N" gnus-summary-insert-new-articles
1984 "S" gnus-summary-limit-to-singletons
1985 "r" gnus-summary-limit-to-replied
1986 "R" gnus-summary-limit-to-recipient
1987 "A" gnus-summary-limit-to-address)
1989 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1990 "n" gnus-summary-next-unread-article
1991 "p" gnus-summary-prev-unread-article
1992 "N" gnus-summary-next-article
1993 "P" gnus-summary-prev-article
1994 "\C-n" gnus-summary-next-same-subject
1995 "\C-p" gnus-summary-prev-same-subject
1996 "\M-n" gnus-summary-next-unread-subject
1997 "\M-p" gnus-summary-prev-unread-subject
1998 "f" gnus-summary-first-unread-article
1999 "b" gnus-summary-best-unread-article
2000 "j" gnus-summary-goto-article
2001 "g" gnus-summary-goto-subject
2002 "l" gnus-summary-goto-last-article
2003 "o" gnus-summary-pop-article)
2005 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2006 "k" gnus-summary-kill-thread
2007 "E" gnus-summary-expire-thread
2008 "l" gnus-summary-lower-thread
2009 "i" gnus-summary-raise-thread
2010 "T" gnus-summary-toggle-threads
2011 "t" gnus-summary-rethread-current
2012 "^" gnus-summary-reparent-thread
2013 "\M-^" gnus-summary-reparent-children
2014 "s" gnus-summary-show-thread
2015 "S" gnus-summary-show-all-threads
2016 "h" gnus-summary-hide-thread
2017 "H" gnus-summary-hide-all-threads
2018 "n" gnus-summary-next-thread
2019 "p" gnus-summary-prev-thread
2020 "u" gnus-summary-up-thread
2021 "o" gnus-summary-top-thread
2022 "d" gnus-summary-down-thread
2023 "#" gnus-uu-mark-thread
2024 "\M-#" gnus-uu-unmark-thread)
2026 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2027 "g" gnus-summary-prepare
2028 "c" gnus-summary-insert-cached-articles
2029 "d" gnus-summary-insert-dormant-articles
2030 "t" gnus-summary-insert-ticked-articles)
2032 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2033 "c" gnus-summary-catchup-and-exit
2034 "C" gnus-summary-catchup-all-and-exit
2035 "E" gnus-summary-exit-no-update
2036 "Q" gnus-summary-exit
2037 "Z" gnus-summary-exit
2038 "n" gnus-summary-catchup-and-goto-next-group
2039 "p" gnus-summary-catchup-and-goto-prev-group
2040 "R" gnus-summary-reselect-current-group
2041 "G" gnus-summary-rescan-group
2042 "N" gnus-summary-next-group
2043 "s" gnus-summary-save-newsrc
2044 "P" gnus-summary-prev-group)
2046 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2047 " " gnus-summary-next-page
2048 "n" gnus-summary-next-page
2049 "\177" gnus-summary-prev-page
2050 [delete] gnus-summary-prev-page
2051 "p" gnus-summary-prev-page
2052 "\r" gnus-summary-scroll-up
2053 "\M-\r" gnus-summary-scroll-down
2054 "<" gnus-summary-beginning-of-article
2055 ">" gnus-summary-end-of-article
2056 "b" gnus-summary-beginning-of-article
2057 "e" gnus-summary-end-of-article
2058 "^" gnus-summary-refer-parent-article
2059 "r" gnus-summary-refer-parent-article
2060 "C" gnus-summary-show-complete-article
2061 "D" gnus-summary-enter-digest-group
2062 "R" gnus-summary-refer-references
2063 "T" gnus-summary-refer-thread
2064 "g" gnus-summary-show-article
2065 "s" gnus-summary-isearch-article
2066 "P" gnus-summary-print-article
2067 "S" gnus-sticky-article
2068 "M" gnus-mailing-list-insinuate
2069 "t" gnus-article-babel)
2071 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2072 "b" gnus-article-add-buttons
2073 "B" gnus-article-add-buttons-to-head
2074 "o" gnus-article-treat-overstrike
2075 "e" gnus-article-emphasize
2076 "w" gnus-article-fill-cited-article
2077 "Q" gnus-article-fill-long-lines
2078 "L" gnus-article-toggle-truncate-lines
2079 "C" gnus-article-capitalize-sentences
2080 "c" gnus-article-remove-cr
2081 "q" gnus-article-de-quoted-unreadable
2082 "6" gnus-article-de-base64-unreadable
2083 "Z" gnus-article-decode-HZ
2084 "A" gnus-article-treat-ansi-sequences
2085 "h" gnus-article-wash-html
2086 "u" gnus-article-unsplit-urls
2087 "s" gnus-summary-force-verify-and-decrypt
2088 "f" gnus-article-display-x-face
2089 "l" gnus-summary-stop-page-breaking
2090 "r" gnus-summary-caesar-message
2091 "m" gnus-summary-morse-message
2092 "t" gnus-summary-toggle-header
2093 "g" gnus-treat-smiley
2094 "v" gnus-summary-verbose-headers
2095 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2096 "p" gnus-article-verify-x-pgp-sig
2097 "d" gnus-article-treat-dumbquotes
2098 "i" gnus-summary-idna-message)
2100 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2101 ;; mnemonic: deuglif*Y*
2102 "u" gnus-article-outlook-unwrap-lines
2103 "a" gnus-article-outlook-repair-attribution
2104 "c" gnus-article-outlook-rearrange-citation
2105 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2107 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2108 "a" gnus-article-hide
2109 "h" gnus-article-hide-headers
2110 "b" gnus-article-hide-boring-headers
2111 "s" gnus-article-hide-signature
2112 "c" gnus-article-hide-citation
2113 "C" gnus-article-hide-citation-in-followups
2114 "l" gnus-article-hide-list-identifiers
2115 "B" gnus-article-strip-banner
2116 "P" gnus-article-hide-pem
2117 "\C-c" gnus-article-hide-citation-maybe)
2119 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2120 "a" gnus-article-highlight
2121 "h" gnus-article-highlight-headers
2122 "c" gnus-article-highlight-citation
2123 "s" gnus-article-highlight-signature)
2125 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2126 "f" gnus-article-treat-fold-headers
2127 "u" gnus-article-treat-unfold-headers
2128 "n" gnus-article-treat-fold-newsgroups)
2130 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2131 "x" gnus-article-display-x-face
2132 "d" gnus-article-display-face
2133 "s" gnus-treat-smiley
2134 "D" gnus-article-remove-images
2135 "W" gnus-html-show-images
2136 "f" gnus-treat-from-picon
2137 "m" gnus-treat-mail-picon
2138 "n" gnus-treat-newsgroups-picon
2139 "g" gnus-treat-from-gravatar
2140 "h" gnus-treat-mail-gravatar)
2142 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2143 "w" gnus-article-decode-mime-words
2144 "c" gnus-article-decode-charset
2145 "v" gnus-mime-view-all-parts
2146 "b" gnus-article-view-part)
2148 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2149 "z" gnus-article-date-ut
2150 "u" gnus-article-date-ut
2151 "l" gnus-article-date-local
2152 "p" gnus-article-date-english
2153 "e" gnus-article-date-lapsed
2154 "o" gnus-article-date-original
2155 "i" gnus-article-date-iso8601
2156 "s" gnus-article-date-user)
2158 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2159 "t" gnus-article-remove-trailing-blank-lines
2160 "l" gnus-article-strip-leading-blank-lines
2161 "m" gnus-article-strip-multiple-blank-lines
2162 "a" gnus-article-strip-blank-lines
2163 "A" gnus-article-strip-all-blank-lines
2164 "s" gnus-article-strip-leading-space
2165 "e" gnus-article-strip-trailing-space
2166 "w" gnus-article-remove-leading-whitespace)
2168 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2169 "v" gnus-version
2170 "d" gnus-summary-describe-group
2171 "h" gnus-summary-describe-briefly
2172 "i" gnus-info-find-node
2173 "C" gnus-group-fetch-control)
2175 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2176 "e" gnus-summary-expire-articles
2177 "\M-\C-e" gnus-summary-expire-articles-now
2178 "\177" gnus-summary-delete-article
2179 [delete] gnus-summary-delete-article
2180 [backspace] gnus-summary-delete-article
2181 "m" gnus-summary-move-article
2182 "r" gnus-summary-respool-article
2183 "w" gnus-summary-edit-article
2184 "c" gnus-summary-copy-article
2185 "B" gnus-summary-crosspost-article
2186 "q" gnus-summary-respool-query
2187 "t" gnus-summary-respool-trace
2188 "i" gnus-summary-import-article
2189 "I" gnus-summary-create-article
2190 "p" gnus-summary-article-posted-p)
2192 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2193 "o" gnus-summary-save-article
2194 "m" gnus-summary-save-article-mail
2195 "F" gnus-summary-write-article-file
2196 "r" gnus-summary-save-article-rmail
2197 "f" gnus-summary-save-article-file
2198 "b" gnus-summary-save-article-body-file
2199 "B" gnus-summary-write-article-body-file
2200 "h" gnus-summary-save-article-folder
2201 "v" gnus-summary-save-article-vm
2202 "p" gnus-summary-pipe-output
2203 "P" gnus-summary-muttprint)
2205 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2206 "b" gnus-summary-display-buttonized
2207 "m" gnus-summary-repair-multipart
2208 "v" gnus-article-view-part
2209 "o" gnus-article-save-part
2210 "O" gnus-article-save-part-and-strip
2211 "r" gnus-article-replace-part
2212 "d" gnus-article-delete-part
2213 "t" gnus-article-view-part-as-type
2214 "j" gnus-article-jump-to-part
2215 "c" gnus-article-copy-part
2216 "C" gnus-article-view-part-as-charset
2217 "e" gnus-article-view-part-externally
2218 "H" gnus-article-browse-html-article
2219 "E" gnus-article-encrypt-body
2220 "i" gnus-article-inline-part
2221 "|" gnus-article-pipe-part)
2223 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2224 "p" gnus-summary-mark-as-processable
2225 "u" gnus-summary-unmark-as-processable
2226 "U" gnus-summary-unmark-all-processable
2227 "v" gnus-uu-mark-over
2228 "s" gnus-uu-mark-series
2229 "r" gnus-uu-mark-region
2230 "g" gnus-uu-unmark-region
2231 "R" gnus-uu-mark-by-regexp
2232 "G" gnus-uu-unmark-by-regexp
2233 "t" gnus-uu-mark-thread
2234 "T" gnus-uu-unmark-thread
2235 "a" gnus-uu-mark-all
2236 "b" gnus-uu-mark-buffer
2237 "S" gnus-uu-mark-sparse
2238 "k" gnus-summary-kill-process-mark
2239 "y" gnus-summary-yank-process-mark
2240 "w" gnus-summary-save-process-mark
2241 "i" gnus-uu-invert-processable)
2243 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2244 ;;"x" gnus-uu-extract-any
2245 "m" gnus-summary-save-parts
2246 "u" gnus-uu-decode-uu
2247 "U" gnus-uu-decode-uu-and-save
2248 "s" gnus-uu-decode-unshar
2249 "S" gnus-uu-decode-unshar-and-save
2250 "o" gnus-uu-decode-save
2251 "O" gnus-uu-decode-save
2252 "b" gnus-uu-decode-binhex
2253 "B" gnus-uu-decode-binhex
2254 "Y" gnus-uu-decode-yenc
2255 "p" gnus-uu-decode-postscript
2256 "P" gnus-uu-decode-postscript-and-save)
2258 (gnus-define-keys
2259 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2260 "u" gnus-uu-decode-uu-view
2261 "U" gnus-uu-decode-uu-and-save-view
2262 "s" gnus-uu-decode-unshar-view
2263 "S" gnus-uu-decode-unshar-and-save-view
2264 "o" gnus-uu-decode-save-view
2265 "O" gnus-uu-decode-save-view
2266 "b" gnus-uu-decode-binhex-view
2267 "B" gnus-uu-decode-binhex-view
2268 "p" gnus-uu-decode-postscript-view
2269 "P" gnus-uu-decode-postscript-and-save-view)
2271 (defvar gnus-article-post-menu nil)
2273 (defconst gnus-summary-menu-maxlen 20)
2275 (defun gnus-summary-menu-split (menu)
2276 ;; If we have lots of elements, divide them into groups of 20
2277 ;; and make a pane (or submenu) for each one.
2278 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2279 (let ((menu menu) sublists next
2280 (i 1))
2281 (while menu
2282 ;; Pull off the next gnus-summary-menu-maxlen elements
2283 ;; and make them the next element of sublist.
2284 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2285 (if next
2286 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2287 nil))
2288 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2289 (aref (car (last menu)) 0)) menu)
2290 sublists))
2291 (setq i (1+ i))
2292 (setq menu next))
2293 (nreverse sublists))
2294 ;; Few elements--put them all in one pane.
2295 menu))
2297 (defun gnus-summary-make-menu-bar ()
2298 (gnus-turn-off-edit-menu 'summary)
2300 (unless (boundp 'gnus-summary-misc-menu)
2302 (easy-menu-define
2303 gnus-summary-kill-menu gnus-summary-mode-map ""
2304 (cons
2305 "Score"
2306 (nconc
2307 (list
2308 ["Customize" gnus-score-customize t])
2309 (gnus-make-score-map 'increase)
2310 (gnus-make-score-map 'lower)
2311 '(("Mark"
2312 ["Kill below" gnus-summary-kill-below t]
2313 ["Mark above" gnus-summary-mark-above t]
2314 ["Tick above" gnus-summary-tick-above t]
2315 ["Clear above" gnus-summary-clear-above t])
2316 ["Current score" gnus-summary-current-score t]
2317 ["Set score" gnus-summary-set-score t]
2318 ["Switch current score file..." gnus-score-change-score-file t]
2319 ["Set mark below..." gnus-score-set-mark-below t]
2320 ["Set expunge below..." gnus-score-set-expunge-below t]
2321 ["Edit current score file" gnus-score-edit-current-scores t]
2322 ["Edit score file..." gnus-score-edit-file t]
2323 ["Trace score" gnus-score-find-trace t]
2324 ["Find words" gnus-score-find-favourite-words t]
2325 ["Rescore buffer" gnus-summary-rescore t]
2326 ["Increase score..." gnus-summary-increase-score t]
2327 ["Lower score..." gnus-summary-lower-score t]))))
2329 ;; Define both the Article menu in the summary buffer and the
2330 ;; equivalent Commands menu in the article buffer here for
2331 ;; consistency.
2332 (let ((innards
2333 `(("Hide"
2334 ["All" gnus-article-hide t]
2335 ["Headers" gnus-article-hide-headers t]
2336 ["Signature" gnus-article-hide-signature t]
2337 ["Citation" gnus-article-hide-citation t]
2338 ["List identifiers" gnus-article-hide-list-identifiers t]
2339 ["Banner" gnus-article-strip-banner t]
2340 ["Boring headers" gnus-article-hide-boring-headers t])
2341 ("Highlight"
2342 ["All" gnus-article-highlight t]
2343 ["Headers" gnus-article-highlight-headers t]
2344 ["Signature" gnus-article-highlight-signature t]
2345 ["Citation" gnus-article-highlight-citation t])
2346 ("MIME"
2347 ["Words" gnus-article-decode-mime-words t]
2348 ["Charset" gnus-article-decode-charset t]
2349 ["QP" gnus-article-de-quoted-unreadable t]
2350 ["Base64" gnus-article-de-base64-unreadable t]
2351 ["View MIME buttons" gnus-summary-display-buttonized t]
2352 ["View all" gnus-mime-view-all-parts t]
2353 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2354 ["Encrypt body" gnus-article-encrypt-body
2355 :active (not (gnus-group-read-only-p))
2356 ,@(if (featurep 'xemacs) nil
2357 '(:help "Encrypt the message body on disk"))]
2358 ["Extract all parts..." gnus-summary-save-parts t]
2359 ("Multipart"
2360 ["Repair multipart" gnus-summary-repair-multipart t]
2361 ["Pipe part..." gnus-article-pipe-part t]
2362 ["Inline part" gnus-article-inline-part t]
2363 ["View part as type..." gnus-article-view-part-as-type t]
2364 ["Encrypt body" gnus-article-encrypt-body
2365 :active (not (gnus-group-read-only-p))
2366 ,@(if (featurep 'xemacs) nil
2367 '(:help "Encrypt the message body on disk"))]
2368 ["View part externally" gnus-article-view-part-externally t]
2369 ["View HTML parts in browser" gnus-article-browse-html-article t]
2370 ["View part with charset..." gnus-article-view-part-as-charset t]
2371 ["Copy part" gnus-article-copy-part t]
2372 ["Save part..." gnus-article-save-part t]
2373 ["View part" gnus-article-view-part t]))
2374 ("Date"
2375 ["Local" gnus-article-date-local t]
2376 ["ISO8601" gnus-article-date-iso8601 t]
2377 ["UT" gnus-article-date-ut t]
2378 ["Original" gnus-article-date-original t]
2379 ["Lapsed" gnus-article-date-lapsed t]
2380 ["User-defined" gnus-article-date-user t])
2381 ("Display"
2382 ["Remove images" gnus-article-remove-images t]
2383 ["Toggle smiley" gnus-treat-smiley t]
2384 ["Show X-Face" gnus-article-display-x-face t]
2385 ["Show picons in From" gnus-treat-from-picon t]
2386 ["Show picons in mail headers" gnus-treat-mail-picon t]
2387 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2388 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2389 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2390 ("View as different encoding"
2391 ,@(gnus-summary-menu-split
2392 (mapcar
2393 (lambda (cs)
2394 ;; Since easymenu under Emacs doesn't allow
2395 ;; lambda forms for menu commands, we should
2396 ;; provide intern'ed function symbols.
2397 (let ((command (intern (format "\
2398 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2399 (fset command
2400 `(lambda ()
2401 (interactive)
2402 (let ((gnus-summary-show-article-charset-alist
2403 '((1 . ,cs))))
2404 (gnus-summary-show-article 1))))
2405 `[,(symbol-name cs) ,command t]))
2406 (sort (if (fboundp 'coding-system-list)
2407 (coding-system-list)
2408 (mapcar 'car mm-mime-mule-charset-alist))
2409 'string<)))))
2410 ("Washing"
2411 ("Remove Blanks"
2412 ["Leading" gnus-article-strip-leading-blank-lines t]
2413 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2414 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2415 ["All of the above" gnus-article-strip-blank-lines t]
2416 ["All" gnus-article-strip-all-blank-lines t]
2417 ["Leading space" gnus-article-strip-leading-space t]
2418 ["Trailing space" gnus-article-strip-trailing-space t]
2419 ["Leading space in headers"
2420 gnus-article-remove-leading-whitespace t])
2421 ["Overstrike" gnus-article-treat-overstrike t]
2422 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2423 ["Emphasis" gnus-article-emphasize t]
2424 ["Word wrap" gnus-article-fill-cited-article t]
2425 ["Fill long lines" gnus-article-fill-long-lines t]
2426 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2427 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2428 ["Remove CR" gnus-article-remove-cr t]
2429 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2430 ["Base64" gnus-article-de-base64-unreadable t]
2431 ["Rot 13" gnus-summary-caesar-message
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "\"Caesar rotate\" article by 13"))]
2434 ["De-IDNA" gnus-summary-idna-message t]
2435 ["Morse decode" gnus-summary-morse-message t]
2436 ["Unix pipe..." gnus-summary-pipe-message t]
2437 ["Add buttons" gnus-article-add-buttons t]
2438 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2439 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2440 ["Verbose header" gnus-summary-verbose-headers t]
2441 ["Toggle header" gnus-summary-toggle-header t]
2442 ["Unfold headers" gnus-article-treat-unfold-headers t]
2443 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2444 ["Html" gnus-article-wash-html t]
2445 ["Unsplit URLs" gnus-article-unsplit-urls t]
2446 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2447 ["Decode HZ" gnus-article-decode-HZ t]
2448 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2449 ("(Outlook) Deuglify"
2450 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2451 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2452 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2453 ["Full (Outlook) deuglify"
2454 gnus-article-outlook-deuglify-article t])
2456 ("Output"
2457 ["Save in default format..." gnus-summary-save-article
2458 ,@(if (featurep 'xemacs) '(t)
2459 '(:help "Save article using default method"))]
2460 ["Save in file..." gnus-summary-save-article-file
2461 ,@(if (featurep 'xemacs) '(t)
2462 '(:help "Save article in file"))]
2463 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2464 ["Save in MH folder..." gnus-summary-save-article-folder t]
2465 ["Save in VM folder..." gnus-summary-save-article-vm t]
2466 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2467 ["Save body in file..." gnus-summary-save-article-body-file t]
2468 ["Pipe through a filter..." gnus-summary-pipe-output t]
2469 ["Print with Muttprint..." gnus-summary-muttprint t]
2470 ["Print" gnus-summary-print-article
2471 ,@(if (featurep 'xemacs) '(t)
2472 '(:help "Generate and print a PostScript image"))])
2473 ("Copy, move,... (Backend)"
2474 ,@(if (featurep 'xemacs) nil
2475 '(:help "Copying, moving, expiring articles..."))
2476 ["Respool article..." gnus-summary-respool-article t]
2477 ["Move article..." gnus-summary-move-article
2478 (gnus-check-backend-function
2479 'request-move-article gnus-newsgroup-name)]
2480 ["Copy article..." gnus-summary-copy-article t]
2481 ["Crosspost article..." gnus-summary-crosspost-article
2482 (gnus-check-backend-function
2483 'request-replace-article gnus-newsgroup-name)]
2484 ["Import file..." gnus-summary-import-article
2485 (gnus-check-backend-function
2486 'request-accept-article gnus-newsgroup-name)]
2487 ["Create article..." gnus-summary-create-article
2488 (gnus-check-backend-function
2489 'request-accept-article gnus-newsgroup-name)]
2490 ["Check if posted" gnus-summary-article-posted-p t]
2491 ["Edit article" gnus-summary-edit-article
2492 (not (gnus-group-read-only-p))]
2493 ["Delete article" gnus-summary-delete-article
2494 (gnus-check-backend-function
2495 'request-expire-articles gnus-newsgroup-name)]
2496 ["Query respool" gnus-summary-respool-query t]
2497 ["Trace respool" gnus-summary-respool-trace t]
2498 ["Delete expirable articles" gnus-summary-expire-articles-now
2499 (gnus-check-backend-function
2500 'request-expire-articles gnus-newsgroup-name)])
2501 ("Extract"
2502 ["Uudecode" gnus-uu-decode-uu
2503 ,@(if (featurep 'xemacs) '(t)
2504 '(:help "Decode uuencoded article(s)"))]
2505 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2506 ["Unshar" gnus-uu-decode-unshar t]
2507 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2508 ["Save" gnus-uu-decode-save t]
2509 ["Binhex" gnus-uu-decode-binhex t]
2510 ["Postscript" gnus-uu-decode-postscript t]
2511 ["All MIME parts" gnus-summary-save-parts t])
2512 ("Cache"
2513 ["Enter article" gnus-cache-enter-article t]
2514 ["Remove article" gnus-cache-remove-article t])
2515 ["Translate" gnus-article-babel t]
2516 ["Select article buffer" gnus-summary-select-article-buffer t]
2517 ["Make article buffer sticky" gnus-sticky-article t]
2518 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2519 ["Isearch article..." gnus-summary-isearch-article t]
2520 ["Beginning of the article" gnus-summary-beginning-of-article t]
2521 ["End of the article" gnus-summary-end-of-article t]
2522 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2523 ["Fetch referenced articles" gnus-summary-refer-references t]
2524 ["Fetch current thread" gnus-summary-refer-thread t]
2525 ["Fetch article with id..." gnus-summary-refer-article t]
2526 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2527 ["Redisplay" gnus-summary-show-article t]
2528 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2529 (easy-menu-define
2530 gnus-summary-article-menu gnus-summary-mode-map ""
2531 (cons "Article" innards))
2533 (if (not (keymapp gnus-summary-article-menu))
2534 (easy-menu-define
2535 gnus-article-commands-menu gnus-article-mode-map ""
2536 (cons "Commands" innards))
2537 ;; in Emacs, don't share menu.
2538 (setq gnus-article-commands-menu
2539 (copy-keymap gnus-summary-article-menu))
2540 (define-key gnus-article-mode-map [menu-bar commands]
2541 (cons "Commands" gnus-article-commands-menu))))
2543 (easy-menu-define
2544 gnus-summary-thread-menu gnus-summary-mode-map ""
2545 '("Threads"
2546 ["Find all messages in thread" gnus-summary-refer-thread t]
2547 ["Toggle threading" gnus-summary-toggle-threads t]
2548 ["Hide threads" gnus-summary-hide-all-threads t]
2549 ["Show threads" gnus-summary-show-all-threads t]
2550 ["Hide thread" gnus-summary-hide-thread t]
2551 ["Show thread" gnus-summary-show-thread t]
2552 ["Go to next thread" gnus-summary-next-thread t]
2553 ["Go to previous thread" gnus-summary-prev-thread t]
2554 ["Go down thread" gnus-summary-down-thread t]
2555 ["Go up thread" gnus-summary-up-thread t]
2556 ["Top of thread" gnus-summary-top-thread t]
2557 ["Mark thread as read" gnus-summary-kill-thread t]
2558 ["Mark thread as expired" gnus-summary-expire-thread t]
2559 ["Lower thread score" gnus-summary-lower-thread t]
2560 ["Raise thread score" gnus-summary-raise-thread t]
2561 ["Rethread current" gnus-summary-rethread-current t]))
2563 (easy-menu-define
2564 gnus-summary-post-menu gnus-summary-mode-map ""
2565 `("Post"
2566 ["Send a message (mail or news)" gnus-summary-post-news
2567 ,@(if (featurep 'xemacs) '(t)
2568 '(:help "Compose a new message (mail or news)"))]
2569 ["Followup" gnus-summary-followup
2570 ,@(if (featurep 'xemacs) '(t)
2571 '(:help "Post followup to this article"))]
2572 ["Followup and yank" gnus-summary-followup-with-original
2573 ,@(if (featurep 'xemacs) '(t)
2574 '(:help "Post followup to this article, quoting its contents"))]
2575 ["Supersede article" gnus-summary-supersede-article t]
2576 ["Cancel article" gnus-summary-cancel-article
2577 ,@(if (featurep 'xemacs) '(t)
2578 '(:help "Cancel an article you posted"))]
2579 ["Reply" gnus-summary-reply t]
2580 ["Reply and yank" gnus-summary-reply-with-original t]
2581 ["Wide reply" gnus-summary-wide-reply t]
2582 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Mail a reply, quoting this article"))]
2585 ["Very wide reply" gnus-summary-very-wide-reply t]
2586 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2587 ,@(if (featurep 'xemacs) '(t)
2588 '(:help "Mail a very wide reply, quoting this article"))]
2589 ["Mail forward" gnus-summary-mail-forward t]
2590 ["Post forward" gnus-summary-post-forward t]
2591 ["Digest and mail" gnus-uu-digest-mail-forward t]
2592 ["Digest and post" gnus-uu-digest-post-forward t]
2593 ["Resend message" gnus-summary-resend-message t]
2594 ["Resend message edit" gnus-summary-resend-message-edit t]
2595 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2596 ["Send a mail" gnus-summary-mail-other-window t]
2597 ["Create a local message" gnus-summary-news-other-window t]
2598 ["Uuencode and post" gnus-uu-post-news
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Post a uuencoded article"))]
2601 ["Followup via news" gnus-summary-followup-to-mail t]
2602 ["Followup via news and yank"
2603 gnus-summary-followup-to-mail-with-original t]
2604 ["Strip signature on reply"
2605 (lambda ()
2606 (interactive)
2607 (if (not (memq message-cite-function
2608 '(message-cite-original-without-signature
2609 message-cite-original)))
2610 ;; Stupid workaround for XEmacs not honoring :visible.
2611 (message "Can't toggle this value of `message-cite-function'")
2612 (setq message-cite-function
2613 (if (eq message-cite-function
2614 'message-cite-original-without-signature)
2615 'message-cite-original
2616 'message-cite-original-without-signature))))
2617 ;; XEmacs barfs on :visible.
2618 ,@(if (featurep 'xemacs) nil
2619 '(:visible (memq message-cite-function
2620 '(message-cite-original-without-signature
2621 message-cite-original))))
2622 :style toggle
2623 :selected (eq message-cite-function
2624 'message-cite-original-without-signature)
2625 ,@(if (featurep 'xemacs) nil
2626 '(:help "Strip signature from cited article when replying."))]
2627 ;;("Draft"
2628 ;;["Send" gnus-summary-send-draft t]
2629 ;;["Send bounced" gnus-resend-bounced-mail t])
2632 (cond
2633 ((not (keymapp gnus-summary-post-menu))
2634 (setq gnus-article-post-menu gnus-summary-post-menu))
2635 ((not gnus-article-post-menu)
2636 ;; Don't share post menu.
2637 (setq gnus-article-post-menu
2638 (copy-keymap gnus-summary-post-menu))))
2639 (define-key gnus-article-mode-map [menu-bar post]
2640 (cons "Post" gnus-article-post-menu))
2642 (easy-menu-define
2643 gnus-summary-misc-menu gnus-summary-mode-map ""
2644 `("Gnus"
2645 ("Mark Read"
2646 ["Mark as read" gnus-summary-mark-as-read-forward t]
2647 ["Mark same subject and select"
2648 gnus-summary-kill-same-subject-and-select t]
2649 ["Mark same subject" gnus-summary-kill-same-subject t]
2650 ["Catchup" gnus-summary-catchup
2651 ,@(if (featurep 'xemacs) '(t)
2652 '(:help "Mark unread articles in this group as read"))]
2653 ["Catchup all" gnus-summary-catchup-all t]
2654 ["Catchup to here" gnus-summary-catchup-to-here t]
2655 ["Catchup from here" gnus-summary-catchup-from-here t]
2656 ["Catchup region" gnus-summary-mark-region-as-read
2657 (gnus-mark-active-p)]
2658 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2659 ("Mark Various"
2660 ["Tick" gnus-summary-tick-article-forward t]
2661 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2662 ["Remove marks" gnus-summary-clear-mark-forward t]
2663 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2664 ["Set bookmark" gnus-summary-set-bookmark t]
2665 ["Remove bookmark" gnus-summary-remove-bookmark t])
2666 ("Limit to"
2667 ["Marks..." gnus-summary-limit-to-marks t]
2668 ["Subject..." gnus-summary-limit-to-subject t]
2669 ["Author..." gnus-summary-limit-to-author t]
2670 ["Recipient..." gnus-summary-limit-to-recipient t]
2671 ["Address..." gnus-summary-limit-to-address t]
2672 ["Age..." gnus-summary-limit-to-age t]
2673 ["Extra..." gnus-summary-limit-to-extra t]
2674 ["Score..." gnus-summary-limit-to-score t]
2675 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2676 ["Unread" gnus-summary-limit-to-unread t]
2677 ["Unseen" gnus-summary-limit-to-unseen t]
2678 ["Singletons" gnus-summary-limit-to-singletons t]
2679 ["Replied" gnus-summary-limit-to-replied t]
2680 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2681 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2682 ["Pop limit" gnus-summary-pop-limit t]
2683 ["Show dormant" gnus-summary-limit-include-dormant t]
2684 ["Hide childless dormant"
2685 gnus-summary-limit-exclude-childless-dormant t]
2686 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2687 ["Hide marked" gnus-summary-limit-exclude-marks t]
2688 ["Show expunged" gnus-summary-limit-include-expunged t])
2689 ("Process Mark"
2690 ["Set mark" gnus-summary-mark-as-processable t]
2691 ["Remove mark" gnus-summary-unmark-as-processable t]
2692 ["Remove all marks" gnus-summary-unmark-all-processable t]
2693 ["Invert marks" gnus-uu-invert-processable t]
2694 ["Mark above" gnus-uu-mark-over t]
2695 ["Mark series" gnus-uu-mark-series t]
2696 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2697 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2698 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2699 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2700 ["Mark all" gnus-uu-mark-all t]
2701 ["Mark buffer" gnus-uu-mark-buffer t]
2702 ["Mark sparse" gnus-uu-mark-sparse t]
2703 ["Mark thread" gnus-uu-mark-thread t]
2704 ["Unmark thread" gnus-uu-unmark-thread t]
2705 ("Process Mark Sets"
2706 ["Kill" gnus-summary-kill-process-mark t]
2707 ["Yank" gnus-summary-yank-process-mark
2708 gnus-newsgroup-process-stack]
2709 ["Save" gnus-summary-save-process-mark t]
2710 ["Run command on marked..." gnus-summary-universal-argument t]))
2711 ("Registry Marks")
2712 ("Scroll article"
2713 ["Page forward" gnus-summary-next-page
2714 ,@(if (featurep 'xemacs) '(t)
2715 '(:help "Show next page of article"))]
2716 ["Page backward" gnus-summary-prev-page
2717 ,@(if (featurep 'xemacs) '(t)
2718 '(:help "Show previous page of article"))]
2719 ["Line forward" gnus-summary-scroll-up t])
2720 ("Move"
2721 ["Next unread article" gnus-summary-next-unread-article t]
2722 ["Previous unread article" gnus-summary-prev-unread-article t]
2723 ["Next article" gnus-summary-next-article t]
2724 ["Previous article" gnus-summary-prev-article t]
2725 ["Next unread subject" gnus-summary-next-unread-subject t]
2726 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2727 ["Next article same subject" gnus-summary-next-same-subject t]
2728 ["Previous article same subject" gnus-summary-prev-same-subject t]
2729 ["First unread article" gnus-summary-first-unread-article t]
2730 ["Best unread article" gnus-summary-best-unread-article t]
2731 ["Go to subject number..." gnus-summary-goto-subject t]
2732 ["Go to article number..." gnus-summary-goto-article t]
2733 ["Go to the last article" gnus-summary-goto-last-article t]
2734 ["Pop article off history" gnus-summary-pop-article t])
2735 ("Sort"
2736 ["Sort by number" gnus-summary-sort-by-number t]
2737 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2738 ["Sort by author" gnus-summary-sort-by-author t]
2739 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2740 ["Sort by subject" gnus-summary-sort-by-subject t]
2741 ["Sort by date" gnus-summary-sort-by-date t]
2742 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2743 ["Sort by score" gnus-summary-sort-by-score t]
2744 ["Sort by lines" gnus-summary-sort-by-lines t]
2745 ["Sort by characters" gnus-summary-sort-by-chars t]
2746 ["Randomize" gnus-summary-sort-by-random t]
2747 ["Original sort" gnus-summary-sort-by-original t])
2748 ("Help"
2749 ["Describe group" gnus-summary-describe-group t]
2750 ["Fetch control message" gnus-group-fetch-control
2751 ,@(if (featurep 'xemacs) nil
2752 '(:help "Display the archived control message for the current group"))]
2753 ["Read manual" gnus-info-find-node t])
2754 ("Modes"
2755 ["Pick and read" gnus-pick-mode t]
2756 ["Binary" gnus-binary-mode t])
2757 ("Regeneration"
2758 ["Regenerate" gnus-summary-prepare t]
2759 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2760 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2761 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2762 ["Toggle threading" gnus-summary-toggle-threads t])
2763 ["See old articles" gnus-summary-insert-old-articles t]
2764 ["See new articles" gnus-summary-insert-new-articles t]
2765 ["Filter articles..." gnus-summary-execute-command t]
2766 ["Run command on articles..." gnus-summary-universal-argument t]
2767 ["Search articles forward..." gnus-summary-search-article-forward t]
2768 ["Search articles backward..." gnus-summary-search-article-backward t]
2769 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2770 ["Expand window" gnus-summary-expand-window t]
2771 ["Expire expirable articles" gnus-summary-expire-articles
2772 (gnus-check-backend-function
2773 'request-expire-articles gnus-newsgroup-name)]
2774 ["Edit local kill file" gnus-summary-edit-local-kill t]
2775 ["Edit main kill file" gnus-summary-edit-global-kill t]
2776 ["Edit group parameters" gnus-summary-edit-parameters t]
2777 ["Customize group parameters" gnus-summary-customize-parameters t]
2778 ["Send a bug report" gnus-bug t]
2779 ("Exit"
2780 ["Catchup and exit" gnus-summary-catchup-and-exit
2781 ,@(if (featurep 'xemacs) '(t)
2782 '(:help "Mark unread articles in this group as read, then exit"))]
2783 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2784 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2785 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2786 ["Exit group" gnus-summary-exit
2787 ,@(if (featurep 'xemacs) '(t)
2788 '(:help "Exit current group, return to group selection mode"))]
2789 ["Exit group without updating" gnus-summary-exit-no-update t]
2790 ["Exit and goto next group" gnus-summary-next-group t]
2791 ["Exit and goto prev group" gnus-summary-prev-group t]
2792 ["Reselect group" gnus-summary-reselect-current-group t]
2793 ["Rescan group" gnus-summary-rescan-group t]
2794 ["Update dribble" gnus-summary-save-newsrc t])))
2796 (gnus-run-hooks 'gnus-summary-menu-hook)))
2798 (defvar gnus-summary-tool-bar-map nil)
2800 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2801 ;; affect _new_ message buffers. We might add a function that walks thru all
2802 ;; summary-mode buffers and force the update.
2803 (defun gnus-summary-tool-bar-update (&optional symbol value)
2804 "Update summary mode toolbar.
2805 Setter function for custom variables."
2806 (setq-default gnus-summary-tool-bar-map nil)
2807 (when symbol
2808 ;; When used as ":set" function:
2809 (set-default symbol value))
2810 (when (gnus-buffer-live-p gnus-summary-buffer)
2811 (with-current-buffer gnus-summary-buffer
2812 (gnus-summary-make-tool-bar))))
2814 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2815 'gnus-summary-tool-bar-gnome
2816 'gnus-summary-tool-bar-retro)
2817 "Specifies the Gnus summary tool bar.
2819 It can be either a list or a symbol refering to a list. See
2820 `gmm-tool-bar-from-list' for the format of the list. The
2821 default key map is `gnus-summary-mode-map'.
2823 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2824 `gnus-summary-tool-bar-retro'."
2825 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2826 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2827 (repeat :tag "User defined list" gmm-tool-bar-item)
2828 (symbol))
2829 :version "23.1" ;; No Gnus
2830 :initialize 'custom-initialize-default
2831 :set 'gnus-summary-tool-bar-update
2832 :group 'gnus-summary)
2834 (defcustom gnus-summary-tool-bar-gnome
2835 '((gnus-summary-post-news "mail/compose" nil)
2836 (gnus-summary-insert-new-articles "mail/inbox" nil
2837 :visible (or (not gnus-agent)
2838 gnus-plugged))
2839 (gnus-summary-reply-with-original "mail/reply")
2840 (gnus-summary-reply "mail/reply" nil :visible nil)
2841 (gnus-summary-followup-with-original "mail/reply-all")
2842 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2843 (gnus-summary-mail-forward "mail/forward")
2844 (gnus-summary-save-article "mail/save")
2845 (gnus-summary-search-article-forward "search" nil :visible nil)
2846 (gnus-summary-print-article "print")
2847 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2848 ;; Some new commands that may need more suitable icons:
2849 (gnus-summary-save-newsrc "save" nil :visible nil)
2850 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2851 (gnus-summary-prev-article "left-arrow")
2852 (gnus-summary-next-article "right-arrow")
2853 (gnus-summary-next-page "next-page")
2854 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2856 ;; Maybe some sort-by-... could be added:
2857 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2858 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2859 (gnus-summary-mark-as-expirable
2860 "delete" nil
2861 :visible (gnus-check-backend-function 'request-expire-articles
2862 gnus-newsgroup-name))
2863 (gnus-summary-mark-as-spam
2864 "mail/spam" t
2865 :visible (and (fboundp 'spam-group-ham-contents-p)
2866 (spam-group-ham-contents-p gnus-newsgroup-name))
2867 :help "Mark as spam")
2868 (gnus-summary-mark-as-read-forward
2869 "mail/not-spam" nil
2870 :visible (and (fboundp 'spam-group-spam-contents-p)
2871 (spam-group-spam-contents-p gnus-newsgroup-name)))
2873 (gnus-summary-exit "exit")
2874 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2875 (gnus-info-find-node "help"))
2876 "List of functions for the summary tool bar (GNOME style).
2878 See `gmm-tool-bar-from-list' for the format of the list."
2879 :type '(repeat gmm-tool-bar-item)
2880 :version "23.1" ;; No Gnus
2881 :initialize 'custom-initialize-default
2882 :set 'gnus-summary-tool-bar-update
2883 :group 'gnus-summary)
2885 (defcustom gnus-summary-tool-bar-retro
2886 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2887 (gnus-summary-next-unread-article "gnus/next-ur")
2888 (gnus-summary-post-news "gnus/post")
2889 (gnus-summary-followup-with-original "gnus/fuwo")
2890 (gnus-summary-followup "gnus/followup")
2891 (gnus-summary-reply-with-original "gnus/reply-wo")
2892 (gnus-summary-reply "gnus/reply")
2893 (gnus-summary-caesar-message "gnus/rot13")
2894 (gnus-uu-decode-uu "gnus/uu-decode")
2895 (gnus-summary-save-article-file "gnus/save-aif")
2896 (gnus-summary-save-article "gnus/save-art")
2897 (gnus-uu-post-news "gnus/uu-post")
2898 (gnus-summary-catchup "gnus/catchup")
2899 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2900 (gnus-summary-exit "gnus/exit-summ")
2901 ;; Some new command that may need more suitable icons:
2902 (gnus-summary-print-article "gnus/print" nil :visible nil)
2903 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2904 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2905 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2906 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2907 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2908 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2910 (gnus-info-find-node "gnus/help" nil :visible nil))
2911 "List of functions for the summary tool bar (retro look).
2913 See `gmm-tool-bar-from-list' for the format of the list."
2914 :type '(repeat gmm-tool-bar-item)
2915 :version "23.1" ;; No Gnus
2916 :initialize 'custom-initialize-default
2917 :set 'gnus-summary-tool-bar-update
2918 :group 'gnus-summary)
2920 (defcustom gnus-summary-tool-bar-zap-list t
2921 "List of icon items from the global tool bar.
2922 These items are not displayed in the Gnus summary mode tool bar.
2924 See `gmm-tool-bar-from-list' for the format of the list."
2925 :type 'gmm-tool-bar-zap-list
2926 :version "23.1" ;; No Gnus
2927 :initialize 'custom-initialize-default
2928 :set 'gnus-summary-tool-bar-update
2929 :group 'gnus-summary)
2931 (defvar image-load-path)
2932 (defvar tool-bar-map)
2934 (defun gnus-summary-make-tool-bar (&optional force)
2935 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2936 When FORCE, rebuild the tool bar."
2937 (when (and (not (featurep 'xemacs))
2938 (boundp 'tool-bar-mode)
2939 tool-bar-mode
2940 (or (not gnus-summary-tool-bar-map) force))
2941 (let* ((load-path
2942 (gmm-image-load-path-for-library "gnus"
2943 "mail/save.xpm"
2944 nil t))
2945 (image-load-path (cons (car load-path)
2946 (when (boundp 'image-load-path)
2947 image-load-path)))
2948 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2949 gnus-summary-tool-bar-zap-list
2950 'gnus-summary-mode-map)))
2951 (when map
2952 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2953 ;; uses it's value.
2954 (setq gnus-summary-tool-bar-map map))))
2955 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2957 (defun gnus-score-set-default (var value)
2958 "A version of set that updates the GNU Emacs menu-bar."
2959 (set var value)
2960 ;; It is the message that forces the active status to be updated.
2961 (message ""))
2963 (defun gnus-make-score-map (type)
2964 "Make a summary score map of type TYPE."
2965 (if t
2967 (let ((headers '(("author" "from" string)
2968 ("subject" "subject" string)
2969 ("article body" "body" string)
2970 ("article head" "head" string)
2971 ("xref" "xref" string)
2972 ("extra header" "extra" string)
2973 ("lines" "lines" number)
2974 ("followups to author" "followup" string)))
2975 (types '((number ("less than" <)
2976 ("greater than" >)
2977 ("equal" =))
2978 (string ("substring" s)
2979 ("exact string" e)
2980 ("fuzzy string" f)
2981 ("regexp" r))))
2982 (perms '(("temporary" (current-time-string))
2983 ("permanent" nil)
2984 ("immediate" now)))
2985 header)
2986 (list
2987 (apply
2988 'nconc
2989 (list
2990 (if (eq type 'lower)
2991 "Lower score"
2992 "Increase score"))
2993 (let (outh)
2994 (while headers
2995 (setq header (car headers))
2996 (setq outh
2997 (cons
2998 (apply
2999 'nconc
3000 (list (car header))
3001 (let ((ts (cdr (assoc (nth 2 header) types)))
3002 outt)
3003 (while ts
3004 (setq outt
3005 (cons
3006 (apply
3007 'nconc
3008 (list (caar ts))
3009 (let ((ps perms)
3010 outp)
3011 (while ps
3012 (setq outp
3013 (cons
3014 (vector
3015 (caar ps)
3016 (list
3017 'gnus-summary-score-entry
3018 (nth 1 header)
3019 (if (or (string= (nth 1 header)
3020 "head")
3021 (string= (nth 1 header)
3022 "body"))
3024 (list 'gnus-summary-header
3025 (nth 1 header)))
3026 (list 'quote (nth 1 (car ts)))
3027 (list 'gnus-score-delta-default
3028 nil)
3029 (nth 1 (car ps))
3032 outp))
3033 (setq ps (cdr ps)))
3034 (list (nreverse outp))))
3035 outt))
3036 (setq ts (cdr ts)))
3037 (list (nreverse outt))))
3038 outh))
3039 (setq headers (cdr headers)))
3040 (list (nreverse outh))))))))
3043 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3044 (defvar bookmark-make-record-function)
3047 (defun gnus-summary-mode (&optional group)
3048 "Major mode for reading articles.
3050 All normal editing commands are switched off.
3051 \\<gnus-summary-mode-map>
3052 Each line in this buffer represents one article. To read an
3053 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3054 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3055 respectively.
3057 You can also post articles and send mail from this buffer. To
3058 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3059 of an article, type `\\[gnus-summary-reply]'.
3061 There are approx. one gazillion commands you can execute in this
3062 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3064 The following commands are available:
3066 \\{gnus-summary-mode-map}"
3067 (interactive)
3068 (kill-all-local-variables)
3069 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3070 (gnus-summary-make-local-variables))
3071 (gnus-summary-make-local-variables)
3072 (setq gnus-newsgroup-name group)
3073 (when (gnus-visual-p 'summary-menu 'menu)
3074 (gnus-summary-make-menu-bar)
3075 (gnus-summary-make-tool-bar))
3076 (gnus-make-thread-indent-array)
3077 (gnus-simplify-mode-line)
3078 (setq major-mode 'gnus-summary-mode)
3079 (setq mode-name "Summary")
3080 (use-local-map gnus-summary-mode-map)
3081 (buffer-disable-undo)
3082 (setq buffer-read-only t ;Disable modification
3083 show-trailing-whitespace nil)
3084 (setq truncate-lines t)
3085 (add-to-invisibility-spec '(gnus-sum . t))
3086 (gnus-summary-set-display-table)
3087 (gnus-set-default-directory)
3088 (make-local-variable 'gnus-summary-line-format)
3089 (make-local-variable 'gnus-summary-line-format-spec)
3090 (make-local-variable 'gnus-summary-dummy-line-format)
3091 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3092 (make-local-variable 'gnus-summary-mark-positions)
3093 (gnus-make-local-hook 'pre-command-hook)
3094 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3095 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3096 (turn-on-gnus-mailing-list-mode)
3097 (mm-enable-multibyte)
3098 (set (make-local-variable 'bookmark-make-record-function)
3099 'gnus-summary-bookmark-make-record)
3100 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3101 (gnus-update-summary-mark-positions))
3103 (defun gnus-summary-make-local-variables ()
3104 "Make all the local summary buffer variables."
3105 (let (global)
3106 (dolist (local gnus-summary-local-variables)
3107 (if (consp local)
3108 (progn
3109 (if (eq (cdr local) 'global)
3110 ;; Copy the global value of the variable.
3111 (setq global (symbol-value (car local)))
3112 ;; Use the value from the list.
3113 (setq global (eval (cdr local))))
3114 (set (make-local-variable (car local)) global))
3115 ;; Simple nil-valued local variable.
3116 (set (make-local-variable local) nil)))))
3118 ;; Summary data functions.
3120 (defmacro gnus-data-number (data)
3121 `(car ,data))
3123 (defmacro gnus-data-set-number (data number)
3124 `(setcar ,data ,number))
3126 (defmacro gnus-data-mark (data)
3127 `(nth 1 ,data))
3129 (defmacro gnus-data-set-mark (data mark)
3130 `(setcar (nthcdr 1 ,data) ,mark))
3132 (defmacro gnus-data-pos (data)
3133 `(nth 2 ,data))
3135 (defmacro gnus-data-set-pos (data pos)
3136 `(setcar (nthcdr 2 ,data) ,pos))
3138 (defmacro gnus-data-header (data)
3139 `(nth 3 ,data))
3141 (defmacro gnus-data-set-header (data header)
3142 `(setf (nth 3 ,data) ,header))
3144 (defmacro gnus-data-level (data)
3145 `(nth 4 ,data))
3147 (defmacro gnus-data-unread-p (data)
3148 `(= (nth 1 ,data) gnus-unread-mark))
3150 (defmacro gnus-data-read-p (data)
3151 `(/= (nth 1 ,data) gnus-unread-mark))
3153 (defmacro gnus-data-pseudo-p (data)
3154 `(consp (nth 3 ,data)))
3156 (defmacro gnus-data-find (number)
3157 `(assq ,number gnus-newsgroup-data))
3159 (defmacro gnus-data-find-list (number &optional data)
3160 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3161 (memq (assq ,number bdata)
3162 bdata)))
3164 (defmacro gnus-data-make (number mark pos header level)
3165 `(list ,number ,mark ,pos ,header ,level))
3167 (defun gnus-data-enter (after-article number mark pos header level offset)
3168 (let ((data (gnus-data-find-list after-article)))
3169 (unless data
3170 (error "No such article: %d" after-article))
3171 (setcdr data (cons (gnus-data-make number mark pos header level)
3172 (cdr data)))
3173 (setq gnus-newsgroup-data-reverse nil)
3174 (gnus-data-update-list (cddr data) offset)))
3176 (defun gnus-data-enter-list (after-article list &optional offset)
3177 (when list
3178 (let ((data (and after-article (gnus-data-find-list after-article)))
3179 (ilist list))
3180 (if (not (or data
3181 after-article))
3182 (let ((odata gnus-newsgroup-data))
3183 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3184 (when offset
3185 (gnus-data-update-list odata offset)))
3186 ;; Find the last element in the list to be spliced into the main
3187 ;; list.
3188 (setq list (last list))
3189 (if (not data)
3190 (progn
3191 (setcdr list gnus-newsgroup-data)
3192 (setq gnus-newsgroup-data ilist)
3193 (when offset
3194 (gnus-data-update-list (cdr list) offset)))
3195 (setcdr list (cdr data))
3196 (setcdr data ilist)
3197 (when offset
3198 (gnus-data-update-list (cdr list) offset))))
3199 (setq gnus-newsgroup-data-reverse nil))))
3201 (defun gnus-data-remove (article &optional offset)
3202 (let ((data gnus-newsgroup-data))
3203 (if (= (gnus-data-number (car data)) article)
3204 (progn
3205 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3206 gnus-newsgroup-data-reverse nil)
3207 (when offset
3208 (gnus-data-update-list gnus-newsgroup-data offset)))
3209 (while (cdr data)
3210 (when (= (gnus-data-number (cadr data)) article)
3211 (setcdr data (cddr data))
3212 (when offset
3213 (gnus-data-update-list (cdr data) offset))
3214 (setq data nil
3215 gnus-newsgroup-data-reverse nil))
3216 (setq data (cdr data))))))
3218 (defmacro gnus-data-list (backward)
3219 `(if ,backward
3220 (or gnus-newsgroup-data-reverse
3221 (setq gnus-newsgroup-data-reverse
3222 (reverse gnus-newsgroup-data)))
3223 gnus-newsgroup-data))
3225 (defun gnus-data-update-list (data offset)
3226 "Add OFFSET to the POS of all data entries in DATA."
3227 (setq gnus-newsgroup-data-reverse nil)
3228 (while data
3229 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3230 (setq data (cdr data))))
3232 (defun gnus-summary-article-pseudo-p (article)
3233 "Say whether this article is a pseudo article or not."
3234 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3236 (defmacro gnus-summary-article-sparse-p (article)
3237 "Say whether this article is a sparse article or not."
3238 `(memq ,article gnus-newsgroup-sparse))
3240 (defmacro gnus-summary-article-ancient-p (article)
3241 "Say whether this article is a sparse article or not."
3242 `(memq ,article gnus-newsgroup-ancient))
3244 (defun gnus-article-parent-p (number)
3245 "Say whether this article is a parent or not."
3246 (let ((data (gnus-data-find-list number)))
3247 (and (cdr data) ; There has to be an article after...
3248 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3249 (gnus-data-level (nth 1 data))))))
3251 (defun gnus-article-children (number)
3252 "Return a list of all children to NUMBER."
3253 (let* ((data (gnus-data-find-list number))
3254 (level (gnus-data-level (car data)))
3255 children)
3256 (setq data (cdr data))
3257 (while (and data
3258 (= (gnus-data-level (car data)) (1+ level)))
3259 (push (gnus-data-number (car data)) children)
3260 (setq data (cdr data)))
3261 children))
3263 (defmacro gnus-summary-skip-intangible ()
3264 "If the current article is intangible, then jump to a different article."
3265 '(let ((to (get-text-property (point) 'gnus-intangible)))
3266 (and to (gnus-summary-goto-subject to))))
3268 (defmacro gnus-summary-article-intangible-p ()
3269 "Say whether this article is intangible or not."
3270 '(get-text-property (point) 'gnus-intangible))
3272 (defun gnus-article-read-p (article)
3273 "Say whether ARTICLE is read or not."
3274 (not (or (memq article gnus-newsgroup-marked)
3275 (memq article gnus-newsgroup-spam-marked)
3276 (memq article gnus-newsgroup-unreads)
3277 (memq article gnus-newsgroup-unselected)
3278 (memq article gnus-newsgroup-dormant))))
3280 ;; Some summary mode macros.
3282 (defmacro gnus-summary-article-number ()
3283 "The article number of the article on the current line.
3284 If there isn't an article number here, then we return the current
3285 article number."
3286 '(progn
3287 (gnus-summary-skip-intangible)
3288 (or (get-text-property (point) 'gnus-number)
3289 (gnus-summary-last-subject))))
3291 (defmacro gnus-summary-article-header (&optional number)
3292 "Return the header of article NUMBER."
3293 `(gnus-data-header (gnus-data-find
3294 ,(or number '(gnus-summary-article-number)))))
3296 (defmacro gnus-summary-thread-level (&optional number)
3297 "Return the level of thread that starts with article NUMBER."
3298 `(if (and (eq gnus-summary-make-false-root 'dummy)
3299 (get-text-property (point) 'gnus-intangible))
3301 (gnus-data-level (gnus-data-find
3302 ,(or number '(gnus-summary-article-number))))))
3304 (defmacro gnus-summary-article-mark (&optional number)
3305 "Return the mark of article NUMBER."
3306 `(gnus-data-mark (gnus-data-find
3307 ,(or number '(gnus-summary-article-number)))))
3309 (defmacro gnus-summary-article-pos (&optional number)
3310 "Return the position of the line of article NUMBER."
3311 `(gnus-data-pos (gnus-data-find
3312 ,(or number '(gnus-summary-article-number)))))
3314 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3315 (defmacro gnus-summary-article-subject (&optional number)
3316 "Return current subject string or nil if nothing."
3317 `(let ((headers
3318 ,(if number
3319 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3320 '(gnus-data-header (assq (gnus-summary-article-number)
3321 gnus-newsgroup-data)))))
3322 (and headers
3323 (vectorp headers)
3324 (mail-header-subject headers))))
3326 (defmacro gnus-summary-article-score (&optional number)
3327 "Return current article score."
3328 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3329 gnus-newsgroup-scored))
3330 gnus-summary-default-score 0))
3332 (defun gnus-summary-article-children (&optional number)
3333 "Return a list of article numbers that are children of article NUMBER."
3334 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3335 (level (gnus-data-level (car data)))
3336 l children)
3337 (while (and (setq data (cdr data))
3338 (> (setq l (gnus-data-level (car data))) level))
3339 (and (= (1+ level) l)
3340 (push (gnus-data-number (car data))
3341 children)))
3342 (nreverse children)))
3344 (defun gnus-summary-article-parent (&optional number)
3345 "Return the article number of the parent of article NUMBER."
3346 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3347 (gnus-data-list t)))
3348 (level (gnus-data-level (car data))))
3349 (if (zerop level)
3350 () ; This is a root.
3351 ;; We search until we find an article with a level less than
3352 ;; this one. That function has to be the parent.
3353 (while (and (setq data (cdr data))
3354 (not (< (gnus-data-level (car data)) level))))
3355 (and data (gnus-data-number (car data))))))
3357 (defun gnus-unread-mark-p (mark)
3358 "Say whether MARK is the unread mark."
3359 (= mark gnus-unread-mark))
3361 (defun gnus-read-mark-p (mark)
3362 "Say whether MARK is one of the marks that mark as read.
3363 This is all marks except unread, ticked, dormant, and expirable."
3364 (not (or (= mark gnus-unread-mark)
3365 (= mark gnus-ticked-mark)
3366 (= mark gnus-spam-mark)
3367 (= mark gnus-dormant-mark)
3368 (= mark gnus-expirable-mark))))
3370 (defmacro gnus-article-mark (number)
3371 "Return the MARK of article NUMBER.
3372 This macro should only be used when computing the mark the \"first\"
3373 time; i.e., when generating the summary lines. After that,
3374 `gnus-summary-article-mark' should be used to examine the
3375 marks of articles."
3376 `(cond
3377 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3378 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3379 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3380 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3381 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3382 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3383 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3384 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3385 gnus-ancient-mark))))
3387 ;; Saving hidden threads.
3389 (defmacro gnus-save-hidden-threads (&rest forms)
3390 "Save hidden threads, eval FORMS, and restore the hidden threads."
3391 (let ((config (make-symbol "config")))
3392 `(let ((,config (gnus-hidden-threads-configuration)))
3393 (unwind-protect
3394 (save-excursion
3395 ,@forms)
3396 (gnus-restore-hidden-threads-configuration ,config)))))
3397 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3398 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3400 (defun gnus-data-compute-positions ()
3401 "Compute the positions of all articles."
3402 (setq gnus-newsgroup-data-reverse nil)
3403 (let ((data gnus-newsgroup-data))
3404 (save-excursion
3405 (gnus-save-hidden-threads
3406 (gnus-summary-show-all-threads)
3407 (goto-char (point-min))
3408 (while data
3409 (while (get-text-property (point) 'gnus-intangible)
3410 (forward-line 1))
3411 (gnus-data-set-pos (car data) (+ (point) 3))
3412 (setq data (cdr data))
3413 (forward-line 1))))))
3415 (defun gnus-hidden-threads-configuration ()
3416 "Return the current hidden threads configuration."
3417 (save-excursion
3418 (let (config)
3419 (goto-char (point-min))
3420 (while (not (eobp))
3421 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3422 (push (save-excursion (forward-line 0) (point)) config))
3423 (forward-line 1))
3424 config)))
3426 (defun gnus-restore-hidden-threads-configuration (config)
3427 "Restore hidden threads configuration from CONFIG."
3428 (save-excursion
3429 (let (point (inhibit-read-only t))
3430 (while (setq point (pop config))
3431 (goto-char point)
3432 (gnus-summary-hide-thread)))))
3434 ;; Various summary mode internalish functions.
3436 (defun gnus-mouse-pick-article (e)
3437 (interactive "e")
3438 (mouse-set-point e)
3439 (gnus-summary-next-page nil t))
3441 (defun gnus-summary-set-display-table ()
3442 "Change the display table.
3443 Odd characters have a tendency to mess
3444 up nicely formatted displays - we make all possible glyphs
3445 display only a single character."
3447 ;; We start from the standard display table, if any.
3448 (let ((table (or (copy-sequence standard-display-table)
3449 (make-display-table)))
3450 (i 32))
3451 ;; Nix out all the control chars...
3452 (while (>= (setq i (1- i)) 0)
3453 (gnus-put-display-table i [??] table))
3454 ;; ... but not newline and cr, of course. (cr is necessary for the
3455 ;; selective display).
3456 (gnus-put-display-table ?\n nil table)
3457 (gnus-put-display-table ?\r nil table)
3458 ;; We keep TAB as well.
3459 (gnus-put-display-table ?\t nil table)
3460 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3461 ;; Emacs 23 (unicode), that are not set already.
3462 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3464 256)))
3465 (while (>= (setq i (1- i)) 127)
3466 ;; Only modify if the entry is nil.
3467 (unless (gnus-get-display-table i table)
3468 (gnus-put-display-table i [??] table))))
3469 (setq buffer-display-table table)))
3471 (defun gnus-summary-set-article-display-arrow (pos)
3472 "Update the overlay arrow to point to line at position POS."
3473 (when gnus-summary-display-arrow
3474 (make-local-variable 'overlay-arrow-position)
3475 (make-local-variable 'overlay-arrow-string)
3476 (save-excursion
3477 (goto-char pos)
3478 (beginning-of-line)
3479 (unless overlay-arrow-position
3480 (setq overlay-arrow-position (make-marker)))
3481 (setq overlay-arrow-string "=>"
3482 overlay-arrow-position (set-marker overlay-arrow-position
3483 (point)
3484 (current-buffer))))))
3486 (defun gnus-summary-setup-buffer (group)
3487 "Initialize summary buffer."
3488 (let ((buffer (gnus-summary-buffer-name group))
3489 (dead-name (concat "*Dead Summary "
3490 (gnus-group-decoded-name group) "*")))
3491 ;; If a dead summary buffer exists, we kill it.
3492 (when (gnus-buffer-live-p dead-name)
3493 (gnus-kill-buffer dead-name))
3494 (if (get-buffer buffer)
3495 (progn
3496 (set-buffer buffer)
3497 (setq gnus-summary-buffer (current-buffer))
3498 (not gnus-newsgroup-prepared))
3499 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3500 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3501 (gnus-summary-mode group)
3502 (when (gnus-group-quit-config group)
3503 (set (make-local-variable 'gnus-single-article-buffer) nil))
3504 (make-local-variable 'gnus-article-buffer)
3505 (make-local-variable 'gnus-article-current)
3506 (make-local-variable 'gnus-original-article-buffer)
3507 (setq gnus-newsgroup-name group)
3508 ;; Set any local variables in the group parameters.
3509 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3510 t)))
3512 (defun gnus-set-global-variables ()
3513 "Set the global equivalents of the buffer-local variables.
3514 They are set to the latest values they had. These reflect the summary
3515 buffer that was in action when the last article was fetched."
3516 (when (eq major-mode 'gnus-summary-mode)
3517 (setq gnus-summary-buffer (current-buffer))
3518 (let ((name gnus-newsgroup-name)
3519 (marked gnus-newsgroup-marked)
3520 (spam gnus-newsgroup-spam-marked)
3521 (unread gnus-newsgroup-unreads)
3522 (headers gnus-current-headers)
3523 (data gnus-newsgroup-data)
3524 (summary gnus-summary-buffer)
3525 (article-buffer gnus-article-buffer)
3526 (original gnus-original-article-buffer)
3527 (gac gnus-article-current)
3528 (reffed gnus-reffed-article-number)
3529 (score-file gnus-current-score-file)
3530 (default-charset gnus-newsgroup-charset)
3531 vlist)
3532 (let ((locals gnus-newsgroup-variables))
3533 (while locals
3534 (if (consp (car locals))
3535 (push (eval (caar locals)) vlist)
3536 (push (eval (car locals)) vlist))
3537 (setq locals (cdr locals)))
3538 (setq vlist (nreverse vlist)))
3539 (with-current-buffer gnus-group-buffer
3540 (setq gnus-newsgroup-name name
3541 gnus-newsgroup-marked marked
3542 gnus-newsgroup-spam-marked spam
3543 gnus-newsgroup-unreads unread
3544 gnus-current-headers headers
3545 gnus-newsgroup-data data
3546 gnus-article-current gac
3547 gnus-summary-buffer summary
3548 gnus-article-buffer article-buffer
3549 gnus-original-article-buffer original
3550 gnus-reffed-article-number reffed
3551 gnus-current-score-file score-file
3552 gnus-newsgroup-charset default-charset)
3553 (let ((locals gnus-newsgroup-variables))
3554 (while locals
3555 (if (consp (car locals))
3556 (set (caar locals) (pop vlist))
3557 (set (car locals) (pop vlist)))
3558 (setq locals (cdr locals))))
3559 ;; The article buffer also has local variables.
3560 (when (gnus-buffer-live-p gnus-article-buffer)
3561 (set-buffer gnus-article-buffer)
3562 (setq gnus-summary-buffer summary))))))
3564 (defun gnus-summary-article-unread-p (article)
3565 "Say whether ARTICLE is unread or not."
3566 (memq article gnus-newsgroup-unreads))
3568 (defun gnus-summary-first-article-p (&optional article)
3569 "Return whether ARTICLE is the first article in the buffer."
3570 (if (not (setq article (or article (gnus-summary-article-number))))
3572 (eq article (caar gnus-newsgroup-data))))
3574 (defun gnus-summary-last-article-p (&optional article)
3575 "Return whether ARTICLE is the last article in the buffer."
3576 (if (not (setq article (or article (gnus-summary-article-number))))
3577 ;; All non-existent numbers are the last article. :-)
3579 (not (cdr (gnus-data-find-list article)))))
3581 (defun gnus-make-thread-indent-array (&optional n)
3582 (when (or n
3583 (progn (setq n 200) nil)
3584 (null gnus-thread-indent-array)
3585 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3586 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3587 gnus-thread-indent-array-level gnus-thread-indent-level)
3588 (while (>= n 0)
3589 (aset gnus-thread-indent-array n
3590 (make-string (* n gnus-thread-indent-level) ? ))
3591 (setq n (1- n)))))
3593 (defun gnus-update-summary-mark-positions ()
3594 "Compute where the summary marks are to go."
3595 (save-excursion
3596 (when (gnus-buffer-exists-p gnus-summary-buffer)
3597 (set-buffer gnus-summary-buffer))
3598 (let ((spec gnus-summary-line-format-spec)
3599 pos)
3600 (save-excursion
3601 (gnus-set-work-buffer)
3602 (let ((gnus-tmp-unread ?Z)
3603 (gnus-replied-mark ?Z)
3604 (gnus-score-below-mark ?Z)
3605 (gnus-score-over-mark ?Z)
3606 (gnus-undownloaded-mark ?Z)
3607 (gnus-summary-line-format-spec spec)
3608 (gnus-newsgroup-downloadable '(0))
3609 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3610 case-fold-search ignores)
3611 ;; Here, all marks are bound to Z.
3612 (gnus-summary-insert-line header
3613 0 nil t gnus-tmp-unread t nil "" nil 1)
3614 (goto-char (point-min))
3615 ;; Memorize the positions of the same characters as dummy marks.
3616 (while (re-search-forward "[A-D]" nil t)
3617 (push (point) ignores))
3618 (erase-buffer)
3619 ;; We use A-D as dummy marks in order to know column positions
3620 ;; where marks should be inserted.
3621 (setq gnus-tmp-unread ?A
3622 gnus-replied-mark ?B
3623 gnus-score-below-mark ?C
3624 gnus-score-over-mark ?C
3625 gnus-undownloaded-mark ?D)
3626 (gnus-summary-insert-line header
3627 0 nil t gnus-tmp-unread t nil "" nil 1)
3628 ;; Ignore characters which aren't dummy marks.
3629 (dolist (p ignores)
3630 (delete-region (goto-char (1- p)) p)
3631 (insert ?Z))
3632 (goto-char (point-min))
3633 (setq pos (list (cons 'unread
3634 (and (search-forward "A" nil t)
3635 (- (point) (point-min) 1)))))
3636 (goto-char (point-min))
3637 (push (cons 'replied (and (search-forward "B" nil t)
3638 (- (point) (point-min) 1)))
3639 pos)
3640 (goto-char (point-min))
3641 (push (cons 'score (and (search-forward "C" nil t)
3642 (- (point) (point-min) 1)))
3643 pos)
3644 (goto-char (point-min))
3645 (push (cons 'download (and (search-forward "D" nil t)
3646 (- (point) (point-min) 1)))
3647 pos)))
3648 (setq gnus-summary-mark-positions pos))))
3650 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3651 "Insert a dummy root in the summary buffer."
3652 (beginning-of-line)
3653 (gnus-add-text-properties
3654 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3655 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3657 (defun gnus-summary-extract-address-component (from)
3658 (or (car (funcall gnus-extract-address-components from))
3659 from))
3661 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3662 (let ((mail-parse-charset gnus-newsgroup-charset)
3663 (ignored-from-addresses (gnus-ignored-from-addresses))
3664 ; Is it really necessary to do this next part for each summary line?
3665 ; Luckily, doesn't seem to slow things down much.
3666 (mail-parse-ignored-charsets
3667 (with-current-buffer gnus-summary-buffer
3668 gnus-newsgroup-ignored-charsets)))
3670 (and ignored-from-addresses
3671 (string-match ignored-from-addresses gnus-tmp-from)
3672 (let ((extra-headers (mail-header-extra header))
3674 newsgroups)
3675 (cond
3676 ((setq to (cdr (assq 'To extra-headers)))
3677 (concat gnus-summary-to-prefix
3678 (inline
3679 (gnus-summary-extract-address-component
3680 (funcall gnus-decode-encoded-address-function to)))))
3681 ((setq newsgroups
3683 (cdr (assq 'Newsgroups extra-headers))
3684 (and
3685 (memq 'Newsgroups gnus-extra-headers)
3686 (eq (car (gnus-find-method-for-group
3687 gnus-newsgroup-name)) 'nntp)
3688 (gnus-group-real-name gnus-newsgroup-name))))
3689 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3690 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3692 (defun gnus-summary-insert-line (gnus-tmp-header
3693 gnus-tmp-level gnus-tmp-current
3694 undownloaded gnus-tmp-unread gnus-tmp-replied
3695 gnus-tmp-expirable gnus-tmp-subject-or-nil
3696 &optional gnus-tmp-dummy gnus-tmp-score
3697 gnus-tmp-process)
3698 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3699 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3700 gnus-tmp-level)))
3701 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3702 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3703 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3704 (gnus-tmp-score-char
3705 (if (or (null gnus-summary-default-score)
3706 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3707 gnus-summary-zcore-fuzz))
3708 ? ;Whitespace
3709 (if (< gnus-tmp-score gnus-summary-default-score)
3710 gnus-score-below-mark gnus-score-over-mark)))
3711 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3712 (gnus-tmp-replied
3713 (cond (gnus-tmp-process gnus-process-mark)
3714 ((memq gnus-tmp-current gnus-newsgroup-cached)
3715 gnus-cached-mark)
3716 (gnus-tmp-replied gnus-replied-mark)
3717 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3718 gnus-forwarded-mark)
3719 ((memq gnus-tmp-current gnus-newsgroup-saved)
3720 gnus-saved-mark)
3721 ((memq gnus-tmp-number gnus-newsgroup-recent)
3722 gnus-recent-mark)
3723 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3724 gnus-unseen-mark)
3725 (t gnus-no-mark)))
3726 (gnus-tmp-downloaded
3727 (cond (undownloaded
3728 gnus-undownloaded-mark)
3729 (gnus-newsgroup-agentized
3730 gnus-downloaded-mark)
3732 gnus-no-mark)))
3733 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3734 (gnus-tmp-name
3735 (cond
3736 ((string-match "<[^>]+> *$" gnus-tmp-from)
3737 (let ((beg (match-beginning 0)))
3738 (or (and (string-match "^\".+\"" gnus-tmp-from)
3739 (substring gnus-tmp-from 1 (1- (match-end 0))))
3740 (substring gnus-tmp-from 0 beg))))
3741 ((string-match "(.+)" gnus-tmp-from)
3742 (substring gnus-tmp-from
3743 (1+ (match-beginning 0)) (1- (match-end 0))))
3744 (t gnus-tmp-from)))
3745 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3746 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3747 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3748 (inhibit-read-only t))
3749 (when (string= gnus-tmp-name "")
3750 (setq gnus-tmp-name gnus-tmp-from))
3751 (unless (numberp gnus-tmp-lines)
3752 (setq gnus-tmp-lines -1))
3753 (if (= gnus-tmp-lines -1)
3754 (setq gnus-tmp-lines "?")
3755 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3756 (condition-case ()
3757 (gnus-put-text-property
3758 (point)
3759 (progn (eval gnus-summary-line-format-spec) (point))
3760 'gnus-number gnus-tmp-number)
3761 (error (gnus-message 5 "Error updating the summary line")))
3762 (when (gnus-visual-p 'summary-highlight 'highlight)
3763 (forward-line -1)
3764 (gnus-summary-highlight-line)
3765 (gnus-run-hooks 'gnus-summary-update-hook)
3766 (forward-line 1))))
3768 (defun gnus-summary-update-line (&optional dont-update)
3769 "Update summary line after change."
3770 (when (and gnus-summary-default-score
3771 (not gnus-summary-inhibit-highlight))
3772 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3773 (article (gnus-summary-article-number))
3774 (score (gnus-summary-article-score article)))
3775 (unless dont-update
3776 (if (and gnus-summary-mark-below
3777 (< (gnus-summary-article-score)
3778 gnus-summary-mark-below))
3779 ;; This article has a low score, so we mark it as read.
3780 (when (memq article gnus-newsgroup-unreads)
3781 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3782 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3783 ;; This article was previously marked as read on account
3784 ;; of a low score, but now it has risen, so we mark it as
3785 ;; unread.
3786 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3787 (gnus-summary-update-mark
3788 (if (or (null gnus-summary-default-score)
3789 (<= (abs (- score gnus-summary-default-score))
3790 gnus-summary-zcore-fuzz))
3791 ? ;Whitespace
3792 (if (< score gnus-summary-default-score)
3793 gnus-score-below-mark gnus-score-over-mark))
3794 'score))
3795 ;; Do visual highlighting.
3796 (when (gnus-visual-p 'summary-highlight 'highlight)
3797 (gnus-summary-highlight-line)
3798 (gnus-run-hooks 'gnus-summary-update-hook)))))
3800 (defvar gnus-tmp-new-adopts nil)
3802 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3803 "Return the number of articles in THREAD.
3804 This may be 0 in some cases -- if none of the articles in
3805 the thread are to be displayed."
3806 (let* ((number
3807 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3808 (cond
3809 ((not (listp thread))
3811 ((and (consp thread) (cdr thread))
3812 (apply
3813 '+ 1 (mapcar
3814 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3815 ((null thread)
3817 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3819 (t 0))))
3820 (when (and level (zerop level) gnus-tmp-new-adopts)
3821 (incf number
3822 (apply '+ (mapcar
3823 'gnus-summary-number-of-articles-in-thread
3824 gnus-tmp-new-adopts))))
3825 (if char
3826 (if (> number 1) gnus-not-empty-thread-mark
3827 gnus-empty-thread-mark)
3828 number)))
3830 (defsubst gnus-summary-line-message-size (head)
3831 "Return pretty-printed version of message size.
3832 This function is intended to be used in
3833 `gnus-summary-line-format-alist'."
3834 (let ((c (or (mail-header-chars head) -1)))
3835 (cond ((< c 0) "n/a") ; chars not available
3836 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3837 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3838 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3839 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3842 (defun gnus-summary-set-local-parameters (group)
3843 "Go through the local params of GROUP and set all variable specs in that list."
3844 (let ((vars '(quit-config))) ; Ignore quit-config.
3845 (dolist (elem (gnus-group-find-parameter group))
3846 (and (consp elem) ; Has to be a cons.
3847 (consp (cdr elem)) ; The cdr has to be a list.
3848 (symbolp (car elem)) ; Has to be a symbol in there.
3849 (not (memq (car elem) vars))
3850 (ignore-errors
3851 (push (car elem) vars)
3852 ;; Variables like `gnus-show-threads' that are globally
3853 ;; bound, if used as group parameters, need to get to be
3854 ;; buffer-local, whereas just parameters like `gcc-self',
3855 ;; `timestamp', etc. should not be bound as variables.
3856 (if (boundp (car elem))
3857 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3858 (eval (nth 1 elem))))))))
3860 (defun gnus-summary-read-group (group &optional show-all no-article
3861 kill-buffer no-display backward
3862 select-articles)
3863 "Start reading news in newsgroup GROUP.
3864 If SHOW-ALL is non-nil, already read articles are also listed.
3865 If NO-ARTICLE is non-nil, no article is selected initially.
3866 If NO-DISPLAY, don't generate a summary buffer."
3867 (let (result)
3868 (while (and group
3869 (null (setq result
3870 (let ((gnus-auto-select-next nil))
3871 (or (gnus-summary-read-group-1
3872 group show-all no-article
3873 kill-buffer no-display
3874 select-articles)
3875 (setq show-all nil
3876 select-articles nil)))))
3877 (eq gnus-auto-select-next 'quietly))
3878 (set-buffer gnus-group-buffer)
3879 ;; The entry function called above goes to the next
3880 ;; group automatically, so we go two groups back
3881 ;; if we are searching for the previous group.
3882 (when backward
3883 (gnus-group-prev-unread-group 2))
3884 (if (not (equal group (gnus-group-group-name)))
3885 (setq group (gnus-group-group-name))
3886 (setq group nil)))
3887 result))
3889 (defun gnus-summary-read-group-1 (group show-all no-article
3890 kill-buffer no-display
3891 &optional select-articles)
3892 ;; Killed foreign groups can't be entered.
3893 ;; (when (and (not (gnus-group-native-p group))
3894 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3895 ;; (error "Dead non-native groups can't be entered"))
3896 (gnus-message 5 "Retrieving newsgroup: %s..."
3897 (gnus-group-decoded-name group))
3898 (let* ((new-group (gnus-summary-setup-buffer group))
3899 (quit-config (gnus-group-quit-config group))
3900 (did-select (and new-group (gnus-select-newsgroup
3901 group show-all select-articles))))
3902 (cond
3903 ;; This summary buffer exists already, so we just select it.
3904 ((not new-group)
3905 (gnus-set-global-variables)
3906 (when kill-buffer
3907 (gnus-kill-or-deaden-summary kill-buffer))
3908 (gnus-configure-windows 'summary 'force)
3909 (gnus-set-mode-line 'summary)
3910 (gnus-summary-position-point)
3911 (message "")
3913 ;; We couldn't select this group.
3914 ((null did-select)
3915 (when (and (eq major-mode 'gnus-summary-mode)
3916 (not (equal (current-buffer) kill-buffer)))
3917 (kill-buffer (current-buffer))
3918 (if (not quit-config)
3919 (progn
3920 ;; Update the info -- marks might need to be removed,
3921 ;; for instance.
3922 (gnus-summary-update-info)
3923 (set-buffer gnus-group-buffer)
3924 (gnus-group-jump-to-group group)
3925 (gnus-group-next-unread-group 1))
3926 (gnus-handle-ephemeral-exit quit-config)))
3927 (let ((grpinfo (gnus-get-info group)))
3928 (if (null (gnus-info-read grpinfo))
3929 (gnus-message 3 "Group %s contains no messages"
3930 (gnus-group-decoded-name group))
3931 (gnus-message 3 "Can't select group")))
3932 nil)
3933 ;; The user did a `C-g' while prompting for number of articles,
3934 ;; so we exit this group.
3935 ((eq did-select 'quit)
3936 (and (eq major-mode 'gnus-summary-mode)
3937 (not (equal (current-buffer) kill-buffer))
3938 (kill-buffer (current-buffer)))
3939 (when kill-buffer
3940 (gnus-kill-or-deaden-summary kill-buffer))
3941 (if (not quit-config)
3942 (progn
3943 (set-buffer gnus-group-buffer)
3944 (gnus-group-jump-to-group group)
3945 (gnus-configure-windows 'group 'force))
3946 (gnus-handle-ephemeral-exit quit-config))
3947 ;; Finally signal the quit.
3948 (signal 'quit nil))
3949 ;; The group was successfully selected.
3951 (gnus-set-global-variables)
3952 ;; Save the active value in effect when the group was entered.
3953 (setq gnus-newsgroup-active
3954 (gnus-copy-sequence
3955 (gnus-active gnus-newsgroup-name)))
3956 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3957 ;; You can change the summary buffer in some way with this hook.
3958 (gnus-run-hooks 'gnus-select-group-hook)
3959 (when (memq 'summary (gnus-update-format-specifications
3960 nil 'summary 'summary-mode 'summary-dummy))
3961 ;; The format specification for the summary line was updated,
3962 ;; so we need to update the mark positions as well.
3963 (gnus-update-summary-mark-positions))
3964 ;; Do score processing.
3965 (when gnus-use-scoring
3966 (gnus-possibly-score-headers))
3967 ;; Check whether to fill in the gaps in the threads.
3968 (when gnus-build-sparse-threads
3969 (gnus-build-sparse-threads))
3970 ;; Find the initial limit.
3971 (if show-all
3972 (let ((gnus-newsgroup-dormant nil))
3973 (gnus-summary-initial-limit show-all))
3974 (gnus-summary-initial-limit show-all))
3975 ;; Generate the summary buffer.
3976 (unless no-display
3977 (gnus-summary-prepare))
3978 (when gnus-use-trees
3979 (gnus-tree-open group)
3980 (setq gnus-summary-highlight-line-function
3981 'gnus-tree-highlight-article))
3982 ;; If the summary buffer is empty, but there are some low-scored
3983 ;; articles or some excluded dormants, we include these in the
3984 ;; buffer.
3985 (when (and (zerop (buffer-size))
3986 (not no-display))
3987 (cond (gnus-newsgroup-dormant
3988 (gnus-summary-limit-include-dormant))
3989 ((and gnus-newsgroup-scored show-all)
3990 (gnus-summary-limit-include-expunged t))))
3991 ;; Function `gnus-apply-kill-file' must be called in this hook.
3992 (gnus-run-hooks 'gnus-apply-kill-hook)
3993 (if (and (zerop (buffer-size))
3994 (not no-display))
3995 (progn
3996 ;; This newsgroup is empty.
3997 (gnus-summary-catchup-and-exit nil t)
3998 (gnus-message 6 "No unread news")
3999 (when kill-buffer
4000 (gnus-kill-or-deaden-summary kill-buffer))
4001 ;; Return nil from this function.
4002 nil)
4003 ;; Hide conversation thread subtrees. We cannot do this in
4004 ;; gnus-summary-prepare-hook since kill processing may not
4005 ;; work with hidden articles.
4006 (gnus-summary-maybe-hide-threads)
4007 (when kill-buffer
4008 (gnus-kill-or-deaden-summary kill-buffer))
4009 (gnus-summary-auto-select-subject)
4010 ;; Show first unread article if requested.
4011 (if (and (not no-article)
4012 (not no-display)
4013 gnus-newsgroup-unreads
4014 gnus-auto-select-first)
4015 (progn
4016 (gnus-configure-windows 'summary)
4017 (let ((art (gnus-summary-article-number)))
4018 (unless (and (not gnus-plugged)
4019 (or (memq art gnus-newsgroup-undownloaded)
4020 (memq art gnus-newsgroup-downloadable)))
4021 (gnus-summary-goto-article art))))
4022 ;; Don't select any articles.
4023 (gnus-summary-position-point)
4024 (gnus-configure-windows 'summary 'force)
4025 (gnus-set-mode-line 'summary))
4026 (when (and gnus-auto-center-group
4027 (get-buffer-window gnus-group-buffer t))
4028 ;; Gotta use windows, because recenter does weird stuff if
4029 ;; the current buffer ain't the displayed window.
4030 (let ((owin (selected-window)))
4031 (select-window (get-buffer-window gnus-group-buffer t))
4032 (when (gnus-group-goto-group group)
4033 (recenter))
4034 (select-window owin)))
4035 ;; Mark this buffer as "prepared".
4036 (setq gnus-newsgroup-prepared t)
4037 (gnus-run-hooks 'gnus-summary-prepared-hook)
4038 (unless (gnus-ephemeral-group-p group)
4039 (gnus-group-update-group group))
4040 t)))))
4042 (defun gnus-summary-auto-select-subject ()
4043 "Select the subject line on initial group entry."
4044 (goto-char (point-min))
4045 (cond
4046 ((eq gnus-auto-select-subject 'best)
4047 (gnus-summary-best-unread-subject))
4048 ((eq gnus-auto-select-subject 'unread)
4049 (gnus-summary-first-unread-subject))
4050 ((eq gnus-auto-select-subject 'unseen)
4051 (gnus-summary-first-unseen-subject))
4052 ((eq gnus-auto-select-subject 'unseen-or-unread)
4053 (gnus-summary-first-unseen-or-unread-subject))
4054 ((eq gnus-auto-select-subject 'first)
4055 ;; Do nothing.
4057 ((functionp gnus-auto-select-subject)
4058 (funcall gnus-auto-select-subject))))
4060 (defun gnus-summary-prepare ()
4061 "Generate the summary buffer."
4062 (interactive)
4063 (let ((inhibit-read-only t))
4064 (erase-buffer)
4065 (setq gnus-newsgroup-data nil
4066 gnus-newsgroup-data-reverse nil)
4067 (gnus-run-hooks 'gnus-summary-generate-hook)
4068 ;; Generate the buffer, either with threads or without.
4069 (when gnus-newsgroup-headers
4070 (gnus-summary-prepare-threads
4071 (if gnus-show-threads
4072 (gnus-sort-gathered-threads
4073 (funcall gnus-summary-thread-gathering-function
4074 (gnus-sort-threads
4075 (gnus-cut-threads (gnus-make-threads)))))
4076 ;; Unthreaded display.
4077 (gnus-sort-articles gnus-newsgroup-headers))))
4078 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4079 ;; Call hooks for modifying summary buffer.
4080 (goto-char (point-min))
4081 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4083 (defsubst gnus-general-simplify-subject (subject)
4084 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4085 (setq subject
4086 (cond
4087 ;; Truncate the subject.
4088 (gnus-simplify-subject-functions
4089 (gnus-map-function gnus-simplify-subject-functions subject))
4090 ((numberp gnus-summary-gather-subject-limit)
4091 (setq subject (gnus-simplify-subject-re subject))
4092 (if (> (length subject) gnus-summary-gather-subject-limit)
4093 (substring subject 0 gnus-summary-gather-subject-limit)
4094 subject))
4095 ;; Fuzzily simplify it.
4096 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4097 (gnus-simplify-subject-fuzzy subject))
4098 ;; Just remove the leading "Re:".
4100 (gnus-simplify-subject-re subject))))
4102 (if (and gnus-summary-gather-exclude-subject
4103 (string-match gnus-summary-gather-exclude-subject subject))
4104 nil ; This article shouldn't be gathered
4105 subject))
4107 (defun gnus-summary-simplify-subject-query ()
4108 "Query where the respool algorithm would put this article."
4109 (interactive)
4110 (gnus-summary-select-article)
4111 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4113 (defun gnus-gather-threads-by-subject (threads)
4114 "Gather threads by looking at Subject headers."
4115 (if (not gnus-summary-make-false-root)
4116 threads
4117 (let ((hashtb (gnus-make-hashtable 1024))
4118 (prev threads)
4119 (result threads)
4120 subject hthread whole-subject)
4121 (while threads
4122 (setq subject (gnus-general-simplify-subject
4123 (setq whole-subject (mail-header-subject
4124 (caar threads)))))
4125 (when subject
4126 (if (setq hthread (gnus-gethash subject hashtb))
4127 (progn
4128 ;; We enter a dummy root into the thread, if we
4129 ;; haven't done that already.
4130 (unless (stringp (caar hthread))
4131 (setcar hthread (list whole-subject (car hthread))))
4132 ;; We add this new gathered thread to this gathered
4133 ;; thread.
4134 (setcdr (car hthread)
4135 (nconc (cdar hthread) (list (car threads))))
4136 ;; Remove it from the list of threads.
4137 (setcdr prev (cdr threads))
4138 (setq threads prev))
4139 ;; Enter this thread into the hash table.
4140 (gnus-sethash subject
4141 (if gnus-summary-make-false-root-always
4142 (progn
4143 ;; If you want a dummy root above all
4144 ;; threads...
4145 (setcar threads (list whole-subject
4146 (car threads)))
4147 threads)
4148 threads)
4149 hashtb)))
4150 (setq prev threads)
4151 (setq threads (cdr threads)))
4152 result)))
4154 (defun gnus-gather-threads-by-references (threads)
4155 "Gather threads by looking at References headers."
4156 (let ((idhashtb (gnus-make-hashtable 1024))
4157 (thhashtb (gnus-make-hashtable 1024))
4158 (prev threads)
4159 (result threads)
4160 ids references id gthread gid entered ref)
4161 (while threads
4162 (when (setq references (mail-header-references (caar threads)))
4163 (setq id (mail-header-id (caar threads))
4164 ids (inline (gnus-split-references references))
4165 entered nil)
4166 (while (setq ref (pop ids))
4167 (setq ids (delete ref ids))
4168 (if (not (setq gid (gnus-gethash ref idhashtb)))
4169 (progn
4170 (gnus-sethash ref id idhashtb)
4171 (gnus-sethash id threads thhashtb))
4172 (setq gthread (gnus-gethash gid thhashtb))
4173 (unless entered
4174 ;; We enter a dummy root into the thread, if we
4175 ;; haven't done that already.
4176 (unless (stringp (caar gthread))
4177 (setcar gthread (list (mail-header-subject (caar gthread))
4178 (car gthread))))
4179 ;; We add this new gathered thread to this gathered
4180 ;; thread.
4181 (setcdr (car gthread)
4182 (nconc (cdar gthread) (list (car threads)))))
4183 ;; Add it into the thread hash table.
4184 (gnus-sethash id gthread thhashtb)
4185 (setq entered t)
4186 ;; Remove it from the list of threads.
4187 (setcdr prev (cdr threads))
4188 (setq threads prev))))
4189 (setq prev threads)
4190 (setq threads (cdr threads)))
4191 result))
4193 (defun gnus-sort-gathered-threads (threads)
4194 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4195 (let ((result threads))
4196 (while threads
4197 (when (stringp (caar threads))
4198 (setcdr (car threads)
4199 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4200 (setq threads (cdr threads)))
4201 result))
4203 (defun gnus-thread-loop-p (root thread)
4204 "Say whether ROOT is in THREAD."
4205 (let ((stack (list thread))
4206 (infloop 0)
4208 (while (setq thread (pop stack))
4209 (setq th (cdr thread))
4210 (while (and th
4211 (not (eq (caar th) root)))
4212 (pop th))
4213 (if th
4214 ;; We have found a loop.
4215 (let (ref-dep)
4216 (setcdr thread (delq (car th) (cdr thread)))
4217 (if (boundp (setq ref-dep (intern "none"
4218 gnus-newsgroup-dependencies)))
4219 (setcdr (symbol-value ref-dep)
4220 (nconc (cdr (symbol-value ref-dep))
4221 (list (car th))))
4222 (set ref-dep (list nil (car th))))
4223 (setq infloop 1
4224 stack nil))
4225 ;; Push all the subthreads onto the stack.
4226 (push (cdr thread) stack)))
4227 infloop))
4229 (defun gnus-make-threads ()
4230 "Go through the dependency hashtb and find the roots. Return all threads."
4231 (let (threads)
4232 (while (catch 'infloop
4233 (mapatoms
4234 (lambda (refs)
4235 ;; Deal with self-referencing References loops.
4236 (when (and (car (symbol-value refs))
4237 (not (zerop
4238 (apply
4240 (mapcar
4241 (lambda (thread)
4242 (gnus-thread-loop-p
4243 (car (symbol-value refs)) thread))
4244 (cdr (symbol-value refs)))))))
4245 (setq threads nil)
4246 (throw 'infloop t))
4247 (unless (car (symbol-value refs))
4248 ;; These threads do not refer back to any other
4249 ;; articles, so they're roots.
4250 (setq threads (append (cdr (symbol-value refs)) threads))))
4251 gnus-newsgroup-dependencies)))
4252 threads))
4254 ;; Build the thread tree.
4255 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4256 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4258 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4259 if it was already present.
4261 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4262 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4263 Message-IDs will be renamed to a unique Message-ID before being
4264 entered.
4266 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4267 (let* ((id (mail-header-id header))
4268 (id-dep (and id (intern id dependencies)))
4269 parent-id ref ref-dep ref-header replaced)
4270 ;; Enter this `header' in the `dependencies' table.
4271 (cond
4272 ((not id-dep)
4273 (setq header nil))
4274 ;; The first two cases do the normal part: enter a new `header'
4275 ;; in the `dependencies' table.
4276 ((not (boundp id-dep))
4277 (set id-dep (list header)))
4278 ((null (car (symbol-value id-dep)))
4279 (setcar (symbol-value id-dep) header))
4281 ;; From here the `header' was already present in the
4282 ;; `dependencies' table.
4283 (force-new
4284 ;; Overrides an existing entry;
4285 ;; just set the header part of the entry.
4286 (setcar (symbol-value id-dep) header)
4287 (setq replaced t))
4289 ;; Renames the existing `header' to a unique Message-ID.
4290 ((not gnus-summary-ignore-duplicates)
4291 ;; An article with this Message-ID has already been seen.
4292 ;; We rename the Message-ID.
4293 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4294 (list header))
4295 (mail-header-set-id header id))
4297 ;; The last case ignores an existing entry, except it adds any
4298 ;; additional Xrefs (in case the two articles came from different
4299 ;; servers.
4300 ;; Also sets `header' to `nil' meaning that the `dependencies'
4301 ;; table was *not* modified.
4303 (mail-header-set-xref
4304 (car (symbol-value id-dep))
4305 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4307 (or (mail-header-xref header) "")))
4308 (setq header nil)))
4310 (when (and header (not replaced))
4311 ;; First check that we are not creating a References loop.
4312 (setq parent-id (gnus-parent-id (mail-header-references header)))
4313 (setq ref parent-id)
4314 (while (and ref
4315 (setq ref-dep (intern-soft ref dependencies))
4316 (boundp ref-dep)
4317 (setq ref-header (car (symbol-value ref-dep))))
4318 (if (string= id ref)
4319 ;; Yuk! This is a reference loop. Make the article be a
4320 ;; root article.
4321 (progn
4322 (mail-header-set-references (car (symbol-value id-dep)) "none")
4323 (setq ref nil)
4324 (setq parent-id nil))
4325 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4326 (setq ref-dep (intern (or parent-id "none") dependencies))
4327 (if (boundp ref-dep)
4328 (setcdr (symbol-value ref-dep)
4329 (nconc (cdr (symbol-value ref-dep))
4330 (list (symbol-value id-dep))))
4331 (set ref-dep (list nil (symbol-value id-dep)))))
4332 header))
4334 (defun gnus-extract-message-id-from-in-reply-to (string)
4335 (if (string-match "<[^>]+>" string)
4336 (substring string (match-beginning 0) (match-end 0))
4337 nil))
4339 (defun gnus-build-sparse-threads ()
4340 (let ((headers gnus-newsgroup-headers)
4341 (mail-parse-charset gnus-newsgroup-charset)
4342 (gnus-summary-ignore-duplicates t)
4343 header references generation relations
4344 subject child end new-child date)
4345 ;; First we create an alist of generations/relations, where
4346 ;; generations is how much we trust the relation, and the relation
4347 ;; is parent/child.
4348 (gnus-message 7 "Making sparse threads...")
4349 (save-excursion
4350 (nnheader-set-temp-buffer " *gnus sparse threads*")
4351 (while (setq header (pop headers))
4352 (when (and (setq references (mail-header-references header))
4353 (not (string= references "")))
4354 (insert references)
4355 (setq child (mail-header-id header)
4356 subject (mail-header-subject header)
4357 date (mail-header-date header)
4358 generation 0)
4359 (while (search-backward ">" nil t)
4360 (setq end (1+ (point)))
4361 (when (search-backward "<" nil t)
4362 (setq new-child (buffer-substring (point) end))
4363 (push (list (incf generation)
4364 child (setq child new-child)
4365 subject date)
4366 relations)))
4367 (when child
4368 (push (list (1+ generation) child nil subject) relations))
4369 (erase-buffer)))
4370 (kill-buffer (current-buffer)))
4371 ;; Sort over trustworthiness.
4372 (dolist (relation (sort relations 'car-less-than-car))
4373 (when (gnus-dependencies-add-header
4374 (make-full-mail-header
4375 gnus-reffed-article-number
4376 (nth 3 relation) "" (or (nth 4 relation) "")
4377 (nth 1 relation)
4378 (or (nth 2 relation) "") 0 0 "")
4379 gnus-newsgroup-dependencies nil)
4380 (push gnus-reffed-article-number gnus-newsgroup-limit)
4381 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4382 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4383 gnus-newsgroup-reads)
4384 (decf gnus-reffed-article-number)))
4385 (gnus-message 7 "Making sparse threads...done")))
4387 (defun gnus-build-old-threads ()
4388 ;; Look at all the articles that refer back to old articles, and
4389 ;; fetch the headers for the articles that aren't there. This will
4390 ;; build complete threads - if the roots haven't been expired by the
4391 ;; server, that is.
4392 (let ((mail-parse-charset gnus-newsgroup-charset)
4393 id heads)
4394 (mapatoms
4395 (lambda (refs)
4396 (when (not (car (symbol-value refs)))
4397 (setq heads (cdr (symbol-value refs)))
4398 (while heads
4399 (if (memq (mail-header-number (caar heads))
4400 gnus-newsgroup-dormant)
4401 (setq heads (cdr heads))
4402 (setq id (symbol-name refs))
4403 (while (and (setq id (gnus-build-get-header id))
4404 (not (car (gnus-id-to-thread id)))))
4405 (setq heads nil)))))
4406 gnus-newsgroup-dependencies)))
4408 (defsubst gnus-remove-odd-characters (string)
4409 "Translate STRING into something that doesn't contain weird characters."
4410 (mm-subst-char-in-string
4411 ?\r ?\-
4412 (mm-subst-char-in-string ?\n ?\- string t) t))
4414 ;; This function has to be called with point after the article number
4415 ;; on the beginning of the line.
4416 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4417 (let ((eol (point-at-eol))
4418 (buffer (current-buffer))
4419 header references in-reply-to)
4421 ;; overview: [num subject from date id refs chars lines misc]
4422 (unwind-protect
4423 (let (x)
4424 (narrow-to-region (point) eol)
4425 (unless (eobp)
4426 (forward-char))
4428 (setq header
4429 (make-full-mail-header
4430 number ; number
4431 (condition-case () ; subject
4432 (gnus-remove-odd-characters
4433 (funcall gnus-decode-encoded-word-function
4434 (setq x (nnheader-nov-field))))
4435 (error x))
4436 (condition-case () ; from
4437 (gnus-remove-odd-characters
4438 (funcall gnus-decode-encoded-address-function
4439 (setq x (nnheader-nov-field))))
4440 (error x))
4441 (nnheader-nov-field) ; date
4442 (nnheader-nov-read-message-id number) ; id
4443 (setq references (nnheader-nov-field)) ; refs
4444 (nnheader-nov-read-integer) ; chars
4445 (nnheader-nov-read-integer) ; lines
4446 (unless (eobp)
4447 (if (looking-at "Xref: ")
4448 (goto-char (match-end 0)))
4449 (nnheader-nov-field)) ; Xref
4450 (nnheader-nov-parse-extra)))) ; extra
4452 (widen))
4454 (when (and (string= references "")
4455 (setq in-reply-to (mail-header-extra header))
4456 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4457 (mail-header-set-references
4458 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4460 (when gnus-alter-header-function
4461 (funcall gnus-alter-header-function header))
4462 (gnus-dependencies-add-header header dependencies force-new)))
4464 (defun gnus-build-get-header (id)
4465 "Look through the buffer of NOV lines and find the header to ID.
4466 Enter this line into the dependencies hash table, and return
4467 the id of the parent article (if any)."
4468 (let ((deps gnus-newsgroup-dependencies)
4469 found header)
4470 (prog1
4471 (with-current-buffer nntp-server-buffer
4472 (let ((case-fold-search nil))
4473 (goto-char (point-min))
4474 (while (and (not found)
4475 (search-forward id nil t))
4476 (beginning-of-line)
4477 (setq found (looking-at
4478 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4479 (regexp-quote id))))
4480 (or found (beginning-of-line 2)))
4481 (when found
4482 (beginning-of-line)
4483 (and
4484 (setq header (gnus-nov-parse-line
4485 (read (current-buffer)) deps))
4486 (gnus-parent-id (mail-header-references header))))))
4487 (when header
4488 (let ((number (mail-header-number header)))
4489 (push number gnus-newsgroup-limit)
4490 (push header gnus-newsgroup-headers)
4491 (if (memq number gnus-newsgroup-unselected)
4492 (progn
4493 (setq gnus-newsgroup-unreads
4494 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4495 number))
4496 (setq gnus-newsgroup-unselected
4497 (delq number gnus-newsgroup-unselected)))
4498 (push number gnus-newsgroup-ancient)))))))
4500 (defun gnus-build-all-threads ()
4501 "Read all the headers."
4502 (let ((gnus-summary-ignore-duplicates t)
4503 (mail-parse-charset gnus-newsgroup-charset)
4504 (dependencies gnus-newsgroup-dependencies)
4505 header article)
4506 (with-current-buffer nntp-server-buffer
4507 (let ((case-fold-search nil))
4508 (goto-char (point-min))
4509 (while (not (eobp))
4510 (ignore-errors
4511 (setq article (read (current-buffer))
4512 header (gnus-nov-parse-line article dependencies)))
4513 (when header
4514 (with-current-buffer gnus-summary-buffer
4515 (push header gnus-newsgroup-headers)
4516 (if (memq (setq article (mail-header-number header))
4517 gnus-newsgroup-unselected)
4518 (progn
4519 (setq gnus-newsgroup-unreads
4520 (gnus-add-to-sorted-list
4521 gnus-newsgroup-unreads article))
4522 (setq gnus-newsgroup-unselected
4523 (delq article gnus-newsgroup-unselected)))
4524 (push article gnus-newsgroup-ancient)))
4525 (forward-line 1)))))))
4527 (defun gnus-summary-update-article-line (article header)
4528 "Update the line for ARTICLE using HEADER."
4529 (let* ((id (mail-header-id header))
4530 (thread (gnus-id-to-thread id)))
4531 (unless thread
4532 (error "Article in no thread"))
4533 ;; Update the thread.
4534 (setcar thread header)
4535 (gnus-summary-goto-subject article)
4536 (let* ((datal (gnus-data-find-list article))
4537 (data (car datal))
4538 (inhibit-read-only t)
4539 (level (gnus-summary-thread-level)))
4540 (gnus-delete-line)
4541 (let ((inserted (- (point)
4542 (progn
4543 (gnus-summary-insert-line
4544 header level nil
4545 (memq article gnus-newsgroup-undownloaded)
4546 (gnus-article-mark article)
4547 (memq article gnus-newsgroup-replied)
4548 (memq article gnus-newsgroup-expirable)
4549 ;; Only insert the Subject string when it's different
4550 ;; from the previous Subject string.
4551 (if (and
4552 gnus-show-threads
4553 (gnus-subject-equal
4554 (condition-case ()
4555 (mail-header-subject
4556 (gnus-data-header
4557 (cadr
4558 (gnus-data-find-list
4559 article
4560 (gnus-data-list t)))))
4561 ;; Error on the side of excessive subjects.
4562 (error ""))
4563 (mail-header-subject header)))
4565 (mail-header-subject header))
4566 nil (cdr (assq article gnus-newsgroup-scored))
4567 (memq article gnus-newsgroup-processable))
4568 (point)))))
4569 (when (cdr datal)
4570 (gnus-data-update-list
4571 (cdr datal)
4572 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4574 (defun gnus-summary-update-article (article &optional iheader)
4575 "Update ARTICLE in the summary buffer."
4576 (set-buffer gnus-summary-buffer)
4577 (let* ((header (gnus-summary-article-header article))
4578 (id (mail-header-id header))
4579 (data (gnus-data-find article))
4580 (thread (gnus-id-to-thread id))
4581 (references (mail-header-references header))
4582 (parent
4583 (gnus-id-to-thread
4584 (or (gnus-parent-id
4585 (when (and references
4586 (not (equal "" references)))
4587 references))
4588 "none")))
4589 (inhibit-read-only t)
4590 (old (car thread)))
4591 (when thread
4592 (unless iheader
4593 (setcar thread nil)
4594 (when parent
4595 (delq thread parent)))
4596 (if (gnus-summary-insert-subject id header)
4597 ;; Set the (possibly) new article number in the data structure.
4598 (gnus-data-set-number data (gnus-id-to-article id))
4599 (setcar thread old)
4600 nil))))
4602 (defun gnus-rebuild-thread (id &optional line)
4603 "Rebuild the thread containing ID.
4604 If LINE, insert the rebuilt thread starting on line LINE."
4605 (let ((inhibit-read-only t)
4606 old-pos current thread data)
4607 (if (not gnus-show-threads)
4608 (setq thread (list (car (gnus-id-to-thread id))))
4609 ;; Get the thread this article is part of.
4610 (setq thread (gnus-remove-thread id)))
4611 (setq old-pos (point-at-bol))
4612 (setq current (save-excursion
4613 (and (re-search-backward "[\r\n]" nil t)
4614 (gnus-summary-article-number))))
4615 ;; If this is a gathered thread, we have to go some re-gathering.
4616 (when (stringp (car thread))
4617 (let ((subject (car thread))
4618 roots thr)
4619 (setq thread (cdr thread))
4620 (while thread
4621 (unless (memq (setq thr (gnus-id-to-thread
4622 (gnus-root-id
4623 (mail-header-id (caar thread)))))
4624 roots)
4625 (push thr roots))
4626 (setq thread (cdr thread)))
4627 ;; We now have all (unique) roots.
4628 (if (= (length roots) 1)
4629 ;; All the loose roots are now one solid root.
4630 (setq thread (car roots))
4631 (setq thread (cons subject (gnus-sort-threads roots))))))
4632 (let (threads)
4633 ;; We then insert this thread into the summary buffer.
4634 (when line
4635 (goto-char (point-min))
4636 (forward-line (1- line)))
4637 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4638 (if gnus-show-threads
4639 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4640 (gnus-summary-prepare-unthreaded thread))
4641 (setq data (nreverse gnus-newsgroup-data))
4642 (setq threads gnus-newsgroup-threads))
4643 ;; We splice the new data into the data structure.
4644 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4645 ;;!!! then we want to insert at the beginning of the buffer.
4646 ;;!!! That happens to be true with Gnus now, but that may
4647 ;;!!! change in the future. Perhaps.
4648 (gnus-data-enter-list
4649 (if line nil current) data (- (point) old-pos))
4650 (setq gnus-newsgroup-threads
4651 (nconc threads gnus-newsgroup-threads))
4652 (gnus-data-compute-positions))))
4654 (defun gnus-number-to-header (number)
4655 "Return the header for article NUMBER."
4656 (let ((headers gnus-newsgroup-headers))
4657 (while (and headers
4658 (not (= number (mail-header-number (car headers)))))
4659 (pop headers))
4660 (when headers
4661 (car headers))))
4663 (defun gnus-parent-headers (in-headers &optional generation)
4664 "Return the headers of the GENERATIONeth parent of HEADERS."
4665 (unless generation
4666 (setq generation 1))
4667 (let ((parent t)
4668 (headers in-headers)
4669 references)
4670 (while (and parent
4671 (not (zerop generation))
4672 (setq references (mail-header-references headers)))
4673 (setq headers (if (and references
4674 (setq parent (gnus-parent-id references)))
4675 (car (gnus-id-to-thread parent))
4676 nil))
4677 (decf generation))
4678 (and (not (eq headers in-headers))
4679 headers)))
4681 (defun gnus-id-to-thread (id)
4682 "Return the (sub-)thread where ID appears."
4683 (gnus-gethash id gnus-newsgroup-dependencies))
4685 (defun gnus-id-to-article (id)
4686 "Return the article number of ID."
4687 (let ((thread (gnus-id-to-thread id)))
4688 (when (and thread
4689 (car thread))
4690 (mail-header-number (car thread)))))
4692 (defun gnus-id-to-header (id)
4693 "Return the article headers of ID."
4694 (car (gnus-id-to-thread id)))
4696 (defun gnus-article-displayed-root-p (article)
4697 "Say whether ARTICLE is a root(ish) article."
4698 (let ((level (gnus-summary-thread-level article))
4699 (refs (mail-header-references (gnus-summary-article-header article)))
4700 particle)
4701 (cond
4702 ((null level) nil)
4703 ((zerop level) t)
4704 ((null refs) t)
4705 ((null (gnus-parent-id refs)) t)
4706 ((and (= 1 level)
4707 (null (setq particle (gnus-id-to-article
4708 (gnus-parent-id refs))))
4709 (null (gnus-summary-thread-level particle)))))))
4711 (defun gnus-root-id (id)
4712 "Return the id of the root of the thread where ID appears."
4713 (let (last-id prev)
4714 (while (and id (setq prev (car (gnus-id-to-thread id))))
4715 (setq last-id id
4716 id (gnus-parent-id (mail-header-references prev))))
4717 last-id))
4719 (defun gnus-articles-in-thread (thread)
4720 "Return the list of articles in THREAD."
4721 (cons (mail-header-number (car thread))
4722 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4724 (defun gnus-remove-thread (id &optional dont-remove)
4725 "Remove the thread that has ID in it."
4726 (let (headers thread last-id)
4727 ;; First go up in this thread until we find the root.
4728 (setq last-id (gnus-root-id id)
4729 headers (message-flatten-list (gnus-id-to-thread last-id)))
4730 ;; We have now found the real root of this thread. It might have
4731 ;; been gathered into some loose thread, so we have to search
4732 ;; through the threads to find the thread we wanted.
4733 (let ((threads gnus-newsgroup-threads)
4734 sub)
4735 (while threads
4736 (setq sub (car threads))
4737 (if (stringp (car sub))
4738 ;; This is a gathered thread, so we look at the roots
4739 ;; below it to find whether this article is in this
4740 ;; gathered root.
4741 (progn
4742 (setq sub (cdr sub))
4743 (while sub
4744 (when (member (caar sub) headers)
4745 (setq thread (car threads)
4746 threads nil
4747 sub nil))
4748 (setq sub (cdr sub))))
4749 ;; It's an ordinary thread, so we check it.
4750 (when (eq (car sub) (car headers))
4751 (setq thread sub
4752 threads nil)))
4753 (setq threads (cdr threads)))
4754 ;; If this article is in no thread, then it's a root.
4755 (if thread
4756 (unless dont-remove
4757 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4758 (setq thread (gnus-id-to-thread last-id)))
4759 (when thread
4760 (prog1
4761 thread ; We return this thread.
4762 (unless dont-remove
4763 (if (stringp (car thread))
4764 (progn
4765 ;; If we use dummy roots, then we have to remove the
4766 ;; dummy root as well.
4767 (when (eq gnus-summary-make-false-root 'dummy)
4768 ;; We go to the dummy root by going to
4769 ;; the first sub-"thread", and then one line up.
4770 (gnus-summary-goto-article
4771 (mail-header-number (caadr thread)))
4772 (forward-line -1)
4773 (gnus-delete-line)
4774 (gnus-data-compute-positions))
4775 (setq thread (cdr thread))
4776 (while thread
4777 (gnus-remove-thread-1 (car thread))
4778 (setq thread (cdr thread))))
4779 (gnus-remove-thread-1 thread))))))))
4781 (defun gnus-remove-thread-1 (thread)
4782 "Remove the thread THREAD recursively."
4783 (let ((number (mail-header-number (pop thread)))
4785 (setq thread (reverse thread))
4786 (while thread
4787 (gnus-remove-thread-1 (pop thread)))
4788 (when (setq d (gnus-data-find number))
4789 (goto-char (gnus-data-pos d))
4790 (gnus-summary-show-thread)
4791 (gnus-data-remove
4792 number
4793 (- (point-at-bol)
4794 (prog1
4795 (1+ (point-at-eol))
4796 (gnus-delete-line)))))))
4798 (defun gnus-sort-threads-recursive (threads func)
4799 (sort (mapcar (lambda (thread)
4800 (cons (car thread)
4801 (and (cdr thread)
4802 (gnus-sort-threads-recursive (cdr thread) func))))
4803 threads) func))
4805 (defun gnus-sort-threads-loop (threads func)
4806 (let* ((superthread (cons nil threads))
4807 (stack (list (cons superthread threads)))
4808 remaining-threads thread)
4809 (while stack
4810 (setq remaining-threads (cdr (car stack)))
4811 (if remaining-threads
4812 (progn (setq thread (car remaining-threads))
4813 (setcdr (car stack) (cdr remaining-threads))
4814 (if (cdr thread)
4815 (push (cons thread (cdr thread)) stack)))
4816 (setq thread (caar stack))
4817 (setcdr thread (sort (cdr thread) func))
4818 (pop stack)))
4819 (cdr superthread)))
4821 (defun gnus-sort-threads (threads)
4822 "Sort THREADS."
4823 (if (not gnus-thread-sort-functions)
4824 threads
4825 (gnus-message 8 "Sorting threads...")
4826 (prog1
4827 (condition-case nil
4828 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4829 (gnus-sort-threads-recursive
4830 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4831 ;; Even after binding max-lisp-eval-depth, the recursive
4832 ;; sorter might fail for very long threads. In that case,
4833 ;; try using a (less well-tested) non-recursive sorter.
4834 (error (gnus-message 9 "Sorting threads with loop...")
4835 (gnus-sort-threads-loop
4836 threads (gnus-make-sort-function
4837 gnus-thread-sort-functions))))
4838 (gnus-message 8 "Sorting threads...done"))))
4840 (defun gnus-sort-articles (articles)
4841 "Sort ARTICLES."
4842 (when gnus-article-sort-functions
4843 (gnus-message 7 "Sorting articles...")
4844 (prog1
4845 (setq gnus-newsgroup-headers
4846 (sort articles (gnus-make-sort-function
4847 gnus-article-sort-functions)))
4848 (gnus-message 7 "Sorting articles...done"))))
4850 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4851 (defmacro gnus-thread-header (thread)
4852 "Return header of first article in THREAD.
4853 Note that THREAD must never, ever be anything else than a variable -
4854 using some other form will lead to serious barfage."
4855 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4856 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4857 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4858 (vector thread) 2))
4860 (defsubst gnus-article-sort-by-number (h1 h2)
4861 "Sort articles by article number."
4862 (< (mail-header-number h1)
4863 (mail-header-number h2)))
4865 (defun gnus-thread-sort-by-number (h1 h2)
4866 "Sort threads by root article number."
4867 (gnus-article-sort-by-number
4868 (gnus-thread-header h1) (gnus-thread-header h2)))
4870 (defsubst gnus-article-sort-by-random (h1 h2)
4871 "Sort articles randomly."
4872 (zerop (random 2)))
4874 (defun gnus-thread-sort-by-random (h1 h2)
4875 "Sort threads randomly."
4876 (gnus-article-sort-by-random
4877 (gnus-thread-header h1) (gnus-thread-header h2)))
4879 (defsubst gnus-article-sort-by-lines (h1 h2)
4880 "Sort articles by article Lines header."
4881 (< (mail-header-lines h1)
4882 (mail-header-lines h2)))
4884 (defun gnus-thread-sort-by-lines (h1 h2)
4885 "Sort threads by root article Lines header."
4886 (gnus-article-sort-by-lines
4887 (gnus-thread-header h1) (gnus-thread-header h2)))
4889 (defsubst gnus-article-sort-by-chars (h1 h2)
4890 "Sort articles by octet length."
4891 (< (mail-header-chars h1)
4892 (mail-header-chars h2)))
4894 (defun gnus-thread-sort-by-chars (h1 h2)
4895 "Sort threads by root article octet length."
4896 (gnus-article-sort-by-chars
4897 (gnus-thread-header h1) (gnus-thread-header h2)))
4899 (defsubst gnus-article-sort-by-author (h1 h2)
4900 "Sort articles by root author."
4901 (gnus-string<
4902 (let ((extract (funcall
4903 gnus-extract-address-components
4904 (mail-header-from h1))))
4905 (or (car extract) (cadr extract) ""))
4906 (let ((extract (funcall
4907 gnus-extract-address-components
4908 (mail-header-from h2))))
4909 (or (car extract) (cadr extract) ""))))
4911 (defun gnus-thread-sort-by-author (h1 h2)
4912 "Sort threads by root author."
4913 (gnus-article-sort-by-author
4914 (gnus-thread-header h1) (gnus-thread-header h2)))
4916 (defsubst gnus-article-sort-by-recipient (h1 h2)
4917 "Sort articles by recipient."
4918 (gnus-string<
4919 (let ((extract (funcall
4920 gnus-extract-address-components
4921 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4922 (or (car extract) (cadr extract)))
4923 (let ((extract (funcall
4924 gnus-extract-address-components
4925 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4926 (or (car extract) (cadr extract)))))
4928 (defun gnus-thread-sort-by-recipient (h1 h2)
4929 "Sort threads by root recipient."
4930 (gnus-article-sort-by-recipient
4931 (gnus-thread-header h1) (gnus-thread-header h2)))
4933 (defsubst gnus-article-sort-by-subject (h1 h2)
4934 "Sort articles by root subject."
4935 (gnus-string<
4936 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4937 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4939 (defun gnus-thread-sort-by-subject (h1 h2)
4940 "Sort threads by root subject."
4941 (gnus-article-sort-by-subject
4942 (gnus-thread-header h1) (gnus-thread-header h2)))
4944 (defsubst gnus-article-sort-by-date (h1 h2)
4945 "Sort articles by root article date."
4946 (time-less-p
4947 (gnus-date-get-time (mail-header-date h1))
4948 (gnus-date-get-time (mail-header-date h2))))
4950 (defun gnus-thread-sort-by-date (h1 h2)
4951 "Sort threads by root article date."
4952 (gnus-article-sort-by-date
4953 (gnus-thread-header h1) (gnus-thread-header h2)))
4955 (defsubst gnus-article-sort-by-score (h1 h2)
4956 "Sort articles by root article score.
4957 Unscored articles will be counted as having a score of zero."
4958 (> (or (cdr (assq (mail-header-number h1)
4959 gnus-newsgroup-scored))
4960 gnus-summary-default-score 0)
4961 (or (cdr (assq (mail-header-number h2)
4962 gnus-newsgroup-scored))
4963 gnus-summary-default-score 0)))
4965 (defun gnus-thread-sort-by-score (h1 h2)
4966 "Sort threads by root article score."
4967 (gnus-article-sort-by-score
4968 (gnus-thread-header h1) (gnus-thread-header h2)))
4970 (defun gnus-thread-sort-by-total-score (h1 h2)
4971 "Sort threads by the sum of all scores in the thread.
4972 Unscored articles will be counted as having a score of zero."
4973 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4975 (defun gnus-thread-total-score (thread)
4976 ;; This function find the total score of THREAD.
4977 (cond
4978 ((null thread)
4980 ((consp thread)
4981 (if (stringp (car thread))
4982 (apply gnus-thread-score-function 0
4983 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4984 (gnus-thread-total-score-1 thread)))
4986 (gnus-thread-total-score-1 (list thread)))))
4988 (defun gnus-article-sort-by-most-recent-number (h1 h2)
4989 "Sort articles by number."
4990 (gnus-article-sort-by-number h1 h2))
4992 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4993 "Sort threads such that the thread with the most recently arrived article comes first."
4994 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4996 (defun gnus-thread-highest-number (thread)
4997 "Return the highest article number in THREAD."
4998 (apply 'max (mapcar (lambda (header)
4999 (mail-header-number header))
5000 (message-flatten-list thread))))
5002 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5003 "Sort articles by number."
5004 (gnus-article-sort-by-date h1 h2))
5006 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5007 "Sort threads such that the thread with the most recently dated article comes first."
5008 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5010 ; Since this is called not only to sort the top-level threads, but
5011 ; also in recursive sorts to order the articles within a thread, each
5012 ; article will be processed many times. Thus it speeds things up
5013 ; quite a bit to use gnus-date-get-time, which caches the time value.
5014 (defun gnus-thread-latest-date (thread)
5015 "Return the highest article date in THREAD."
5016 (apply 'max
5017 (mapcar (lambda (header) (gnus-float-time
5018 (gnus-date-get-time
5019 (mail-header-date header))))
5020 (message-flatten-list thread))))
5022 (defun gnus-thread-total-score-1 (root)
5023 ;; This function find the total score of the thread below ROOT.
5024 (setq root (car root))
5025 (apply gnus-thread-score-function
5026 (or (append
5027 (mapcar 'gnus-thread-total-score
5028 (cdr (gnus-id-to-thread (mail-header-id root))))
5029 (when (> (mail-header-number root) 0)
5030 (list (or (cdr (assq (mail-header-number root)
5031 gnus-newsgroup-scored))
5032 gnus-summary-default-score 0))))
5033 (list gnus-summary-default-score)
5034 '(0))))
5036 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5037 (defvar gnus-tmp-prev-subject nil)
5038 (defvar gnus-tmp-false-parent nil)
5039 (defvar gnus-tmp-root-expunged nil)
5040 (defvar gnus-tmp-dummy-line nil)
5042 (defun gnus-extra-header (type &optional header)
5043 "Return the extra header of TYPE."
5044 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5045 ""))
5047 (defvar gnus-tmp-thread-tree-header-string "")
5049 (defcustom gnus-sum-thread-tree-root "> "
5050 "With %B spec, used for the root of a thread.
5051 If nil, use subject instead."
5052 :version "22.1"
5053 :type '(radio (const :format "%v " nil) string)
5054 :group 'gnus-thread)
5056 (defcustom gnus-sum-thread-tree-false-root "> "
5057 "With %B spec, used for a false root of a thread.
5058 If nil, use subject instead."
5059 :version "22.1"
5060 :type '(radio (const :format "%v " nil) string)
5061 :group 'gnus-thread)
5063 (defcustom gnus-sum-thread-tree-single-indent ""
5064 "With %B spec, used for a thread with just one message.
5065 If nil, use subject instead."
5066 :version "22.1"
5067 :type '(radio (const :format "%v " nil) string)
5068 :group 'gnus-thread)
5070 (defcustom gnus-sum-thread-tree-vertical "| "
5071 "With %B spec, used for drawing a vertical line."
5072 :version "22.1"
5073 :type 'string
5074 :group 'gnus-thread)
5076 (defcustom gnus-sum-thread-tree-indent " "
5077 "With %B spec, used for indenting."
5078 :version "22.1"
5079 :type 'string
5080 :group 'gnus-thread)
5082 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5083 "With %B spec, used for a leaf with brothers."
5084 :version "22.1"
5085 :type 'string
5086 :group 'gnus-thread)
5088 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5089 "With %B spec, used for a leaf without brothers."
5090 :version "22.1"
5091 :type 'string
5092 :group 'gnus-thread)
5094 (defcustom gnus-summary-display-while-building nil
5095 "If non-nil, show and update the summary buffer as it's being built.
5096 If the value is t, update the buffer after every line is inserted. If
5097 the value is an integer (N), update the display every N lines."
5098 :version "22.1"
5099 :group 'gnus-thread
5100 :type '(choice (const :tag "off" nil)
5101 number
5102 (const :tag "frequently" t)))
5104 (defun gnus-summary-prepare-threads (threads)
5105 "Prepare summary buffer from THREADS and indentation LEVEL.
5106 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5107 or a straight list of headers."
5108 (gnus-message 7 "Generating summary...")
5110 (setq gnus-newsgroup-threads threads)
5111 (beginning-of-line)
5113 (let ((gnus-tmp-level 0)
5114 (default-score (or gnus-summary-default-score 0))
5115 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5116 (building-line-count gnus-summary-display-while-building)
5117 (building-count (integerp gnus-summary-display-while-building))
5118 thread number subject stack state gnus-tmp-gathered beg-match
5119 new-roots gnus-tmp-new-adopts thread-end simp-subject
5120 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5121 gnus-tmp-replied gnus-tmp-subject-or-nil
5122 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5123 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5124 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5125 tree-stack)
5127 (setq gnus-tmp-prev-subject nil
5128 gnus-tmp-thread-tree-header-string "")
5130 (if (vectorp (car threads))
5131 ;; If this is a straight (sic) list of headers, then a
5132 ;; threaded summary display isn't required, so we just create
5133 ;; an unthreaded one.
5134 (gnus-summary-prepare-unthreaded threads)
5136 ;; Do the threaded display.
5138 (if gnus-summary-display-while-building
5139 (switch-to-buffer (buffer-name)))
5140 (while (or threads stack gnus-tmp-new-adopts new-roots)
5142 (if (and (= gnus-tmp-level 0)
5143 (or (not stack)
5144 (= (caar stack) 0))
5145 (not gnus-tmp-false-parent)
5146 (or gnus-tmp-new-adopts new-roots))
5147 (if gnus-tmp-new-adopts
5148 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5149 thread (list (car gnus-tmp-new-adopts))
5150 gnus-tmp-header (caar thread)
5151 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5152 (when new-roots
5153 (setq thread (list (car new-roots))
5154 gnus-tmp-header (caar thread)
5155 new-roots (cdr new-roots))))
5157 (if threads
5158 ;; If there are some threads, we do them before the
5159 ;; threads on the stack.
5160 (setq thread threads
5161 gnus-tmp-header (caar thread))
5162 ;; There were no current threads, so we pop something off
5163 ;; the stack.
5164 (setq state (car stack)
5165 gnus-tmp-level (car state)
5166 tree-stack (cadr state)
5167 thread (caddr state)
5168 stack (cdr stack)
5169 gnus-tmp-header (caar thread))))
5171 (setq gnus-tmp-false-parent nil)
5172 (setq gnus-tmp-root-expunged nil)
5173 (setq thread-end nil)
5175 (if (stringp gnus-tmp-header)
5176 ;; The header is a dummy root.
5177 (cond
5178 ((eq gnus-summary-make-false-root 'adopt)
5179 ;; We let the first article adopt the rest.
5180 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5181 (cddar thread)))
5182 (setq gnus-tmp-gathered
5183 (nconc (mapcar
5184 (lambda (h) (mail-header-number (car h)))
5185 (cddar thread))
5186 gnus-tmp-gathered))
5187 (setq thread (cons (list (caar thread)
5188 (cadar thread))
5189 (cdr thread)))
5190 (setq gnus-tmp-level -1
5191 gnus-tmp-false-parent t))
5192 ((eq gnus-summary-make-false-root 'empty)
5193 ;; We print adopted articles with empty subject fields.
5194 (setq gnus-tmp-gathered
5195 (nconc (mapcar
5196 (lambda (h) (mail-header-number (car h)))
5197 (cddar thread))
5198 gnus-tmp-gathered))
5199 (setq gnus-tmp-level -1))
5200 ((eq gnus-summary-make-false-root 'dummy)
5201 ;; We remember that we probably want to output a dummy
5202 ;; root.
5203 (setq gnus-tmp-dummy-line gnus-tmp-header)
5204 (setq gnus-tmp-prev-subject gnus-tmp-header))
5206 ;; We do not make a root for the gathered
5207 ;; sub-threads at all.
5208 (setq gnus-tmp-level -1)))
5210 (setq number (mail-header-number gnus-tmp-header)
5211 subject (mail-header-subject gnus-tmp-header)
5212 simp-subject (gnus-simplify-subject-fully subject))
5214 (cond
5215 ;; If the thread has changed subject, we might want to make
5216 ;; this subthread into a root.
5217 ((and (null gnus-thread-ignore-subject)
5218 (not (zerop gnus-tmp-level))
5219 gnus-tmp-prev-subject
5220 (not (string= gnus-tmp-prev-subject simp-subject)))
5221 (setq new-roots (nconc new-roots (list (car thread)))
5222 thread-end t
5223 gnus-tmp-header nil))
5224 ;; If the article lies outside the current limit,
5225 ;; then we do not display it.
5226 ((not (memq number gnus-newsgroup-limit))
5227 (setq gnus-tmp-gathered
5228 (nconc (mapcar
5229 (lambda (h) (mail-header-number (car h)))
5230 (cdar thread))
5231 gnus-tmp-gathered))
5232 (setq gnus-tmp-new-adopts (if (cdar thread)
5233 (append gnus-tmp-new-adopts
5234 (cdar thread))
5235 gnus-tmp-new-adopts)
5236 thread-end t
5237 gnus-tmp-header nil)
5238 (when (zerop gnus-tmp-level)
5239 (setq gnus-tmp-root-expunged t)))
5240 ;; Perhaps this article is to be marked as read?
5241 ((and gnus-summary-mark-below
5242 (< (or (cdr (assq number gnus-newsgroup-scored))
5243 default-score)
5244 gnus-summary-mark-below)
5245 ;; Don't touch sparse articles.
5246 (not (gnus-summary-article-sparse-p number))
5247 (not (gnus-summary-article-ancient-p number)))
5248 (setq gnus-newsgroup-unreads
5249 (delq number gnus-newsgroup-unreads))
5250 (if gnus-newsgroup-auto-expire
5251 (setq gnus-newsgroup-expirable
5252 (gnus-add-to-sorted-list
5253 gnus-newsgroup-expirable number))
5254 (push (cons number gnus-low-score-mark)
5255 gnus-newsgroup-reads))))
5257 (when gnus-tmp-header
5258 ;; We may have an old dummy line to output before this
5259 ;; article.
5260 (when (and gnus-tmp-dummy-line
5261 (gnus-subject-equal
5262 gnus-tmp-dummy-line
5263 (mail-header-subject gnus-tmp-header)))
5264 (gnus-summary-insert-dummy-line
5265 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5266 (setq gnus-tmp-dummy-line nil))
5268 ;; Compute the mark.
5269 (setq gnus-tmp-unread (gnus-article-mark number))
5271 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5272 gnus-tmp-header gnus-tmp-level)
5273 gnus-newsgroup-data)
5275 ;; Actually insert the line.
5276 (setq
5277 gnus-tmp-subject-or-nil
5278 (cond
5279 ((and gnus-thread-ignore-subject
5280 gnus-tmp-prev-subject
5281 (not (string= gnus-tmp-prev-subject simp-subject)))
5282 subject)
5283 ((zerop gnus-tmp-level)
5284 (if (and (eq gnus-summary-make-false-root 'empty)
5285 (memq number gnus-tmp-gathered)
5286 gnus-tmp-prev-subject
5287 (string= gnus-tmp-prev-subject simp-subject))
5288 gnus-summary-same-subject
5289 subject))
5290 (t gnus-summary-same-subject)))
5291 (if (and (eq gnus-summary-make-false-root 'adopt)
5292 (= gnus-tmp-level 1)
5293 (memq number gnus-tmp-gathered))
5294 (setq gnus-tmp-opening-bracket ?\<
5295 gnus-tmp-closing-bracket ?\>)
5296 (setq gnus-tmp-opening-bracket ?\[
5297 gnus-tmp-closing-bracket ?\]))
5298 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5299 (gnus-make-thread-indent-array
5300 (max (* 2 (length gnus-thread-indent-array))
5301 gnus-tmp-level)))
5302 (setq
5303 gnus-tmp-indentation
5304 (aref gnus-thread-indent-array gnus-tmp-level)
5305 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5306 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5307 gnus-summary-default-score 0)
5308 gnus-tmp-score-char
5309 (if (or (null gnus-summary-default-score)
5310 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5311 gnus-summary-zcore-fuzz))
5312 ? ;Whitespace
5313 (if (< gnus-tmp-score gnus-summary-default-score)
5314 gnus-score-below-mark gnus-score-over-mark))
5315 gnus-tmp-replied
5316 (cond ((memq number gnus-newsgroup-processable)
5317 gnus-process-mark)
5318 ((memq number gnus-newsgroup-cached)
5319 gnus-cached-mark)
5320 ((memq number gnus-newsgroup-replied)
5321 gnus-replied-mark)
5322 ((memq number gnus-newsgroup-forwarded)
5323 gnus-forwarded-mark)
5324 ((memq number gnus-newsgroup-saved)
5325 gnus-saved-mark)
5326 ((memq number gnus-newsgroup-recent)
5327 gnus-recent-mark)
5328 ((memq number gnus-newsgroup-unseen)
5329 gnus-unseen-mark)
5330 (t gnus-no-mark))
5331 gnus-tmp-downloaded
5332 (cond ((memq number gnus-newsgroup-undownloaded)
5333 gnus-undownloaded-mark)
5334 (gnus-newsgroup-agentized
5335 gnus-downloaded-mark)
5337 gnus-no-mark))
5338 gnus-tmp-from (mail-header-from gnus-tmp-header)
5339 gnus-tmp-name
5340 (cond
5341 ((string-match "<[^>]+> *$" gnus-tmp-from)
5342 (setq beg-match (match-beginning 0))
5343 (or (and (string-match "^\".+\"" gnus-tmp-from)
5344 (substring gnus-tmp-from 1 (1- (match-end 0))))
5345 (substring gnus-tmp-from 0 beg-match)))
5346 ((string-match "(.+)" gnus-tmp-from)
5347 (substring gnus-tmp-from
5348 (1+ (match-beginning 0)) (1- (match-end 0))))
5349 (t gnus-tmp-from))
5351 ;; Do the %B string
5352 gnus-tmp-thread-tree-header-string
5353 (cond
5354 ((not gnus-show-threads) "")
5355 ((zerop gnus-tmp-level)
5356 (cond ((cdar thread)
5357 (or gnus-sum-thread-tree-root subject))
5358 (gnus-tmp-new-adopts
5359 (or gnus-sum-thread-tree-false-root subject))
5361 (or gnus-sum-thread-tree-single-indent subject))))
5363 (concat (apply 'concat
5364 (mapcar (lambda (item)
5365 (if (= item 1)
5366 gnus-sum-thread-tree-vertical
5367 gnus-sum-thread-tree-indent))
5368 (cdr (reverse tree-stack))))
5369 (if (nth 1 thread)
5370 gnus-sum-thread-tree-leaf-with-other
5371 gnus-sum-thread-tree-single-leaf)))))
5372 (when (string= gnus-tmp-name "")
5373 (setq gnus-tmp-name gnus-tmp-from))
5374 (unless (numberp gnus-tmp-lines)
5375 (setq gnus-tmp-lines -1))
5376 (if (= gnus-tmp-lines -1)
5377 (setq gnus-tmp-lines "?")
5378 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5379 (gnus-put-text-property
5380 (point)
5381 (progn (eval gnus-summary-line-format-spec) (point))
5382 'gnus-number number)
5383 (when gnus-visual-p
5384 (forward-line -1)
5385 (gnus-summary-highlight-line)
5386 (when gnus-summary-update-hook
5387 (gnus-run-hooks 'gnus-summary-update-hook))
5388 (forward-line 1))
5390 (setq gnus-tmp-prev-subject simp-subject)))
5392 (when (nth 1 thread)
5393 (push (list (max 0 gnus-tmp-level)
5394 (copy-sequence tree-stack)
5395 (nthcdr 1 thread))
5396 stack))
5397 (push (if (nth 1 thread) 1 0) tree-stack)
5398 (incf gnus-tmp-level)
5399 (setq threads (if thread-end nil (cdar thread)))
5400 (if gnus-summary-display-while-building
5401 (if building-count
5402 (progn
5403 ;; use a set frequency
5404 (setq building-line-count (1- building-line-count))
5405 (when (= building-line-count 0)
5406 (sit-for 0)
5407 (setq building-line-count
5408 gnus-summary-display-while-building)))
5409 ;; always
5410 (sit-for 0)))
5411 (unless threads
5412 (setq gnus-tmp-level 0)))))
5413 (gnus-message 7 "Generating summary...done"))
5415 (defun gnus-summary-prepare-unthreaded (headers)
5416 "Generate an unthreaded summary buffer based on HEADERS."
5417 (let (header number mark)
5419 (beginning-of-line)
5421 (while headers
5422 ;; We may have to root out some bad articles...
5423 (when (memq (setq number (mail-header-number
5424 (setq header (pop headers))))
5425 gnus-newsgroup-limit)
5426 ;; Mark article as read when it has a low score.
5427 (when (and gnus-summary-mark-below
5428 (< (or (cdr (assq number gnus-newsgroup-scored))
5429 gnus-summary-default-score 0)
5430 gnus-summary-mark-below)
5431 (not (gnus-summary-article-ancient-p number)))
5432 (setq gnus-newsgroup-unreads
5433 (delq number gnus-newsgroup-unreads))
5434 (if gnus-newsgroup-auto-expire
5435 (push number gnus-newsgroup-expirable)
5436 (push (cons number gnus-low-score-mark)
5437 gnus-newsgroup-reads)))
5439 (setq mark (gnus-article-mark number))
5440 (push (gnus-data-make number mark (1+ (point)) header 0)
5441 gnus-newsgroup-data)
5442 (gnus-summary-insert-line
5443 header 0 number
5444 (memq number gnus-newsgroup-undownloaded)
5445 mark (memq number gnus-newsgroup-replied)
5446 (memq number gnus-newsgroup-expirable)
5447 (mail-header-subject header) nil
5448 (cdr (assq number gnus-newsgroup-scored))
5449 (memq number gnus-newsgroup-processable))))))
5451 (defun gnus-summary-remove-list-identifiers ()
5452 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5453 (let ((regexp (if (consp gnus-list-identifiers)
5454 (mapconcat 'identity gnus-list-identifiers " *\\|")
5455 gnus-list-identifiers))
5456 changed subject)
5457 (when regexp
5458 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5459 (dolist (header gnus-newsgroup-headers)
5460 (setq subject (mail-header-subject header)
5461 changed nil)
5462 (while (string-match regexp subject)
5463 (setq subject
5464 (concat (substring subject 0 (match-beginning 1))
5465 (substring subject (match-end 0)))
5466 changed t))
5467 (when changed
5468 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5469 (setq subject
5470 (concat (substring subject 0 (match-beginning 1))
5471 (substring subject (match-end 1)))))
5472 (mail-header-set-subject header subject))))))
5474 (defun gnus-fetch-headers (articles)
5475 "Fetch headers of ARTICLES."
5476 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5477 (gnus-message 5 "Fetching headers for %s..." name)
5478 (prog1
5479 (if (eq 'nov
5480 (setq gnus-headers-retrieved-by
5481 (gnus-retrieve-headers
5482 articles gnus-newsgroup-name
5483 ;; We might want to fetch old headers, but
5484 ;; not if there is only 1 article.
5485 (and (or (and
5486 (not (eq gnus-fetch-old-headers 'some))
5487 (not (numberp gnus-fetch-old-headers)))
5488 (> (length articles) 1))
5489 gnus-fetch-old-headers))))
5490 (gnus-get-newsgroup-headers-xover
5491 articles nil nil gnus-newsgroup-name t)
5492 (gnus-get-newsgroup-headers))
5493 (gnus-message 5 "Fetching headers for %s...done" name))))
5495 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5496 "Select newsgroup GROUP.
5497 If READ-ALL is non-nil, all articles in the group are selected.
5498 If SELECT-ARTICLES, only select those articles from GROUP."
5499 (let* ((entry (gnus-group-entry group))
5500 ;;!!! Dirty hack; should be removed.
5501 (gnus-summary-ignore-duplicates
5502 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5504 gnus-summary-ignore-duplicates))
5505 (info (nth 2 entry))
5506 charset articles fetched-articles cached)
5508 (unless (gnus-check-server
5509 (set (make-local-variable 'gnus-current-select-method)
5510 (gnus-find-method-for-group group)))
5511 (error "Couldn't open server"))
5512 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5514 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5515 (gnus-activate-group group) ; Or we can activate it...
5516 (progn ; Or we bug out.
5517 (when (equal major-mode 'gnus-summary-mode)
5518 (gnus-kill-buffer (current-buffer)))
5519 (error
5520 "Couldn't activate group %s: %s"
5521 (mm-decode-coding-string group charset)
5522 (mm-decode-coding-string (gnus-status-message group) charset))))
5524 (unless (gnus-request-group group t)
5525 (when (equal major-mode 'gnus-summary-mode)
5526 (gnus-kill-buffer (current-buffer)))
5527 (error "Couldn't request group %s: %s"
5528 (mm-decode-coding-string group charset)
5529 (mm-decode-coding-string (gnus-status-message group) charset)))
5531 (when gnus-agent
5532 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5534 (setq gnus-summary-use-undownloaded-faces
5535 (gnus-agent-find-parameter
5536 group
5537 'agent-enable-undownloaded-faces)))
5539 (setq gnus-newsgroup-name group
5540 gnus-newsgroup-unselected nil
5541 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5543 (let ((display (gnus-group-find-parameter group 'display)))
5544 (setq gnus-newsgroup-display
5545 (cond
5546 ((not (zerop (or (car-safe read-all) 0)))
5547 ;; The user entered the group with C-u SPC/RET, let's show
5548 ;; all articles.
5549 'gnus-not-ignore)
5550 ((eq display 'all)
5551 'gnus-not-ignore)
5552 ((arrayp display)
5553 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5554 ((numberp display)
5555 ;; The following is probably the "correct" solution, but
5556 ;; it makes Gnus fetch all headers and then limit the
5557 ;; articles (which is slow), so instead we hack the
5558 ;; select-articles parameter instead. -- Simon Josefsson
5559 ;; <jas@kth.se>
5561 ;; (gnus-byte-compile
5562 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5563 ;; display)))))
5564 (setq select-articles
5565 (gnus-uncompress-range
5566 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5567 (if (> tmp 0)
5570 (cdr (gnus-active group)))))
5571 nil)
5573 nil))))
5575 (gnus-summary-setup-default-charset)
5577 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5578 (when (gnus-virtual-group-p group)
5579 (setq cached gnus-newsgroup-cached))
5581 (setq gnus-newsgroup-unreads
5582 (gnus-sorted-ndifference
5583 (gnus-sorted-ndifference gnus-newsgroup-unreads
5584 gnus-newsgroup-marked)
5585 gnus-newsgroup-dormant))
5587 (setq gnus-newsgroup-processable nil)
5589 (gnus-update-read-articles group gnus-newsgroup-unreads)
5591 ;; Adjust and set lists of article marks.
5592 (when info
5593 (gnus-adjust-marked-articles info))
5594 (if (setq articles select-articles)
5595 (setq gnus-newsgroup-unselected
5596 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5597 (setq articles (gnus-articles-to-read group read-all)))
5599 (cond
5600 ((null articles)
5601 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5602 'quit)
5603 ((eq articles 0) nil)
5605 ;; Init the dependencies hash table.
5606 (setq gnus-newsgroup-dependencies
5607 (gnus-make-hashtable (length articles)))
5608 (gnus-set-global-variables)
5609 ;; Retrieve the headers and read them in.
5611 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5613 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5614 (when cached
5615 (setq gnus-newsgroup-cached cached))
5617 ;; Suppress duplicates?
5618 (when gnus-suppress-duplicates
5619 (gnus-dup-suppress-articles))
5621 ;; Set the initial limit.
5622 (setq gnus-newsgroup-limit (copy-sequence articles))
5623 ;; Remove canceled articles from the list of unread articles.
5624 (setq fetched-articles
5625 (mapcar (lambda (headers) (mail-header-number headers))
5626 gnus-newsgroup-headers))
5627 (setq gnus-newsgroup-articles fetched-articles)
5628 (setq gnus-newsgroup-unreads
5629 (gnus-sorted-nintersection
5630 gnus-newsgroup-unreads fetched-articles))
5631 (gnus-compute-unseen-list)
5633 ;; Removed marked articles that do not exist.
5634 (gnus-update-missing-marks
5635 (gnus-sorted-difference articles fetched-articles))
5636 ;; We might want to build some more threads first.
5637 (when (and gnus-fetch-old-headers
5638 (eq gnus-headers-retrieved-by 'nov))
5639 (if (eq gnus-fetch-old-headers 'invisible)
5640 (gnus-build-all-threads)
5641 (gnus-build-old-threads)))
5642 ;; Let the Gnus agent mark articles as read.
5643 (when gnus-agent
5644 (gnus-agent-get-undownloaded-list))
5645 ;; Remove list identifiers from subject
5646 (when gnus-list-identifiers
5647 (gnus-summary-remove-list-identifiers))
5648 ;; Check whether auto-expire is to be done in this group.
5649 (setq gnus-newsgroup-auto-expire
5650 (gnus-group-auto-expirable-p group))
5651 ;; Set up the article buffer now, if necessary.
5652 (unless (and gnus-single-article-buffer
5653 (equal gnus-article-buffer "*Article*"))
5654 (gnus-article-setup-buffer))
5655 ;; First and last article in this newsgroup.
5656 (when gnus-newsgroup-headers
5657 (setq gnus-newsgroup-begin
5658 (mail-header-number (car gnus-newsgroup-headers))
5659 gnus-newsgroup-end
5660 (mail-header-number
5661 (gnus-last-element gnus-newsgroup-headers))))
5662 ;; GROUP is successfully selected.
5663 (or gnus-newsgroup-headers t)))))
5665 (defun gnus-compute-unseen-list ()
5666 ;; The `seen' marks are treated specially.
5667 (if (not gnus-newsgroup-seen)
5668 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5669 (setq gnus-newsgroup-unseen
5670 (gnus-inverse-list-range-intersection
5671 gnus-newsgroup-articles gnus-newsgroup-seen))))
5673 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5675 (defun gnus-summary-display-make-predicate (display)
5676 (require 'gnus-agent)
5677 (when (= (length display) 1)
5678 (setq display (car display)))
5679 (unless gnus-summary-display-cache
5680 (dolist (elem (append '((unread . unread)
5681 (read . read)
5682 (unseen . unseen))
5683 gnus-article-mark-lists))
5684 (push (cons (cdr elem)
5685 (gnus-byte-compile ;Why bother?
5686 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5687 gnus-summary-display-cache)))
5688 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5689 (gnus-category-predicate-cache gnus-summary-display-cache))
5690 (gnus-get-predicate display)))
5692 ;; Uses the dynamically bound `gnus-number' variable.
5693 (defvar gnus-number)
5694 (defun gnus-article-marked-p (type &optional article)
5695 (let ((article (or article gnus-number)))
5696 (cond
5697 ((eq type 'tick)
5698 (memq article gnus-newsgroup-marked))
5699 ((eq type 'spam)
5700 (memq article gnus-newsgroup-spam-marked))
5701 ((eq type 'unsend)
5702 (memq article gnus-newsgroup-unsendable))
5703 ((eq type 'undownload)
5704 (memq article gnus-newsgroup-undownloaded))
5705 ((eq type 'download)
5706 (memq article gnus-newsgroup-downloadable))
5707 ((eq type 'unread)
5708 (memq article gnus-newsgroup-unreads))
5709 ((eq type 'read)
5710 (memq article gnus-newsgroup-reads))
5711 ((eq type 'dormant)
5712 (memq article gnus-newsgroup-dormant) )
5713 ((eq type 'expire)
5714 (memq article gnus-newsgroup-expirable))
5715 ((eq type 'reply)
5716 (memq article gnus-newsgroup-replied))
5717 ((eq type 'killed)
5718 (memq article gnus-newsgroup-killed))
5719 ((eq type 'bookmark)
5720 (assq article gnus-newsgroup-bookmarks))
5721 ((eq type 'score)
5722 (assq article gnus-newsgroup-scored))
5723 ((eq type 'save)
5724 (memq article gnus-newsgroup-saved))
5725 ((eq type 'cache)
5726 (memq article gnus-newsgroup-cached))
5727 ((eq type 'forward)
5728 (memq article gnus-newsgroup-forwarded))
5729 ((eq type 'seen)
5730 (not (memq article gnus-newsgroup-unseen)))
5731 ((eq type 'recent)
5732 (memq article gnus-newsgroup-recent))
5733 (t t))))
5735 (defun gnus-articles-to-read (group &optional read-all)
5736 "Find out what articles the user wants to read."
5737 (let* ((articles
5738 ;; Select all articles if `read-all' is non-nil, or if there
5739 ;; are no unread articles.
5740 (if (or read-all
5741 (and (zerop (length gnus-newsgroup-marked))
5742 (zerop (length gnus-newsgroup-unreads)))
5743 ;; Fetch all if the predicate is non-nil.
5744 gnus-newsgroup-display)
5745 ;; We want to select the headers for all the articles in
5746 ;; the group, so we select either all the active
5747 ;; articles in the group, or (if that's nil), the
5748 ;; articles in the cache.
5750 (if gnus-newsgroup-maximum-articles
5751 (let ((active (gnus-active group)))
5752 (gnus-uncompress-range
5753 (cons (max (car active)
5754 (- (cdr active)
5755 gnus-newsgroup-maximum-articles
5756 -1))
5757 (cdr active))))
5758 (gnus-uncompress-range (gnus-active group)))
5759 (gnus-cache-articles-in-group group))
5760 ;; Select only the "normal" subset of articles.
5761 (gnus-sorted-nunion
5762 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5763 gnus-newsgroup-unreads)))
5764 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5765 (scored (length scored-list))
5766 (number (length articles))
5767 (marked (+ (length gnus-newsgroup-marked)
5768 (length gnus-newsgroup-dormant)))
5769 (select
5770 (cond
5771 ((numberp read-all)
5772 read-all)
5773 ((numberp gnus-newsgroup-display)
5774 gnus-newsgroup-display)
5776 (condition-case ()
5777 (cond
5778 ((and (or (<= scored marked) (= scored number))
5779 (numberp gnus-large-newsgroup)
5780 (> number gnus-large-newsgroup))
5781 (let* ((cursor-in-echo-area nil)
5782 (initial (gnus-parameter-large-newsgroup-initial
5783 gnus-newsgroup-name))
5784 (input
5785 (read-string
5786 (format
5787 "How many articles from %s (%s %d): "
5788 (gnus-group-decoded-name gnus-newsgroup-name)
5789 (if initial "max" "default")
5790 number)
5791 (if initial
5792 (cons (number-to-string initial)
5793 0)))))
5794 (if (string-match "^[ \t]*$" input) number input)))
5795 ((and (> scored marked) (< scored number)
5796 (> (- scored number) 20))
5797 (let ((input
5798 (read-string
5799 (format "%s %s (%d scored, %d total): "
5800 "How many articles from"
5801 (gnus-group-decoded-name group)
5802 scored number))))
5803 (if (string-match "^[ \t]*$" input)
5804 number input)))
5805 (t number))
5806 (quit
5807 (message "Quit getting the articles to read")
5808 nil))))))
5809 (setq select (if (stringp select) (string-to-number select) select))
5810 (if (or (null select) (zerop select))
5811 select
5812 (if (and (not (zerop scored)) (<= (abs select) scored))
5813 (progn
5814 (setq articles (sort scored-list '<))
5815 (setq number (length articles)))
5816 (setq articles (copy-sequence articles)))
5818 (when (< (abs select) number)
5819 (if (< select 0)
5820 ;; Select the N oldest articles.
5821 (setcdr (nthcdr (1- (abs select)) articles) nil)
5822 ;; Select the N most recent articles.
5823 (setq articles (nthcdr (- number select) articles))))
5824 (setq gnus-newsgroup-unselected
5825 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5826 (when gnus-alter-articles-to-read-function
5827 (setq articles
5828 (sort
5829 (funcall gnus-alter-articles-to-read-function
5830 gnus-newsgroup-name articles)
5831 '<)))
5832 articles)))
5834 (defun gnus-killed-articles (killed articles)
5835 (let (out)
5836 (while articles
5837 (when (inline (gnus-member-of-range (car articles) killed))
5838 (push (car articles) out))
5839 (setq articles (cdr articles)))
5840 out))
5842 (defun gnus-uncompress-marks (marks)
5843 "Uncompress the mark ranges in MARKS."
5844 (let ((uncompressed '(score bookmark))
5845 out)
5846 (while marks
5847 (if (memq (caar marks) uncompressed)
5848 (push (car marks) out)
5849 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5850 (setq marks (cdr marks)))
5851 out))
5853 (defun gnus-article-mark-to-type (mark)
5854 "Return the type of MARK."
5855 (or (cadr (assq mark gnus-article-special-mark-lists))
5856 'list))
5858 (defun gnus-article-unpropagatable-p (mark)
5859 "Return whether MARK should be propagated to back end."
5860 (memq mark gnus-article-unpropagated-mark-lists))
5862 (defun gnus-adjust-marked-articles (info)
5863 "Set all article lists and remove all marks that are no longer valid."
5864 (let* ((marked-lists (gnus-info-marks info))
5865 (active (gnus-active (gnus-info-group info)))
5866 (min (car active))
5867 (max (cdr active))
5868 (types gnus-article-mark-lists)
5869 marks var articles article mark mark-type
5870 bgn end)
5871 ;; Hack to avoid adjusting marks for imap.
5872 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5873 'nnimap)
5874 (setq min 1))
5876 (dolist (marks marked-lists)
5877 (setq mark (car marks)
5878 mark-type (gnus-article-mark-to-type mark)
5879 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5881 ;; We set the variable according to the type of the marks list,
5882 ;; and then adjust the marks to a subset of the active articles.
5883 (cond
5884 ;; Adjust "simple" lists - compressed yet unsorted
5885 ((eq mark-type 'list)
5886 ;; Simultaneously uncompress and clip to active range
5887 ;; See gnus-uncompress-range for a description of possible marks
5888 (let (l lh)
5889 (if (not (cadr marks))
5890 (set var nil)
5891 (setq articles (if (numberp (cddr marks))
5892 (list (cdr marks))
5893 (cdr marks))
5894 lh (cons nil nil)
5895 l lh)
5897 (while (setq article (pop articles))
5898 (cond ((consp article)
5899 (setq bgn (max (car article) min)
5900 end (min (cdr article) max))
5901 (while (<= bgn end)
5902 (setq l (setcdr l (cons bgn nil))
5903 bgn (1+ bgn))))
5904 ((and (<= min article)
5905 (>= max article))
5906 (setq l (setcdr l (cons article nil))))))
5907 (set var (cdr lh)))))
5908 ;; Adjust assocs.
5909 ((eq mark-type 'tuple)
5910 (set var (setq articles (cdr marks)))
5911 (when (not (listp (cdr (symbol-value var))))
5912 (set var (list (symbol-value var))))
5913 (when (not (listp (cdr articles)))
5914 (setq articles (list articles)))
5915 (while articles
5916 (when (or (not (consp (setq article (pop articles))))
5917 (< (car article) min)
5918 (> (car article) max))
5919 (set var (delq article (symbol-value var))))))
5920 ;; Adjust ranges (sloppily).
5921 ((eq mark-type 'range)
5922 (cond
5923 ((eq mark 'seen)
5924 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5925 ;; It should be (seen (NUM1 . NUM2)).
5926 (when (numberp (cddr marks))
5927 (setcdr marks (list (cdr marks))))
5928 (setq articles (cdr marks))
5929 (while (and articles
5930 (or (and (consp (car articles))
5931 (> min (cdar articles)))
5932 (and (numberp (car articles))
5933 (> min (car articles)))))
5934 (pop articles))
5935 (set var articles))))))))
5937 (defun gnus-update-missing-marks (missing)
5938 "Go through the list of MISSING articles and remove them from the mark lists."
5939 (when missing
5940 (let (var m)
5941 ;; Go through all types.
5942 (dolist (elem gnus-article-mark-lists)
5943 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5944 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5945 (when (symbol-value var)
5946 ;; This list has articles. So we delete all missing
5947 ;; articles from it.
5948 (setq m missing)
5949 (while m
5950 (set var (delq (pop m) (symbol-value var))))))))))
5952 (defun gnus-update-marks ()
5953 "Enter the various lists of marked articles into the newsgroup info list."
5954 (let ((types gnus-article-mark-lists)
5955 (info (gnus-get-info gnus-newsgroup-name))
5956 type list newmarked symbol delta-marks)
5957 (when info
5958 ;; Add all marks lists to the list of marks lists.
5959 (while (setq type (pop types))
5960 (setq list (symbol-value
5961 (setq symbol
5962 (intern (format "gnus-newsgroup-%s" (car type))))))
5964 (when list
5965 ;; Get rid of the entries of the articles that have the
5966 ;; default score.
5967 (when (and (eq (cdr type) 'score)
5968 gnus-save-score
5969 list)
5970 (let* ((arts list)
5971 (prev (cons nil list))
5972 (all prev))
5973 (while arts
5974 (if (or (not (consp (car arts)))
5975 (= (cdar arts) gnus-summary-default-score))
5976 (setcdr prev (cdr arts))
5977 (setq prev arts))
5978 (setq arts (cdr arts)))
5979 (setq list (cdr all)))))
5981 (when (eq (cdr type) 'seen)
5982 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5984 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5985 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5987 (when (and (gnus-check-backend-function
5988 'request-set-mark gnus-newsgroup-name)
5989 (not (gnus-article-unpropagatable-p (cdr type))))
5990 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5991 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5992 (add (gnus-remove-from-range
5993 (gnus-copy-sequence list) old)))
5994 (when add
5995 (push (list add 'add (list (cdr type))) delta-marks))
5996 (when del
5997 ;; Don't delete marks from outside the active range. This
5998 ;; shouldn't happen, but is a sanity check.
5999 (setq del (gnus-sorted-range-intersection
6000 (gnus-active gnus-newsgroup-name) del))
6001 (push (list del 'del (list (cdr type))) delta-marks))))
6003 (when list
6004 (push (cons (cdr type) list) newmarked)))
6006 (when delta-marks
6007 (unless (gnus-check-group gnus-newsgroup-name)
6008 (error "Can't open server for %s" gnus-newsgroup-name))
6009 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6011 ;; Enter these new marks into the info of the group.
6012 (if (nthcdr 3 info)
6013 (setcar (nthcdr 3 info) newmarked)
6014 ;; Add the marks lists to the end of the info.
6015 (when newmarked
6016 (setcdr (nthcdr 2 info) (list newmarked))))
6018 ;; Cut off the end of the info if there's nothing else there.
6019 (let ((i 5))
6020 (while (and (> i 2)
6021 (not (nth i info)))
6022 (when (nthcdr (decf i) info)
6023 (setcdr (nthcdr i info) nil)))))))
6025 (defun gnus-set-mode-line (where)
6026 "Set the mode line of the article or summary buffers.
6027 If WHERE is `summary', the summary mode line format will be used."
6028 ;; Is this mode line one we keep updated?
6029 (when (and (memq where gnus-updated-mode-lines)
6030 (symbol-value
6031 (intern (format "gnus-%s-mode-line-format-spec" where))))
6032 (let (mode-string)
6033 ;; We evaluate this in the summary buffer since these
6034 ;; variables are buffer-local to that buffer.
6035 (with-current-buffer gnus-summary-buffer
6036 ;; We bind all these variables that are used in the `eval' form
6037 ;; below.
6038 (let* ((mformat (symbol-value
6039 (intern
6040 (format "gnus-%s-mode-line-format-spec" where))))
6041 (gnus-tmp-group-name (gnus-mode-string-quote
6042 (gnus-group-decoded-name
6043 gnus-newsgroup-name)))
6044 (gnus-tmp-article-number (or gnus-current-article 0))
6045 (gnus-tmp-unread gnus-newsgroup-unreads)
6046 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6047 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6048 (gnus-tmp-unread-and-unselected
6049 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6050 (zerop gnus-tmp-unselected))
6052 ((zerop gnus-tmp-unselected)
6053 (format "{%d more}" gnus-tmp-unread-and-unticked))
6054 (t (format "{%d(+%d) more}"
6055 gnus-tmp-unread-and-unticked
6056 gnus-tmp-unselected))))
6057 (gnus-tmp-subject
6058 (if (and gnus-current-headers
6059 (vectorp gnus-current-headers))
6060 (gnus-mode-string-quote
6061 (mail-header-subject gnus-current-headers))
6062 ""))
6063 bufname-length max-len
6064 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6065 (setq mode-string (eval mformat))
6066 (setq bufname-length (if (string-match "%b" mode-string)
6067 (- (length
6068 (buffer-name
6069 (if (eq where 'summary)
6071 (get-buffer gnus-article-buffer))))
6074 (setq max-len (max 4 (if gnus-mode-non-string-length
6075 (- (window-width)
6076 gnus-mode-non-string-length
6077 bufname-length)
6078 (length mode-string))))
6079 ;; We might have to chop a bit of the string off...
6080 (when (> (length mode-string) max-len)
6081 (setq mode-string
6082 (concat (truncate-string-to-width mode-string (- max-len 3))
6083 "...")))))
6084 ;; Update the mode line.
6085 (setq mode-line-buffer-identification
6086 (gnus-mode-line-buffer-identification (list mode-string)))
6087 (set-buffer-modified-p t))))
6089 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6090 "Go through the HEADERS list and add all Xrefs to a hash table.
6091 The resulting hash table is returned, or nil if no Xrefs were found."
6092 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6093 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6094 (xref-hashtb (gnus-make-hashtable))
6095 start group entry number xrefs header)
6096 (while headers
6097 (setq header (pop headers))
6098 (when (and (setq xrefs (mail-header-xref header))
6099 (not (memq (setq number (mail-header-number header))
6100 unreads)))
6101 (setq start 0)
6102 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6103 (setq start (match-end 0))
6104 (setq group (if prefix
6105 (concat prefix (substring xrefs (match-beginning 1)
6106 (match-end 1)))
6107 (substring xrefs (match-beginning 1) (match-end 1))))
6108 (setq number
6109 (string-to-number (substring xrefs (match-beginning 2)
6110 (match-end 2))))
6111 (if (setq entry (gnus-gethash group xref-hashtb))
6112 (setcdr entry (cons number (cdr entry)))
6113 (gnus-sethash group (cons number nil) xref-hashtb)))))
6114 (and start xref-hashtb)))
6116 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6117 "Look through all the headers and mark the Xrefs as read."
6118 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6119 name info xref-hashtb idlist method nth4)
6120 (with-current-buffer gnus-group-buffer
6121 (when (setq xref-hashtb
6122 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6123 (mapatoms
6124 (lambda (group)
6125 (unless (string= from-newsgroup (setq name (symbol-name group)))
6126 (setq idlist (symbol-value group))
6127 ;; Dead groups are not updated.
6128 (and (prog1
6129 (setq info (gnus-get-info name))
6130 (when (stringp (setq nth4 (gnus-info-method info)))
6131 (setq nth4 (gnus-server-to-method nth4))))
6132 ;; Only do the xrefs if the group has the same
6133 ;; select method as the group we have just read.
6134 (or (gnus-methods-equal-p
6135 nth4 (gnus-find-method-for-group from-newsgroup))
6136 virtual
6137 (equal nth4 (setq method (gnus-find-method-for-group
6138 from-newsgroup)))
6139 (and (equal (car nth4) (car method))
6140 (equal (nth 1 nth4) (nth 1 method))))
6141 gnus-use-cross-reference
6142 (or (not (eq gnus-use-cross-reference t))
6143 virtual
6144 ;; Only do cross-references on subscribed
6145 ;; groups, if that is what is wanted.
6146 (<= (gnus-info-level info) gnus-level-subscribed))
6147 (gnus-group-make-articles-read name idlist))))
6148 xref-hashtb)))))
6150 (defun gnus-compute-read-articles (group articles)
6151 (let* ((entry (gnus-group-entry group))
6152 (info (nth 2 entry))
6153 (active (gnus-active group))
6154 ninfo)
6155 (when entry
6156 ;; First peel off all invalid article numbers.
6157 (when active
6158 (let ((ids articles)
6159 id first)
6160 (while (setq id (pop ids))
6161 (when (and first (> id (cdr active)))
6162 ;; We'll end up in this situation in one particular
6163 ;; obscure situation. If you re-scan a group and get
6164 ;; a new article that is cross-posted to a different
6165 ;; group that has not been re-scanned, you might get
6166 ;; crossposted article that has a higher number than
6167 ;; Gnus believes possible. So we re-activate this
6168 ;; group as well. This might mean doing the
6169 ;; crossposting thingy will *increase* the number
6170 ;; of articles in some groups. Tsk, tsk.
6171 (setq active (or (gnus-activate-group group) active)))
6172 (when (or (> id (cdr active))
6173 (< id (car active)))
6174 (setq articles (delq id articles))))))
6175 ;; If the read list is nil, we init it.
6176 (if (and active
6177 (null (gnus-info-read info))
6178 (> (car active) 1))
6179 (setq ninfo (cons 1 (1- (car active))))
6180 (setq ninfo (gnus-info-read info)))
6181 ;; Then we add the read articles to the range.
6182 (gnus-add-to-range
6183 ninfo (setq articles (sort articles '<))))))
6185 (defun gnus-group-make-articles-read (group articles)
6186 "Update the info of GROUP to say that ARTICLES are read."
6187 (let* ((num 0)
6188 (entry (gnus-group-entry group))
6189 (info (nth 2 entry))
6190 (active (gnus-active group))
6191 range)
6192 (when entry
6193 (setq range (gnus-compute-read-articles group articles))
6194 (with-current-buffer gnus-group-buffer
6195 (gnus-undo-register
6196 `(progn
6197 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6198 (gnus-info-set-read ',info ',(gnus-info-read info))
6199 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6200 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6201 (gnus-group-update-group ,group t))))
6202 ;; Add the read articles to the range.
6203 (gnus-info-set-read info range)
6204 (gnus-request-set-mark group (list (list range 'add '(read))))
6205 ;; Then we have to re-compute how many unread
6206 ;; articles there are in this group.
6207 (when active
6208 (cond
6209 ((not range)
6210 (setq num (- (1+ (cdr active)) (car active))))
6211 ((not (listp (cdr range)))
6212 (setq num (- (cdr active) (- (1+ (cdr range))
6213 (car range)))))
6215 (while range
6216 (if (numberp (car range))
6217 (setq num (1+ num))
6218 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6219 (setq range (cdr range)))
6220 (setq num (- (cdr active) num))))
6221 ;; Update the number of unread articles.
6222 (setcar entry num)
6223 ;; Update the group buffer.
6224 (unless (gnus-ephemeral-group-p group)
6225 (gnus-group-update-group group t))))))
6227 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6228 (let ((cur nntp-server-buffer)
6229 (dependencies
6230 (or dependencies
6231 (with-current-buffer gnus-summary-buffer
6232 gnus-newsgroup-dependencies)))
6233 headers id end ref number
6234 (mail-parse-charset gnus-newsgroup-charset)
6235 (mail-parse-ignored-charsets
6236 (save-current-buffer (condition-case nil
6237 (set-buffer gnus-summary-buffer)
6238 (error))
6239 gnus-newsgroup-ignored-charsets)))
6240 (with-current-buffer nntp-server-buffer
6241 ;; Translate all TAB characters into SPACE characters.
6242 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6243 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6244 (ietf-drums-unfold-fws)
6245 (gnus-run-hooks 'gnus-parse-headers-hook)
6246 (let ((case-fold-search t)
6247 in-reply-to header p lines chars)
6248 (goto-char (point-min))
6249 ;; Search to the beginning of the next header. Error messages
6250 ;; do not begin with 2 or 3.
6251 (while (re-search-forward "^[23][0-9]+ " nil t)
6252 (setq id nil
6253 ref nil)
6254 ;; This implementation of this function, with nine
6255 ;; search-forwards instead of the one re-search-forward and
6256 ;; a case (which basically was the old function) is actually
6257 ;; about twice as fast, even though it looks messier. You
6258 ;; can't have everything, I guess. Speed and elegance
6259 ;; doesn't always go hand in hand.
6260 (setq
6261 header
6262 (vector
6263 ;; Number.
6264 (prog1
6265 (setq number (read cur))
6266 (end-of-line)
6267 (setq p (point))
6268 (narrow-to-region (point)
6269 (or (and (search-forward "\n.\n" nil t)
6270 (- (point) 2))
6271 (point))))
6272 ;; Subject.
6273 (progn
6274 (goto-char p)
6275 (if (search-forward "\nsubject:" nil t)
6276 (funcall gnus-decode-encoded-word-function
6277 (nnheader-header-value))
6278 "(none)"))
6279 ;; From.
6280 (progn
6281 (goto-char p)
6282 (if (search-forward "\nfrom:" nil t)
6283 (funcall gnus-decode-encoded-address-function
6284 (nnheader-header-value))
6285 "(nobody)"))
6286 ;; Date.
6287 (progn
6288 (goto-char p)
6289 (if (search-forward "\ndate:" nil t)
6290 (nnheader-header-value) ""))
6291 ;; Message-ID.
6292 (progn
6293 (goto-char p)
6294 (setq id (if (re-search-forward
6295 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6296 ;; We do it this way to make sure the Message-ID
6297 ;; is (somewhat) syntactically valid.
6298 (buffer-substring (match-beginning 1)
6299 (match-end 1))
6300 ;; If there was no message-id, we just fake one
6301 ;; to make subsequent routines simpler.
6302 (nnheader-generate-fake-message-id number))))
6303 ;; References.
6304 (progn
6305 (goto-char p)
6306 (if (search-forward "\nreferences:" nil t)
6307 (progn
6308 (setq end (point))
6309 (prog1
6310 (nnheader-header-value)
6311 (setq ref
6312 (buffer-substring
6313 (progn
6314 (end-of-line)
6315 (search-backward ">" end t)
6316 (1+ (point)))
6317 (progn
6318 (search-backward "<" end t)
6319 (point))))))
6320 ;; Get the references from the in-reply-to header if there
6321 ;; were no references and the in-reply-to header looks
6322 ;; promising.
6323 (if (and (search-forward "\nin-reply-to:" nil t)
6324 (setq in-reply-to (nnheader-header-value))
6325 (string-match "<[^>]+>" in-reply-to))
6326 (let (ref2)
6327 (setq ref (substring in-reply-to (match-beginning 0)
6328 (match-end 0)))
6329 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6330 (setq ref2 (substring in-reply-to (match-beginning 0)
6331 (match-end 0)))
6332 (when (> (length ref2) (length ref))
6333 (setq ref ref2)))
6334 ref)
6335 (setq ref nil))))
6336 ;; Chars.
6337 (progn
6338 (goto-char p)
6339 (if (search-forward "\nchars: " nil t)
6340 (if (numberp (setq chars (ignore-errors (read cur))))
6341 chars -1)
6342 -1))
6343 ;; Lines.
6344 (progn
6345 (goto-char p)
6346 (if (search-forward "\nlines: " nil t)
6347 (if (numberp (setq lines (ignore-errors (read cur))))
6348 lines -1)
6349 -1))
6350 ;; Xref.
6351 (progn
6352 (goto-char p)
6353 (and (search-forward "\nxref:" nil t)
6354 (nnheader-header-value)))
6355 ;; Extra.
6356 (when gnus-extra-headers
6357 (let ((extra gnus-extra-headers)
6358 out)
6359 (while extra
6360 (goto-char p)
6361 (when (search-forward
6362 (concat "\n" (symbol-name (car extra)) ":") nil t)
6363 (push (cons (car extra) (nnheader-header-value))
6364 out))
6365 (pop extra))
6366 out))))
6367 (when (equal id ref)
6368 (setq ref nil))
6370 (when gnus-alter-header-function
6371 (funcall gnus-alter-header-function header)
6372 (setq id (mail-header-id header)
6373 ref (gnus-parent-id (mail-header-references header))))
6375 (when (setq header
6376 (gnus-dependencies-add-header
6377 header dependencies force-new))
6378 (push header headers))
6379 (goto-char (point-max))
6380 (widen))
6381 (nreverse headers)))))
6383 ;; Goes through the xover lines and returns a list of vectors
6384 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6385 force-new dependencies
6386 group also-fetch-heads)
6387 "Parse the news overview data in the server buffer.
6388 Return a list of headers that match SEQUENCE (see
6389 `nntp-retrieve-headers')."
6390 ;; Get the Xref when the users reads the articles since most/some
6391 ;; NNTP servers do not include Xrefs when using XOVER.
6392 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6393 (let ((mail-parse-charset gnus-newsgroup-charset)
6394 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6395 (cur nntp-server-buffer)
6396 (dependencies (or dependencies gnus-newsgroup-dependencies))
6397 (allp (cond
6398 ((eq gnus-read-all-available-headers t)
6400 ((and (stringp gnus-read-all-available-headers)
6401 group)
6402 (string-match gnus-read-all-available-headers group))
6404 nil)))
6405 number headers header)
6406 (with-current-buffer nntp-server-buffer
6407 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6408 ;; Allow the user to mangle the headers before parsing them.
6409 (gnus-run-hooks 'gnus-parse-headers-hook)
6410 (goto-char (point-min))
6411 (gnus-parse-without-error
6412 (while (and (or sequence allp)
6413 (not (eobp)))
6414 (setq number (read cur))
6415 (when (not allp)
6416 (while (and sequence
6417 (< (car sequence) number))
6418 (setq sequence (cdr sequence))))
6419 (when (and (or allp
6420 (and sequence
6421 (eq number (car sequence))))
6422 (progn
6423 (setq sequence (cdr sequence))
6424 (setq header (inline
6425 (gnus-nov-parse-line
6426 number dependencies force-new)))))
6427 (push header headers))
6428 (forward-line 1)))
6429 ;; A common bug in inn is that if you have posted an article and
6430 ;; then retrieves the active file, it will answer correctly --
6431 ;; the new article is included. However, a NOV entry for the
6432 ;; article may not have been generated yet, so this may fail.
6433 ;; We work around this problem by retrieving the last few
6434 ;; headers using HEAD.
6435 (if (or (not also-fetch-heads)
6436 (not sequence))
6437 ;; We (probably) got all the headers.
6438 (nreverse headers)
6439 (let ((gnus-nov-is-evil t))
6440 (nconc
6441 (nreverse headers)
6442 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6443 (gnus-get-newsgroup-headers))))))))
6445 (defun gnus-article-get-xrefs ()
6446 "Fill in the Xref value in `gnus-current-headers', if necessary.
6447 This is meant to be called in `gnus-article-internal-prepare-hook'."
6448 (let ((headers (with-current-buffer gnus-summary-buffer
6449 gnus-current-headers)))
6450 (or (not gnus-use-cross-reference)
6451 (not headers)
6452 (and (mail-header-xref headers)
6453 (not (string= (mail-header-xref headers) "")))
6454 (let ((case-fold-search t)
6455 xref)
6456 (save-restriction
6457 (nnheader-narrow-to-headers)
6458 (goto-char (point-min))
6459 (when (or (and (not (eobp))
6460 (eq (downcase (char-after)) ?x)
6461 (looking-at "Xref:"))
6462 (search-forward "\nXref:" nil t))
6463 (goto-char (1+ (match-end 0)))
6464 (setq xref (buffer-substring (point) (point-at-eol)))
6465 (mail-header-set-xref headers xref)))))))
6467 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6468 "Find article ID and insert the summary line for that article.
6469 OLD-HEADER can either be a header or a line number to insert
6470 the subject line on."
6471 (let* ((line (and (numberp old-header) old-header))
6472 (old-header (and (vectorp old-header) old-header))
6473 (header (cond ((and old-header use-old-header)
6474 old-header)
6475 ((and (numberp id)
6476 (gnus-number-to-header id))
6477 (gnus-number-to-header id))
6479 (gnus-read-header id))))
6480 (number (and (numberp id) id))
6482 (when header
6483 ;; Rebuild the thread that this article is part of and go to the
6484 ;; article we have fetched.
6485 (when (and (not gnus-show-threads)
6486 old-header)
6487 (when (and number
6488 (setq d (gnus-data-find (mail-header-number old-header))))
6489 (goto-char (gnus-data-pos d))
6490 (gnus-data-remove
6491 number
6492 (- (point-at-bol)
6493 (prog1
6494 (1+ (point-at-eol))
6495 (gnus-delete-line))))))
6496 ;; Remove list identifiers from subject.
6497 (when gnus-list-identifiers
6498 (let ((gnus-newsgroup-headers (list header)))
6499 (gnus-summary-remove-list-identifiers)))
6500 (when old-header
6501 (mail-header-set-number header (mail-header-number old-header)))
6502 (setq gnus-newsgroup-sparse
6503 (delq (setq number (mail-header-number header))
6504 gnus-newsgroup-sparse))
6505 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6506 (push number gnus-newsgroup-limit)
6507 (gnus-rebuild-thread (mail-header-id header) line)
6508 (gnus-summary-goto-subject number nil t))
6509 (when (and (numberp number)
6510 (> number 0))
6511 ;; We have to update the boundaries even if we can't fetch the
6512 ;; article if ID is a number -- so that the next `P' or `N'
6513 ;; command will fetch the previous (or next) article even
6514 ;; if the one we tried to fetch this time has been canceled.
6515 (when (> number gnus-newsgroup-end)
6516 (setq gnus-newsgroup-end number))
6517 (when (< number gnus-newsgroup-begin)
6518 (setq gnus-newsgroup-begin number))
6519 (setq gnus-newsgroup-unselected
6520 (delq number gnus-newsgroup-unselected)))
6521 ;; Report back a success?
6522 (and header (mail-header-number header))))
6524 ;;; Process/prefix in the summary buffer
6526 (defun gnus-summary-work-articles (n)
6527 "Return a list of articles to be worked upon.
6528 The prefix argument, the list of process marked articles, and the
6529 current article will be taken into consideration."
6530 (with-current-buffer gnus-summary-buffer
6531 (cond
6533 ;; A numerical prefix has been given.
6534 (setq n (prefix-numeric-value n))
6535 (let ((backward (< n 0))
6536 (n (abs (prefix-numeric-value n)))
6537 articles article)
6538 (save-excursion
6539 (while
6540 (and (> n 0)
6541 (push (setq article (gnus-summary-article-number))
6542 articles)
6543 (if backward
6544 (gnus-summary-find-prev nil article)
6545 (gnus-summary-find-next nil article)))
6546 (decf n)))
6547 (nreverse articles)))
6548 ((and (gnus-region-active-p) (mark))
6549 (message "region active")
6550 ;; Work on the region between point and mark.
6551 (let ((max (max (point) (mark)))
6552 articles article)
6553 (save-excursion
6554 (goto-char (min (point) (mark)))
6555 (while
6556 (and
6557 (push (setq article (gnus-summary-article-number)) articles)
6558 (gnus-summary-find-next nil article)
6559 (< (point) max)))
6560 (nreverse articles))))
6561 (gnus-newsgroup-processable
6562 ;; There are process-marked articles present.
6563 ;; Save current state.
6564 (gnus-summary-save-process-mark)
6565 ;; Return the list.
6566 (reverse gnus-newsgroup-processable))
6568 ;; Just return the current article.
6569 (list (gnus-summary-article-number))))))
6571 (defmacro gnus-summary-iterate (arg &rest forms)
6572 "Iterate over the process/prefixed articles and do FORMS.
6573 ARG is the interactive prefix given to the command. FORMS will be
6574 executed with point over the summary line of the articles."
6575 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6576 `(let ((,articles (gnus-summary-work-articles ,arg)))
6577 (while ,articles
6578 (gnus-summary-goto-subject (car ,articles))
6579 ,@forms
6580 (pop ,articles)))))
6582 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6583 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6585 (defun gnus-summary-save-process-mark ()
6586 "Push the current set of process marked articles on the stack."
6587 (interactive)
6588 (push (copy-sequence gnus-newsgroup-processable)
6589 gnus-newsgroup-process-stack))
6591 (defun gnus-summary-kill-process-mark ()
6592 "Push the current set of process marked articles on the stack and unmark."
6593 (interactive)
6594 (gnus-summary-save-process-mark)
6595 (gnus-summary-unmark-all-processable))
6597 (defun gnus-summary-yank-process-mark ()
6598 "Pop the last process mark state off the stack and restore it."
6599 (interactive)
6600 (unless gnus-newsgroup-process-stack
6601 (error "Empty mark stack"))
6602 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6604 (defun gnus-summary-process-mark-set (set)
6605 "Make SET into the current process marked articles."
6606 (gnus-summary-unmark-all-processable)
6607 (mapc 'gnus-summary-set-process-mark set))
6609 ;;; Searching and stuff
6611 (defun gnus-summary-search-group (&optional backward use-level)
6612 "Search for next unread newsgroup.
6613 If optional argument BACKWARD is non-nil, search backward instead."
6614 (with-current-buffer gnus-group-buffer
6615 (when (gnus-group-search-forward
6616 backward nil (if use-level (gnus-group-group-level) nil))
6617 (gnus-group-group-name))))
6619 (defun gnus-summary-best-group (&optional exclude-group)
6620 "Find the name of the best unread group.
6621 If EXCLUDE-GROUP, do not go to this group."
6622 (with-current-buffer gnus-group-buffer
6623 (save-excursion
6624 (gnus-group-best-unread-group exclude-group))))
6626 (defun gnus-summary-find-next (&optional unread article backward)
6627 (if backward
6628 (gnus-summary-find-prev unread article)
6629 (let* ((dummy (gnus-summary-article-intangible-p))
6630 (article (or article (gnus-summary-article-number)))
6631 (data (gnus-data-find-list article))
6632 result)
6633 (when (and (not dummy)
6634 (or (not gnus-summary-check-current)
6635 (not unread)
6636 (not (gnus-data-unread-p (car data)))))
6637 (setq data (cdr data)))
6638 (when (setq result
6639 (if unread
6640 (progn
6641 (while data
6642 (unless (memq (gnus-data-number (car data))
6643 (cond
6644 ((eq gnus-auto-goto-ignores
6645 'always-undownloaded)
6646 gnus-newsgroup-undownloaded)
6647 (gnus-plugged
6648 nil)
6649 ((eq gnus-auto-goto-ignores
6650 'unfetched)
6651 gnus-newsgroup-unfetched)
6652 ((eq gnus-auto-goto-ignores
6653 'undownloaded)
6654 gnus-newsgroup-undownloaded)))
6655 (when (gnus-data-unread-p (car data))
6656 (setq result (car data)
6657 data nil)))
6658 (setq data (cdr data)))
6659 result)
6660 (car data)))
6661 (goto-char (gnus-data-pos result))
6662 (gnus-data-number result)))))
6664 (defun gnus-summary-find-prev (&optional unread article)
6665 (let* ((eobp (eobp))
6666 (article (or article (gnus-summary-article-number)))
6667 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6668 result)
6669 (when (and (not eobp)
6670 (or (not gnus-summary-check-current)
6671 (not unread)
6672 (not (gnus-data-unread-p (car data)))))
6673 (setq data (cdr data)))
6674 (when (setq result
6675 (if unread
6676 (progn
6677 (while data
6678 (unless (memq (gnus-data-number (car data))
6679 (cond
6680 ((eq gnus-auto-goto-ignores
6681 'always-undownloaded)
6682 gnus-newsgroup-undownloaded)
6683 (gnus-plugged
6684 nil)
6685 ((eq gnus-auto-goto-ignores
6686 'unfetched)
6687 gnus-newsgroup-unfetched)
6688 ((eq gnus-auto-goto-ignores
6689 'undownloaded)
6690 gnus-newsgroup-undownloaded)))
6691 (when (gnus-data-unread-p (car data))
6692 (setq result (car data)
6693 data nil)))
6694 (setq data (cdr data)))
6695 result)
6696 (car data)))
6697 (goto-char (gnus-data-pos result))
6698 (gnus-data-number result))))
6700 (defun gnus-summary-find-subject (subject &optional unread backward article)
6701 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6702 (article (or article (gnus-summary-article-number)))
6703 (articles (gnus-data-list backward))
6704 (arts (gnus-data-find-list article articles))
6705 result)
6706 (when (or (not gnus-summary-check-current)
6707 (not unread)
6708 (not (gnus-data-unread-p (car arts))))
6709 (setq arts (cdr arts)))
6710 (while arts
6711 (and (or (not unread)
6712 (gnus-data-unread-p (car arts)))
6713 (vectorp (gnus-data-header (car arts)))
6714 (gnus-subject-equal
6715 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6716 (setq result (car arts)
6717 arts nil))
6718 (setq arts (cdr arts)))
6719 (and result
6720 (goto-char (gnus-data-pos result))
6721 (gnus-data-number result))))
6723 (defun gnus-summary-search-forward (&optional unread subject backward)
6724 "Search forward for an article.
6725 If UNREAD, look for unread articles. If SUBJECT, look for
6726 articles with that subject. If BACKWARD, search backward instead."
6727 (cond (subject (gnus-summary-find-subject subject unread backward))
6728 (backward (gnus-summary-find-prev unread))
6729 (t (gnus-summary-find-next unread))))
6731 (defun gnus-recenter (&optional n)
6732 "Center point in window and redisplay frame.
6733 Also do horizontal recentering."
6734 (interactive "P")
6735 (when (and gnus-auto-center-summary
6736 (not (eq gnus-auto-center-summary 'vertical)))
6737 (gnus-horizontal-recenter))
6738 (if (fboundp 'recenter-top-bottom)
6739 (recenter-top-bottom n)
6740 (recenter n)))
6742 (put 'gnus-recenter 'isearch-scroll t)
6744 (defun gnus-forward-line-ignore-invisible (n)
6745 "Move N lines forward (backward if N is negative).
6746 Like forward-line, but skip over (and don't count) invisible lines."
6747 (let (done)
6748 (while (and (> n 0) (not done))
6749 ;; If the following character is currently invisible,
6750 ;; skip all characters with that same `invisible' property value.
6751 (while (gnus-invisible-p (point))
6752 (goto-char (gnus-next-char-property-change (point))))
6753 (forward-line 1)
6754 (if (eobp)
6755 (setq done t)
6756 (setq n (1- n))))
6757 (while (and (< n 0) (not done))
6758 (forward-line -1)
6759 (if (bobp) (setq done t)
6760 (setq n (1+ n))
6761 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6762 (goto-char (gnus-previous-char-property-change (point))))))))
6764 (defun gnus-summary-recenter ()
6765 "Center point in the summary window.
6766 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6767 displayed, no centering will be performed."
6768 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6769 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6770 (interactive)
6771 ;; The user has to want it.
6772 (when gnus-auto-center-summary
6773 (let* ((top (cond ((< (window-height) 4) 0)
6774 ((< (window-height) 7) 1)
6775 (t (if (numberp gnus-auto-center-summary)
6776 gnus-auto-center-summary
6777 (/ (1- (window-height)) 2)))))
6778 (height (1- (window-height)))
6779 (bottom (save-excursion
6780 (goto-char (point-max))
6781 (gnus-forward-line-ignore-invisible (- height))
6782 (point)))
6783 (window (get-buffer-window (current-buffer))))
6784 (when (get-buffer-window gnus-article-buffer)
6785 ;; Only do recentering when the article buffer is displayed,
6786 ;; Set the window start to either `bottom', which is the biggest
6787 ;; possible valid number, or the second line from the top,
6788 ;; whichever is the least.
6789 (let ((top-pos (save-excursion
6790 (gnus-forward-line-ignore-invisible (- top))
6791 (point))))
6792 (if (> bottom top-pos)
6793 ;; Keep the second line from the top visible
6794 (set-window-start window top-pos)
6795 ;; Try to keep the bottom line visible; if it's partially
6796 ;; obscured, either scroll one more line to make it fully
6797 ;; visible, or revert to using TOP-POS.
6798 (save-excursion
6799 (goto-char (point-max))
6800 (gnus-forward-line-ignore-invisible -1)
6801 (let ((last-line-start (point)))
6802 (goto-char bottom)
6803 (set-window-start window (point) t)
6804 (when (not (pos-visible-in-window-p last-line-start window))
6805 (gnus-forward-line-ignore-invisible 1)
6806 (set-window-start window (min (point) top-pos) t)))))))
6807 ;; Do horizontal recentering while we're at it.
6808 (when (and (get-buffer-window (current-buffer) t)
6809 (not (eq gnus-auto-center-summary 'vertical)))
6810 (let ((selected (selected-window)))
6811 (select-window (get-buffer-window (current-buffer) t))
6812 (gnus-summary-position-point)
6813 (gnus-horizontal-recenter)
6814 (select-window selected))))))
6816 (defun gnus-summary-jump-to-group (newsgroup)
6817 "Move point to NEWSGROUP in group mode buffer."
6818 ;; Keep update point of group mode buffer if visible.
6819 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6820 (save-window-excursion
6821 ;; Take care of tree window mode.
6822 (when (get-buffer-window gnus-group-buffer)
6823 (pop-to-buffer gnus-group-buffer))
6824 (gnus-group-jump-to-group newsgroup))
6825 (save-excursion
6826 ;; Take care of tree window mode.
6827 (if (get-buffer-window gnus-group-buffer 0)
6828 (pop-to-buffer gnus-group-buffer)
6829 (set-buffer gnus-group-buffer))
6830 (gnus-group-jump-to-group newsgroup))))
6832 ;; This function returns a list of article numbers based on the
6833 ;; difference between the ranges of read articles in this group and
6834 ;; the range of active articles.
6835 (defun gnus-list-of-unread-articles (group)
6836 (let* ((read (gnus-info-read (gnus-get-info group)))
6837 (active (or (gnus-active group) (gnus-activate-group group)))
6838 (last (or (cdr active)
6839 (error "Group %s couldn't be activated " group)))
6840 (bottom (if gnus-newsgroup-maximum-articles
6841 (max (car active)
6842 (- last gnus-newsgroup-maximum-articles -1))
6843 (car active)))
6844 first nlast unread)
6845 ;; If none are read, then all are unread.
6846 (if (not read)
6847 (setq first bottom)
6848 ;; If the range of read articles is a single range, then the
6849 ;; first unread article is the article after the last read
6850 ;; article. Sounds logical, doesn't it?
6851 (if (and (not (listp (cdr read)))
6852 (or (< (car read) bottom)
6853 (progn (setq read (list read))
6854 nil)))
6855 (setq first (max bottom (1+ (cdr read))))
6856 ;; `read' is a list of ranges.
6857 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6858 (caar read)))
6860 (setq first bottom))
6861 (while read
6862 (when first
6863 (while (< first nlast)
6864 (setq unread (cons first unread)
6865 first (1+ first))))
6866 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6867 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6868 (setq read (cdr read)))))
6869 ;; And add the last unread articles.
6870 (while (<= first last)
6871 (setq unread (cons first unread)
6872 first (1+ first)))
6873 ;; Return the list of unread articles.
6874 (delq 0 (nreverse unread))))
6876 (defun gnus-list-of-read-articles (group)
6877 "Return a list of unread, unticked and non-dormant articles."
6878 (let* ((info (gnus-get-info group))
6879 (marked (gnus-info-marks info))
6880 (active (gnus-active group)))
6881 (and info active
6882 (gnus-list-range-difference
6883 (gnus-list-range-difference
6884 (gnus-sorted-complement
6885 (gnus-uncompress-range
6886 (if gnus-newsgroup-maximum-articles
6887 (cons (max (car active)
6888 (- (cdr active)
6889 gnus-newsgroup-maximum-articles
6890 -1))
6891 (cdr active))
6892 active))
6893 (gnus-list-of-unread-articles group))
6894 (cdr (assq 'dormant marked)))
6895 (cdr (assq 'tick marked))))))
6897 ;; This function returns a sequence of article numbers based on the
6898 ;; difference between the ranges of read articles in this group and
6899 ;; the range of active articles.
6900 (defun gnus-sequence-of-unread-articles (group)
6901 (let* ((read (gnus-info-read (gnus-get-info group)))
6902 (active (or (gnus-active group) (gnus-activate-group group)))
6903 (last (cdr active))
6904 (bottom (if gnus-newsgroup-maximum-articles
6905 (max (car active)
6906 (- last gnus-newsgroup-maximum-articles -1))
6907 (car active)))
6908 first nlast unread)
6909 ;; If none are read, then all are unread.
6910 (if (not read)
6911 (setq first bottom)
6912 ;; If the range of read articles is a single range, then the
6913 ;; first unread article is the article after the last read
6914 ;; article. Sounds logical, doesn't it?
6915 (if (and (not (listp (cdr read)))
6916 (or (< (car read) bottom)
6917 (progn (setq read (list read))
6918 nil)))
6919 (setq first (max bottom (1+ (cdr read))))
6920 ;; `read' is a list of ranges.
6921 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6922 (caar read)))
6924 (setq first bottom))
6925 (while read
6926 (when first
6927 (push (cons first nlast) unread))
6928 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6929 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6930 (setq read (cdr read)))))
6931 ;; And add the last unread articles.
6932 (cond ((not (and first last))
6933 nil)
6934 ((< first last)
6935 (push (cons first last) unread))
6936 ((= first last)
6937 (push first unread)))
6938 ;; Return the sequence of unread articles.
6939 (delq 0 (nreverse unread))))
6941 ;; Various summary commands
6943 (defun gnus-summary-select-article-buffer ()
6944 "Reconfigure windows to show the article buffer."
6945 (interactive)
6946 (if (not (gnus-buffer-live-p gnus-article-buffer))
6947 (error "There is no article buffer for this summary buffer")
6948 (unless (get-buffer-window gnus-article-buffer)
6949 (gnus-summary-show-article))
6950 (gnus-configure-windows
6951 (if gnus-widen-article-window
6952 'only-article
6953 'article)
6955 (select-window (get-buffer-window gnus-article-buffer))))
6957 (defun gnus-summary-universal-argument (arg)
6958 "Perform any operation on all articles that are process/prefixed."
6959 (interactive "P")
6960 (let ((articles (gnus-summary-work-articles arg))
6961 func article)
6962 (if (eq
6963 (setq
6964 func
6965 (key-binding
6966 (read-key-sequence
6967 (substitute-command-keys
6968 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6969 'undefined)
6970 (gnus-error 1 "Undefined key")
6971 (save-excursion
6972 (while articles
6973 (gnus-summary-goto-subject (setq article (pop articles)))
6974 (let (gnus-newsgroup-processable)
6975 (command-execute func))
6976 (gnus-summary-remove-process-mark article)))))
6977 (gnus-summary-position-point))
6979 (defun gnus-summary-toggle-truncation (&optional arg)
6980 "Toggle truncation of summary lines.
6981 With ARG, turn line truncation on if ARG is positive."
6982 (interactive "P")
6983 (setq truncate-lines
6984 (if (null arg) (not truncate-lines)
6985 (> (prefix-numeric-value arg) 0)))
6986 (redraw-display))
6988 (defun gnus-summary-find-for-reselect ()
6989 "Return the number of an article to stay on across a reselect.
6990 The current article is considered, then following articles, then previous
6991 articles. An article is sought which is not cancelled and isn't a temporary
6992 insertion from another group. If there's no such then return a dummy 0."
6993 (let (found)
6994 (dolist (rev '(nil t))
6995 (unless found ; don't demand the reverse list if we don't need it
6996 (let ((data (gnus-data-find-list
6997 (gnus-summary-article-number) (gnus-data-list rev))))
6998 (while (and data (not found))
6999 (if (and (< 0 (gnus-data-number (car data)))
7000 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7001 (setq found (gnus-data-number (car data))))
7002 (setq data (cdr data))))))
7003 (or found 0)))
7005 (defun gnus-summary-reselect-current-group (&optional all rescan)
7006 "Exit and then reselect the current newsgroup.
7007 The prefix argument ALL means to select all articles."
7008 (interactive "P")
7009 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7010 (error "Ephemeral groups can't be reselected"))
7011 (let ((current-subject (gnus-summary-find-for-reselect))
7012 (group gnus-newsgroup-name))
7013 (setq gnus-newsgroup-begin nil)
7014 (gnus-summary-exit nil 'leave-hidden)
7015 ;; We have to adjust the point of group mode buffer because
7016 ;; point was moved to the next unread newsgroup by exiting.
7017 (gnus-summary-jump-to-group group)
7018 (when rescan
7019 (save-excursion
7020 (gnus-group-get-new-news-this-group 1)))
7021 (gnus-group-read-group all t)
7022 (gnus-summary-goto-subject current-subject nil t)))
7024 (defun gnus-summary-rescan-group (&optional all)
7025 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7026 (interactive "P")
7027 (gnus-summary-reselect-current-group all t))
7029 (defun gnus-summary-update-info (&optional non-destructive)
7030 (save-excursion
7031 (let ((group gnus-newsgroup-name))
7032 (when group
7033 (when gnus-newsgroup-kill-headers
7034 (setq gnus-newsgroup-killed
7035 (gnus-compress-sequence
7036 (gnus-sorted-union
7037 (gnus-list-range-intersection
7038 gnus-newsgroup-unselected gnus-newsgroup-killed)
7039 gnus-newsgroup-unreads)
7040 t)))
7041 (unless (listp (cdr gnus-newsgroup-killed))
7042 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7043 (let ((headers gnus-newsgroup-headers))
7044 ;; Set the new ranges of read articles.
7045 (with-current-buffer gnus-group-buffer
7046 (gnus-undo-force-boundary))
7047 (gnus-update-read-articles
7048 group (gnus-sorted-union
7049 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7050 ;; Set the current article marks.
7051 (let ((gnus-newsgroup-scored
7052 (if (and (not gnus-save-score)
7053 (not non-destructive))
7055 gnus-newsgroup-scored)))
7056 (save-excursion
7057 (gnus-update-marks)))
7058 ;; Do the cross-ref thing.
7059 (when gnus-use-cross-reference
7060 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7061 ;; Do not switch windows but change the buffer to work.
7062 (set-buffer gnus-group-buffer)
7063 (unless (gnus-ephemeral-group-p group)
7064 (gnus-group-update-group group)))))))
7066 (defun gnus-summary-save-newsrc (&optional force)
7067 "Save the current number of read/marked articles in the dribble buffer.
7068 The dribble buffer will then be saved.
7069 If FORCE (the prefix), also save the .newsrc file(s)."
7070 (interactive "P")
7071 (gnus-summary-update-info t)
7072 (if force
7073 (gnus-save-newsrc-file)
7074 (gnus-dribble-save)))
7076 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7078 (defun gnus-summary-exit (&optional temporary leave-hidden)
7079 "Exit reading current newsgroup, and then return to group selection mode.
7080 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7081 (interactive)
7082 (gnus-set-global-variables)
7083 (when (gnus-buffer-live-p gnus-article-buffer)
7084 (with-current-buffer gnus-article-buffer
7085 (mm-destroy-parts gnus-article-mime-handles)
7086 ;; Set it to nil for safety reason.
7087 (setq gnus-article-mime-handle-alist nil)
7088 (setq gnus-article-mime-handles nil)))
7089 (gnus-kill-save-kill-buffer)
7090 (gnus-async-halt-prefetch)
7091 (let* ((group gnus-newsgroup-name)
7092 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7093 (gnus-group-is-exiting-p t)
7094 (mode major-mode)
7095 (group-point nil)
7096 (buf (current-buffer)))
7097 (unless quit-config
7098 ;; Do adaptive scoring, and possibly save score files.
7099 (when gnus-newsgroup-adaptive
7100 (gnus-score-adaptive))
7101 (when gnus-use-scoring
7102 (gnus-score-save)))
7103 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7104 (when gnus-use-cache
7105 (gnus-cache-possibly-remove-articles)
7106 (gnus-cache-save-buffers))
7107 (gnus-async-prefetch-remove-group group)
7108 (when gnus-suppress-duplicates
7109 (gnus-dup-enter-articles))
7110 (when gnus-use-trees
7111 (gnus-tree-close group))
7112 (when gnus-use-cache
7113 (gnus-cache-write-active))
7114 ;; Remove entries for this group.
7115 (nnmail-purge-split-history (gnus-group-real-name group))
7116 ;; Make all changes in this group permanent.
7117 (unless quit-config
7118 (gnus-run-hooks 'gnus-exit-group-hook)
7119 (gnus-summary-update-info))
7120 (gnus-close-group group)
7121 ;; Make sure where we were, and go to next newsgroup.
7122 (set-buffer gnus-group-buffer)
7123 (unless quit-config
7124 (gnus-group-jump-to-group group))
7125 (gnus-run-hooks 'gnus-summary-exit-hook)
7126 (unless (or quit-config
7127 (not gnus-summary-next-group-on-exit)
7128 ;; If this group has disappeared from the summary
7129 ;; buffer, don't skip forwards.
7130 (not (string= group (gnus-group-group-name))))
7131 (gnus-group-next-unread-group 1))
7132 (setq group-point (point))
7133 (if temporary
7134 nil ;Nothing to do.
7135 (set-buffer buf)
7136 (if (not gnus-kill-summary-on-exit)
7137 (progn
7138 (gnus-deaden-summary)
7139 (setq mode nil))
7140 (when (get-buffer gnus-article-buffer)
7141 (bury-buffer gnus-article-buffer))
7142 ;; Return to group mode buffer.
7143 (when (eq mode 'gnus-summary-mode)
7144 (gnus-kill-buffer buf)))
7146 ;; If we have several article buffers, we kill them at exit.
7147 (unless gnus-single-article-buffer
7148 (when (gnus-buffer-live-p gnus-article-buffer)
7149 (with-current-buffer gnus-article-buffer
7150 ;; Don't kill sticky article buffers
7151 (unless (eq major-mode 'gnus-sticky-article-mode)
7152 (gnus-kill-buffer gnus-article-buffer)
7153 (setq gnus-article-current nil))))
7154 (gnus-kill-buffer gnus-original-article-buffer))
7156 (setq gnus-current-select-method gnus-select-method)
7157 (set-buffer gnus-group-buffer)
7158 (if quit-config
7159 (gnus-handle-ephemeral-exit quit-config)
7160 (goto-char group-point)
7161 ;; If gnus-group-buffer is already displayed, make sure we also move
7162 ;; the cursor in the window that displays it.
7163 (let ((win (get-buffer-window (current-buffer) 0)))
7164 (if win (set-window-point win (point))))
7165 (unless leave-hidden
7166 (gnus-configure-windows 'group 'force)))
7167 ;; Clear the current group name.
7168 (unless quit-config
7169 (setq gnus-newsgroup-name nil)))))
7171 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7172 (defun gnus-summary-exit-no-update (&optional no-questions)
7173 "Quit reading current newsgroup without updating read article info."
7174 (interactive)
7175 (let* ((group gnus-newsgroup-name)
7176 (gnus-group-is-exiting-p t)
7177 (gnus-group-is-exiting-without-update-p t)
7178 (quit-config (gnus-group-quit-config group)))
7179 (when (or no-questions
7180 gnus-expert-user
7181 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7182 (gnus-async-halt-prefetch)
7183 (run-hooks 'gnus-summary-prepare-exit-hook)
7184 (when (gnus-buffer-live-p gnus-article-buffer)
7185 (with-current-buffer gnus-article-buffer
7186 (mm-destroy-parts gnus-article-mime-handles)
7187 ;; Set it to nil for safety reason.
7188 (setq gnus-article-mime-handle-alist nil)
7189 (setq gnus-article-mime-handles nil)))
7190 ;; If we have several article buffers, we kill them at exit.
7191 (unless gnus-single-article-buffer
7192 (gnus-kill-buffer gnus-article-buffer)
7193 (gnus-kill-buffer gnus-original-article-buffer)
7194 (setq gnus-article-current nil))
7195 (if (not gnus-kill-summary-on-exit)
7196 (gnus-deaden-summary)
7197 (gnus-close-group group)
7198 (gnus-kill-buffer gnus-summary-buffer))
7199 (unless gnus-single-article-buffer
7200 (setq gnus-article-current nil))
7201 (when gnus-use-trees
7202 (gnus-tree-close group))
7203 (gnus-async-prefetch-remove-group group)
7204 (when (get-buffer gnus-article-buffer)
7205 (bury-buffer gnus-article-buffer))
7206 ;; Return to the group buffer.
7207 (gnus-configure-windows 'group 'force)
7208 ;; Clear the current group name.
7209 (setq gnus-newsgroup-name nil)
7210 (unless (gnus-ephemeral-group-p group)
7211 (gnus-group-update-group group))
7212 (when (equal (gnus-group-group-name) group)
7213 (gnus-group-next-unread-group 1))
7214 (when quit-config
7215 (gnus-handle-ephemeral-exit quit-config)))))
7217 (defun gnus-handle-ephemeral-exit (quit-config)
7218 "Handle movement when leaving an ephemeral group.
7219 The state which existed when entering the ephemeral is reset."
7220 (if (not (buffer-name (car quit-config)))
7221 (gnus-configure-windows 'group 'force)
7222 (set-buffer (car quit-config))
7223 (cond ((eq major-mode 'gnus-summary-mode)
7224 (gnus-set-global-variables))
7225 ((eq major-mode 'gnus-article-mode)
7226 (save-current-buffer
7227 ;; The `gnus-summary-buffer' variable may point
7228 ;; to the old summary buffer when using a single
7229 ;; article buffer.
7230 (unless (gnus-buffer-live-p gnus-summary-buffer)
7231 (set-buffer gnus-group-buffer))
7232 (set-buffer gnus-summary-buffer)
7233 (gnus-set-global-variables))))
7234 (if (or (eq (cdr quit-config) 'article)
7235 (eq (cdr quit-config) 'pick))
7236 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7237 (gnus-configure-windows 'pick 'force)
7238 (gnus-configure-windows (cdr quit-config) 'force))
7239 (gnus-configure-windows (cdr quit-config) 'force))
7240 (when (eq major-mode 'gnus-summary-mode)
7241 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7242 next-unread-noselect))
7243 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7244 'next-noselect)
7245 (gnus-summary-next-subject 1 nil t))
7246 ((eq gnus-auto-select-on-ephemeral-exit
7247 'next-unread-noselect)
7248 (gnus-summary-next-subject 1 t t))))
7249 ;; Hide the article buffer which displays the article different
7250 ;; from the one that the cursor points to in the summary buffer.
7251 (gnus-configure-windows 'summary 'force))
7252 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7253 (gnus-summary-next-subject 1))
7254 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7255 (gnus-summary-next-subject 1 t))))
7256 (gnus-summary-recenter)
7257 (gnus-summary-position-point))))
7259 ;;; Dead summaries.
7261 (defvar gnus-dead-summary-mode-map
7262 (let ((map (make-keymap)))
7263 (suppress-keymap map)
7264 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7265 (dolist (key '("\C-d" "\r" "\177" [delete]))
7266 (define-key map key 'gnus-summary-wake-up-the-dead))
7267 (dolist (key '("q" "Q"))
7268 (define-key map key 'bury-buffer))
7269 map))
7271 (define-minor-mode gnus-dead-summary-mode
7272 "Minor mode for Gnus summary buffers."
7273 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7274 (unless (derived-mode-p 'gnus-summary-mode)
7275 (setq gnus-dead-summary-mode nil)))
7277 (defun gnus-deaden-summary ()
7278 "Make the current summary buffer into a dead summary buffer."
7279 ;; Kill any previous dead summary buffer.
7280 (when (and gnus-dead-summary
7281 (buffer-name gnus-dead-summary))
7282 (with-current-buffer gnus-dead-summary
7283 (when gnus-dead-summary-mode
7284 (kill-buffer (current-buffer)))))
7285 ;; Make this the current dead summary.
7286 (setq gnus-dead-summary (current-buffer))
7287 (gnus-dead-summary-mode 1)
7288 (let ((name (buffer-name)))
7289 (when (string-match "Summary" name)
7290 (rename-buffer
7291 (concat (substring name 0 (match-beginning 0)) "Dead "
7292 (substring name (match-beginning 0)))
7294 (bury-buffer))))
7296 (defun gnus-kill-or-deaden-summary (buffer)
7297 "Kill or deaden the summary BUFFER."
7298 (save-excursion
7299 (when (and (buffer-name buffer)
7300 (not gnus-single-article-buffer))
7301 (with-current-buffer buffer
7302 (gnus-kill-buffer gnus-article-buffer)
7303 (gnus-kill-buffer gnus-original-article-buffer)))
7304 (cond
7305 ;; Kill the buffer.
7306 (gnus-kill-summary-on-exit
7307 (when (and gnus-use-trees
7308 (gnus-buffer-exists-p buffer))
7309 (with-current-buffer buffer
7310 (gnus-tree-close gnus-newsgroup-name)))
7311 (gnus-kill-buffer buffer))
7312 ;; Deaden the buffer.
7313 ((gnus-buffer-exists-p buffer)
7314 (with-current-buffer buffer
7315 (gnus-deaden-summary))))))
7317 (defun gnus-summary-wake-up-the-dead (&rest args)
7318 "Wake up the dead summary buffer."
7319 (interactive)
7320 (gnus-dead-summary-mode -1)
7321 (let ((name (buffer-name)))
7322 (when (string-match "Dead " name)
7323 (rename-buffer
7324 (concat (substring name 0 (match-beginning 0))
7325 (substring name (match-end 0)))
7326 t)))
7327 (gnus-message 3 "This dead summary is now alive again"))
7329 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7330 (defun gnus-summary-describe-group (&optional force)
7331 "Describe the current newsgroup."
7332 (interactive "P")
7333 (gnus-group-describe-group force gnus-newsgroup-name))
7335 (defun gnus-summary-describe-briefly ()
7336 "Describe summary mode commands briefly."
7337 (interactive)
7338 (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")))
7340 ;; Walking around group mode buffer from summary mode.
7342 (defun gnus-summary-next-group (&optional no-article target-group backward)
7343 "Exit current newsgroup and then select next unread newsgroup.
7344 If prefix argument NO-ARTICLE is non-nil, no article is selected
7345 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7346 previous group instead."
7347 (interactive "P")
7348 ;; Stop pre-fetching.
7349 (gnus-async-halt-prefetch)
7350 (let ((current-group gnus-newsgroup-name)
7351 (current-buffer (current-buffer))
7352 entered)
7353 ;; First we semi-exit this group to update Xrefs and all variables.
7354 ;; We can't do a real exit, because the window conf must remain
7355 ;; the same in case the user is prompted for info, and we don't
7356 ;; want the window conf to change before that...
7357 (gnus-summary-exit t)
7358 (while (not entered)
7359 ;; Then we find what group we are supposed to enter.
7360 (set-buffer gnus-group-buffer)
7361 (gnus-group-jump-to-group current-group)
7362 (setq target-group
7363 (or target-group
7364 (if (eq gnus-keep-same-level 'best)
7365 (gnus-summary-best-group gnus-newsgroup-name)
7366 (gnus-summary-search-group backward gnus-keep-same-level))))
7367 (if (not target-group)
7368 ;; There are no further groups, so we return to the group
7369 ;; buffer.
7370 (progn
7371 (gnus-message 5 "Returning to the group buffer")
7372 (setq entered t)
7373 (when (gnus-buffer-live-p current-buffer)
7374 (set-buffer current-buffer)
7375 (gnus-summary-exit))
7376 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7377 ;; We try to enter the target group.
7378 (gnus-group-jump-to-group target-group)
7379 (let ((unreads (gnus-group-group-unread)))
7380 (if (and (or (eq t unreads)
7381 (and unreads (not (zerop unreads))))
7382 (gnus-summary-read-group
7383 target-group nil no-article
7384 (and (buffer-name current-buffer) current-buffer)
7385 nil backward))
7386 (setq entered t)
7387 (setq current-group target-group
7388 target-group nil)))))))
7390 (defun gnus-summary-prev-group (&optional no-article)
7391 "Exit current newsgroup and then select previous unread newsgroup.
7392 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7393 (interactive "P")
7394 (gnus-summary-next-group no-article nil t))
7396 ;; Walking around summary lines.
7398 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7399 "Go to the first subject satisfying any non-nil constraint.
7400 If UNREAD is non-nil, the article should be unread.
7401 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7402 If UNSEEN is non-nil, the article should be unseen as well as unread.
7403 Returns the article selected or nil if there are no matching articles."
7404 (interactive "P")
7405 (cond
7406 ;; Empty summary.
7407 ((null gnus-newsgroup-data)
7408 (gnus-message 3 "No articles in the group")
7409 nil)
7410 ;; Pick the first article.
7411 ((not (or unread undownloaded unseen))
7412 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7413 (gnus-data-number (car gnus-newsgroup-data)))
7414 ;; Find the first unread article.
7416 (let ((data gnus-newsgroup-data))
7417 (while (and data
7418 (let ((num (gnus-data-number (car data))))
7419 (or (memq num gnus-newsgroup-unfetched)
7420 (not (or (and unread
7421 (memq num gnus-newsgroup-unreads))
7422 (and undownloaded
7423 (memq num gnus-newsgroup-undownloaded))
7424 (and unseen
7425 (memq num gnus-newsgroup-unseen)
7426 (memq num gnus-newsgroup-unreads)))))))
7427 (setq data (cdr data)))
7428 (prog1
7429 (if data
7430 (progn
7431 (goto-char (gnus-data-pos (car data)))
7432 (gnus-data-number (car data)))
7433 (gnus-message 3 "No more%s articles"
7434 (let* ((r (when unread " unread"))
7435 (d (when undownloaded " undownloaded"))
7436 (s (when unseen " unseen"))
7437 (l (delq nil (list r d s))))
7438 (cond ((= 3 (length l))
7439 (concat r "," d ", or" s))
7440 ((= 2 (length l))
7441 (concat (car l) ", or" (cadr l)))
7442 ((= 1 (length l))
7443 (car l))
7445 ""))))
7448 (gnus-summary-position-point))))))
7450 (defun gnus-summary-next-subject (n &optional unread dont-display)
7451 "Go to next N'th summary line.
7452 If N is negative, go to the previous N'th subject line.
7453 If UNREAD is non-nil, only unread articles are selected.
7454 The difference between N and the actual number of steps taken is
7455 returned."
7456 (interactive "p")
7457 (let ((backward (< n 0))
7458 (n (abs n)))
7459 (while (and (> n 0)
7460 (if backward
7461 (gnus-summary-find-prev unread)
7462 (gnus-summary-find-next unread)))
7463 (unless (zerop (setq n (1- n)))
7464 (gnus-summary-show-thread)))
7465 (when (/= 0 n)
7466 (gnus-message 7 "No more%s articles"
7467 (if unread " unread" "")))
7468 (unless dont-display
7469 (gnus-summary-recenter)
7470 (gnus-summary-position-point))
7473 (defun gnus-summary-next-unread-subject (n)
7474 "Go to next N'th unread summary line."
7475 (interactive "p")
7476 (gnus-summary-next-subject n t))
7478 (defun gnus-summary-prev-subject (n &optional unread)
7479 "Go to previous N'th summary line.
7480 If optional argument UNREAD is non-nil, only unread article is selected."
7481 (interactive "p")
7482 (gnus-summary-next-subject (- n) unread))
7484 (defun gnus-summary-prev-unread-subject (n)
7485 "Go to previous N'th unread summary line."
7486 (interactive "p")
7487 (gnus-summary-next-subject (- n) t))
7489 (defun gnus-summary-goto-subjects (articles)
7490 "Insert the subject header for ARTICLES in the current buffer."
7491 (save-excursion
7492 (dolist (article articles)
7493 (gnus-summary-goto-subject article t)))
7494 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7495 (gnus-summary-position-point))
7497 (defun gnus-summary-goto-subject (article &optional force silent)
7498 "Go to the subject line of ARTICLE.
7499 If FORCE, also allow jumping to articles not currently shown."
7500 (interactive "nArticle number: ")
7501 (unless (numberp article)
7502 (error "Article %s is not a number" article))
7503 (let ((b (point))
7504 (data (gnus-data-find article)))
7505 ;; We read in the article if we have to.
7506 (and (not data)
7507 force
7508 (gnus-summary-insert-subject
7509 article
7510 (if (or (numberp force) (vectorp force)) force)
7512 (setq data (gnus-data-find article)))
7513 (goto-char b)
7514 (if (not data)
7515 (progn
7516 (unless silent
7517 (gnus-message 3 "Can't find article %d" article))
7518 nil)
7519 (let ((pt (gnus-data-pos data)))
7520 (goto-char pt)
7521 (gnus-summary-set-article-display-arrow pt))
7522 (gnus-summary-position-point)
7523 article)))
7525 ;; Walking around summary lines with displaying articles.
7527 (defun gnus-summary-expand-window (&optional arg)
7528 "Make the summary buffer take up the entire Emacs frame.
7529 Given a prefix, will force an `article' buffer configuration."
7530 (interactive "P")
7531 (if arg
7532 (gnus-configure-windows 'article 'force)
7533 (gnus-configure-windows 'summary 'force)))
7535 (defun gnus-summary-display-article (article &optional all-header)
7536 "Display ARTICLE in article buffer."
7537 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7538 (with-current-buffer gnus-article-buffer
7539 (eq major-mode 'gnus-article-mode)))
7540 (gnus-article-setup-buffer))
7541 (gnus-set-global-variables)
7542 (with-current-buffer gnus-article-buffer
7543 (setq gnus-article-charset gnus-newsgroup-charset)
7544 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7545 (mm-enable-multibyte))
7546 (if (null article)
7548 (prog1
7549 (if gnus-summary-display-article-function
7550 (funcall gnus-summary-display-article-function article all-header)
7551 (gnus-article-prepare article all-header))
7552 (gnus-run-hooks 'gnus-select-article-hook)
7553 (when (and gnus-current-article
7554 (not (zerop gnus-current-article)))
7555 (gnus-summary-goto-subject gnus-current-article))
7556 (gnus-summary-recenter)
7557 (when (and gnus-use-trees gnus-show-threads)
7558 (gnus-possibly-generate-tree article)
7559 (gnus-highlight-selected-tree article))
7560 ;; Successfully display article.
7561 (gnus-article-set-window-start
7562 (cdr (assq article gnus-newsgroup-bookmarks))))))
7564 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7565 "Select the current article.
7566 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7567 non-nil, the article will be re-fetched even if it already present in
7568 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7569 be displayed."
7570 ;; Make sure we are in the summary buffer to work around bbdb bug.
7571 (unless (eq major-mode 'gnus-summary-mode)
7572 (set-buffer gnus-summary-buffer))
7573 (let ((article (or article (gnus-summary-article-number)))
7574 (all-headers (not (not all-headers))) ;Must be t or nil.
7575 gnus-summary-display-article-function)
7576 (and (not pseudo)
7577 (gnus-summary-article-pseudo-p article)
7578 (error "This is a pseudo-article"))
7579 (with-current-buffer gnus-summary-buffer
7580 (if (or (and gnus-single-article-buffer
7581 (or (null gnus-current-article)
7582 (null gnus-article-current)
7583 (null (get-buffer gnus-article-buffer))
7584 (not (eq article (cdr gnus-article-current)))
7585 (not (equal (car gnus-article-current)
7586 gnus-newsgroup-name))))
7587 (and (not gnus-single-article-buffer)
7588 (or (null gnus-current-article)
7589 (not (eq gnus-current-article article))))
7590 force)
7591 ;; The requested article is different from the current article.
7592 (progn
7593 (gnus-summary-display-article article all-headers)
7594 (when (gnus-buffer-live-p gnus-article-buffer)
7595 (with-current-buffer gnus-article-buffer
7596 (if (not gnus-article-decoded-p) ;; a local variable
7597 (mm-disable-multibyte))))
7598 (gnus-article-set-window-start
7599 (cdr (assq article gnus-newsgroup-bookmarks)))
7600 article)
7601 'old))))
7603 (defun gnus-summary-force-verify-and-decrypt ()
7604 "Display buttons for signed/encrypted parts and verify/decrypt them."
7605 (interactive)
7606 (let ((mm-verify-option 'known)
7607 (mm-decrypt-option 'known)
7608 (gnus-article-emulate-mime t)
7609 (gnus-buttonized-mime-types (append (list "multipart/signed"
7610 "multipart/encrypted")
7611 gnus-buttonized-mime-types)))
7612 (gnus-summary-select-article nil 'force)))
7614 (defun gnus-summary-set-current-mark (&optional current-mark)
7615 "Obsolete function."
7616 nil)
7618 (defun gnus-summary-next-article (&optional unread subject backward push)
7619 "Select the next article.
7620 If UNREAD, only unread articles are selected.
7621 If SUBJECT, only articles with SUBJECT are selected.
7622 If BACKWARD, the previous article is selected instead of the next."
7623 (interactive "P")
7624 ;; Make sure we are in the summary buffer.
7625 (unless (eq major-mode 'gnus-summary-mode)
7626 (set-buffer gnus-summary-buffer))
7627 (cond
7628 ;; Is there such an article?
7629 ((and (gnus-summary-search-forward unread subject backward)
7630 (or (gnus-summary-display-article (gnus-summary-article-number))
7631 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7632 (gnus-summary-position-point))
7633 ;; If not, we try the first unread, if that is wanted.
7634 ((and subject
7635 gnus-auto-select-same
7636 (gnus-summary-first-unread-article))
7637 (gnus-summary-position-point)
7638 (gnus-message 6 "Wrapped"))
7639 ;; Try to get next/previous article not displayed in this group.
7640 ((and gnus-auto-extend-newsgroup
7641 (not unread) (not subject))
7642 (gnus-summary-goto-article
7643 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7644 nil (count-lines (point-min) (point))))
7645 ;; Go to next/previous group.
7647 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7648 (gnus-summary-jump-to-group gnus-newsgroup-name))
7649 (let ((cmd (if (featurep 'xemacs)
7650 last-command-char
7651 last-command-event))
7652 (point
7653 (with-current-buffer gnus-group-buffer
7654 (point)))
7655 (group
7656 (if (eq gnus-keep-same-level 'best)
7657 (gnus-summary-best-group gnus-newsgroup-name)
7658 (gnus-summary-search-group backward gnus-keep-same-level))))
7659 ;; For some reason, the group window gets selected. We change
7660 ;; it back.
7661 (select-window (get-buffer-window (current-buffer)))
7662 ;; Select next unread newsgroup automagically.
7663 (cond
7664 ((or (not gnus-auto-select-next)
7665 (not cmd))
7666 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7667 ((or (eq gnus-auto-select-next 'quietly)
7668 (and (eq gnus-auto-select-next 'slightly-quietly)
7669 push)
7670 (and (eq gnus-auto-select-next 'almost-quietly)
7671 (gnus-summary-last-article-p)))
7672 ;; Select quietly.
7673 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7674 (gnus-summary-exit)
7675 (gnus-message 7 "No more%s articles (%s)..."
7676 (if unread " unread" "")
7677 (if group (concat "selecting " group)
7678 "exiting"))
7679 (gnus-summary-next-group nil group backward)))
7681 (when (gnus-key-press-event-p last-input-event)
7682 (gnus-summary-walk-group-buffer
7683 gnus-newsgroup-name cmd unread backward point))))))))
7685 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7686 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7687 (?\C-p (gnus-group-prev-unread-group 1))))
7688 (cursor-in-echo-area t)
7689 keve key group ended prompt)
7690 (with-current-buffer gnus-group-buffer
7691 (goto-char start)
7692 (setq group
7693 (if (eq gnus-keep-same-level 'best)
7694 (gnus-summary-best-group gnus-newsgroup-name)
7695 (gnus-summary-search-group backward gnus-keep-same-level))))
7696 (while (not ended)
7697 (setq prompt
7698 (format
7699 "No more%s articles%s " (if unread " unread" "")
7700 (if (and group
7701 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7702 (format " (Type %s for %s [%s])"
7703 (single-key-description cmd)
7704 (gnus-group-decoded-name group)
7705 (gnus-group-unread group))
7706 (format " (Type %s to exit %s)"
7707 (single-key-description cmd)
7708 (gnus-group-decoded-name gnus-newsgroup-name)))))
7709 ;; Confirm auto selection.
7710 (setq key (car (setq keve (gnus-read-event-char prompt)))
7711 ended t)
7712 (cond
7713 ((assq key keystrokes)
7714 (let ((obuf (current-buffer)))
7715 (switch-to-buffer gnus-group-buffer)
7716 (when group
7717 (gnus-group-jump-to-group group))
7718 (eval (cadr (assq key keystrokes)))
7719 (setq group (gnus-group-group-name))
7720 (switch-to-buffer obuf))
7721 (setq ended nil))
7722 ((equal key cmd)
7723 (if (or (not group)
7724 (gnus-ephemeral-group-p gnus-newsgroup-name))
7725 (gnus-summary-exit)
7726 (gnus-summary-next-group nil group backward)))
7728 (push (cdr keve) unread-command-events))))))
7730 (defun gnus-summary-next-unread-article ()
7731 "Select unread article after current one."
7732 (interactive)
7733 (gnus-summary-next-article
7734 (or (not (eq gnus-summary-goto-unread 'never))
7735 (gnus-summary-last-article-p (gnus-summary-article-number)))
7736 (and gnus-auto-select-same
7737 (gnus-summary-article-subject))))
7739 (defun gnus-summary-prev-article (&optional unread subject)
7740 "Select the article before the current one.
7741 If UNREAD is non-nil, only unread articles are selected."
7742 (interactive "P")
7743 (gnus-summary-next-article unread subject t))
7745 (defun gnus-summary-prev-unread-article ()
7746 "Select unread article before current one."
7747 (interactive)
7748 (gnus-summary-prev-article
7749 (or (not (eq gnus-summary-goto-unread 'never))
7750 (gnus-summary-first-article-p (gnus-summary-article-number)))
7751 (and gnus-auto-select-same
7752 (gnus-summary-article-subject))))
7754 (defun gnus-summary-next-page (&optional lines circular stop)
7755 "Show next page of the selected article.
7756 If at the end of the current article, select the next article.
7757 LINES says how many lines should be scrolled up.
7759 If CIRCULAR is non-nil, go to the start of the article instead of
7760 selecting the next article when reaching the end of the current
7761 article.
7763 If STOP is non-nil, just stop when reaching the end of the message.
7765 Also see the variable `gnus-article-skip-boring'."
7766 (interactive "P")
7767 (setq gnus-summary-buffer (current-buffer))
7768 (gnus-set-global-variables)
7769 (let ((article (gnus-summary-article-number))
7770 (article-window (get-buffer-window gnus-article-buffer t))
7771 endp)
7772 ;; If the buffer is empty, we have no article.
7773 (unless article
7774 (error "No article to select"))
7775 (gnus-configure-windows 'article)
7776 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7777 (if (and (eq gnus-summary-goto-unread 'never)
7778 (not (gnus-summary-last-article-p article)))
7779 (gnus-summary-next-article)
7780 (gnus-summary-next-unread-article))
7781 (if (or (null gnus-current-article)
7782 (null gnus-article-current)
7783 (/= article (cdr gnus-article-current))
7784 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7785 ;; Selected subject is different from current article's.
7786 (gnus-summary-display-article article)
7787 (when article-window
7788 (gnus-eval-in-buffer-window gnus-article-buffer
7789 (setq endp (or (gnus-article-next-page lines)
7790 (gnus-article-only-boring-p))))
7791 (when endp
7792 (cond ((or stop gnus-summary-stop-at-end-of-message)
7793 (gnus-message 3 "End of message"))
7794 (circular
7795 (gnus-summary-beginning-of-article))
7796 (lines
7797 (gnus-message 3 "End of message"))
7798 ((null lines)
7799 (if (and (eq gnus-summary-goto-unread 'never)
7800 (not (gnus-summary-last-article-p article)))
7801 (gnus-summary-next-article)
7802 (gnus-summary-next-unread-article))))))))
7803 (gnus-summary-recenter)
7804 (gnus-summary-position-point)))
7806 (defun gnus-summary-prev-page (&optional lines move)
7807 "Show previous page of selected article.
7808 Argument LINES specifies lines to be scrolled down.
7809 If MOVE, move to the previous unread article if point is at
7810 the beginning of the buffer."
7811 (interactive "P")
7812 (let ((article (gnus-summary-article-number))
7813 (article-window (get-buffer-window gnus-article-buffer t))
7814 endp)
7815 (gnus-configure-windows 'article)
7816 (if (or (null gnus-current-article)
7817 (null gnus-article-current)
7818 (/= article (cdr gnus-article-current))
7819 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7820 ;; Selected subject is different from current article's.
7821 (gnus-summary-display-article article)
7822 (gnus-summary-recenter)
7823 (when article-window
7824 (gnus-eval-in-buffer-window gnus-article-buffer
7825 (setq endp (gnus-article-prev-page lines)))
7826 (when (and move endp)
7827 (cond (lines
7828 (gnus-message 3 "Beginning of message"))
7829 ((null lines)
7830 (if (and (eq gnus-summary-goto-unread 'never)
7831 (not (gnus-summary-first-article-p article)))
7832 (gnus-summary-prev-article)
7833 (gnus-summary-prev-unread-article))))))))
7834 (gnus-summary-position-point))
7836 (defun gnus-summary-prev-page-or-article (&optional lines)
7837 "Show previous page of selected article.
7838 Argument LINES specifies lines to be scrolled down.
7839 If at the beginning of the article, go to the next article."
7840 (interactive "P")
7841 (gnus-summary-prev-page lines t))
7843 (defun gnus-summary-scroll-up (lines)
7844 "Scroll up (or down) one line current article.
7845 Argument LINES specifies lines to be scrolled up (or down if negative).
7846 If no article is selected, then the current article will be selected first."
7847 (interactive "p")
7848 (gnus-configure-windows 'article)
7849 (gnus-summary-show-thread)
7850 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7851 (gnus-eval-in-buffer-window gnus-article-buffer
7852 (cond ((> lines 0)
7853 (when (gnus-article-next-page lines)
7854 (gnus-message 3 "End of message")))
7855 ((< lines 0)
7856 (gnus-article-prev-page (- lines))))))
7857 (gnus-summary-recenter)
7858 (gnus-summary-position-point))
7860 (defun gnus-summary-scroll-down (lines)
7861 "Scroll down (or up) one line current article.
7862 Argument LINES specifies lines to be scrolled down (or up if negative).
7863 If no article is selected, then the current article will be selected first."
7864 (interactive "p")
7865 (gnus-summary-scroll-up (- lines)))
7867 (defun gnus-summary-next-same-subject ()
7868 "Select next article which has the same subject as current one."
7869 (interactive)
7870 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7872 (defun gnus-summary-prev-same-subject ()
7873 "Select previous article which has the same subject as current one."
7874 (interactive)
7875 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7877 (defun gnus-summary-next-unread-same-subject ()
7878 "Select next unread article which has the same subject as current one."
7879 (interactive)
7880 (gnus-summary-next-article t (gnus-summary-article-subject)))
7882 (defun gnus-summary-prev-unread-same-subject ()
7883 "Select previous unread article which has the same subject as current one."
7884 (interactive)
7885 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7887 (defun gnus-summary-first-unread-article ()
7888 "Select the first unread article.
7889 Return nil if there are no unread articles."
7890 (interactive)
7891 (prog1
7892 (when (gnus-summary-first-subject t)
7893 (gnus-summary-show-thread)
7894 (gnus-summary-first-subject t)
7895 (gnus-summary-display-article (gnus-summary-article-number)))
7896 (gnus-summary-position-point)))
7898 (defun gnus-summary-first-unread-subject ()
7899 "Place the point on the subject line of the first unread article.
7900 Return nil if there are no unread articles."
7901 (interactive)
7902 (prog1
7903 (when (gnus-summary-first-subject t)
7904 (gnus-summary-show-thread)
7905 (gnus-summary-first-subject t))
7906 (gnus-summary-position-point)))
7908 (defun gnus-summary-first-unseen-subject ()
7909 "Place the point on the subject line of the first unseen article.
7910 Return nil if there are no unseen articles."
7911 (interactive)
7912 (prog1
7913 (when (gnus-summary-first-subject nil nil t)
7914 (gnus-summary-show-thread)
7915 (gnus-summary-first-subject nil nil t))
7916 (gnus-summary-position-point)))
7918 (defun gnus-summary-first-unseen-or-unread-subject ()
7919 "Place the point on the subject line of the first unseen and unread article.
7920 If all article have been seen, on the subject line of the first unread
7921 article."
7922 (interactive)
7923 (prog1
7924 (unless (when (gnus-summary-first-subject nil nil t)
7925 (gnus-summary-show-thread)
7926 (gnus-summary-first-subject nil nil t))
7927 (when (gnus-summary-first-subject t)
7928 (gnus-summary-show-thread)
7929 (gnus-summary-first-subject t)))
7930 (gnus-summary-position-point)))
7932 (defun gnus-summary-first-article ()
7933 "Select the first article.
7934 Return nil if there are no articles."
7935 (interactive)
7936 (prog1
7937 (when (gnus-summary-first-subject)
7938 (gnus-summary-show-thread)
7939 (gnus-summary-first-subject)
7940 (gnus-summary-display-article (gnus-summary-article-number)))
7941 (gnus-summary-position-point)))
7943 (defun gnus-summary-best-unread-article (&optional arg)
7944 "Select the unread article with the highest score.
7945 If given a prefix argument, select the next unread article that has a
7946 score higher than the default score."
7947 (interactive "P")
7948 (let ((article (if arg
7949 (gnus-summary-better-unread-subject)
7950 (gnus-summary-best-unread-subject))))
7951 (if article
7952 (gnus-summary-goto-article article)
7953 (error "No unread articles"))))
7955 (defun gnus-summary-best-unread-subject ()
7956 "Select the unread subject with the highest score."
7957 (interactive)
7958 (let ((best -1000000)
7959 (data gnus-newsgroup-data)
7960 article score)
7961 (while data
7962 (and (gnus-data-unread-p (car data))
7963 (> (setq score
7964 (gnus-summary-article-score (gnus-data-number (car data))))
7965 best)
7966 (setq best score
7967 article (gnus-data-number (car data))))
7968 (setq data (cdr data)))
7969 (when article
7970 (gnus-summary-goto-subject article))
7971 (gnus-summary-position-point)
7972 article))
7974 (defun gnus-summary-better-unread-subject ()
7975 "Select the first unread subject that has a score over the default score."
7976 (interactive)
7977 (let ((data gnus-newsgroup-data)
7978 article score)
7979 (while (and (setq article (gnus-data-number (car data)))
7980 (or (gnus-data-read-p (car data))
7981 (not (> (gnus-summary-article-score article)
7982 gnus-summary-default-score))))
7983 (setq data (cdr data)))
7984 (when article
7985 (gnus-summary-goto-subject article))
7986 (gnus-summary-position-point)
7987 article))
7989 (defun gnus-summary-last-subject ()
7990 "Go to the last displayed subject line in the group."
7991 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7992 (when article
7993 (gnus-summary-goto-subject article))))
7995 (defun gnus-summary-goto-article (article &optional all-headers force)
7996 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7997 If ALL-HEADERS is non-nil, no header lines are hidden.
7998 If FORCE, go to the article even if it isn't displayed. If FORCE
7999 is a number, it is the line the article is to be displayed on."
8000 (interactive
8001 (list
8002 (gnus-completing-read
8003 "Article number or Message-ID"
8004 (mapcar 'int-to-string gnus-newsgroup-limit))
8005 current-prefix-arg
8007 (prog1
8008 (if (and (stringp article)
8009 (string-match "@\\|%40" article))
8010 (gnus-summary-refer-article article)
8011 (when (stringp article)
8012 (setq article (string-to-number article)))
8013 (if (gnus-summary-goto-subject article force)
8014 (gnus-summary-display-article article all-headers)
8015 (gnus-message 4 "Couldn't go to article %s" article) nil))
8016 (gnus-summary-position-point)))
8018 (defun gnus-summary-goto-last-article ()
8019 "Go to the previously read article."
8020 (interactive)
8021 (prog1
8022 (when gnus-last-article
8023 (gnus-summary-goto-article gnus-last-article nil t))
8024 (gnus-summary-position-point)))
8026 (defun gnus-summary-pop-article (number)
8027 "Pop one article off the history and go to the previous.
8028 NUMBER articles will be popped off."
8029 (interactive "p")
8030 (let (to)
8031 (setq gnus-newsgroup-history
8032 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8033 (if to
8034 (gnus-summary-goto-article (car to) nil t)
8035 (error "Article history empty")))
8036 (gnus-summary-position-point))
8038 ;; Summary commands and functions for limiting the summary buffer.
8040 (defun gnus-summary-limit-to-articles (n)
8041 "Limit the summary buffer to the next N articles.
8042 If not given a prefix, use the process marked articles instead."
8043 (interactive "P")
8044 (prog1
8045 (let ((articles (gnus-summary-work-articles n)))
8046 (setq gnus-newsgroup-processable nil)
8047 (gnus-summary-limit articles))
8048 (gnus-summary-position-point)))
8050 (defun gnus-summary-pop-limit (&optional total)
8051 "Restore the previous limit.
8052 If given a prefix, remove all limits."
8053 (interactive "P")
8054 (when total
8055 (setq gnus-newsgroup-limits
8056 (list (mapcar (lambda (h) (mail-header-number h))
8057 gnus-newsgroup-headers))))
8058 (unless gnus-newsgroup-limits
8059 (error "No limit to pop"))
8060 (prog1
8061 (gnus-summary-limit nil 'pop)
8062 (gnus-summary-position-point)))
8064 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8065 "Limit the summary buffer to articles that have subjects that match a regexp.
8066 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8067 (interactive
8068 (list (read-string (if current-prefix-arg
8069 "Exclude subject (regexp): "
8070 "Limit to subject (regexp): "))
8071 nil current-prefix-arg))
8072 (unless header
8073 (setq header "subject"))
8074 (when (not (equal "" subject))
8075 (prog1
8076 (let ((articles (gnus-summary-find-matching
8077 (or header "subject") subject 'all nil nil
8078 not-matching)))
8079 (unless articles
8080 (error "Found no matches for \"%s\"" subject))
8081 (gnus-summary-limit articles))
8082 (gnus-summary-position-point))))
8084 (defun gnus-summary-limit-to-author (from &optional not-matching)
8085 "Limit the summary buffer to articles that have authors that match a regexp.
8086 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8087 (interactive
8088 (list (read-string (if current-prefix-arg
8089 "Exclude author (regexp): "
8090 "Limit to author (regexp): "))
8091 current-prefix-arg))
8092 (gnus-summary-limit-to-subject from "from" not-matching))
8094 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8095 "Limit the summary buffer to articles with the given RECIPIENT.
8097 If NOT-MATCHING, exclude RECIPIENT.
8099 To and Cc headers are checked. You need to include them in
8100 `nnmail-extra-headers'."
8101 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8102 (interactive
8103 (list (read-string (format "%s recipient (regexp): "
8104 (if current-prefix-arg "Exclude" "Limit to")))
8105 current-prefix-arg))
8106 (when (not (equal "" recipient))
8107 (prog1 (let* ((to
8108 (if (memq 'To nnmail-extra-headers)
8109 (gnus-summary-find-matching
8110 (cons 'extra 'To) recipient 'all nil nil
8111 not-matching)
8112 (gnus-message
8113 1 "`To' isn't present in `nnmail-extra-headers'")
8114 (sit-for 1)
8115 nil))
8117 (if (memq 'Cc nnmail-extra-headers)
8118 (gnus-summary-find-matching
8119 (cons 'extra 'Cc) recipient 'all nil nil
8120 not-matching)
8121 (gnus-message
8122 1 "`Cc' isn't present in `nnmail-extra-headers'")
8123 (sit-for 1)
8124 nil))
8125 (articles
8126 (if not-matching
8127 ;; We need the numbers that are in both lists:
8128 (mapcar (lambda (a)
8129 (and (memq a to) a))
8131 (nconc to cc))))
8132 (unless articles
8133 (error "Found no matches for \"%s\"" recipient))
8134 (gnus-summary-limit articles))
8135 (gnus-summary-position-point))))
8137 (defun gnus-summary-limit-to-address (address &optional not-matching)
8138 "Limit the summary buffer to articles with the given ADDRESS.
8140 If NOT-MATCHING, exclude ADDRESS.
8142 To, Cc and From headers are checked. You need to include `To' and `Cc'
8143 in `nnmail-extra-headers'."
8144 (interactive
8145 (list (read-string (format "%s address (regexp): "
8146 (if current-prefix-arg "Exclude" "Limit to")))
8147 current-prefix-arg))
8148 (when (not (equal "" address))
8149 (prog1 (let* ((to
8150 (if (memq 'To nnmail-extra-headers)
8151 (gnus-summary-find-matching
8152 (cons 'extra 'To) address 'all nil nil
8153 not-matching)
8154 (gnus-message
8155 1 "`To' isn't present in `nnmail-extra-headers'")
8156 (sit-for 1)
8159 (if (memq 'Cc nnmail-extra-headers)
8160 (gnus-summary-find-matching
8161 (cons 'extra 'Cc) address 'all nil nil
8162 not-matching)
8163 (gnus-message
8164 1 "`Cc' isn't present in `nnmail-extra-headers'")
8165 (sit-for 1)
8167 (from
8168 (gnus-summary-find-matching "from" address
8169 'all nil nil not-matching))
8170 (articles
8171 (if not-matching
8172 ;; We need the numbers that are in all lists:
8173 (if (eq cc t)
8174 (if (eq to t)
8175 from
8176 (mapcar (lambda (a) (car (memq a from))) to))
8177 (if (eq to t)
8178 (mapcar (lambda (a) (car (memq a from))) cc)
8179 (mapcar (lambda (a) (car (memq a from)))
8180 (mapcar (lambda (a) (car (memq a to)))
8181 cc))))
8182 (nconc (if (eq to t) nil to)
8183 (if (eq cc t) nil cc)
8184 from))))
8185 (unless articles
8186 (error "Found no matches for \"%s\"" address))
8187 (gnus-summary-limit articles))
8188 (gnus-summary-position-point))))
8190 (defun gnus-summary-limit-strange-charsets-predicate (header)
8191 (when (fboundp 'char-charset)
8192 (let ((string (concat (mail-header-subject header)
8193 (mail-header-from header)))
8194 charset found)
8195 (dotimes (i (1- (length string)))
8196 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8197 (when (string-match "unicode\\|big\\|japanese" charset)
8198 (setq found t)))
8199 found)))
8201 (defun gnus-summary-limit-to-predicate (predicate)
8202 "Limit to articles where PREDICATE returns non-nil.
8203 PREDICATE will be called with the header structures of the
8204 articles."
8205 (let ((articles nil)
8206 (case-fold-search t))
8207 (dolist (header gnus-newsgroup-headers)
8208 (when (funcall predicate header)
8209 (push (mail-header-number header) articles)))
8210 (gnus-summary-limit (nreverse articles))))
8212 (defun gnus-summary-limit-to-age (age &optional younger-p)
8213 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8214 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8215 articles that are younger than AGE days."
8216 (interactive
8217 (let ((younger current-prefix-arg)
8218 (days-got nil)
8219 days)
8220 (while (not days-got)
8221 (setq days (if younger
8222 (read-string "Limit to articles younger than (in days, older when negative): ")
8223 (read-string
8224 "Limit to articles older than (in days, younger when negative): ")))
8225 (when (> (length days) 0)
8226 (setq days (read days)))
8227 (if (numberp days)
8228 (progn
8229 (setq days-got t)
8230 (when (< days 0)
8231 (setq younger (not younger))
8232 (setq days (* days -1))))
8233 (message "Please enter a number.")
8234 (sleep-for 1)))
8235 (list days younger)))
8236 (prog1
8237 (let ((data gnus-newsgroup-data)
8238 (cutoff (days-to-time age))
8239 articles d date is-younger)
8240 (while (setq d (pop data))
8241 (when (and (vectorp (gnus-data-header d))
8242 (setq date (mail-header-date (gnus-data-header d))))
8243 (setq is-younger (time-less-p
8244 (time-since (gnus-date-get-time date))
8245 cutoff))
8246 (when (if younger-p
8247 is-younger
8248 (not is-younger))
8249 (push (gnus-data-number d) articles))))
8250 (gnus-summary-limit (nreverse articles)))
8251 (gnus-summary-position-point)))
8253 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8254 "Limit the summary buffer to articles that match an 'extra' header."
8255 (interactive
8256 (let ((header
8257 (intern
8258 (gnus-completing-read
8259 (if current-prefix-arg
8260 "Exclude extra header"
8261 "Limit extra header")
8262 (mapcar 'symbol-name gnus-extra-headers)
8263 t nil nil
8264 (symbol-name (car gnus-extra-headers))))))
8265 (list header
8266 (read-string (format "%s header %s (regexp): "
8267 (if current-prefix-arg "Exclude" "Limit to")
8268 header))
8269 current-prefix-arg)))
8270 (when (not (equal "" regexp))
8271 (prog1
8272 (let ((articles (gnus-summary-find-matching
8273 (cons 'extra header) regexp 'all nil nil
8274 not-matching)))
8275 (unless articles
8276 (error "Found no matches for \"%s\"" regexp))
8277 (gnus-summary-limit articles))
8278 (gnus-summary-position-point))))
8280 (defun gnus-summary-limit-to-display-predicate ()
8281 "Limit the summary buffer to the predicated in the `display' group parameter."
8282 (interactive)
8283 (unless gnus-newsgroup-display
8284 (error "There is no `display' group parameter"))
8285 (let (articles)
8286 (dolist (gnus-number gnus-newsgroup-articles)
8287 (when (funcall gnus-newsgroup-display)
8288 (push gnus-number articles)))
8289 (gnus-summary-limit articles))
8290 (gnus-summary-position-point))
8292 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8293 (make-obsolete
8294 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
8296 (defun gnus-summary-limit-to-unread (&optional all)
8297 "Limit the summary buffer to articles that are not marked as read.
8298 If ALL is non-nil, limit strictly to unread articles."
8299 (interactive "P")
8300 (if all
8301 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8302 (gnus-summary-limit-to-marks
8303 ;; Concat all the marks that say that an article is read and have
8304 ;; those removed.
8305 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8306 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8307 gnus-low-score-mark gnus-expirable-mark
8308 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8309 gnus-duplicate-mark)
8310 'reverse)))
8312 (defun gnus-summary-limit-to-headers (match &optional reverse)
8313 "Limit the summary buffer to articles that have headers that match MATCH.
8314 If REVERSE (the prefix), limit to articles that don't match."
8315 (interactive "sMatch headers (regexp): \nP")
8316 (gnus-summary-limit-to-bodies match reverse t))
8318 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8319 "Limit the summary buffer to articles that have bodies that match MATCH.
8320 If REVERSE (the prefix), limit to articles that don't match."
8321 (interactive "sMatch body (regexp): \nP")
8322 (let ((articles nil)
8323 (gnus-select-article-hook nil) ;Disable hook.
8324 (gnus-article-prepare-hook nil)
8325 (gnus-use-article-prefetch nil)
8326 (gnus-keep-backlog nil)
8327 (gnus-break-pages nil)
8328 (gnus-summary-display-arrow nil)
8329 (gnus-updated-mode-lines nil)
8330 (gnus-auto-center-summary nil)
8331 (gnus-display-mime-function nil))
8332 (dolist (data gnus-newsgroup-data)
8333 (let (gnus-mark-article-hook)
8334 (gnus-summary-select-article t t nil (gnus-data-number data)))
8335 (with-current-buffer gnus-article-buffer
8336 (article-goto-body)
8337 (let* ((case-fold-search t)
8338 (found (if headersp
8339 (re-search-backward match nil t)
8340 (re-search-forward match nil t))))
8341 (when (or (and found
8342 (not reverse))
8343 (and (not found)
8344 reverse))
8345 (push (gnus-data-number data) articles)))))
8346 (if (not articles)
8347 (message "No messages matched")
8348 (gnus-summary-limit articles)))
8349 (gnus-summary-position-point))
8351 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8352 "Limit the summary buffer to articles that aren't part on any thread.
8353 If THREADSP (the prefix), limit to articles that are in threads."
8354 (interactive "P")
8355 (let ((articles nil)
8356 thread-articles
8357 threads)
8358 (dolist (thread gnus-newsgroup-threads)
8359 (if (stringp (car thread))
8360 (dolist (thread (cdr thread))
8361 (push thread threads))
8362 (push thread threads)))
8363 (dolist (thread threads)
8364 (setq thread-articles (gnus-articles-in-thread thread))
8365 (when (or (and threadsp
8366 (> (length thread-articles) 1))
8367 (and (not threadsp)
8368 (= (length thread-articles) 1)))
8369 (setq articles (nconc thread-articles articles))))
8370 (if (not articles)
8371 (message "No messages matched")
8372 (gnus-summary-limit articles))
8373 (gnus-summary-position-point)))
8375 (defun gnus-summary-limit-to-replied (&optional unreplied)
8376 "Limit the summary buffer to replied articles.
8377 If UNREPLIED (the prefix), limit to unreplied articles."
8378 (interactive "P")
8379 (if unreplied
8380 (gnus-summary-limit
8381 (gnus-set-difference gnus-newsgroup-articles
8382 gnus-newsgroup-replied))
8383 (gnus-summary-limit gnus-newsgroup-replied))
8384 (gnus-summary-position-point))
8386 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8387 (make-obsolete 'gnus-summary-delete-marked-with
8388 'gnus-summary-limit-exclude-marks "Emacs 20.4")
8390 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8391 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8392 If REVERSE, limit the summary buffer to articles that are marked
8393 with MARKS. MARKS can either be a string of marks or a list of marks.
8394 Returns how many articles were removed."
8395 (interactive "sMarks: ")
8396 (gnus-summary-limit-to-marks marks t))
8398 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8399 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8400 If REVERSE (the prefix), limit the summary buffer to articles that are
8401 not marked with MARKS. MARKS can either be a string of marks or a
8402 list of marks.
8403 Returns how many articles were removed."
8404 (interactive "sMarks: \nP")
8405 (prog1
8406 (let ((data gnus-newsgroup-data)
8407 (marks (if (listp marks) marks
8408 (append marks nil))) ; Transform to list.
8409 articles)
8410 (while data
8411 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8412 (memq (gnus-data-mark (car data)) marks))
8413 (push (gnus-data-number (car data)) articles))
8414 (setq data (cdr data)))
8415 (gnus-summary-limit articles))
8416 (gnus-summary-position-point)))
8418 (defun gnus-summary-limit-to-score (score)
8419 "Limit to articles with score at or above SCORE."
8420 (interactive "NLimit to articles with score of at least: ")
8421 (let ((data gnus-newsgroup-data)
8422 articles)
8423 (while data
8424 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8425 score)
8426 (push (gnus-data-number (car data)) articles))
8427 (setq data (cdr data)))
8428 (prog1
8429 (gnus-summary-limit articles)
8430 (gnus-summary-position-point))))
8432 (defun gnus-summary-limit-to-unseen ()
8433 "Limit to unseen articles."
8434 (interactive)
8435 (prog1
8436 (gnus-summary-limit gnus-newsgroup-unseen)
8437 (gnus-summary-position-point)))
8439 (defun gnus-summary-limit-include-thread (id)
8440 "Display all the hidden articles that is in the thread with ID in it.
8441 When called interactively, ID is the Message-ID of the current
8442 article."
8443 (interactive (list (mail-header-id (gnus-summary-article-header))))
8444 (let ((articles (gnus-articles-in-thread
8445 (gnus-id-to-thread (gnus-root-id id)))))
8446 (prog1
8447 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8448 (gnus-summary-limit-include-matching-articles
8449 "subject"
8450 (regexp-quote (gnus-simplify-subject-re
8451 (mail-header-subject (gnus-id-to-header id)))))
8452 (gnus-summary-position-point))))
8454 (defun gnus-summary-limit-include-matching-articles (header regexp)
8455 "Display all the hidden articles that have HEADERs that match REGEXP."
8456 (interactive (list (read-string "Match on header: ")
8457 (read-string "Regexp: ")))
8458 (let ((articles (gnus-find-matching-articles header regexp)))
8459 (prog1
8460 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8461 (gnus-summary-position-point))))
8463 (defun gnus-summary-insert-dormant-articles ()
8464 "Insert all the dormant articles for this group into the current buffer."
8465 (interactive)
8466 (let ((gnus-verbose (max 6 gnus-verbose)))
8467 (if (not gnus-newsgroup-dormant)
8468 (gnus-message 3 "No dormant articles for this group")
8469 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8471 (defun gnus-summary-insert-ticked-articles ()
8472 "Insert ticked articles for this group into the current buffer."
8473 (interactive)
8474 (let ((gnus-verbose (max 6 gnus-verbose)))
8475 (if (not gnus-newsgroup-marked)
8476 (gnus-message 3 "No ticked articles for this group")
8477 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8479 (defun gnus-summary-limit-include-dormant ()
8480 "Display all the hidden articles that are marked as dormant.
8481 Note that this command only works on a subset of the articles currently
8482 fetched for this group."
8483 (interactive)
8484 (unless gnus-newsgroup-dormant
8485 (error "There are no dormant articles in this group"))
8486 (prog1
8487 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8488 (gnus-summary-position-point)))
8490 (defun gnus-summary-limit-exclude-dormant ()
8491 "Hide all dormant articles."
8492 (interactive)
8493 (prog1
8494 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8495 (gnus-summary-position-point)))
8497 (defun gnus-summary-limit-exclude-childless-dormant ()
8498 "Hide all dormant articles that have no children."
8499 (interactive)
8500 (let ((data (gnus-data-list t))
8501 articles d children)
8502 ;; Find all articles that are either not dormant or have
8503 ;; children.
8504 (while (setq d (pop data))
8505 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8506 (and (setq children
8507 (gnus-article-children (gnus-data-number d)))
8508 (let (found)
8509 (while children
8510 (when (memq (car children) articles)
8511 (setq children nil
8512 found t))
8513 (pop children))
8514 found)))
8515 (push (gnus-data-number d) articles)))
8516 ;; Do the limiting.
8517 (prog1
8518 (gnus-summary-limit articles)
8519 (gnus-summary-position-point))))
8521 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8522 "Mark all unread excluded articles as read.
8523 If ALL, mark even excluded ticked and dormants as read."
8524 (interactive "P")
8525 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8526 (let ((articles (gnus-sorted-ndifference
8527 (sort
8528 (mapcar (lambda (h) (mail-header-number h))
8529 gnus-newsgroup-headers)
8531 gnus-newsgroup-limit))
8532 article)
8533 (setq gnus-newsgroup-unreads
8534 (gnus-sorted-intersection gnus-newsgroup-unreads
8535 gnus-newsgroup-limit))
8536 (if all
8537 (setq gnus-newsgroup-dormant nil
8538 gnus-newsgroup-marked nil
8539 gnus-newsgroup-reads
8540 (nconc
8541 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8542 gnus-newsgroup-reads))
8543 (while (setq article (pop articles))
8544 (unless (or (memq article gnus-newsgroup-dormant)
8545 (memq article gnus-newsgroup-marked))
8546 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8548 (defun gnus-summary-limit (articles &optional pop)
8549 (if pop
8550 ;; We pop the previous limit off the stack and use that.
8551 (setq articles (car gnus-newsgroup-limits)
8552 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8553 ;; We use the new limit, so we push the old limit on the stack.
8554 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8555 ;; Set the limit.
8556 (setq gnus-newsgroup-limit articles)
8557 (let ((total (length gnus-newsgroup-data))
8558 (data (gnus-data-find-list (gnus-summary-article-number)))
8559 (gnus-summary-mark-below nil) ; Inhibit this.
8560 found)
8561 ;; This will do all the work of generating the new summary buffer
8562 ;; according to the new limit.
8563 (gnus-summary-prepare)
8564 ;; Hide any threads, possibly.
8565 (gnus-summary-maybe-hide-threads)
8566 ;; Try to return to the article you were at, or one in the
8567 ;; neighborhood.
8568 (when data
8569 ;; We try to find some article after the current one.
8570 (while data
8571 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8572 (setq data nil
8573 found t))
8574 (setq data (cdr data))))
8575 (unless found
8576 ;; If there is no data, that means that we were after the last
8577 ;; article. The same goes when we can't find any articles
8578 ;; after the current one.
8579 (goto-char (point-max))
8580 (gnus-summary-find-prev))
8581 (gnus-set-mode-line 'summary)
8582 ;; We return how many articles were removed from the summary
8583 ;; buffer as a result of the new limit.
8584 (- total (length gnus-newsgroup-data))))
8586 (defsubst gnus-invisible-cut-children (threads)
8587 (let ((num 0))
8588 (while threads
8589 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8590 (incf num))
8591 (pop threads))
8592 (< num 2)))
8594 (defsubst gnus-cut-thread (thread)
8595 "Go forwards in the thread until we find an article that we want to display."
8596 (when (or (eq gnus-fetch-old-headers 'some)
8597 (eq gnus-fetch-old-headers 'invisible)
8598 (numberp gnus-fetch-old-headers)
8599 (eq gnus-build-sparse-threads 'some)
8600 (eq gnus-build-sparse-threads 'more))
8601 ;; Deal with old-fetched headers and sparse threads.
8602 (while (and
8603 thread
8605 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8606 (gnus-summary-article-ancient-p
8607 (mail-header-number (car thread))))
8608 (if (or (<= (length (cdr thread)) 1)
8609 (eq gnus-fetch-old-headers 'invisible))
8610 (setq gnus-newsgroup-limit
8611 (delq (mail-header-number (car thread))
8612 gnus-newsgroup-limit)
8613 thread (cadr thread))
8614 (when (gnus-invisible-cut-children (cdr thread))
8615 (let ((th (cdr thread)))
8616 (while th
8617 (if (memq (mail-header-number (caar th))
8618 gnus-newsgroup-limit)
8619 (setq thread (car th)
8620 th nil)
8621 (setq th (cdr th))))))))))
8622 thread)
8624 (defun gnus-cut-threads (threads)
8625 "Cut off all uninteresting articles from the beginning of THREADS."
8626 (when (or (eq gnus-fetch-old-headers 'some)
8627 (eq gnus-fetch-old-headers 'invisible)
8628 (numberp gnus-fetch-old-headers)
8629 (eq gnus-build-sparse-threads 'some)
8630 (eq gnus-build-sparse-threads 'more))
8631 (let ((th threads))
8632 (while th
8633 (setcar th (gnus-cut-thread (car th)))
8634 (setq th (cdr th)))))
8635 ;; Remove nixed out threads.
8636 (delq nil threads))
8638 (defun gnus-summary-initial-limit (&optional show-if-empty)
8639 "Figure out what the initial limit is supposed to be on group entry.
8640 This entails weeding out unwanted dormants, low-scored articles,
8641 fetch-old-headers verbiage, and so on."
8642 ;; Most groups have nothing to remove.
8643 (unless (or gnus-inhibit-limiting
8644 (and (null gnus-newsgroup-dormant)
8645 (eq gnus-newsgroup-display 'gnus-not-ignore)
8646 (not (eq gnus-fetch-old-headers 'some))
8647 (not (numberp gnus-fetch-old-headers))
8648 (not (eq gnus-fetch-old-headers 'invisible))
8649 (null gnus-summary-expunge-below)
8650 (not (eq gnus-build-sparse-threads 'some))
8651 (not (eq gnus-build-sparse-threads 'more))
8652 (null gnus-thread-expunge-below)))
8653 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8654 (setq gnus-newsgroup-limit nil)
8655 (mapatoms
8656 (lambda (node)
8657 (unless (car (symbol-value node))
8658 ;; These threads have no parents -- they are roots.
8659 (let ((nodes (cdr (symbol-value node)))
8660 thread)
8661 (while nodes
8662 (if (and gnus-thread-expunge-below
8663 (< (gnus-thread-total-score (car nodes))
8664 gnus-thread-expunge-below))
8665 (gnus-expunge-thread (pop nodes))
8666 (setq thread (pop nodes))
8667 (gnus-summary-limit-children thread))))))
8668 gnus-newsgroup-dependencies)
8669 ;; If this limitation resulted in an empty group, we might
8670 ;; pop the previous limit and use it instead.
8671 (when (and (not gnus-newsgroup-limit)
8672 show-if-empty)
8673 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8674 gnus-newsgroup-limit))
8676 (defun gnus-summary-limit-children (thread)
8677 "Return 1 if this subthread is visible and 0 if it is not."
8678 ;; First we get the number of visible children to this thread. This
8679 ;; is done by recursing down the thread using this function, so this
8680 ;; will really go down to a leaf article first, before slowly
8681 ;; working its way up towards the root.
8682 (when thread
8683 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8684 (children
8685 (if (cdr thread)
8686 (apply '+ (mapcar 'gnus-summary-limit-children
8687 (cdr thread)))
8689 (number (mail-header-number (car thread)))
8690 score)
8691 (if (and
8692 (not (memq number gnus-newsgroup-marked))
8694 ;; If this article is dormant and has absolutely no visible
8695 ;; children, then this article isn't visible.
8696 (and (memq number gnus-newsgroup-dormant)
8697 (zerop children))
8698 ;; If this is "fetch-old-headered" and there is no
8699 ;; visible children, then we don't want this article.
8700 (and (or (eq gnus-fetch-old-headers 'some)
8701 (numberp gnus-fetch-old-headers))
8702 (gnus-summary-article-ancient-p number)
8703 (zerop children))
8704 ;; If this is "fetch-old-headered" and `invisible', then
8705 ;; we don't want this article.
8706 (and (eq gnus-fetch-old-headers 'invisible)
8707 (gnus-summary-article-ancient-p number))
8708 ;; If this is a sparsely inserted article with no children,
8709 ;; we don't want it.
8710 (and (eq gnus-build-sparse-threads 'some)
8711 (gnus-summary-article-sparse-p number)
8712 (zerop children))
8713 ;; If we use expunging, and this article is really
8714 ;; low-scored, then we don't want this article.
8715 (when (and gnus-summary-expunge-below
8716 (< (setq score
8717 (or (cdr (assq number gnus-newsgroup-scored))
8718 gnus-summary-default-score))
8719 gnus-summary-expunge-below))
8720 ;; We increase the expunge-tally here, but that has
8721 ;; nothing to do with the limits, really.
8722 (incf gnus-newsgroup-expunged-tally)
8723 ;; We also mark as read here, if that's wanted.
8724 (when (and gnus-summary-mark-below
8725 (< score gnus-summary-mark-below))
8726 (setq gnus-newsgroup-unreads
8727 (delq number gnus-newsgroup-unreads))
8728 (if gnus-newsgroup-auto-expire
8729 (push number gnus-newsgroup-expirable)
8730 (push (cons number gnus-low-score-mark)
8731 gnus-newsgroup-reads)))
8733 ;; Do the `display' group parameter.
8734 (and gnus-newsgroup-display
8735 (let ((gnus-number number))
8736 (not (funcall gnus-newsgroup-display))))))
8737 ;; Nope, invisible article.
8739 ;; Ok, this article is to be visible, so we add it to the limit
8740 ;; and return 1.
8741 (push number gnus-newsgroup-limit)
8742 1))))
8744 (defun gnus-expunge-thread (thread)
8745 "Mark all articles in THREAD as read."
8746 (let* ((number (mail-header-number (car thread))))
8747 (incf gnus-newsgroup-expunged-tally)
8748 ;; We also mark as read here, if that's wanted.
8749 (setq gnus-newsgroup-unreads
8750 (delq number gnus-newsgroup-unreads))
8751 (if gnus-newsgroup-auto-expire
8752 (push number gnus-newsgroup-expirable)
8753 (push (cons number gnus-low-score-mark)
8754 gnus-newsgroup-reads)))
8755 ;; Go recursively through all subthreads.
8756 (mapcar 'gnus-expunge-thread (cdr thread)))
8758 ;; Summary article oriented commands
8760 (defun gnus-summary-refer-parent-article (n)
8761 "Refer parent article N times.
8762 If N is negative, go to ancestor -N instead.
8763 The difference between N and the number of articles fetched is returned."
8764 (interactive "p")
8765 (let ((skip 1)
8766 error header ref)
8767 (when (not (natnump n))
8768 (setq skip (abs n)
8769 n 1))
8770 (while (and (> n 0)
8771 (not error))
8772 (setq header (gnus-summary-article-header))
8773 (if (and (eq (mail-header-number header)
8774 (cdr gnus-article-current))
8775 (equal gnus-newsgroup-name
8776 (car gnus-article-current)))
8777 ;; If we try to find the parent of the currently
8778 ;; displayed article, then we take a look at the actual
8779 ;; References header, since this is slightly more
8780 ;; reliable than the References field we got from the
8781 ;; server.
8782 (with-current-buffer gnus-original-article-buffer
8783 (nnheader-narrow-to-headers)
8784 (unless (setq ref (message-fetch-field "references"))
8785 (when (setq ref (message-fetch-field "in-reply-to"))
8786 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8787 (widen))
8788 (setq ref
8789 ;; It's not the current article, so we take a bet on
8790 ;; the value we got from the server.
8791 (mail-header-references header)))
8792 (if (and ref
8793 (not (equal ref "")))
8794 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8795 (gnus-message 1 "Couldn't find parent"))
8796 (gnus-message 1 "No references in article %d"
8797 (gnus-summary-article-number))
8798 (setq error t))
8799 (decf n))
8800 (gnus-summary-position-point)
8803 (defun gnus-summary-refer-references ()
8804 "Fetch all articles mentioned in the References header.
8805 Return the number of articles fetched."
8806 (interactive)
8807 (let ((ref (mail-header-references (gnus-summary-article-header)))
8808 (current (gnus-summary-article-number))
8809 (n 0))
8810 (if (or (not ref)
8811 (equal ref ""))
8812 (error "No References in the current article")
8813 ;; For each Message-ID in the References header...
8814 (while (string-match "<[^>]*>" ref)
8815 (incf n)
8816 ;; ... fetch that article.
8817 (gnus-summary-refer-article
8818 (prog1 (match-string 0 ref)
8819 (setq ref (substring ref (match-end 0))))))
8820 (gnus-summary-goto-subject current)
8821 (gnus-summary-position-point)
8822 n)))
8824 (defun gnus-summary-refer-thread (&optional limit)
8825 "Fetch all articles in the current thread.
8826 If LIMIT (the numerical prefix), fetch that many old headers instead
8827 of what's specified by the `gnus-refer-thread-limit' variable."
8828 (interactive "P")
8829 (let ((id (mail-header-id (gnus-summary-article-header)))
8830 (limit (if limit (prefix-numeric-value limit)
8831 gnus-refer-thread-limit)))
8832 (unless (eq gnus-fetch-old-headers 'invisible)
8833 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8834 ;; Retrieve the headers and read them in.
8835 (if (eq (if (numberp limit)
8836 (gnus-retrieve-headers
8837 (list (min
8838 (+ (mail-header-number
8839 (gnus-summary-article-header))
8840 limit)
8841 gnus-newsgroup-end))
8842 gnus-newsgroup-name (* limit 2))
8843 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8844 ;; headers.
8845 (gnus-retrieve-headers (list gnus-newsgroup-end)
8846 gnus-newsgroup-name limit))
8847 'nov)
8848 (gnus-build-all-threads)
8849 (error "Can't fetch thread from back ends that don't support NOV"))
8850 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8851 (gnus-summary-limit-include-thread id)))
8853 (defun gnus-summary-refer-article (message-id)
8854 "Fetch an article specified by MESSAGE-ID."
8855 (interactive "sMessage-ID: ")
8856 (when (and (stringp message-id)
8857 (not (zerop (length message-id))))
8858 (setq message-id (gnus-replace-in-string message-id " " ""))
8859 ;; Construct the correct Message-ID if necessary.
8860 ;; Suggested by tale@pawl.rpi.edu.
8861 (unless (string-match "^<" message-id)
8862 (setq message-id (concat "<" message-id)))
8863 (unless (string-match ">$" message-id)
8864 (setq message-id (concat message-id ">")))
8865 ;; People often post MIDs from URLs, so unhex it:
8866 (unless (string-match "@" message-id)
8867 (setq message-id (gnus-url-unhex-string message-id)))
8868 (let* ((header (gnus-id-to-header message-id))
8869 (sparse (and header
8870 (gnus-summary-article-sparse-p
8871 (mail-header-number header))
8872 (memq (mail-header-number header)
8873 gnus-newsgroup-limit)))
8874 number)
8875 (cond
8876 ;; If the article is present in the buffer we just go to it.
8877 ((and header
8878 (or (not (gnus-summary-article-sparse-p
8879 (mail-header-number header)))
8880 sparse))
8881 (prog1
8882 (gnus-summary-goto-article
8883 (mail-header-number header) nil t)
8884 (when sparse
8885 (gnus-summary-update-article (mail-header-number header)))))
8887 ;; We fetch the article.
8888 (catch 'found
8889 (dolist (gnus-override-method (gnus-refer-article-methods))
8890 (when (and (gnus-check-server gnus-override-method)
8891 ;; Fetch the header,
8892 (setq number (gnus-summary-insert-subject message-id)))
8893 ;; and display the article.
8894 (gnus-summary-select-article nil nil nil number)
8895 (throw 'found t)))
8896 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8898 (defun gnus-refer-article-methods ()
8899 "Return a list of referable methods."
8900 (cond
8901 ;; No method, so we default to current and native.
8902 ((null gnus-refer-article-method)
8903 (list gnus-current-select-method gnus-select-method))
8904 ;; Current.
8905 ((eq 'current gnus-refer-article-method)
8906 (list gnus-current-select-method))
8907 ;; List of select methods.
8908 ((not (and (symbolp (car gnus-refer-article-method))
8909 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8910 (let (out)
8911 (dolist (method gnus-refer-article-method)
8912 (push (if (eq 'current method)
8913 gnus-current-select-method
8914 method)
8915 out))
8916 (nreverse out)))
8917 ;; One single select method.
8919 (list gnus-refer-article-method))))
8921 (defun gnus-summary-edit-parameters ()
8922 "Edit the group parameters of the current group."
8923 (interactive)
8924 (gnus-group-edit-group gnus-newsgroup-name 'params))
8926 (defun gnus-summary-customize-parameters ()
8927 "Customize the group parameters of the current group."
8928 (interactive)
8929 (gnus-group-customize gnus-newsgroup-name))
8931 (defun gnus-summary-enter-digest-group (&optional force)
8932 "Enter an nndoc group based on the current article.
8933 If FORCE, force a digest interpretation. If not, try
8934 to guess what the document format is."
8935 (interactive "P")
8936 (let ((conf gnus-current-window-configuration))
8937 (save-window-excursion
8938 (save-excursion
8939 (let (gnus-article-prepare-hook
8940 gnus-display-mime-function
8941 gnus-break-pages)
8942 (gnus-summary-select-article))))
8943 (setq gnus-current-window-configuration conf)
8944 (let* ((name (format "%s-%d"
8945 (gnus-group-prefixed-name
8946 gnus-newsgroup-name (list 'nndoc ""))
8947 (with-current-buffer gnus-summary-buffer
8948 gnus-current-article)))
8949 (ogroup gnus-newsgroup-name)
8950 (params (append (gnus-info-params (gnus-get-info ogroup))
8951 (list (cons 'to-group ogroup))
8952 (list (cons 'parent-group ogroup))
8953 (list (cons 'save-article-group ogroup))))
8954 (case-fold-search t)
8955 (buf (current-buffer))
8956 dig to-address)
8957 (with-current-buffer gnus-original-article-buffer
8958 ;; Have the digest group inherit the main mail address of
8959 ;; the parent article.
8960 (when (setq to-address (or (gnus-fetch-field "reply-to")
8961 (gnus-fetch-field "from")))
8962 (setq params
8963 (append
8964 (list (cons 'to-address
8965 (funcall gnus-decode-encoded-address-function
8966 to-address))))))
8967 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8968 (insert-buffer-substring gnus-original-article-buffer)
8969 ;; Remove lines that may lead nndoc to misinterpret the
8970 ;; document type.
8971 (narrow-to-region
8972 (goto-char (point-min))
8973 (or (search-forward "\n\n" nil t) (point)))
8974 (goto-char (point-min))
8975 (delete-matching-lines "^Path:\\|^From ")
8976 (widen))
8977 (unwind-protect
8978 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8979 (gnus-newsgroup-ephemeral-ignored-charsets
8980 gnus-newsgroup-ignored-charsets))
8981 (gnus-group-read-ephemeral-group
8982 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8983 (nndoc-article-type
8984 ,(if force 'mbox 'guess)))
8985 t nil nil nil
8986 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8987 "ADAPT")))))
8988 ;; Make all postings to this group go to the parent group.
8989 (nconc (gnus-info-params (gnus-get-info name))
8990 params)
8991 ;; Couldn't select this doc group.
8992 (switch-to-buffer buf)
8993 (gnus-set-global-variables)
8994 (gnus-configure-windows 'summary)
8995 (gnus-message 3 "Article couldn't be entered?"))
8996 (kill-buffer dig)))))
8998 (defun gnus-summary-read-document (n)
8999 "Open a new group based on the current article(s).
9000 This will allow you to read digests and other similar
9001 documents as newsgroups.
9002 Obeys the standard process/prefix convention."
9003 (interactive "P")
9004 (let* ((ogroup gnus-newsgroup-name)
9005 (params (append (gnus-info-params (gnus-get-info ogroup))
9006 (list (cons 'to-group ogroup))))
9007 group egroup groups vgroup)
9008 (dolist (article (gnus-summary-work-articles n))
9009 (setq group (format "%s-%d" gnus-newsgroup-name article))
9010 (gnus-summary-remove-process-mark article)
9011 (when (gnus-summary-display-article article)
9012 (save-excursion ;;What for?
9013 (with-temp-buffer
9014 (insert-buffer-substring gnus-original-article-buffer)
9015 ;; Remove some headers that may lead nndoc to make
9016 ;; the wrong guess.
9017 (message-narrow-to-head)
9018 (goto-char (point-min))
9019 (delete-matching-lines "^Path:\\|^From ")
9020 (widen)
9021 (if (setq egroup
9022 (gnus-group-read-ephemeral-group
9023 group `(nndoc ,group (nndoc-address ,(current-buffer))
9024 (nndoc-article-type guess))
9025 t nil t))
9026 (progn
9027 ;; Make all postings to this group go to the parent group.
9028 (nconc (gnus-info-params (gnus-get-info egroup))
9029 params)
9030 (push egroup groups))
9031 ;; Couldn't select this doc group.
9032 (gnus-error 3 "Article couldn't be entered"))))))
9033 ;; Now we have selected all the documents.
9034 (cond
9035 ((not groups)
9036 (error "None of the articles could be interpreted as documents"))
9037 ((gnus-group-read-ephemeral-group
9038 (setq vgroup (format
9039 "nnvirtual:%s-%s" gnus-newsgroup-name
9040 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9041 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9043 (cons (current-buffer) 'summary)))
9045 (error "Couldn't select virtual nndoc group")))))
9047 (defun gnus-summary-isearch-article (&optional regexp-p)
9048 "Do incremental search forward on the current article.
9049 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9050 (interactive "P")
9051 (gnus-summary-select-article)
9052 (gnus-configure-windows 'article)
9053 (gnus-eval-in-buffer-window gnus-article-buffer
9054 (save-restriction
9055 (widen)
9056 (isearch-forward regexp-p))))
9058 (defun gnus-summary-repeat-search-article-forward ()
9059 "Repeat the previous search forwards."
9060 (interactive)
9061 (unless gnus-last-search-regexp
9062 (error "No previous search"))
9063 (gnus-summary-search-article-forward gnus-last-search-regexp))
9065 (defun gnus-summary-repeat-search-article-backward ()
9066 "Repeat the previous search backwards."
9067 (interactive)
9068 (unless gnus-last-search-regexp
9069 (error "No previous search"))
9070 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9072 (defun gnus-summary-search-article-forward (regexp &optional backward)
9073 "Search for an article containing REGEXP forward.
9074 If BACKWARD, search backward instead."
9075 (interactive
9076 (list (read-string
9077 (format "Search article %s (regexp%s): "
9078 (if current-prefix-arg "backward" "forward")
9079 (if gnus-last-search-regexp
9080 (concat ", default " gnus-last-search-regexp)
9081 "")))
9082 current-prefix-arg))
9083 (if (string-equal regexp "")
9084 (setq regexp (or gnus-last-search-regexp ""))
9085 (setq gnus-last-search-regexp regexp)
9086 (setq gnus-article-before-search gnus-current-article))
9087 ;; Intentionally set gnus-last-article.
9088 (setq gnus-last-article gnus-article-before-search)
9089 (let ((gnus-last-article gnus-last-article))
9090 (if (gnus-summary-search-article regexp backward)
9091 (gnus-summary-show-thread)
9092 (signal 'search-failed (list regexp)))))
9094 (defun gnus-summary-search-article-backward (regexp)
9095 "Search for an article containing REGEXP backward."
9096 (interactive
9097 (list (read-string
9098 (format "Search article backward (regexp%s): "
9099 (if gnus-last-search-regexp
9100 (concat ", default " gnus-last-search-regexp)
9101 "")))))
9102 (gnus-summary-search-article-forward regexp 'backward))
9104 (defun gnus-summary-search-article (regexp &optional backward)
9105 "Search for an article containing REGEXP.
9106 Optional argument BACKWARD means do search for backward.
9107 `gnus-select-article-hook' is not called during the search."
9108 ;; We have to require this here to make sure that the following
9109 ;; dynamic binding isn't shadowed by autoloading.
9110 (require 'gnus-async)
9111 (require 'gnus-art)
9112 (let ((gnus-select-article-hook nil) ;Disable hook.
9113 (gnus-article-prepare-hook nil)
9114 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9115 (gnus-use-article-prefetch nil)
9116 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9117 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9118 (gnus-visual nil)
9119 (gnus-keep-backlog nil)
9120 (gnus-break-pages nil)
9121 (gnus-summary-display-arrow nil)
9122 (gnus-updated-mode-lines nil)
9123 (gnus-auto-center-summary nil)
9124 (sum (current-buffer))
9125 (gnus-display-mime-function nil)
9126 (found nil)
9127 point)
9128 (gnus-save-hidden-threads
9129 (gnus-summary-select-article)
9130 (set-buffer gnus-article-buffer)
9131 (goto-char (window-point (get-buffer-window (current-buffer))))
9132 (when backward
9133 (forward-line -1))
9134 (while (not found)
9135 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9136 (if (if backward
9137 (re-search-backward regexp nil t)
9138 (re-search-forward regexp nil t))
9139 ;; We found the regexp.
9140 (progn
9141 (setq found 'found)
9142 (beginning-of-line)
9143 (set-window-start
9144 (get-buffer-window (current-buffer))
9145 (point))
9146 (forward-line 1)
9147 (set-window-point
9148 (get-buffer-window (current-buffer))
9149 (point))
9150 (set-buffer sum)
9151 (setq point (point)))
9152 ;; We didn't find it, so we go to the next article.
9153 (set-buffer sum)
9154 (setq found 'not)
9155 (while (eq found 'not)
9156 (if (not (if backward (gnus-summary-find-prev)
9157 (gnus-summary-find-next)))
9158 ;; No more articles.
9159 (setq found t)
9160 ;; Select the next article and adjust point.
9161 (unless (gnus-summary-article-sparse-p
9162 (gnus-summary-article-number))
9163 (setq found nil)
9164 (gnus-summary-select-article)
9165 (set-buffer gnus-article-buffer)
9166 (widen)
9167 (goto-char (if backward (point-max) (point-min))))))))
9168 (gnus-message 7 ""))
9169 ;; Return whether we found the regexp.
9170 (when (eq found 'found)
9171 (goto-char point)
9172 (gnus-summary-show-thread)
9173 (gnus-summary-goto-subject gnus-current-article)
9174 (gnus-summary-position-point)
9175 t)))
9177 (defun gnus-find-matching-articles (header regexp)
9178 "Return a list of all articles that match REGEXP on HEADER.
9179 This search includes all articles in the current group that Gnus has
9180 fetched headers for, whether they are displayed or not."
9181 (let ((articles nil)
9182 ;; Can't eta-reduce because it's a macro.
9183 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9184 (case-fold-search t))
9185 (dolist (header gnus-newsgroup-headers)
9186 (when (string-match regexp (funcall func header))
9187 (push (mail-header-number header) articles)))
9188 (nreverse articles)))
9190 (defun gnus-summary-find-matching (header regexp &optional backward unread
9191 not-case-fold not-matching)
9192 "Return a list of all articles that match REGEXP on HEADER.
9193 The search stars on the current article and goes forwards unless
9194 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9195 If UNREAD is non-nil, only unread articles will
9196 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9197 in the comparisons. If NOT-MATCHING, return a list of all articles that
9198 not match REGEXP on HEADER."
9199 (let ((case-fold-search (not not-case-fold))
9200 articles d func)
9201 (if (consp header)
9202 (if (eq (car header) 'extra)
9203 (setq func
9204 `(lambda (h)
9205 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9206 "")))
9207 (error "%s is an invalid header" header))
9208 (unless (fboundp (intern (concat "mail-header-" header)))
9209 (error "%s is not a valid header" header))
9210 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9211 (dolist (d (if (eq backward 'all)
9212 gnus-newsgroup-data
9213 (gnus-data-find-list
9214 (gnus-summary-article-number)
9215 (gnus-data-list backward))))
9216 (when (and (or (not unread) ; We want all articles...
9217 (gnus-data-unread-p d)) ; Or just unreads.
9218 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9219 (if not-matching
9220 (not (string-match
9221 regexp
9222 (funcall func (gnus-data-header d))))
9223 (string-match regexp
9224 (funcall func (gnus-data-header d)))))
9225 (push (gnus-data-number d) articles))) ; Success!
9226 (nreverse articles)))
9228 (defun gnus-summary-execute-command (header regexp command &optional backward)
9229 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9230 If HEADER is an empty string (or nil), the match is done on the entire
9231 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9232 (interactive
9233 (list (let ((completion-ignore-case t))
9234 (gnus-completing-read
9235 "Header name"
9236 (mapcar 'symbol-name
9237 (append
9238 '(Number Subject From Lines Date
9239 Message-ID Xref References Body)
9240 gnus-extra-headers))
9241 'require-match))
9242 (read-string "Regexp: ")
9243 (read-key-sequence "Command: ")
9244 current-prefix-arg))
9245 (when (equal header "Body")
9246 (setq header ""))
9247 ;; Hidden thread subtrees must be searched as well.
9248 (gnus-summary-show-all-threads)
9249 ;; We don't want to change current point nor window configuration.
9250 (save-excursion
9251 (save-window-excursion
9252 (let (gnus-visual
9253 gnus-treat-strip-trailing-blank-lines
9254 gnus-treat-strip-leading-blank-lines
9255 gnus-treat-strip-multiple-blank-lines
9256 gnus-treat-hide-boring-headers
9257 gnus-treat-fold-newsgroups
9258 gnus-article-prepare-hook)
9259 (gnus-message 6 "Executing %s..." (key-description command))
9260 ;; We'd like to execute COMMAND interactively so as to give arguments.
9261 (gnus-execute header regexp
9262 `(call-interactively ',(key-binding command))
9263 backward)
9264 (gnus-message 6 "Executing %s...done" (key-description command))))))
9266 (defun gnus-summary-beginning-of-article ()
9267 "Scroll the article back to the beginning."
9268 (interactive)
9269 (gnus-summary-select-article)
9270 (gnus-configure-windows 'article)
9271 (gnus-eval-in-buffer-window gnus-article-buffer
9272 (widen)
9273 (goto-char (point-min))
9274 (when gnus-break-pages
9275 (gnus-narrow-to-page))))
9277 (defun gnus-summary-end-of-article ()
9278 "Scroll to the end of the article."
9279 (interactive)
9280 (gnus-summary-select-article)
9281 (gnus-configure-windows 'article)
9282 (gnus-eval-in-buffer-window gnus-article-buffer
9283 (widen)
9284 (goto-char (point-max))
9285 (recenter -3)
9286 (when gnus-break-pages
9287 (gnus-narrow-to-page))))
9289 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9290 "Truncate to LEN and quote all \"(\"'s in STRING."
9291 (gnus-replace-in-string (if (and len (> (length string) len))
9292 (substring string 0 len)
9293 string)
9294 "[()]" "\\\\\\&"))
9296 (defun gnus-summary-print-article (&optional filename n)
9297 "Generate and print a PostScript image of the process-marked (mail) articles.
9299 If used interactively, print the current article if none are
9300 process-marked. With prefix arg, prompt the user for the name of the
9301 file to save in.
9303 When used from Lisp, accept two optional args FILENAME and N. N means
9304 to print the next N articles. If N is negative, print the N previous
9305 articles. If N is nil and articles have been marked with the process
9306 mark, print these instead.
9308 If the optional first argument FILENAME is nil, send the image to the
9309 printer. If FILENAME is a string, save the PostScript image in a file with
9310 that name. If FILENAME is a number, prompt the user for the name of the file
9311 to save in."
9312 (interactive (list (ps-print-preprint current-prefix-arg)))
9313 (dolist (article (gnus-summary-work-articles n))
9314 (gnus-summary-select-article nil nil 'pseudo article)
9315 (gnus-eval-in-buffer-window gnus-article-buffer
9316 (gnus-print-buffer))
9317 (gnus-summary-remove-process-mark article))
9318 (ps-despool filename))
9320 (defun gnus-print-buffer ()
9321 (let ((buffer (generate-new-buffer " *print*")))
9322 (unwind-protect
9323 (progn
9324 (copy-to-buffer buffer (point-min) (point-max))
9325 (set-buffer buffer)
9326 (gnus-remove-text-with-property 'gnus-decoration)
9327 (when (gnus-visual-p 'article-highlight 'highlight)
9328 ;; Copy-to-buffer doesn't copy overlay. So redo
9329 ;; highlight.
9330 (let ((gnus-article-buffer buffer))
9331 (gnus-article-highlight-citation t)
9332 (gnus-article-highlight-signature)
9333 (gnus-article-emphasize)
9334 (gnus-article-delete-invisible-text)))
9335 (let ((ps-left-header
9336 (list
9337 (concat "("
9338 (gnus-summary-print-truncate-and-quote
9339 (mail-header-subject gnus-current-headers)
9340 66) ")")
9341 (concat "("
9342 (gnus-summary-print-truncate-and-quote
9343 (mail-header-from gnus-current-headers)
9344 45) ")")))
9345 (ps-right-header
9346 (list
9347 "/pagenumberstring load"
9348 (concat "("
9349 (mail-header-date gnus-current-headers) ")"))))
9350 (gnus-run-hooks 'gnus-ps-print-hook)
9351 (save-excursion
9352 (if ps-print-color-p
9353 (ps-spool-buffer-with-faces)
9354 (ps-spool-buffer)))))
9355 (kill-buffer buffer))))
9357 (defun gnus-summary-show-complete-article ()
9358 "Show a complete version of the current article.
9359 This is only useful if you're looking at a partial version of the
9360 article currently."
9361 (interactive)
9362 (let ((gnus-keep-backlog nil)
9363 (gnus-use-cache nil)
9364 (gnus-agent nil)
9365 (variable (intern
9366 (format "%s-fetch-partial-articles"
9367 (car (gnus-find-method-for-group
9368 gnus-newsgroup-name)))
9369 obarray))
9370 old-val)
9371 (unwind-protect
9372 (progn
9373 (setq old-val (symbol-value variable))
9374 (set variable nil)
9375 (gnus-flush-original-article-buffer)
9376 (gnus-summary-show-article))
9377 (set variable old-val))))
9379 (defun gnus-summary-show-article (&optional arg)
9380 "Force redisplaying of the current article.
9381 If ARG (the prefix) is a number, show the article with the charset
9382 defined in `gnus-summary-show-article-charset-alist', or the charset
9383 input.
9384 If ARG (the prefix) is non-nil and not a number, show the raw article
9385 without any article massaging functions being run. Normally, the key
9386 strokes are `C-u g'."
9387 (interactive "P")
9388 (cond
9389 ((numberp arg)
9390 (gnus-summary-show-article t)
9391 (let ((gnus-newsgroup-charset
9392 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9393 (mm-read-coding-system
9394 "View as charset: " ;; actually it is coding system.
9395 (with-current-buffer gnus-article-buffer
9396 (mm-detect-coding-region (point) (point-max))))))
9397 (gnus-newsgroup-ignored-charsets 'gnus-all))
9398 (gnus-summary-select-article nil 'force)
9399 (let ((deps gnus-newsgroup-dependencies)
9400 head header lines)
9401 (with-current-buffer gnus-original-article-buffer
9402 (save-restriction
9403 (message-narrow-to-head)
9404 (setq head (buffer-string))
9405 (goto-char (point-min))
9406 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9407 (goto-char (point-max))
9408 (widen)
9409 (setq lines (1- (count-lines (point) (point-max))))))
9410 (with-temp-buffer
9411 (insert (format "211 %d Article retrieved.\n"
9412 (cdr gnus-article-current)))
9413 (insert head)
9414 (if lines (insert (format "Lines: %d\n" lines)))
9415 (insert ".\n")
9416 (let ((nntp-server-buffer (current-buffer)))
9417 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9418 (gnus-data-set-header
9419 (gnus-data-find (cdr gnus-article-current))
9420 header)
9421 (gnus-summary-update-article-line
9422 (cdr gnus-article-current) header)
9423 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9424 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9425 ((not arg)
9426 ;; Select the article the normal way.
9427 (gnus-summary-select-article nil 'force))
9429 ;; We have to require this here to make sure that the following
9430 ;; dynamic binding isn't shadowed by autoloading.
9431 (require 'gnus-async)
9432 (require 'gnus-art)
9433 ;; Bind the article treatment functions to nil.
9434 (let ((gnus-have-all-headers t)
9435 gnus-article-prepare-hook
9436 gnus-article-decode-hook
9437 gnus-display-mime-function
9438 gnus-break-pages)
9439 ;; Destroy any MIME parts.
9440 (when (gnus-buffer-live-p gnus-article-buffer)
9441 (with-current-buffer gnus-article-buffer
9442 (mm-destroy-parts gnus-article-mime-handles)
9443 ;; Set it to nil for safety reason.
9444 (setq gnus-article-mime-handle-alist nil)
9445 (setq gnus-article-mime-handles nil)))
9446 (gnus-summary-select-article nil 'force))))
9447 (gnus-summary-goto-subject gnus-current-article)
9448 (gnus-summary-position-point))
9450 (defun gnus-summary-show-raw-article ()
9451 "Show the raw article without any article massaging functions being run."
9452 (interactive)
9453 (gnus-summary-show-article t))
9455 (defun gnus-summary-verbose-headers (&optional arg)
9456 "Toggle permanent full header display.
9457 If ARG is a positive number, turn header display on.
9458 If ARG is a negative number, turn header display off."
9459 (interactive "P")
9460 (setq gnus-show-all-headers
9461 (cond ((or (not (numberp arg))
9462 (zerop arg))
9463 (not gnus-show-all-headers))
9464 ((natnump arg)
9465 t)))
9466 (gnus-summary-show-article))
9468 (defun gnus-summary-toggle-header (&optional arg)
9469 "Show the headers if they are hidden, or hide them if they are shown.
9470 If ARG is a positive number, show the entire header.
9471 If ARG is a negative number, hide the unwanted header lines."
9472 (interactive "P")
9473 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9474 (get-buffer-window gnus-article-buffer t))))
9475 (with-current-buffer gnus-article-buffer
9476 (widen)
9477 (article-narrow-to-head)
9478 (let* ((inhibit-read-only t)
9479 (inhibit-point-motion-hooks t)
9480 (hidden (if (numberp arg)
9481 (>= arg 0)
9482 (or (not (looking-at "[^ \t\n]+:"))
9483 (gnus-article-hidden-text-p 'headers))))
9484 s e)
9485 (delete-region (point-min) (point-max))
9486 (with-current-buffer gnus-original-article-buffer
9487 (goto-char (setq s (point-min)))
9488 (setq e (if (search-forward "\n\n" nil t)
9489 (1- (point))
9490 (point-max))))
9491 (insert-buffer-substring gnus-original-article-buffer s e)
9492 (run-hooks 'gnus-article-decode-hook)
9493 (if hidden
9494 (let ((gnus-treat-hide-headers nil)
9495 (gnus-treat-hide-boring-headers nil))
9496 (gnus-delete-wash-type 'headers)
9497 (gnus-treat-article 'head))
9498 (gnus-treat-article 'head))
9499 (widen)
9500 (if window
9501 (set-window-start window (goto-char (point-min))))
9502 (if gnus-break-pages
9503 (gnus-narrow-to-page)
9504 (when (gnus-visual-p 'page-marker)
9505 (let ((inhibit-read-only t))
9506 (gnus-remove-text-with-property 'gnus-prev)
9507 (gnus-remove-text-with-property 'gnus-next))))
9508 (gnus-set-mode-line 'article)))))
9510 (defun gnus-summary-show-all-headers ()
9511 "Make all header lines visible."
9512 (interactive)
9513 (gnus-summary-toggle-header 1))
9515 (defun gnus-summary-caesar-message (&optional arg)
9516 "Caesar rotate the current article by 13.
9517 With a non-numerical prefix, also rotate headers. A numerical
9518 prefix specifies how many places to rotate each letter forward."
9519 (interactive "P")
9520 (gnus-summary-select-article)
9521 (let ((mail-header-separator ""))
9522 (gnus-eval-in-buffer-window gnus-article-buffer
9523 (save-restriction
9524 (widen)
9525 (let ((start (window-start))
9526 (inhibit-read-only t))
9527 (if (equal arg '(4))
9528 (message-caesar-buffer-body nil t)
9529 (message-caesar-buffer-body arg))
9530 (set-window-start (get-buffer-window (current-buffer)) start)))))
9531 ;; Create buttons and stuff...
9532 (gnus-treat-article nil))
9534 (declare-function idna-to-unicode "ext:idna" (str))
9536 (defun gnus-summary-idna-message (&optional arg)
9537 "Decode IDNA encoded domain names in the current articles.
9538 IDNA encoded domain names looks like `xn--bar'. If a string
9539 remain unencoded after running this function, it is likely an
9540 invalid IDNA string (`xn--bar' is invalid).
9542 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9543 installed for this command to work."
9544 (interactive "P")
9545 (if (not (and (condition-case nil (require 'idna)
9546 (file-error))
9547 (mm-coding-system-p 'utf-8)
9548 (executable-find (symbol-value 'idna-program))))
9549 (gnus-message
9550 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9551 (gnus-summary-select-article)
9552 (let ((mail-header-separator ""))
9553 (gnus-eval-in-buffer-window gnus-article-buffer
9554 (save-restriction
9555 (widen)
9556 (let ((start (window-start))
9557 buffer-read-only)
9558 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9559 (replace-match (idna-to-unicode (match-string 1))))
9560 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9562 (defun gnus-summary-morse-message (&optional arg)
9563 "Morse decode the current article."
9564 (interactive "P")
9565 (gnus-summary-select-article)
9566 (let ((mail-header-separator ""))
9567 (gnus-eval-in-buffer-window gnus-article-buffer
9568 (save-excursion
9569 (save-restriction
9570 (widen)
9571 (let ((pos (window-start))
9572 (inhibit-read-only t))
9573 (goto-char (point-min))
9574 (when (message-goto-body)
9575 (gnus-narrow-to-body))
9576 (goto-char (point-min))
9577 (while (search-forward "·" (point-max) t)
9578 (replace-match "."))
9579 (unmorse-region (point-min) (point-max))
9580 (widen)
9581 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9583 (defun gnus-summary-stop-page-breaking ()
9584 "Stop page breaking in the current article."
9585 (interactive)
9586 (gnus-summary-select-article)
9587 (gnus-eval-in-buffer-window gnus-article-buffer
9588 (widen)
9589 (when (gnus-visual-p 'page-marker)
9590 (let ((inhibit-read-only t))
9591 (gnus-remove-text-with-property 'gnus-prev)
9592 (gnus-remove-text-with-property 'gnus-next))
9593 (setq gnus-page-broken nil))))
9595 (defun gnus-summary-move-article (&optional n to-newsgroup
9596 select-method action)
9597 "Move the current article to a different newsgroup.
9598 If N is a positive number, move the N next articles.
9599 If N is a negative number, move the N previous articles.
9600 If N is nil and any articles have been marked with the process mark,
9601 move those articles instead.
9602 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9603 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9604 re-spool using this method.
9606 When called interactively with TO-NEWSGROUP being nil, the value of
9607 the variable `gnus-move-split-methods' is used for finding a default
9608 for the target newsgroup.
9610 For this function to work, both the current newsgroup and the
9611 newsgroup that you want to move to have to support the `request-move'
9612 and `request-accept' functions.
9614 ACTION can be either `move' (the default), `crosspost' or `copy'."
9615 (interactive "P")
9616 (unless action
9617 (setq action 'move))
9618 ;; Check whether the source group supports the required functions.
9619 (cond ((and (eq action 'move)
9620 (not (gnus-check-backend-function
9621 'request-move-article gnus-newsgroup-name)))
9622 (error "The current group does not support article moving"))
9623 ((and (eq action 'crosspost)
9624 (not (gnus-check-backend-function
9625 'request-replace-article gnus-newsgroup-name)))
9626 (error "The current group does not support article editing")))
9627 (let ((articles (gnus-summary-work-articles n))
9628 (prefix (if (gnus-check-backend-function
9629 'request-move-article gnus-newsgroup-name)
9630 (funcall gnus-move-group-prefix-function
9631 gnus-newsgroup-name)
9632 ""))
9633 (names '((move "Move" "Moving")
9634 (copy "Copy" "Copying")
9635 (crosspost "Crosspost" "Crossposting")))
9636 (copy-buf (save-excursion
9637 (nnheader-set-temp-buffer " *copy article*")))
9638 art-group to-method new-xref article to-groups
9639 articles-to-update-marks encoded)
9640 (unless (assq action names)
9641 (error "Unknown action %s" action))
9642 ;; Read the newsgroup name.
9643 (when (and (not to-newsgroup)
9644 (not select-method))
9645 (if (and gnus-move-split-methods
9646 (not
9647 (and (memq gnus-current-article articles)
9648 (gnus-buffer-live-p gnus-original-article-buffer))))
9649 ;; When `gnus-move-split-methods' is non-nil, we have to
9650 ;; select an article to give `gnus-read-move-group-name' an
9651 ;; opportunity to suggest an appropriate default. However,
9652 ;; we needn't render or mark the article.
9653 (let ((gnus-display-mime-function nil)
9654 (gnus-article-prepare-hook nil)
9655 (gnus-mark-article-hook nil))
9656 (gnus-summary-select-article nil nil nil (car articles))))
9657 (setq to-newsgroup (gnus-read-move-group-name
9658 (cadr (assq action names))
9659 (symbol-value
9660 (intern (format "gnus-current-%s-group" action)))
9661 articles prefix)
9662 encoded to-newsgroup
9663 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9664 (set (intern (format "gnus-current-%s-group" action))
9665 (mm-decode-coding-string
9666 to-newsgroup
9667 (gnus-group-name-charset to-method to-newsgroup))))
9668 (unless to-method
9669 (setq to-method (or select-method
9670 (gnus-server-to-method
9671 (gnus-group-method to-newsgroup)))))
9672 (setq to-newsgroup
9673 (or encoded
9674 (and to-newsgroup
9675 (mm-encode-coding-string
9676 to-newsgroup
9677 (gnus-group-name-charset to-method to-newsgroup)))))
9678 ;; Check the method we are to move this article to...
9679 (unless (gnus-check-backend-function
9680 'request-accept-article (car to-method))
9681 (error "%s does not support article copying" (car to-method)))
9682 (unless (gnus-check-server to-method)
9683 (error "Can't open server %s" (car to-method)))
9684 (gnus-message 6 "%s to %s: %s..."
9685 (caddr (assq action names))
9686 (or (car select-method)
9687 (gnus-group-decoded-name to-newsgroup))
9688 articles)
9689 (while articles
9690 (setq article (pop articles))
9691 (setq
9692 art-group
9693 (cond
9694 ;; Move the article.
9695 ((eq action 'move)
9696 ;; Remove this article from future suppression.
9697 (gnus-dup-unsuppress-article article)
9698 (let* ((from-method (gnus-find-method-for-group
9699 gnus-newsgroup-name))
9700 (to-method (or select-method
9701 (gnus-find-method-for-group to-newsgroup)))
9702 (move-is-internal (gnus-server-equal from-method to-method)))
9703 (gnus-request-move-article
9704 article ; Article to move
9705 gnus-newsgroup-name ; From newsgroup
9706 (nth 1 (gnus-find-method-for-group
9707 gnus-newsgroup-name)) ; Server
9708 (list 'gnus-request-accept-article
9709 to-newsgroup (list 'quote select-method)
9710 (not articles) t) ; Accept form
9711 (not articles) ; Only save nov last time
9712 (and move-is-internal
9713 to-newsgroup ; Not respooling
9714 (gnus-group-real-name to-newsgroup))))) ; Is this move internal?
9715 ;; Copy the article.
9716 ((eq action 'copy)
9717 (with-current-buffer copy-buf
9718 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9719 (save-restriction
9720 (nnheader-narrow-to-headers)
9721 (dolist (hdr gnus-copy-article-ignored-headers)
9722 (message-remove-header hdr t)))
9723 (gnus-request-accept-article
9724 to-newsgroup select-method (not articles) t))))
9725 ;; Crosspost the article.
9726 ((eq action 'crosspost)
9727 (let ((xref (message-tokenize-header
9728 (mail-header-xref (gnus-summary-article-header article))
9729 " ")))
9730 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9731 ":" (number-to-string article)))
9732 (unless xref
9733 (setq xref (list (system-name))))
9734 (setq new-xref
9735 (concat
9736 (mapconcat 'identity
9737 (delete "Xref:" (delete new-xref xref))
9738 " ")
9739 " " new-xref))
9740 (with-current-buffer copy-buf
9741 ;; First put the article in the destination group.
9742 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9743 (when (consp (setq art-group
9744 (gnus-request-accept-article
9745 to-newsgroup select-method (not articles) t)))
9746 (setq new-xref (concat new-xref " " (car art-group)
9748 (number-to-string (cdr art-group))))
9749 ;; Now we have the new Xrefs header, so we insert
9750 ;; it and replace the new article.
9751 (nnheader-replace-header "Xref" new-xref)
9752 (gnus-request-replace-article
9753 (cdr art-group) to-newsgroup (current-buffer) t)
9754 art-group))))))
9755 (cond
9756 ((not art-group)
9757 (gnus-message 1 "Couldn't %s article %s: %s"
9758 (cadr (assq action names)) article
9759 (nnheader-get-report (car to-method))))
9760 ((eq art-group 'junk)
9761 (when (eq action 'move)
9762 (gnus-summary-mark-article article gnus-canceled-mark)
9763 (gnus-message 4 "Deleted article %s" article)
9764 ;; run the delete hook
9765 (run-hook-with-args 'gnus-summary-article-delete-hook
9766 action
9767 (gnus-data-header
9768 (assoc article (gnus-data-list nil)))
9769 gnus-newsgroup-name nil
9770 select-method)))
9772 (let* ((pto-group (gnus-group-prefixed-name
9773 (car art-group) to-method))
9774 (info (gnus-get-info pto-group))
9775 (to-group (gnus-info-group info))
9776 to-marks)
9777 ;; Update the group that has been moved to.
9778 (when (and info
9779 (memq action '(move copy)))
9780 (unless (member to-group to-groups)
9781 (push to-group to-groups))
9783 (unless (memq article gnus-newsgroup-unreads)
9784 (push 'read to-marks)
9785 (gnus-info-set-read
9786 info (gnus-add-to-range (gnus-info-read info)
9787 (list (cdr art-group)))))
9789 ;; See whether the article is to be put in the cache.
9790 (let* ((expirable (gnus-group-auto-expirable-p to-group))
9791 (marks (if expirable
9792 gnus-article-mark-lists
9793 (delete '(expirable . expire)
9794 (copy-sequence gnus-article-mark-lists))))
9795 (to-article (cdr art-group)))
9797 ;; Enter the article into the cache in the new group,
9798 ;; if that is required.
9799 (when gnus-use-cache
9800 (gnus-cache-possibly-enter-article
9801 to-group to-article
9802 (memq article gnus-newsgroup-marked)
9803 (memq article gnus-newsgroup-dormant)
9804 (memq article gnus-newsgroup-unreads)))
9806 (when gnus-preserve-marks
9807 ;; Copy any marks over to the new group.
9808 (when (and (equal to-group gnus-newsgroup-name)
9809 (not (memq article gnus-newsgroup-unreads)))
9810 ;; Mark this article as read in this group.
9811 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9812 ;; Increase the active status of this group.
9813 (setcdr (gnus-active to-group) to-article)
9814 (setcdr gnus-newsgroup-active to-article))
9816 (while marks
9817 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9818 (when (memq article (symbol-value
9819 (intern (format "gnus-newsgroup-%s"
9820 (caar marks)))))
9821 (push (cdar marks) to-marks)
9822 ;; If the other group is the same as this group,
9823 ;; then we have to add the mark to the list.
9824 (when (equal to-group gnus-newsgroup-name)
9825 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9826 (cons to-article
9827 (symbol-value
9828 (intern (format "gnus-newsgroup-%s"
9829 (caar marks)))))))
9830 ;; Copy the marks to other group.
9831 (gnus-add-marked-articles
9832 to-group (cdar marks) (list to-article) info)))
9833 (setq marks (cdr marks)))
9835 (when (and expirable
9836 gnus-mark-copied-or-moved-articles-as-expirable
9837 (not (memq 'expire to-marks)))
9838 ;; Mark this article as expirable.
9839 (push 'expire to-marks)
9840 (when (equal to-group gnus-newsgroup-name)
9841 (push to-article gnus-newsgroup-expirable))
9842 ;; Copy the expirable mark to other group.
9843 (gnus-add-marked-articles
9844 to-group 'expire (list to-article) info))
9846 (when to-marks
9847 (gnus-request-set-mark
9848 to-group (list (list (list to-article) 'add to-marks)))))
9850 (gnus-dribble-enter
9851 (concat "(gnus-group-set-info '"
9852 (gnus-prin1-to-string (gnus-get-info to-group))
9853 ")"))))
9855 ;; Update the Xref header in this article to point to
9856 ;; the new crossposted article we have just created.
9857 (when (eq action 'crosspost)
9858 (with-current-buffer copy-buf
9859 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9860 (nnheader-replace-header "Xref" new-xref)
9861 (gnus-request-replace-article
9862 article gnus-newsgroup-name (current-buffer) t)))
9864 ;; run the move/copy/crosspost/respool hook
9865 (run-hook-with-args 'gnus-summary-article-move-hook
9866 action
9867 (gnus-data-header
9868 (assoc article (gnus-data-list nil)))
9869 gnus-newsgroup-name
9870 to-newsgroup
9871 select-method))
9873 ;;;!!!Why is this necessary?
9874 (set-buffer gnus-summary-buffer)
9876 (when (eq action 'move)
9877 (save-excursion
9878 (gnus-summary-goto-subject article)
9879 (gnus-summary-mark-article article gnus-canceled-mark)))))
9880 (push article articles-to-update-marks))
9882 (save-excursion
9883 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
9884 ;; Re-activate all groups that have been moved to.
9885 (with-current-buffer gnus-group-buffer
9886 (let ((gnus-group-marked to-groups))
9887 (gnus-group-get-new-news-this-group nil t)))
9889 (gnus-kill-buffer copy-buf)
9890 (gnus-summary-position-point)
9891 (gnus-set-mode-line 'summary)))
9893 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9894 "Copy the current article to some other group.
9895 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9896 When called interactively, if TO-NEWSGROUP is nil, use the value of
9897 the variable `gnus-move-split-methods' for finding a default target
9898 newsgroup.
9899 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9900 re-spool using this method."
9901 (interactive "P")
9902 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9904 (defun gnus-summary-crosspost-article (&optional n)
9905 "Crosspost the current article to some other group."
9906 (interactive "P")
9907 (gnus-summary-move-article n nil nil 'crosspost))
9909 (defcustom gnus-summary-respool-default-method nil
9910 "Default method type for respooling an article.
9911 If nil, use to the current newsgroup method."
9912 :type 'symbol
9913 :group 'gnus-summary-mail)
9915 (defun gnus-summary-respool-article (&optional n method)
9916 "Respool the current article.
9917 The article will be squeezed through the mail spooling process again,
9918 which means that it will be put in some mail newsgroup or other
9919 depending on `nnmail-split-methods'.
9920 If N is a positive number, respool the N next articles.
9921 If N is a negative number, respool the N previous articles.
9922 If N is nil and any articles have been marked with the process mark,
9923 respool those articles instead.
9925 Respooling can be done both from mail groups and \"real\" newsgroups.
9926 In the former case, the articles in question will be moved from the
9927 current group into whatever groups they are destined to. In the
9928 latter case, they will be copied into the relevant groups."
9929 (interactive
9930 (list current-prefix-arg
9931 (let* ((methods (gnus-methods-using 'respool))
9932 (methname
9933 (symbol-name (or gnus-summary-respool-default-method
9934 (car (gnus-find-method-for-group
9935 gnus-newsgroup-name)))))
9936 (method
9937 (gnus-completing-read
9938 "Backend to use when respooling"
9939 methods t nil 'gnus-mail-method-history methname))
9941 (cond
9942 ((zerop (length (setq ms (gnus-servers-using-backend
9943 (intern method)))))
9944 (list (intern method) ""))
9945 ((= 1 (length ms))
9946 (car ms))
9948 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9949 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
9950 ms-alist))))))))
9951 (unless method
9952 (error "No method given for respooling"))
9953 (if (assoc (symbol-name
9954 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9955 (gnus-methods-using 'respool))
9956 (gnus-summary-move-article n nil method)
9957 (gnus-summary-copy-article n nil method)))
9959 (defun gnus-summary-import-article (file &optional edit)
9960 "Import an arbitrary file into a mail newsgroup."
9961 (interactive "fImport file: \nP")
9962 (let ((group gnus-newsgroup-name)
9963 (now (current-time))
9964 atts lines group-art)
9965 (unless (gnus-check-backend-function 'request-accept-article group)
9966 (error "%s does not support article importing" group))
9967 (or (file-readable-p file)
9968 (not (file-regular-p file))
9969 (error "Can't read %s" file))
9970 (with-current-buffer (gnus-get-buffer-create " *import file*")
9971 (erase-buffer)
9972 (nnheader-insert-file-contents file)
9973 (goto-char (point-min))
9974 (if (nnheader-article-p)
9975 (save-restriction
9976 (goto-char (point-min))
9977 (search-forward "\n\n" nil t)
9978 (narrow-to-region (point-min) (1- (point)))
9979 (goto-char (point-min))
9980 (unless (re-search-forward "^date:" nil t)
9981 (goto-char (point-max))
9982 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9983 ;; This doesn't look like an article, so we fudge some headers.
9984 (setq atts (file-attributes file)
9985 lines (count-lines (point-min) (point-max)))
9986 (insert "From: " (read-string "From: ") "\n"
9987 "Subject: " (read-string "Subject: ") "\n"
9988 "Date: " (message-make-date (nth 5 atts)) "\n"
9989 "Message-ID: " (message-make-message-id) "\n"
9990 "Lines: " (int-to-string lines) "\n"
9991 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9992 (setq group-art (gnus-request-accept-article group nil t))
9993 (kill-buffer (current-buffer)))
9994 (setq gnus-newsgroup-active (gnus-activate-group group))
9995 (forward-line 1)
9996 (gnus-summary-goto-article (cdr group-art) nil t)
9997 (when edit
9998 (gnus-summary-edit-article))))
10000 (defun gnus-summary-create-article ()
10001 "Create an article in a mail newsgroup."
10002 (interactive)
10003 (let ((group gnus-newsgroup-name)
10004 (now (current-time))
10005 group-art)
10006 (unless (gnus-check-backend-function 'request-accept-article group)
10007 (error "%s does not support article importing" group))
10008 (with-current-buffer (gnus-get-buffer-create " *import file*")
10009 (erase-buffer)
10010 (goto-char (point-min))
10011 ;; This doesn't look like an article, so we fudge some headers.
10012 (insert "From: " (read-string "From: ") "\n"
10013 "Subject: " (read-string "Subject: ") "\n"
10014 "Date: " (message-make-date now) "\n"
10015 "Message-ID: " (message-make-message-id) "\n")
10016 (setq group-art (gnus-request-accept-article group nil t))
10017 (kill-buffer (current-buffer)))
10018 (setq gnus-newsgroup-active (gnus-activate-group group))
10019 (forward-line 1)
10020 (gnus-summary-goto-article (cdr group-art) nil t)
10021 (gnus-summary-edit-article)))
10023 (defun gnus-summary-article-posted-p ()
10024 "Say whether the current (mail) article is available from news as well.
10025 This will be the case if the article has both been mailed and posted."
10026 (interactive)
10027 (let ((id (mail-header-references (gnus-summary-article-header)))
10028 (gnus-override-method (car (gnus-refer-article-methods))))
10029 (if (gnus-request-head id "")
10030 (gnus-message 2 "The current message was found on %s"
10031 gnus-override-method)
10032 (gnus-message 2 "The current message couldn't be found on %s"
10033 gnus-override-method)
10034 nil)))
10036 (defun gnus-summary-expire-articles (&optional now)
10037 "Expire all articles that are marked as expirable in the current group."
10038 (interactive)
10039 (when (and (not gnus-group-is-exiting-without-update-p)
10040 (gnus-check-backend-function
10041 'request-expire-articles gnus-newsgroup-name))
10042 ;; This backend supports expiry.
10043 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10044 (expirable (if total
10045 (progn
10046 ;; We need to update the info for
10047 ;; this group for `gnus-list-of-read-articles'
10048 ;; to give us the right answer.
10049 (gnus-run-hooks 'gnus-exit-group-hook)
10050 (gnus-summary-update-info)
10051 (gnus-list-of-read-articles gnus-newsgroup-name))
10052 (setq gnus-newsgroup-expirable
10053 (sort gnus-newsgroup-expirable '<))))
10054 (expiry-wait (if now 'immediate
10055 (gnus-group-find-parameter
10056 gnus-newsgroup-name 'expiry-wait)))
10057 (nnmail-expiry-target
10058 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10059 nnmail-expiry-target))
10061 (when expirable
10062 ;; There are expirable articles in this group, so we run them
10063 ;; through the expiry process.
10064 (gnus-message 6 "Expiring articles...")
10065 (unless (gnus-check-group gnus-newsgroup-name)
10066 (error "Can't open server for %s" gnus-newsgroup-name))
10067 ;; The list of articles that weren't expired is returned.
10068 (save-excursion
10069 (if expiry-wait
10070 (let ((nnmail-expiry-wait-function nil)
10071 (nnmail-expiry-wait expiry-wait))
10072 (setq es (gnus-request-expire-articles
10073 expirable gnus-newsgroup-name)))
10074 (setq es (gnus-request-expire-articles
10075 expirable gnus-newsgroup-name)))
10076 (unless total
10077 (setq gnus-newsgroup-expirable es))
10078 ;; We go through the old list of expirable, and mark all
10079 ;; really expired articles as nonexistent.
10080 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10081 (let ((gnus-use-cache nil))
10082 (dolist (article expirable)
10083 (when (and (not (memq article es))
10084 (gnus-data-find article))
10085 (gnus-summary-mark-article article gnus-canceled-mark)
10086 (run-hook-with-args 'gnus-summary-article-expire-hook
10087 'delete
10088 (gnus-data-header
10089 (assoc article (gnus-data-list nil)))
10090 gnus-newsgroup-name
10092 nil))))))
10093 (gnus-message 6 "Expiring articles...done")))))
10095 (defun gnus-summary-expire-articles-now ()
10096 "Expunge all expirable articles in the current group.
10097 This means that *all* articles that are marked as expirable will be
10098 deleted forever, right now."
10099 (interactive)
10100 (or gnus-expert-user
10101 (gnus-yes-or-no-p
10102 "Are you really, really sure you want to delete all expirable messages? ")
10103 (error "Phew!"))
10104 (gnus-summary-expire-articles t))
10106 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10107 (defun gnus-summary-delete-article (&optional n)
10108 "Delete the N next (mail) articles.
10109 This command actually deletes articles. This is not a marking
10110 command. The article will disappear forever from your life, never to
10111 return.
10113 If N is negative, delete backwards.
10114 If N is nil and articles have been marked with the process mark,
10115 delete these instead.
10117 If `gnus-novice-user' is non-nil you will be asked for
10118 confirmation before the articles are deleted."
10119 (interactive "P")
10120 (unless (gnus-check-backend-function 'request-expire-articles
10121 gnus-newsgroup-name)
10122 (error "The current newsgroup does not support article deletion"))
10123 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10124 (error "Couldn't open server"))
10125 ;; Compute the list of articles to delete.
10126 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10127 (nnmail-expiry-target 'delete)
10128 not-deleted)
10129 (if (and gnus-novice-user
10130 (not (gnus-yes-or-no-p
10131 (format "Do you really want to delete %s forever? "
10132 (if (> (length articles) 1)
10133 (format "these %s articles" (length articles))
10134 "this article")))))
10136 ;; Delete the articles.
10137 (setq not-deleted (gnus-request-expire-articles
10138 articles gnus-newsgroup-name 'force))
10139 (save-excursion
10140 (while articles
10141 (gnus-summary-remove-process-mark (car articles))
10142 ;; The backend might not have been able to delete the article
10143 ;; after all.
10144 (unless (memq (car articles) not-deleted)
10145 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
10146 (let* ((article (car articles))
10147 (ghead (gnus-data-header
10148 (assoc article (gnus-data-list nil)))))
10149 (run-hook-with-args 'gnus-summary-article-delete-hook
10150 'delete ghead gnus-newsgroup-name nil
10151 nil))
10152 (setq articles (cdr articles))))
10153 (when not-deleted
10154 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10155 (gnus-summary-position-point)
10156 (gnus-set-mode-line 'summary)
10157 not-deleted))
10159 (defun gnus-summary-edit-article (&optional arg)
10160 "Edit the current article.
10161 This will have permanent effect only in mail groups.
10162 If ARG is nil, edit the decoded articles.
10163 If ARG is 1, edit the raw articles.
10164 If ARG is 2, edit the raw articles even in read-only groups.
10165 If ARG is 3, edit the articles with the current handles.
10166 Otherwise, allow editing of articles even in read-only
10167 groups."
10168 (interactive "P")
10169 (let (force raw current-handles)
10170 (cond
10171 ((null arg))
10172 ((eq arg 1)
10173 (setq raw t))
10174 ((eq arg 2)
10175 (setq raw t
10176 force t))
10177 ((eq arg 3)
10178 (setq current-handles
10179 (and (gnus-buffer-live-p gnus-article-buffer)
10180 (with-current-buffer gnus-article-buffer
10181 (prog1
10182 gnus-article-mime-handles
10183 (setq gnus-article-mime-handles nil))))))
10185 (setq force t)))
10186 (when (and raw (not force)
10187 (member gnus-newsgroup-name '("nndraft:delayed"
10188 "nndraft:drafts"
10189 "nndraft:queue")))
10190 (error "Can't edit the raw article in group %s"
10191 gnus-newsgroup-name))
10192 (with-current-buffer gnus-summary-buffer
10193 (let ((mail-parse-charset gnus-newsgroup-charset)
10194 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10195 (gnus-set-global-variables)
10196 (when (and (not force)
10197 (gnus-group-read-only-p))
10198 (error "The current newsgroup does not support article editing"))
10199 (gnus-summary-show-article t)
10200 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10201 (with-current-buffer gnus-article-buffer
10202 (mm-enable-multibyte)))
10203 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10204 (setq raw t))
10205 (gnus-article-edit-article
10206 (if raw 'ignore
10207 `(lambda ()
10208 (let ((mbl mml-buffer-list))
10209 (setq mml-buffer-list nil)
10210 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10211 (mime-to-mml ,'current-handles))
10212 (let ((mbl1 mml-buffer-list))
10213 (setq mml-buffer-list mbl)
10214 (set (make-local-variable 'mml-buffer-list) mbl1))
10215 (gnus-make-local-hook 'kill-buffer-hook)
10216 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10217 `(lambda (no-highlight)
10218 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10219 (message-options message-options)
10220 (message-options-set-recipient)
10221 (mail-parse-ignored-charsets
10222 ',gnus-newsgroup-ignored-charsets)
10223 (rfc2047-header-encoding-alist
10224 ',(let ((charset (gnus-group-name-charset
10225 (gnus-find-method-for-group
10226 gnus-newsgroup-name)
10227 gnus-newsgroup-name)))
10228 (append (list (cons "Newsgroups" charset)
10229 (cons "Followup-To" charset)
10230 (cons "Xref" charset))
10231 rfc2047-header-encoding-alist))))
10232 ,(if (not raw) '(progn
10233 (mml-to-mime)
10234 (mml-destroy-buffers)
10235 (remove-hook 'kill-buffer-hook
10236 'mml-destroy-buffers t)
10237 (kill-local-variable 'mml-buffer-list)))
10238 (gnus-summary-edit-article-done
10239 ,(or (mail-header-references gnus-current-headers) "")
10240 ,(gnus-group-read-only-p)
10241 ,gnus-summary-buffer no-highlight))))))))
10243 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10245 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10246 no-highlight)
10247 "Make edits to the current article permanent."
10248 (interactive)
10249 (save-excursion
10250 ;; The buffer restriction contains the entire article if it exists.
10251 (when (article-goto-body)
10252 (let ((lines (count-lines (point) (point-max)))
10253 (length (- (point-max) (point)))
10254 (case-fold-search t)
10255 (body (copy-marker (point))))
10256 (goto-char (point-min))
10257 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10258 (delete-region (match-beginning 1) (match-end 1))
10259 (insert (number-to-string length)))
10260 (goto-char (point-min))
10261 (when (re-search-forward
10262 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10263 (delete-region (match-beginning 1) (match-end 1))
10264 (insert (number-to-string length)))
10265 (goto-char (point-min))
10266 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10267 (delete-region (match-beginning 1) (match-end 1))
10268 (insert (number-to-string lines))))))
10269 ;; Replace the article.
10270 (let ((buf (current-buffer)))
10271 (with-temp-buffer
10272 (insert-buffer-substring buf)
10274 (if (and (not read-only)
10275 (not (gnus-request-replace-article
10276 (cdr gnus-article-current) (car gnus-article-current)
10277 (current-buffer) t)))
10278 (error "Couldn't replace article")
10279 ;; Update the summary buffer.
10280 (if (and references
10281 (equal (message-tokenize-header references " ")
10282 (message-tokenize-header
10283 (or (message-fetch-field "references") "") " ")))
10284 ;; We only have to update this line.
10285 (save-excursion
10286 (save-restriction
10287 (message-narrow-to-head)
10288 (let ((head (buffer-substring-no-properties
10289 (point-min) (point-max)))
10290 header)
10291 (with-temp-buffer
10292 (insert (format "211 %d Article retrieved.\n"
10293 (cdr gnus-article-current)))
10294 (insert head)
10295 (insert ".\n")
10296 (let ((nntp-server-buffer (current-buffer)))
10297 (setq header (car (gnus-get-newsgroup-headers
10298 nil t))))
10299 (with-current-buffer gnus-summary-buffer
10300 (gnus-data-set-header
10301 (gnus-data-find (cdr gnus-article-current))
10302 header)
10303 (gnus-summary-update-article-line
10304 (cdr gnus-article-current) header)
10305 (if (gnus-summary-goto-subject
10306 (cdr gnus-article-current) nil t)
10307 (gnus-summary-update-secondary-mark
10308 (cdr gnus-article-current))))))))
10309 ;; Update threads.
10310 (set-buffer (or buffer gnus-summary-buffer))
10311 (gnus-summary-update-article (cdr gnus-article-current))
10312 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10313 (gnus-summary-update-secondary-mark
10314 (cdr gnus-article-current))))
10315 ;; Prettify the article buffer again.
10316 (unless no-highlight
10317 (with-current-buffer gnus-article-buffer
10318 ;;;!!! Fix this -- article should be rehighlighted.
10319 ;;;(gnus-run-hooks 'gnus-article-display-hook)
10320 (set-buffer gnus-original-article-buffer)
10321 (gnus-request-article
10322 (cdr gnus-article-current)
10323 (car gnus-article-current) (current-buffer))))
10324 ;; Prettify the summary buffer line.
10325 (when (gnus-visual-p 'summary-highlight 'highlight)
10326 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10328 (defun gnus-summary-edit-wash (key)
10329 "Perform editing command KEY in the article buffer."
10330 (interactive
10331 (list
10332 (progn
10333 (message "%s" (concat (this-command-keys) "- "))
10334 (read-char))))
10335 (message "")
10336 (gnus-summary-edit-article)
10337 (execute-kbd-macro (concat (this-command-keys) key))
10338 (gnus-article-edit-done))
10340 ;;; Respooling
10342 (defun gnus-summary-respool-query (&optional silent trace)
10343 "Query where the respool algorithm would put this article."
10344 (interactive)
10345 (let (gnus-mark-article-hook)
10346 (gnus-summary-select-article)
10347 (with-current-buffer gnus-original-article-buffer
10348 (let ((groups (nnmail-article-group 'identity trace)))
10349 (unless silent
10350 (if groups
10351 (message "This message would go to %s"
10352 (mapconcat 'car groups ", "))
10353 (message "This message would go to no groups"))
10354 groups)))))
10356 (defun gnus-summary-respool-trace ()
10357 "Trace where the respool algorithm would put this article.
10358 Display a buffer showing all fancy splitting patterns which matched."
10359 (interactive)
10360 (gnus-summary-respool-query nil t))
10362 ;; Summary marking commands.
10364 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10365 "Mark articles which has the same subject as read, and then select the next.
10366 If UNMARK is positive, remove any kind of mark.
10367 If UNMARK is negative, tick articles."
10368 (interactive "P")
10369 (when unmark
10370 (setq unmark (prefix-numeric-value unmark)))
10371 (let ((count
10372 (gnus-summary-mark-same-subject
10373 (gnus-summary-article-subject) unmark)))
10374 ;; Select next unread article. If auto-select-same mode, should
10375 ;; select the first unread article.
10376 (gnus-summary-next-article t (and gnus-auto-select-same
10377 (gnus-summary-article-subject)))
10378 (gnus-message 7 "%d article%s marked as %s"
10379 count (if (= count 1) " is" "s are")
10380 (if unmark "unread" "read"))))
10382 (defun gnus-summary-kill-same-subject (&optional unmark)
10383 "Mark articles which has the same subject as read.
10384 If UNMARK is positive, remove any kind of mark.
10385 If UNMARK is negative, tick articles."
10386 (interactive "P")
10387 (when unmark
10388 (setq unmark (prefix-numeric-value unmark)))
10389 (let ((count
10390 (gnus-summary-mark-same-subject
10391 (gnus-summary-article-subject) unmark)))
10392 ;; If marked as read, go to next unread subject.
10393 (when (null unmark)
10394 ;; Go to next unread subject.
10395 (gnus-summary-next-subject 1 t))
10396 (gnus-message 7 "%d articles are marked as %s"
10397 count (if unmark "unread" "read"))))
10399 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10400 "Mark articles with same SUBJECT as read, and return marked number.
10401 If optional argument UNMARK is positive, remove any kinds of marks.
10402 If optional argument UNMARK is negative, mark articles as unread instead."
10403 (let ((count 1))
10404 (save-excursion
10405 (cond
10406 ((null unmark) ; Mark as read.
10407 (while (and
10408 (progn
10409 (gnus-summary-mark-article-as-read gnus-killed-mark)
10410 (gnus-summary-show-thread) t)
10411 (gnus-summary-find-subject subject))
10412 (setq count (1+ count))))
10413 ((> unmark 0) ; Tick.
10414 (while (and
10415 (progn
10416 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10417 (gnus-summary-show-thread) t)
10418 (gnus-summary-find-subject subject))
10419 (setq count (1+ count))))
10420 (t ; Mark as unread.
10421 (while (and
10422 (progn
10423 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10424 (gnus-summary-show-thread) t)
10425 (gnus-summary-find-subject subject))
10426 (setq count (1+ count)))))
10427 (gnus-set-mode-line 'summary)
10428 ;; Return the number of marked articles.
10429 count)))
10431 (defun gnus-summary-mark-as-processable (n &optional unmark)
10432 "Set the process mark on the next N articles.
10433 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10434 the process mark instead. The difference between N and the actual
10435 number of articles marked is returned."
10436 (interactive "P")
10437 (if (and (null n) (gnus-region-active-p))
10438 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10439 (setq n (prefix-numeric-value n))
10440 (let ((backward (< n 0))
10441 (n (abs n)))
10442 (while (and
10443 (> n 0)
10444 (if unmark
10445 (gnus-summary-remove-process-mark
10446 (gnus-summary-article-number))
10447 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10448 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10449 (setq n (1- n)))
10450 (when (/= 0 n)
10451 (gnus-message 7 "No more articles"))
10452 (gnus-summary-recenter)
10453 (gnus-summary-position-point)
10454 n)))
10456 (defun gnus-summary-unmark-as-processable (n)
10457 "Remove the process mark from the next N articles.
10458 If N is negative, unmark backward instead. The difference between N and
10459 the actual number of articles unmarked is returned."
10460 (interactive "P")
10461 (gnus-summary-mark-as-processable n t))
10463 (defun gnus-summary-unmark-all-processable ()
10464 "Remove the process mark from all articles."
10465 (interactive)
10466 (save-excursion
10467 (while gnus-newsgroup-processable
10468 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10469 (gnus-summary-position-point))
10471 (defun gnus-summary-add-mark (article type)
10472 "Mark ARTICLE with a mark of TYPE."
10473 (let ((vtype (car (assq type gnus-article-mark-lists)))
10474 var)
10475 (if (not vtype)
10476 (error "No such mark type: %s" type)
10477 (setq var (intern (format "gnus-newsgroup-%s" type)))
10478 (set var (cons article (symbol-value var)))
10479 (if (memq type '(processable cached replied forwarded recent saved))
10480 (gnus-summary-update-secondary-mark article)
10481 ;;; !!! This is bogus. We should find out what primary
10482 ;;; !!! mark we want to set.
10483 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10485 (defun gnus-summary-mark-as-expirable (n)
10486 "Mark N articles forward as expirable.
10487 If N is negative, mark backward instead. The difference between N and
10488 the actual number of articles marked is returned."
10489 (interactive "p")
10490 (gnus-summary-mark-forward n gnus-expirable-mark))
10492 (defun gnus-summary-mark-as-spam (n)
10493 "Mark N articles forward as spam.
10494 If N is negative, mark backward instead. The difference between N and
10495 the actual number of articles marked is returned."
10496 (interactive "p")
10497 (gnus-summary-mark-forward n gnus-spam-mark))
10499 (defun gnus-summary-mark-article-as-replied (article)
10500 "Mark ARTICLE as replied to and update the summary line.
10501 ARTICLE can also be a list of articles."
10502 (interactive (list (gnus-summary-article-number)))
10503 (let ((articles (if (listp article) article (list article))))
10504 (dolist (article articles)
10505 (unless (numberp article)
10506 (error "%s is not a number" article))
10507 (push article gnus-newsgroup-replied)
10508 (let ((inhibit-read-only t))
10509 (when (gnus-summary-goto-subject article nil t)
10510 (gnus-summary-update-secondary-mark article))))))
10512 (defun gnus-summary-mark-article-as-forwarded (article)
10513 "Mark ARTICLE as forwarded and update the summary line.
10514 ARTICLE can also be a list of articles."
10515 (let ((articles (if (listp article) article (list article))))
10516 (dolist (article articles)
10517 (push article gnus-newsgroup-forwarded)
10518 (let ((inhibit-read-only t))
10519 (when (gnus-summary-goto-subject article nil t)
10520 (gnus-summary-update-secondary-mark article))))))
10522 (defun gnus-summary-set-bookmark (article)
10523 "Set a bookmark in current article."
10524 (interactive (list (gnus-summary-article-number)))
10525 (when (or (not (get-buffer gnus-article-buffer))
10526 (not gnus-current-article)
10527 (not gnus-article-current)
10528 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10529 (error "No current article selected"))
10530 ;; Remove old bookmark, if one exists.
10531 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10532 ;; Set the new bookmark, which is on the form
10533 ;; (article-number . line-number-in-body).
10534 (push
10535 (cons article
10536 (with-current-buffer gnus-article-buffer
10537 (count-lines
10538 (min (point)
10539 (save-excursion
10540 (article-goto-body)
10541 (point)))
10542 (point))))
10543 gnus-newsgroup-bookmarks)
10544 (gnus-message 6 "A bookmark has been added to the current article."))
10546 (defun gnus-summary-remove-bookmark (article)
10547 "Remove the bookmark from the current article."
10548 (interactive (list (gnus-summary-article-number)))
10549 ;; Remove old bookmark, if one exists.
10550 (if (not (assq article gnus-newsgroup-bookmarks))
10551 (gnus-message 6 "No bookmark in current article.")
10552 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10553 (gnus-message 6 "Removed bookmark.")))
10555 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10556 (defun gnus-summary-mark-as-dormant (n)
10557 "Mark N articles forward as dormant.
10558 If N is negative, mark backward instead. The difference between N and
10559 the actual number of articles marked is returned."
10560 (interactive "p")
10561 (gnus-summary-mark-forward n gnus-dormant-mark))
10563 (defun gnus-summary-set-process-mark (article)
10564 "Set the process mark on ARTICLE and update the summary line."
10565 (setq gnus-newsgroup-processable
10566 (cons article
10567 (delq article gnus-newsgroup-processable)))
10568 (when (gnus-summary-goto-subject article)
10569 (gnus-summary-show-thread)
10570 (gnus-summary-goto-subject article)
10571 (gnus-summary-update-secondary-mark article)))
10573 (defun gnus-summary-remove-process-mark (&rest articles)
10574 "Remove the process mark from ARTICLES and update the summary line."
10575 (dolist (article articles)
10576 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10577 (when (gnus-summary-goto-subject article)
10578 (gnus-summary-show-thread)
10579 (gnus-summary-goto-subject article)
10580 (gnus-summary-update-secondary-mark article)))
10583 (defun gnus-summary-set-saved-mark (article)
10584 "Set the process mark on ARTICLE and update the summary line."
10585 (push article gnus-newsgroup-saved)
10586 (when (gnus-summary-goto-subject article)
10587 (gnus-summary-update-secondary-mark article)))
10589 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10590 "Mark N articles as read forwards.
10591 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10592 The difference between N and the actual number of articles marked is
10593 returned.
10594 If NO-EXPIRE, auto-expiry will be inhibited."
10595 (interactive "p")
10596 (gnus-summary-show-thread)
10597 (let ((backward (< n 0))
10598 (gnus-summary-goto-unread
10599 (and gnus-summary-goto-unread
10600 (not (eq gnus-summary-goto-unread 'never))
10601 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10602 gnus-ticked-mark gnus-dormant-mark)))))
10603 (n (abs n))
10604 (mark (or mark gnus-del-mark)))
10605 (while (and (> n 0)
10606 (gnus-summary-mark-article nil mark no-expire)
10607 (zerop (gnus-summary-next-subject
10608 (if backward -1 1)
10609 (and gnus-summary-goto-unread
10610 (not (eq gnus-summary-goto-unread 'never)))
10611 t)))
10612 (setq n (1- n)))
10613 (when (/= 0 n)
10614 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10615 (gnus-summary-recenter)
10616 (gnus-summary-position-point)
10617 (gnus-set-mode-line 'summary)
10620 (defun gnus-summary-mark-article-as-read (mark)
10621 "Mark the current article quickly as read with MARK."
10622 (let ((article (gnus-summary-article-number)))
10623 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10624 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10625 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10626 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10627 (push (cons article mark) gnus-newsgroup-reads)
10628 ;; Possibly remove from cache, if that is used.
10629 (when gnus-use-cache
10630 (gnus-cache-enter-remove-article article))
10631 ;; Allow the backend to change the mark.
10632 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10633 ;; Check for auto-expiry.
10634 (when (and gnus-newsgroup-auto-expire
10635 (memq mark gnus-auto-expirable-marks))
10636 (setq mark gnus-expirable-mark)
10637 ;; Let the backend know about the mark change.
10638 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10639 (push article gnus-newsgroup-expirable))
10640 ;; Set the mark in the buffer.
10641 (gnus-summary-update-mark mark 'unread)
10644 (defun gnus-summary-mark-article-as-unread (mark)
10645 "Mark the current article quickly as unread with MARK."
10646 (let* ((article (gnus-summary-article-number))
10647 (old-mark (gnus-summary-article-mark article)))
10648 ;; Allow the backend to change the mark.
10649 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10650 (if (eq mark old-mark)
10652 (if (<= article 0)
10653 (progn
10654 (gnus-error 1 "Can't mark negative article numbers")
10655 nil)
10656 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10657 (setq gnus-newsgroup-spam-marked
10658 (delq article gnus-newsgroup-spam-marked))
10659 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10660 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10661 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10662 (cond ((= mark gnus-ticked-mark)
10663 (setq gnus-newsgroup-marked
10664 (gnus-add-to-sorted-list gnus-newsgroup-marked
10665 article)))
10666 ((= mark gnus-spam-mark)
10667 (setq gnus-newsgroup-spam-marked
10668 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10669 article)))
10670 ((= mark gnus-dormant-mark)
10671 (setq gnus-newsgroup-dormant
10672 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10673 article)))
10675 (setq gnus-newsgroup-unreads
10676 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10677 article))))
10678 (gnus-alist-pull article gnus-newsgroup-reads)
10680 ;; See whether the article is to be put in the cache.
10681 (and gnus-use-cache
10682 (vectorp (gnus-summary-article-header article))
10683 (save-excursion
10684 (gnus-cache-possibly-enter-article
10685 gnus-newsgroup-name article
10686 (= mark gnus-ticked-mark)
10687 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10689 ;; Fix the mark.
10690 (gnus-summary-update-mark mark 'unread)
10691 t))))
10693 (defun gnus-summary-mark-article (&optional article mark no-expire)
10694 "Mark ARTICLE with MARK. MARK can be any character.
10695 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10696 `??' (dormant) and `?E' (expirable).
10697 If MARK is nil, then the default character `?r' is used.
10698 If ARTICLE is nil, then the article on the current line will be
10699 marked.
10700 If NO-EXPIRE, auto-expiry will be inhibited."
10701 ;; The mark might be a string.
10702 (when (stringp mark)
10703 (setq mark (aref mark 0)))
10704 ;; If no mark is given, then we check auto-expiring.
10705 (when (null mark)
10706 (setq mark gnus-del-mark))
10707 (when (and (not no-expire)
10708 gnus-newsgroup-auto-expire
10709 (memq mark gnus-auto-expirable-marks))
10710 (setq mark gnus-expirable-mark))
10711 (let ((article (or article (gnus-summary-article-number)))
10712 (old-mark (gnus-summary-article-mark article)))
10713 ;; Allow the backend to change the mark.
10714 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10715 (if (eq mark old-mark)
10717 (unless article
10718 (error "No article on current line"))
10719 (if (not (if (or (= mark gnus-unread-mark)
10720 (= mark gnus-ticked-mark)
10721 (= mark gnus-spam-mark)
10722 (= mark gnus-dormant-mark))
10723 (gnus-mark-article-as-unread article mark)
10724 (gnus-mark-article-as-read article mark)))
10726 ;; See whether the article is to be put in the cache.
10727 (and gnus-use-cache
10728 (not (= mark gnus-canceled-mark))
10729 (vectorp (gnus-summary-article-header article))
10730 (save-excursion
10731 (gnus-cache-possibly-enter-article
10732 gnus-newsgroup-name article
10733 (= mark gnus-ticked-mark)
10734 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10736 (when (gnus-summary-goto-subject article nil t)
10737 (let ((inhibit-read-only t))
10738 (gnus-summary-show-thread)
10739 ;; Fix the mark.
10740 (gnus-summary-update-mark mark 'unread)
10741 t))))))
10743 (defun gnus-summary-update-secondary-mark (article)
10744 "Update the secondary (read, process, cache) mark."
10745 (gnus-summary-update-mark
10746 (cond ((memq article gnus-newsgroup-processable)
10747 gnus-process-mark)
10748 ((memq article gnus-newsgroup-cached)
10749 gnus-cached-mark)
10750 ((memq article gnus-newsgroup-replied)
10751 gnus-replied-mark)
10752 ((memq article gnus-newsgroup-forwarded)
10753 gnus-forwarded-mark)
10754 ((memq article gnus-newsgroup-saved)
10755 gnus-saved-mark)
10756 ((memq article gnus-newsgroup-recent)
10757 gnus-recent-mark)
10758 ((memq article gnus-newsgroup-unseen)
10759 gnus-unseen-mark)
10760 (t gnus-no-mark))
10761 'replied)
10762 (when (gnus-visual-p 'summary-highlight 'highlight)
10763 (gnus-summary-highlight-line)
10764 (gnus-run-hooks 'gnus-summary-update-hook))
10767 (defun gnus-summary-update-download-mark (article)
10768 "Update the download mark."
10769 (gnus-summary-update-mark
10770 (cond ((memq article gnus-newsgroup-undownloaded)
10771 gnus-undownloaded-mark)
10772 (gnus-newsgroup-agentized
10773 gnus-downloaded-mark)
10775 gnus-no-mark))
10776 'download)
10777 (gnus-summary-update-line t)
10780 (defun gnus-summary-update-mark (mark type)
10781 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10782 (inhibit-read-only t))
10783 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10784 (when forward
10785 (when (looking-at "\r")
10786 (incf forward))
10787 (when (<= (+ forward (point)) (point-max))
10788 ;; Go to the right position on the line.
10789 (goto-char (+ forward (point)))
10790 ;; Replace the old mark with the new mark.
10791 (let ((to-insert
10792 (mm-subst-char-in-string
10793 (char-after) mark
10794 (buffer-substring (point) (1+ (point))))))
10795 (delete-region (point) (1+ (point)))
10796 (insert to-insert))
10797 ;; Optionally update the marks by some user rule.
10798 (when (eq type 'unread)
10799 (gnus-data-set-mark
10800 (gnus-data-find (gnus-summary-article-number)) mark)
10801 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10803 (defun gnus-mark-article-as-read (article &optional mark)
10804 "Enter ARTICLE in the pertinent lists and remove it from others."
10805 ;; Make the article expirable.
10806 (let ((mark (or mark gnus-del-mark)))
10807 (setq gnus-newsgroup-expirable
10808 (if (= mark gnus-expirable-mark)
10809 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10810 (delq article gnus-newsgroup-expirable)))
10811 ;; Remove from unread and marked lists.
10812 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10813 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10814 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10815 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10816 (push (cons article mark) gnus-newsgroup-reads)
10817 ;; Possibly remove from cache, if that is used.
10818 (when gnus-use-cache
10819 (gnus-cache-enter-remove-article article))
10822 (defun gnus-mark-article-as-unread (article &optional mark)
10823 "Enter ARTICLE in the pertinent lists and remove it from others."
10824 (let ((mark (or mark gnus-ticked-mark)))
10825 (if (<= article 0)
10826 (progn
10827 (gnus-error 1 "Can't mark negative article numbers")
10828 nil)
10829 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10830 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10831 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10832 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10833 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10835 ;; Unsuppress duplicates?
10836 (when gnus-suppress-duplicates
10837 (gnus-dup-unsuppress-article article))
10839 (cond ((= mark gnus-ticked-mark)
10840 (setq gnus-newsgroup-marked
10841 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10842 ((= mark gnus-spam-mark)
10843 (setq gnus-newsgroup-spam-marked
10844 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10845 article)))
10846 ((= mark gnus-dormant-mark)
10847 (setq gnus-newsgroup-dormant
10848 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10850 (setq gnus-newsgroup-unreads
10851 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10852 (gnus-alist-pull article gnus-newsgroup-reads)
10853 t)))
10855 (defalias 'gnus-summary-mark-as-unread-forward
10856 'gnus-summary-tick-article-forward)
10857 (make-obsolete 'gnus-summary-mark-as-unread-forward
10858 'gnus-summary-tick-article-forward "Emacs 20.4")
10859 (defun gnus-summary-tick-article-forward (n)
10860 "Tick N articles forwards.
10861 If N is negative, tick backwards instead.
10862 The difference between N and the number of articles ticked is returned."
10863 (interactive "p")
10864 (gnus-summary-mark-forward n gnus-ticked-mark))
10866 (defalias 'gnus-summary-mark-as-unread-backward
10867 'gnus-summary-tick-article-backward)
10868 (make-obsolete 'gnus-summary-mark-as-unread-backward
10869 'gnus-summary-tick-article-backward "Emacs 20.4")
10870 (defun gnus-summary-tick-article-backward (n)
10871 "Tick N articles backwards.
10872 The difference between N and the number of articles ticked is returned."
10873 (interactive "p")
10874 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10876 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10877 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article "Emacs 20.4")
10878 (defun gnus-summary-tick-article (&optional article clear-mark)
10879 "Mark current article as unread.
10880 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10881 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10882 (interactive)
10883 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10884 gnus-ticked-mark)))
10886 (defun gnus-summary-mark-as-read-forward (n)
10887 "Mark N articles as read forwards.
10888 If N is negative, mark backwards instead.
10889 The difference between N and the actual number of articles marked is
10890 returned."
10891 (interactive "p")
10892 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10894 (defun gnus-summary-mark-as-read-backward (n)
10895 "Mark the N articles as read backwards.
10896 The difference between N and the actual number of articles marked is
10897 returned."
10898 (interactive "p")
10899 (gnus-summary-mark-forward
10900 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10902 (defun gnus-summary-mark-as-read (&optional article mark)
10903 "Mark current article as read.
10904 ARTICLE specifies the article to be marked as read.
10905 MARK specifies a string to be inserted at the beginning of the line."
10906 (gnus-summary-mark-article article mark))
10908 (defun gnus-summary-clear-mark-forward (n)
10909 "Clear marks from N articles forward.
10910 If N is negative, clear backward instead.
10911 The difference between N and the number of marks cleared is returned."
10912 (interactive "p")
10913 (gnus-summary-mark-forward n gnus-unread-mark))
10915 (defun gnus-summary-clear-mark-backward (n)
10916 "Clear marks from N articles backward.
10917 The difference between N and the number of marks cleared is returned."
10918 (interactive "p")
10919 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10921 (defun gnus-summary-mark-unread-as-read ()
10922 "Intended to be used by `gnus-mark-article-hook'."
10923 (when (memq gnus-current-article gnus-newsgroup-unreads)
10924 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10926 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10927 "Intended to be used by `gnus-mark-article-hook'."
10928 (let ((mark (gnus-summary-article-mark)))
10929 (when (or (gnus-unread-mark-p mark)
10930 (gnus-read-mark-p mark))
10931 (gnus-summary-mark-article gnus-current-article
10932 (or new-mark gnus-read-mark)))))
10934 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10935 "Intended to be used by `gnus-mark-article-hook'."
10936 (let ((mark (gnus-summary-article-mark)))
10937 (when (or (gnus-unread-mark-p mark)
10938 (gnus-read-mark-p mark))
10939 (gnus-summary-mark-article (gnus-summary-article-number)
10940 (or new-mark gnus-read-mark)))))
10942 (defun gnus-summary-mark-unread-as-ticked ()
10943 "Intended to be used by `gnus-mark-article-hook'."
10944 (when (memq gnus-current-article gnus-newsgroup-unreads)
10945 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10947 (defun gnus-summary-mark-region-as-read (point mark all)
10948 "Mark all unread articles between point and mark as read.
10949 If given a prefix, mark all articles between point and mark as read,
10950 even ticked and dormant ones."
10951 (interactive "r\nP")
10952 (save-excursion
10953 (let (article)
10954 (goto-char point)
10955 (beginning-of-line)
10956 (while (and
10957 (< (point) mark)
10958 (progn
10959 (when (or all
10960 (memq (setq article (gnus-summary-article-number))
10961 gnus-newsgroup-unreads))
10962 (gnus-summary-mark-article article gnus-del-mark))
10964 (gnus-summary-find-next))))))
10966 (defun gnus-summary-mark-below (score mark)
10967 "Mark articles with score less than SCORE with MARK."
10968 (interactive "P\ncMark: ")
10969 (setq score (if score
10970 (prefix-numeric-value score)
10971 (or gnus-summary-default-score 0)))
10972 (with-current-buffer gnus-summary-buffer
10973 (goto-char (point-min))
10974 (while
10975 (progn
10976 (and (< (gnus-summary-article-score) score)
10977 (gnus-summary-mark-article nil mark))
10978 (gnus-summary-find-next)))))
10980 (defun gnus-summary-kill-below (&optional score)
10981 "Mark articles with score below SCORE as read."
10982 (interactive "P")
10983 (gnus-summary-mark-below score gnus-killed-mark))
10985 (defun gnus-summary-clear-above (&optional score)
10986 "Clear all marks from articles with score above SCORE."
10987 (interactive "P")
10988 (gnus-summary-mark-above score gnus-unread-mark))
10990 (defun gnus-summary-tick-above (&optional score)
10991 "Tick all articles with score above SCORE."
10992 (interactive "P")
10993 (gnus-summary-mark-above score gnus-ticked-mark))
10995 (defun gnus-summary-mark-above (score mark)
10996 "Mark articles with score over SCORE with MARK."
10997 (interactive "P\ncMark: ")
10998 (setq score (if score
10999 (prefix-numeric-value score)
11000 (or gnus-summary-default-score 0)))
11001 (with-current-buffer gnus-summary-buffer
11002 (goto-char (point-min))
11003 (while (and (progn
11004 (when (> (gnus-summary-article-score) score)
11005 (gnus-summary-mark-article nil mark))
11007 (gnus-summary-find-next)))))
11009 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11010 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11011 (defun gnus-summary-limit-include-expunged (&optional no-error)
11012 "Display all the hidden articles that were expunged for low scores."
11013 (interactive)
11014 (let ((inhibit-read-only t))
11015 (let ((scored gnus-newsgroup-scored)
11016 headers h)
11017 (while scored
11018 (unless (gnus-summary-article-header (caar scored))
11019 (and (setq h (gnus-number-to-header (caar scored)))
11020 (< (cdar scored) gnus-summary-expunge-below)
11021 (push h headers)))
11022 (setq scored (cdr scored)))
11023 (if (not headers)
11024 (when (not no-error)
11025 (error "No expunged articles hidden"))
11026 (goto-char (point-min))
11027 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11028 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11029 (dolist (x headers)
11030 (push (mail-header-number x) gnus-newsgroup-limit))
11031 (gnus-summary-prepare-unthreaded (nreverse headers))
11032 (goto-char (point-min))
11033 (gnus-summary-position-point)
11034 t))))
11036 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11037 "Mark all unread articles in this newsgroup as read.
11038 If prefix argument ALL is non-nil, ticked and dormant articles will
11039 also be marked as read.
11040 If QUIETLY is non-nil, no questions will be asked.
11042 If TO-HERE is non-nil, it should be a point in the buffer. All
11043 articles before (after, if REVERSE is set) this point will be marked
11044 as read.
11046 Note that this function will only catch up the unread article
11047 in the current summary buffer limitation.
11049 The number of articles marked as read is returned."
11050 (interactive "P")
11051 (prog1
11052 (save-excursion
11053 (when (or quietly
11054 (not gnus-interactive-catchup) ;Without confirmation?
11055 gnus-expert-user
11056 (gnus-y-or-n-p
11057 (if all
11058 "Mark absolutely all articles as read? "
11059 "Mark all unread articles as read? ")))
11060 (if (and not-mark
11061 (not gnus-newsgroup-adaptive)
11062 (not gnus-newsgroup-auto-expire)
11063 (not gnus-suppress-duplicates)
11064 (or (not gnus-use-cache)
11065 (eq gnus-use-cache 'passive)))
11066 (progn
11067 (when all
11068 (setq gnus-newsgroup-marked nil
11069 gnus-newsgroup-spam-marked nil
11070 gnus-newsgroup-dormant nil))
11071 (setq gnus-newsgroup-unreads
11072 (gnus-sorted-nunion
11073 (gnus-sorted-intersection gnus-newsgroup-unreads
11074 gnus-newsgroup-downloadable)
11075 (gnus-sorted-difference gnus-newsgroup-unfetched
11076 gnus-newsgroup-cached))))
11077 ;; We actually mark all articles as canceled, which we
11078 ;; have to do when using auto-expiry or adaptive scoring.
11079 (gnus-summary-show-all-threads)
11080 (if (and to-here reverse)
11081 (progn
11082 (goto-char to-here)
11083 (gnus-summary-mark-current-read-and-unread-as-read
11084 gnus-catchup-mark)
11085 (while (gnus-summary-find-next (not all))
11086 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11087 (when (gnus-summary-first-subject (not all))
11088 (while (and
11089 (if to-here (< (point) to-here) t)
11090 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11091 (gnus-summary-find-next (not all))))))
11092 (gnus-set-mode-line 'summary))
11094 (gnus-summary-position-point)))
11096 (defun gnus-summary-catchup-to-here (&optional all)
11097 "Mark all unticked articles before the current one as read.
11098 If ALL is non-nil, also mark ticked and dormant articles as read."
11099 (interactive "P")
11100 (save-excursion
11101 (gnus-save-hidden-threads
11102 (let ((beg (point)))
11103 ;; We check that there are unread articles.
11104 (when (or all (gnus-summary-find-prev))
11105 (gnus-summary-catchup all t beg)))))
11106 (gnus-summary-position-point))
11108 (defun gnus-summary-catchup-from-here (&optional all)
11109 "Mark all unticked articles after (and including) the current one as read.
11110 If ALL is non-nil, also mark ticked and dormant articles as read."
11111 (interactive "P")
11112 (save-excursion
11113 (gnus-save-hidden-threads
11114 (let ((beg (point)))
11115 ;; We check that there are unread articles.
11116 (when (or all (gnus-summary-find-next))
11117 (gnus-summary-catchup all t beg nil t)))))
11118 (gnus-summary-position-point))
11120 (defun gnus-summary-catchup-all (&optional quietly)
11121 "Mark all articles in this newsgroup as read.
11122 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11123 instead, which marks only unread articles as read."
11124 (interactive "P")
11125 (gnus-summary-catchup t quietly))
11127 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11128 "Mark all unread articles in this group as read, then exit.
11129 If prefix argument ALL is non-nil, all articles are marked as read.
11130 If QUIETLY is non-nil, no questions will be asked."
11131 (interactive "P")
11132 (when (gnus-summary-catchup all quietly nil 'fast)
11133 ;; Select next newsgroup or exit.
11134 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11135 (eq gnus-auto-select-next 'quietly))
11136 (gnus-summary-next-group nil)
11137 (gnus-summary-exit))))
11139 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11140 "Mark all articles in this newsgroup as read, and then exit.
11141 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11142 instead, which marks only unread articles as read."
11143 (interactive "P")
11144 (gnus-summary-catchup-and-exit t quietly))
11146 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11147 "Mark all articles in this group as read and select the next group.
11148 If given a prefix, mark all articles, unread as well as ticked, as
11149 read."
11150 (interactive "P")
11151 (save-excursion
11152 (gnus-summary-catchup all))
11153 (gnus-summary-next-group))
11155 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11156 "Mark all articles in this group as read and select the previous group.
11157 If given a prefix, mark all articles, unread as well as ticked, as
11158 read."
11159 (interactive "P")
11160 (save-excursion
11161 (gnus-summary-catchup all))
11162 (gnus-summary-next-group nil nil t))
11165 ;;; with article
11168 (defmacro gnus-with-article (article &rest forms)
11169 "Select ARTICLE and perform FORMS in the original article buffer.
11170 Then replace the article with the result."
11171 `(progn
11172 ;; We don't want the article to be marked as read.
11173 (let (gnus-mark-article-hook)
11174 (gnus-summary-select-article t t nil ,article))
11175 (set-buffer gnus-original-article-buffer)
11176 ,@forms
11177 (if (not (gnus-check-backend-function
11178 'request-replace-article (car gnus-article-current)))
11179 (gnus-message 5 "Read-only group; not replacing")
11180 (unless (gnus-request-replace-article
11181 ,article (car gnus-article-current)
11182 (current-buffer) t)
11183 (error "Couldn't replace article")))
11184 ;; The cache and backlog have to be flushed somewhat.
11185 (when gnus-keep-backlog
11186 (gnus-backlog-remove-article
11187 (car gnus-article-current) (cdr gnus-article-current)))
11188 (when gnus-use-cache
11189 (gnus-cache-update-article
11190 (car gnus-article-current) (cdr gnus-article-current)))))
11192 (put 'gnus-with-article 'lisp-indent-function 1)
11193 (put 'gnus-with-article 'edebug-form-spec '(form body))
11195 ;; Thread-based commands.
11197 (defun gnus-summary-articles-in-thread (&optional article)
11198 "Return a list of all articles in the current thread.
11199 If ARTICLE is non-nil, return all articles in the thread that starts
11200 with that article."
11201 (let* ((article (or article (gnus-summary-article-number)))
11202 (data (gnus-data-find-list article))
11203 (top-level (gnus-data-level (car data)))
11204 (top-subject
11205 (cond ((null gnus-thread-operation-ignore-subject)
11206 (gnus-simplify-subject-re
11207 (mail-header-subject (gnus-data-header (car data)))))
11208 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11209 (gnus-simplify-subject-fuzzy
11210 (mail-header-subject (gnus-data-header (car data)))))
11211 (t nil)))
11212 (end-point (save-excursion
11213 (if (gnus-summary-go-to-next-thread)
11214 (point) (point-max))))
11215 articles)
11216 (while (and data
11217 (< (gnus-data-pos (car data)) end-point))
11218 (when (or (not top-subject)
11219 (string= top-subject
11220 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11221 (gnus-simplify-subject-fuzzy
11222 (mail-header-subject
11223 (gnus-data-header (car data))))
11224 (gnus-simplify-subject-re
11225 (mail-header-subject
11226 (gnus-data-header (car data)))))))
11227 (push (gnus-data-number (car data)) articles))
11228 (unless (and (setq data (cdr data))
11229 (> (gnus-data-level (car data)) top-level))
11230 (setq data nil)))
11231 ;; Return the list of articles.
11232 (nreverse articles)))
11234 (defun gnus-summary-rethread-current ()
11235 "Rethread the thread the current article is part of."
11236 (interactive)
11237 (let* ((gnus-show-threads t)
11238 (article (gnus-summary-article-number))
11239 (id (mail-header-id (gnus-summary-article-header)))
11240 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11241 (unless id
11242 (error "No article on the current line"))
11243 (gnus-rebuild-thread id)
11244 (gnus-summary-goto-subject article)))
11246 (defun gnus-summary-reparent-thread ()
11247 "Make the current article child of the marked (or previous) article.
11249 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11250 is non-nil or the Subject: of both articles are the same."
11251 (interactive)
11252 (unless (not (gnus-group-read-only-p))
11253 (error "The current newsgroup does not support article editing"))
11254 (unless (<= (length gnus-newsgroup-processable) 1)
11255 (error "No more than one article may be marked"))
11256 (let ((child (gnus-summary-article-number))
11257 ;; First grab the marked article, otherwise one line up.
11258 (parent (if (not (null gnus-newsgroup-processable))
11259 (car gnus-newsgroup-processable)
11260 (save-excursion
11261 (if (eq (forward-line -1) 0)
11262 (gnus-summary-article-number)
11263 (error "Beginning of summary buffer"))))))
11264 (gnus-summary-reparent-children parent (list child))))
11266 (defun gnus-summary-reparent-children (parent children)
11267 "Make PARENT the parent of CHILDREN.
11268 When called interactively, PARENT is the current article and CHILDREN
11269 are the process-marked articles."
11270 (interactive
11271 (list (gnus-summary-article-number)
11272 (gnus-summary-work-articles nil)))
11273 (dolist (child children)
11274 (save-window-excursion
11275 (let ((gnus-article-buffer " *reparent*"))
11276 (unless (not (eq parent child))
11277 (error "An article may not be self-referential"))
11278 (let ((message-id (mail-header-id
11279 (gnus-summary-article-header parent))))
11280 (unless (and message-id (not (equal message-id "")))
11281 (error "No message-id in desired parent"))
11282 (gnus-with-article child
11283 (save-restriction
11284 (goto-char (point-min))
11285 (message-narrow-to-head)
11286 (if (re-search-forward "^References: " nil t)
11287 (progn
11288 (re-search-forward "^[^ \t]" nil t)
11289 (forward-line -1)
11290 (end-of-line)
11291 (insert " " message-id))
11292 (insert "References: " message-id "\n"))))
11293 (set-buffer gnus-summary-buffer)
11294 (gnus-summary-unmark-all-processable)
11295 (gnus-summary-update-article child)
11296 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11297 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11298 (gnus-summary-rethread-current)
11299 (gnus-message 3 "Article %d is now the child of article %d"
11300 child parent))))))
11302 (defun gnus-summary-toggle-threads (&optional arg)
11303 "Toggle showing conversation threads.
11304 If ARG is positive number, turn showing conversation threads on."
11305 (interactive "P")
11306 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11307 (setq gnus-show-threads
11308 (if (null arg) (not gnus-show-threads)
11309 (> (prefix-numeric-value arg) 0)))
11310 (gnus-summary-prepare)
11311 (gnus-summary-goto-subject current)
11312 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11313 (gnus-summary-position-point)))
11315 (eval-and-compile
11316 (if (fboundp 'remove-overlays)
11317 (defalias 'gnus-remove-overlays 'remove-overlays)
11318 (defun gnus-remove-overlays (beg end name val)
11319 "Clear BEG and END of overlays whose property NAME has value VAL.
11320 For compatibility with XEmacs."
11321 (dolist (ov (gnus-overlays-in beg end))
11322 (when (eq (gnus-overlay-get ov name) val)
11323 (gnus-delete-overlay ov))))))
11325 (defun gnus-summary-show-all-threads ()
11326 "Show all threads."
11327 (interactive)
11328 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11329 (gnus-summary-position-point))
11331 (defsubst gnus-summary--inv (p)
11332 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11334 (defun gnus-summary-show-thread ()
11335 "Show thread subtrees.
11336 Returns nil if no thread was there to be shown."
11337 (interactive)
11338 (let* ((orig (point))
11339 (end (point-at-eol))
11340 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11341 ;; Leave point at bol
11342 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11343 (eoi (when end
11344 (if (fboundp 'next-single-char-property-change)
11345 (or (next-single-char-property-change end 'invisible)
11346 (point-max))
11347 (while (progn
11348 (end-of-line 2)
11349 (and (not (eobp))
11350 (eq (get-char-property (point) 'invisible)
11351 'gnus-sum))))
11352 (point)))))
11353 (when eoi
11354 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11355 (goto-char orig)
11356 (gnus-summary-position-point)
11357 eoi)))
11359 (defun gnus-summary-maybe-hide-threads ()
11360 "If requested, hide the threads that should be hidden."
11361 (when (and gnus-show-threads
11362 gnus-thread-hide-subtree)
11363 (gnus-summary-hide-all-threads
11364 (if (or (consp gnus-thread-hide-subtree)
11365 (functionp gnus-thread-hide-subtree))
11366 (gnus-make-predicate gnus-thread-hide-subtree)
11367 nil))))
11369 ;;; Hiding predicates.
11371 (defun gnus-article-unread-p (header)
11372 (memq (mail-header-number header) gnus-newsgroup-unreads))
11374 (defun gnus-article-unseen-p (header)
11375 (memq (mail-header-number header) gnus-newsgroup-unseen))
11377 (defun gnus-map-articles (predicate articles)
11378 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11379 (apply 'gnus-or (mapcar predicate
11380 (mapcar (lambda (number)
11381 (gnus-summary-article-header number))
11382 articles))))
11384 (defun gnus-summary-hide-all-threads (&optional predicate)
11385 "Hide all thread subtrees.
11386 If PREDICATE is supplied, threads that satisfy this predicate
11387 will not be hidden."
11388 (interactive)
11389 (save-excursion
11390 (goto-char (point-min))
11391 (let ((end nil))
11392 (while (not end)
11393 (when (or (not predicate)
11394 (gnus-map-articles
11395 predicate (gnus-summary-article-children)))
11396 (gnus-summary-hide-thread))
11397 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11398 (gnus-summary-position-point))
11400 (defun gnus-summary-hide-thread ()
11401 "Hide thread subtrees.
11402 If PREDICATE is supplied, threads that satisfy this predicate
11403 will not be hidden.
11404 Returns nil if no threads were there to be hidden."
11405 (interactive)
11406 (let ((start (point))
11407 (starteol (line-end-position))
11408 (article (gnus-summary-article-number)))
11409 (goto-char start)
11410 ;; Go forward until either the buffer ends or the subthread ends.
11411 (when (and (not (eobp))
11412 (or (zerop (gnus-summary-next-thread 1 t))
11413 (goto-char (point-max))))
11414 (if (and (> (point) start)
11415 ;; FIXME: this should actually search for a non-invisible \n.
11416 (search-backward "\n" start t))
11417 (progn
11418 (when (> (point) starteol)
11419 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11420 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11421 (gnus-overlay-put ol 'invisible 'gnus-sum)
11422 (gnus-overlay-put ol 'evaporate t)))
11423 (gnus-summary-goto-subject article))
11424 (goto-char start)
11425 nil))))
11427 (defun gnus-summary-go-to-next-thread (&optional previous)
11428 "Go to the same level (or less) next thread.
11429 If PREVIOUS is non-nil, go to previous thread instead.
11430 Return the article number moved to, or nil if moving was impossible."
11431 (let ((level (gnus-summary-thread-level))
11432 (way (if previous -1 1))
11433 (beg (point)))
11434 (forward-line way)
11435 (while (and (not (eobp))
11436 (< level (gnus-summary-thread-level)))
11437 (forward-line way))
11438 (if (eobp)
11439 (progn
11440 (goto-char beg)
11441 nil)
11442 (setq beg (point))
11443 (prog1
11444 (gnus-summary-article-number)
11445 (goto-char beg)))))
11447 (defun gnus-summary-next-thread (n &optional silent)
11448 "Go to the same level next N'th thread.
11449 If N is negative, search backward instead.
11450 Returns the difference between N and the number of skips actually
11451 done.
11453 If SILENT, don't output messages."
11454 (interactive "p")
11455 (let ((backward (< n 0))
11456 (n (abs n)))
11457 (while (and (> n 0)
11458 (gnus-summary-go-to-next-thread backward))
11459 (decf n))
11460 (unless silent
11461 (gnus-summary-position-point))
11462 (when (and (not silent) (/= 0 n))
11463 (gnus-message 7 "No more threads"))
11466 (defun gnus-summary-prev-thread (n)
11467 "Go to the same level previous N'th thread.
11468 Returns the difference between N and the number of skips actually
11469 done."
11470 (interactive "p")
11471 (gnus-summary-next-thread (- n)))
11473 (defun gnus-summary-go-down-thread ()
11474 "Go down one level in the current thread."
11475 (let ((children (gnus-summary-article-children)))
11476 (when children
11477 (gnus-summary-goto-subject (car children)))))
11479 (defun gnus-summary-go-up-thread ()
11480 "Go up one level in the current thread."
11481 (let ((parent (gnus-summary-article-parent)))
11482 (when parent
11483 (gnus-summary-goto-subject parent))))
11485 (defun gnus-summary-down-thread (n)
11486 "Go down thread N steps.
11487 If N is negative, go up instead.
11488 Returns the difference between N and how many steps down that were
11489 taken."
11490 (interactive "p")
11491 (let ((up (< n 0))
11492 (n (abs n)))
11493 (while (and (> n 0)
11494 (if up (gnus-summary-go-up-thread)
11495 (gnus-summary-go-down-thread)))
11496 (setq n (1- n)))
11497 (gnus-summary-position-point)
11498 (when (/= 0 n)
11499 (gnus-message 7 "Can't go further"))
11502 (defun gnus-summary-up-thread (n)
11503 "Go up thread N steps.
11504 If N is negative, go down instead.
11505 Returns the difference between N and how many steps down that were
11506 taken."
11507 (interactive "p")
11508 (gnus-summary-down-thread (- n)))
11510 (defun gnus-summary-top-thread ()
11511 "Go to the top of the thread."
11512 (interactive)
11513 (while (gnus-summary-go-up-thread))
11514 (gnus-summary-article-number))
11516 (defun gnus-summary-expire-thread ()
11517 "Mark articles under current thread as expired."
11518 (interactive)
11519 (gnus-summary-kill-thread 0))
11521 (defun gnus-summary-kill-thread (&optional unmark)
11522 "Mark articles under current thread as read.
11523 If the prefix argument is positive, remove any kinds of marks.
11524 If the prefix argument is zero, mark thread as expired.
11525 If the prefix argument is negative, tick articles instead."
11526 (interactive "P")
11527 (when unmark
11528 (setq unmark (prefix-numeric-value unmark)))
11529 (let ((articles (gnus-summary-articles-in-thread))
11530 (hide (or (null unmark) (= unmark 0))))
11531 (save-excursion
11532 ;; Expand the thread.
11533 (gnus-summary-show-thread)
11534 ;; Mark all the articles.
11535 (while articles
11536 (gnus-summary-goto-subject (car articles))
11537 (cond ((null unmark)
11538 (gnus-summary-mark-article-as-read gnus-killed-mark))
11539 ((> unmark 0)
11540 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11541 ((= unmark 0)
11542 (gnus-summary-mark-article nil gnus-expirable-mark))
11544 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11545 (setq articles (cdr articles))))
11546 ;; Hide killed subtrees when hide is true.
11547 (and hide
11548 gnus-thread-hide-killed
11549 (gnus-summary-hide-thread))
11550 ;; If hide is t, go to next unread subject.
11551 (when hide
11552 ;; Go to next unread subject.
11553 (gnus-summary-next-subject 1 t)))
11554 (gnus-set-mode-line 'summary))
11556 ;; Summary sorting commands
11558 (defun gnus-summary-sort-by-number (&optional reverse)
11559 "Sort the summary buffer by article number.
11560 Argument REVERSE means reverse order."
11561 (interactive "P")
11562 (gnus-summary-sort 'number reverse))
11564 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11565 "Sort the summary buffer by most recent article number.
11566 Argument REVERSE means reverse order."
11567 (interactive "P")
11568 (gnus-summary-sort 'most-recent-number reverse))
11570 (defun gnus-summary-sort-by-random (&optional reverse)
11571 "Randomize the order in the summary buffer.
11572 Argument REVERSE means to randomize in reverse order."
11573 (interactive "P")
11574 (gnus-summary-sort 'random reverse))
11576 (defun gnus-summary-sort-by-author (&optional reverse)
11577 "Sort the summary buffer by author name alphabetically.
11578 If `case-fold-search' is non-nil, case of letters is ignored.
11579 Argument REVERSE means reverse order."
11580 (interactive "P")
11581 (gnus-summary-sort 'author reverse))
11583 (defun gnus-summary-sort-by-recipient (&optional reverse)
11584 "Sort the summary buffer by recipient name alphabetically.
11585 If `case-fold-search' is non-nil, case of letters is ignored.
11586 Argument REVERSE means reverse order."
11587 (interactive "P")
11588 (gnus-summary-sort 'recipient reverse))
11590 (defun gnus-summary-sort-by-subject (&optional reverse)
11591 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11592 If `case-fold-search' is non-nil, case of letters is ignored.
11593 Argument REVERSE means reverse order."
11594 (interactive "P")
11595 (gnus-summary-sort 'subject reverse))
11597 (defun gnus-summary-sort-by-date (&optional reverse)
11598 "Sort the summary buffer by date.
11599 Argument REVERSE means reverse order."
11600 (interactive "P")
11601 (gnus-summary-sort 'date reverse))
11603 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11604 "Sort the summary buffer by most recent date.
11605 Argument REVERSE means reverse order."
11606 (interactive "P")
11607 (gnus-summary-sort 'most-recent-date reverse))
11609 (defun gnus-summary-sort-by-score (&optional reverse)
11610 "Sort the summary buffer by score.
11611 Argument REVERSE means reverse order."
11612 (interactive "P")
11613 (gnus-summary-sort 'score reverse))
11615 (defun gnus-summary-sort-by-lines (&optional reverse)
11616 "Sort the summary buffer by the number of lines.
11617 Argument REVERSE means reverse order."
11618 (interactive "P")
11619 (gnus-summary-sort 'lines reverse))
11621 (defun gnus-summary-sort-by-chars (&optional reverse)
11622 "Sort the summary buffer by article length.
11623 Argument REVERSE means reverse order."
11624 (interactive "P")
11625 (gnus-summary-sort 'chars reverse))
11627 (defun gnus-summary-sort-by-original (&optional reverse)
11628 "Sort the summary buffer using the default sorting method.
11629 Argument REVERSE means reverse order."
11630 (interactive "P")
11631 (let* ((inhibit-read-only t)
11632 (gnus-summary-prepare-hook nil))
11633 ;; We do the sorting by regenerating the threads.
11634 (gnus-summary-prepare)
11635 ;; Hide subthreads if needed.
11636 (gnus-summary-maybe-hide-threads)))
11638 (defun gnus-summary-sort (predicate reverse)
11639 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11640 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11641 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11642 (gnus-thread-sort-functions
11643 (if (not reverse)
11644 thread
11645 `(lambda (t1 t2)
11646 (,thread t2 t1))))
11647 (gnus-sort-gathered-threads-function
11648 gnus-thread-sort-functions)
11649 (gnus-article-sort-functions
11650 (if (not reverse)
11651 article
11652 `(lambda (t1 t2)
11653 (,article t2 t1))))
11654 (inhibit-read-only t)
11655 (gnus-summary-prepare-hook nil))
11656 ;; We do the sorting by regenerating the threads.
11657 (gnus-summary-prepare)
11658 ;; Hide subthreads if needed.
11659 (gnus-summary-maybe-hide-threads)))
11661 ;; Summary saving commands.
11663 (defun gnus-summary-save-article (&optional n not-saved)
11664 "Save the current article using the default saver function.
11665 If N is a positive number, save the N next articles.
11666 If N is a negative number, save the N previous articles.
11667 If N is nil and any articles have been marked with the process mark,
11668 save those articles instead.
11669 The variable `gnus-default-article-saver' specifies the saver function.
11671 If the optional second argument NOT-SAVED is non-nil, articles saved
11672 will not be marked as saved."
11673 (interactive "P")
11674 (require 'gnus-art)
11675 (let* ((articles (gnus-summary-work-articles n))
11676 (save-buffer (save-excursion
11677 (nnheader-set-temp-buffer " *Gnus Save*")))
11678 (num (length articles))
11679 ;; Whether to save decoded articles or raw articles.
11680 (decode (when gnus-article-save-coding-system
11681 (get gnus-default-article-saver :decode)))
11682 ;; When saving many articles in a single file, use the other
11683 ;; function to save articles other than the first one.
11684 (saver2 (get gnus-default-article-saver :function))
11685 (gnus-prompt-before-saving (if saver2
11687 gnus-prompt-before-saving))
11688 (gnus-default-article-saver gnus-default-article-saver)
11689 header file)
11690 (dolist (article articles)
11691 (setq header (gnus-summary-article-header article))
11692 (if (not (vectorp header))
11693 ;; This is a pseudo-article.
11694 (if (assq 'name header)
11695 (gnus-copy-file (cdr (assq 'name header)))
11696 (gnus-message 1 "Article %d is unsaveable" article))
11697 ;; This is a real article.
11698 (save-window-excursion
11699 (gnus-summary-select-article decode decode nil article)
11700 (gnus-summary-goto-subject article))
11701 (with-current-buffer save-buffer
11702 (erase-buffer)
11703 (insert-buffer-substring (if decode
11704 gnus-article-buffer
11705 gnus-original-article-buffer)))
11706 (setq file (gnus-article-save save-buffer file num))
11707 (gnus-summary-remove-process-mark article)
11708 (unless not-saved
11709 (gnus-summary-set-saved-mark article)))
11710 (when saver2
11711 (setq gnus-default-article-saver saver2
11712 saver2 nil)))
11713 (gnus-kill-buffer save-buffer)
11714 (gnus-summary-position-point)
11715 (gnus-set-mode-line 'summary)
11718 (defun gnus-summary-pipe-output (&optional n sym)
11719 "Pipe the current article to a subprocess.
11720 If N is a positive number, pipe the N next articles.
11721 If N is a negative number, pipe the N previous articles.
11722 If N is nil and any articles have been marked with the process mark,
11723 pipe those articles instead.
11724 The default command to which articles are piped is specified by the
11725 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11726 will be prompted for the command.
11728 The properties `:decode' and `:headers' that are put to the function
11729 symbol `gnus-summary-save-in-pipe' control whether this function
11730 decodes articles and what headers to keep (see the doc string for the
11731 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11732 is neither omitted nor the symbol `r', force including all headers
11733 regardless of the `:headers' property. If it is the symbol `r',
11734 articles that are not decoded and include all headers will be piped
11735 no matter what the properties `:decode' and `:headers' are."
11736 (interactive (gnus-interactive "P\ny"))
11737 (require 'gnus-art)
11738 (let* ((articles (gnus-summary-work-articles n))
11739 (result-buffer "*Shell Command Output*")
11740 (all-headers (not (memq sym '(nil r))))
11741 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11742 (raw (eq sym 'r))
11743 (headers (get 'gnus-summary-save-in-pipe :headers))
11744 command result)
11745 (unless (numberp (car articles))
11746 (error "No article to pipe"))
11747 (setq command (gnus-read-shell-command
11748 (concat "Shell command on "
11749 (if (cdr articles)
11750 (format "these %d articles" (length articles))
11751 "this article")
11752 ": ")
11753 gnus-summary-pipe-output-default-command))
11754 (when (string-equal command "")
11755 (error "A command is required"))
11756 (when all-headers
11757 (put 'gnus-summary-save-in-pipe :headers nil))
11758 (unwind-protect
11759 (while articles
11760 (gnus-summary-goto-subject (pop articles))
11761 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11762 (when (and (get-buffer result-buffer)
11763 (not (zerop (buffer-size (get-buffer result-buffer)))))
11764 (setq result (concat result (with-current-buffer result-buffer
11765 (buffer-string))))))
11766 (put 'gnus-summary-save-in-pipe :headers headers))
11767 (unless (zerop (length result))
11768 (if (with-current-buffer (get-buffer-create result-buffer)
11769 (erase-buffer)
11770 (insert result)
11771 (prog1
11772 (and (= (count-lines (point-min) (point)) 1)
11773 (progn
11774 (end-of-line 0)
11775 (<= (current-column)
11776 (window-width (minibuffer-window)))))
11777 (goto-char (point-min))))
11778 (message "%s" (substring result 0 -1))
11779 (message nil)
11780 (gnus-configure-windows 'pipe)))))
11782 (defun gnus-summary-save-article-mail (&optional arg)
11783 "Append the current article to a Unix mail box file.
11784 If N is a positive number, save the N next articles.
11785 If N is a negative number, save the N previous articles.
11786 If N is nil and any articles have been marked with the process mark,
11787 save those articles instead."
11788 (interactive "P")
11789 (require 'gnus-art)
11790 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11791 (gnus-summary-save-article arg)))
11793 (defun gnus-summary-save-article-rmail (&optional arg)
11794 "Append the current article to an rmail file.
11795 If N is a positive number, save the N next articles.
11796 If N is a negative number, save the N previous articles.
11797 If N is nil and any articles have been marked with the process mark,
11798 save those articles instead."
11799 (interactive "P")
11800 (require 'gnus-art)
11801 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11802 (gnus-summary-save-article arg)))
11804 (defun gnus-summary-save-article-file (&optional arg)
11805 "Append the current article to a file.
11806 If N is a positive number, save the N next articles.
11807 If N is a negative number, save the N previous articles.
11808 If N is nil and any articles have been marked with the process mark,
11809 save those articles instead."
11810 (interactive "P")
11811 (require 'gnus-art)
11812 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11813 (gnus-summary-save-article arg)))
11815 (defun gnus-summary-write-article-file (&optional arg)
11816 "Write the current article to a file, deleting the previous file.
11817 If N is a positive number, save the N next articles.
11818 If N is a negative number, save the N previous articles.
11819 If N is nil and any articles have been marked with the process mark,
11820 save those articles instead."
11821 (interactive "P")
11822 (require 'gnus-art)
11823 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11824 (gnus-summary-save-article arg)))
11826 (defun gnus-summary-save-article-body-file (&optional arg)
11827 "Append the current article body to a file.
11828 If N is a positive number, save the N next articles.
11829 If N is a negative number, save the N previous articles.
11830 If N is nil and any articles have been marked with the process mark,
11831 save those articles instead."
11832 (interactive "P")
11833 (require 'gnus-art)
11834 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11835 (gnus-summary-save-article arg)))
11837 (defun gnus-summary-write-article-body-file (&optional arg)
11838 "Write the current article body to a file, deleting the previous file.
11839 If N is a positive number, save the N next articles.
11840 If N is a negative number, save the N previous articles.
11841 If N is nil and any articles have been marked with the process mark,
11842 save those articles instead."
11843 (interactive "P")
11844 (require 'gnus-art)
11845 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11846 (gnus-summary-save-article arg)))
11848 (defun gnus-summary-muttprint (&optional arg)
11849 "Print the current article using Muttprint.
11850 If N is a positive number, save the N next articles.
11851 If N is a negative number, save the N previous articles.
11852 If N is nil and any articles have been marked with the process mark,
11853 save those articles instead."
11854 (interactive "P")
11855 (require 'gnus-art)
11856 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11857 (gnus-summary-save-article arg t)))
11859 (defun gnus-summary-pipe-message (program)
11860 "Pipe the current article through PROGRAM."
11861 (interactive "sProgram: ")
11862 (gnus-summary-select-article)
11863 (let ((mail-header-separator ""))
11864 (gnus-eval-in-buffer-window gnus-article-buffer
11865 (save-restriction
11866 (widen)
11867 (let ((start (window-start))
11868 (inhibit-read-only t))
11869 (message-pipe-buffer-body program)
11870 (set-window-start (get-buffer-window (current-buffer)) start))))))
11872 (defun gnus-get-split-value (methods)
11873 "Return a value based on the split METHODS."
11874 (let (split-name method result match)
11875 (when methods
11876 (with-current-buffer gnus-original-article-buffer
11877 (save-restriction
11878 (nnheader-narrow-to-headers)
11879 (while (and methods (not split-name))
11880 (goto-char (point-min))
11881 (setq method (pop methods))
11882 (setq match (car method))
11883 (when (cond
11884 ((stringp match)
11885 ;; Regular expression.
11886 (ignore-errors
11887 (re-search-forward match nil t)))
11888 ((functionp match)
11889 ;; Function.
11890 (save-restriction
11891 (widen)
11892 (setq result (funcall match gnus-newsgroup-name))))
11893 ((consp match)
11894 ;; Form.
11895 (save-restriction
11896 (widen)
11897 (setq result (eval match)))))
11898 (setq split-name (cdr method))
11899 (cond ((stringp result)
11900 (push (expand-file-name
11901 result gnus-article-save-directory)
11902 split-name))
11903 ((consp result)
11904 (setq split-name (append result split-name)))))))))
11905 (nreverse split-name)))
11907 (defun gnus-valid-move-group-p (group)
11908 (and (symbolp group)
11909 (boundp group)
11910 (symbol-name group)
11911 (symbol-value group)
11912 (gnus-get-function (gnus-find-method-for-group
11913 (symbol-name group)) 'request-accept-article t)))
11915 (defun gnus-read-move-group-name (prompt default articles prefix)
11916 "Read a group name."
11917 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11918 (minibuffer-confirm-incomplete nil) ; XEmacs
11919 (prom
11920 (format "%s %s to"
11921 prompt
11922 (if (> (length articles) 1)
11923 (format "these %d articles" (length articles))
11924 "this article")))
11925 (to-newsgroup
11926 (cond
11927 ((null split-name)
11928 (gnus-group-completing-read
11929 prom
11930 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
11931 nil prefix nil default))
11932 ((= 1 (length split-name))
11933 (gnus-group-completing-read
11934 prom
11935 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
11936 nil prefix 'gnus-group-history (car split-name)))
11938 (gnus-completing-read
11939 prom (nreverse split-name) nil nil 'gnus-group-history))))
11940 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
11941 encoded)
11942 (when to-newsgroup
11943 (if (or (string= to-newsgroup "")
11944 (string= to-newsgroup prefix))
11945 (setq to-newsgroup default))
11946 (unless to-newsgroup
11947 (error "No group name entered"))
11948 (setq encoded (mm-encode-coding-string
11949 to-newsgroup
11950 (gnus-group-name-charset to-method to-newsgroup)))
11951 (or (gnus-active encoded)
11952 (gnus-activate-group encoded nil nil to-method)
11953 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11954 to-newsgroup))
11955 (or (and (gnus-request-create-group encoded to-method)
11956 (gnus-activate-group encoded nil nil to-method)
11957 (gnus-subscribe-group encoded))
11958 (error "Couldn't create group %s" to-newsgroup)))
11959 (error "No such group: %s" to-newsgroup))
11960 encoded)))
11962 (defvar gnus-summary-save-parts-counter)
11963 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
11965 (defun gnus-summary-save-parts (type dir n &optional reverse)
11966 "Save parts matching TYPE to DIR.
11967 If REVERSE, save parts that do not match TYPE."
11968 (interactive
11969 (list (read-string "Save parts of type: "
11970 (or (car gnus-summary-save-parts-type-history)
11971 gnus-summary-save-parts-default-mime)
11972 'gnus-summary-save-parts-type-history)
11973 (setq gnus-summary-save-parts-last-directory
11974 (read-file-name "Save to directory: "
11975 gnus-summary-save-parts-last-directory
11976 nil t))
11977 current-prefix-arg))
11978 (gnus-summary-iterate n
11979 (let ((gnus-display-mime-function nil)
11980 gnus-article-prepare-hook
11981 gnus-article-decode-hook
11982 gnus-display-mime-function
11983 gnus-break-pages
11984 (gnus-inhibit-treatment t))
11985 (gnus-summary-select-article))
11986 (with-current-buffer gnus-article-buffer
11987 (let ((handles (or gnus-article-mime-handles
11988 (mm-dissect-buffer nil gnus-article-loose-mime)
11989 (and gnus-article-emulate-mime
11990 (mm-uu-dissect))))
11991 (gnus-summary-save-parts-counter 1))
11992 (when handles
11993 (gnus-summary-save-parts-1 type dir handles reverse)
11994 (unless gnus-article-mime-handles ;; Don't destroy this case.
11995 (mm-destroy-parts handles)))))))
11997 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11998 (if (stringp (car handle))
11999 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12000 (cdr handle))
12001 (when (if reverse
12002 (not (string-match type (mm-handle-media-type handle)))
12003 (string-match type (mm-handle-media-type handle)))
12004 (let ((file (expand-file-name
12005 (gnus-map-function
12006 mm-file-name-rewrite-functions
12007 (file-name-nondirectory
12009 (mail-content-type-get
12010 (mm-handle-disposition handle) 'filename)
12011 (mail-content-type-get
12012 (mm-handle-type handle) 'name)
12013 (format "%s.%d.%d" gnus-newsgroup-name
12014 (cdr gnus-article-current)
12015 gnus-summary-save-parts-counter))))
12016 dir)))
12017 (incf gnus-summary-save-parts-counter)
12018 (unless (file-exists-p file)
12019 (mm-save-part-to-file handle file))))))
12021 ;; Summary extract commands
12023 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12024 (let ((inhibit-read-only t)
12025 (article (gnus-summary-article-number))
12026 after-article b e)
12027 (unless (gnus-summary-goto-subject article)
12028 (error "No such article: %d" article))
12029 (gnus-summary-position-point)
12030 ;; If all commands are to be bunched up on one line, we collect
12031 ;; them here.
12032 (unless gnus-view-pseudos-separately
12033 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12034 files action)
12035 (while ps
12036 (setq action (cdr (assq 'action (car ps))))
12037 (setq files (list (cdr (assq 'name (car ps)))))
12038 (while (and ps (cdr ps)
12039 (string= (or action "1")
12040 (or (cdr (assq 'action (cadr ps))) "2")))
12041 (push (cdr (assq 'name (cadr ps))) files)
12042 (setcdr ps (cddr ps)))
12043 (when files
12044 (when (not (string-match "%s" action))
12045 (push " " files))
12046 (push " " files)
12047 (when (assq 'execute (car ps))
12048 (setcdr (assq 'execute (car ps))
12049 (funcall (if (string-match "%s" action)
12050 'format 'concat)
12051 action
12052 (mapconcat
12053 (lambda (f)
12054 (if (equal f " ")
12056 (shell-quote-argument f)))
12057 files " ")))))
12058 (setq ps (cdr ps)))))
12059 (if (and gnus-view-pseudos (not not-view))
12060 (while pslist
12061 (when (assq 'execute (car pslist))
12062 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12063 (eq gnus-view-pseudos 'not-confirm)))
12064 (setq pslist (cdr pslist)))
12065 (save-excursion
12066 (while pslist
12067 (setq after-article (or (cdr (assq 'article (car pslist)))
12068 (gnus-summary-article-number)))
12069 (gnus-summary-goto-subject after-article)
12070 (forward-line 1)
12071 (setq b (point))
12072 (insert " " (file-name-nondirectory
12073 (cdr (assq 'name (car pslist))))
12074 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12075 (setq e (point))
12076 (forward-line -1) ; back to `b'
12077 (gnus-add-text-properties
12078 b (1- e) (list 'gnus-number gnus-reffed-article-number
12079 gnus-mouse-face-prop gnus-mouse-face))
12080 (gnus-data-enter
12081 after-article gnus-reffed-article-number
12082 gnus-unread-mark b (car pslist) 0 (- e b))
12083 (setq gnus-newsgroup-unreads
12084 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12085 gnus-reffed-article-number))
12086 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12087 (setq pslist (cdr pslist)))))))
12089 (defun gnus-pseudos< (p1 p2)
12090 (let ((c1 (cdr (assq 'action p1)))
12091 (c2 (cdr (assq 'action p2))))
12092 (and c1 c2 (string< c1 c2))))
12094 (defun gnus-request-pseudo-article (props)
12095 (cond ((assq 'execute props)
12096 (gnus-execute-command (cdr (assq 'execute props)))))
12097 (let ((gnus-current-article (gnus-summary-article-number)))
12098 (gnus-run-hooks 'gnus-mark-article-hook)))
12100 (defun gnus-execute-command (command &optional automatic)
12101 (save-excursion
12102 (gnus-article-setup-buffer)
12103 (set-buffer gnus-article-buffer)
12104 (setq buffer-read-only nil)
12105 (let ((command (if automatic command
12106 (read-string "Command: " (cons command 0)))))
12107 (erase-buffer)
12108 (insert "$ " command "\n\n")
12109 (if gnus-view-pseudo-asynchronously
12110 (start-process "gnus-execute" (current-buffer) shell-file-name
12111 shell-command-switch command)
12112 (call-process shell-file-name nil t nil
12113 shell-command-switch command)))))
12115 ;; Summary kill commands.
12117 (defun gnus-summary-edit-global-kill (article)
12118 "Edit the \"global\" kill file."
12119 (interactive (list (gnus-summary-article-number)))
12120 (gnus-group-edit-global-kill article))
12122 (defun gnus-summary-edit-local-kill ()
12123 "Edit a local kill file applied to the current newsgroup."
12124 (interactive)
12125 (setq gnus-current-headers (gnus-summary-article-header))
12126 (gnus-group-edit-local-kill
12127 (gnus-summary-article-number) gnus-newsgroup-name))
12129 ;;; Header reading.
12131 (defun gnus-read-header (id &optional header)
12132 "Read the headers of article ID and enter them into the Gnus system."
12133 (let ((group gnus-newsgroup-name)
12134 (gnus-override-method
12136 gnus-override-method
12137 (and (gnus-news-group-p gnus-newsgroup-name)
12138 (car (gnus-refer-article-methods)))))
12139 where)
12140 ;; First we check to see whether the header in question is already
12141 ;; fetched.
12142 (if (stringp id)
12143 ;; This is a Message-ID.
12144 (setq header (or header (gnus-id-to-header id)))
12145 ;; This is an article number.
12146 (setq header (or header (gnus-summary-article-header id))))
12147 (if (and header
12148 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12149 ;; We have found the header.
12150 header
12151 ;; We have to really fetch the header to this article.
12152 (with-current-buffer nntp-server-buffer
12153 (when (setq where (gnus-request-head id group))
12154 (nnheader-fold-continuation-lines)
12155 (goto-char (point-max))
12156 (insert ".\n")
12157 (goto-char (point-min))
12158 (insert "211 ")
12159 (princ (cond
12160 ((numberp id) id)
12161 ((cdr where) (cdr where))
12162 (header (mail-header-number header))
12163 (t gnus-reffed-article-number))
12164 (current-buffer))
12165 (insert " Article retrieved.\n"))
12166 (if (or (not where)
12167 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12168 () ; Malformed head.
12169 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12170 (when (and (stringp id)
12172 (not (string= (gnus-group-real-name group)
12173 (car where)))
12174 (not (gnus-server-equal gnus-override-method
12175 (gnus-group-method group)))))
12176 ;; If we fetched by Message-ID and the article came from
12177 ;; a different group (or server), we fudge some bogus
12178 ;; article numbers for this article.
12179 (mail-header-set-number header gnus-reffed-article-number))
12180 (with-current-buffer gnus-summary-buffer
12181 (decf gnus-reffed-article-number)
12182 (gnus-remove-header (mail-header-number header))
12183 (push header gnus-newsgroup-headers)
12184 (setq gnus-current-headers header)
12185 (push (mail-header-number header) gnus-newsgroup-limit)))
12186 header)))))
12188 (defun gnus-remove-header (number)
12189 "Remove header NUMBER from `gnus-newsgroup-headers'."
12190 (if (and gnus-newsgroup-headers
12191 (= number (mail-header-number (car gnus-newsgroup-headers))))
12192 (pop gnus-newsgroup-headers)
12193 (let ((headers gnus-newsgroup-headers))
12194 (while (and (cdr headers)
12195 (not (= number (mail-header-number (cadr headers)))))
12196 (pop headers))
12197 (when (cdr headers)
12198 (setcdr headers (cddr headers))))))
12201 ;;; summary highlights
12204 (defun gnus-highlight-selected-summary ()
12205 "Highlight selected article in summary buffer."
12206 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12207 (when gnus-summary-selected-face
12208 (save-excursion
12209 (let* ((beg (point-at-bol))
12210 (end (point-at-eol))
12211 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12212 (from (if (get-text-property beg gnus-mouse-face-prop)
12214 (or (next-single-property-change
12215 beg gnus-mouse-face-prop nil end)
12216 beg)))
12218 (if (= from end)
12219 (- from 2)
12220 (or (next-single-property-change
12221 from gnus-mouse-face-prop nil end)
12222 end))))
12223 ;; If no mouse-face prop on line we will have to = from = end,
12224 ;; so we highlight the entire line instead.
12225 (when (= (+ to 2) from)
12226 (setq from beg)
12227 (setq to end))
12228 (if gnus-newsgroup-selected-overlay
12229 ;; Move old overlay.
12230 (gnus-move-overlay
12231 gnus-newsgroup-selected-overlay from to (current-buffer))
12232 ;; Create new overlay.
12233 (gnus-overlay-put
12234 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12235 'face gnus-summary-selected-face))))))
12237 (defvar gnus-summary-highlight-line-cached nil)
12238 (defvar gnus-summary-highlight-line-trigger nil)
12240 (defun gnus-summary-highlight-line-0 ()
12241 (if (and (eq gnus-summary-highlight-line-trigger
12242 gnus-summary-highlight)
12243 gnus-summary-highlight-line-cached)
12244 gnus-summary-highlight-line-cached
12245 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12246 gnus-summary-highlight-line-cached
12247 (let* ((cond (list 'cond))
12248 (c cond)
12249 (list gnus-summary-highlight))
12250 (while list
12251 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12252 nil))
12253 (setq c (cdr c)
12254 list (cdr list)))
12255 (gnus-byte-compile (list 'lambda nil cond))))))
12257 (defun gnus-summary-highlight-line ()
12258 "Highlight current line according to `gnus-summary-highlight'."
12259 (let* ((beg (point-at-bol))
12260 (article (or (gnus-summary-article-number) gnus-current-article))
12261 (score (or (cdr (assq article
12262 gnus-newsgroup-scored))
12263 gnus-summary-default-score 0))
12264 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12265 (inhibit-read-only t)
12266 (default gnus-summary-default-score)
12267 (default-high gnus-summary-default-high-score)
12268 (default-low gnus-summary-default-low-score)
12269 (uncached (and gnus-summary-use-undownloaded-faces
12270 (memq article gnus-newsgroup-undownloaded)
12271 (not (memq article gnus-newsgroup-cached)))))
12272 (let ((face (funcall (gnus-summary-highlight-line-0))))
12273 (unless (eq face (get-text-property beg 'face))
12274 (gnus-put-text-property-excluding-characters-with-faces
12275 beg (point-at-eol) 'face
12276 (setq face (if (boundp face) (symbol-value face) face)))
12277 (when gnus-summary-highlight-line-function
12278 (funcall gnus-summary-highlight-line-function article face))))))
12280 (defun gnus-update-read-articles (group unread &optional compute)
12281 "Update the list of read articles in GROUP.
12282 UNREAD is a sorted list."
12283 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12284 (info (gnus-get-info group))
12285 (prev 1)
12286 read)
12287 (if (or (not info) (not active))
12288 ;; There is no info on this group if it was, in fact,
12289 ;; killed. Gnus stores no information on killed groups, so
12290 ;; there's nothing to be done.
12291 ;; One could store the information somewhere temporarily,
12292 ;; perhaps... Hmmm...
12294 ;; Remove any negative articles numbers.
12295 (while (and unread (< (car unread) 0))
12296 (setq unread (cdr unread)))
12297 ;; Remove any expired article numbers
12298 (while (and unread (< (car unread) (car active)))
12299 (setq unread (cdr unread)))
12300 ;; Compute the ranges of read articles by looking at the list of
12301 ;; unread articles.
12302 (while unread
12303 (when (/= (car unread) prev)
12304 (push (if (= prev (1- (car unread))) prev
12305 (cons prev (1- (car unread))))
12306 read))
12307 (setq prev (1+ (car unread)))
12308 (setq unread (cdr unread)))
12309 (when (<= prev (cdr active))
12310 (push (cons prev (cdr active)) read))
12311 (setq read (if (> (length read) 1) (nreverse read) read))
12312 (if compute
12313 read
12314 (save-excursion
12315 (let (setmarkundo)
12316 ;; Propagate the read marks to the backend.
12317 (when (and gnus-propagate-marks
12318 (gnus-check-backend-function 'request-set-mark group))
12319 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12320 (add (gnus-remove-from-range read (gnus-info-read info))))
12321 (when (or add del)
12322 (unless (gnus-check-group group)
12323 (error "Can't open server for %s" group))
12324 (gnus-request-set-mark
12325 group (delq nil (list (if add (list add 'add '(read)))
12326 (if del (list del 'del '(read))))))
12327 (setq setmarkundo
12328 `(gnus-request-set-mark
12329 ,group
12330 ',(delq nil (list
12331 (if del (list del 'add '(read)))
12332 (if add (list add 'del '(read))))))))))
12333 (set-buffer gnus-group-buffer)
12334 (gnus-undo-register
12335 `(progn
12336 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12337 (gnus-info-set-read ',info ',(gnus-info-read info))
12338 (gnus-get-unread-articles-in-group ',info
12339 (gnus-active ,group))
12340 (gnus-group-update-group ,group t)
12341 ,setmarkundo))))
12342 ;; Enter this list into the group info.
12343 (gnus-info-set-read info read)
12344 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12345 (gnus-get-unread-articles-in-group info (gnus-active group))
12346 t))))
12348 (defun gnus-offer-save-summaries ()
12349 "Offer to save all active summary buffers."
12350 (let (buffers)
12351 ;; Go through all buffers and find all summaries.
12352 (dolist (buffer (buffer-list))
12353 (when (and (setq buffer (buffer-name buffer))
12354 (string-match "Summary" buffer)
12355 (with-current-buffer buffer
12356 ;; We check that this is, indeed, a summary buffer.
12357 (and (eq major-mode 'gnus-summary-mode)
12358 ;; Also make sure this isn't bogus.
12359 gnus-newsgroup-prepared
12360 ;; Also make sure that this isn't a
12361 ;; dead summary buffer.
12362 (not gnus-dead-summary-mode))))
12363 (push buffer buffers)))
12364 ;; Go through all these summary buffers and offer to save them.
12365 (when buffers
12366 (save-excursion
12367 (map-y-or-n-p
12368 "Update summary buffer %s? "
12369 (lambda (buf)
12370 (switch-to-buffer buf)
12371 (gnus-summary-exit))
12372 buffers)))))
12374 (defun gnus-summary-setup-default-charset ()
12375 "Setup newsgroup default charset."
12376 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12377 (setq gnus-newsgroup-charset nil)
12378 (let* ((ignored-charsets
12379 (or gnus-newsgroup-ephemeral-ignored-charsets
12380 (append
12381 (and gnus-newsgroup-name
12382 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12383 gnus-newsgroup-ignored-charsets))))
12384 (setq gnus-newsgroup-charset
12385 (or gnus-newsgroup-ephemeral-charset
12386 (and gnus-newsgroup-name
12387 (gnus-parameter-charset gnus-newsgroup-name))
12388 gnus-default-charset))
12389 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12390 ignored-charsets))))
12393 ;;; Mime Commands
12396 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12397 "Display the current article buffer fully MIME-buttonized.
12398 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12399 treated as multipart/mixed."
12400 (interactive "P")
12401 (require 'gnus-art)
12402 (let ((gnus-unbuttonized-mime-types nil)
12403 (gnus-mime-display-multipart-as-mixed show-all-parts))
12404 (gnus-summary-show-article)))
12406 (defun gnus-summary-repair-multipart (article)
12407 "Add a Content-Type header to a multipart article without one."
12408 (interactive (list (gnus-summary-article-number)))
12409 (gnus-with-article article
12410 (message-narrow-to-head)
12411 (message-remove-header "Mime-Version")
12412 (goto-char (point-max))
12413 (insert "Mime-Version: 1.0\n")
12414 (widen)
12415 (when (search-forward "\n--" nil t)
12416 (let ((separator (buffer-substring (point) (point-at-eol))))
12417 (message-narrow-to-head)
12418 (message-remove-header "Content-Type")
12419 (goto-char (point-max))
12420 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12421 separator))
12422 (widen))))
12423 (let (gnus-mark-article-hook)
12424 (gnus-summary-select-article t t nil article)))
12426 (defun gnus-summary-toggle-display-buttonized ()
12427 "Toggle the buttonizing of the article buffer."
12428 (interactive)
12429 (require 'gnus-art)
12430 (if (setq gnus-inhibit-mime-unbuttonizing
12431 (not gnus-inhibit-mime-unbuttonizing))
12432 (let ((gnus-unbuttonized-mime-types nil))
12433 (gnus-summary-show-article))
12434 (gnus-summary-show-article)))
12437 ;;; Generic summary marking commands
12440 (defvar gnus-summary-marking-alist
12441 '((read gnus-del-mark "d")
12442 (unread gnus-unread-mark "u")
12443 (ticked gnus-ticked-mark "!")
12444 (dormant gnus-dormant-mark "?")
12445 (expirable gnus-expirable-mark "e"))
12446 "An alist of names/marks/keystrokes.")
12448 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12449 (defvar gnus-summary-mark-map)
12451 (defun gnus-summary-make-all-marking-commands ()
12452 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12453 (dolist (elem gnus-summary-marking-alist)
12454 (apply 'gnus-summary-make-marking-command elem)))
12456 (defun gnus-summary-make-marking-command (name mark keystroke)
12457 (let ((map (make-sparse-keymap)))
12458 (define-key gnus-summary-generic-mark-map keystroke map)
12459 (dolist (lway `((next "next" next nil "n")
12460 (next-unread "next unread" next t "N")
12461 (prev "previous" prev nil "p")
12462 (prev-unread "previous unread" prev t "P")
12463 (nomove "" nil nil ,keystroke)))
12464 (let ((func (gnus-summary-make-marking-command-1
12465 mark (car lway) lway name)))
12466 (setq func (eval func))
12467 (define-key map (nth 4 lway) func)))))
12469 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12470 `(defun ,(intern
12471 (format "gnus-summary-put-mark-as-%s%s"
12472 name (if (eq way 'nomove)
12474 (concat "-" (symbol-name way)))))
12476 ,(format
12477 "Mark the current article as %s%s.
12478 If N, the prefix, then repeat N times.
12479 If N is negative, move in reverse order.
12480 The difference between N and the actual number of articles marked is
12481 returned."
12482 name (cadr lway))
12483 (interactive "p")
12484 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12486 (defun gnus-summary-generic-mark (n mark move unread)
12487 "Mark N articles with MARK."
12488 (unless (eq major-mode 'gnus-summary-mode)
12489 (error "This command can only be used in the summary buffer"))
12490 (gnus-summary-show-thread)
12491 (let ((nummove
12492 (cond
12493 ((eq move 'next) 1)
12494 ((eq move 'prev) -1)
12495 (t 0))))
12496 (if (zerop nummove)
12497 (setq n 1)
12498 (when (< n 0)
12499 (setq n (abs n)
12500 nummove (* -1 nummove))))
12501 (while (and (> n 0)
12502 (gnus-summary-mark-article nil mark)
12503 (zerop (gnus-summary-next-subject nummove unread t)))
12504 (setq n (1- n)))
12505 (when (/= 0 n)
12506 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12507 (gnus-summary-recenter)
12508 (gnus-summary-position-point)
12509 (gnus-set-mode-line 'summary)
12512 (defun gnus-summary-insert-articles (articles)
12513 (when (setq articles
12514 (gnus-sorted-difference articles
12515 (mapcar (lambda (h)
12516 (mail-header-number h))
12517 gnus-newsgroup-headers)))
12518 (setq gnus-newsgroup-headers
12519 (gnus-merge 'list
12520 gnus-newsgroup-headers
12521 (gnus-fetch-headers articles)
12522 'gnus-article-sort-by-number))
12523 ;; Suppress duplicates?
12524 (when gnus-suppress-duplicates
12525 (gnus-dup-suppress-articles))
12527 (if (and gnus-fetch-old-headers
12528 (eq gnus-headers-retrieved-by 'nov))
12529 ;; We might want to build some more threads first.
12530 (if (eq gnus-fetch-old-headers 'invisible)
12531 (gnus-build-all-threads)
12532 (gnus-build-old-threads))
12533 ;; Mark the inserted articles that are unread as unread.
12534 (setq gnus-newsgroup-unreads
12535 (gnus-sorted-nunion
12536 gnus-newsgroup-unreads
12537 (gnus-sorted-nintersection
12538 (gnus-list-of-unread-articles gnus-newsgroup-name)
12539 articles)))
12540 ;; Mark the inserted articles as selected so that the information
12541 ;; of the marks having been changed by a user may be updated when
12542 ;; exiting this group. See `gnus-summary-update-info'.
12543 (dolist (art articles)
12544 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12545 ;; Let the Gnus agent mark articles as read.
12546 (when gnus-agent
12547 (gnus-agent-get-undownloaded-list))
12548 ;; Remove list identifiers from subject
12549 (when gnus-list-identifiers
12550 (gnus-summary-remove-list-identifiers))
12551 ;; First and last article in this newsgroup.
12552 (when gnus-newsgroup-headers
12553 (setq gnus-newsgroup-begin
12554 (mail-header-number (car gnus-newsgroup-headers))
12555 gnus-newsgroup-end
12556 (mail-header-number
12557 (gnus-last-element gnus-newsgroup-headers))))
12558 (when gnus-use-scoring
12559 (gnus-possibly-score-headers))))
12561 (defun gnus-summary-insert-old-articles (&optional all)
12562 "Insert all old articles in this group.
12563 If ALL is non-nil, already read articles become readable.
12564 If ALL is a number, fetch this number of articles."
12565 (interactive "P")
12566 (prog1
12567 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12568 older len)
12569 (setq older
12570 ;; Some nntp servers lie about their active range. When
12571 ;; this happens, the active range can be in the millions.
12572 ;; Use a compressed range to avoid creating a huge list.
12573 (gnus-range-difference (list gnus-newsgroup-active) old))
12574 (setq len (gnus-range-length older))
12575 (cond
12576 ((null older) nil)
12577 ((numberp all)
12578 (if (< all len)
12579 (let ((older-range (nreverse older)))
12580 (setq older nil)
12582 (while (> all 0)
12583 (let* ((r (pop older-range))
12584 (min (if (numberp r) r (car r)))
12585 (max (if (numberp r) r (cdr r))))
12586 (while (and (<= min max)
12587 (> all 0))
12588 (push max older)
12589 (setq all (1- all)
12590 max (1- max))))))
12591 (setq older (gnus-uncompress-range older))))
12592 (all
12593 (setq older (gnus-uncompress-range older)))
12595 (when (and (numberp gnus-large-newsgroup)
12596 (> len gnus-large-newsgroup))
12597 (let* ((cursor-in-echo-area nil)
12598 (initial (gnus-parameter-large-newsgroup-initial
12599 gnus-newsgroup-name))
12600 (input
12601 (read-string
12602 (format
12603 "How many articles from %s (%s %d): "
12604 (gnus-group-decoded-name gnus-newsgroup-name)
12605 (if initial "max" "default")
12606 len)
12607 (if initial
12608 (cons (number-to-string initial)
12609 0)))))
12610 (unless (string-match "^[ \t]*$" input)
12611 (setq all (string-to-number input))
12612 (if (< all len)
12613 (let ((older-range (nreverse older)))
12614 (setq older nil)
12616 (while (> all 0)
12617 (let* ((r (pop older-range))
12618 (min (if (numberp r) r (car r)))
12619 (max (if (numberp r) r (cdr r))))
12620 (while (and (<= min max)
12621 (> all 0))
12622 (push max older)
12623 (setq all (1- all)
12624 max (1- max))))))))))
12625 (setq older (gnus-uncompress-range older))))
12626 (if (not older)
12627 (message "No old news.")
12628 (gnus-summary-insert-articles older)
12629 (gnus-summary-limit (gnus-sorted-nunion old older))))
12630 (gnus-summary-position-point)))
12632 (defun gnus-summary-insert-new-articles ()
12633 "Insert all new articles in this group."
12634 (interactive)
12635 (prog1
12636 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12637 (old-high gnus-newsgroup-highest)
12638 (nnmail-fetched-sources (list t))
12639 i new)
12640 (setq gnus-newsgroup-active
12641 (gnus-copy-sequence
12642 (gnus-activate-group gnus-newsgroup-name 'scan)))
12643 (setq i (cdr gnus-newsgroup-active)
12644 gnus-newsgroup-highest i)
12645 (while (> i old-high)
12646 (push i new)
12647 (decf i))
12648 (if (not new)
12649 (message "No gnus is bad news")
12650 (gnus-summary-insert-articles new)
12651 (setq gnus-newsgroup-unreads
12652 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12653 (gnus-summary-limit (gnus-sorted-nunion old new))))
12654 (gnus-summary-position-point)))
12656 ;;; Bookmark support for Gnus.
12657 (declare-function bookmark-make-record-default
12658 "bookmark" (&optional no-file no-context posn))
12659 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12660 (declare-function bookmark-default-handler "bookmark" (bmk))
12661 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12662 (defvar bookmark-yank-point)
12663 (defvar bookmark-current-buffer)
12665 (defun gnus-summary-bookmark-make-record ()
12666 "Make a bookmark entry for a Gnus summary buffer."
12667 (let (pos buf)
12668 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12669 (save-restriction ; FIXME is it necessary to widen?
12670 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12671 (setq buf "art") ; We are recording bookmark from article buffer.
12672 (setq bookmark-yank-point (point))
12673 (setq bookmark-current-buffer (current-buffer))
12674 (gnus-article-show-summary)) ; Go back in summary buffer.
12675 ;; We are now recording bookmark from summary buffer.
12676 (unless buf (setq buf "sum"))
12677 (let* ((subject (elt (gnus-summary-article-header) 1))
12678 (grp (car gnus-article-current))
12679 (art (cdr gnus-article-current))
12680 (head (gnus-summary-article-header art))
12681 (id (mail-header-id head)))
12682 `(,subject
12683 ,@(condition-case nil
12684 (bookmark-make-record-default 'no-file 'no-context pos)
12685 (wrong-number-of-arguments
12686 (bookmark-make-record-default 'point-only)))
12687 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12688 (group . ,grp) (article . ,art)
12689 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12691 ;;;###autoload
12692 (defun gnus-summary-bookmark-jump (bookmark)
12693 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12694 BOOKMARK is a bookmark name or a bookmark record."
12695 (let ((group (bookmark-prop-get bookmark 'group))
12696 (article (bookmark-prop-get bookmark 'article))
12697 (id (bookmark-prop-get bookmark 'message-id))
12698 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12699 (gnus-fetch-group group (list article))
12700 (gnus-summary-insert-cached-articles)
12701 (gnus-summary-goto-article id nil 'force)
12702 ;; FIXME we have to wait article buffer is ready (only large buffer)
12703 ;; Is there a better solution to know that?
12704 ;; If we don't wait `bookmark-default-handler' will have no chance
12705 ;; to set position. However there is no error, just wrong pos.
12706 (sit-for 1)
12707 (when (string= buf "Gnus-art")
12708 (other-window 1))
12709 (bookmark-default-handler
12710 `(""
12711 (buffer . ,(current-buffer))
12712 . ,(bookmark-get-bookmark-record bookmark)))))
12714 (gnus-summary-make-all-marking-commands)
12716 (gnus-ems-redefine)
12718 (provide 'gnus-sum)
12720 (run-hooks 'gnus-sum-load-hook)
12722 ;; Local Variables:
12723 ;; coding: iso-8859-1
12724 ;; End:
12726 ;;; gnus-sum.el ends here